From 11beb6676eb3f2ade054d8c11be82eaf3e8c53f0 Mon Sep 17 00:00:00 2001 From: Clansty Date: Wed, 6 Nov 2024 11:39:54 +0800 Subject: [PATCH] [+] Show alert in CI builds --- .github/workflows/aquamai.yaml | 2 +- AquaMai/Helpers/MessageHelper.cs | 6 ++++-- AquaMai/Main.cs | 8 ++++++++ AquaMai/Resources/Locale.Designer.cs | 18 ++++++++++++++++++ AquaMai/Resources/Locale.resx | 6 ++++++ AquaMai/Resources/Locale.zh.resx | 6 ++++++ AquaMai/UX/CiBuildAlert.cs | 16 ++++++++++++++++ 7 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 AquaMai/UX/CiBuildAlert.cs diff --git a/.github/workflows/aquamai.yaml b/.github/workflows/aquamai.yaml index 6bafbc81..489f6eca 100644 --- a/.github/workflows/aquamai.yaml +++ b/.github/workflows/aquamai.yaml @@ -29,7 +29,7 @@ jobs: run: | copy /y build-assets\SDEZ\* AquaMai\Libs cd AquaMai - dotnet build -c Release + dotnet build -c Release /p:DefineConstants="CI" - name: Make example config shell: cmd diff --git a/AquaMai/Helpers/MessageHelper.cs b/AquaMai/Helpers/MessageHelper.cs index 0d66c603..348ddd95 100644 --- a/AquaMai/Helpers/MessageHelper.cs +++ b/AquaMai/Helpers/MessageHelper.cs @@ -17,7 +17,7 @@ private static void OnSetMessageManager(IGenericManager genericManager) _genericManager = genericManager; } - public static void ShowMessage(string message, WindowSizeID size = WindowSizeID.Middle) + public static void ShowMessage(string message, WindowSizeID size = WindowSizeID.Middle, string title = null) { if (_genericManager is null) { @@ -27,7 +27,9 @@ public static void ShowMessage(string message, WindowSizeID size = WindowSizeID. _genericManager.Enqueue(0, WindowMessageID.CollectionAttentionEmptyFavorite, new WindowParam() { - hideTitle = true, + hideTitle = title is null, + replaceTitle = true, + title = title, replaceText = true, text = message, changeSize = true, diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index 79798272..8efe9559 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -188,6 +188,9 @@ public override void OnInitializeMelon() Patch(typeof(TestProof)); Patch(typeof(PractiseMode)); Patch(typeof(HideSelfMadeCharts)); +# if CI + Patch(typeof(CiBuildAlert)); +# endif // Apply patches based on the settings ApplyPatches(); @@ -198,6 +201,11 @@ public override void OnInitializeMelon() MelonLogger.Warning("==========================================================================="); } +# if CI + MelonLogger.Warning(Locale.CiBuildAlertTitle); + MelonLogger.Warning(Locale.CiBuildAlertContent); +# endif + MelonLogger.Msg(Locale.Loaded); } diff --git a/AquaMai/Resources/Locale.Designer.cs b/AquaMai/Resources/Locale.Designer.cs index 75e6ae87..06c8962b 100644 --- a/AquaMai/Resources/Locale.Designer.cs +++ b/AquaMai/Resources/Locale.Designer.cs @@ -59,6 +59,24 @@ internal Locale() { } } + /// + /// Looks up a localized string similar to You are using AquaMai CI build version. This version is built from the latest mainline code and may contain undocumented configuration changes or potential issues.. + /// + internal static string CiBuildAlertContent { + get { + return ResourceManager.GetString("CiBuildAlertContent", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Important Notice: Test Version. + /// + internal static string CiBuildAlertTitle { + get { + return ResourceManager.GetString("CiBuildAlertTitle", resourceCulture); + } + } + /// /// Looks up a localized string similar to Loaded!. /// diff --git a/AquaMai/Resources/Locale.resx b/AquaMai/Resources/Locale.resx index 6358fab1..080b297c 100644 --- a/AquaMai/Resources/Locale.resx +++ b/AquaMai/Resources/Locale.resx @@ -95,4 +95,10 @@ Repeat end time cannot be less than repeat start time + + Important Notice: Test Version + + + You are using AquaMai CI build version. This version is built from the latest mainline code and may contain undocumented configuration changes or potential issues. + diff --git a/AquaMai/Resources/Locale.zh.resx b/AquaMai/Resources/Locale.zh.resx index 194d5006..eee9d712 100644 --- a/AquaMai/Resources/Locale.zh.resx +++ b/AquaMai/Resources/Locale.zh.resx @@ -88,4 +88,10 @@ 请先设置循环开始时间 + + 重要提示:测试版本 + + + 您正在使用的是 AquaMai CI 构建版本。由于该版本基于最新的主线代码构建,可能包含未通知的配置文件变更或潜在问题。 + diff --git a/AquaMai/UX/CiBuildAlert.cs b/AquaMai/UX/CiBuildAlert.cs new file mode 100644 index 00000000..b6c2e307 --- /dev/null +++ b/AquaMai/UX/CiBuildAlert.cs @@ -0,0 +1,16 @@ +using AquaMai.Helpers; +using AquaMai.Resources; +using HarmonyLib; +using Process; + +namespace AquaMai.UX; + +public class CiBuildAlert +{ + [HarmonyPatch(typeof(AdvertiseProcess), "OnStart")] + [HarmonyPostfix] + public static void OnStart(AdvertiseProcess __instance) + { + MessageHelper.ShowMessage(Locale.CiBuildAlertContent, title: Locale.CiBuildAlertTitle); + } +}