Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #123 from ore-/feature/segi
Browse files Browse the repository at this point in the history
Support SEGI
  • Loading branch information
ore- committed Jun 7, 2020
2 parents 74d9d57 + 6946f5d commit 1008875
Show file tree
Hide file tree
Showing 79 changed files with 1,641 additions and 202 deletions.
5 changes: 3 additions & 2 deletions Graphics/Shared/Graphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial class Graphics : BaseUnityPlugin
{
public const string GUID = "ore.graphics";
public const string PluginName = "Graphics";
public const string Version = "0.3.2";
public const string Version = "0.3.3";

public static ConfigEntry<KeyCode> ConfigShortcut { get; private set; }
public static ConfigEntry<string> ConfigCubeMapPath { get; private set; }
Expand Down Expand Up @@ -127,7 +127,8 @@ private IEnumerator Start()
_presetManager = new PresetManager(ConfigPresetPath.Value, this);

yield return new WaitUntil(() => PCSSLight.LoadAssets());

yield return new WaitUntil(() => SEGI.LoadAssets());

_inspector = new Inspector.Inspector(this);
_isLoaded = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Graphics/Shared/Inspector/GUIStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static GUISkin Skin
}
catch (Exception ex)
{
Debug.Log("Could not load custom GUISkin - " + ex.Message);
Graphics.Instance.Log.Log(BepInEx.Logging.LogLevel.Fatal, "Could not load custom GUISkin - " + ex.Message);
_skin = GUI.skin;
}
}
Expand Down
117 changes: 32 additions & 85 deletions Graphics/Shared/Inspector/GUIUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ internal static void Slider(string label, int value, int min, int max, Action<in
}

// useColorDisplayColor32 is for setting colour on skybox tint, Color<->Color32 conversion loses precision
internal static void SliderColor(string label, Color value, Action<Color> onChanged = null, bool useColorDisplayColor32 = false, bool enable = true, Action<bool> onChangedEnable = null)
internal static void SliderColor(string label, Color value, Action<Color> onChanged = null,
bool useColorDisplayColor32 = false, bool enable = true, Action<bool> onChangedEnable = null, string colourGradingName = "", float mincolourGrading = 0, float maxcolourGrading = 1)
{
GUILayout.BeginHorizontal();
int spacing = 0;
Expand All @@ -99,53 +100,11 @@ internal static void SliderColor(string label, Color value, Action<Color> onChan
color.g = SliderColor("Green", color.g, spacing);
color.b = SliderColor("Blue", color.b, spacing);
Color newValue = color;
if (onChanged != null && value != newValue)
if (!colourGradingName.IsNullOrEmpty())
{
onChanged(newValue);
float colourGradingValue = SliderColor(colourGradingName, color.a, spacing, mincolourGrading, maxcolourGrading, false);
newValue.a = colourGradingValue;
}
}
else
{
Color32 color = value;
color.r = SliderColor("Red", color.r, spacing);
color.g = SliderColor("Green", color.g, spacing);
color.b = SliderColor("Blue", color.b, spacing);
Color newValue = color;
if (onChanged != null && value != newValue)
{
onChanged(newValue);
}
}
GUILayout.EndVertical();
if (!enable)
{
GUI.enabled = true;
}
}

