Skip to content

Commit

Permalink
Merge branch 'master' from fork dymanoid/Skylines-ModTools
Browse files Browse the repository at this point in the history
  • Loading branch information
dymanoid committed Jun 21, 2019
2 parents 266af32 + e29b0a4 commit 2621416
Show file tree
Hide file tree
Showing 93 changed files with 6,307 additions and 7,548 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.suo
*.user
*.sln.docstates
.vs

# Build results
[Dd]ebug/
Expand Down
6 changes: 3 additions & 3 deletions Debugger/App.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
</configuration>
<startup>
<supportedRuntime version="v2.0.50727" /></startup>
</configuration>
151 changes: 151 additions & 0 deletions Debugger/AppearanceConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using System;
using ModTools.UI;
using UnityEngine;

namespace ModTools
{
internal sealed class AppearanceConfig : GUIWindow
{
private readonly string[] availableFonts;
private int selectedFont;

public AppearanceConfig()
: base("Appearance configuration", new Rect(16.0f, 16.0f, 600.0f, 490.0f), Skin, resizable: false)
{
availableFonts = Font.GetOSInstalledFontNames();
selectedFont = Array.IndexOf(availableFonts, MainWindow.Instance.Config.FontName);
}

protected override void DrawWindow()
{
var config = MainWindow.Instance.Config;

GUILayout.BeginHorizontal();
GUILayout.Label("Font");
GUILayout.FlexibleSpace();

var newSelectedFont = GUIComboBox.Box(selectedFont, availableFonts, "AppearanceSettingsFonts");
if (newSelectedFont != selectedFont && newSelectedFont >= 0)
{
config.FontName = availableFonts[newSelectedFont];
selectedFont = newSelectedFont;
UpdateFont();
}

GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();

GUILayout.Label("Font size");

var newFontSize = (int)GUILayout.HorizontalSlider(config.FontSize, 13.0f, 39.0f, GUILayout.Width(256));

if (newFontSize != config.FontSize)
{
config.FontSize = newFontSize;
UpdateFont();
}

GUILayout.EndHorizontal();

var newColor = DrawColorControl("Background", config.BackgroundColor);
if (newColor != config.BackgroundColor)
{
config.BackgroundColor = newColor;
BgTexture.SetPixel(0, 0, config.BackgroundColor);
BgTexture.Apply();
}

newColor = DrawColorControl("Title bar", config.TitleBarColor);
if (newColor != config.TitleBarColor)
{
config.TitleBarColor = newColor;
MoveNormalTexture.SetPixel(0, 0, config.TitleBarColor);
MoveNormalTexture.Apply();

MoveHoverTexture.SetPixel(0, 0, config.TitleBarColor * 1.2f);
MoveHoverTexture.Apply();
}

config.TitleBarTextColor = DrawColorControl("Title bar text", config.TitleBarTextColor);

config.GameObjectColor = DrawColorControl("GameObject", config.GameObjectColor);
config.EnabledComponentColor = DrawColorControl("Component (enabled)", config.EnabledComponentColor);
config.DisabledComponentColor = DrawColorControl("Component (disabled)", config.DisabledComponentColor);
config.SelectedComponentColor = DrawColorControl("Selected component", config.SelectedComponentColor);
config.KeywordColor = DrawColorControl("Keyword", config.KeywordColor);
config.NameColor = DrawColorControl("Member name", config.NameColor);
config.TypeColor = DrawColorControl("Member type", config.TypeColor);
config.ModifierColor = DrawColorControl("Member modifier", config.ModifierColor);
config.MemberTypeColor = DrawColorControl("Field type", config.MemberTypeColor);
config.ValueColor = DrawColorControl("Member value", config.ValueColor);

GUILayout.FlexibleSpace();

GUILayout.BeginHorizontal();

GUILayout.FlexibleSpace();

if (GUILayout.Button("OK", GUILayout.Width(100)))
{
MainWindow.Instance.SaveConfig();
Visible = false;
}

if (GUILayout.Button("Defaults", GUILayout.Width(100)))
{
ResetDoDefault(config);
selectedFont = Array.IndexOf(availableFonts, config.FontName);
}

GUILayout.EndHorizontal();
}

protected override void HandleException(Exception ex)
{
Logger.Error("Exception in AppearanceConfig - " + ex.Message);
Visible = false;
}

private static void ResetDoDefault(ModConfiguration config)
{
var template = new ModConfiguration();

config.BackgroundColor = template.BackgroundColor;
BgTexture.SetPixel(0, 0, config.BackgroundColor);
BgTexture.Apply();

config.TitleBarColor = template.TitleBarColor;
MoveNormalTexture.SetPixel(0, 0, config.TitleBarColor);
MoveNormalTexture.Apply();

MoveHoverTexture.SetPixel(0, 0, config.TitleBarColor * 1.2f);
MoveHoverTexture.Apply();

config.TitleBarTextColor = template.TitleBarTextColor;

config.GameObjectColor = template.GameObjectColor;
config.EnabledComponentColor = template.EnabledComponentColor;
config.DisabledComponentColor = template.DisabledComponentColor;
config.SelectedComponentColor = template.SelectedComponentColor;
config.NameColor = template.NameColor;
config.TypeColor = template.TypeColor;
config.ModifierColor = template.ModifierColor;
config.MemberTypeColor = template.MemberTypeColor;
config.ValueColor = template.ValueColor;
config.FontName = template.FontName;
config.FontSize = template.FontSize;

UpdateFont();
}

private Color DrawColorControl(string name, Color value)
{
GUILayout.BeginHorizontal();
GUILayout.Label(name);
GUILayout.FlexibleSpace();
var newColor = GUIControls.CustomValueField(name, string.Empty, GUIControls.PresentColor, value);
GUILayout.EndHorizontal();
return newColor;
}
}
}
122 changes: 0 additions & 122 deletions Debugger/Configuration.cs

This file was deleted.

27 changes: 27 additions & 0 deletions Debugger/Console/ConsoleMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Diagnostics;
using UnityEngine;

namespace ModTools.Console
{
internal sealed class ConsoleMessage
{
public ConsoleMessage(string caller, string message, LogType type, StackTrace trace)
{
Caller = caller;
Message = message;
Type = type;
Count = 1;
Trace = trace;
}

public string Caller { get; }

public string Message { get; }

public LogType Type { get; }

public int Count { get; set; }

public StackTrace Trace { get; }
}
}
Loading

0 comments on commit 2621416

Please sign in to comment.