diff --git a/PROJECT/Yamanobo-Ryou/index.html b/PROJECT/Yamanobo-Ryou/index.html index 8df302f..03ba71f 100644 --- a/PROJECT/Yamanobo-Ryou/index.html +++ b/PROJECT/Yamanobo-Ryou/index.html @@ -10,7 +10,7 @@ 山田凉上山 - + @@ -42,15 +42,15 @@
  • -
  • - + @@ -1567,10 +1567,17 @@

    游戏

      -
    • - +
    • + Del
    • +
    • + +
    @@ -1658,13 +1665,13 @@

    文库

  • - +
  • - +
  • - +
  • @@ -1712,16 +1719,16 @@

    文库

  • - +
  • 若要分享导出的数据,请注意其中是否包含个人信息。「重置文库」可将文库恢复至初始状态,仅有内置文本。重置前建议先备份当前文库。

    @@ -1776,13 +1783,13 @@

    设定

  • - +
  • - +
  • - +
  • - +
  • - +
  • @@ -1897,13 +1904,17 @@

    设定

  • - 其他 -

    您可将本网页安装至桌面,以 progressive web app (俗称小程序) 的形式更方便地使用。若下面的按钮不可用,请尝试前往浏览器的菜单来安装。

    + PWA +

    您可将本网页安装至桌面,以 PWA (俗称小程序) 的形式更方便地使用。若下面的按钮不可用,请尝试前往浏览器的菜单来安装。

    +

    状态

    +

    PWA 模式:未知
    + PWA service worker registration:未知
    + PWA service worker controller:未知

  • @@ -1949,10 +1960,10 @@

    设定

  • - +
  • - +
  • @@ -1977,10 +1988,10 @@

    帮助

    本游戏的教程以 PDF 文档的形式提供。这方便您保存至本地,还可以打印出来备用。

    @@ -1988,18 +1999,20 @@

    帮助

  • 参与进来 +

    反馈

    您可通过以下渠道向我提供反馈:

    +

    翻译

    Help me translate the webpage into your language! Please contact me if you are interested.

  • @@ -2037,11 +2050,12 @@

    图标

    关于

    山田凉上山

    by SAM TOKI STUDIO

    -

    版本 v1.01 ()
    +

    版本 v1.03 ()
    始于 2024/10/13

    + @@ -2099,13 +2113,13 @@

    图标

    diff --git a/PROJECT/Yamanobo-Ryou/manifests/manifest.json b/PROJECT/Yamanobo-Ryou/manifests/manifest.json index e623106..1eb3ce6 100644 --- a/PROJECT/Yamanobo-Ryou/manifests/manifest.json +++ b/PROJECT/Yamanobo-Ryou/manifests/manifest.json @@ -1,4 +1,5 @@ { + "lang": "zh-CN", "name": "山田凉上山", "short_name": "山田凉上山", "icons": [ diff --git a/PROJECT/Yamanobo-Ryou/script_ServiceWorker.js b/PROJECT/Yamanobo-Ryou/script_ServiceWorker.js new file mode 100644 index 0000000..df4062c --- /dev/null +++ b/PROJECT/Yamanobo-Ryou/script_ServiceWorker.js @@ -0,0 +1,59 @@ +// For SamToki.github.io/Yamanobo-Ryou +// Released under GNU GPL v3 open source license. +// (C) 2024 SAM TOKI STUDIO + +// Initialization + // Declare variables + "use strict"; + // Unsaved + const CacheName = "Yamanobo-Ryou_v1.03"; + +// Listeners + // Service worker (https://learn.microsoft.com/en-us/microsoft-edge/progressive-web-apps-chromium/how-to/#step-5---add-a-service-worker) + self.addEventListener("install", Event => { + Event.waitUntil((async() => { + const CacheContent = await caches.open(CacheName); + CacheContent.addAll([ + "index.html", + "icons/favicon.ico", + "../styles/common.css", + "../styles/common_Dark.css", + "../styles/common_Genshin.css", + "../styles/common_HighContrast.css", + "styles/style.css", + "styles/style_Dark.css", + "styles/style_Genshin.css", + "styles/style_HighContrast.css", + "../scripts/common.js", + "../scripts/common_UserDataRepairer.js", + "scripts/script.js", + "manifests/manifest.json", + "../cursors/BTRAhoge.cur", + "../cursors/Genshin.cur", + "../cursors/GenshinFurina.cur", + "../cursors/GenshinNahida.cur", + "images/Icon.png", + "images/Icon_Large.png", + "images/Icon_Maskable.png", + "images/Preview.jpg", + "images/Background.jpg", + "images/YamadaRyou.png", + "images/GotouHitori.png", + "docs/山田凉上山 快速入门.pdf", + "docs/山田凉上山 说明文档.pdf" + ]); + })()); + }); + self.addEventListener("fetch", Event => { + Event.respondWith((async() => { + const CacheContent = await caches.open(CacheName); + const CachedResponse = await CacheContent.match(Event.request); + if(CachedResponse) { + return CachedResponse; + } else { + const FetchResponse = await fetch(Event.request); + CacheContent.put(Event.request, FetchResponse.clone()); + return FetchResponse; + } + })()); + }); diff --git a/PROJECT/Yamanobo-Ryou/scripts/script.js b/PROJECT/Yamanobo-Ryou/scripts/script.js index e5cb871..108cba5 100644 --- a/PROJECT/Yamanobo-Ryou/scripts/script.js +++ b/PROJECT/Yamanobo-Ryou/scripts/script.js @@ -6,7 +6,7 @@ // Declare variables "use strict"; // Unsaved - const CurrentVersion = 1.01; + const CurrentVersion = 1.03; var Game0 = { Terrain: { WalkedWidth: 0, @@ -122,9 +122,10 @@ ] }; - // Load user data + // Load window.onload = Load(); function Load() { + // User data if(localStorage.System != undefined) { System = JSON.parse(localStorage.getItem("System")); } @@ -184,6 +185,8 @@ if(localStorage.YamanoboRyou_Library != undefined) { Library = JSON.parse(localStorage.getItem("YamanoboRyou_Library")); } + + // Refresh ChangeValue("Textbox_LibraryFilter", ""); ChangeValue("Textbox_LibraryImport", ""); ChangeText("Ctnr_GameTerrain", ""); @@ -193,13 +196,91 @@ RefreshGame(); RefreshHighscore(); RefreshLibrary(); + + // PWA + navigator.serviceWorker.register("script_ServiceWorker.js").then(function(ServiceWorkerRegistration) { + // Detect update (https://stackoverflow.com/a/41896649) + ServiceWorkerRegistration.addEventListener("updatefound", function() { + const ServiceWorkerInstallation = ServiceWorkerRegistration.installing; + ServiceWorkerInstallation.addEventListener("statechange", function() { + if(ServiceWorkerInstallation.state == "installed" && navigator.serviceWorker.controller != null) { + Show("Label_HelpPWAUpdateReady"); + ShowDialog("System_PWAUpdateReady", + "Info", + "新版本已就绪。请重新打开本网页来应用更新 (不要使用刷新按钮)。", + "", "", "", "确定"); + } + }); + }); + + // Read service worker status (https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/registration-events/index.html) + switch(true) { + case ServiceWorkerRegistration.installing != null: + ChangeText("Label_SettingsPWAServiceWorkerRegistration", "等待生效"); + break; + case ServiceWorkerRegistration.waiting != null: + ChangeText("Label_SettingsPWAServiceWorkerRegistration", "等待更新"); + Show("Label_HelpPWAUpdateReady"); + ShowDialog("System_PWAUpdateReady", + "Info", + "新版本已就绪。请重新打开本网页来应用更新 (不要使用刷新按钮)。", + "", "", "", "确定"); + break; + case ServiceWorkerRegistration.active != null: + ChangeText("Label_SettingsPWAServiceWorkerRegistration", "已生效"); + break; + default: + break; + } + if(navigator.serviceWorker.controller != null) { + ChangeText("Label_SettingsPWAServiceWorkerController", "已生效"); + } else { + ChangeText("Label_SettingsPWAServiceWorkerController", "未生效"); + } + }); + + // Ready Focus("Textbox_Game"); setTimeout(HideToast, 0); } // Refresh + // Webpage + function RefreshWebpage() { + ShowDialog("System_RefreshingWebpage", + "Info", + "正在刷新网页...", + "", "", "", "确定"); + ChangeCursorOverall("wait"); + window.location.reload(); + } + // System function RefreshSystem() { + // Topbar + if(IsMobileLayout() == false) { + HideHorizontally("Button_Nav"); + ChangeInert("DropctrlGroup_Nav", false); + } else { + Show("Button_Nav"); + ChangeInert("DropctrlGroup_Nav", true); + } + + // Fullscreen + if(IsFullscreen() == false) { + Show("Topbar"); + ChangeText("Button_GameToggleFullscreen", + "" + + " " + + ""); + } else { + Hide("Topbar"); + ChangeText("Button_GameToggleFullscreen", + "" + + " " + + ""); + } + // Settings // Display if(window.matchMedia("(prefers-contrast: more)").matches == false) { @@ -289,6 +370,13 @@ ChangeValue("Combobox_SettingsAnim", System.Display.Anim); ChangeAnimOverall(System.Display.Anim); + // PWA + if(window.matchMedia("(display-mode: standalone)").matches == true) { + ChangeText("Label_SettingsPWAMode", "是"); + } else { + ChangeText("Label_SettingsPWAMode", "否"); + } + // Dev ChangeChecked("Checkbox_SettingsTryToOptimizePerformance", System.Dev.TryToOptimizePerformance); if(System.Dev.TryToOptimizePerformance == true) { @@ -751,7 +839,7 @@ // Victory if(Game.Status.IsRunning == true && Game.Stats.Progress >= 100) { Game.Stats.Progress = 100; - ChangeDisabled("Cmdbtn_GamePauseOrReset", true); + ChangeDisabled("Button_GamePauseOrReset", true); if(Game.Status.IsPaused == false) { Game.Status.IsPaused = true; ChangeValue("Textbox_Game", ""); @@ -773,7 +861,7 @@ // Game over if(Game.Status.IsRunning == true && Game.Stats.Odometer > 20 && Game.Stats.ChaserOdometer >= Game.Stats.Odometer) { Game.Stats.ChaserOdometer = Game.Stats.Odometer; - ChangeDisabled("Cmdbtn_GamePauseOrReset", true); + ChangeDisabled("Button_GamePauseOrReset", true); if(Game.Status.IsPaused == false) { Game.Status.IsPaused = true; ChangeValue("Textbox_Game", ""); @@ -798,8 +886,8 @@ // Ctrls if(Game.Status.IsRunning == false) { - ChangeDisabled("Cmdbtn_GamePauseOrReset", true); - ChangeText("Cmdbtn_GamePauseOrReset", "暂停"); + ChangeDisabled("Button_GamePauseOrReset", true); + ChangeText("Button_GamePauseOrReset", "暂停"); ChangeDisabled("Fieldset_Library", false); ChangeDisabled("Fieldset_LibraryTextProperties", false); ChangeDisabled("Fieldset_LibraryManagement", false); @@ -807,11 +895,11 @@ ChangeDisabled("Fieldset_SettingsDifficulty", false); ChangeDisabled("Combobox_SettingsGameFont", false); } else { - ChangeDisabled("Cmdbtn_GamePauseOrReset", false); + ChangeDisabled("Button_GamePauseOrReset", false); if(Game.Status.IsPaused == false) { - ChangeText("Cmdbtn_GamePauseOrReset", "暂停"); + ChangeText("Button_GamePauseOrReset", "暂停"); } else { - ChangeText("Cmdbtn_GamePauseOrReset", "重置"); + ChangeText("Button_GamePauseOrReset", "重置"); } ChangeDisabled("Fieldset_Library", true); ChangeDisabled("Fieldset_LibraryTextProperties", true); @@ -850,17 +938,17 @@ // Difficulty ChangeValue("Textbox_SettingsChaserSpeedInitial", Game.Difficulty.ChaserSpeed.Initial); ChangeValue("Textbox_SettingsChaserSpeedFinal", Game.Difficulty.ChaserSpeed.Final); - RemoveClass("Cmdbtn_SettingsChaserSpeedWestern", "Active"); - RemoveClass("Cmdbtn_SettingsChaserSpeedCJK", "Active"); - RemoveClass("Cmdbtn_SettingsChaserSpeedZenMode", "Active"); + RemoveClass("Button_SettingsChaserSpeedWestern", "Active"); + RemoveClass("Button_SettingsChaserSpeedCJK", "Active"); + RemoveClass("Button_SettingsChaserSpeedZenMode", "Active"); if(Game.Difficulty.ChaserSpeed.Initial == 180 && Game.Difficulty.ChaserSpeed.Final == 240) { - AddClass("Cmdbtn_SettingsChaserSpeedWestern", "Active"); + AddClass("Button_SettingsChaserSpeedWestern", "Active"); } if(Game.Difficulty.ChaserSpeed.Initial == 40 && Game.Difficulty.ChaserSpeed.Final == 60) { - AddClass("Cmdbtn_SettingsChaserSpeedCJK", "Active"); + AddClass("Button_SettingsChaserSpeedCJK", "Active"); } if(Game.Difficulty.ChaserSpeed.Initial == 10 && Game.Difficulty.ChaserSpeed.Final == 10) { - AddClass("Cmdbtn_SettingsChaserSpeedZenMode", "Active"); + AddClass("Button_SettingsChaserSpeedZenMode", "Active"); } ChangeValue("Textbox_SettingsMaxSeparation", Game.Difficulty.MaxSeparation); @@ -938,18 +1026,18 @@ " " + " " + ConvertEmptyName(Library.Text[Looper].Name) + "" + " " + - " " + - " " + - "