Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

# CUSTOM
/*.DotSettings.user
/RELEASES/
/Folder.DotSettings.user
Folder.DotSettings.user
4 changes: 4 additions & 0 deletions DevTools.Humankind.GUITools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@
<HintPath>$(HUMANKIND_REFERENCED_LIBRARIES_PATH)\UnityEngine.XRModule.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Amplitude.Wwise">
<HintPath>$(HUMANKIND_REFERENCED_LIBRARIES_PATH)\Amplitude.Wwise.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Modding.Humankind.DevTools">
<HintPath>$(DevToolsPATH)</HintPath>
<Private>false</Private>
Expand Down
2 changes: 0 additions & 2 deletions Folder.DotSettings.user

This file was deleted.

2 changes: 1 addition & 1 deletion GUITools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace DevTools.Humankind.GUITools
{
[BepInPlugin(PLUGIN_GUID, "GUITools", "1.2.1.0")]
[BepInPlugin(PLUGIN_GUID, "GUITools", "1.3.0.0")]
[BepInDependency("Modding.Humankind.DevTools")]
[BepInDependency("DevTools.Humankind.SharedAssets")]
public class GUITools : BaseUnityPlugin
Expand Down
43 changes: 25 additions & 18 deletions MainTools.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System;
using System.IO;
using System.Linq;
using Modding.Humankind.DevTools;
using Modding.Humankind.DevTools.DeveloperTools.UI;
using DevTools.Humankind.GUITools.UI;
using HarmonyLib;
using Amplitude.Mercury.Presentation;
using BepInEx;
using BepInEx.Configuration;
using DevTools.Humankind.GUITools.UI.PauseMenu;
using StyledGUI;

namespace DevTools.Humankind.GUITools
{
Expand All @@ -29,11 +24,14 @@ public static class MainTools
public static FameToolWindow FameWindow { get; set; }
public static EndGameToolWindow EndGameWindow { get; set; }
public static GameStatsWindow StatsWindow { get; set; }
public static BackScreenWindow BackScreen { get; set; }

public static void Main()
{
if (IsDebugModeEnabled) Debug();

UIController.OnceGUIHasLoaded(() => StyledGUIUtility.DefaultSkin = UIController.DefaultSkin);
PopupToolWindow.Open<BackScreenWindow>(w => BackScreen = w);
PopupToolWindow.Open<MainToolbar>(w => Toolbar = w);
PopupToolWindow.Open<InGameMenuWindow>(w => InGameMenu = w);

Expand All @@ -45,24 +43,31 @@ public static void Main()
// PopupToolWindow.Open<EndGameToolWindow>(w => EndGameWindow = w);
// PopupToolWindow.Open<GameStatsWindow>(w => StatsWindow = w);

// HumankindDevTools.RegisterAction(new KeyboardShortcut(UnityEngine.KeyCode.Home), "ToggleBasicToolWindow", ToggleBasicToolWindow);
HumankindDevTools.RegisterAction(new KeyboardShortcut(UnityEngine.KeyCode.Home), "ToggleHideToolbarWindow", ToggleHideToolbarWindow);
HumankindDevTools.RegisterAction(new KeyboardShortcut(UnityEngine.KeyCode.Tab), "ToggleGameOverviewWindow", ToggleGameOverviewWindow);

HumankindDevTools.RegisterAction(
// HumankindDevTools.RegisterAction(new KeyboardShortcut(UnityEngine.KeyCode.UpArrow, UnityEngine.KeyCode.LeftControl), "ToggleBasicToolWindow", ToggleBasicToolWindow);
// HumankindDevTools.RegisterAction(new KeyboardShortcut(UnityEngine.KeyCode.Home), "ToggleHideToolbarWindow", ToggleHideToolbarWindow);
// HumankindDevTools.RegisterAction(new KeyboardShortcut(UnityEngine.KeyCode.Tab), "ToggleGameOverviewWindow", ToggleGameOverviewWindow);
/*HumankindDevTools.RegisterAction(
new KeyboardShortcut(UnityEngine.KeyCode.Insert),
"ToggleHideAllGUITools",
ToggleHideAllUIWindows);
ToggleHideAllUIWindows);*/

// Maps [ESC] key to: GodMode.Enabled = false
// HumankindDevTools.RegisterAction(new KeyboardShortcut(UnityEngine.KeyCode.Escape), "CancelGodMode", CancelGodMode);

// ToggleGameOverviewWindow();
// ToggleGameOverviewWindow();
// ToggleBasicToolWindow();

/*HumankindDevTools.RegisterAction(
new KeyboardShortcut(UnityEngine.KeyCode.F4, UnityEngine.KeyCode.LeftShift),
"RebuildConstructibles",
ConstructibleStore.Rebuild);*/
}

public static void ToggleHideToolbarWindow() => GlobalSettings.HideToolbarWindow.Value = !GlobalSettings.HideToolbarWindow.Value;

