Skip to content

Commit c19d8cb

Browse files
committed
Added switch button
1 parent dbd5dcb commit c19d8cb

11 files changed

Lines changed: 64 additions & 38 deletions

File tree

Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Main : MelonMod
1616
internal static int ClickIndex { get; set; } = 0;
1717
internal static bool SetKey { get; set; } = false;
1818

19-
public override void OnInitializeMelon()
19+
public override void OnApplicationStart()
2020
{
2121
Save.Load();
2222
LoggerInstance.Msg("QuickSwitchCombination is loaded!");

Menu.bundle

433 Bytes
Binary file not shown.

Menu.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ namespace QuickSwitchCombination
99
internal class Menu : MonoBehaviour
1010
{
1111
internal static AssetBundle ab { get; set; }
12+
internal static bool ShowMenu { get; set; } = false;
1213

1314
public Menu(IntPtr intPtr) : base(intPtr)
1415
{
1516
}
1617

17-
public static bool ShowMenu = false;
18-
1918
private void Start()
2019
{
2120
if (ab == null)
@@ -72,29 +71,32 @@ private static void SetMenu()
7271
ClassInjector.RegisterTypeInIl2Cpp<Plus>();
7372
ConstantVariables.Plus.AddComponent<Plus>();
7473

75-
SetCombination();
74+
for (int i = 0; i < Save.Settings.datas.Count; i++)
75+
{
76+
SetCombination(i);
77+
}
7678
}
7779

78-
internal static void SetCombination()
80+
internal static void SetCombination(int count)
7981
{
80-
for (int i = 0; i < Save.Settings.datas.Count; i++)
81-
{
82-
var combination = Instantiate(ab.LoadAsset("Assets/Combination.prefab").Cast<GameObject>(), ConstantVariables.ContentTransform);
82+
var combination = Instantiate(ab.LoadAsset("Assets/Combination.prefab").Cast<GameObject>(), ConstantVariables.ContentTransform);
8383

84-
ClassInjector.RegisterTypeInIl2Cpp<Count>();
85-
combination.AddComponent<Count>();
86-
combination.GetComponent<Count>().count = i;
84+
ClassInjector.RegisterTypeInIl2Cpp<Count>();
85+
combination.AddComponent<Count>();
86+
combination.GetComponent<Count>().count = count;
8787

88-
ClassInjector.RegisterTypeInIl2Cpp<Character>();
89-
combination.transform.GetChild(0).gameObject.AddComponent<Character>();
88+
ClassInjector.RegisterTypeInIl2Cpp<Character>();
89+
combination.transform.GetChild(0).gameObject.AddComponent<Character>();
9090

91-
ClassInjector.RegisterTypeInIl2Cpp<Elfin>();
92-
combination.transform.GetChild(1).gameObject.AddComponent<Elfin>();
91+
ClassInjector.RegisterTypeInIl2Cpp<Elfin>();
92+
combination.transform.GetChild(1).gameObject.AddComponent<Elfin>();
9393

94-
ClassInjector.RegisterTypeInIl2Cpp<Key>();
95-
combination.transform.GetChild(2).gameObject.AddComponent<Key>();
96-
combination.transform.GetChild(2).GetChild(0).gameObject.GetComponent<Text>().text = Save.Settings.datas[i].Key.ToString();
97-
}
94+
ClassInjector.RegisterTypeInIl2Cpp<Key>();
95+
combination.transform.GetChild(2).gameObject.AddComponent<Key>();
96+
combination.transform.GetChild(2).GetChild(0).gameObject.GetComponent<Text>().text = Save.Settings.datas[count].Key.ToString();
97+
98+
ClassInjector.RegisterTypeInIl2Cpp<Select>();
99+
combination.transform.GetChild(3).gameObject.AddComponent<Select>();
98100
}
99101
}
100102
}

Plus.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using UnhollowerRuntimeLib;
32
using UnityEngine;
43
using UnityEngine.Events;
54
using UnityEngine.UI;
@@ -19,20 +18,8 @@ private void Start()
1918

2019
private void OnClick()
2120
{
22-
var combination = Instantiate(Menu.ab.LoadAsset("Assets/Combination.prefab").Cast<GameObject>(), ConstantVariables.ContentTransform);
2321
Save.Settings.datas.Add(new Data(KeyCode.None, 0, -1));
24-
25-
ClassInjector.RegisterTypeInIl2Cpp<Count>();
26-
combination.AddComponent<Count>();
27-
combination.GetComponent<Count>().count = Save.Settings.datas.Count - 1;
28-
29-
ClassInjector.RegisterTypeInIl2Cpp<Character>();
30-
combination.transform.GetChild(0).gameObject.AddComponent<Character>();
31-
32-
ClassInjector.RegisterTypeInIl2Cpp<Elfin>();
33-
combination.transform.GetChild(1).gameObject.AddComponent<Elfin>();
34-
ClassInjector.RegisterTypeInIl2Cpp<Key>();
35-
combination.transform.GetChild(2).gameObject.AddComponent<Key>();
22+
Menu.SetCombination(Save.Settings.datas.Count - 1);
3623
}
3724
}
3825
}

Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.0")]
36-
[assembly: AssemblyFileVersion("2.0.0")]
37-
[assembly: MelonInfo(typeof(QuickSwitchCombination.Main), "QuickSwitchCombination", "2.0.0", "lxy")]
35+
[assembly: AssemblyVersion("2.1.0")]
36+
[assembly: AssemblyFileVersion("2.1.0")]
37+
[assembly: MelonInfo(typeof(QuickSwitchCombination.Main), "QuickSwitchCombination", "2.1.0", "lxy")]
3838
[assembly: MelonGame("PeroPeroGames", "MuseDash")]

QuickSwitchCombination.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<Compile Include="Properties\AssemblyInfo.cs" />
105105
<Compile Include="Reload.cs" />
106106
<Compile Include="Save.cs" />
107+
<Compile Include="Select.cs" />
107108
</ItemGroup>
108109
<ItemGroup>
109110
<EmbeddedResource Include="Menu.bundle" />

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ When you launch the game after putting the dll file into the mods folder, the mo
1212
* The default menu key is F11
1313
* After pressing the menu key on the main scene, select character with the first dropdown, and elfin with second dropdown
1414
* Pressing the third button and input the key you want to use for shortcut
15+
* If it's hard for you to memorize the key, press the fourth select switch button to switch
1516

1617
## PS
1718

README.zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* 默认设置的菜单栏键为F11
1414
* 在主界面按下菜单键之后在右边的第一个下拉式菜单栏里选择要使用的人物,第二个下拉式菜单栏中选择要使用的精灵
1515
* 用鼠标点击右边的按钮,并且输入你想要使用的快捷键
16+
* 如果实在记不住按键对应的组合,直接按最后一个选择组合的按键即可切换
1617

1718
##
1819

Reload.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ private void OnClick()
2828
Destroy(ConstantVariables.ContentTransform.GetChild(i).gameObject);
2929
}
3030

31-
Menu.SetCombination();
31+
for (int i = 0; i < Save.Settings.datas.Count; i++)
32+
{
33+
Menu.SetCombination(i);
34+
}
3235
}
3336
}
3437
}

Save.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Data(KeyCode key, int character, int elfin)
3333

3434
public struct Config
3535
{
36-
[TomlPrecedingComment("Menu for adding settings (Still in developing)")]
36+
[TomlPrecedingComment("Menu for adding settings")]
3737
internal KeyCode MenuKey = KeyCode.F11;
3838

3939
internal List<Data> datas { get; init; } = new() { new Data(KeyCode.F12, 11, 7) };

0 commit comments

Comments
 (0)