mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 00:12:16 +02:00
Extracted setOptionsCursor function
This commit is contained in:
parent
e4a550550e
commit
562eb1d334
@ -949,10 +949,29 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setCursor(cursor: number): boolean {
|
setCursor(cursor: number): boolean {
|
||||||
let changed: boolean;
|
|
||||||
|
|
||||||
if (this.optionsMode) {
|
if (this.optionsMode) {
|
||||||
changed = this.optionsCursor !== cursor;
|
return this.setOptionsCursor(cursor);
|
||||||
|
}
|
||||||
|
const changed = this.cursor !== cursor;
|
||||||
|
if (changed) {
|
||||||
|
this.lastCursor = this.cursor;
|
||||||
|
this.cursor = cursor;
|
||||||
|
if (this.lastCursor < 6) {
|
||||||
|
this.partySlots[this.lastCursor].deselect();
|
||||||
|
} else if (this.lastCursor === 6) {
|
||||||
|
this.partyCancelButton.deselect();
|
||||||
|
}
|
||||||
|
if (cursor < 6) {
|
||||||
|
this.partySlots[cursor].select();
|
||||||
|
} else if (cursor === 6) {
|
||||||
|
this.partyCancelButton.select();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
setOptionsCursor(cursor: number): boolean {
|
||||||
|
const changed = this.optionsCursor !== cursor;
|
||||||
let isScroll = false;
|
let isScroll = false;
|
||||||
if (changed && this.optionsScroll) {
|
if (changed && this.optionsScroll) {
|
||||||
if (Math.abs(cursor - this.optionsCursor) === this.options.length - 1) {
|
if (Math.abs(cursor - this.optionsCursor) === this.options.length - 1) {
|
||||||
@ -990,23 +1009,6 @@ export default class PartyUiHandler extends MessageUiHandler {
|
|||||||
8 - this.optionsBg.displayWidth,
|
8 - this.optionsBg.displayWidth,
|
||||||
-19 - 16 * (this.options.length - 1 - this.optionsCursor),
|
-19 - 16 * (this.options.length - 1 - this.optionsCursor),
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
changed = this.cursor !== cursor;
|
|
||||||
if (changed) {
|
|
||||||
this.lastCursor = this.cursor;
|
|
||||||
this.cursor = cursor;
|
|
||||||
if (this.lastCursor < 6) {
|
|
||||||
this.partySlots[this.lastCursor].deselect();
|
|
||||||
} else if (this.lastCursor === 6) {
|
|
||||||
this.partyCancelButton.deselect();
|
|
||||||
}
|
|
||||||
if (cursor < 6) {
|
|
||||||
this.partySlots[cursor].select();
|
|
||||||
} else if (cursor === 6) {
|
|
||||||
this.partyCancelButton.select();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user