Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 2c95fec

Browse files
committed
3.1.10: Add "Hide on startup" config option
1 parent 69912d7 commit 2c95fec

File tree

4 files changed

+59
-32
lines changed

4 files changed

+59
-32
lines changed

src/Config/ModConfig.cs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ static ModConfig()
2424
public int Default_Page_Limit = 25;
2525
public string Default_Output_Path = ExplorerCore.EXPLORER_FOLDER + @"\Output";
2626
public bool Log_Unity_Debug = false;
27-
public bool Save_Logs_To_Disk = true;
27+
public bool Hide_On_Startup = false;
28+
//public bool Save_Logs_To_Disk = true;
2829

2930
public static event Action OnConfigChanged;
3031

@@ -56,24 +57,27 @@ public static bool LoadSettings()
5657
{
5758
switch (config.KeyName)
5859
{
59-
case "Main_Menu_Toggle":
60+
case nameof(Main_Menu_Toggle):
6061
Instance.Main_Menu_Toggle = (KeyCode)Enum.Parse(typeof(KeyCode), config.Value);
6162
break;
62-
case "Force_Unlock_Mouse":
63+
case nameof(Force_Unlock_Mouse):
6364
Instance.Force_Unlock_Mouse = bool.Parse(config.Value);
6465
break;
65-
case "Default_Page_Limit":
66+
case nameof(Default_Page_Limit):
6667
Instance.Default_Page_Limit = int.Parse(config.Value);
6768
break;
68-
case "Log_Unity_Debug":
69+
case nameof(Log_Unity_Debug):
6970
Instance.Log_Unity_Debug = bool.Parse(config.Value);
7071
break;
71-
case "Save_Logs_To_Disk":
72-
Instance.Save_Logs_To_Disk = bool.Parse(config.Value);
73-
break;
74-
case "Default_Output_Path":
72+
case nameof(Default_Output_Path):
7573
Instance.Default_Output_Path = config.Value;
7674
break;
75+
case nameof(Hide_On_Startup):
76+
Instance.Hide_On_Startup = bool.Parse(config.Value);
77+
break;
78+
//case nameof(Save_Logs_To_Disk):
79+
// Instance.Save_Logs_To_Disk = bool.Parse(config.Value);
80+
// break;
7781
}
7882
}
7983

@@ -87,12 +91,13 @@ public static void SaveSettings()
8791
data.Sections.AddSection("Config");
8892

8993
var sec = data.Sections["Config"];
90-
sec.AddKey("Main_Menu_Toggle", Instance.Main_Menu_Toggle.ToString());
91-
sec.AddKey("Force_Unlock_Mouse", Instance.Force_Unlock_Mouse.ToString());
92-
sec.AddKey("Default_Page_Limit", Instance.Default_Page_Limit.ToString());
93-
sec.AddKey("Log_Unity_Debug", Instance.Log_Unity_Debug.ToString());
94-
sec.AddKey("Save_Logs_To_Disk", Instance.Save_Logs_To_Disk.ToString());
95-
sec.AddKey("Default_Output_Path", Instance.Default_Output_Path);
94+
sec.AddKey(nameof(Main_Menu_Toggle), Instance.Main_Menu_Toggle.ToString());
95+
sec.AddKey(nameof(Force_Unlock_Mouse), Instance.Force_Unlock_Mouse.ToString());
96+
sec.AddKey(nameof(Default_Page_Limit), Instance.Default_Page_Limit.ToString());
97+
sec.AddKey(nameof(Log_Unity_Debug), Instance.Log_Unity_Debug.ToString());
98+
sec.AddKey(nameof(Default_Output_Path), Instance.Default_Output_Path);
99+
sec.AddKey(nameof(Hide_On_Startup), Instance.Hide_On_Startup.ToString());
100+
//sec.AddKey("Save_Logs_To_Disk", Instance.Save_Logs_To_Disk.ToString());
96101

97102
File.WriteAllText(INI_PATH, data.ToString());
98103
}

