mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Extracted setOptionsCursor function
This commit is contained in:
parent
e4a550550e
commit
562eb1d334
@ -949,64 +949,66 @@ 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);
|
||||||
let isScroll = false;
|
}
|
||||||
if (changed && this.optionsScroll) {
|
const changed = this.cursor !== cursor;
|
||||||
if (Math.abs(cursor - this.optionsCursor) === this.options.length - 1) {
|
if (changed) {
|
||||||
this.optionsScrollCursor = cursor ? this.optionsScrollTotal - 8 : 0;
|
this.lastCursor = this.cursor;
|
||||||
this.updateOptions();
|
this.cursor = cursor;
|
||||||
} else {
|
if (this.lastCursor < 6) {
|
||||||
const isDown = cursor && cursor > this.optionsCursor;
|
this.partySlots[this.lastCursor].deselect();
|
||||||
if (isDown) {
|
} else if (this.lastCursor === 6) {
|
||||||
if (this.options[cursor] === PartyOption.SCROLL_DOWN) {
|
this.partyCancelButton.deselect();
|
||||||
isScroll = true;
|
|
||||||
this.optionsScrollCursor++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!cursor && this.optionsScrollCursor) {
|
|
||||||
isScroll = true;
|
|
||||||
this.optionsScrollCursor--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isScroll && this.optionsScrollCursor === 1) {
|
|
||||||
this.optionsScrollCursor += isDown ? 1 : -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isScroll) {
|
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;
|
||||||
|
if (changed && this.optionsScroll) {
|
||||||
|
if (Math.abs(cursor - this.optionsCursor) === this.options.length - 1) {
|
||||||
|
this.optionsScrollCursor = cursor ? this.optionsScrollTotal - 8 : 0;
|
||||||
this.updateOptions();
|
this.updateOptions();
|
||||||
} else {
|
} else {
|
||||||
this.optionsCursor = cursor;
|
const isDown = cursor && cursor > this.optionsCursor;
|
||||||
}
|
if (isDown) {
|
||||||
if (!this.optionsCursorObj) {
|
if (this.options[cursor] === PartyOption.SCROLL_DOWN) {
|
||||||
this.optionsCursorObj = globalScene.add.image(0, 0, "cursor");
|
isScroll = true;
|
||||||
this.optionsCursorObj.setOrigin(0, 0);
|
this.optionsScrollCursor++;
|
||||||
this.optionsContainer.add(this.optionsCursorObj);
|
}
|
||||||
}
|
} else {
|
||||||
this.optionsCursorObj.setPosition(
|
if (!cursor && this.optionsScrollCursor) {
|
||||||
8 - this.optionsBg.displayWidth,
|
isScroll = true;
|
||||||
-19 - 16 * (this.options.length - 1 - this.optionsCursor),
|
this.optionsScrollCursor--;
|
||||||
);
|
}
|
||||||
} 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) {
|
if (isScroll && this.optionsScrollCursor === 1) {
|
||||||
this.partySlots[cursor].select();
|
this.optionsScrollCursor += isDown ? 1 : -1;
|
||||||
} else if (cursor === 6) {
|
|
||||||
this.partyCancelButton.select();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isScroll) {
|
||||||
|
this.updateOptions();
|
||||||
|
} else {
|
||||||
|
this.optionsCursor = cursor;
|
||||||
|
}
|
||||||
|
if (!this.optionsCursorObj) {
|
||||||
|
this.optionsCursorObj = globalScene.add.image(0, 0, "cursor");
|
||||||
|
this.optionsCursorObj.setOrigin(0, 0);
|
||||||
|
this.optionsContainer.add(this.optionsCursorObj);
|
||||||
|
}
|
||||||
|
this.optionsCursorObj.setPosition(
|
||||||
|
8 - this.optionsBg.displayWidth,
|
||||||
|
-19 - 16 * (this.options.length - 1 - this.optionsCursor),
|
||||||
|
);
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user