mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-26 08:46:55 +00:00
[Bug] Fix bug of remaining pokerus and starter cursor on scrolling (#3293)
This commit is contained in:
parent
c1595bf2b7
commit
69e4ed9284
@ -1025,16 +1025,17 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
const maxColumns = 9;
|
||||
const maxRows = 9;
|
||||
const numberOfStarters = this.filteredStarterContainers.length;
|
||||
const numOfRows = Math.ceil(numberOfStarters / 9);
|
||||
const currentRow = Math.floor(this.cursor / 9);
|
||||
const onScreenFirstIndex = this.scrollCursor * 9; // this is first starter index on the screen
|
||||
const onScreenLastIndex = Math.min(onScreenFirstIndex + 9*9, numberOfStarters) - 1; // this is the last starter index on the screen
|
||||
const numOfRows = Math.ceil(numberOfStarters / maxColumns);
|
||||
const currentRow = Math.floor(this.cursor / maxColumns);
|
||||
const onScreenFirstIndex = this.scrollCursor * maxColumns; // this is first starter index on the screen
|
||||
const onScreenLastIndex = Math.min(this.filteredStarterContainers.length - 1, onScreenFirstIndex + maxRows * maxColumns - 1); // this is the last starter index on the screen
|
||||
const onScreenNumberOfStarters = onScreenLastIndex - onScreenFirstIndex + 1;
|
||||
const onScreenNumberOfRows = Math.ceil(onScreenNumberOfStarters / 9);
|
||||
// const onScreenFirstRow = Math.floor(onScreenFirstIndex / 9);
|
||||
const onScreenCurrentRow = Math.floor((this.cursor - onScreenFirstIndex) / 9);
|
||||
|
||||
const onScreenNumberOfRows = Math.ceil(onScreenNumberOfStarters / maxColumns);
|
||||
// const onScreenFirstRow = Math.floor(onScreenFirstIndex / maxColumns);
|
||||
const onScreenCurrentRow = Math.floor((this.cursor - onScreenFirstIndex) / maxColumns);
|
||||
|
||||
// console.log("this.cursor: ", this.cursor, "this.scrollCursor" , this.scrollCursor, "numberOfStarters: ", numberOfStarters, "numOfRows: ", numOfRows, "currentRow: ", currentRow, "onScreenFirstIndex: ", onScreenFirstIndex, "onScreenLastIndex: ", onScreenLastIndex, "onScreenNumberOfStarters: ", onScreenNumberOfStarters, "onScreenNumberOfRow: ", onScreenNumberOfRows, "onScreenCurrentRow: ", onScreenCurrentRow);
|
||||
|
||||
@ -2057,45 +2058,41 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
updateScroll = () => {
|
||||
const maxColumns = 9;
|
||||
const maxRows = 9;
|
||||
const onScreenFirstIndex = this.scrollCursor * 9;
|
||||
const onScreenLastIndex = Math.min(this.filteredStarterContainers.length - 1, onScreenFirstIndex + 81);
|
||||
const onScreenFirstIndex = this.scrollCursor * maxColumns;
|
||||
const onScreenLastIndex = Math.min(this.filteredStarterContainers.length - 1, onScreenFirstIndex + maxRows * maxColumns -1);
|
||||
|
||||
this.starterSelectScrollBar.setPage(this.scrollCursor);
|
||||
|
||||
let pokerusCursorIndex = 0;
|
||||
this.filteredStarterContainers.forEach((container, i) => {
|
||||
if (i < onScreenFirstIndex || i > onScreenLastIndex) {
|
||||
container.setVisible(false);
|
||||
return;
|
||||
} else {
|
||||
const pos = calcStarterPosition(i, this.scrollCursor);
|
||||
container.setPosition(pos.x, pos.y);
|
||||
|
||||
if (i < (maxRows + this.scrollCursor) * maxColumns && i >= this.scrollCursor * maxColumns) {
|
||||
container.setVisible(true);
|
||||
} else {
|
||||
if (i < onScreenFirstIndex || i > onScreenLastIndex) {
|
||||
container.setVisible(false);
|
||||
}
|
||||
|
||||
if (this.pokerusSpecies.includes(container.species)) {
|
||||
this.pokerusCursorObjs[pokerusCursorIndex].setPosition(pos.x - 1, pos.y + 1);
|
||||
|
||||
if (i < (maxRows + this.scrollCursor) * maxColumns && i >= this.scrollCursor * maxColumns) {
|
||||
this.pokerusCursorObjs[pokerusCursorIndex].setVisible(true);
|
||||
} else {
|
||||
this.pokerusCursorObjs[pokerusCursorIndex].setVisible(false);
|
||||
}
|
||||
pokerusCursorIndex++;
|
||||
}
|
||||
|
||||
if (this.starterSpecies.includes(container.species)) {
|
||||
this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setPosition(pos.x - 1, pos.y + 1);
|
||||
|
||||
if (i < (maxRows + this.scrollCursor) * maxColumns && i >= this.scrollCursor * maxColumns) {
|
||||
this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setVisible(true);
|
||||
} else {
|
||||
this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setVisible(false);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
container.setVisible(true);
|
||||
|
||||
if (this.pokerusSpecies.includes(container.species)) {
|
||||
this.pokerusCursorObjs[pokerusCursorIndex].setPosition(pos.x - 1, pos.y + 1);
|
||||
this.pokerusCursorObjs[pokerusCursorIndex].setVisible(true);
|
||||
pokerusCursorIndex++;
|
||||
}
|
||||
|
||||
if (this.starterSpecies.includes(container.species)) {
|
||||
this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setPosition(pos.x - 1, pos.y + 1);
|
||||
this.starterCursorObjs[this.starterSpecies.indexOf(container.species)].setVisible(true);
|
||||
}
|
||||
|
||||
const speciesId = container.species.speciesId;
|
||||
|
Loading…
Reference in New Issue
Block a user