Skip to content

Commit

Permalink
[+] Show alert in CI builds
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Nov 6, 2024
1 parent 99d7fe5 commit 11beb66
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aquamai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions AquaMai/Helpers/MessageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions AquaMai/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

Expand Down
18 changes: 18 additions & 0 deletions AquaMai/Resources/Locale.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions AquaMai/Resources/Locale.resx
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@
<data name="RepeatEndTimeLessThenStartTime" xml:space="preserve">
<value>Repeat end time cannot be less than repeat start time</value>
</data>
<data name="CiBuildAlertTitle" xml:space="preserve">
<value>Important Notice: Test Version</value>
</data>
<data name="CiBuildAlertContent" xml:space="preserve">
<value>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.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions AquaMai/Resources/Locale.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@
<data name="RepeatStartTimeNotSet" xml:space="preserve">
<value>请先设置循环开始时间</value>
</data>
<data name="CiBuildAlertTitle" xml:space="preserve">
<value>重要提示:测试版本</value>
</data>
<data name="CiBuildAlertContent" xml:space="preserve">
<value>您正在使用的是 AquaMai CI 构建版本。由于该版本基于最新的主线代码构建,可能包含未通知的配置文件变更或潜在问题。</value>
</data>
</root>
16 changes: 16 additions & 0 deletions AquaMai/UX/CiBuildAlert.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 11beb66

Please sign in to comment.