diff --git a/GalacticScale2/DSP_Plugins.GalacticScale.csproj b/GalacticScale2/DSP_Plugins.GalacticScale.csproj
index a16b5b13..307d5733 100644
--- a/GalacticScale2/DSP_Plugins.GalacticScale.csproj
+++ b/GalacticScale2/DSP_Plugins.GalacticScale.csproj
@@ -151,6 +151,7 @@
+
@@ -188,6 +189,7 @@
+
@@ -270,11 +272,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -393,7 +409,6 @@
-
@@ -419,4 +434,4 @@
-
+
\ No newline at end of file
diff --git a/GalacticScale2/Directory.Build.props.example b/GalacticScale2/Directory.Build.props.example
deleted file mode 100644
index b5da3536..00000000
--- a/GalacticScale2/Directory.Build.props.example
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
- C:\Users\{username}\AppData\Roaming\r2modmanPlus-local\DysonSphereProgram\profiles\test\BepInEx\plugins\GalacticScale
- C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program
- C:\Users\{username}\AppData\Roaming\r2modmanPlus-local\DysonSphereProgram\profiles\test\BepInEx\core
-
-
-
-
-
-
diff --git a/GalacticScale2/Properties/AssemblyInfo.cs b/GalacticScale2/Properties/AssemblyInfo.cs
index 8b8e1b8c..d95b098c 100644
--- a/GalacticScale2/Properties/AssemblyInfo.cs
+++ b/GalacticScale2/Properties/AssemblyInfo.cs
@@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.80.0")]
-[assembly: AssemblyFileVersion("2.0.80.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("2.0.81.5")]
+[assembly: AssemblyFileVersion("2.0.81.5")]
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/3rdParty/RangeSlider.cs b/GalacticScale2/Scripts/3rdParty/RangeSlider.cs
new file mode 100644
index 00000000..322cb942
--- /dev/null
+++ b/GalacticScale2/Scripts/3rdParty/RangeSlider.cs
@@ -0,0 +1,600 @@
+/// Credit Ben MacKinnon @Dover8
+/// Sourced from - https://github.com/Dover8/Unity-UI-Extensions/tree/range-slider
+/// Usage: Extension of the standard slider. Two handles determine a low and high value between a Min and Max.
+/// Raises a UnityEvent passing the low and high values
+
+using System;
+using UnityEngine.Events;
+using UnityEngine.EventSystems;
+
+namespace UnityEngine.UI.Extensions
+{
+ [AddComponentMenu("UI/Extensions/Range Slider", 34)]
+ [ExecuteInEditMode]
+ [RequireComponent(typeof(RectTransform))]
+ public class RangeSlider : Selectable, IDragHandler, IInitializePotentialDragHandler, ICanvasElement
+ {
+
+ [Serializable]
+ public class RangeSliderEvent : UnityEvent { }
+
+ [SerializeField]
+ private RectTransform m_FillRect;
+
+ public RectTransform FillRect { get { return m_FillRect; } set { if (SetClass(ref m_FillRect, value)) { UpdateCachedReferences(); UpdateVisuals(); } } }
+
+ [SerializeField]
+ private RectTransform m_LowHandleRect;
+
+ public RectTransform LowHandleRect { get { return m_LowHandleRect; } set { if (SetClass(ref m_LowHandleRect, value)) { UpdateCachedReferences(); UpdateVisuals(); } } }
+
+ [SerializeField]
+ private RectTransform m_HighHandleRect;
+
+ public RectTransform HighHandleRect { get { return m_HighHandleRect; } set { if (SetClass(ref m_HighHandleRect, value)) { UpdateCachedReferences(); UpdateVisuals(); } } }
+
+ [Space]
+
+ [SerializeField]
+ private float m_MinValue = 0;
+
+ public float MinValue { get { return m_MinValue; } set { if (SetStruct(ref m_MinValue, value)) { SetLow(m_LowValue); SetHigh(m_HighValue); UpdateVisuals(); } } }
+
+
+ [SerializeField]
+ private float m_MaxValue = 1;
+
+ public float MaxValue { get { return m_MaxValue; } set { if (SetStruct(ref m_MaxValue, value)) { SetLow(m_LowValue); SetHigh(m_HighValue); UpdateVisuals(); } } }
+
+ [SerializeField]
+ private bool m_WholeNumbers = false;
+
+ public bool WholeNumbers { get { return m_WholeNumbers; } set { if (SetStruct(ref m_WholeNumbers, value)) { SetLow(m_LowValue); SetHigh(m_HighValue); UpdateVisuals(); } } }
+
+ [SerializeField]
+ private float m_LowValue;
+ public virtual float LowValue
+ {
+ get
+ {
+ if (WholeNumbers)
+ {
+ return Mathf.Round(m_LowValue);
+ }
+
+ return m_LowValue;
+ }
+ set
+ {
+ SetLow(value);
+ }
+ }
+
+ public float NormalizedLowValue
+ {
+ get
+ {
+ if (Mathf.Approximately(MinValue, MaxValue))
+ {
+ return 0;
+ }
+ return Mathf.InverseLerp(MinValue, MaxValue, LowValue);
+ }
+ set
+ {
+ this.LowValue = Mathf.Lerp(MinValue, MaxValue, value);
+ }
+ }
+
+
+ [SerializeField]
+ private float m_HighValue;
+ public virtual float HighValue
+ {
+ get
+ {
+ if (WholeNumbers)
+ {
+ return Mathf.Round(m_HighValue);
+ }
+
+ return m_HighValue;
+ }
+ set
+ {
+ SetHigh(value);
+ }
+ }
+
+ public float NormalizedHighValue
+ {
+ get
+ {
+ if (Mathf.Approximately(MinValue, MaxValue))
+ {
+ return 0;
+ }
+ return Mathf.InverseLerp(MinValue, MaxValue, HighValue);
+ }
+ set
+ {
+ this.HighValue = Mathf.Lerp(MinValue, MaxValue, value);
+ }
+ }
+
+ ///
+ /// Set the value of the slider without invoking onValueChanged callback.
+ ///
+ /// The new value for the slider.
+ public virtual void SetValueWithoutNotify(float low, float high)
+ {
+ SetLow(low, false);
+ SetHigh(high, false);
+ }
+
+ [Space]
+
+ [SerializeField]
+ private RangeSliderEvent m_OnValueChanged = new RangeSliderEvent();
+
+ public RangeSliderEvent OnValueChanged { get { return m_OnValueChanged; } set { m_OnValueChanged = value; } }
+
+ // Private fields
+
+ ///
+ /// An Enum that says in what state we and interacting with the slider
+ ///
+ private enum InteractionState
+ {
+ Low,
+ High,
+ Bar,
+ None
+ }
+
+ private InteractionState interactionState = InteractionState.None;
+
+ private Image m_FillImage;
+ private Transform m_FillTransform;
+ private RectTransform m_FillContainerRect;
+ private Transform m_HighHandleTransform;
+ private RectTransform m_HighHandleContainerRect;
+ private Transform m_LowHandleTransform;
+ private RectTransform m_LowHandleContainerRect;
+
+ // The offset from handle position to mouse down position
+ private Vector2 m_LowOffset = Vector2.zero;
+ // The offset from handle position to mouse down position
+ private Vector2 m_HighOffset = Vector2.zero;
+
+ private DrivenRectTransformTracker m_Tracker;
+
+ // This "delayed" mechanism is required for case 1037681.
+ private bool m_DelayedUpdateVisuals = false;
+
+ // Size of each step.
+ float StepSize { get { return WholeNumbers ? 1 : (MaxValue - MinValue) * 0.1f; } }
+
+ protected RangeSlider()
+ { }
+
+#if UNITY_EDITOR
+ protected override void OnValidate()
+ {
+ base.OnValidate();
+
+ if (WholeNumbers)
+ {
+ m_MinValue = Mathf.Round(m_MinValue);
+ m_MaxValue = Mathf.Round(m_MaxValue);
+ }
+
+ if (IsActive())
+ {
+ UpdateCachedReferences();
+ SetLow(m_LowValue, false);
+ SetHigh(m_HighValue, false);
+ //Update rects since other things might affect them even if value didn't change
+ m_DelayedUpdateVisuals = true;
+ }
+
+ if (!UnityEditor.PrefabUtility.IsPartOfPrefabAsset(this) && !Application.isPlaying)
+ {
+ CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild(this);
+ }
+ }
+#endif
+
+ public virtual void Rebuild(CanvasUpdate executing)
+ {
+#if UNITY_EDITOR
+ if (executing == CanvasUpdate.Prelayout)
+ {
+ OnValueChanged.Invoke(LowValue, HighValue);
+ }
+#endif
+ }
+
+ ///
+ /// See ICanvasElement.LayoutComplete
+ ///
+ public virtual void LayoutComplete()
+ { }
+
+ ///
+ /// See ICanvasElement.GraphicUpdateComplete
+ ///
+ public virtual void GraphicUpdateComplete()
+ { }
+
+ public static bool SetClass(ref T currentValue, T newValue) where T : class
+ {
+ if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
+ return false;
+
+ currentValue = newValue;
+ return true;
+ }
+
+ public static bool SetStruct(ref T currentValue, T newValue) where T : struct
+ {
+ if (currentValue.Equals(newValue))
+ return false;
+
+ currentValue = newValue;
+ return true;
+ }
+
+ protected override void OnEnable()
+ {
+ base.OnEnable();
+ UpdateCachedReferences();
+ SetLow(LowValue, false);
+ SetHigh(HighValue, false);
+ // Update rects since they need to be initialized correctly.
+ UpdateVisuals();
+ }
+
+ protected override void OnDisable()
+ {
+ m_Tracker.Clear();
+ base.OnDisable();
+ }
+
+ ///
+ /// Update the rect based on the delayed update visuals.
+ /// Got around issue of calling sendMessage from onValidate.
+ ///
+ protected virtual void Update()
+ {
+ if (m_DelayedUpdateVisuals)
+ {
+ m_DelayedUpdateVisuals = false;
+ UpdateVisuals();
+ }
+ }
+
+ protected override void OnDidApplyAnimationProperties()
+ {
+ base.OnDidApplyAnimationProperties();
+ }
+
+ void UpdateCachedReferences()
+ {
+ if (m_FillRect && m_FillRect != (RectTransform)transform)
+ {
+ m_FillTransform = m_FillRect.transform;
+ m_FillImage = m_FillRect.GetComponent();
+ if (m_FillTransform.parent != null)
+ m_FillContainerRect = m_FillTransform.parent.GetComponent();
+ }
+ else
+ {
+ m_FillRect = null;
+ m_FillContainerRect = null;
+ m_FillImage = null;
+ }
+
+ if (m_HighHandleRect && m_HighHandleRect != (RectTransform)transform)
+ {
+ m_HighHandleTransform = m_HighHandleRect.transform;
+ if (m_HighHandleTransform.parent != null)
+ m_HighHandleContainerRect = m_HighHandleTransform.parent.GetComponent();
+ }
+ else
+ {
+ m_HighHandleRect = null;
+ m_HighHandleContainerRect = null;
+ }
+
+ if (m_LowHandleRect && m_LowHandleRect != (RectTransform)transform)
+ {
+ m_LowHandleTransform = m_LowHandleRect.transform;
+ if (m_LowHandleTransform.parent != null)
+ {
+ m_LowHandleContainerRect = m_LowHandleTransform.parent.GetComponent();
+ }
+ }
+ else
+ {
+ m_LowHandleRect = null;
+ m_LowHandleContainerRect = null;
+ }
+ }
+
+ void SetLow(float input)
+ {
+ SetLow(input, true);
+ }
+
+ protected virtual void SetLow(float input, bool sendCallback)
+ {
+ // Clamp the input
+ float newValue = Mathf.Clamp(input, MinValue, HighValue); //clamp between min and High
+ if (WholeNumbers)
+ {
+ newValue = Mathf.Round(newValue);
+ }
+
+ // If the stepped value doesn't match the last one, it's time to update
+ if (m_LowValue == newValue)
+ return;
+
+ m_LowValue = newValue;
+ UpdateVisuals();
+ if (sendCallback)
+ {
+ UISystemProfilerApi.AddMarker("RangeSlider.lowValue", this);
+ m_OnValueChanged.Invoke(newValue, HighValue);
+ }
+ }
+
+ void SetHigh(float input)
+ {
+ SetHigh(input, true);
+ }
+
+ protected virtual void SetHigh(float input, bool sendCallback)
+ {
+ // Clamp the input
+ float newValue = Mathf.Clamp(input, LowValue, MaxValue); //clamp between min and High
+ if (WholeNumbers)
+ {
+ newValue = Mathf.Round(newValue);
+ }
+
+ // If the stepped value doesn't match the last one, it's time to update
+ if (m_HighValue == newValue)
+ return;
+
+ m_HighValue = newValue;
+ UpdateVisuals();
+ if (sendCallback)
+ {
+ UISystemProfilerApi.AddMarker("RangeSlider.highValue", this);
+ m_OnValueChanged.Invoke(LowValue, newValue);
+ }
+ }
+
+
+ protected override void OnRectTransformDimensionsChange()
+ {
+ base.OnRectTransformDimensionsChange();
+
+ //This can be invoked before OnEnabled is called. So we shouldn't be accessing other objects, before OnEnable is called.
+ if (!IsActive())
+ return;
+
+ UpdateVisuals();
+ }
+
+
+ // Force-update the slider. Useful if you've changed the properties and want it to update visually.
+ private void UpdateVisuals()
+ {
+#if UNITY_EDITOR
+ if (!Application.isPlaying)
+ UpdateCachedReferences();
+#endif
+
+ m_Tracker.Clear();
+
+ if (m_FillContainerRect != null)
+ {
+ m_Tracker.Add(this, m_FillRect, DrivenTransformProperties.Anchors);
+ Vector2 anchorMin = Vector2.zero;
+ Vector2 anchorMax = Vector2.one;
+
+ //this is where some new magic must happen. Slider just uses a filled image
+ //and changes the % of fill. We must move the image anchors to be between the two handles.
+ anchorMin[0] = NormalizedLowValue;
+ anchorMax[0] = NormalizedHighValue;
+
+ m_FillRect.anchorMin = anchorMin;
+ m_FillRect.anchorMax = anchorMax;
+ }
+
+ if (m_LowHandleContainerRect != null)
+ {
+ m_Tracker.Add(this, m_LowHandleRect, DrivenTransformProperties.Anchors);
+ Vector2 anchorMin = Vector2.zero;
+ Vector2 anchorMax = Vector2.one;
+ anchorMin[0] = anchorMax[0] = NormalizedLowValue;
+ m_LowHandleRect.anchorMin = anchorMin;
+ m_LowHandleRect.anchorMax = anchorMax;
+ }
+
+ if (m_HighHandleContainerRect != null)
+ {
+ m_Tracker.Add(this, m_HighHandleRect, DrivenTransformProperties.Anchors);
+ Vector2 anchorMin = Vector2.zero;
+ Vector2 anchorMax = Vector2.one;
+ anchorMin[0] = anchorMax[0] = NormalizedHighValue;
+ m_HighHandleRect.anchorMin = anchorMin;
+ m_HighHandleRect.anchorMax = anchorMax;
+ }
+ }
+
+ // Update the slider's position based on the mouse.
+ void UpdateDrag(PointerEventData eventData, Camera cam)
+ {
+ //this needs to differ from slider in that we have two handles, and need to move the right one.
+ //and if it was neither handle, we will have a separate case where both handles move uniformly
+ //moving the entire range
+
+ //this is where we use our interationState
+ switch (interactionState)
+ {
+ case InteractionState.Low:
+ NormalizedLowValue = CalculateDrag(eventData, cam, m_LowHandleContainerRect, m_LowOffset);
+ break;
+ case InteractionState.High:
+ NormalizedHighValue = CalculateDrag(eventData, cam, m_HighHandleContainerRect, m_HighOffset);
+ break;
+ case InteractionState.Bar:
+ //special case
+ CalculateBarDrag(eventData, cam);
+ break;
+ case InteractionState.None:
+ break;
+ }
+ }
+
+ private float CalculateDrag(PointerEventData eventData, Camera cam, RectTransform containerRect, Vector2 offset)
+ {
+ RectTransform clickRect = containerRect ?? m_FillContainerRect;
+ if (clickRect != null && clickRect.rect.size[0] > 0)
+ {
+ Vector2 localCursor;
+ if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(clickRect, eventData.position, cam, out localCursor))
+ {
+ return 0f;
+ }
+ localCursor -= clickRect.rect.position;
+
+ float val = Mathf.Clamp01((localCursor - offset)[0] / clickRect.rect.size[0]);
+
+ return val;
+ }
+ return 0;
+ }
+
+ private void CalculateBarDrag(PointerEventData eventData, Camera cam)
+ {
+ RectTransform clickRect = m_FillContainerRect;
+ if (clickRect != null && clickRect.rect.size[0] > 0)
+ {
+ Vector2 localCursor;
+ if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(clickRect, eventData.position, cam, out localCursor))
+ {
+ return;
+ }
+ localCursor -= clickRect.rect.position;
+
+ //now we need to get the delta drag on the bar
+ //and move both the normalized low and high values by this amount
+ //but also check that neither is going beyond the bounds
+ if (NormalizedLowValue >= 0 && NormalizedHighValue <= 1)
+ {
+ //find the mid point on the current bar
+ float mid = (NormalizedHighValue + NormalizedLowValue)/2;
+ //find where the new mid point should be
+ float val = Mathf.Clamp01((localCursor)[0] / clickRect.rect.size[0]);
+ //calculate the delta
+ float delta = val - mid;
+ //check the clamp range
+ if (NormalizedLowValue + delta < 0)
+ {
+ delta = -NormalizedLowValue;
+ }
+ else if (NormalizedHighValue + delta > 1)
+ {
+ delta = 1 - NormalizedHighValue;
+ }
+
+ //adjust both ends
+ NormalizedLowValue += delta;
+ NormalizedHighValue += delta;
+ }
+ }
+ }
+
+ private bool MayDrag(PointerEventData eventData)
+ {
+ return IsActive() && IsInteractable() && eventData.button == PointerEventData.InputButton.Left;
+ }
+
+ public override void OnPointerDown(PointerEventData eventData)
+ {
+ if (!MayDrag(eventData))
+ return;
+
+
+ //HANDLE DRAG EVENTS
+ m_LowOffset = m_HighOffset = Vector2.zero;
+ Vector2 localMousePos;
+ if (m_HighHandleRect != null && RectTransformUtility.RectangleContainsScreenPoint(m_HighHandleRect, eventData.position, eventData.enterEventCamera))
+ {
+ //dragging the high value handle
+ if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_HighHandleRect, eventData.position, eventData.pressEventCamera, out localMousePos))
+ {
+ m_HighOffset = localMousePos;
+ }
+ interactionState = InteractionState.High;
+ if (transition == Transition.ColorTint)
+ {
+ targetGraphic = m_HighHandleRect.GetComponent();
+ }
+ }
+ else if (m_LowHandleRect != null && RectTransformUtility.RectangleContainsScreenPoint(m_LowHandleRect, eventData.position, eventData.enterEventCamera))
+ {
+ //dragging the low value handle
+ if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_LowHandleRect, eventData.position, eventData.pressEventCamera, out localMousePos))
+ {
+ m_LowOffset = localMousePos;
+ }
+ interactionState = InteractionState.Low;
+ if (transition == Transition.ColorTint)
+ {
+ targetGraphic = m_LowHandleRect.GetComponent();
+ }
+ }
+ else
+ {
+ //outside the handles, move the entire slider along
+ UpdateDrag(eventData, eventData.pressEventCamera);
+ interactionState = InteractionState.Bar;
+ if (transition == Transition.ColorTint)
+ {
+ targetGraphic = m_FillImage;
+ }
+ }
+ base.OnPointerDown(eventData);
+ }
+
+ public virtual void OnDrag(PointerEventData eventData)
+ {
+ if (!MayDrag(eventData))
+ {
+ return;
+ }
+ UpdateDrag(eventData, eventData.pressEventCamera);
+ }
+
+ public override void OnPointerUp(PointerEventData eventData)
+ {
+ base.OnPointerUp(eventData);
+ interactionState = InteractionState.None;
+ }
+
+ public override void OnMove(AxisEventData eventData)
+ {
+ //this requires further investigation
+ }
+
+ public virtual void OnInitializePotentialDrag(PointerEventData eventData)
+ {
+ eventData.useDragThreshold = false;
+ }
+ }
+}
diff --git a/GalacticScale2/Scripts/Assets/galacticbundle b/GalacticScale2/Scripts/Assets/galacticbundle
index 956a0c22..5b6863ae 100644
Binary files a/GalacticScale2/Scripts/Assets/galacticbundle and b/GalacticScale2/Scripts/Assets/galacticbundle differ
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/CreateStarCountText.cs b/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/CreateStarCountText.cs
index 566c27bb..c87b7d57 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/CreateStarCountText.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/CreateStarCountText.cs
@@ -10,13 +10,22 @@ public static GameObject CreateStarCountText(Slider slider)
var starCountSlider = slider.GetComponent();
slider.gameObject.SetActive(false);
var template = slider.GetComponentInParent();
- var starCountText = Instantiate(template.GetComponent(),
+ RectTransform starCountText;
+ if (template != null)
+ {
+ var rect = template.GetComponent();
+ if (rect == null) return null;
+
+ starCountText = Object.Instantiate(rect,
template.GetComponentInParent().parent, false);
starCountText.anchoredPosition = new Vector2(starCountText.anchoredPosition.x + 140,
starCountSlider.GetComponentInParent().anchoredPosition.y);
- DestroyImmediate(starCountText.GetComponent());
+ Object.DestroyImmediate(starCountText.GetComponent());
starCountText.name = "GS Star Count";
- return starCountText.gameObject;
+ return starCountText.gameObject; }
+
+ return null;
}
+
+ }
}
-}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs b/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs
index 1060cc41..3c518793 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs
@@ -112,6 +112,13 @@ public static GalaxyData ProcessGalaxy(GameDesc desc, bool sketchOnly = false)
$"birthStarName: {galaxy.stars[galaxy.birthStarId - 1].name} Radius:{galaxy.PlanetById(galaxy.birthPlanetId).radius} Scale:{galaxy.PlanetById(galaxy.birthPlanetId).scale}");
Log($"its planets length: {galaxy.stars[galaxy.birthStarId - 1].planets.Length}");
Log($"First System Radius = {galaxy.stars[0].systemRadius}");
+ // foreach (var star in GSSettings.Stars)
+ // {
+ // foreach (var planet in star.Planets)
+ // {
+ // GS2.Warn($"Theme used:{planet.GsTheme.Name}");
+ // }
+ // }
return galaxy;
}
catch (Exception e)
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2/GS2Generator.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2/GS2Generator.cs
index fa7b939c..fd440d73 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2/GS2Generator.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2/GS2Generator.cs
@@ -117,7 +117,7 @@ private void EnsureBirthSystemHasTi()
var p = birthPlanet;
while (p == birthPlanet) p = random.Item(birthStar.TelluricBodies);
- p.Theme = "AshenGellisol";
+ p.Theme = "AshenGelisol";
}
}
@@ -576,7 +576,7 @@ private float GetOrbitGap(GSStar star)
(float min, float max) hz = Utils.CalculateHabitableZone(star.luminosity);
float pCount = star.Planets.Count;
var maxOrbitByRadius = Mathf.Sqrt(star.radius);
- var maxOrbitByHabitableZone = 30f * hz.max;
+ var maxOrbitByHabitableZone = 30f * hz.min;
var maxOrbitByPlanetCount = 50f * pCount / 99f;
var maxOrbit = Mathf.Max(maxOrbitByPlanetCount, maxOrbitByRadius, maxOrbitByHabitableZone);
var averageOrbit = maxOrbit / pCount;
@@ -711,13 +711,13 @@ private bool CalculateIsGas(GSStar star)
public static EThemeHeat CalculateThemeHeat(GSStar star, float OrbitRadius)
{
(float min, float max) hz = Utils.CalculateHabitableZone(star.luminosity);
- hz.min *= 5f;
- hz.max *= 10f;
+ hz.max *= 5f;
+ hz.min *= 10f;
//Warn($"HZ for {star.Name} {hz.min}-{hz.max}");
- if (OrbitRadius < hz.min / 2) return EThemeHeat.Hot;
- if (OrbitRadius < hz.min) return EThemeHeat.Warm;
- if (OrbitRadius < hz.max) return EThemeHeat.Temperate;
- if (OrbitRadius < hz.max * 2) return EThemeHeat.Cold;
+ if (OrbitRadius < hz.max / 2) return EThemeHeat.Hot;
+ if (OrbitRadius < hz.max) return EThemeHeat.Warm;
+ if (OrbitRadius < hz.min) return EThemeHeat.Temperate;
+ if (OrbitRadius < hz.min * 2) return EThemeHeat.Cold;
return EThemeHeat.Frozen;
}
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/GS2Generator.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/GS2Generator.cs
index 10fe8293..2cd13cae 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/GS2Generator.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/GS2Generator.cs
@@ -136,16 +136,17 @@ private void EnsureBirthSystemHasTi()
// if (!GSSettings.ThemeLibrary.ContainsKey("AshenGelisol"))
// {
Themes.AshenGelisol.Process();
- if (!GS2.ThemeLibrary.ContainsKey("AshenGelisol"))
+ if (!GSSettings.ThemeLibrary.ContainsKey("AshenGelisol"))
{
Warn("Nope" + GS2.ThemeLibrary.Count);
- GS2.ThemeLibrary.Add("AshenGelisol", Themes.AshenGelisol);
+ GSSettings.ThemeLibrary.Add("AshenGelisol", Themes.AshenGelisol);
+ Themes.AshenGelisol.Process();
}
GS2.Warn($"Ashen Gelisol:{GSSettings.ThemeLibrary.ContainsKey("AshenGelisol")}");
// }
- var tiPlanet = birthStar.Planets.Add(new GSPlanet("Black Swan", "AshenGelisol",
- GetStarPlanetSize(birthStar), GetOrbitGap(birthStar) * birthStar.PlanetCount, 0f, 100000f, 0f,
- 0f, 360f, 0f, -1f));
+ var tiPlanet = birthPlanet.Moons.Add(new GSPlanet("Titania McGrath", "AshenGelisol",
+ GetStarPlanetSize(birthStar), 0.03f, 66f, 1000f, 0f,
+ 66f, 360f, 0f, -1f));
tiPlanet.OrbitalPeriod =
Utils.CalculateOrbitPeriodFromStarMass(tiPlanet.OrbitRadius, birthStar.mass);
return;
@@ -153,7 +154,7 @@ private void EnsureBirthSystemHasTi()
var p = birthPlanet;
while (p == birthPlanet) p = random.Item(birthStar.TelluricBodies);
- p.Theme = "AshenGellisol";
+ p.Theme = "AshenGelisol";
}
}
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs
index a9e60650..a554ade6 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs
@@ -1,5 +1,4 @@
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
+using System.Collections.Generic;
using UnityEngine;
using static GalacticScale.GS2;
@@ -66,13 +65,13 @@ private void AssignPlanetOrbits(GSStar star)
if (availableOrbits.Count == 0)
{
//Warn("Free Orbit Ranges:");
- LogJson(freeOrbitRanges);
+ // LogJson(freeOrbitRanges);
//Warn($"No Orbit Ranges found for planet {planet.Name} radius:{planet.SystemRadius}");
var success = false;
foreach (var existingOrbit in orbits)
if (existingOrbit.hasRoom && existingOrbit.SystemRadius > planet.SystemRadius)
{
- Warn($"Existing orbit {existingOrbit.radius} used for planet {planet.Name}");
+ // Warn($"Existing orbit {existingOrbit.radius} used for planet {planet.Name}");
existingOrbit.planets.Add(planet);
planet.OrbitRadius = existingOrbit.radius;
planet.OrbitalPeriod = Utils.CalculateOrbitPeriod(planet.OrbitRadius);
@@ -149,7 +148,7 @@ private int PlanetSortBySystemRadius(GSPlanet x, GSPlanet y)
private void SetPlanetOrbitPhase()
{
- Log("Adjusting Orbits");
+ // Log("Adjusting Orbits");
var r = new GS2.Random(GSSettings.Seed);
foreach (var star in GSSettings.Stars)
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs
index 26923711..c96a39d8 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
-using System.Runtime.Remoting.Messaging;
-using Steamworks;
using UnityEngine;
using static GalacticScale.GS2;
using static GalacticScale.RomanNumbers;
-using Random = System.Random;
namespace GalacticScale.Generators
{
@@ -233,7 +230,7 @@ public float GetOrbitGap(GSStar star)
(float min, float max) hz = Utils.CalculateHabitableZone(star.luminosity);
float pCount = star.Planets.Count;
var maxOrbitByRadius = Mathf.Sqrt(star.radius);
- var maxOrbitByHabitableZone = 30f * hz.max;
+ var maxOrbitByHabitableZone = 30f * hz.min;
var maxOrbitByPlanetCount = 50f * pCount / 99f;
var maxOrbit = Mathf.Max(maxOrbitByPlanetCount, maxOrbitByRadius, maxOrbitByHabitableZone);
var averageOrbit = maxOrbit / pCount;
@@ -274,8 +271,7 @@ public bool CalculateIsGas(GSStar star)
public static EThemeHeat CalculateThemeHeat(GSStar star, float OrbitRadius)
{
(float min, float max) hz = Utils.CalculateHabitableZone(star.luminosity);
- //hz.min *= 5f;
- //hz.max *= 10f;
+ // GS2.Warn($"Habitable zone for {star.Name} is {hz.min} - {hz.max}");
//Warn($"HZ for {star.Name} {hz.min}-{hz.max}");
if (OrbitRadius < hz.min / 2) return EThemeHeat.Hot;
if (OrbitRadius < hz.min) return EThemeHeat.Warm;
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Settings.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Settings.cs
index a1bd9f5f..c7de3076 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Settings.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Settings.cs
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Linq;
+using UnityEngine;
using static GalacticScale.GS2;
namespace GalacticScale.Generators
{
public partial class GS2Generator2 : iConfigurableGenerator
{
- private readonly GSGenPreferences preferences = new GSGenPreferences();
+ private GSGenPreferences preferences = new GSGenPreferences();
private Dictionary starFreq = new Dictionary();
private readonly Dictionary
@@ -34,19 +35,34 @@ public void Init()
InitPreferences();
}
+ private static bool loaded = false;
public void Import(GSGenPreferences preferences)
{
+
+ if (!this.preferences.GetBool("ludicrousMode", false) && preferences.GetBool("ludicrousMode", false))
+ {
+
+ EnableLudicrousMode();
+ Config.MaxStarCount = 4096;
+ }
+ // this.preferences = preferences;
for (var i = 0; i < preferences.Count; i++)
{
var key = preferences.Keys.ElementAt(i);
//GS2.Log($"pref set {key} {preferences[key]}");
this.preferences.Set(key, preferences[key]);
+
+ if (loaded && UI.ContainsKey(key))
+ {
+ // GS2.Warn($"Setting {key} {this.preferences[key]}");
+ UI[key].Set(preferences[key]);
+ }
}
+ if (loaded) loaded = false;
Config.DefaultStarCount = preferences.GetInt("defaultStarCount");
- if (preferences.GetBool("ludicrousMode")) Config.MaxStarCount = 4096;
- else Config.MaxStarCount = 1024;
+ if (!preferences.GetBool("ludicrousMode")) Config.MaxStarCount = 1024;
}
public GSGenPreferences Export()
@@ -116,8 +132,12 @@ public void EnableLudicrousMode()
UI["defaultStarCount"].Set(new GSSliderConfig(1, preferences.GetInt("defaultStarCount"), 4096));
UI["minPlanetCount"].Set(new GSSliderConfig(0, preferences.GetInt("minPlanetCount"), 99));
UI["maxPlanetCount"].Set(new GSSliderConfig(1, preferences.GetInt("maxPlanetCount"), 99));
+ UI["chanceGas"].Set(new GSSliderConfig(0, preferences.GetInt("chanceGas"), 99));
+ UI["chanceMoon"].Set(new GSSliderConfig(0, preferences.GetInt("chanceMoon"), 99));
for (var i = 0; i < 14; i++)
{
+ UI[$"{typeLetter[i]}chanceGas"].Set(new GSSliderConfig(0,preferences.GetInt($"{typeLetter[i]}chanceGas", 99), 99));
+ UI[$"{typeLetter[i]}chanceMoon"].Set(new GSSliderConfig(0,preferences.GetInt($"{typeLetter[i]}chanceMoon"), 99));
UI[$"{typeLetter[i]}minPlanetCount"].Set(new GSSliderConfig(0, preferences.GetInt($"{typeLetter[i]}minPlanetCount"), 99));
UI[$"{typeLetter[i]}maxPlanetCount"].Set(new GSSliderConfig(1, preferences.GetInt($"{typeLetter[i]}maxPlanetCount"), 99));
UI[$"{typeLetter[i]}minPlanetSize"].Set(new GSSliderConfig(5, preferences.GetInt($"{typeLetter[i]}minPlanetSize"), 500));
@@ -137,8 +157,12 @@ public void DisableLudicrousMode()
UI["defaultStarCount"].Set(new GSSliderConfig(1, preferences.GetInt("defaultStarCount"), 1024));
UI["minPlanetCount"].Set(new GSSliderConfig(0, preferences.GetInt("minPlanetCount"), 25));
UI["maxPlanetCount"].Set(new GSSliderConfig(1, preferences.GetInt("maxPlanetCount"), 25));
+ UI["chanceGas"].Set(new GSSliderConfig(10, Mathf.Clamp(preferences.GetInt("chanceGas"), 10, 50), 50));
+ UI["chanceMoon"].Set(new GSSliderConfig(10, Mathf.Clamp(preferences.GetInt("chanceMoon"), 10, 80), 80));
for (var i = 0; i < 14; i++)
{
+ UI[$"{typeLetter[i]}chanceGas"].Set(new GSSliderConfig(0,Mathf.Clamp(preferences.GetInt($"{typeLetter[i]}chanceGas"), 10, 50), 50));
+ UI[$"{typeLetter[i]}chanceMoon"].Set(new GSSliderConfig(0,Mathf.Clamp(preferences.GetInt($"{typeLetter[i]}chanceMoon"), 10, 80), 80));
UI[$"{typeLetter[i]}minPlanetCount"].Set(new GSSliderConfig(0, preferences.GetInt($"{typeLetter[i]}minPlanetCount"), 25));
UI[$"{typeLetter[i]}maxPlanetCount"].Set(new GSSliderConfig(1, preferences.GetInt($"{typeLetter[i]}maxPlanetCount"), 25));
UI[$"{typeLetter[i]}minPlanetSize"].Set(new GSSliderConfig(30, preferences.GetInt($"{typeLetter[i]}minPlanetSize"), 200));
@@ -287,6 +311,8 @@ private void InitPreferences()
private void AddUIElements()
{
+ Val l = preferences.GetBool("ludicrousMode", false);
+ GS2.Warn(l);
UI.Add("safeMode", Options.Add(GSUI.Checkbox("Safe Mode".Translate(), false, "safeMode", o =>
{
if ((bool) o) EnableSafeMode();
@@ -347,7 +373,7 @@ private void AddUIElements()
MaxPlanetSizeCallback)));
UI.Add("sizeBias", Options.Add(GSUI.Slider("Planet Size Bias".Translate(), 0, 50, 100, "sizeBias", SizeBiasCallback)));
- UI.Add("chanceGas", Options.Add(GSUI.Slider("Chance Gas".Translate(), 10, 20, 50, "chanceGas", GasChanceCallback)));
+ UI.Add("chanceGas", Options.Add(GSUI.Slider("Chance Gas".Translate(), 10, 20, l?99:50, "chanceGas", GasChanceCallback)));
UI.Add("chanceMoon", Options.Add(GSUI.Slider("Chance Moon".Translate(), 10, 20, 80, "chanceMoon", MoonChanceCallback)));
UI.Add("systemDensity",
Options.Add(GSUI.Slider("System Density".Translate(), 1, 3, 5, "systemDensity", SystemDensityCallback)));
@@ -373,13 +399,14 @@ private void AddUIElements()
UI.Add($"{typeLetter[i]}sizeBias",
Options.Add(GSUI.Slider($"{typeDesc[i]} Size Bias".Translate(), 0, 50, 100, $"{typeLetter[i]}sizeBias")));
UI.Add($"{typeLetter[i]}chanceGas",
- Options.Add(GSUI.Slider($"{typeDesc[i]} %Gas".Translate(), 10, 20, 50, $"{typeLetter[i]}chanceGas")));
+ Options.Add(GSUI.Slider($"{typeDesc[i]} %Gas".Translate(), l?0:10, 20, l?99:50, $"{typeLetter[i]}chanceGas")));
UI.Add($"{typeLetter[i]}chanceMoon",
- Options.Add(GSUI.Slider($"{typeDesc[i]} %Moon".Translate(), 10, 20, 80, $"{typeLetter[i]}chanceMoon")));
+ Options.Add(GSUI.Slider($"{typeDesc[i]} %Moon".Translate(), l?0:10, 20, l?99:80, $"{typeLetter[i]}chanceMoon")));
UI.Add($"{typeLetter[i]}systemDensity",
Options.Add(GSUI.Slider($"{typeDesc[i]} Density".Translate(), 1, 3, 5, $"{typeLetter[i]}systemDensity")));
}
Options.Add(GSUI.Button("Reset".Translate(), "Now".Translate(), Reset));
+ loaded = true;
}
private GSOptionCallback CreateTypeMinPlanetSizeCallback(string type)
@@ -425,6 +452,7 @@ private void MoonChanceCallback(Val o)
private void GasChanceCallback(Val o)
{
+ GS2.Warn("Setting Gas Chance"+ o.String());
SetAllStarTypeOptions("chanceGas", o);
}
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs
index faa6648f..18bfd6da 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs
@@ -1,9 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using UnityEngine;
+using UnityEngine;
using static GalacticScale.GS2;
-using static GalacticScale.RomanNumbers;
namespace GalacticScale.Generators
{
@@ -60,7 +56,7 @@ private int GetStarMoonSize(GSStar star, int hostRadius, bool hostGas)
var range = max - min;
var sd = (float) range / 4;
//int size = Utils.ParsePlanetSize(random.Next(min, max));
- var size = ClampedNormalSize(min, max, GetSizeBiasForStar(star));
+ var size = Mathf.Clamp(ClampedNormalSize(min, max, GetSizeBiasForStar(star)), min, GetMaxPlanetSizeForStar(star));
//if (size > hostRadius)
//{
//Warn($"MoonSize {size} selected for {star.Name} moon with host size {hostRadius} avg:{average} sd:{sd} max:{max} min:{min} range:{range} hostGas:{hostGas}");
@@ -78,7 +74,7 @@ private int GetStarPlanetSize(GSStar star)
private (float min, float max) CalculateHabitableZone(GSStar star)
{
var lum = star.luminosity;
- var (max, min) = Utils.CalculateHabitableZone(lum);
+ var (min, max) = Utils.CalculateHabitableZone(lum);
star.genData.Set("minHZ", min);
star.genData.Set("maxHZ", max);
// GS2.Warn($"HZ of {star.Name} {min}:{max}");
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Themes.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Themes.cs
index 99f42c0a..65af236a 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Themes.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Themes.cs
@@ -64,7 +64,9 @@ public void SetupBaseThemes()
foreach (var s in smolLibrary)
if (!newLibrary.ContainsKey(s.Key)) newLibrary.Add(s.Key, s.Value);
else newLibrary[s.Key] = s.Value;
+ newLibrary.AddRange(GS2.externalThemes);
GS2.ThemeLibrary = GSSettings.ThemeLibrary = newLibrary;
+
}
public static void InitThemes()
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/Json.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/Json.cs
index 7a36942c..0eff6389 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/Json.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/Json.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.IO;
-using UnityEngine.UI;
namespace GalacticScale.Generators
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/Sol/Sol.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/Sol/Sol.cs
index c5eb54cd..0fbbf860 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/Sol/Sol.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/Sol/Sol.cs
@@ -135,7 +135,6 @@ public void Generate(int starCount)
}
GenerateSol(GSSettings.Stars[0]);
- (float min, float max) hz = Utils.CalculateHabitableZone(GSSettings.Stars[0].luminosity);
//GS2.Warn($"Habitable Zone for Star with Luminosity {GSSettings.Stars[0].luminosity} is {hz.min} , {hz.max}");
for (var i = 1; i < starCount; i++)
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs b/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs
index 5f66c7cb..ce7cfbbc 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs
@@ -1,12 +1,99 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using GSSerializer;
+
namespace GalacticScale
{
public static partial class GS2
{
+ public static void LoadExternalThemes(string path)
+ {
+ GS2.Log($"Loading External Themes from: {path}");
+ ThemeLibrary tl = new ThemeLibrary();
+ if (!Directory.Exists(path))
+ {
+ GS2.Warn("External Theme Directory Not Found. Creating");
+ Directory.CreateDirectory(path);
+ return;
+ }
+ var files = Directory.GetFiles(path);
+ //LogJson(files);
+ var directories = Directory.GetDirectories(path);
+ //LogJson(directories);
+ if (files.Length == 0 && directories.Length == 0) return;
+ foreach (var directory in directories)
+ {
+ var DirName = new DirectoryInfo(directory).Name;
+ GS2.Log($"Searching directory:{directory}");
+ if (availableExternalThemes.ContainsKey(DirName))
+ availableExternalThemes[DirName] = LoadDirectoryJsonThemes(directory);
+ else availableExternalThemes.Add(DirName, LoadDirectoryJsonThemes(directory));
+ }
+ foreach (var filename in files)
+ {
+ Log($"Found file:{filename}");
+ Warn(new FileInfo(filename).Extension);
+ if (new FileInfo(filename).Extension != ".json") continue;
+ GSTheme theme = LoadJsonTheme(filename);
+ if (theme != null)
+ {
+ if (tl.ContainsKey(theme.Name)) tl[theme.Name] = theme;
+ else tl.Add(theme.Name, theme);
+ }
+ }
+
+ //LogJson(tl.Keys.ToList());
+ if (availableExternalThemes.ContainsKey("Root"))
+ availableExternalThemes["Root"] = tl;
+ else availableExternalThemes.Add("Root", tl);
+ }
+ public static ThemeLibrary LoadDirectoryJsonThemes(string path)
+ {
+ var tl = new ThemeLibrary();
+ var directories = Directory.GetDirectories(path);
+ var files = Directory.GetFiles(path);
+ foreach (var directory in directories)
+ {
+ var dtl = (LoadDirectoryJsonThemes(directory));
+ tl.AddRange(dtl);
+ }
+ foreach (var file in files)
+ {
+ GSTheme theme = LoadJsonTheme(file);
+ if (theme != null) tl.Add(theme.Name, theme);
+ }
+ return tl;
+ }
+ public static GSTheme LoadJsonTheme(string filename)
+ {
+ Log("Loading JSON Theme " + filename);
+ if (new FileInfo(filename).Extension != ".json")
+ {
+ GS2.Warn($"Non Json File Skipped: {filename}");
+ return null;
+ }
+ var json = File.ReadAllText(filename);
+ var result = new GSTheme();
+ fsData data;
+ var fsresult = fsJsonParser.Parse(json, out data);
+ if (fsresult.Failed)
+ {
+ GS2.Error("Loading of Json Theme " + filename + " failed. "+fsresult.FormattedMessages);
+ return null;
+ }
+ Log("Trying To Deserialize JSON");
+ var serializer = new fsSerializer();
+ var deserializeResult = serializer.TryDeserialize(data, ref result);
+ if (deserializeResult.Failed)
+ {
+ Error("Failed to deserialize "+filename + ": " +deserializeResult.FormattedMessages );
+ return null;
+ }
+ return result;
+ }
public static bool LoadSettingsFromJson(string path)
{
Log("Start");
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/IO/Preferences.cs b/GalacticScale2/Scripts/GalacticScale2.0/IO/Preferences.cs
index 9c769c7c..3427b6f5 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/IO/Preferences.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/IO/Preferences.cs
@@ -37,6 +37,9 @@ public static void SavePreferences()
if (!Directory.Exists(DataDir)) Directory.CreateDirectory(DataDir);
File.WriteAllText(Path.Combine(DataDir, "Preferences.json"), json);
+ GS2.Warn("Reloading External Themes");
+ ThemeLibrary = ThemeLibrary.Vanilla();
+ ExternalThemeProcessor.LoadEnabledThemes();
Log("End");
}
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Init.cs b/GalacticScale2/Scripts/GalacticScale2.0/Init.cs
index a90baa6c..2f1d9de9 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Init.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Init.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Reflection;
using BepInEx;
+using rail;
using UnityEngine;
namespace GalacticScale
@@ -16,7 +17,9 @@ public static partial class GS2
public static bool Failed = false;
public static string updateMessage = "";
public static bool Initialized = false;
+ public static Dictionary availableExternalThemes = new Dictionary();
+ public static ExternalThemeSelector themeSelector;
// public static bool CheatMode = false;
public static bool ResearchUnlocked = false;
@@ -35,6 +38,7 @@ public static partial class GS2
public static Dictionary gsPlanets = new Dictionary();
public static Dictionary gsStars = new Dictionary();
private static AssetBundle _bundle;
+ // public static AssetBundle bundle2;
public static bool IsMenuDemo
{
@@ -77,9 +81,17 @@ public static AssetBundle bundle
}
public static void Init()
-
+
{
-
+ GS2.Warn("Start");
+ // if (bundle2 == null)
+ // {
+ // var path = Path.Combine(AssemblyPath, "themeselector");
+ // if (File.Exists(path)) bundle2 = AssetBundle.LoadFromFile(path);
+ // GS2.Warn(" ");
+ //
+ // GS2.Warn(" ");
+ // }
NebulaCompatibility.Init();
if (Directory.Exists(OldDataDir) && !Directory.Exists(DataDir))
{
@@ -90,7 +102,11 @@ public static void Init()
}
if (!Directory.Exists(DataDir)) Directory.CreateDirectory(DataDir);
Config.Init();
+
LoadPreferences(true);
+ // LoadExternalThemes(Path.Combine(DataDir, "CustomThemes"));
+ // ExternalThemeProcessor.LoadEnabledThemes();
+ //LogJson(availableExternalThemes);
Log("GalacticScale2|Creating List of Themes");
var themes = ThemeLibrary.Select(t => t.Value).ToList();
Log("GalacticScale2|Init|Processing Themes");
@@ -100,9 +116,14 @@ public static void Init()
Log("End");
}
+ public static bool MenuHasLoaded = false;
public static void OnMenuLoaded()
{
-
+ if (MenuHasLoaded) return;
+ MenuHasLoaded = true;
+ GS2.Log("Loading External Themes");
+ LoadExternalThemes(Path.Combine(DataDir, "CustomThemes"));
+ ExternalThemeProcessor.LoadEnabledThemes();
if (Config.Dev) DumpObjectToJson(Path.Combine(DataDir, "ldbthemes.json"), LDB._themes.dataArray);
if (Config.Dev)
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Logging/DebugLogging.cs b/GalacticScale2/Scripts/GalacticScale2.0/Logging/DebugLogging.cs
index 0a8fc809..6c1cfd15 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Logging/DebugLogging.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Logging/DebugLogging.cs
@@ -43,6 +43,14 @@ public static void LogJson(object o, bool force = false)
var json = fsJsonPrinter.PrettyJson(data);
Bootstrap.Debug(GetCaller() + json);
}
+ public static void WarnJson(object o)
+ {
+
+ var serializer = new fsSerializer();
+ serializer.TrySerialize(o, out var data).AssertSuccessWithoutWarnings();
+ var json = fsJsonPrinter.PrettyJson(data);
+ Bootstrap.Debug(GetCaller() + json, LogLevel.Warning, true);
+ }
public static string GetCaller(int depth = 0)
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs
index 68ca1b83..3542a15b 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/GSUI/GSUI.cs
@@ -119,7 +119,7 @@ public Val DefaultValue
private (bool succeeded, int value) GetInt(object o)
{
- GS2.Warn(Label);
+ // GS2.Warn(Label);
if (o is int) return (true, (int) o);
var success = int.TryParse(o.ToString(), out var result);
return (success, result);
@@ -241,7 +241,7 @@ public bool Set(GSSliderConfig cfg)
public bool Set(Val o)
{
- //GS2.Log($"Set called by {GS2.GetCaller()} to set {o} for {label}");
+ // GS2.Log($"Set called by {GS2.GetCaller()} to set {o} for {Label}");
if (RectTransform == null) return false;
switch (Type)
@@ -553,7 +553,7 @@ private GSOptionPostfix CreateDefaultPostfix()
{
return () =>
{
- //GS2.Log($"Creating DefaultPostfix for {label}");
+ // GS2.Warn($"Creating DefaultPostfix for {Label}");
if (Generator is null)
{
@@ -564,10 +564,9 @@ private GSOptionPostfix CreateDefaultPostfix()
var value = Generator.Export().Get(key);
// GS2.Log($"{key} Value:{value} is null?:{value == null}");
- //GS2.Log($"Got");
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;
}
if (value != null)
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/Generator/GSGenPreferences.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/Generator/GSGenPreferences.cs
index c3331ff1..1e984e6d 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Models/Generator/GSGenPreferences.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/Generator/GSGenPreferences.cs
@@ -37,6 +37,27 @@ public double GetDouble(string key, double Default = -1.0)
return ContainsKey(key) ? double.TryParse(this[key], out parsedResult) ? parsedResult : Default : Default;
}
+ internal List StringList(string key, List Default)
+ {
+ if (!ContainsKey(key)) return Default;
+ var fsSerializer = new fsSerializer();
+ List parsedResult = new List();
+ fsResult result = fsJsonParser.Parse(this[key], out fsData data);
+ if (result.Failed)
+ {
+ GS2.Warn("Failed to parse StringList " + key);
+ return Default;
+ }
+ var deserializedResult = fsSerializer.TryDeserialize(data, ref parsedResult);
+ if (deserializedResult.Failed)
+ {
+ GS2.Warn("Failed to deserialize StringList " + key);
+ return Default;
+ }
+ return parsedResult;
+
+ }
+
public bool GetBool(string key, bool Default = false)
{
bool parsedResult;
@@ -45,7 +66,19 @@ public bool GetBool(string key, bool Default = false)
public void Set(string key, object value)
{
- this[key] = value.ToString();
+ if (value.GetType() == typeof(List))
+ {
+ fsSerializer fs = new fsSerializer();
+ var result = fs.TrySerialize(value, out fsData data);
+ if (result.Failed)
+ {
+ GS2.Warn("Failed to Serialize " + key);
+ return;
+ }
+ var stringResult = fsJsonPrinter.CompressedJson(data);
+ this[key] = stringResult;
+ }
+ else this[key] = value.ToString();
}
public string SerializeAndSet(string key, object value)
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/Libraries/ThemeLibrary.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/Libraries/ThemeLibrary.cs
index 1aec91f4..6b4b37d2 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Models/Libraries/ThemeLibrary.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/Libraries/ThemeLibrary.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using GSSerializer;
+using ScenarioRTL;
namespace GalacticScale
{
@@ -24,10 +25,30 @@ public List Habitable
public new GSTheme Add(string name, GSTheme theme)
{
+ GS2.Warn($"Adding {name},{theme == null}");
+ if (theme == null) return null;
+ if (string.IsNullOrEmpty(name)) name = theme.Name??"Hmm";
+ if (ContainsKey(name))
+ {
+ GS2.Warn("Theme already exists. Updating.");
+ this[name] = theme;
+ return theme;
+ }
base.Add(name, theme);
return theme;
}
-
+ public ThemeLibrary AddRange(ThemeLibrary values)
+ {
+ foreach (var theme in values)
+ {
+ if (ContainsKey(theme.Key)) {
+ GS2.Warn("Adding Duplicate Theme " + theme.Key);
+ this[theme.Key] = theme.Value;
+ }
+ else Add(theme.Key, theme.Value);
+ }
+ return this;
+ }
public static ThemeLibrary Vanilla()
{
var t = new ThemeLibrary
@@ -170,6 +191,7 @@ public List QueryThemes(List starTypes, EThemeType type, EThemeH
var q = from theme in this
where types.Contains(theme.Value.ThemeType)
+ where distributes.Contains(theme.Value.Distribute)
where theme.Value.StarTypes.Intersect(starTypes).Count() > 1
where theme.Value.Temperature < temp.max
where theme.Value.Temperature >= temp.min
@@ -187,9 +209,10 @@ where theme.Value.Temperature < temp.max
results.Add(Themes.Mediterranean);
}
- //GS2.Warn($"Selected Themes for EThemeType {type} EThemeHeat {heat} Radius {radius} EThemeDistribute {distribute} Checking against temp.min:Value>={temp.min} temp.max:Value<{temp.max}");
- //GS2.LogJson(results);
+ // GS2.Warn($"Selected Themes for EThemeType {type} EThemeHeat {heat} Radius {radius} EThemeDistribute {distribute} Checking against temp.min:Value>={temp.min} temp.max:Value<{temp.max}");
+ // GS2.WarnJson((from result in results select result.Name).ToList());
return results;
+
}
//public List Desert {
// get {
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/EStar.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/EStar.cs
index f9514dc1..18c58828 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/EStar.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/EStar.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace GalacticScale
+namespace GalacticScale
{
public enum EStar
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/GSStar.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/GSStar.cs
index 634f70c6..e205ab81 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/GSStar.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/Star/GSStar.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using UnityEngine;
namespace GalacticScale
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Models/Themes/ExternalThemes.cs b/GalacticScale2/Scripts/GalacticScale2.0/Models/Themes/ExternalThemes.cs
new file mode 100644
index 00000000..dcd60ca6
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Models/Themes/ExternalThemes.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using GSSerializer;
+using UnityEngine;
+using Object = UnityEngine.Object;
+
+namespace GalacticScale
+{
+ public static partial class GS2
+ {
+ public static ThemeLibrary externalThemes = new ThemeLibrary();
+ public static class ExternalThemeProcessor
+ {
+ public static void LoadEnabledThemes()
+ {
+ GS2.LogJson(Config.ExternalThemeNames);
+ foreach (string name in GS2.Config.ExternalThemeNames)
+ {
+ var fragments = name.Split('|');
+ var group = fragments[0];
+ var item = fragments[1];
+ if (group == "Root")
+ {
+ if (!GS2.availableExternalThemes.ContainsKey("Root"))
+ {
+ GS2.Log("No loose themes loaded!");
+ continue;
+ }
+ ThemeLibrary tl = GS2.availableExternalThemes["Root"];
+ if (tl.ContainsKey(item)) GS2.externalThemes.Add(item, tl[item]);
+ }
+ else if (GS2.availableExternalThemes.ContainsKey(group))
+ {
+ GS2.externalThemes.AddRange(GS2.availableExternalThemes[group]);
+ }
+
+ }
+ GS2.Warn("External Themes:");
+ GS2.LogJson(GS2.externalThemes.Keys.ToList());
+ GS2.Warn("End External Themes");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs
index ff5c0d43..af3c4cbf 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs
@@ -1,7 +1,6 @@
using System;
using HarmonyLib;
using UnityEngine;
-using static GalacticScale.GS2;
namespace GalacticScale
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetGrid/CalcLocalGridSize.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetGrid/CalcLocalGridSize.cs
index 62d4ef4f..a94548b9 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetGrid/CalcLocalGridSize.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetGrid/CalcLocalGridSize.cs
@@ -13,7 +13,7 @@ public static void CalcLocalGridSize(Vector3 posR, Vector3 dir, ref float __resu
if (GS2.Config.FixCopyPaste && GameMain.localPlanet.radius == 490) __result -= 0.15f;
if (GS2.Config.FixCopyPaste && GameMain.localPlanet.radius == 500) __result -= 0.15f;
if (GS2.Config.FixCopyPaste && GameMain.localPlanet.radius == 510) __result -= 0.19f;
- if (GS2.Config.Test) __result += GS2.Config.TestNum;
+ //if (GS2.Config.Test) __result += GS2.Config.TestNum;
}
}
}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain - Copy.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain - Copy.cs
index dde0a98d..178909d0 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain - Copy.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain - Copy.cs
@@ -7,7 +7,7 @@
namespace GalacticScale
{
- public partial class PatchOnPlanetModelingManager : MonoBehaviour
+ public partial class PatchOnPlanetModelingManager
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetMain")]
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain.cs
index b0825df6..d7e149ba 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/PlanetModelingManager/ModelingPlanetMain.cs
@@ -6,7 +6,7 @@
namespace GalacticScale
{
- public partial class PatchOnPlanetModelingManager : MonoBehaviour
+ public partial class PatchOnPlanetModelingManager
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetMain")]
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs
index 350f3f2f..fb3c0dc2 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs
@@ -1,9 +1,7 @@
-using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using HarmonyLib;
-using UnityEngine;
namespace GalacticScale
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/OnStarCountSliderValueChange.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/OnStarCountSliderValueChange.cs
index 20add3f5..64e6beab 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/OnStarCountSliderValueChange.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/OnStarCountSliderValueChange.cs
@@ -5,7 +5,7 @@
namespace GalacticScale
{
- public partial class PatchOnUIGalaxySelect : MonoBehaviour
+ public partial class PatchOnUIGalaxySelect
{
public static Delayer delayer;
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIOptionWindow/_OnOpen.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIOptionWindow/_OnOpen.cs
index 829103ef..1308b0ea 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIOptionWindow/_OnOpen.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIOptionWindow/_OnOpen.cs
@@ -1,4 +1,5 @@
-using HarmonyLib;
+using System.IO;
+using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
@@ -15,12 +16,18 @@ public static void PatchMainMenu(ref UIOptionWindow __instance, ref UIButton[] _
if (overlayCanvas == null || overlayCanvas.transform.Find("Top Windows") == null) return;
var contentGS = GameObject.Find("Option Window/details/GalacticScaleSettings");
+ GS2.LoadExternalThemes(Path.Combine(GS2.DataDir, "CustomThemes"));
+
if (contentGS == null)
{
__instance.applyButton.button.onClick.AddListener(GS2.SavePreferences);
__instance.cancelButton.button.onClick.AddListener(() => { GS2.LoadPreferences(); });
SettingsUI.CreateGalacticScaleSettingsPage(___tabButtons, ___tabTexts);
}
+ else
+ {
+ GS2.RefreshThemeList();
+ }
UIRoot.instance.optionWindow.SetTabIndex(SettingsUI.MainTabIndex, false);
SettingsUI.GalacticScaleTabClick();
}
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIRoot/OnGameBegin.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIRoot/OnGameBegin.cs
index d45cc941..23e2bc58 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIRoot/OnGameBegin.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIRoot/OnGameBegin.cs
@@ -1,6 +1,4 @@
using HarmonyLib;
-using UnityEngine;
-using UnityEngine.UI;
namespace GalacticScale
{
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/CreatePlanet.cs b/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/CreatePlanet.cs
index 26e0e115..c2448d8e 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/CreatePlanet.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/CreatePlanet.cs
@@ -122,7 +122,7 @@ public static PlanetData CreatePlanet(ref StarData star, GSPlanet gsPlanet, Rand
Error($"star.planets length of {star.planets.Length} <= counter {counter}");
star.planets[counter] = planet;
- //DebugPlanet(planetData);
+ // DebugPlanet(planet);
if (GSSettings.Stars.Count <= star.index) Error($"GSSettings.Stars[{star.index}] does not exist");
GSSettings.Stars[star.index].counter++;
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ExternalThemeSelector.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ExternalThemeSelector.cs
new file mode 100644
index 00000000..c1678992
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ExternalThemeSelector.cs
@@ -0,0 +1,149 @@
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class ExternalThemeSelector : MonoBehaviour
+ {
+ // public ThemeLibrary ThemeLibrary = new ThemeLibrary();
+ public RectTransform itemTemplate;
+ public RectTransform groupTemplate;
+ public RectTransform itemList;
+ public Toggle masterToggle;
+ public List items = new List();
+
+ public List groups = new List();
+
+ // Start is called before the first frame update
+ private void Start()
+ {
+ if (GS2.availableExternalThemes.Count == 0)
+ {
+ gameObject.SetActive(false);
+ // GS2.Warn(gameObject.name);
+
+ return;
+ }
+
+ itemTemplate.gameObject.SetActive(false);
+ groupTemplate.gameObject.SetActive(false);
+ // GS2.LogJson(GS2.availableExternalThemes);
+ GS2.themeSelector = this;
+ if (GS2.availableExternalThemes.ContainsKey("Root"))
+ foreach (var t in GS2.availableExternalThemes["Root"])
+ {
+ GS2.Warn($"Adding {t.Key}");
+ var item = Instantiate(itemTemplate, itemList, false);
+ var tsi = item.GetComponent();
+ tsi.label = t.Value.DisplayName;
+ tsi.theme = t.Value;
+ tsi.gameObject.SetActive(true);
+ items.Add(tsi);
+ }
+
+ foreach (var td in GS2.availableExternalThemes)
+ {
+ if (td.Key == "Root") continue;
+ // GS2.Warn($"Adding {td.Key}");
+ var item = Instantiate(groupTemplate, itemList, false);
+ var tsg = item.GetComponent();
+ tsg.label = td.Key;
+ tsg.themes = td.Value;
+ tsg.gameObject.SetActive(true);
+ groups.Add(tsg);
+ }
+
+ var names = GS2.Config.ExternalThemeNames;
+ // var groupNames = new List();
+ // var itemNames = new List();
+ if (names.Count > 0)
+ {
+ masterToggle.isOn = true;
+ GS2.Config.SetUseExternalThemes(true);
+ }
+ else
+ {
+ masterToggle.isOn = false;
+ GS2.Config.SetUseExternalThemes(false);
+
+ }
+
+ foreach (var name in names)
+ {
+ var flag = false;
+ var fragments = name.Split('|');
+ var label = fragments[0];
+ if (fragments[1] != "*") label = fragments[1];
+ foreach (var group in groups)
+ if (group.label == label)
+ {
+ group.Set(true);
+ flag = true;
+ }
+
+ if (flag) continue;
+ foreach (var item in items)
+ if (item.theme.Name == label)
+ item.Set(true);
+ }
+ }
+
+ public void Init()
+ {
+ foreach (var theme in GS2.availableExternalThemes) Debug.Log("Test" + theme.Value);
+ }
+
+ public void CollapseAll()
+ {
+ foreach (var t in items) t.gameObject.SetActive(false);
+ }
+
+ public void ExpandAll()
+ {
+ foreach (var t in items) t.gameObject.SetActive(true);
+ }
+
+ public void CheckAll()
+ {
+ // GS2.Warn("CheckAll");
+ foreach (var t in items) t.Set(true);
+ }
+
+ public void SetAll(bool val)
+ {
+ if (val) CheckAll();
+ else UnCheckAll();
+ }
+
+ public void ToggleAll()
+ {
+ // GS2.Warn("Toggle");
+ if (!masterToggle.isOn) UnCheckAll();
+ else CheckAll();
+ }
+
+ public void UnCheckAll()
+ {
+ // GS2.Warn("Uncheck All");
+ foreach (var t in items) t.Set(false);
+ }
+
+ public List Get()
+ {
+ var output = new List();
+ foreach (var tsi in items)
+ if (tsi.ticked)
+ output.Add("Root|" + tsi.theme.Name);
+ foreach (var tsg in groups) if (tsg.ticked) output.Add(tsg.label + "|*");
+ return output;
+ }
+
+ public void MasterToggleClick()
+ {
+ // Debug.Log("Click");
+ Debug.Log(masterToggle.isOn.ToString());
+ GS2.Config.SetUseExternalThemes(masterToggle.isOn);
+ }
+ }
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs
index bd3e2ccb..899935f8 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using GalacticScale.Generators;
+using GSSerializer;
namespace GalacticScale
{
@@ -15,15 +16,17 @@ public class GS2MainSettings : iConfigurableGenerator
private List _generatorNames;
private GSUI _generatorsCombobox;
public GSGenPreferences Preferences = new GSGenPreferences();
- public bool ForceRare => Preferences.GetBool("Force Rare Spawn", false);
- public bool DebugMode => Preferences.GetBool("Debug Log", false);
- public bool Dev => Preferences.GetBool("Dev", false);
- public bool SkipPrologue => Preferences.GetBool("Skip Prologue", false);
- public bool SkipTutorials => Preferences.GetBool("Skip Tutorials", false);
- public bool CheatMode => Preferences.GetBool("Cheat Mode", false);
- public bool MinifyJson => Preferences.GetBool("Minify JSON", false);
+ public bool ForceRare => Preferences.GetBool("Force Rare Spawn");
+ public bool DebugMode => Preferences.GetBool("Debug Log");
+ public bool Dev => Preferences.GetBool("Dev");
+ public bool SkipPrologue => Preferences.GetBool("Skip Prologue");
+ public bool SkipTutorials => Preferences.GetBool("Skip Tutorials");
+ public bool CheatMode => Preferences.GetBool("Cheat Mode");
+ public bool MinifyJson => Preferences.GetBool("Minify JSON");
public bool FixCopyPaste => Preferences.GetBool("Fix CopyPaste", true);
public string GeneratorID => Preferences.GetString("Generator ID", "space.customizing.generators.vanilla");
+ public bool UseExternalThemes => Preferences.GetBool("Use External Themes");
+ public List ExternalThemeNames => Preferences.StringList("External Themes", new List());
public string Name => "Main Settings";
public string Author => "innominata";
@@ -37,8 +40,8 @@ public class GS2MainSettings : iConfigurableGenerator
public GSGeneratorConfig Config => new GSGeneratorConfig();
public GSOptions Options { get; } = new GSOptions();
- public bool Test => Preferences.GetBool("Test", false);
- public float TestNum => Preferences.GetFloat("TestNum", 0f);
+ //public bool Test => Preferences.GetBool("Test", false);
+ //public float TestNum => Preferences.GetFloat("TestNum", 0f);
public GSGenPreferences Export()
{
@@ -77,13 +80,51 @@ public void Init()
Options.Add(GSUI.Input("Export Filename".Translate(), "My First Custom Galaxy", "Export Filename"));
Options.Add(GSUI.Checkbox("Minify Exported JSON".Translate(), false, "Minify JSON"));
Options.Add(GSUI.Checkbox("(Test) Fix CopyPaste Inserter Length".Translate(), true, "Fix CopyPaste"));
- Options.Add(GSUI.Checkbox("(Test) ", false, "Test"));
- Options.Add(GSUI.Input("Test", "0", "TestNum"));
- // Options.Add(GSUI.Button("Fix 1000s Planet Orbits", "Go", FixOrbits));
+ Options.Add(GSUI.Button("Export All Themes".Translate(), "Export", ExportAllThemes));
+ //Options.Add(GSUI.Checkbox("Adjust Inserter Length ", false, "Test"));
+ //Options.Add(GSUI.Input("Inserter Length Adjust", "0", "TestNum"));
+ //Options.Add(GSUI.Button("Debug ThemeSelector", "Go", FixOrbits));
- _exportButton = Options.Add(GSUI.Button("Export Custom Galaxy".Translate(), "Export".Translate(), ExportJsonGalaxy));
+ _exportButton = Options.Add(GSUI.Button("Export Custom Galaxy".Translate(), "Export".Translate(),
+ ExportJsonGalaxy));
}
+ private void ExportAllThemes(Val o)
+ {
+ if (GameMain.isPaused)
+ {
+ var path = Path.Combine(GS2.DataDir, "ExportedThemes");
+ if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+ foreach (var theme in GSSettings.ThemeLibrary)
+ {
+ var filename = Path.Combine(path, theme.Value.Name + ".json");
+ var fs = new fsSerializer();
+ fs.TrySerialize(theme.Value, out var data);
+ var json = fsJsonPrinter.PrettyJson(data);
+ File.WriteAllText(filename, json);
+
+ }
+ UIMessageBox.Show("Success".Translate(),
+ "Themes have been exported to "
+ .Translate() + path + "/",
+ "D'oh!".Translate(), 2);
+ return;
+ }
+ UIMessageBox.Show("Error".Translate(),
+ "Please try again after creating a galaxy :)\r\nStart a game, then press ESC and click settings."
+ .Translate(),
+ "D'oh!".Translate(), 2);
+ }
+
+
+ //private static void FixOrbits(Val o)
+ //{
+ // var v =GS2.themeSelector.Get();
+ // foreach (var c in v)
+ // {
+ // GS2.Warn($"::{c}");
+ // }
+ //}
// private static void FixOrbits(Val o)
// {
// if (GS2.Vanilla || GS2.IsMenuDemo) return;
@@ -139,5 +180,18 @@ public void DisableCheatMode()
{
_cheatModeCheckbox.Set(false);
}
+
+ public void SetExternalThemes(ExternalThemeSelector e)
+ {
+ GS2.Warn("Setting External Themes");
+ GS2.WarnJson(e.Get());
+ var themeNames = e.Get();
+ Preferences.Set("External Themes", themeNames);
+ }
+
+ public void SetUseExternalThemes(bool val)
+ {
+ Preferences.Set("Use External Themes", val);
+ }
}
}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIBtn.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIBtn.cs
new file mode 100644
index 00000000..2d13b748
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIBtn.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUIBtn : MonoBehaviour
+ {
+ public Button _button;
+ public GSOptionCallback OnClick;
+ public GSUITemplates templates;
+ public Text _labelText;
+ public Text _hintText;
+ public Text _buttonText;
+ public string Hint
+ {
+ get => _hintText.text;
+ set => _hintText.text = value;
+ }
+ public string Label
+ {
+ get => _labelText.text;
+ set => _labelText.text = value;
+ }
+
+ public string Caption
+ {
+ get => _buttonText.text;
+ set => _buttonText.text = value;
+ }
+ public void OnButtonClick()
+ {
+ if (OnClick != null) OnClick.Invoke(null);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIDropdown.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIDropdown.cs
new file mode 100644
index 00000000..12ab28ba
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIDropdown.cs
@@ -0,0 +1,57 @@
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUIDropdown : MonoBehaviour
+ {
+ public Dropdown _dropdown;
+
+ public GSOptionCallback OnChange;
+ public Text _labelText;
+ public Text _hintText;
+ public List Items
+ {
+ get=> _dropdown.options.Select((option)=>option.text).ToList();
+ set => _dropdown.options = value.Select((s) => new Dropdown.OptionData() {text = s}).ToList();
+ }
+ public string Hint
+ {
+ get => _hintText.text;
+ set => _hintText.text = value;
+ }
+ public string Label
+ {
+ get => _labelText.text;
+ set => _labelText.text = value;
+ }
+ public string Value
+ {
+ get
+ {
+ if (Items.Count < 1 || Items.Count >= _dropdown.value)
+ {
+ GS2.Warn($"Index out of bounds: {Label} {_dropdown.value}");
+ return null;
+ }
+ return Items[_dropdown.value];
+ }
+ set => _dropdown.value = Items.IndexOf(value);
+ }
+
+ public void OnValueChange(int value)
+ {
+ if (Items.Count < 1 || Items.Count >= value)
+ {
+ GS2.Warn($"Index out of bounds: {Label} {value}");
+ return;
+ }
+ Value = Items[value];
+ OnChange?.Invoke(Items[value]);
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIInput.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIInput.cs
new file mode 100644
index 00000000..b887c3d1
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIInput.cs
@@ -0,0 +1,45 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUIInput : MonoBehaviour
+ {
+ public Input input;
+
+ public GSOptionCallback OnChange;
+ public GSOptionCallback OnEndEdit;
+ public InputField _input;
+ public Text _textText;
+ public Text _labelText;
+ public Text _hintText;
+ public string Hint
+ {
+ get => _hintText.text;
+ set => _hintText.text = value;
+ }
+ public string Label
+ {
+ get => _labelText.text;
+ set => _labelText.text = value;
+ }
+ public string Value
+ {
+ get => _textText.text;
+ set => _textText.text = value;
+ }
+
+ public void OnInputChange(string value)
+ {
+ Value = value;
+ OnChange?.Invoke(value);
+ }
+
+ public void OnInputEndEdit(string value)
+ {
+ Value = value;
+ OnEndEdit?.Invoke(value);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIList.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIList.cs
new file mode 100644
index 00000000..194b4a25
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIList.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUIList : MonoBehaviour
+ {
+ public GameObject List;
+ public List Contents;
+ public GameObject ListHeading;
+ public GameObject ListCollapseButton;
+ public GameObject ListExpandButton;
+ public GameObject ListContents;
+ public GSUITemplates templates;
+ public bool Collapsible = false;
+ public bool ShowHeader = true;
+ public Text _labelText;
+ public Text _hintText;
+ public string Hint
+ {
+ get => _hintText.text;
+ set => _hintText.text = value;
+ }
+ public string Label
+ {
+ get => _labelText.text;
+ set => _labelText.text = value;
+ }
+ public GameObject AddItem(GSUITemplate template)
+ {
+ var newItem = Instantiate(template.gameObject, ListContents.transform, false);
+ Contents.Add(newItem);
+ return newItem;
+ }
+
+ public void Start()
+ {
+ if (!ShowHeader)
+ {
+ Collapsible = false;
+ ListHeading.SetActive(false);
+ }
+ if (!Collapsible)
+ {
+ ListExpandButton.SetActive(false);
+ ListCollapseButton.SetActive(false);
+ ListContents.SetActive(true);
+ }
+
+
+ }
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIPanel.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIPanel.cs
new file mode 100644
index 00000000..6fcaa4ab
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIPanel.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUIPanel : MonoBehaviour
+ {
+ public GSUIList contents;
+ public GSUITemplates templates;
+ public GameObject Add(GSUITemplate template)
+ {
+ return contents.AddItem(template);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIRangeSlider.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIRangeSlider.cs
new file mode 100644
index 00000000..724a9e7c
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIRangeSlider.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+
+using UnityEngine;
+using UnityEngine.UI;
+using UnityEngine.UI.Extensions;
+
+namespace GalacticScale
+{
+ public class GSUIRangeSlider : MonoBehaviour
+ {
+ public float minValue
+ {
+ get => _slider.MinValue;
+ set => _slider.MinValue = value;
+ }
+ public float maxValue
+ {
+ get => _slider.MaxValue;
+ set => _slider.MaxValue = value;
+ }
+ public GSOptionCallback OnLowChange;
+ public GSOptionCallback OnHighChange;
+ public RangeSlider _slider;
+ public Text _labelText;
+ public Text _hintText;
+ public string Hint
+ {
+ get => _hintText.text;
+ set => _hintText.text = value;
+ }
+ public string Label
+ {
+ get => _labelText.text;
+ set => _labelText.text = value;
+ }
+ public float LowValue
+ {
+ get => _slider.LowValue;
+ set => _slider.LowValue = value;
+ }
+ public float HighValue
+ {
+ get => _slider.HighValue;
+ set => _slider.HighValue = value;
+ }
+ public bool WholeNumbers
+ {
+ get => _slider.WholeNumbers;
+ set => _slider.WholeNumbers = value;
+ }
+
+ public Text _lowValueText;
+ public Text _highValueText;
+ public void OnSliderValueChange(RangeSlider slider)
+ {
+ // float lowValue = (int)(slider.LowValue * 100) / 100f;
+ // float highValue = (int)(slider.LowValue * 100) / 100f;
+ // _lowValueText.text = lowValue.ToString();
+ // _highValueText.text = highValue.ToString();
+ // if (LowValue != lowValue)
+ // {
+ // LowValue = lowValue;
+ // if (OnLowChange != null) OnLowChange.Invoke(lowValue);
+ // }
+ //
+ // if (HighValue != highValue)
+ // {
+ // HighValue = highValue;
+ // if (OnHighChange != null) OnHighChange.Invoke(highValue);
+ // }
+ //
+ }
+
+ public void Test(float a, float b)
+ {
+
+ }
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUISlider.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUISlider.cs
new file mode 100644
index 00000000..c3bd168b
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUISlider.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUISlider : MonoBehaviour
+ {
+ public GSOptionCallback OnChange;
+ public Slider _slider;
+ public Text _labelText;
+ public Text _hintText;
+ public float Value
+ {
+ get => _slider.value;
+ set => _slider.value = value;
+ }
+ public string Hint
+ {
+ get => _hintText.text;
+ set => _hintText.text = value;
+ }
+ public string Label
+ {
+ get => _labelText.text;
+ set => _labelText.text = value;
+ }
+ public float minValue
+ {
+ get => _slider.minValue;
+ set => _slider.minValue = value;
+ }
+ public float maxValue
+ {
+ get => _slider.maxValue;
+ set => _slider.maxValue = value;
+ }
+ public Text _valueText;
+
+ public void OnSliderValueChange(Slider slider)
+ {
+ float value = (int)(slider.value * 100) / 100f;
+ _valueText.text = value.ToString();
+ OnChange?.Invoke(value);
+ }
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUITemplate.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUITemplate.cs
new file mode 100644
index 00000000..cb9d9705
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUITemplate.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUITemplate : MonoBehaviour
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUITemplates.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUITemplates.cs
new file mode 100644
index 00000000..8bd4be5f
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUITemplates.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUITemplates : MonoBehaviour
+ {
+ public GSUITemplate list;
+ public GSUITemplate button;
+ public GSUITemplate minmax;
+ public GSUITemplate slider;
+ public GSUITemplate combo;
+ public GSUITemplate header;
+ public GSUITemplate spacer;
+ public GSUITemplate toggle;
+
+ }
+
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIToggle.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIToggle.cs
new file mode 100644
index 00000000..e8321b72
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MonoBehaviors/GSUIToggle.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using Steamworks;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class GSUIToggle : MonoBehaviour
+ {
+
+ public Toggle _Toggle;
+ public Text _labelText;
+ public Text _hintText;
+ public string Hint
+ {
+ get => _hintText.text;
+ set => _hintText.text = value;
+ }
+ public string Label
+ {
+ get => _labelText.text;
+ set => _labelText.text = value;
+ }
+ public bool Value
+ {
+ get => _Toggle.isOn;
+ set => _Toggle.isOn = value;
+ }
+
+ public GSOptionCallback OnChange;
+
+ public void _OnToggleChange(bool value)
+ {
+ Value = value;
+ OnChange?.Invoke(value);
+ }
+ }
+
+}
\ 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 ef4912be..9aeb6d85 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/SettingsUI.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/SettingsUI.cs
@@ -30,7 +30,7 @@ public static class SettingsUI
private static UIButton[] tabButtons;
private static Text[] tabTexts;
public static RectTransform seedInput;
- private static RectTransform details;
+ public static RectTransform details;
private static RectTransform scrollview;
private static RectTransform templateOptionsCanvas;
private static RectTransform templateUIComboBox;
@@ -42,6 +42,7 @@ 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;
public static int GeneratorIndex;
@@ -201,6 +202,7 @@ public static void CreateGalacticScaleSettingsPage(UIButton[] _tabButtons, Text[
//UI Root/Overlay Canvas/Top Windows/Option Window/details/GalacticScaleSettings/scroll-view/viewport
UpdateContentRect();
//viewportRect.sizeDelta = this.keyScrollVbarRect.gameObject.activeSelf ? new Vector2(-10f, 0.0f) : Vector2.zero;
+
}
//private static RectTransform CreateCollapseBox()
@@ -333,6 +335,11 @@ private static void CreateOptionsUI()
}
}
+ var go = GS2.bundle.LoadAsset("ThemeSelector");
+ themeselector = Object.Instantiate(go, details, false);
+ var tsRect = themeselector.GetComponent();
+ var offset = options.Count * -40;
+ tsRect.anchoredPosition = new Vector2(tsRect.anchoredPosition.x,tsRect.anchoredPosition.x+ offset);
var currentGenIndex = GS2.GetCurrentGeneratorIndex();
//GS2.Log("CreateGeneratorOptionsCanvases: currentGenIndex = " + currentGenIndex + " - " + GS2.generators[currentGenIndex].Name);
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectGroup.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectGroup.cs
new file mode 100644
index 00000000..e1b847dd
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectGroup.cs
@@ -0,0 +1,34 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class ThemeSelectGroup : MonoBehaviour
+ {
+ public Text text;
+ public Toggle toggle;
+ public string label = "Template";
+ public ExternalThemeSelector themeSelector;
+
+ // [NonSerialized]
+ public ThemeLibrary themes;
+ // Start is called before the first frame update
+ void Start()
+ {
+ text.text = label;
+ }
+
+ public void Set(bool value)
+ {
+ toggle.isOn = value;
+ }
+
+ public bool ticked => toggle.isOn;
+
+ public void Click()
+ {
+ if (!themeSelector.masterToggle.isOn && toggle.isOn) themeSelector.masterToggle.isOn = true;
+ GS2.Config.SetExternalThemes(themeSelector);
+ }
+ }
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectItem.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectItem.cs
new file mode 100644
index 00000000..f4ee98b0
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectItem.cs
@@ -0,0 +1,34 @@
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace GalacticScale
+{
+ public class ThemeSelectItem : MonoBehaviour
+ {
+ public Text text;
+ public Toggle toggle;
+ public string label = "Template";
+
+ public ExternalThemeSelector themeSelector;
+ // [NonSerialized]
+ public GSTheme theme;
+ // Start is called before the first frame update
+ void Start()
+ {
+ text.text = label;
+ }
+
+ public void Set(bool value)
+ {
+ toggle.isOn = value;
+ }
+
+ public bool ticked => toggle.isOn;
+
+ public void Click()
+ {
+ if (!themeSelector.masterToggle.isOn && toggle.isOn) themeSelector.masterToggle.isOn = true;
+ GS2.Config.SetExternalThemes(themeSelector);
+ }
+ }
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectorUI.cs b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectorUI.cs
new file mode 100644
index 00000000..5dd0c5ca
--- /dev/null
+++ b/GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/ThemeSelectorUI.cs
@@ -0,0 +1,22 @@
+using UnityEngine;
+
+namespace GalacticScale
+{
+ public static partial class GS2
+ {
+ public static void RefreshThemeList()
+ {
+ var details = SettingsUI.details;
+ ref var themeselector = ref SettingsUI.themeselector;
+ if (details != null && themeselector != null)
+ {
+ var y = themeselector.GetComponent().anchoredPosition.y;
+ Object.DestroyImmediate(themeselector);
+ var go = GS2.bundle.LoadAsset("ThemeSelector");
+ themeselector = Object.Instantiate(go, details, false);
+ var rt = themeselector.GetComponent();
+ rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, y);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs b/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs
index 394dbc4d..a592aacb 100644
--- a/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs
+++ b/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs
@@ -100,9 +100,9 @@ public static float CalculateOrbitPeriodFromStarMass(float orbitRadius, float ma
return (float) (36000 * periodFactor);
}
- public static (float, float) CalculateHabitableZone(float luminosity)
+ public static (float min, float max) CalculateHabitableZone(float luminosity)
{
- return ((float) Math.Sqrt(luminosity / 0.53), (float) Math.Sqrt(luminosity / 1.1));
+ return ((float) Math.Sqrt(luminosity / 1.1), (float) Math.Sqrt(luminosity / 0.53));
}
public static Type GetCallingType()