internal static void SliderTrackball(string label, Color value, Action<Color> onChanged = null, bool useColorDisplayColor32 = false, bool enable = true, Action<bool> onChangedEnable = null)
{
GUILayout.BeginHorizontal();
int spacing = 0;
EnableToggle(label, ref spacing, ref enable, onChangedEnable);
if (!enable)
{
GUI.enabled = false;
}

GUI.color = new Color(value.r, value.g, value.b, 1f);
GUILayout.Label(colourIndicator);
GUI.color = Color.white;
GUILayout.EndHorizontal();
GUILayout.BeginVertical();
if (useColorDisplayColor32)
{
Color color = value;
color.r = SliderColor("Red", color.r, spacing);
color.g = SliderColor("Green", color.g, spacing);
color.b = SliderColor("Blue", color.b, spacing);
color.a = SliderColorFloat("Value", color.a, -5f, 5f, spacing);
Color newValue = color;
if (onChanged != null && value != newValue)
{
onChanged(newValue);
Expand All @@ -157,10 +116,12 @@ internal static void SliderTrackball(string label, Color value, Action<Color> on
color.r = SliderColor("Red", color.r, spacing);
color.g = SliderColor("Green", color.g, spacing);
color.b = SliderColor("Blue", color.b, spacing);
// This value needs to be a float even when using a Color32 since the value is out of the 0, 1 (or 0-255) range
float alpha = SliderColorFloat("Value", value.a, -5f, 5f, spacing);
Color newValue = color;
newValue.a = alpha;
if (!colourGradingName.IsNullOrEmpty())
{
float colourGradingValue = SliderColor(colourGradingName, value.a, spacing, mincolourGrading, maxcolourGrading, false);
newValue.a = colourGradingValue;
}
if (onChanged != null && value != newValue)
{
onChanged(newValue);
Expand All @@ -173,7 +134,7 @@ internal static void SliderTrackball(string label, Color value, Action<Color> on
}
}

internal static float SliderColor(string label, float value, int spacing)
internal static float SliderColor(string label, float value, int spacing, float min = 0, float max = 1, bool RGB = true)
{
GUILayout.BeginHorizontal();
if (0 != spacing)
Expand All @@ -183,14 +144,15 @@ internal static float SliderColor(string label, float value, int spacing)
label = LocalizationManager.HasLocalization() ? LocalizationManager.Localized(label) : label;
GUILayout.Label(label, GUILayout.ExpandWidth(false));
GUILayout.Label("", GUILayout.Width(GUIStyles.labelWidth - GUI.skin.label.CalcSize(new GUIContent(label)).x - spacing));
float newValue = GUILayout.HorizontalSlider(value, 0, 1);
float newValue = GUILayout.HorizontalSlider(value, min, max);
string valueString = value.ToString();
string newValueString = GUILayout.TextField((newValue * 255).ToString("N0"), GUILayout.Width(40), GUILayout.ExpandWidth(false));
string newValueString = RGB ? (newValue * 255).ToString("N0") : newValue.ToString();
newValueString = GUILayout.TextField(newValueString, GUILayout.Width(40), GUILayout.ExpandWidth(false));
if (newValueString != valueString)
{
if (float.TryParse(newValueString, out float parseResult))
{
newValue = parseResult / 255;
newValue = RGB ? parseResult / 255 : parseResult;
}
}
GUILayout.EndHorizontal();
Expand Down Expand Up @@ -221,30 +183,6 @@ internal static byte SliderColor(string label, byte value, int spacing)
return newValue;
}

internal static float SliderColorFloat(string label, float value, float minValue, float maxValue, int spacing)
{
GUILayout.BeginHorizontal();
if (0 != spacing)
{
GUILayout.Label("", GUILayout.Width(spacing));
}
label = LocalizationManager.HasLocalization() ? LocalizationManager.Localized(label) : label;
GUILayout.Label(label, GUILayout.ExpandWidth(false));
GUILayout.Label("", GUILayout.Width(GUIStyles.labelWidth - GUI.skin.label.CalcSize(new GUIContent(label)).x - spacing));
float newValue = GUILayout.HorizontalSlider(value, minValue, maxValue);
string valueString = value.ToString();
string newValueString = GUILayout.TextField(newValue.ToString(), GUILayout.Width(40), GUILayout.ExpandWidth(false));
GUILayout.EndHorizontal();
if (newValueString != valueString)
{
if (float.TryParse(newValueString, out float parseResult))
{
newValue = parseResult;
}
}
return newValue;
}

internal static T Selection<T>(string label, T selected, T[] selection, Action<T> onChanged = null, int columns = -1, bool enable = true, Action<bool> onChangedEnable = null)
{
GUILayout.BeginHorizontal();
Expand Down Expand Up @@ -429,7 +367,7 @@ internal static bool Button(string label, bool ExpandWidth = false)
internal static void Label(string label, string text, bool bold = false)
{
label = LocalizationManager.HasLocalization() ? LocalizationManager.Localized(label) : label;
if(0 < text.Length) text = LocalizationManager.HasLocalization() ? LocalizationManager.Localized(text) : text;
if (0 < text.Length) text = LocalizationManager.HasLocalization() ? LocalizationManager.Localized(text) : text;
GUILayout.BeginHorizontal();
if (bold)
{
Expand All @@ -444,7 +382,7 @@ internal static void Label(string label, string text, bool bold = false)
GUILayout.EndHorizontal();
}

internal static int Text(string label, int Integer, bool enable = true, Action<bool> onChangedEnable = null)
internal static void Text(string label, int Integer, Action<int> onChanged = null, bool enable = true, Action<bool> onChangedEnable = null)
{
GUILayout.BeginHorizontal();
int spacing = 0;
Expand All @@ -461,10 +399,13 @@ internal static int Text(string label, int Integer, bool enable = true, Action<b
}

GUILayout.EndHorizontal();
return count;
if (onChanged != null && Integer != count)
{
onChanged(count);
}
}

internal static float Text(string label, float Float, string format = "N0", bool enable = true, Action<bool> onChangedEnable = null)
internal static void Text(string label, float Float, string format = "N0", Action<float> onChanged = null, bool enable = true, Action<bool> onChangedEnable = null)
{
GUILayout.BeginHorizontal();
int spacing = 0;
Expand All @@ -481,10 +422,13 @@ internal static float Text(string label, float Float, string format = "N0", bool
}

GUILayout.EndHorizontal();
return count;
if (onChanged != null && Float != count)
{
onChanged(count);
}
}

internal static string Text(string label, string text, bool enable = true, Action<bool> onChangedEnable = null)
internal static void Text(string label, string text, Action<string> onChanged = null, bool enable = true, Action<bool> onChangedEnable = null)
{
GUILayout.BeginHorizontal();
int spacing = 0;
Expand All @@ -493,14 +437,17 @@ internal static string Text(string label, string text, bool enable = true, Actio
{
GUI.enabled = false;
}
text = GUILayout.TextField(text, 32);
string newText = GUILayout.TextField(text, 32);
if (!enable)
{
GUI.enabled = true;
}

GUILayout.EndHorizontal();
return text;
if (onChanged != null && text != newText)
{
onChanged(newText);
}
}

internal static Vector3 Dimension(string label, Vector3 size, Action<Vector3> onChanged = null)
Expand Down

0 comments on commit 1008875

Please sign in to comment.