[UI/UX] Shop cursor freedom (#5110)

* Allowing cursor in shop to cycle horizontally

* Improved cycling of commands

---------

Co-authored-by: damocleas <damocleas25@gmail.com>
This commit is contained in:
Wlowscha 2025-01-15 07:18:24 +01:00 committed by GitHub
parent d5f84cf3df
commit 7ae216f0d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 6 deletions

View File

@ -364,6 +364,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
success = this.setCursor(0);
} else if (this.rowCursor < this.shopOptionsRows.length + 1) {
success = this.setRowCursor(this.rowCursor + 1);
} else {
success = this.setRowCursor(0);
}
break;
case Button.DOWN:
@ -371,13 +373,15 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
success = this.setRowCursor(this.rowCursor - 1);
} else if (this.lockRarityButtonContainer.visible && this.cursor === 0) {
success = this.setCursor(3);
} else {
success = this.setRowCursor(this.shopOptionsRows.length + 1);
}
break;
case Button.LEFT:
if (!this.rowCursor) {
switch (this.cursor) {
case 0:
success = false;
success = this.setCursor(2);
break;
case 1:
if (this.lockRarityButtonContainer.visible) {
@ -395,11 +399,21 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
success = false;
}
break;
case 3:
if (this.lockRarityButtonContainer.visible) {
success = this.setCursor(2);
} else {
success = false;
}
}
} else if (this.cursor) {
success = this.setCursor(this.cursor - 1);
} else if (this.rowCursor === 1 && this.rerollButtonContainer.visible) {
success = this.setRowCursor(0);
} else {
if (this.rowCursor === 1 && this.options.length === 0) {
success = false;
} else {
success = this.setCursor(this.getRowItems(this.rowCursor) - 1);
}
}
break;
case Button.RIGHT:
@ -416,7 +430,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
success = this.setCursor(2);
break;
case 2:
success = false;
success = this.setCursor(0);
break;
case 3:
if (this.transferButtonContainer.visible) {
@ -428,8 +442,12 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
}
} else if (this.cursor < this.getRowItems(this.rowCursor) - 1) {
success = this.setCursor(this.cursor + 1);
} else if (this.rowCursor === 1 && this.transferButtonContainer.visible) {
success = this.setRowCursor(0);
} else {
if (this.rowCursor === 1 && this.options.length === 0) {
success = this.setRowCursor(0);
} else {
success = this.setCursor(0);
}
}
break;
}
@ -519,6 +537,14 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
newCursor = 2;
}
}
// Allows to find lock rarity button when looping from the top
if (rowCursor === 0 && lastRowCursor > 1 && newCursor === 0 && this.lockRarityButtonContainer.visible) {
newCursor = 3;
}
// Allows to loop to top when lock rarity button is shown
if (rowCursor === this.shopOptionsRows.length + 1 && lastRowCursor === 0 && this.cursor === 3) {
newCursor = 0;
}
this.cursor = -1;
this.setCursor(newCursor);
return true;