diff --git a/GalacticScale.sln.DotSettings b/GalacticScale.sln.DotSettings new file mode 100644 index 00000000..ee8d2521 --- /dev/null +++ b/GalacticScale.sln.DotSettings @@ -0,0 +1,2 @@ + + GSUI \ No newline at end of file diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Logging/ConsoleSplash.cs b/GalacticScale2/Scripts/GalacticScale2.0/Logging/ConsoleSplash.cs index a7118463..0d76ca32 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Logging/ConsoleSplash.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Logging/ConsoleSplash.cs @@ -20,7 +20,7 @@ public static void ConsoleSplash() BCE.Console.Write("│\n", ConsoleColor.Red); BCE.Console.Write("│", ConsoleColor.Red); BCE.Console.Write(" ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ ", ConsoleColor.DarkGray); - BCE.Console.Write("Version " + Version + " Initializing ", ConsoleColor.White); + BCE.Console.Write("Version " + Version + " Initializing ", ConsoleColor.White); BCE.Console.Write("│\n", ConsoleColor.Red); BCE.Console.WriteLine("└─────────────────────────────────────────────────────────────────────────┘", ConsoleColor.Red); diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI-Constructors.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI-Constructors.cs index 1b7bff11..6dc0737a 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI-Constructors.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI-Constructors.cs @@ -1,13 +1,9 @@ -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; +using System.Collections.Generic; namespace GalacticScale { public partial class GSUI { - public static GSUI Header(string label, string hint = "") { return new GSUI(label, null, "Header", null, null, null, hint); @@ -26,21 +22,20 @@ public static GSUI Group(string label, List options, string hint = "", boo instance.callback = callback; return instance; } - //Backup of Group with Key - // public static GSUI Group(string label, List options, string key, bool defaultValue, string hint = "", bool collapsible = true, GSOptionCallback callback = null) - // { - // var data = new GSUIGroupConfig(options, true, collapsible, defaultValue); - // var t = Utils.GetCallingType(); - // var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), key, label, "Group", data, - // null, null, hint); - // instance.callback = instance.CreateDefaultCallback(callback); - // instance.postfix = instance.CreateDefaultPostfix(); - // // return instance; - // // var instance = new GSUI(label, null, "Group", data, null); - // // instance.callback = callback; - // return instance; - // } - + + public static GSUI Selector(string label, List items, string defaultValue, string key, GSOptionCallback callback = null, string hint = null) + { + GSUI instance = null; + var tt = Utils.GetCallingType(); + foreach (var t in tt.GetInterfaces()) + if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Selector", items, null, null, hint); + else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Selector", items, null, null, hint); + if (instance == null) return null; + instance.callback = instance.CreateDefaultCallback(callback); + instance.postfix = instance.CreateDefaultPostfix(); + instance.comboDefault = items.IndexOf(defaultValue); + return instance; + } // Group with Checkbox and Key public static GSUI Group(string label, List options, string key, bool defaultValue, string hint = "", bool collapsible = true, GSOptionCallback callback = null) { @@ -48,51 +43,33 @@ public static GSUI Group(string label, List options, string key, bool defa GSUI instance = null; var tt = Utils.GetCallingType(); foreach (var t in tt.GetInterfaces()) - { if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Group", data, null, null, hint); else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Group", data, null, null, hint); - } if (instance == null) return null; instance.callback = instance.CreateDefaultCallback(callback); instance.postfix = instance.CreateDefaultPostfix(); return instance; } - - - - - - - - - - + // Slider (Integer, no key) - public static GSUI Slider(string label, float min, float val, float max, GSOptionCallback callback, - GSOptionPostfix postfix = null, string hint = "") + public static GSUI Slider(string label, float min, float val, float max, GSOptionCallback callback, GSOptionPostfix postfix = null, string hint = "") { var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Slider", - new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, postfix, hint); + var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, postfix, hint); instance.callback = callback; instance.postfix = postfix; return instance; } // Slider for Planet Sizes with key - public static GSUI PlanetSizeSlider(string label, float min, float val, float max, string key, - GSOptionCallback callback = null, string hint = "") + public static GSUI PlanetSizeSlider(string label, float min, float val, float max, string key, GSOptionCallback callback = null, string hint = "") { GSUI instance = null; var tt = Utils.GetCallingType(); foreach (var t in tt.GetInterfaces()) - { - if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) - instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, null, hint); - else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) - instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, null, hint); - } + if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, null, hint); + else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, null, hint); if (instance == null) return null; var defaultCallback = instance.CreateDefaultCallback(callback); instance.callback = CreatePlanetSizeCallback(instance, defaultCallback); @@ -101,8 +78,7 @@ public static GSUI PlanetSizeSlider(string label, float min, float val, float ma } // Slider for Planet Sizes without key - public static GSUI PlanetSizeSlider(string label, float min, float val, float max, - GSOptionCallback callback = null, GSOptionPostfix postfix = null, string hint = "") + public static GSUI PlanetSizeSlider(string label, float min, float val, float max, GSOptionCallback callback = null, GSOptionPostfix postfix = null, string hint = "") { var t = Utils.GetCallingType(); var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, callback, postfix, hint); @@ -112,25 +88,14 @@ public static GSUI PlanetSizeSlider(string label, float min, float val, float ma } //Slider with preferences Key - public static GSUI Slider(string label, float min, float val, float max, string key, - GSOptionCallback callback = null, string hint = "") + public static GSUI Slider(string label, float min, float val, float max, string key, GSOptionCallback callback = null, string hint = "") { GSUI instance = null; var tt = Utils.GetCallingType(); - // GS2.Warn(tt.Name); foreach (var t in tt.GetInterfaces()) - { - // GS2.Log(t.Name); - if (t.Name == "iConfigurableGenerator" && !tt.IsAbstract && !tt.IsInterface) - { - // GS2.Warn($"Setting generator for {label}"); - instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, null, hint); - } + if (t.Name == "iConfigurableGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, null, hint); else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, null, hint); - } - - if (instance == null) return null; instance.callback = instance.CreateDefaultCallback(callback); instance.postfix = instance.CreateDefaultPostfix(); @@ -138,40 +103,35 @@ public static GSUI Slider(string label, float min, float val, float max, string } //Slider with increment and preferences Key - public static GSUI Slider(string label, float min, float val, float max, float increment, string key, - GSOptionCallback callback = null, string hint = "", string negativeLabel = "") + public static GSUI Slider(string label, float min, float val, float max, float increment, string key, GSOptionCallback callback = null, string hint = "", string negativeLabel = "") { GSUI instance = null; var tt = Utils.GetCallingType(); - // GS2.Warn(tt.Name); foreach (var t in tt.GetInterfaces()) - { - // GS2.Warn(label + " " +t.Name); if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val, negativeLabel = negativeLabel }, null, null, hint); else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val, negativeLabel = negativeLabel }, null, null, hint); - } - - if (instance == null) return null; - // var t = Utils.GetCallingType(); - // var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), key, label, "Slider", - // new GSSliderConfig {minValue = min, maxValue = max, defaultValue = val, negativeLabel = negativeLabel}, null, null, hint); + if (instance == null) return null; var defaultCallback = instance.CreateDefaultCallback(callback); var CB = defaultCallback; if (increment != 1f) CB = CreateIncrementCallback(increment, instance, defaultCallback); - //if (planetSizes) CB = CreatePlanetSizeCallback(instance, defaultCallback); instance.callback = CB; instance.postfix = instance.CreateDefaultPostfix(); instance.increment = increment; return instance; } + + //RangeSlider with increment and preferences Key - public static GSUI RangeSlider(string label, float min, float lowVal, float highVal, float max, float increment, string key, - GSOptionCallback callback = null, GSOptionCallback callbackLow = null, GSOptionCallback callbackHigh = null, string hint = "") + public static GSUI RangeSlider(string label, float min, float lowVal, float highVal, float max, float increment, string key, GSOptionCallback callback = null, GSOptionCallback callbackLow = null, GSOptionCallback callbackHigh = null, string hint = "") { - var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), key, label, "RangeSlider", - new GSRangeSliderConfig { minValue = min, maxValue = max, defaultLowValue = lowVal, defaultHighValue = highVal, callbackLow = callbackLow, callbackHigh = callbackHigh }, null, null, hint); + GSUI instance = null; + var tt = Utils.GetCallingType(); + foreach (var t in tt.GetInterfaces()) + if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "RangeSlider", new GSRangeSliderConfig { minValue = min, maxValue = max, defaultLowValue = lowVal, defaultHighValue = highVal, callbackLow = callbackLow, callbackHigh = callbackHigh }, null, null, hint); + else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "RangeSlider", new GSRangeSliderConfig { minValue = min, maxValue = max, defaultLowValue = lowVal, defaultHighValue = highVal, callbackLow = callbackLow, callbackHigh = callbackHigh }, null, null, hint); + if (instance == null) return null; + var defaultCallback = instance.CreateDefaultCallback(callback); var CB = defaultCallback; if (increment != 1f) CB = CreateIncrementCallback(increment, instance, defaultCallback); @@ -183,12 +143,15 @@ public static GSUI RangeSlider(string label, float min, float lowVal, float high } // Slider for Planet Sizes with key - public static GSUI PlanetSizeRangeSlider(string label, float min, float valLow, float valHigh, float max, string key, - GSOptionCallback callback = null, GSOptionCallback callbackLow = null, GSOptionCallback callbackHigh = null, string hint = "") + public static GSUI PlanetSizeRangeSlider(string label, float min, float valLow, float valHigh, float max, string key, GSOptionCallback callback = null, GSOptionCallback callbackLow = null, GSOptionCallback callbackHigh = null, string hint = "") { - var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), key, label, "RangeSlider", - new GSRangeSliderConfig { minValue = min, maxValue = max, defaultLowValue = valLow, defaultHighValue = valHigh, callbackLow = callbackLow, callbackHigh = callbackHigh }, null, null, hint); + GSUI instance = null; + var tt = Utils.GetCallingType(); + foreach (var t in tt.GetInterfaces()) + if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "RangeSlider", new GSRangeSliderConfig { minValue = min, maxValue = max, defaultLowValue = valLow, defaultHighValue = valHigh, callbackLow = callbackLow, callbackHigh = callbackHigh }, null, null, hint); + else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "RangeSlider", new GSRangeSliderConfig { minValue = min, maxValue = max, defaultLowValue = valLow, defaultHighValue = valHigh, callbackLow = callbackLow, callbackHigh = callbackHigh }, null, null, hint); + if (instance == null) return null; + var defaultCallback = instance.CreateDefaultCallback(callback); instance.callback = CreatePlanetSizeRangeCallback(instance, defaultCallback); instance.postfix = instance.CreateDefaultPostfix(); @@ -196,12 +159,10 @@ public static GSUI PlanetSizeRangeSlider(string label, float min, float valLow, } //Slider with increment and no Key - public static GSUI Slider(string label, float min, float val, float max, float increment, - GSOptionCallback callback = null, GSOptionPostfix postfix = null, string hint = "") + public static GSUI Slider(string label, float min, float val, float max, float increment, GSOptionCallback callback = null, GSOptionPostfix postfix = null, string hint = "") { var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Slider", - new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, postfix, hint); + var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Slider", new GSSliderConfig { minValue = min, maxValue = max, defaultValue = val }, null, postfix, hint); var CB = callback; if (increment != 1f) CB = CreateIncrementCallback(increment, instance, callback); instance.callback = CB; @@ -209,73 +170,79 @@ public static GSUI Slider(string label, float min, float val, float max, float i return instance; } - public static GSUI Checkbox(string label, bool value, GSOptionCallback callback, GSOptionPostfix postfix = null, - string hint = "") + //Checkbox with no key + public static GSUI Checkbox(string label, bool value, GSOptionCallback callback, GSOptionPostfix postfix = null, string hint = "") { var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Checkbox", value, callback, - postfix, hint); + var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Checkbox", value, callback, postfix, hint); return instance; } - public static GSUI Checkbox(string label, bool defaultValue, string key, GSOptionCallback callback = null, - string hint = "") + //Checkbox with key + public static GSUI Checkbox(string label, bool defaultValue, string key, GSOptionCallback callback = null, string hint = "") { - var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), key, label, "Checkbox", defaultValue, - null, null, hint); + GSUI instance = null; + var tt = Utils.GetCallingType(); + foreach (var t in tt.GetInterfaces()) + if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Checkbox", defaultValue, null, null, hint); + else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Checkbox", defaultValue, null, null, hint); + if (instance == null) return null; + instance.callback = instance.CreateDefaultCallback(callback); instance.postfix = instance.CreateDefaultPostfix(); return instance; } - public static GSUI Combobox(string label, List items, GSOptionCallback callback, - GSOptionPostfix postfix = null, string hint = "") + //Combobox without key + public static GSUI Combobox(string label, List items, GSOptionCallback callback, GSOptionPostfix postfix = null, string hint = "") { var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Combobox", items, callback, - postfix, hint); + var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Combobox", items, callback, postfix, hint); return instance; } - public static GSUI Combobox(string label, List items, int defaultValue, string key, - GSOptionCallback callback = null, string hint = "") + //Combobox with key + public static GSUI Combobox(string label, List items, int defaultValue, string key, GSOptionCallback callback = null, string hint = "") { - var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), key, label, "Combobox", items, null, - null, hint); + GSUI instance = null; + var tt = Utils.GetCallingType(); + foreach (var t in tt.GetInterfaces()) + if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Combobox", items, null, null, hint); + else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Combobox", items, null, null, hint); + if (instance == null) return null; instance.callback = instance.CreateDefaultCallback(callback); instance.postfix = instance.CreateDefaultPostfix(); instance.comboDefault = defaultValue; return instance; } - public static GSUI Input(string label, string value, GSOptionCallback callback, GSOptionPostfix postfix = null, - string hint = "") + //Input no key + public static GSUI Input(string label, string value, GSOptionCallback callback, GSOptionPostfix postfix = null, string hint = "") { var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Input", value, callback, - postfix, hint); + var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Input", value, callback, postfix, hint); return instance; } - public static GSUI Input(string label, string defaultValue, string key, GSOptionCallback callback = null, - string hint = "") + //Input with Key + public static GSUI Input(string label, string defaultValue, string key, GSOptionCallback callback = null, string hint = "") { - var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), key, label, "Input", defaultValue, null, - null, hint); + GSUI instance = null; + var tt = Utils.GetCallingType(); + foreach (var t in tt.GetInterfaces()) + if (t.Name == "iGenerator" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurableGeneratorInstance(tt), key, label, "Input", defaultValue, null, null, hint); + else if (t.Name == "iConfigurablePlugin" && !tt.IsAbstract && !tt.IsInterface) instance = new GSUI(Utils.GetConfigurablePluginInstance(tt), key, label, "Input", defaultValue, null, null, hint); + if (instance == null) return null; instance.callback = instance.CreateDefaultCallback(callback); instance.postfix = instance.CreateDefaultPostfix(); return instance; } - public static GSUI Button(string label, string caption, GSOptionCallback callback, - GSOptionPostfix postfix = null, string hint = "") + //Button + public static GSUI Button(string label, string caption, GSOptionCallback callback, GSOptionPostfix postfix = null, string hint = "") { var t = Utils.GetCallingType(); - var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Button", caption, callback, - null, hint); + var instance = new GSUI(Utils.GetConfigurableGeneratorInstance(t), null, label, "Button", caption, callback, null, hint); return instance; } } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs index 045b7d91..5cd2450a 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs @@ -132,6 +132,15 @@ public Val DefaultValue if (comboDefault >= 0) return comboDefault; GS2.Warn($"No default value found for Combobox {Label}"); return false; + case "Selector": + List list = Data as List; + if (comboDefault >= 0) + { + if (list.Count > comboDefault) + return list[comboDefault]; + } + GS2.Warn($"No default value found for Combobox {Label}"); + return false; } GS2.Error($"Failed to return default value for {Type} {Label}"); @@ -522,7 +531,7 @@ private GSOptionPostfix CreateDefaultPostfix() // GS2.Log($"{key} Value:{value} is null?:{value == null}"); if (value == null) { - GS2.Warn($"Setting value which was null for {key} to {DefaultValue}"); + // GS2.Warn($"Setting value which was null for {key} to {DefaultValue}"); value = DefaultValue; } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs index aa4a19b4..dc13e242 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Xml.Schema; @@ -103,7 +104,6 @@ public void Import(GSGenPreferences preferences) // GS2.Log("*"); } - public static GSUI xx; public void Init() { // GS2.Warn("!"); @@ -114,11 +114,7 @@ public void Init() RefreshFileNames(); // Options.Add(GSUI.Checkbox("Vanilla Grid (200r)".Translate(), false, "Vanilla Grid", VanillaGridCheckboxCallback, "Use the vanilla grid for 200 size planets".Translate())); - var xOptions = new GSOptions(); - xOptions.Add(GSUI.Checkbox("Show Iron Vein Labels".Translate(), true, "veinTip1", UpdateVeinDetail, "When show vein markers is enabled".Translate())); - xOptions.Add(GSUI.Checkbox("Show Copper Vein Labels".Translate(), true, "veinTip2", UpdateVeinDetail, "When show vein markers is enabled".Translate())); - xx = Options.Add(GSUI.Group("TEST", xOptions, "keyey", false, "Testy", true, (o)=>Warn(xx.DefaultValue))); var VeinOptions = new GSOptions(); VeinOptions.Add(GSUI.Spacer()); VeinOptions.Add(GSUI.Checkbox("Show Iron Vein Labels".Translate(), true, "veinTip1", UpdateVeinDetail, "When show vein markers is enabled".Translate())); @@ -181,7 +177,7 @@ public void Init() public void ResetBinaryStars(Val o) { - var random = new Random(GSSettings.Seed); + var random = new GS2.Random(GSSettings.Seed); foreach (var star in GSSettings.Stars) if (star.BinaryCompanion != null) { diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIList.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIList.cs index 5c06aed9..2b987b8b 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIList.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIList.cs @@ -103,6 +103,11 @@ public GSUIDropdown AddDropdown() var go = AddItem(templates.dropdown); go.SetActive(true); return go.GetComponent(); + } public GSUISelector AddSelector() + { + var go = AddItem(templates.selector); + go.SetActive(true); + return go.GetComponent(); } public GSUIButton AddButton() { diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUISelector.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUISelector.cs index 3e275f7c..5455b145 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUISelector.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUISelector.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Steamworks; +using System.Collections.Generic; using UnityEngine; -using UnityEngine.Experimental.PlayerLoop; using UnityEngine.UI; namespace GalacticScale @@ -12,20 +8,18 @@ public class GSUISelector : MonoBehaviour { public Button lbutton; public Button rButton; - public GSOptionCallback OnLeftClick; - public GSOptionCallback OnRightClick; - public GSOptionCallback OnChange; public Text _labelText; public Text _hintText; public Text _itemText; - public List Items = new List() {"Test", "Test2", "test3!"}; + public List Items = new List { "Test", "Test2", "test3!" }; private int _index = 0; + public GSOptionCallback OnChange; + public GSOptionCallback OnLeftClick; + public GSOptionCallback OnRightClick; + public int index { - get - { - return _index; - } + get => _index; set { _index = value; @@ -35,10 +29,7 @@ public int index public string value { - get - { - return Items[_index]; - } + get => Items[_index]; set { if (!Items.Contains(value)) GS2.Error($"Trying to set an invalid value of {value}"); @@ -47,23 +38,26 @@ public string value } } - public void UpdateItem() - { - if (Items.Count == 0) return; - if (_index < 0 || _index >= Items.Count) index = 0; - _itemText.text = Items[_index]; - } public string Hint { get => _hintText.text; set => _hintText.text = value; } + public string Label { get => _labelText.text; set => _labelText.text = value; } + public void UpdateItem() + { + if (Items.Count == 0) return; + if (_index < 0 || _index >= Items.Count) index = 0; + _itemText.text = Items[_index]; + OnChange.Invoke(Items[_index]); + } + public void LeftClick() { @@ -72,25 +66,22 @@ public void LeftClick() if (_index < 0) _index = Items.Count - 1; UpdateItem(); } + public void RightClick() { - Debug.Log("LeftClick"); - _index--; - if (_index > Items.Count -1) _index = 0; + Debug.Log("RightClick"); + _index++; + if (_index > Items.Count - 1) _index = 0; UpdateItem(); } + public void initialize(GSUI options) { - // GS2.Log("Initializing"); - //_dropdown.AddOptions(options.Data as List); - // Caption = (string)options.Data; - Canvas.ForceUpdateCanvases(); + Items = options.Data as List; + // Canvas.ForceUpdateCanvases(); Label = options.Label; Hint = options.Hint; OnChange = options.callback; - //options.postfix?.Invoke(); - } } - } \ No newline at end of file diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/SettingsUI.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/SettingsUI.cs index 4396b9d1..d31e0f69 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/SettingsUI.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/SettingsUI.cs @@ -1,20 +1,16 @@ -using System; +//using System.Linq; +//using UITools; using System.Collections.Generic; using System.IO; -//using System.Linq; using System.Reflection; using HarmonyLib; -//using UITools; using UnityEngine; using UnityEngine.Events; -using UnityEngine.EventSystems; using UnityEngine.UI; -using Object = UnityEngine.Object; using static GalacticScale.GS2; + namespace GalacticScale { - - public static class SettingsUI { public static int MainTabIndex = 5; @@ -27,7 +23,9 @@ public static class SettingsUI //private static readonly List optionRects = new List(); public static readonly List GeneratorCanvases = new List(); + public static readonly List> generatorPluginOptions = new List>(); + // public static GameObject themeselector; private static float anchorX; private static float anchorY; @@ -47,8 +45,7 @@ public static void CreateGalacticScaleSettingsPage(UIButton[] _tabButtons, Text[ var tabButtonTemplate = tabParent.GetChild(tabParent.childCount - 1).GetComponent(); galacticButton = Object.Instantiate(tabButtonTemplate, tabLine, false); galacticButton.name = "tab-button-gs"; - galacticButton.anchoredPosition = - new Vector2(galacticButton.anchoredPosition.x + 160, galacticButton.anchoredPosition.y); + galacticButton.anchoredPosition = new Vector2(galacticButton.anchoredPosition.x + 160, galacticButton.anchoredPosition.y); Object.Destroy(galacticButton.GetComponentInChildren()); galacticButton.GetComponent