From ee5d6895754ba5a500e5520e0b65a625b82542a7 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Sat, 1 Jun 2024 17:23:01 +0100 Subject: [PATCH 1/6] feat: Add Google and Discord login functionality feat: Add link to Discord in menu UI feat: Add Discord and Google login functionality Add container around discord and google icons refactor: Update environment variable names for Discord and Google client IDs feat: Add "Or use" translation for login options in multiple languages feat: Update menu UI translations for multiple languages Code review fixes refactor: Update Discord and Google client IDs in environment variables --- .env | 4 +- .env.development | 4 +- public/images/ui/discord.png | Bin 0 -> 5682 bytes public/images/ui/google.png | Bin 0 -> 569 bytes public/images/ui/legacy/discord.png | Bin 0 -> 505 bytes public/images/ui/legacy/google.png | Bin 0 -> 569 bytes src/account.ts | 4 +- src/loading-scene.ts | 2 + src/locales/de/menu-ui-handler.ts | 4 ++ src/locales/de/menu.ts | 1 + src/locales/en/menu-ui-handler.ts | 4 ++ src/locales/en/menu.ts | 1 + src/locales/es/menu-ui-handler.ts | 4 ++ src/locales/es/menu.ts | 1 + src/locales/fr/menu-ui-handler.ts | 4 ++ src/locales/fr/menu.ts | 1 + src/locales/it/menu-ui-handler.ts | 4 ++ src/locales/it/menu.ts | 1 + src/locales/ko/menu-ui-handler.ts | 4 ++ src/locales/ko/menu.ts | 1 + src/locales/pt_BR/menu-ui-handler.ts | 4 ++ src/locales/pt_BR/menu.ts | 1 + src/locales/zh_CN/menu-ui-handler.ts | 4 ++ src/locales/zh_CN/menu.ts | 1 + src/locales/zh_TW/menu-ui-handler.ts | 4 ++ src/locales/zh_TW/menu.ts | 1 + src/phases.ts | 10 +++ src/ui/login-form-ui-handler.ts | 92 ++++++++++++++++++++++++++- src/ui/menu-ui-handler.ts | 49 +++++++++++++- src/vite.env.d.ts | 2 + 30 files changed, 205 insertions(+), 7 deletions(-) create mode 100644 public/images/ui/discord.png create mode 100644 public/images/ui/google.png create mode 100644 public/images/ui/legacy/discord.png create mode 100644 public/images/ui/legacy/google.png diff --git a/.env b/.env index 6ac42ba97b4..7d21f7d3208 100644 --- a/.env +++ b/.env @@ -1,3 +1,5 @@ VITE_BYPASS_LOGIN=0 VITE_BYPASS_TUTORIAL=0 -VITE_SERVER_URL=http://localhost:8001 \ No newline at end of file +VITE_SERVER_URL=http://localhost:8001 +VITE_DISCORD_CLIENT_ID=1248062921129459756 +VITE_GOOGLE_CLIENT_ID=955345393540-2k6lfftf0fdnb0krqmpthjnqavfvvf73.apps.googleusercontent.com diff --git a/.env.development b/.env.development index e9180f0875d..eaf1d1403f2 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,5 @@ VITE_BYPASS_LOGIN=1 VITE_BYPASS_TUTORIAL=0 -VITE_SERVER_URL=http://localhost:8001 \ No newline at end of file +VITE_SERVER_URL=http://localhost:8001 +VITE_DISCORD_CLIENT_ID=1234567890 +VITE_GOOGLE_CLIENT_ID=1234567890 diff --git a/public/images/ui/discord.png b/public/images/ui/discord.png new file mode 100644 index 0000000000000000000000000000000000000000..1cd833854b0facf93f69a97e7ae309a8401c4816 GIT binary patch literal 5682 zcmb`Lc{tSF`^V4B$i9U{mKlUnBD*kSELpR!S+hiWQcs8?Ga)TxEh1Zm>|3NP%}}iPb@&;P&Q=X!sxbIyHU=RWtj&-M9S=Q{VSER49=53vIPxJ--< zYyg1lRUv>CwpRp{IobVc1=$$sL58}HWA++sSB#y50N~*N^+G^qmJk5YV^-#NhQ@Y% zPQE{!d{-QO_O$Hiv*hT#=ZOdX zpK3{l2u7S4TU4xdcyKAds-X6DdiY}-Mm{4{s`V&U9>+Pc-m zw)3k;w_ku*aj%~HnJPio#((!8g1>b}yc zIORQQ#Vcz)P}WLN*^_pXs!p=1PKv5ds+vwJad=h@`A`k{NF9}?j!IWYJyzF!tf8Ah z9G=tA&D2C^Y3gNb>gAl$%OwrZYofDH=|9ync&2TTuWh)e0&T-W9m5wor}tEhG%7(F zm!W>C9A#XAGN~YqEa;prLK>ConpEkUR-?^cqRndc%$LQr>6yP89$C~isnj#C zA0AoKKlA3aRm(7WX_&m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lboVRGfHx&G(&67IyKn`btM`SSr z1Gg{;GcwGYBLNgt4DbnYJ#^^M|NsAAIh($6G5fuT#i{j+$%H8P25&8q{;!1nK-`9PjMrwyTw(9&%iFx}wv@ud6|5FJy0Vy$shd~xeEFEzq5&DWPf3&`exC}X%3JQ>9DboFyt=akR{0OG(&67IyKn`btM`SSr z1Gg{;GcwGYBLNf?4e$wZ^$58dk^1T3oJB5EAuG(&67IyKn`btM`SSr z1Gg{;GcwGYBLNgt4DbnYJ#^^M|NsAAIh($6G5fuT#i{j+$%H8P25&8q{;!1nK-`9PjMrwyTw(9&%iFx}wv@ud6|5FJy0Vy$shd~xeEFEzq5&DWPf3&`exC}X%3JQ>9DboFyt=akR{0O { return new Promise<[boolean, integer]>(resolve => { if (bypassLogin) { - loggedInUser = { username: "Guest", lastSessionSlot: -1 }; + loggedInUser = { username: "Guest", lastSessionSlot: -1, discordId: "", googleId: "" }; let lastSessionSlot = -1; for (let s = 0; s < 5; s++) { if (localStorage.getItem(`sessionData${s ? s : ""}_${loggedInUser.username}`)) { diff --git a/src/loading-scene.ts b/src/loading-scene.ts index f6ca88192da..e623c00aad0 100644 --- a/src/loading-scene.ts +++ b/src/loading-scene.ts @@ -153,6 +153,8 @@ export class LoadingScene extends SceneBase { this.loadImage("select_gen_cursor_highlight", "ui"); this.loadImage("saving_icon", "ui"); + this.loadImage("discord", "ui"); + this.loadImage("google", "ui"); this.loadImage("default_bg", "arenas"); // Load arena images diff --git a/src/locales/de/menu-ui-handler.ts b/src/locales/de/menu-ui-handler.ts index 62c53be4c62..1e04fc04599 100644 --- a/src/locales/de/menu-ui-handler.ts +++ b/src/locales/de/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "Wähle einen Slot zum Exportieren.", "importData": "Daten importieren", "exportData": "Daten exportieren", + "linkDiscord": "Link Discord", + "unlinkDiscord": "Unlink Discord", + "linkGoogle": "Link Google", + "unlinkGoogle": "Unlink Google", "cancel": "Abbrechen", "losingProgressionWarning": "Du wirst jeglichen Fortschritt seit Anfang dieses Kampfes verlieren. Fortfahren?" } as const; diff --git a/src/locales/de/menu.ts b/src/locales/de/menu.ts index beb46ff16aa..e31f352030c 100644 --- a/src/locales/de/menu.ts +++ b/src/locales/de/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "Benutzername", "password": "Passwort", "login": "Anmelden", + "orUse": "Or use", "register": "Registrieren", "emptyUsername": "Benutzername darf nicht leer sein.", "invalidLoginUsername": "Der eingegebene Benutzername ist ungültig.", diff --git a/src/locales/en/menu-ui-handler.ts b/src/locales/en/menu-ui-handler.ts index f34a87bb778..1a46812293c 100644 --- a/src/locales/en/menu-ui-handler.ts +++ b/src/locales/en/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "Select a slot to export from.", "importData": "Import Data", "exportData": "Export Data", + "linkDiscord": "Link Discord", + "unlinkDiscord": "Unlink Discord", + "linkGoogle": "Link Google", + "unlinkGoogle": "Unlink Google", "cancel": "Cancel", "losingProgressionWarning": "You will lose any progress since the beginning of the battle. Proceed?" } as const; diff --git a/src/locales/en/menu.ts b/src/locales/en/menu.ts index c7bade07a47..1a6ddf0aca0 100644 --- a/src/locales/en/menu.ts +++ b/src/locales/en/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "Username", "password": "Password", "login": "Login", + "orUse": "Or use", "register": "Register", "emptyUsername": "Username must not be empty", "invalidLoginUsername": "The provided username is invalid", diff --git a/src/locales/es/menu-ui-handler.ts b/src/locales/es/menu-ui-handler.ts index ff0e38f110a..8982c8e147c 100644 --- a/src/locales/es/menu-ui-handler.ts +++ b/src/locales/es/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "Selecciona una ranura para exportar.", "importData": "Importar Datos", "exportData": "Exportar Datos", + "linkDiscord": "Conectar Discord", + "unlinkDiscord": "Desconectar Discord", + "linkGoogle": "Conectar Google", + "unlinkGoogle": "Desconectar Google", "cancel": "Cancelar", "losingProgressionWarning": "Perderás cualquier progreso desde el inicio de la batalla. ¿Continuar?" } as const; diff --git a/src/locales/es/menu.ts b/src/locales/es/menu.ts index c47406a0e95..37c45203410 100644 --- a/src/locales/es/menu.ts +++ b/src/locales/es/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "Usuario", "password": "Contraseña", "login": "Iniciar Sesión", + "orUse": "O usa", "register": "Registrarse", "emptyUsername": "El usuario no puede estar vacío", "invalidLoginUsername": "El usuario no es válido", diff --git a/src/locales/fr/menu-ui-handler.ts b/src/locales/fr/menu-ui-handler.ts index 2a9eecd66ec..9cf14cc61dc 100644 --- a/src/locales/fr/menu-ui-handler.ts +++ b/src/locales/fr/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "Sélectionnez l’emplacement depuis lequel exporter les données.", "importData": "Importer données", "exportData": "Exporter données", + "linkDiscord": "Link Discord", + "unlinkDiscord": "Unlink Discord", + "linkGoogle": "Link Google", + "unlinkGoogle": "Unlink Google", "cancel": "Retour", "losingProgressionWarning": "Vous allez perdre votre progression depuis le début du combat. Continuer ?" } as const; diff --git a/src/locales/fr/menu.ts b/src/locales/fr/menu.ts index 8b13335fe57..2416b60b9aa 100644 --- a/src/locales/fr/menu.ts +++ b/src/locales/fr/menu.ts @@ -12,6 +12,7 @@ export const menu: SimpleTranslationEntries = { "username": "Nom d’utilisateur", "password": "Mot de passe", "login": "Connexion", + "orUse": "Ou utilisez", "register": "S’inscrire", "emptyUsername": "Le nom d’utilisateur est manquant", "invalidLoginUsername": "Le nom d’utilisateur n’est pas valide", diff --git a/src/locales/it/menu-ui-handler.ts b/src/locales/it/menu-ui-handler.ts index 9a1e16a77b5..320a4844372 100644 --- a/src/locales/it/menu-ui-handler.ts +++ b/src/locales/it/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "Seleziona uno slot da cui esportare.", "importData": "Importa Dati", "exportData": "Esporta Dati", + "linkDiscord": "Link Discord", + "unlinkDiscord": "Unlink Discord", + "linkGoogle": "Link Google", + "unlinkGoogle": "Unlink Google", "cancel": "Annulla", "losingProgressionWarning": "Perderai tutti i progressi dall'inizio della battaglia. Procedere?" } as const; diff --git a/src/locales/it/menu.ts b/src/locales/it/menu.ts index 187743a7921..ad47faa8980 100644 --- a/src/locales/it/menu.ts +++ b/src/locales/it/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "Nome utente", "password": "Password", "login": "Accedi", + "orUse": "Or use", "register": "Registrati", "emptyUsername": "Nome utente mancante!", "invalidLoginUsername": "Nome utente non valido!", diff --git a/src/locales/ko/menu-ui-handler.ts b/src/locales/ko/menu-ui-handler.ts index 5e13d010438..e7bb1477cdd 100644 --- a/src/locales/ko/menu-ui-handler.ts +++ b/src/locales/ko/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "내보낼 슬롯을 골라주세요.", "importData": "데이터 불러오기", "exportData": "데이터 내보내기", + "linkDiscord": "Link Discord", + "unlinkDiscord": "Unlink Discord", + "linkGoogle": "Link Google", + "unlinkGoogle": "Unlink Google", "cancel": "취소", "losingProgressionWarning": "전투 시작으로부터의 진행 상황을 잃게 됩니다. 계속하시겠습니까?" } as const; diff --git a/src/locales/ko/menu.ts b/src/locales/ko/menu.ts index 134963d6cce..bdcf621a5e8 100644 --- a/src/locales/ko/menu.ts +++ b/src/locales/ko/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "이름", "password": "비밀번호", "login": "로그인", + "orUse": "Or use", "register": "등록", "emptyUsername": "이름은 비워둘 수 없습니다", "invalidLoginUsername": "사용할 수 없는 이름입니다", diff --git a/src/locales/pt_BR/menu-ui-handler.ts b/src/locales/pt_BR/menu-ui-handler.ts index 47386943831..e1592a4e332 100644 --- a/src/locales/pt_BR/menu-ui-handler.ts +++ b/src/locales/pt_BR/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "Selecione um slot para exportar.", "importData": "Importar dados", "exportData": "Exportar dados", + "linkDiscord": "Conectar Discord", + "unlinkDiscord": "Desconectar Discord", + "linkGoogle": "Conectar Google", + "unlinkGoogle": "Desconectar Google", "cancel": "Cancelar", "losingProgressionWarning": "Você vai perder todo o progresso desde o início da batalha. Confirmar?" } as const; diff --git a/src/locales/pt_BR/menu.ts b/src/locales/pt_BR/menu.ts index 2837ff55e26..39ac38b6ae1 100644 --- a/src/locales/pt_BR/menu.ts +++ b/src/locales/pt_BR/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "Nome de Usuário", "password": "Senha", "login": "Iniciar sessão", + "orUse": "Ou use", "register": "Registrar-se", "emptyUsername": "Nome de usuário vazio", "invalidLoginUsername": "Nome de usuário inválido", diff --git a/src/locales/zh_CN/menu-ui-handler.ts b/src/locales/zh_CN/menu-ui-handler.ts index 6107c1c2800..39d4dbbfede 100644 --- a/src/locales/zh_CN/menu-ui-handler.ts +++ b/src/locales/zh_CN/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "选择要导出的存档位。", "importData": "导入数据", "exportData": "导出数据", + "linkDiscord": "Link Discord", + "unlinkDiscord": "Unlink Discord", + "linkGoogle": "Link Google", + "unlinkGoogle": "Unlink Google", "cancel": "取消", "losingProgressionWarning": "你将失去自战斗开始以来的所有进度。是否\n继续?" } as const; diff --git a/src/locales/zh_CN/menu.ts b/src/locales/zh_CN/menu.ts index 97af66c8d3a..006b285a5e2 100644 --- a/src/locales/zh_CN/menu.ts +++ b/src/locales/zh_CN/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "用户名", "password": "密码", "login": "登录", + "Or use": "Or use", "register": "注册", "emptyUsername": "用户名不能为空", "invalidLoginUsername": "输入的用户名无效", diff --git a/src/locales/zh_TW/menu-ui-handler.ts b/src/locales/zh_TW/menu-ui-handler.ts index 6108b732d95..77aa45ad1bf 100644 --- a/src/locales/zh_TW/menu-ui-handler.ts +++ b/src/locales/zh_TW/menu-ui-handler.ts @@ -18,6 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "選擇要導出的存檔位。", "importData": "導入數據", "exportData": "導出數據", + "linkDiscord": "Link Discord", + "unlinkDiscord": "Unlink Discord", + "linkGoogle": "Link Google", + "unlinkGoogle": "Unlink Google", "cancel": "取消", "losingProgressionWarning": "你將失去自戰鬥開始以來的所有進度。是否\n繼續?" } as const; diff --git a/src/locales/zh_TW/menu.ts b/src/locales/zh_TW/menu.ts index 443b569d908..9758b0da175 100644 --- a/src/locales/zh_TW/menu.ts +++ b/src/locales/zh_TW/menu.ts @@ -17,6 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "用戶名", "password": "密碼", "login": "登入", + "orUse": "Or use", "register": "注冊", "emptyUsername": "用戶名不能為空", "invalidLoginUsername": "提供的用戶名無效", diff --git a/src/phases.ts b/src/phases.ts index dd3ebf148fb..4c63aaabf42 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -130,6 +130,16 @@ export class LoginPhase extends Phase { } ] }); + }, () => { + const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/discord/callback`); + const discordId = import.meta.env.VITE_DISCORD_CLIENT_ID; + const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify`; + window.open(discordUrl, "_self"); + }, () => { + const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/google/callback`); + const googleId = import.meta.env.VITE_GOOGLE_CLIENT_ID; + const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&redirect_uri=${redirectUri}&response_type=code&scope=openid`; + window.open(googleUrl, "_self"); } ] }); diff --git a/src/ui/login-form-ui-handler.ts b/src/ui/login-form-ui-handler.ts index 3b75c6f7c13..810f4a0e754 100644 --- a/src/ui/login-form-ui-handler.ts +++ b/src/ui/login-form-ui-handler.ts @@ -3,8 +3,65 @@ import { ModalConfig } from "./modal-ui-handler"; import * as Utils from "../utils"; import { Mode } from "./ui"; import i18next from "i18next"; +import BattleScene from "#app/battle-scene.js"; +import { addTextObject, TextStyle } from "./text"; +import { addWindow } from "./ui-theme"; export default class LoginFormUiHandler extends FormModalUiHandler { + private googleImage: Phaser.GameObjects.Image; + private discordImage: Phaser.GameObjects.Image; + private externalPartyContainer: Phaser.GameObjects.Container; + private externalPartyBg: Phaser.GameObjects.NineSlice; + private externalPartyTitle: Phaser.GameObjects.Text; + constructor(scene: BattleScene, mode?: Mode) { + super(scene, mode); + } + + setup(): void { + + super.setup(); + this.externalPartyContainer = this.scene.add.container(0, 0); + this.externalPartyContainer.setInteractive(new Phaser.Geom.Rectangle(0, 0, this.scene.game.canvas.width / 12, this.scene.game.canvas.height / 12), Phaser.Geom.Rectangle.Contains); + this.externalPartyTitle = addTextObject(this.scene, 0, 4, "", TextStyle.SETTINGS_LABEL); + this.externalPartyTitle.setOrigin(0.5, 0); + this.externalPartyBg = addWindow(this.scene, 0, 0, 0, 0); + this.externalPartyContainer.add(this.externalPartyBg); + this.externalPartyContainer.add(this.externalPartyTitle); + + const googleImage = this.scene.add.image(0, 0, "google"); + googleImage.setOrigin(0, 0); + googleImage.setScale(0.07); + googleImage.setInteractive(); + googleImage.setName("google-icon"); + googleImage.on("pointerdown", () => { + const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/google/callback`); + const googleId = import.meta.env.VITE_GOOGLE_CLIENT_ID; + const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&redirect_uri=${redirectUri}&response_type=code&scope=openid`; + window.open(googleUrl, "_self"); + }); + this.googleImage = googleImage; + + const discordImage = this.scene.add.image(20, 0, "discord"); + discordImage.setOrigin(0, 0); + discordImage.setScale(0.07); + discordImage.setInteractive(); + discordImage.setName("discord-icon"); + discordImage.on("pointerdown", () => { + const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/discord/callback`); + const discordId = import.meta.env.VITE_DISCORD_CLIENT_ID; + const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify`; + window.open(discordUrl, "_self"); + }); + this.discordImage = discordImage; + + this.externalPartyContainer.add(this.googleImage); + this.externalPartyContainer.add(this.discordImage); + this.getUi().add(this.externalPartyContainer); + this.externalPartyContainer.add(this.googleImage); + this.externalPartyContainer.add(this.discordImage); + this.externalPartyContainer.setVisible(false); + } + getModalTitle(config?: ModalConfig): string { return i18next.t("menu:login"); } @@ -22,7 +79,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { } getButtonLabels(config?: ModalConfig): string[] { - return [ i18next.t("menu:login"), i18next.t("menu:register") ]; + return [ i18next.t("menu:login"), i18next.t("menu:register")]; } getReadableErrorMessage(error: string): string { @@ -46,8 +103,10 @@ export default class LoginFormUiHandler extends FormModalUiHandler { show(args: any[]): boolean { if (super.show(args)) { - const config = args[0] as ModalConfig; + this.processExternalProvider(); + + const config = args[0] as ModalConfig; const originalLoginAction = this.submitAction; this.submitAction = (_) => { // Prevent overlapping overrides on action modification @@ -83,4 +142,33 @@ export default class LoginFormUiHandler extends FormModalUiHandler { return false; } + + clear() { + super.clear(); + this.externalPartyContainer.setVisible(false); + + this.discordImage.off("pointerdown"); + this.googleImage.off("pointerdown"); + } + + processExternalProvider() : void { + this.externalPartyTitle.setText(i18next.t("menu:orUse")); + this.externalPartyTitle.setX(20+this.externalPartyTitle.text.length); + this.externalPartyTitle.setVisible(true); + this.externalPartyContainer.setPositionRelative(this.modalContainer, 175, 0); + this.externalPartyContainer.setVisible(true); + this.externalPartyBg.setSize(this.externalPartyTitle.text.length+50, this.modalBg.height); + this.getUi().moveTo(this.externalPartyContainer, this.getUi().length - 1); + this.googleImage.setPosition(this.externalPartyBg.width/3.1,this.externalPartyBg.height-60); + this.discordImage.setPosition(this.externalPartyBg.width/3.1, this.externalPartyBg.height-40); + + this.externalPartyContainer.setAlpha(0); + this.scene.tweens.add({ + targets: this.externalPartyContainer, + duration: Utils.fixedInt(1000), + ease: "Sine.easeInOut", + y: "-=24", + alpha: 1 + }); + } } diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 5b1b2caf917..81c22323618 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -6,7 +6,7 @@ import { addWindow } from "./ui-theme"; import MessageUiHandler from "./message-ui-handler"; import { OptionSelectConfig, OptionSelectItem } from "./abstact-option-select-ui-handler"; import { Tutorial, handleTutorial } from "../tutorial"; -import { updateUserInfo } from "../account"; +import { loggedInUser, updateUserInfo } from "../account"; import i18next from "i18next"; import {Button} from "#enums/buttons"; import { GameDataType } from "#enums/game-data-type"; @@ -21,7 +21,7 @@ export enum MenuOptions { MANAGE_DATA, COMMUNITY, SAVE_AND_QUIT, - LOG_OUT + LOG_OUT, } const wikiUrl = "https://wiki.pokerogue.net/start"; @@ -303,6 +303,51 @@ export default class MenuUiHandler extends MessageUiHandler { success = true; break; case MenuOptions.MANAGE_DATA: + if (!bypassLogin && !this.manageDataConfig.options.some(o => o.label === i18next.t("menuUiHandler:linkDiscord") || o.label === i18next.t("menuUiHandler:unlinkDiscord"))) { + this.manageDataConfig.options.splice(this.manageDataConfig.options.length-1,0, + { + label: loggedInUser.discordId === "" ? i18next.t("menuUiHandler:linkDiscord") : i18next.t("menuUiHandler:unlinkDiscord"), + handler: () => { + if (loggedInUser?.discordId === "") { + const token = Utils.getCookie(Utils.sessionIdKey); + const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/discord/callback`); + const discordId = import.meta.env.VITE_DISCORD_CLIENT_ID; + const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify&state=${token}`; + window.open(discordUrl, "_self"); + return true; + } else { + Utils.apiPost("/auth/discord/logout", undefined, undefined, true).then(res => { + if (!res.ok) { + console.error(`Unlink failed (${res.status}: ${res.statusText})`); + } + updateUserInfo().then(() => this.scene.reset(true, true)); + }); + return true; + } + } + }, + { + label: loggedInUser?.googleId === "" ? i18next.t("menuUiHandler:linkGoogle") : i18next.t("menuUiHandler:unlinkGoogle"), + handler: () => { + if (loggedInUser?.googleId === "") { + const token = Utils.getCookie(Utils.sessionIdKey); + const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/google/callback`); + const googleId = import.meta.env.VITE_GOOGLE_CLIENT_ID; + const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&response_type=code&redirect_uri=${redirectUri}&scope=openid&state=${token}`; + window.open(googleUrl, "_self"); + return true; + } else { + Utils.apiPost("/auth/google/logout", undefined, undefined, true).then(res => { + if (!res.ok) { + console.error(`Unlink failed (${res.status}: ${res.statusText})`); + } + updateUserInfo().then(() => this.scene.reset(true, true)); + }); + return true; + } + } + }); + } ui.setOverlayMode(Mode.MENU_OPTION_SELECT, this.manageDataConfig); success = true; break; diff --git a/src/vite.env.d.ts b/src/vite.env.d.ts index b588b5b1145..ba466ecb27c 100644 --- a/src/vite.env.d.ts +++ b/src/vite.env.d.ts @@ -5,6 +5,8 @@ interface ImportMetaEnv { readonly VITE_BYPASS_TUTORIAL?: string; readonly VITE_API_BASE_URL?: string; readonly VITE_SERVER_URL?: string; + readonly VITE_DISCORD_CLIENT_ID?: string; + readonly VITE_GOOGLE_CLIENT_ID?: string; } interface ImportMeta { From dbb1fc1ce22d7e64a6818b6f6b5ad7fdbab2914b Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Wed, 19 Jun 2024 17:37:11 +0100 Subject: [PATCH 2/6] refactor: Add missing properties to initLoggedInUser function --- src/account.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/account.ts b/src/account.ts index f6dd3d479a5..7fd1d208496 100644 --- a/src/account.ts +++ b/src/account.ts @@ -13,7 +13,7 @@ export let loggedInUser: UserInfo = null; export const clientSessionId = Utils.randomString(32); export function initLoggedInUser(): void { - loggedInUser = { username: "Guest", lastSessionSlot: -1 }; + loggedInUser = { username: "Guest", lastSessionSlot: -1, discordId: "", googleId: ""}; } export function updateUserInfo(): Promise<[boolean, integer]> { From ef5847dee38659a949e20593ab557f9239385bec Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Sun, 23 Jun 2024 01:52:52 +0100 Subject: [PATCH 3/6] Update src/locales/de/menu-ui-handler.ts Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> --- src/locales/de/menu-ui-handler.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/locales/de/menu-ui-handler.ts b/src/locales/de/menu-ui-handler.ts index 1e04fc04599..7c5858540ca 100644 --- a/src/locales/de/menu-ui-handler.ts +++ b/src/locales/de/menu-ui-handler.ts @@ -18,10 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "Wähle einen Slot zum Exportieren.", "importData": "Daten importieren", "exportData": "Daten exportieren", - "linkDiscord": "Link Discord", - "unlinkDiscord": "Unlink Discord", - "linkGoogle": "Link Google", - "unlinkGoogle": "Unlink Google", + "linkDiscord": "Discord verbinden", + "unlinkDiscord": "Discord trennen", + "linkGoogle": "Google verbinden", + "unlinkGoogle": "Google trennen", "cancel": "Abbrechen", "losingProgressionWarning": "Du wirst jeglichen Fortschritt seit Anfang dieses Kampfes verlieren. Fortfahren?" } as const; From ea4e56b92962274240c1332492f5e7fddb8f0c24 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Wed, 10 Jul 2024 19:56:37 +0100 Subject: [PATCH 4/6] Update src/locales/ko/menu-ui-handler.ts Co-authored-by: lnuvy --- src/locales/ko/menu-ui-handler.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/locales/ko/menu-ui-handler.ts b/src/locales/ko/menu-ui-handler.ts index b62ff2247e3..2e036f49b4d 100644 --- a/src/locales/ko/menu-ui-handler.ts +++ b/src/locales/ko/menu-ui-handler.ts @@ -18,10 +18,10 @@ export const menuUiHandler: SimpleTranslationEntries = { "exportSlotSelect": "내보낼 슬롯을 골라주세요.", "importData": "데이터 불러오기", "exportData": "데이터 내보내기", - "linkDiscord": "Link Discord", - "unlinkDiscord": "Unlink Discord", - "linkGoogle": "Link Google", - "unlinkGoogle": "Unlink Google", + "linkDiscord": "디스코드 연동", + "unlinkDiscord": "디스코드 연동해제", + "linkGoogle": "구글 연동", + "unlinkGoogle": "구글 연동해제", "cancel": "취소", "losingProgressionWarning": "전투 시작으로부터의 진행 상황을 잃게 됩니다. 계속하시겠습니까?", "noEggs": "부화중인 알이 없습니다!" From cf1e457edc03ad0a208ffab639edd6918b456a7b Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Wed, 10 Jul 2024 19:56:48 +0100 Subject: [PATCH 5/6] Update src/locales/ko/menu.ts Co-authored-by: lnuvy --- src/locales/ko/menu.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/ko/menu.ts b/src/locales/ko/menu.ts index 945f4e711f8..1025ccff5c5 100644 --- a/src/locales/ko/menu.ts +++ b/src/locales/ko/menu.ts @@ -17,7 +17,7 @@ export const menu: SimpleTranslationEntries = { "username": "이름", "password": "비밀번호", "login": "로그인", - "orUse": "Or use", + "orUse": "혹은", "register": "등록", "emptyUsername": "이름은 비워둘 수 없습니다", "invalidLoginUsername": "사용할 수 없는 이름입니다", From cbf9bdba46009317958c553e9d3e07c51e8fb3f8 Mon Sep 17 00:00:00 2001 From: Frederico Santos Date: Wed, 10 Jul 2024 21:33:35 +0100 Subject: [PATCH 6/6] chore: Update environment variables for beta and production environments --- .env.beta | 4 +++- .env.production | 4 +++- src/phases.ts | 4 ++-- src/test/utils/mocks/mocksContainer/mockText.ts | 6 +++++- src/ui/login-form-ui-handler.ts | 6 +++--- src/ui/menu-ui-handler.ts | 4 ++-- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.env.beta b/.env.beta index 8d1e93b3277..3f23d53ea3e 100644 --- a/.env.beta +++ b/.env.beta @@ -1,3 +1,5 @@ VITE_BYPASS_LOGIN=0 VITE_BYPASS_TUTORIAL=0 -VITE_SERVER_URL=https://api.beta.pokerogue.net \ No newline at end of file +VITE_SERVER_URL=https://api.beta.pokerogue.net +VITE_DISCORD_CLIENT_ID=1248062921129459756 +VITE_GOOGLE_CLIENT_ID=955345393540-2k6lfftf0fdnb0krqmpthjnqavfvvf73.apps.googleusercontent.com \ No newline at end of file diff --git a/.env.production b/.env.production index 74818d41a12..4d4d8a3aaf3 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,5 @@ VITE_BYPASS_LOGIN=0 VITE_BYPASS_TUTORIAL=0 -VITE_SERVER_URL=https://api.pokerogue.net \ No newline at end of file +VITE_SERVER_URL=https://api.pokerogue.net +VITE_DISCORD_CLIENT_ID=1248062921129459756 +VITE_GOOGLE_CLIENT_ID=955345393540-2k6lfftf0fdnb0krqmpthjnqavfvvf73.apps.googleusercontent.com \ No newline at end of file diff --git a/src/phases.ts b/src/phases.ts index c34889be8f3..c9f9c3c31b2 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -131,12 +131,12 @@ export class LoginPhase extends Phase { ] }); }, () => { - const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/discord/callback`); + const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/discord/callback`); const discordId = import.meta.env.VITE_DISCORD_CLIENT_ID; const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify`; window.open(discordUrl, "_self"); }, () => { - const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/google/callback`); + const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/google/callback`); const googleId = import.meta.env.VITE_GOOGLE_CLIENT_ID; const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&redirect_uri=${redirectUri}&response_type=code&scope=openid`; window.open(googleUrl, "_self"); diff --git a/src/test/utils/mocks/mocksContainer/mockText.ts b/src/test/utils/mocks/mocksContainer/mockText.ts index 1dd440fde7c..f4513e20926 100644 --- a/src/test/utils/mocks/mocksContainer/mockText.ts +++ b/src/test/utils/mocks/mocksContainer/mockText.ts @@ -8,6 +8,7 @@ export default class MockText { private textureManager; public list = []; public style; + public text = ""; constructor(textureManager, x, y, content, styleOptions) { this.scene = textureManager.scene; @@ -17,6 +18,8 @@ export default class MockText { // Phaser.GameObjects.Text.prototype.updateText = () => null; // Phaser.Textures.TextureManager.prototype.addCanvas = () => {}; UI.prototype.showText = this.showText; + this.text = ""; + this.phaserText = ""; // super(scene, x, y); // this.phaserText = new Phaser.GameObjects.Text(scene, x, y, content, styleOptions); } @@ -150,7 +153,8 @@ export default class MockText { setText(text) { // Sets the text this Game Object will display. - // return this.phaserText.setText(text); + // return this.phaserText.setText\(text); + this.text = text; } setAngle(angle) { diff --git a/src/ui/login-form-ui-handler.ts b/src/ui/login-form-ui-handler.ts index 810f4a0e754..2a4f419cbbc 100644 --- a/src/ui/login-form-ui-handler.ts +++ b/src/ui/login-form-ui-handler.ts @@ -34,7 +34,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { googleImage.setInteractive(); googleImage.setName("google-icon"); googleImage.on("pointerdown", () => { - const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/google/callback`); + const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/google/callback`); const googleId = import.meta.env.VITE_GOOGLE_CLIENT_ID; const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&redirect_uri=${redirectUri}&response_type=code&scope=openid`; window.open(googleUrl, "_self"); @@ -47,7 +47,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { discordImage.setInteractive(); discordImage.setName("discord-icon"); discordImage.on("pointerdown", () => { - const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/discord/callback`); + const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/discord/callback`); const discordId = import.meta.env.VITE_DISCORD_CLIENT_ID; const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify`; window.open(discordUrl, "_self"); @@ -152,7 +152,7 @@ export default class LoginFormUiHandler extends FormModalUiHandler { } processExternalProvider() : void { - this.externalPartyTitle.setText(i18next.t("menu:orUse")); + this.externalPartyTitle.setText(i18next.t("menu:orUse") ?? ""); this.externalPartyTitle.setX(20+this.externalPartyTitle.text.length); this.externalPartyTitle.setVisible(true); this.externalPartyContainer.setPositionRelative(this.modalContainer, 175, 0); diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 782498e03de..3bfbb3576cc 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -339,7 +339,7 @@ export default class MenuUiHandler extends MessageUiHandler { handler: () => { if (loggedInUser?.discordId === "") { const token = Utils.getCookie(Utils.sessionIdKey); - const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/discord/callback`); + const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/discord/callback`); const discordId = import.meta.env.VITE_DISCORD_CLIENT_ID; const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=${discordId}&redirect_uri=${redirectUri}&response_type=code&scope=identify&state=${token}`; window.open(discordUrl, "_self"); @@ -360,7 +360,7 @@ export default class MenuUiHandler extends MessageUiHandler { handler: () => { if (loggedInUser?.googleId === "") { const token = Utils.getCookie(Utils.sessionIdKey); - const redirectUri = encodeURIComponent(`${Utils.serverUrl}/auth/google/callback`); + const redirectUri = encodeURIComponent(`${import.meta.env.VITE_SERVER_URL}/auth/google/callback`); const googleId = import.meta.env.VITE_GOOGLE_CLIENT_ID; const googleUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${googleId}&response_type=code&redirect_uri=${redirectUri}&scope=openid&state=${token}`; window.open(googleUrl, "_self");