public static void ToggleHideAllUIWindows() => FloatingToolWindow.HideAllGUITools = !FloatingToolWindow.HideAllGUITools;
public static void ToggleHideAllUIWindows() =>
Loggr.Log("HIDDING ALL GUI TOOLS WINDOWS IS TEMPORARILY DISABLED", ConsoleColor.Magenta); //FloatingToolWindow.HideAllGUITools = !FloatingToolWindow.HideAllGUITools);

// public static void CancelGodMode() => AccessTools.PropertySetter(typeof(GodMode), "Enabled")?.Invoke(null, new object[] { false });

Expand Down Expand Up @@ -103,20 +108,22 @@ public static void Unload(bool saveState = false) {
FameWindow?.Close();
EndGameWindow?.Close();
StatsWindow?.Close();
BackScreen?.Close();
ScreenLocker.Unload();
}

private static void Debug()
{
var scriptsPath = Path.Combine(Paths.GameRootPath, "scripts");
/*var scriptsPath = Path.Combine(Paths.GameRootPath, "scripts");
var files = Directory.GetFiles(scriptsPath, "*.cs", SearchOption.AllDirectories)
.Where(path => path.Substring(scriptsPath.Length, 5) != "\\obj\\");

Loggr.Log(string.Join("\n", files), ConsoleColor.DarkYellow);
Loggr.Log(string.Join("\n", files), ConsoleColor.DarkYellow);*/

// When true, draws a colored border for all UIOverlays backing a FloatingToolWindow derived class
UIOverlay.DEBUG_DRAW_OVERLAY = false;
// When not true, adds more verbosity to console output
Modding.Humankind.DevTools.DevTools.QuietMode = true;
Modding.Humankind.DevTools.DevTools.QuietMode = false;
}
}
}
36 changes: 36 additions & 0 deletions StyledGUI/Graphics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using UnityEngine;

namespace StyledGUI
{
public static class Graphics
{
public static Texture2D WhiteTexture = CreateSinglePixelTexture2D(new Color(1f, 1f, 1f, 1f));
public static Texture2D BlackTexture = CreateSinglePixelTexture2D(new Color(0, 0, 0, 1f));
public static Texture2D TransparentTexture = CreateSinglePixelTexture2D(new Color(1f, 1f, 1f, 0f));

public static Texture2D CreateSinglePixelTexture2D(Color color)
{
Texture2D tex = new Texture2D(1,1);
tex.SetPixel(0, 0, color);
tex.Apply();

return tex;
}

public static void DrawHorizontalLine(float alpha = 0.45f)
{
var r = GUILayoutUtility.GetRect(1f, 1f);
GUI.DrawTexture(new Rect(r.x, r.y, r.width - 3f, 1f),
WhiteTexture, ScaleMode.StretchToFill, true,
1f, new Color(1f, 1f, 1f, alpha), 0,0);
}

public static void DrawHorizontalLine(float alpha, float width)
{
var r = GUILayoutUtility.GetRect(1f, 1f);
GUI.DrawTexture(new Rect(r.x, r.y, width, 1f),
WhiteTexture, ScaleMode.StretchToFill, true,
1f, new Color(1f, 1f, 1f, alpha), 0,0);
}
}
}
74 changes: 74 additions & 0 deletions StyledGUI/Grid/CellSpanGrid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using UnityEngine;

namespace StyledGUI
{

public interface ICellSpan
{
GUILayoutOption CellSpan1 { get; set; }
GUILayoutOption CellSpan2 { get; set; }
GUILayoutOption CellSpan3 { get; set; }
GUILayoutOption CellSpan4 { get; set; }
GUILayoutOption CellSpan5 { get; set; }
GUILayoutOption CellSpan6 { get; set; }
GUILayoutOption CellSpan7 { get; set; }
GUILayoutOption CellSpan8 { get; set; }
GUILayoutOption CellSpan9 { get; set; }
GUILayoutOption CellSpan10 { get; set; }
float GetCellWidth();
float GetCellSpace();
float GetCellHeight();
}

public abstract class CellSpanGrid : ICellSpan
{
public float CellWidth;
public float CellSpace;
public GUILayoutOption CellSpan1 { get; set; }
public GUILayoutOption CellSpan2 { get; set; }
public GUILayoutOption CellSpan3 { get; set; }
public GUILayoutOption CellSpan4 { get; set; }
public GUILayoutOption CellSpan5 { get; set; }
public GUILayoutOption CellSpan6 { get; set; }
public GUILayoutOption CellSpan7 { get; set; }
public GUILayoutOption CellSpan8 { get; set; }
public GUILayoutOption CellSpan9 { get; set; }
public GUILayoutOption CellSpan10 { get; set; }
public GUILayoutOption CellSpan(int numCells) => GUILayout.Width(CellWidth * numCells + CellSpace * (numCells - 1));

public CellSpanGrid()
{
Resize(34f, 1f);
}

public CellSpanGrid(float cellWidth, float cellSpace)
{
Resize(cellWidth, cellSpace);
}

public CellSpanGrid Resize(float cellWidth, float cellSpace)
{
CellWidth = cellWidth;
CellSpace = cellSpace;
CellSpan1 = CellSpan(1);
CellSpan2 = CellSpan(2);
CellSpan3 = CellSpan(3);
CellSpan4 = CellSpan(4);
CellSpan5 = CellSpan(5);
CellSpan6 = CellSpan(6);
CellSpan7 = CellSpan(7);
CellSpan8 = CellSpan(8);
CellSpan9 = CellSpan(9);
CellSpan10 = CellSpan(10);

return this;
}

public float GetCellWidth() => CellWidth;
public float GetCellSpace() => CellSpace;
public virtual float GetCellHeight() => 22f;
}


}
24 changes: 24 additions & 0 deletions StyledGUI/Grid/GridStyles.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using UnityEngine;

