From 3c99c727c31d245c9668d04ee8bd4de09dac3653 Mon Sep 17 00:00:00 2001 From: RedstonewolfX <108761527+RedstonewolfX@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:52:11 -0400 Subject: [PATCH] Move links Links have been removed from the page A new section for viewing the pages' contents has been added to the menu Achievements, Stats, and Vouchers have been moved to a single panel to make space in the menu --- index.html | 3 +- src/logger.ts | 3 +- src/ui/abstact-option-select-ui-handler.ts | 5 +- src/ui/menu-ui-handler.ts | 122 +++++++++++++++++---- 4 files changed, 104 insertions(+), 29 deletions(-) diff --git a/index.html b/index.html index ebe5b063c52..cc7acb24e69 100644 --- a/index.html +++ b/index.html @@ -116,10 +116,11 @@ diff --git a/src/logger.ts b/src/logger.ts index c3c0d3d287b..88ef18d08f0 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1262,14 +1262,12 @@ function printItemNoNewline(inData: string, indent: string, item: ItemData) { * Sets the name, author, and label for a file. * @param title The display name of the file. * @param authors The author(s) of the file. - * @todo Add label field. */ export function setFileInfo(title: string, authors: string[], label: string) { console.log("Setting file " + rarityslot[1] + " to " + title + " / [" + authors.join(", ") + "]") var fileID = rarityslot[1] as string var drpd = JSON.parse(localStorage.getItem(fileID)) as DRPD; drpd = updateLog(drpd) - drpd.title = title; for (var i = 0; i < authors.length; i++) { while (authors[i][0] == " ") { authors[i] = authors[i].substring(1) @@ -1284,6 +1282,7 @@ export function setFileInfo(title: string, authors: string[], label: string) { i--; } } + drpd.title = title; drpd.authors = authors; drpd.label = label; localStorage.setItem(fileID, JSON.stringify(drpd)) diff --git a/src/ui/abstact-option-select-ui-handler.ts b/src/ui/abstact-option-select-ui-handler.ts index eda469adaf3..35b72d82834 100644 --- a/src/ui/abstact-option-select-ui-handler.ts +++ b/src/ui/abstact-option-select-ui-handler.ts @@ -21,12 +21,13 @@ export interface OptionSelectConfig { export interface OptionSelectItem { label: string; - handler: () => boolean; + handler: (s?: any) => boolean; onHover?: () => void; keepOpen?: boolean; overrideSound?: boolean; item?: string; itemArgs?: any[]; + specialData?: any; } const scrollUpLabel = "↑"; @@ -179,7 +180,7 @@ export default abstract class AbstractOptionSelectUiHandler extends UiHandler { } } const option = this.config?.options[this.cursor + (this.scrollCursor - (this.scrollCursor ? 1 : 0))]; - if (option?.handler()) { + if (option?.handler(option.specialData)) { if (!option.keepOpen) { this.clear(); } diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 1d23e66abee..4a69e6e0162 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -14,9 +14,8 @@ import BgmBar from "#app/ui/bgm-bar"; enum MenuOptions { GAME_SETTINGS, - ACHIEVEMENTS, STATS, - VOUCHERS, + LINKS, EGG_LIST, EGG_GACHA, MANAGE_DATA, @@ -30,6 +29,20 @@ let wikiUrl = "https://wiki.pokerogue.net/start"; const discordUrl = "https://discord.gg/uWpTfdKG49"; const githubUrl = "https://github.com/pagefaultgames/pokerogue"; const redditUrl = "https://www.reddit.com/r/pokerogue"; +const links = [ + ["Privacy Policy", "https://app.termly.io/policy-viewer/policy.html?policyUUID=bc96778b-3f04-4d25-bafc-0deba53e8bec"], + ["Cookie Disclaimer", "https://app.termly.io/policy-viewer/policy.html?policyUUID=8b523c05-7ec2-4646-9534-5bd61b386e2a"], + ["Terms & Conditions", "https://app.termly.io/policy-viewer/policy.html?policyUUID=b01e092a-9721-477f-8356-45576702ff9e"], + ["Acceptable Use Policy", "https://app.termly.io/policy-viewer/policy.html?policyUUID=3b5d1928-3f5b-4ee1-b8df-2d6c276b0bcc"] +] +function goToWebpage(urlIndex: integer) { + const link = document.createElement("a"); + link.href = links[urlIndex][1]; + link.target = "_blank" + link.rel = "noreferrer noopener" + link.click(); + link.remove(); +} export default class MenuUiHandler extends MessageUiHandler { private menuContainer: Phaser.GameObjects.Container; @@ -46,6 +59,8 @@ export default class MenuUiHandler extends MessageUiHandler { protected manageDataConfig: OptionSelectConfig; protected communityConfig: OptionSelectConfig; + protected accountStatsConfig: OptionSelectConfig; + protected legalLinksConfig: OptionSelectConfig; public bgmBar: BgmBar; @@ -196,21 +211,6 @@ export default class MenuUiHandler extends MessageUiHandler { return true; } }, - { - label: "Consent Preferences", - handler: () => { - const consentLink = document.querySelector(".termly-display-preferences") as HTMLInputElement; - const clickEvent = new MouseEvent("click", { - view: window, - bubbles: true, - cancelable: true - }); - consentLink.dispatchEvent(clickEvent); - consentLink.focus(); - return true; - }, - keepOpen: true - }, { label: i18next.t("menuUiHandler:cancel"), handler: () => { @@ -225,6 +225,84 @@ export default class MenuUiHandler extends MessageUiHandler { options: manageDataOptions }; + const accountOptions: OptionSelectItem[] = [ + { + label: "Stats", + handler: () => { + ui.setOverlayMode(Mode.GAME_STATS); + return true; + } + }, + { + label: "Achievements", + handler: () => { + ui.setOverlayMode(Mode.ACHIEVEMENTS); + return true; + } + }, + { + label: "Vouchers", + handler: () => { + ui.setOverlayMode(Mode.VOUCHERS); + return true; + } + }, + { + label: i18next.t("menuUiHandler:cancel"), + handler: () => { + this.scene.ui.revertMode(); + return true; + }, + keepOpen: true + } + ] + + this.accountStatsConfig = { + xOffset: 98, + options: accountOptions + }; + + const siteOptions: OptionSelectItem[] = [ + { + label: "Consent Preferences", + handler: () => { + const consentLink = document.querySelector(".termly-display-preferences") as HTMLInputElement; + const clickEvent = new MouseEvent("click", { + view: window, + bubbles: true, + cancelable: true + }); + consentLink.dispatchEvent(clickEvent); + consentLink.focus(); + return true; + }, + keepOpen: true + } + ] + for (var i = 0; i < links.length; i++) { + siteOptions.push({ + label: links[i][0], + handler: () => { + window.open(links[i][1], "_blank").focus(); + return true; + }, + keepOpen: true + }) + } + siteOptions.push({ + label: i18next.t("menuUiHandler:cancel"), + handler: () => { + this.scene.ui.revertMode(); + return true; + }, + keepOpen: true + }) + + this.legalLinksConfig = { + xOffset: 98, + options: siteOptions + }; + const communityOptions: OptionSelectItem[] = [ { label: "Wiki", @@ -318,16 +396,12 @@ export default class MenuUiHandler extends MessageUiHandler { ui.setOverlayMode(Mode.SETTINGS); success = true; break; - case MenuOptions.ACHIEVEMENTS: - ui.setOverlayMode(Mode.ACHIEVEMENTS); - success = true; - break; case MenuOptions.STATS: - ui.setOverlayMode(Mode.GAME_STATS); + ui.setOverlayMode(Mode.MENU_OPTION_SELECT, this.accountStatsConfig); success = true; break; - case MenuOptions.VOUCHERS: - ui.setOverlayMode(Mode.VOUCHERS); + case MenuOptions.LINKS: + ui.setOverlayMode(Mode.MENU_OPTION_SELECT, this.legalLinksConfig); success = true; break; case MenuOptions.EGG_LIST: