Highlighting text filters, resetting all filters when starting up
This commit is contained in:
parent
5f5a05cd95
commit
fcc9ec57d3
|
@ -1,5 +1,4 @@
|
|||
import BattleScene from "#app/battle-scene";
|
||||
import { DropDown, DropDownType } from "./dropdown";
|
||||
import { StarterContainer } from "./starter-container";
|
||||
import { addTextObject, getTextColor, TextStyle } from "./text";
|
||||
import { UiTheme } from "#enums/ui-theme";
|
||||
|
@ -116,21 +115,18 @@ export class FilterText extends Phaser.GameObjects.Container {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DropDown associated to a given filter
|
||||
* @param col the DropDownColumn used to register the filter to retrieve
|
||||
* @returns the associated DropDown if it exists, undefined otherwise
|
||||
*/
|
||||
getFilter(row: FilterTextRow) : DropDown {
|
||||
return this.dropDowns[this.rows.indexOf(row)];
|
||||
}
|
||||
|
||||
resetSelection(index: number): void {
|
||||
this.selections[index].setText(this.defaultText);
|
||||
this.selectionStrings[index] = "";
|
||||
this.onChange();
|
||||
}
|
||||
|
||||
setValsToDefault(): void {
|
||||
for (let i = 0; i < this.numFilters; i++) {
|
||||
this.resetSelection(i);
|
||||
}
|
||||
}
|
||||
|
||||
startSearch(index: number, ui: UI): void {
|
||||
|
||||
ui.playSelect();
|
||||
|
@ -141,26 +137,20 @@ export class FilterText extends Phaser.GameObjects.Container {
|
|||
// ui.revertMode();
|
||||
ui.playSelect();
|
||||
const dialogueTestName = sanitizedName;
|
||||
console.log("1", dialogueTestName);
|
||||
//TODO: Is it really necessary to encode and decode?
|
||||
const dialogueName = decodeURIComponent(escape(atob(dialogueTestName)));
|
||||
console.log("2", dialogueName);
|
||||
const handler = ui.getHandler() as AwaitableUiHandler;
|
||||
handler.tutorialActive = true;
|
||||
// Switch to the dialog test window
|
||||
console.log("6", "switch");
|
||||
this.selections[index].setText(String(i18next.t(dialogueName)));
|
||||
console.log("6.5", "revert");
|
||||
ui.revertMode();
|
||||
this.onChange();
|
||||
},
|
||||
() => {
|
||||
console.log("7", "revert");
|
||||
ui.revertMode();
|
||||
this.onChange;
|
||||
}
|
||||
];
|
||||
console.log("8", "setmode");
|
||||
ui.setOverlayMode(Mode.POKEDEX_SCAN, buttonAction, prefilledText, index);
|
||||
}
|
||||
|
||||
|
@ -168,8 +158,6 @@ export class FilterText extends Phaser.GameObjects.Container {
|
|||
setCursor(cursor: number): void {
|
||||
const cursorOffset = 8;
|
||||
|
||||
console.log("Called set cursor from inside", cursor, 6 - cursorOffset + 2, this.labels[cursor].y + 5);
|
||||
|
||||
this.cursorObj.setPosition(cursorOffset, this.labels[cursor].y + 3);
|
||||
this.lastCursor = cursor;
|
||||
}
|
||||
|
@ -195,7 +183,7 @@ export class FilterText extends Phaser.GameObjects.Container {
|
|||
*/
|
||||
updateFilterLabels(): void {
|
||||
for (let i = 0; i < this.numFilters; i++) {
|
||||
if (this.dropDowns[i].hasDefaultValues()) {
|
||||
if (this.selections[i].text === this.defaultText) {
|
||||
this.labels[i].setColor(getTextColor(TextStyle.TOOLTIP_CONTENT, false, this.uiTheme));
|
||||
} else {
|
||||
this.labels[i].setColor(getTextColor(TextStyle.STATS_LABEL, false, this.uiTheme));
|
||||
|
@ -229,64 +217,10 @@ export class FilterText extends Phaser.GameObjects.Container {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move the leftmost dropdown to the left of the FilterBar instead of below it
|
||||
*/
|
||||
offsetHybridFilters(): void {
|
||||
for (let i = 0; i < this.dropDowns.length; i++) {
|
||||
if (this.dropDowns[i].dropDownType === DropDownType.HYBRID) {
|
||||
this.dropDowns[i].autoSize();
|
||||
this.dropDowns[i].x = - this.dropDowns[i].getWidth();
|
||||
this.dropDowns[i].y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toggleDropDown(index: number): void {
|
||||
this.dropDowns[index].toggleVisibility();
|
||||
this.openDropDown = this.dropDowns[index].visible;
|
||||
this.dropDowns[index].resetCursor();
|
||||
}
|
||||
|
||||
hideDropDowns(): void {
|
||||
this.dropDowns.forEach(dropDown => {
|
||||
dropDown.setVisible(false);
|
||||
});
|
||||
this.openDropDown = false;
|
||||
}
|
||||
|
||||
incDropDownCursor(): boolean {
|
||||
if (this.dropDowns[this.lastCursor].cursor === this.dropDowns[this.lastCursor].options.length - 1) {// if at the bottom of the list, wrap around
|
||||
return this.dropDowns[this.lastCursor].setCursor(0);
|
||||
} else {
|
||||
return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].cursor + 1);
|
||||
}
|
||||
}
|
||||
|
||||
decDropDownCursor(): boolean {
|
||||
if (this.dropDowns[this.lastCursor].cursor === 0) {// if at the top of the list, wrap around
|
||||
return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].options.length - 1);
|
||||
} else {
|
||||
return this.dropDowns[this.lastCursor].setCursor(this.dropDowns[this.lastCursor].cursor - 1);
|
||||
}
|
||||
}
|
||||
|
||||
toggleOptionState(): void {
|
||||
this.dropDowns[this.lastCursor].toggleOptionState();
|
||||
}
|
||||
|
||||
getValue(row: number): string {
|
||||
return this.selections[row].getWrappedText()[0];
|
||||
}
|
||||
|
||||
setValsToDefault(): void {
|
||||
for (const dropDown of this.dropDowns) {
|
||||
dropDown.resetToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the nearest filter to the provided container on the y-axis
|
||||
* @param container the StarterContainer to compare position against
|
||||
|
|
|
@ -639,8 +639,6 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||
this.setUpgradeAnimation(icon, species);
|
||||
});
|
||||
|
||||
console.log("Allspecies", this.starterContainers.length);
|
||||
|
||||
this.resetFilters();
|
||||
this.updateStarters();
|
||||
|
||||
|
@ -748,6 +746,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||
*/
|
||||
resetFilters() : void {
|
||||
this.filterBar.setValsToDefault();
|
||||
this.filterText.setValsToDefault();
|
||||
}
|
||||
|
||||
showText(text: string, delay?: integer, callback?: Function, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer, moveToTop?: boolean) {
|
||||
|
@ -1004,9 +1003,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||
success = true;
|
||||
}
|
||||
} else if (button === Button.STATS) {
|
||||
console.log("Pressed button");
|
||||
this.showDecorations = !this.showDecorations;
|
||||
console.log(this.showDecorations);
|
||||
this.updateScroll();
|
||||
success = true;
|
||||
} else if (this.filterMode) {
|
||||
|
@ -1296,6 +1293,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||
this.starterCursorObjs.forEach(cursor => cursor.setVisible(false));
|
||||
|
||||
this.filterBar.updateFilterLabels();
|
||||
this.filterText.updateFilterLabels();
|
||||
|
||||
this.validStarterContainers = this.starterContainers;
|
||||
|
||||
|
@ -1495,52 +1493,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
|
|||
|
||||
if (fitsName && fitsAbilities && fitsMoves && fitsGen && fitsBiome && fitsType && fitsCaught && fitsPassive && fitsCostReduction && fitsFavorite && fitsWin && fitsHA && fitsEgg && fitsPokerus) {
|
||||
this.filteredStarterContainers.push(container);
|
||||
} else {
|
||||
console.log(container.species.name);
|
||||
if (!fitsName) {
|
||||
console.log("fitsName is false");
|
||||
}
|
||||
if (!fitsAbilities) {
|
||||
console.log("fitsAbilities is false");
|
||||
}
|
||||
if (!fitsMoves) {
|
||||
console.log("fitsMoves is false");
|
||||
}
|
||||
if (!fitsGen) {
|
||||
console.log("fitsGen is false");
|
||||
}
|
||||
if (!fitsBiome) {
|
||||
console.log("fitsBiome is false");
|
||||
}
|
||||
if (!fitsType) {
|
||||
console.log("fitsType is false");
|
||||
}
|
||||
if (!fitsCaught) {
|
||||
console.log("fitsCaught is false");
|
||||
}
|
||||
if (!fitsPassive) {
|
||||
console.log("fitsPassive is false");
|
||||
}
|
||||
if (!fitsCostReduction) {
|
||||
console.log("fitsCostReduction is false");
|
||||
}
|
||||
if (!fitsFavorite) {
|
||||
console.log("fitsFavorite is false");
|
||||
}
|
||||
if (!fitsWin) {
|
||||
console.log("fitsWin is false");
|
||||
}
|
||||
if (!fitsHA) {
|
||||
console.log("fitsHA is false");
|
||||
}
|
||||
if (!fitsEgg) {
|
||||
console.log("fitsEgg is false");
|
||||
}
|
||||
if (!fitsPokerus) {
|
||||
console.log("fitsPokerus is false");
|
||||
}
|
||||
}
|
||||
console.log(this.filteredStarterContainers.length);
|
||||
});
|
||||
|
||||
this.starterSelectScrollBar.setTotalRows(Math.max(Math.ceil(this.filteredStarterContainers.length / 9), 1));
|
||||
|
|
Loading…
Reference in New Issue