namespace StyledGUI
{
public interface IStyledGrid : ICellSpan
{
Color CellTintColor { get; set; }
Color CellTintColorAlt { get; set; }
Color IconTintColor { get; set; }
Color CellButtonTintColor { get; set; }
Color SelectedCellTintColor { get; set; }
}

public abstract class GridStyles : CellSpanGrid, IStyledGrid
{
public virtual Color CellTintColor { get; set; } = new Color(0.9f, 0.9f, 0.85f, 1f);
public virtual Color CellTintColorAlt { get; set; } = new Color(0.6f, 0.6f, 0.6f, 1f);
public virtual Color IconTintColor { get; set; } = new Color(1f, 1f, 1f, 0.7f);
public virtual Color CellButtonTintColor { get; set; } = new Color32(85, 136, 254, 230);
public virtual Color SelectedCellTintColor { get; set; } = new Color32(40, 86, 240, 255);

}
}
125 changes: 125 additions & 0 deletions StyledGUI/Grid/StyledGridEx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using UnityEngine;

namespace StyledGUI
{
public static class StyledGridEx
{
public static IStyledGrid Row(this IStyledGrid self, GUIStyle style, params GUILayoutOption[] options)
{
GUILayout.BeginHorizontal(style, options);

return self;
}

public static IStyledGrid Row(this IStyledGrid self, params GUILayoutOption[] options)
{
GUILayout.BeginHorizontal(Styles.RowStyle, options);

return self;
}

public static IStyledGrid EndRow(this IStyledGrid self)
{
GUILayout.EndHorizontal();

return self;
}

public static IStyledGrid EmptyRow(this IStyledGrid self, params GUILayoutOption[] options)
{
GUILayout.BeginHorizontal(Styles.StaticRowStyle, options);
GUILayout.Label(" ", Styles.RowHeaderStyle);
GUILayout.EndHorizontal();

return self;
}

public static IStyledGrid VerticalStack(this IStyledGrid self, params GUILayoutOption[] options)
{
GUILayout.BeginVertical(Styles.StaticRowStyle, options);

return self;
}

public static IStyledGrid EndVerticalStack(this IStyledGrid self, params GUILayoutOption[] options)
{
GUILayout.EndVertical();

return self;
}

public static IStyledGrid Cell(this IStyledGrid self, string text, GUIStyle style, params GUILayoutOption[] options)
{
GUILayout.Label(text, style, options);

return self;
}

public static IStyledGrid Cell(this IStyledGrid self, string text, params GUILayoutOption[] options)
{
GUILayout.Label(text, Styles.CellStyle, options);

return self;
}

public static IStyledGrid Cell(this IStyledGrid self, string text, Color color, params GUILayoutOption[] options)
{
var prevColor = GUI.backgroundColor;
GUI.backgroundColor = color;

GUILayout.Label("<size=11>" + text + "</size>", Styles.CellStyle, options);

GUI.backgroundColor = prevColor;

return self;
}

public static IStyledGrid Cell(this IStyledGrid self, string text, GUIStyle style, Color color, params GUILayoutOption[] options)
{
var prevColor = GUI.backgroundColor;
GUI.backgroundColor = color;

GUILayout.Label("<size=11>" + text + "</size>", style, options);

GUI.backgroundColor = prevColor;

return self;
}

public static IStyledGrid RowHeader(this IStyledGrid self, string text, GUIStyle style, params GUILayoutOption[] options)
{
GUILayout.Label("<size=10><b>" + text + "</b></size>", style, options);

return self;
}

public static IStyledGrid RowHeader(this IStyledGrid self, string text, params GUILayoutOption[] options)
{
GUILayout.Label("<size=10>" + text + "</size>", Styles.RowHeaderStyle, options);

return self;
}


public static IStyledGrid DrawHorizontalLine(this IStyledGrid self, float alpha = 0.3f)
{
Graphics.DrawHorizontalLine(alpha);

return self;
}

public static IStyledGrid DrawHorizontalLine(this IStyledGrid self, float alpha, float width)
{
Graphics.DrawHorizontalLine(alpha, width);

return self;
}

public static IStyledGrid Space(this IStyledGrid self, float size)
{
GUILayout.Space(size);

return self;
}
}
}
Loading