src/ExplorerCore.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ namespace UnityExplorer
1515
public class ExplorerCore
1616
{
1717
public const string NAME = "UnityExplorer";
18-
public const string VERSION = "3.1.9";
18+
public const string VERSION = "3.1.10";
1919
public const string AUTHOR = "Sinai";
2020
public const string GUID = "com.sinai.unityexplorer";
2121

2222
#if ML
23-
public const string EXPLORER_FOLDER = @"Mods\UnityExplorer";
23+
public static string EXPLORER_FOLDER = Path.Combine("Mods", NAME);
2424
#elif BIE
25-
public static string EXPLORER_FOLDER = Path.Combine(BepInEx.Paths.ConfigPath, "UnityExplorer");
25+
public static string EXPLORER_FOLDER = Path.Combine(BepInEx.Paths.ConfigPath, NAME);
2626
#elif STANDALONE
2727
public static string EXPLORER_FOLDER
2828
{
@@ -110,6 +110,10 @@ private static void CheckUIInit()
110110
{
111111
UIManager.Init();
112112
Log("Initialized UnityExplorer UI.");
113+
114+
if (ModConfig.Instance.Hide_On_Startup)
115+
ShowMenu = false;
116+
113117
// InspectorManager.Instance.Inspect(Tests.TestClass.Instance);
114118
}
115119
catch (Exception e)

src/UI/Modules/DebugConsole.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class DebugConsole
1616
public static DebugConsole Instance { get; private set; }
1717

1818
public static bool LogUnity { get; set; } = ModConfig.Instance.Log_Unity_Debug;
19-
public static bool SaveToDisk { get; set; } = ModConfig.Instance.Save_Logs_To_Disk;
19+
//public static bool SaveToDisk { get; set; } = ModConfig.Instance.Save_Logs_To_Disk;
2020

2121
internal static StreamWriter s_streamWriter;
2222

@@ -49,8 +49,8 @@ public DebugConsole(GameObject parent)
4949

5050
// set up IO
5151

52-
if (!SaveToDisk)
53-
return;
52+
//if (!SaveToDisk)
53+
// return;
5454

5555
var path = ExplorerCore.EXPLORER_FOLDER + @"\Logs";
5656

src/UI/Modules/OptionsPage.cs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
//using TMPro;
54
using UnityEngine;
65
using UnityEngine.UI;
76
using UnityExplorer.Config;
@@ -19,6 +18,7 @@ public class OptionsPage : MainMenu.Page
1918
private Toggle m_unlockMouseToggle;
2019
private InputField m_pageLimitInput;
2120
private InputField m_defaultOutputInput;
21+
private Toggle m_hideOnStartupToggle;
2222

2323
public override void Init()
2424
{
@@ -27,26 +27,21 @@ public override void Init()
2727

2828
public override void Update()
2929
{
30-
// not needed?
3130
}
3231

3332
internal void OnApply()
3433
{
3534
if (!string.IsNullOrEmpty(m_keycodeInput.text) && Enum.Parse(typeof(KeyCode), m_keycodeInput.text) is KeyCode keyCode)
36-
{
3735
ModConfig.Instance.Main_Menu_Toggle = keyCode;
38-
}
3936

4037
ModConfig.Instance.Force_Unlock_Mouse = m_unlockMouseToggle.isOn;
4138

4239
if (!string.IsNullOrEmpty(m_pageLimitInput.text) && int.TryParse(m_pageLimitInput.text, out int lim))
43-
{
4440
ModConfig.Instance.Default_Page_Limit = lim;
45-
}
4641

4742
ModConfig.Instance.Default_Output_Path = m_defaultOutputInput.text;
4843

49-
// todo default output path
44+
ModConfig.Instance.Hide_On_Startup = m_hideOnStartupToggle.isOn;
5045

5146
ModConfig.SaveSettings();
5247
ModConfig.InvokeConfigChanged();
@@ -98,6 +93,7 @@ internal void ConstructUI()
9893
ConstructMouseUnlockOpt(optionsGroupObj);
9994
ConstructPageLimitOpt(optionsGroupObj);
10095
ConstructOutputPathOpt(optionsGroupObj);
96+
ConstructHideOnStartupOpt(optionsGroupObj);
10197

10298
var applyBtnObj = UIFactory.CreateButton(Content, new Color(0.2f, 0.2f, 0.2f));
10399
var applyText = applyBtnObj.GetComponentInChildren<Text>();
@@ -113,10 +109,34 @@ internal void ConstructUI()
113109
applyBtn.onClick.AddListener(OnApply);
114110
}
115111

116-
internal void ConstructKeycodeOpt(GameObject parent)
112+
private void ConstructHideOnStartupOpt(GameObject optionsGroupObj)
117113
{
118-
//public KeyCode Main_Menu_Toggle = KeyCode.F7;
114+
var rowObj = UIFactory.CreateHorizontalGroup(optionsGroupObj, new Color(1, 1, 1, 0));
115+
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
116+
rowGroup.childControlWidth = true;
117+
rowGroup.childForceExpandWidth = false;
118+
rowGroup.childControlHeight = true;
119+
rowGroup.childForceExpandHeight = true;
120+
var groupLayout = rowObj.AddComponent<LayoutElement>();
121+
groupLayout.minHeight = 25;
122+
groupLayout.flexibleHeight = 0;
123+
groupLayout.minWidth = 200;
124+
groupLayout.flexibleWidth = 1000;
119125

126+
var labelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
127+
var labelText = labelObj.GetComponent<Text>();
128+
labelText.text = "Hide UI on startup:";
129+
var labelLayout = labelObj.AddComponent<LayoutElement>();
130+
labelLayout.minWidth = 150;
131+
labelLayout.minHeight = 25;
132+
133+
UIFactory.CreateToggle(rowObj, out m_hideOnStartupToggle, out Text toggleText);
134+
m_hideOnStartupToggle.isOn = ModConfig.Instance.Hide_On_Startup;
135+
toggleText.text = "";
136+
}
137+
138+
internal void ConstructKeycodeOpt(GameObject parent)
139+
{
120140
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
121141
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
122142
rowGroup.childControlWidth = true;
@@ -146,8 +166,6 @@ internal void ConstructKeycodeOpt(GameObject parent)
146166

147167
internal void ConstructMouseUnlockOpt(GameObject parent)
148168
{
149-
//public bool Force_Unlock_Mouse = true;
150-
151169
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
152170
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
153171
rowGroup.childControlWidth = true;

0 commit comments

Comments
 (0)