Skip to content

Commit

Permalink
Add OnToggleChanged event
Browse files Browse the repository at this point in the history
  • Loading branch information
lxymahatma committed Feb 11, 2023
1 parent c9efb37 commit 9cf8aa5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/CommonPatches/PatchEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,12 @@ public static class PatchEvents
public static event Action SwitchLanguagesEvent;

internal static void SwitchLanguagesEventInvoke() => SwitchLanguagesEvent?.Invoke();

/// <summary>
/// An event to invoke methods when switching menu
/// </summary>
public static event Action<int, int, bool> MenuSelectEvent;

internal static void MenuSelectEventInvoke(int listIndex, int index, bool isOn) => MenuSelectEvent?.Invoke(listIndex, index, isOn);
}
}
1 change: 1 addition & 0 deletions src/MuseDashMirror.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="CommonPatches\ManualPatches.cs" />
<Compile Include="Main.cs" />
<Compile Include="MelonBuildInfo.cs" />
<Compile Include="Patch\MenuSelectPatch.cs" />
<Compile Include="Patch\PnlMenuPatch.cs" />
<Compile Include="Patch\PnlStagePatch.cs" />
<Compile Include="Patch\StageBattleComponentPatch.cs" />
Expand Down
13 changes: 13 additions & 0 deletions src/Patch/MenuSelectPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using MuseDashMirror.CommonPatches;

namespace MuseDashMirror.Patch
{
[HarmonyPatch(typeof(MenuSelect), "OnToggleChanged")]
internal static class MenuSelectPatch
{
private static void Postfix(int listIndex, int index, bool isOn)
{
PatchEvents.MenuSelectEventInvoke(listIndex, index, isOn);
}
}
}

0 comments on commit 9cf8aa5

Please sign in to comment.