Skip to content

Commit

Permalink
Merge pull request #17 from Theadd/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Theadd authored Dec 3, 2022
2 parents c87bf7e + fb76fe8 commit 0b3e115
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 126 deletions.
2 changes: 1 addition & 1 deletion PluginInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal static class PluginInfo
{
public const string PLUGIN_GUID = "DevTools.Humankind.GUITools";
public const string PLUGIN_NAME = "GUITools";
public const string PLUGIN_VERSION = "2.1.2.0";
public const string PLUGIN_VERSION = "2.2.0.0";

/// <summary>
/// Change REVISION value to force a reset of player preferences.
Expand Down
1 change: 1 addition & 0 deletions StyledGUI/Styles/Styles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static partial class Styles
public static Color WhiteTextColor { get; set; } = (Color) new Color32(250, 250, 250, 255);
public static Color WhitePearlTextColor { get; set; } = (Color) new Color32(200, 200, 200, 255);
public static Color DarkTextColor { get; set; } = (Color) new Color32(10, 10, 10, 190);
public static Color DarkishTextColor { get; set; } = (Color) new Color32(10, 10, 10, 150);
public static Color BlueTextColor { get; set; } = (Color) new Color32(40, 86, 240, 255);
public static Color GoldTextColor { get; set; } = new Color(0.85f, 0.75f, 0f, 0.85f);

Expand Down
123 changes: 69 additions & 54 deletions UI/BackScreen/BackScreenWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,89 +266,104 @@ private void ViewModeToggleButton(string actionName, string displayText, ViewMod
private bool _drawLiveEditorTags = false;
private bool _drawDefaultModeTags = false;
private bool _drawOnToolboxVisible = false;
private bool _drawMainNavBar = true;

private void DrawStatusBar()
{
GUILayout.Space(8f);
if (_drawNotInGameTags)
if (_drawMainNavBar)
{
GUILayout.BeginHorizontal();
if (_drawNotInGameTags)
{
GUILayout.Label("<b>" + ViewController.View.ToString().ToUpper() + "</b>", ScreenTag);
}
GUILayout.EndHorizontal();
}
if (_drawInGameTags)
{
GUILayout.BeginHorizontal();
{
ViewModeToggleButton("BackToNormalModeInGameView", _normalModeTitle, ViewModeType.Normal);
ViewModeToggleButton("ToggleFreeCameraMode", _freeCamModeTitle, ViewModeType.FreeCamera);
ViewModeToggleButton("ToggleLiveEditor", _liveEditorModeTitle, ViewModeType.LiveEditor);
ViewModeToggleButton("ToggleGameOverviewWindow", _overviewModeTitle, ViewModeType.Overview);
GUI.backgroundColor = Color.black;
}
GUILayout.EndHorizontal();
if (!_drawOnToolboxVisible)
GUILayout.Space(12f);

if (_drawLiveEditorTags)
{
if (_drawOnToolboxVisible)
GUILayout.FlexibleSpace();

GUILayout.BeginHorizontal();
{
if (!_drawOnToolboxVisible)
GUILayout.Label(
_brushTypeTitle + "<b>" + LiveEditorMode.BrushType.ToString().ToUpper() + "</b>", ScreenTag);
var onPaintText = PaintBrush.ActionNameOnCreate != string.Empty
? _onPaintTitle + "<b>" + PaintBrush.ActionNameOnCreate + "</b>"
: "NO EFFECT ON PAINT";
var onEraseText = PaintBrush.ActionNameOnDestroy != string.Empty
? _onEraseTitle + "<b>" + PaintBrush.ActionNameOnDestroy + "</b>"
: "NO EFFECT ON ERASE";
GUILayout.Label(onPaintText, ScreenTag);
GUILayout.Label(onEraseText, ScreenTag);
GUILayout.Label("<b>" + ViewController.View.ToString().ToUpper() + "</b>", ScreenTag);
}
GUILayout.EndHorizontal();
}
else if (_drawDefaultModeTags)

if (_drawInGameTags)
{
GUILayout.BeginHorizontal();
{
var isToolbarActive = !GlobalSettings.HideToolbarWindow.Value;
GUI.backgroundColor = isToolbarActive ? _screenTagColorActive : Color.black;
if (GUILayout.Toggle(isToolbarActive, _toolbarTitle, ScreenTagToggleButton) != isToolbarActive)
{
KeyMappings.Trigger("ToggleHideToolbarWindow");
}
ViewModeToggleButton("BackToNormalModeInGameView", _normalModeTitle,
ViewModeType.Normal);
ViewModeToggleButton("ToggleFreeCameraMode", _freeCamModeTitle,
ViewModeType.FreeCamera);
ViewModeToggleButton("ToggleLiveEditor", _liveEditorModeTitle,
ViewModeType.LiveEditor);
ViewModeToggleButton("ToggleGameOverviewWindow", _overviewModeTitle,
ViewModeType.Overview);
GUI.backgroundColor = Color.black;
}
GUILayout.EndHorizontal();
if (!_drawOnToolboxVisible)
GUILayout.Space(12f);

if (_drawLiveEditorTags)
{
if (_drawOnToolboxVisible)
GUILayout.FlexibleSpace();

var isGodModeActive = UIController.GodMode;
GUI.backgroundColor = isGodModeActive ? _screenTagColorActive : Color.black;
if (GUILayout.Toggle(isGodModeActive, _godModeTitle, ScreenTagToggleButton) != isGodModeActive)
GUILayout.BeginHorizontal();
{
KeyMappings.Trigger("ToggleGodMode");
if (!_drawOnToolboxVisible)
GUILayout.Label(
_brushTypeTitle + "<b>" + LiveEditorMode.BrushType.ToString().ToUpper() +
"</b>", ScreenTag);
var onPaintText = PaintBrush.ActionNameOnCreate != string.Empty
? _onPaintTitle + "<b>" + PaintBrush.ActionNameOnCreate + "</b>"
: "NO EFFECT ON PAINT";
var onEraseText = PaintBrush.ActionNameOnDestroy != string.Empty
? _onEraseTitle + "<b>" + PaintBrush.ActionNameOnDestroy + "</b>"
: "NO EFFECT ON ERASE";
GUILayout.Label(onPaintText, ScreenTag);
GUILayout.Label(onEraseText, ScreenTag);
}

var isScenarioEditorActive = MainTools.IsScenarioEditorWindowEnabled;
GUI.backgroundColor = isScenarioEditorActive ? _screenTagColorActive : Color.black;
if (GUILayout.Toggle(isScenarioEditorActive, _scenarioEditorTitle, ScreenTagToggleButton) != isScenarioEditorActive)
GUILayout.EndHorizontal();
}
else if (_drawDefaultModeTags)
{
GUILayout.BeginHorizontal();
{
KeyMappings.Trigger("ToggleScenarioEditorWindow");
var isToolbarActive = !GlobalSettings.HideToolbarWindow.Value;
GUI.backgroundColor = isToolbarActive ? _screenTagColorActive : Color.black;
if (GUILayout.Toggle(isToolbarActive, _toolbarTitle, ScreenTagToggleButton) !=
isToolbarActive)
{
KeyMappings.Trigger("ToggleHideToolbarWindow");
}

var isGodModeActive = UIController.GodMode;
GUI.backgroundColor = isGodModeActive ? _screenTagColorActive : Color.black;
if (GUILayout.Toggle(isGodModeActive, _godModeTitle, ScreenTagToggleButton) !=
isGodModeActive)
{
KeyMappings.Trigger("ToggleGodMode");
}

var isScenarioEditorActive = MainTools.IsScenarioEditorWindowEnabled;
GUI.backgroundColor =
isScenarioEditorActive ? _screenTagColorActive : Color.black;
if (GUILayout.Toggle(isScenarioEditorActive, _scenarioEditorTitle,
ScreenTagToggleButton) != isScenarioEditorActive)
{
KeyMappings.Trigger("ToggleScenarioEditorWindow");
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndHorizontal();
}
}

if (Event.current.type == EventType.Repaint)
{
_drawNotInGameTags = ViewController.View != ViewType.InGame;
_drawInGameTags = ViewController.View == ViewType.InGame;
_drawLiveEditorTags = IsInGame && LiveEditorMode.Enabled;
_drawDefaultModeTags = ViewController.ViewMode == ViewModeType.Normal;
_drawOnToolboxVisible = IsToolboxVisible;
_drawMainNavBar = !ViewController.HideMainNavBar;
}
GUILayout.Space(8f);
}
Expand Down
1 change: 1 addition & 0 deletions UI/BackScreen/ViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static ViewModeType ViewMode
public static ISessionService SessionService => Services.GetService<ISessionService>();
public static bool IsOnlineGame => SessionService?.Session?.SessionMode == SessionMode.Online;
public static bool IsGloballyDisabled { get; private set; } = false;
public static bool HideMainNavBar { get; set; } = false;

private static void UpdateGloballyDisabled() => IsGloballyDisabled = IsOnlineGame &&
(!InGameMenuWindow.VersionFound || InGameMenuWindow.LatestVersion != PluginInfo.PLUGIN_VERSION);
Expand Down
9 changes: 9 additions & 0 deletions UI/Common/KeyMappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public static void Trigger(string actionName)
IsEditable = false,
IsRemovable = false
},
new KeyMap("ToggleMainNavBar")
{
DisplayName = "TOGGLE MAIN NAVBAR",
Action = MappedActions.ToggleMainNavBar,
Key = KeyboardShortcut.Empty,
GroupName = GlobalKeysGroup,
IsEditable = true,
IsRemovable = true
},
new KeyMap("BackToNormalModeInGameView")
{
DisplayName = "DEFAULT VIEW MODE (IN GAME)",
Expand Down
5 changes: 5 additions & 0 deletions UI/Common/MappedActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public static void ToggleGameOverviewWindow()
}
}

public static void ToggleMainNavBar()
{
ViewController.HideMainNavBar = !ViewController.HideMainNavBar;
}

public static void BackToNormalModeInGameView()
{
if (ViewController.View == ViewType.InGame)
Expand Down
8 changes: 5 additions & 3 deletions UI/Drawables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ public StaticGrid()
{
}

public int Draw<T>() where T : GUIContent
public int Draw<T>() where T : GUIContent => Draw<T>(ContainerStyle, Style);

public int Draw<T>(GUIStyle containerStyle, GUIStyle style) where T : GUIContent
{
GUILayout.BeginHorizontal(ContainerStyle);
GUILayout.BeginHorizontal(containerStyle);
var prev = GUI.backgroundColor;
GUI.backgroundColor = BackgroundColor;
SelectedIndex = GUILayout.SelectionGrid(SelectedIndex, Items as T[], ItemsPerRow, Style);
SelectedIndex = GUILayout.SelectionGrid(SelectedIndex, Items as T[], ItemsPerRow, style);
GUI.backgroundColor = prev;
GUILayout.EndHorizontal();

Expand Down
Loading

0 comments on commit 0b3e115

Please sign in to comment.