Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] Admin panel unlink accounts #4198

Merged
merged 41 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f4df35a
Updated admin panel to allow the concept of unlinking accounts
Opaque02 Sep 12, 2024
2c0fc38
Don't look too hard at this commit, nothing to see here
Opaque02 Sep 12, 2024
79c2829
Merge branch 'beta' into admin-panel-unlink-update
flx-sta Sep 13, 2024
39ee5b2
Merge branch 'pagefaultgames:main' into admin-panel-unlink-update
Opaque02 Sep 18, 2024
b802229
Admin stuff
Opaque02 Sep 24, 2024
cd36b5e
Merge branch 'admin-panel-unlink-update' of https://github.com/Opaque…
Opaque02 Sep 24, 2024
e8430c9
Fixed linking and unlinking and updated menu options
Opaque02 Sep 25, 2024
fd9248d
Merge branch 'beta' into admin-panel-unlink-update
Opaque02 Sep 25, 2024
7c7ebb2
Undid some changes and cleaned up some code
Opaque02 Sep 25, 2024
202b5e3
Updated some logic and added some comments
Opaque02 Sep 25, 2024
c36caea
Merge branch 'beta' into admin-panel-unlink-update
Opaque02 Sep 26, 2024
f50e27a
Updates to admin panel logic
Opaque02 Oct 3, 2024
a477880
Merge branch 'beta' into admin-panel-unlink-update
Opaque02 Oct 3, 2024
74264e0
Stupid promises everyone hates them and they deserver to die
Opaque02 Oct 4, 2024
9a75a30
Promise stuff still
Opaque02 Oct 6, 2024
61774b1
Promises working thanks to Ydarissep on discord - pushing with debug …
Opaque02 Oct 9, 2024
1904631
Removed debugging code
Opaque02 Oct 9, 2024
f07b10d
All discord functionality seems to be working here?? Not sure what ha…
Opaque02 Oct 9, 2024
d52104d
Fixed up some bugs and code
Opaque02 Oct 9, 2024
84561db
Added registered date to the panel
Opaque02 Oct 9, 2024
05be3f2
Fixed and updated some minor error message related stuff
Opaque02 Oct 10, 2024
ec359f5
Minor changes
Opaque02 Oct 10, 2024
b1eb36c
Fixed some minor bugs, made the save related errors have error codes,…
Opaque02 Oct 13, 2024
9563a5b
Updated search field error
Opaque02 Oct 14, 2024
5f0fc22
Merging with beta
Opaque02 Oct 14, 2024
4999b34
Missed a couple of things to push
Opaque02 Oct 14, 2024
77b754a
Fixed linting and doc errors
Opaque02 Oct 15, 2024
f9849db
Revert dev related code and clean up dev comments
Opaque02 Oct 15, 2024
de49839
Reverting utils
Opaque02 Oct 15, 2024
f62c744
Updating front end to match back end from Pancakes' comments
Opaque02 Oct 17, 2024
61b94cc
make getFields and getInputFieldConfigs a single function of FormUiHa…
MokaStitcher Oct 18, 2024
641321b
remove outdated doc
MokaStitcher Oct 18, 2024
65c3748
Merge pull request #3 from MokaStitcher/admin
Opaque02 Oct 19, 2024
4533e53
Apply suggestions from code review
Opaque02 Oct 20, 2024
2242092
Added docs
Opaque02 Oct 20, 2024
12eabfe
Merge branch 'beta' into admin-panel-unlink-update
Opaque02 Oct 20, 2024
7102335
eslint fixes
Opaque02 Oct 20, 2024
fa00458
Fixed error not showing up in certain conditions
Opaque02 Oct 20, 2024
446b1af
Merge branch 'beta' into admin-panel-unlink-update
flx-sta Oct 22, 2024
a341b52
Merge branch 'beta' into pr/4198
innerthunder Oct 23, 2024
c51e2f3
Merge branch 'beta' into pr/4198
innerthunder Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/images/ui/legacy/link_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/ui/legacy/unlink_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/ui/link_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/ui/unlink_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/locales
Submodule locales updated 61 files
+2 −13 README.md
+1 −2 ca-ES/arena-flyout.json
+1 −1 ca-ES/menu.json
+1 −14 ca-ES/move.json
+0 −0 ca-ES/mystery-encounter-messages.json
+1 −8 ca-ES/pokeball.json
+1 −1 ca-ES/pokemon-info.json
+0 −0 ca-ES/splash-messages.json
+0 −1 de/menu.json
+0 −0 de/mystery-encounter-messages.json
+1 −0 de/splash-messages.json
+1 −2 en/menu.json
+0 −0 en/mystery-encounter-messages.json
+1 −0 en/splash-messages.json
+1 −1 es/menu.json
+0 −0 es/mystery-encounter-messages.json
+0 −0 es/splash-messages.json
+1 −1 fr/dialogue.json
+0 −1 fr/menu.json
+0 −0 fr/mystery-encounter-messages.json
+7 −6 fr/splash-messages.json
+0 −106 he/ability.json
+1 −55 he/menu.json
+0 −0 it/mystery-encounter-messages.json
+1 −0 it/splash-messages.json
+16 −34 ja/achv.json
+2 −16 ja/battle.json
+1 −6 ja/battler-tags.json
+0 −19 ja/challenges.json
+4 −4 ja/dialogue-final-boss.json
+6 −380 ja/dialogue.json
+0 −1 ja/menu-ui-handler.json
+0 −4 ja/move-trigger.json
+0 −0 ja/mystery-encounter-messages.json
+2 −2 ja/mystery-encounters/a-trainers-test-dialogue.json
+3 −3 ja/mystery-encounters/an-offer-you-cant-refuse-dialogue.json
+1 −1 ja/mystery-encounters/bug-type-superfan-dialogue.json
+8 −8 ja/mystery-encounters/fiery-fallout-dialogue.json
+1 −1 ja/mystery-encounters/mysterious-challengers-dialogue.json
+1 −1 ja/mystery-encounters/uncommon-breed-dialogue.json
+0 −6 ja/mystery-encounters/weird-dream-dialogue.json
+0 −3 ja/party-ui-handler.json
+1 −2 ja/pokemon-summary.json
+0 −4 ja/settings.json
+0 −0 ja/splash-messages.json
+4 −3 ja/trainer-names.json
+0 −0 ko/mystery-encounter-messages.json
+2 −2 ko/mystery-encounters/an-offer-you-cant-refuse-dialogue.json
+4 −2 ko/mystery-encounters/delibirdy-dialogue.json
+8 −8 ko/mystery-encounters/fiery-fallout-dialogue.json
+1 −7 ko/mystery-encounters/weird-dream-dialogue.json
+0 −0 ko/splash-messages.json
+1 −3 ko/trainer-names.json
+0 −1 pt-BR/menu.json
+0 −0 pt-BR/mystery-encounter-messages.json
+1 −0 pt-BR/splash-messages.json
+1 −2 zh-CN/bgm-name.json
+0 −0 zh-CN/mystery-encounter-messages.json
+0 −0 zh-CN/splash-messages.json
+0 −0 zh-TW/mystery-encounter-messages.json
+0 −0 zh-TW/splash-messages.json
2 changes: 2 additions & 0 deletions src/loading-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ export class LoadingScene extends SceneBase {
this.loadImage("discord", "ui");
this.loadImage("google", "ui");
this.loadImage("settings_icon", "ui");
this.loadImage("link_icon", "ui");
this.loadImage("unlink_icon", "ui");

this.loadImage("default_bg", "arenas");
// Load arena images
Expand Down
351 changes: 314 additions & 37 deletions src/ui/admin-ui-handler.ts

Large diffs are not rendered by default.

56 changes: 40 additions & 16 deletions src/ui/form-modal-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { TextStyle, addTextInputObject, addTextObject } from "./text";
import { WindowVariant, addWindow } from "./ui-theme";
import InputText from "phaser3-rex-plugins/plugins/inputtext";
import * as Utils from "../utils";
import i18next from "i18next";
import { Button } from "#enums/buttons";

export interface FormModalConfig extends ModalConfig {
Expand All @@ -19,19 +18,25 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
protected errorMessage: Phaser.GameObjects.Text;
protected submitAction: Function | null;
protected tween: Phaser.Tweens.Tween;
protected formLabels: Phaser.GameObjects.Text[];

constructor(scene: BattleScene, mode: Mode | null = null) {
super(scene, mode);

this.editing = false;
this.inputContainers = [];
this.inputs = [];
this.formLabels = [];
}

abstract getFields(): string[];
/**
* Get all information for each field to display in the modal
* @returns array of {@linkcode InputFieldConfig}
*/
abstract getInputFieldConfigs(): InputFieldConfig[];

getHeight(config?: ModalConfig): number {
return 20 * this.getFields().length + (this.getModalTitle() ? 26 : 0) + ((config as FormModalConfig)?.errorMessage ? 12 : 0) + this.getButtonTopMargin() + 28;
return 20 * this.getInputFieldConfigs().length + (this.getModalTitle() ? 26 : 0) + ((config as FormModalConfig)?.errorMessage ? 12 : 0) + this.getButtonTopMargin() + 28;
}

getReadableErrorMessage(error: string): string {
Expand All @@ -45,37 +50,50 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
setup(): void {
super.setup();

const fields = this.getFields();
const config = this.getInputFieldConfigs();

const hasTitle = !!this.getModalTitle();

fields.forEach((field, f) => {
const label = addTextObject(this.scene, 10, (hasTitle ? 31 : 5) + 20 * f, field, TextStyle.TOOLTIP_CONTENT);
if (config.length >= 1) {
this.updateFields(config, hasTitle);
}

this.errorMessage = addTextObject(this.scene, 10, (hasTitle ? 31 : 5) + 20 * (config.length - 1) + 16 + this.getButtonTopMargin(), "", TextStyle.TOOLTIP_CONTENT);
this.errorMessage.setColor(this.getTextColor(TextStyle.SUMMARY_PINK));
this.errorMessage.setShadowColor(this.getTextColor(TextStyle.SUMMARY_PINK, true));
this.errorMessage.setVisible(false);
this.modalContainer.add(this.errorMessage);
}

updateFields(fieldsConfig: InputFieldConfig[], hasTitle: boolean) {
this.inputContainers = [];
this.inputs = [];
this.formLabels = [];
fieldsConfig.forEach((config, f) => {
const label = addTextObject(this.scene, 10, (hasTitle ? 31 : 5) + 20 * f, config.label, TextStyle.TOOLTIP_CONTENT);
label.name = "formLabel" + f;

this.modalContainer.add(label);
this.formLabels.push(label);
this.modalContainer.add(this.formLabels[this.formLabels.length - 1]);

const inputContainer = this.scene.add.container(70, (hasTitle ? 28 : 2) + 20 * f);
inputContainer.setVisible(false);

const inputBg = addWindow(this.scene, 0, 0, 80, 16, false, false, 0, 0, WindowVariant.XTHIN);

const isPassword = field.includes(i18next.t("menu:password")) || field.includes(i18next.t("menu:confirmPassword"));
const input = addTextInputObject(this.scene, 4, -2, 440, 116, TextStyle.TOOLTIP_CONTENT, { type: isPassword ? "password" : "text", maxLength: isPassword ? 64 : 20 });
const isPassword = config?.isPassword;
const isReadOnly = config?.isReadOnly;
const input = addTextInputObject(this.scene, 4, -2, 440, 116, TextStyle.TOOLTIP_CONTENT, { type: isPassword ? "password" : "text", maxLength: isPassword ? 64 : 20, readOnly: isReadOnly });
input.setOrigin(0, 0);

inputContainer.add(inputBg);
inputContainer.add(input);
this.modalContainer.add(inputContainer);

this.inputContainers.push(inputContainer);
this.modalContainer.add(this.inputContainers[this.inputContainers.length - 1]);

this.inputs.push(input);
});

this.errorMessage = addTextObject(this.scene, 10, (hasTitle ? 31 : 5) + 20 * (fields.length - 1) + 16 + this.getButtonTopMargin(), "", TextStyle.TOOLTIP_CONTENT);
this.errorMessage.setColor(this.getTextColor(TextStyle.SUMMARY_PINK));
this.errorMessage.setShadowColor(this.getTextColor(TextStyle.SUMMARY_PINK, true));
this.errorMessage.setVisible(false);
this.modalContainer.add(this.errorMessage);
}

show(args: any[]): boolean {
Expand Down Expand Up @@ -149,3 +167,9 @@ export abstract class FormModalUiHandler extends ModalUiHandler {
}
}
}

export interface InputFieldConfig {
label: string,
isPassword?: boolean,
isReadOnly?: boolean
}
25 changes: 14 additions & 11 deletions src/ui/login-form-ui-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormModalUiHandler } from "./form-modal-ui-handler";
import { FormModalUiHandler, InputFieldConfig } from "./form-modal-ui-handler";
import { ModalConfig } from "./modal-ui-handler";
import * as Utils from "../utils";
import { Mode } from "./ui";
Expand All @@ -17,9 +17,9 @@ interface BuildInteractableImageOpts {

export default class LoginFormUiHandler extends FormModalUiHandler {
private readonly ERR_USERNAME: string = "invalid username";
private readonly ERR_PASSWORD: string = "invalid password";
private readonly ERR_ACCOUNT_EXIST: string = "account doesn't exist";
private readonly ERR_PASSWORD_MATCH: string = "password doesn't match";
private readonly ERR_PASSWORD: string = "invalid password";
private readonly ERR_ACCOUNT_EXIST: string = "account doesn't exist";
private readonly ERR_PASSWORD_MATCH: string = "password doesn't match";
private readonly ERR_NO_SAVES: string = "No save files found";
private readonly ERR_TOO_MANY_SAVES: string = "Too many save files found";

Expand Down Expand Up @@ -75,10 +75,6 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
return i18next.t("menu:login");
}

override getFields(_config?: ModalConfig): string[] {
return [ i18next.t("menu:username"), i18next.t("menu:password") ];
}

override getWidth(_config?: ModalConfig): number {
return 160;
}
Expand Down Expand Up @@ -106,14 +102,21 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
case this.ERR_PASSWORD_MATCH:
return i18next.t("menu:unmatchingPassword");
case this.ERR_NO_SAVES:
return i18next.t("menu:noSaves");
return "P01: " + i18next.t("menu:noSaves");
case this.ERR_TOO_MANY_SAVES:
return i18next.t("menu:tooManySaves");
return "P02: " + i18next.t("menu:tooManySaves");
}

return super.getReadableErrorMessage(error);
}

override getInputFieldConfigs(): InputFieldConfig[] {
const inputFieldConfigs: InputFieldConfig[] = [];
inputFieldConfigs.push({ label: i18next.t("menu:username") });
inputFieldConfigs.push({ label: i18next.t("menu:password"), isPassword: true });
return inputFieldConfigs;
}

override show(args: any[]): boolean {
if (super.show(args)) {

Expand Down Expand Up @@ -164,7 +167,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler {
[ this.discordImage, this.googleImage, this.usernameInfoImage ].forEach((img) => img.off("pointerdown"));
}

private processExternalProvider(config: ModalConfig) : void {
private processExternalProvider(config: ModalConfig): void {
this.externalPartyTitle.setText(i18next.t("menu:orUse") ?? "");
this.externalPartyTitle.setX(20 + this.externalPartyTitle.text.length);
this.externalPartyTitle.setVisible(true);
Expand Down
44 changes: 35 additions & 9 deletions src/ui/menu-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { GameDataType } from "#enums/game-data-type";
import BgmBar from "#app/ui/bgm-bar";
import AwaitableUiHandler from "./awaitable-ui-handler";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import { AdminMode, getAdminModeName } from "./admin-ui-handler";

enum MenuOptions {
GAME_SETTINGS,
Expand Down Expand Up @@ -387,16 +388,41 @@ export default class MenuUiHandler extends MessageUiHandler {
communityOptions.push({
label: "Admin",
handler: () => {
ui.playSelect();
ui.setOverlayMode(Mode.ADMIN, {
buttonActions: [
() => {
ui.revertMode();
},
() => {
ui.revertMode();

const skippedAdminModes: AdminMode[] = [ AdminMode.ADMIN ]; // this is here so that we can skip the menu populating enums that aren't meant for the menu, such as the AdminMode.ADMIN
const options: OptionSelectItem[] = [];
Object.values(AdminMode).filter((v) => !isNaN(Number(v)) && !skippedAdminModes.includes(v as AdminMode)).forEach((mode) => { // this gets all the enums in a way we can use
options.push({
label: getAdminModeName(mode as AdminMode),
handler: () => {
ui.playSelect();
ui.setOverlayMode(Mode.ADMIN, {
buttonActions: [
// we double revert here and below to go back 2 layers of menus
() => {
ui.revertMode();
ui.revertMode();
},
() => {
ui.revertMode();
ui.revertMode();
}
]
}, mode); // mode is our AdminMode enum
return true;
}
]
});
});
options.push({
label: "Cancel",
handler: () => {
ui.revertMode();
return true;
}
});
this.scene.ui.setOverlayMode(Mode.OPTION_SELECT, {
options: options,
delay: 0
});
return true;
},
Expand Down
3 changes: 3 additions & 0 deletions src/ui/modal-ui-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export abstract class ModalUiHandler extends UiHandler {
protected titleText: Phaser.GameObjects.Text;
protected buttonContainers: Phaser.GameObjects.Container[];
protected buttonBgs: Phaser.GameObjects.NineSlice[];
protected buttonLabels: Phaser.GameObjects.Text[];

constructor(scene: BattleScene, mode: Mode | null = null) {
super(scene, mode);

this.buttonContainers = [];
this.buttonBgs = [];
this.buttonLabels = [];
}

abstract getModalTitle(config?: ModalConfig): string;
Expand Down Expand Up @@ -75,6 +77,7 @@ export abstract class ModalUiHandler extends UiHandler {

const buttonContainer = this.scene.add.container(0, buttonTopMargin);

this.buttonLabels.push(buttonLabel);
this.buttonBgs.push(buttonBg);
this.buttonContainers.push(buttonContainer);

Expand Down
14 changes: 9 additions & 5 deletions src/ui/registration-form-ui-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormModalUiHandler } from "./form-modal-ui-handler";
import { FormModalUiHandler, InputFieldConfig } from "./form-modal-ui-handler";
import { ModalConfig } from "./modal-ui-handler";
import * as Utils from "../utils";
import { Mode } from "./ui";
Expand All @@ -24,10 +24,6 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
return i18next.t("menu:register");
}

getFields(config?: ModalConfig): string[] {
return [ i18next.t("menu:username"), i18next.t("menu:password"), i18next.t("menu:confirmPassword") ];
}

getWidth(config?: ModalConfig): number {
return 160;
}
Expand Down Expand Up @@ -61,6 +57,14 @@ export default class RegistrationFormUiHandler extends FormModalUiHandler {
return super.getReadableErrorMessage(error);
}

override getInputFieldConfigs(): InputFieldConfig[] {
const inputFieldConfigs: InputFieldConfig[] = [];
inputFieldConfigs.push({ label: i18next.t("menu:username") });
inputFieldConfigs.push({ label: i18next.t("menu:password"), isPassword: true });
inputFieldConfigs.push({ label: i18next.t("menu:confirmPassword"), isPassword: true });
return inputFieldConfigs;
}

setup(): void {
super.setup();

Expand Down
10 changes: 5 additions & 5 deletions src/ui/rename-form-ui-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormModalUiHandler } from "./form-modal-ui-handler";
import { FormModalUiHandler, InputFieldConfig } from "./form-modal-ui-handler";
import { ModalConfig } from "./modal-ui-handler";
import i18next from "i18next";
import { PlayerPokemon } from "#app/field/pokemon";
Expand All @@ -8,10 +8,6 @@ export default class RenameFormUiHandler extends FormModalUiHandler {
return i18next.t("menu:renamePokemon");
}

getFields(config?: ModalConfig): string[] {
return [ i18next.t("menu:nickname") ];
}

getWidth(config?: ModalConfig): number {
return 160;
}
Expand All @@ -33,6 +29,10 @@ export default class RenameFormUiHandler extends FormModalUiHandler {
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;
Expand Down
13 changes: 8 additions & 5 deletions src/ui/test-dialogue-ui-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormModalUiHandler } from "./form-modal-ui-handler";
import { FormModalUiHandler, InputFieldConfig } from "./form-modal-ui-handler";
import { ModalConfig } from "./modal-ui-handler";
import i18next from "i18next";
import { PlayerPokemon } from "#app/field/pokemon";
Expand Down Expand Up @@ -43,10 +43,6 @@ export default class TestDialogueUiHandler extends FormModalUiHandler {
return "Test Dialogue";
}

getFields(config?: ModalConfig): string[] {
return [ "Dialogue" ];
}

getWidth(config?: ModalConfig): number {
return 300;
}
Expand All @@ -68,8 +64,15 @@ export default class TestDialogueUiHandler extends FormModalUiHandler {
return super.getReadableErrorMessage(error);
}

override getInputFieldConfigs(): InputFieldConfig[] {
return [{ label: "Dialogue" }];
}

show(args: any[]): boolean {
const ui = this.getUi();
const hasTitle = !!this.getModalTitle();
this.updateFields(this.getInputFieldConfigs(), hasTitle);
this.updateContainer(args[0] as ModalConfig);
const input = this.inputs[0];
input.setMaxLength(255);

Expand Down
Loading