mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-10 03:48:27 +00:00
* Updated admin panel to allow the concept of unlinking accounts * Don't look too hard at this commit, nothing to see here * Admin stuff * Fixed linking and unlinking and updated menu options * Undid some changes and cleaned up some code * Updated some logic and added some comments * Updates to admin panel logic * Stupid promises everyone hates them and they deserver to die * Promise stuff still * Promises working thanks to Ydarissep on discord - pushing with debug code before it decides to stop working again * Removed debugging code * All discord functionality seems to be working here?? Not sure what happened but yay * Fixed up some bugs and code * Added registered date to the panel * Fixed and updated some minor error message related stuff * Minor changes * Fixed some minor bugs, made the save related errors have error codes, and added updated icons * Updated search field error * Missed a couple of things to push * Fixed linting and doc errors * Revert dev related code and clean up dev comments * Reverting utils * Updating front end to match back end from Pancakes' comments * make getFields and getInputFieldConfigs a single function of FormUiHandler * remove outdated doc * Apply suggestions from code review Moka review changes Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> * Added docs * eslint fixes * Fixed error not showing up in certain conditions --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: MokaStitcher <millennium.stitcher@gmail.com> Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> Co-authored-by: innerthunder <brandonerickson98@gmail.com>
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { FormModalUiHandler, InputFieldConfig } from "./form-modal-ui-handler";
|
|
import { ModalConfig } from "./modal-ui-handler";
|
|
import i18next from "i18next";
|
|
import { PlayerPokemon } from "#app/field/pokemon";
|
|
|
|
export default class RenameFormUiHandler extends FormModalUiHandler {
|
|
getModalTitle(config?: ModalConfig): string {
|
|
return i18next.t("menu:renamePokemon");
|
|
}
|
|
|
|
getWidth(config?: ModalConfig): number {
|
|
return 160;
|
|
}
|
|
|
|
getMargin(config?: ModalConfig): [number, number, number, number] {
|
|
return [ 0, 0, 48, 0 ];
|
|
}
|
|
|
|
getButtonLabels(config?: ModalConfig): string[] {
|
|
return [ i18next.t("menu:rename"), i18next.t("menu:cancel") ];
|
|
}
|
|
|
|
getReadableErrorMessage(error: string): string {
|
|
const colonIndex = error?.indexOf(":");
|
|
if (colonIndex > 0) {
|
|
error = error.slice(0, colonIndex);
|
|
}
|
|
|
|
return super.getReadableErrorMessage(error);
|
|
}
|
|
|
|
override getInputFieldConfigs(): InputFieldConfig[] {
|
|
return [{ label: i18next.t("menu:nickname") }];
|
|
}
|
|
|
|
show(args: any[]): boolean {
|
|
if (super.show(args)) {
|
|
const config = args[0] as ModalConfig;
|
|
if (args[1] && typeof (args[1] as PlayerPokemon).getNameToRender === "function") {
|
|
this.inputs[0].text = (args[1] as PlayerPokemon).getNameToRender();
|
|
} else {
|
|
this.inputs[0].text = args[1];
|
|
}
|
|
this.submitAction = (_) => {
|
|
this.sanitizeInputs();
|
|
const sanitizedName = btoa(unescape(encodeURIComponent(this.inputs[0].text)));
|
|
config.buttonActions[0](sanitizedName);
|
|
return true;
|
|
};
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|