Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Commit ce713c8

Browse files
committed
refractor and add configure to legacy ui
1 parent d275df1 commit ce713c8

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

LegacyGUIManager.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace KiraiMod.Core.UI
1111
{
12+
[Module]
1213
public static class LegacyGUIManager
1314
{
1415
public static event Action OnLoad;
@@ -22,12 +23,13 @@ public static class LegacyGUIManager
2223
private static BaseInputModule inputFix;
2324
private static BaseInputModule inputOrig;
2425

26+
[Configure<bool>("Visuals.Legacy UI", false, Saved: false)]
2527
public static bool Showing
2628
{
27-
get => UserInterface.active;
29+
get => UserInterface != null && UserInterface.active;
2830
set
2931
{
30-
if (UserInterface.active == value)
32+
if (Showing == value)
3133
return;
3234

3335
UserInterface.active = value;
@@ -41,7 +43,7 @@ static LegacyGUIManager()
4143
{
4244
Events.UIManagerLoaded += OnUIManagerLoaded;
4345

44-
Plugin.cfg.Bind("GUI", "Keybind", new Key[] { Key.RightShift }, "The keybind you want to use to open the GUI").Register(() => Showing ^= true);
46+
Plugin.Configuration.Bind("GUI", "Keybind", new Key[] { Key.RightShift }, "The keybind you want to use to open the GUI").Register(() => Showing ^= true);
4547
}
4648

4749
private static void OnUIManagerLoaded()
@@ -52,7 +54,7 @@ private static void OnUIManagerLoaded()
5254

5355
private static void SetupFix()
5456
{
55-
var sys = GameObject.Find("_Application/UiEventSystem");
57+
GameObject sys = GameObject.Find("_Application/UiEventSystem");
5658
inputOrig = sys.GetComponent<EventSystem>().m_SystemInputModules[0];
5759
(inputFix = sys.AddComponent<StandaloneInputModule>()).enabled = false;
5860
}
@@ -80,7 +82,7 @@ private static void CreateUI()
8082

8183
OnLoadLate?.StableInvoke();
8284

83-
Plugin.log.LogInfo("Loaded GUI");
85+
Plugin.Logger.LogInfo("Loaded GUI");
8486
}
8587

8688
private static void HandleMember(MemberAttribute member)
@@ -134,7 +136,7 @@ private static void HandleMember(MemberAttribute member)
134136

135137
if (found) continue;
136138

137-
Plugin.log.LogDebug("Creating new section: " + section);
139+
Plugin.Logger.LogDebug("Creating new section: " + section);
138140
lowest = new(section, lowest);
139141
}
140142

MemoryEntry.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ public T Value
1212
set
1313
{
1414
value = ClampValue(value);
15-
if (!Equals(_value, value))
16-
{
17-
_value = value;
18-
OnSettingChanged(this);
19-
}
15+
if (Equals(_value, value))
16+
return;
17+
18+
_value = value;
19+
OnSettingChanged(this);
2020
}
2121
}
2222

Plugin.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ public class Plugin : BasePlugin
1111
{
1212
public const string GUID = "me.kiraihooks.KiraiMod.Core.UI";
1313

14-
internal static ManualLogSource log;
15-
internal static ConfigFile cfg;
14+
internal static ManualLogSource Logger;
15+
internal static ConfigFile Configuration;
1616

1717
public override void Load()
1818
{
19-
log = Log;
20-
cfg = Config;
19+
Logger = Log;
20+
Configuration = Config;
2121

2222
typeof(LegacyGUIManager).Initialize();
23+
Managers.ModuleManager.Register();
2324
}
2425
}
2526
}

0 commit comments

Comments
 (0)