Skip to content

Commit 13fe910

Browse files
committed
Add button to open mod menu on config screen
- Works on both the main menu config screen and the right click menu config screen
1 parent 124d0b4 commit 13fe910

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

Assets.Scripts.Core/GameSystem.cs

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public class GameSystem : MonoBehaviour
143143
private PromptController promptController;
144144

145145
private ConfigManager configManager;
146+
public ConfigManager ConfigManager() => configManager;
146147

147148
private GalleryManager galleryManager;
148149

Assets.Scripts.UI.Config/ConfigManager.cs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class ConfigManager : MonoBehaviour
1818

1919
private UIPanel panel;
2020

21+
public float PanelAlpha() => panel.alpha;
22+
2123
private IEnumerator LeaveScreen(LeaveConfigDelegate callback)
2224
{
2325
panel = Panel.GetComponent<UIPanel>();

MOD.Scripts.UI/MODMenu.cs

+49-20
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ [MOD Hotkeys]
9898
F3 : Effect Level (Not Used)
9999
F5 : QuickSave
100100
F7 : QuickLoad
101-
F10 : Setting Monitor
101+
F10 : Mod Menu
102102
M : Increase Voice Volume
103103
N : Decrease Voice Volume
104104
7 : Lip-Sync
@@ -283,7 +283,30 @@ public void OnGUIFragment()
283283
}
284284
}
285285

286-
if(visible && !lastMenuVisibleStatus)
286+
// Button to open the Mod Menu on the Config Screen
287+
if (gameSystem.GameState == GameState.ConfigScreen)
288+
{
289+
if (gameSystem.ConfigManager() != null)
290+
{
291+
// Temporarily override the global tint color to get a fade in effect which matches the config screen fade-in
292+
// This value is not saved by Unity (it resets to the default value each frame)
293+
GUI.color = new Color(1.0f, 1.0f, 1.0f, gameSystem.ConfigManager().PanelAlpha());
294+
}
295+
string text = "Mod Menu\n(Hotkey: F10)";
296+
float areaWidth = Screen.width / 8;
297+
float areaHeight = Mathf.Round(styleManager.Group.button.CalcHeight(new GUIContent(text, ""), areaWidth)) + 10;
298+
float xOffset = 0;
299+
float yOffset = Screen.height - areaHeight;
300+
GUILayout.BeginArea(new Rect(xOffset, yOffset, areaWidth, areaHeight), styleManager.modMenuAreaStyle);
301+
if (GUILayout.Button(text, styleManager.Group.button))
302+
{
303+
this.Show();
304+
}
305+
306+
GUILayout.EndArea();
307+
}
308+
309+
if (visible && !lastMenuVisibleStatus)
287310
{
288311
// Executes just before menu becomes visible
289312
// Update the artset radio buttons/descriptions, as these are set by ModAddArtset() calls in init.txt at runtime
@@ -516,9 +539,29 @@ public void OnGUIFragment()
516539

517540
private void Show()
518541
{
519-
gameSystem.MODIgnoreInputs = true;
520-
gameSystem.HideUIControls();
521-
this.visible = true;
542+
void ForceShow()
543+
{
544+
gameSystem.MODIgnoreInputs = true;
545+
gameSystem.HideUIControls();
546+
this.visible = true;
547+
}
548+
549+
if (gameSystem.GameState == GameState.SaveLoadScreen)
550+
{
551+
MODToaster.Show("Please close the current menu and try again");
552+
}
553+
else if (gameSystem.GameState == GameState.ConfigScreen)
554+
{
555+
gameSystem.LeaveConfigScreen(delegate
556+
{
557+
ForceShow();
558+
});
559+
}
560+
else
561+
{
562+
ForceShow();
563+
}
564+
522565
}
523566

524567
public void Hide()
@@ -536,21 +579,7 @@ public void ToggleVisibility()
536579
}
537580
else
538581
{
539-
if (gameSystem.GameState == GameState.SaveLoadScreen)
540-
{
541-
MODToaster.Show("Please close the current menu and try again");
542-
}
543-
else if (gameSystem.GameState == GameState.ConfigScreen)
544-
{
545-
gameSystem.LeaveConfigScreen(delegate
546-
{
547-
Show();
548-
});
549-
}
550-
else
551-
{
552-
Show();
553-
}
582+
this.Show();
554583
}
555584
}
556585

0 commit comments

Comments
 (0)