1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 01:34:18 +00:00

Pause doc: item page cursor movement (#2249)

* doc item page cursor movement

* review
This commit is contained in:
Dragorn421 2024-10-02 06:35:50 +02:00 committed by GitHub
parent 49759e42d7
commit 8ced66d249
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -156,31 +156,38 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
PRINTF("now=%d ccc=%d\n", cursorPoint, cursorItem); PRINTF("now=%d ccc=%d\n", cursorPoint, cursorItem);
do { do {
if (pauseCtx->stickAdjX < -30) { if (pauseCtx->stickAdjX < -30) { // left
// if not on the left-most column
if (pauseCtx->cursorX[PAUSE_ITEM] != 0) { if (pauseCtx->cursorX[PAUSE_ITEM] != 0) {
// move left
pauseCtx->cursorX[PAUSE_ITEM]--; pauseCtx->cursorX[PAUSE_ITEM]--;
pauseCtx->cursorPoint[PAUSE_ITEM] -= 1; pauseCtx->cursorPoint[PAUSE_ITEM] -= 1;
// if there's an item there, stop there
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] !=
ITEM_NONE) { ITEM_NONE) {
cursorMoveResult = 1; cursorMoveResult = 1;
} }
} else { } else {
pauseCtx->cursorX[PAUSE_ITEM] = cursorX; // move the cursor to its initial horizontal position and try find an item on the next line
pauseCtx->cursorY[PAUSE_ITEM]++;
if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { pauseCtx->cursorX[PAUSE_ITEM] = cursorX;
pauseCtx->cursorY[PAUSE_ITEM]++;
if (pauseCtx->cursorY[PAUSE_ITEM] >= ITEM_GRID_ROWS) {
pauseCtx->cursorY[PAUSE_ITEM] = 0; pauseCtx->cursorY[PAUSE_ITEM] = 0;
} }
pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorPoint[PAUSE_ITEM] =
pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * ITEM_GRID_COLS);
if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { if (pauseCtx->cursorPoint[PAUSE_ITEM] >= (ITEM_GRID_ROWS * ITEM_GRID_COLS)) {
pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM];
} }
if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) { if (cursorY == pauseCtx->cursorY[PAUSE_ITEM]) {
// there is no item to the left of the initial position, on any line
pauseCtx->cursorX[PAUSE_ITEM] = cursorX; pauseCtx->cursorX[PAUSE_ITEM] = cursorX;
pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint; pauseCtx->cursorPoint[PAUSE_ITEM] = cursorPoint;
@ -190,7 +197,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
} }
} }
} else if (pauseCtx->stickAdjX > 30) { } else if (pauseCtx->stickAdjX > 30) {
if (pauseCtx->cursorX[PAUSE_ITEM] < 5) { if (pauseCtx->cursorX[PAUSE_ITEM] < (ITEM_GRID_COLS - 1)) {
pauseCtx->cursorX[PAUSE_ITEM]++; pauseCtx->cursorX[PAUSE_ITEM]++;
pauseCtx->cursorPoint[PAUSE_ITEM] += 1; pauseCtx->cursorPoint[PAUSE_ITEM] += 1;
@ -202,14 +209,14 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
pauseCtx->cursorX[PAUSE_ITEM] = cursorX; pauseCtx->cursorX[PAUSE_ITEM] = cursorX;
pauseCtx->cursorY[PAUSE_ITEM]++; pauseCtx->cursorY[PAUSE_ITEM]++;
if (pauseCtx->cursorY[PAUSE_ITEM] >= 4) { if (pauseCtx->cursorY[PAUSE_ITEM] >= ITEM_GRID_ROWS) {
pauseCtx->cursorY[PAUSE_ITEM] = 0; pauseCtx->cursorY[PAUSE_ITEM] = 0;
} }
pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorPoint[PAUSE_ITEM] =
pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * 6); pauseCtx->cursorX[PAUSE_ITEM] + (pauseCtx->cursorY[PAUSE_ITEM] * ITEM_GRID_COLS);
if (pauseCtx->cursorPoint[PAUSE_ITEM] >= 24) { if (pauseCtx->cursorPoint[PAUSE_ITEM] >= (ITEM_GRID_ROWS * ITEM_GRID_COLS)) {
pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM]; pauseCtx->cursorPoint[PAUSE_ITEM] = pauseCtx->cursorX[PAUSE_ITEM];
} }
@ -251,20 +258,20 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
break; break;
} }
cursorY = cursorY + 1; cursorY += 1;
cursorPoint = cursorPoint + 6; cursorPoint += ITEM_GRID_COLS;
if (cursorY >= 4) { if (cursorY >= ITEM_GRID_ROWS) {
cursorY = 0; cursorY = 0;
cursorPoint = cursorX + 1; cursorPoint = cursorX + 1;
cursorX = cursorPoint; cursorX = cursorPoint;
if (cursorX >= 6) { if (cursorX >= ITEM_GRID_COLS) {
KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT); KaleidoScope_MoveCursorToSpecialPos(play, PAUSE_CURSOR_PAGE_RIGHT);
break; break;
} }
} }
} }
} }
} else { } else { // cursorSpecialPos == PAUSE_CURSOR_PAGE_RIGHT
if (pauseCtx->stickAdjX < -30) { if (pauseCtx->stickAdjX < -30) {
pauseCtx->nameDisplayTimer = 0; pauseCtx->nameDisplayTimer = 0;
pauseCtx->cursorSpecialPos = 0; pauseCtx->cursorSpecialPos = 0;
@ -272,7 +279,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
cursorPoint = cursorX = 5; cursorPoint = cursorX = ITEM_GRID_COLS - 1;
cursorY = 0; cursorY = 0;
while (true) { while (true) {
if (gSaveContext.save.info.inventory.items[cursorPoint] != ITEM_NONE) { if (gSaveContext.save.info.inventory.items[cursorPoint] != ITEM_NONE) {
@ -283,9 +290,9 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
break; break;
} }
cursorY = cursorY + 1; cursorY += 1;
cursorPoint = cursorPoint + 6; cursorPoint += ITEM_GRID_COLS;
if (cursorY >= 4) { if (cursorY >= ITEM_GRID_ROWS) {
cursorY = 0; cursorY = 0;
cursorPoint = cursorX - 1; cursorPoint = cursorX - 1;
cursorX = cursorPoint; cursorX = cursorPoint;
@ -309,7 +316,7 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
if (pauseCtx->stickAdjY > 30) { if (pauseCtx->stickAdjY > 30) {
if (pauseCtx->cursorY[PAUSE_ITEM] != 0) { if (pauseCtx->cursorY[PAUSE_ITEM] != 0) {
pauseCtx->cursorY[PAUSE_ITEM]--; pauseCtx->cursorY[PAUSE_ITEM]--;
pauseCtx->cursorPoint[PAUSE_ITEM] -= 6; pauseCtx->cursorPoint[PAUSE_ITEM] -= ITEM_GRID_COLS;
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] !=
ITEM_NONE) { ITEM_NONE) {
@ -322,9 +329,9 @@ void KaleidoScope_DrawItemSelect(PlayState* play) {
cursorMoveResult = 2; cursorMoveResult = 2;
} }
} else if (pauseCtx->stickAdjY < -30) { } else if (pauseCtx->stickAdjY < -30) {
if (pauseCtx->cursorY[PAUSE_ITEM] < 3) { if (pauseCtx->cursorY[PAUSE_ITEM] < (ITEM_GRID_ROWS - 1)) {
pauseCtx->cursorY[PAUSE_ITEM]++; pauseCtx->cursorY[PAUSE_ITEM]++;
pauseCtx->cursorPoint[PAUSE_ITEM] += 6; pauseCtx->cursorPoint[PAUSE_ITEM] += ITEM_GRID_COLS;
if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] != if (gSaveContext.save.info.inventory.items[pauseCtx->cursorPoint[PAUSE_ITEM]] !=
ITEM_NONE) { ITEM_NONE) {