diff --git a/SEWorldGenPlugin/GUI/Controls/MyGuiControlClickableSlider.cs b/SEWorldGenPlugin/GUI/Controls/MyGuiControlClickableSlider.cs new file mode 100644 index 0000000..72b7384 --- /dev/null +++ b/SEWorldGenPlugin/GUI/Controls/MyGuiControlClickableSlider.cs @@ -0,0 +1,35 @@ +using Sandbox; +using Sandbox.Graphics.GUI; +using VRage.Input; +using VRage.Utils; +using VRageMath; + +namespace SEWorldGenPlugin.GUI.Controls +{ + public class MyGuiControlClickableSlider : MyGuiControlSlider + { + public MyGuiControlClickableSlider(Vector2? position = null, float minValue = 0f, float maxValue = 1f, float width = 0.29f, float? defaultValue = null, Vector4? color = null, string labelText = null, int labelDecimalPlaces = 1, float labelScale = 0.8f, float labelSpaceWidth = 0f, string labelFont = "White", string toolTip = null, MyGuiControlSliderStyleEnum visualStyle = MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum originAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, bool intValue = false, bool showLabel = false) + : base(position, minValue, maxValue, width, defaultValue, color, labelText, labelDecimalPlaces, labelScale, labelSpaceWidth, labelFont, toolTip, visualStyle, originAlign, intValue, showLabel) + { + + } + + protected override bool OnSliderClicked() + { + if (MyInput.Static.IsAnyCtrlKeyPressed()) + { + MyGuiScreenDialogAmount dialog = new MyGuiScreenDialogAmount(this.MinValue, this.MaxValue, MyCommonTexts.DialogAmount_SetValueCaption, parseAsInteger: IntValue, defaultAmount: Value, backgroundTransition: MySandboxGame.Config.UIBkOpacity, guiTransition: MySandboxGame.Config.UIOpacity); + dialog.OnConfirmed += m_confirmValue; + MyGuiSandbox.AddScreen(dialog); + return true; + } + return base.OnSliderClicked(); + } + + private void m_confirmValue(float value) + { + Value = value; + ValueChanged(this); + } + } +} diff --git a/SEWorldGenPlugin/GUI/PluginAdminMenu.cs b/SEWorldGenPlugin/GUI/PluginAdminMenu.cs index 15ea227..981290d 100644 --- a/SEWorldGenPlugin/GUI/PluginAdminMenu.cs +++ b/SEWorldGenPlugin/GUI/PluginAdminMenu.cs @@ -9,6 +9,7 @@ using Sandbox.Graphics.GUI; using SEWorldGenPlugin.Generator; using SEWorldGenPlugin.Generator.Asteroids; +using SEWorldGenPlugin.GUI.Controls; using SEWorldGenPlugin.ObjectBuilders; using SEWorldGenPlugin.Session; using SEWorldGenPlugin.Utilities; @@ -42,12 +43,12 @@ public class PluginAdminMenu : MyGuiScreenAdminMenu private MyGuiControlLabel m_ringRoidSizeValue; private MyGuiControlLabel m_ringWidthValue; - private MyGuiControlSlider m_ringDistanceSlider; - private MyGuiControlSlider m_ringAngleXSlider; - private MyGuiControlSlider m_ringAngleYSlider; - private MyGuiControlSlider m_ringAngleZSlider; - private MyGuiControlSlider m_ringRoidSizeSlider; - private MyGuiControlSlider m_ringWidthSlider; + private MyGuiControlClickableSlider m_ringDistanceSlider; + private MyGuiControlClickableSlider m_ringAngleXSlider; + private MyGuiControlClickableSlider m_ringAngleYSlider; + private MyGuiControlClickableSlider m_ringAngleZSlider; + private MyGuiControlClickableSlider m_ringRoidSizeSlider; + private MyGuiControlClickableSlider m_ringWidthSlider; private MyGuiControlButton m_addRingButton; private MyGuiControlButton m_removeRingButton; @@ -59,7 +60,7 @@ public class PluginAdminMenu : MyGuiScreenAdminMenu //Elements for Planet Menu private MyGuiControlListbox m_planetDefListBox; private MyGuiControlLabel m_planetSizeValue; - private MyGuiControlSlider m_planetSizeSlider; + private MyGuiControlClickableSlider m_planetSizeSlider; private MyGuiControlButton m_spawnPlanetButton; private MyPlanetGeneratorDefinition m_selectedDefinition; @@ -223,7 +224,7 @@ private void BuildPlanetMenu() m_currentPosition.Y += 0.025f; - m_planetSizeSlider = new MyGuiControlSlider(m_currentPosition + new Vector2(0.001f, 0f), 120f, 2400f, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_PLANET_SIZE); + m_planetSizeSlider = new MyGuiControlClickableSlider(m_currentPosition + new Vector2(0.001f, 0f), 120f, 2400f, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_PLANET_SIZE); m_planetSizeSlider.Size = new Vector2(0.285f, 1f); m_planetSizeSlider.DefaultValue = 1200f; m_planetSizeSlider.Value = m_planetSizeSlider.DefaultValue.Value; @@ -325,7 +326,7 @@ private void BuildRingMenu() vector.Y += 0.025f; - m_ringDistanceSlider = new MyGuiControlSlider(vector + new Vector2(0.001f, 0f), 5000f, 1000000f, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_DISTANCE, showLabel: false);//Make dynamic + m_ringDistanceSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), 5000f, 1000000f, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_DISTANCE, showLabel: false);//Make dynamic m_ringDistanceSlider.Size = new Vector2(0.285f, 1f); m_ringDistanceSlider.DefaultValue = 100000; m_ringDistanceSlider.Value = m_ringDistanceSlider.DefaultValue.Value; @@ -359,7 +360,7 @@ private void BuildRingMenu() vector.Y += 0.025f; - m_ringWidthSlider = new MyGuiControlSlider(vector + new Vector2(0.001f, 0f), SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MinPlanetRingWidth, SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MaxPlanetRingWidth, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_WIDTH, showLabel: false); + m_ringWidthSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MinPlanetRingWidth, SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MaxPlanetRingWidth, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_WIDTH, showLabel: false); m_ringWidthSlider.Size = new Vector2(0.285f, 1f); m_ringWidthSlider.DefaultValue = (SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MinPlanetRingWidth + SettingsSession.Static.Settings.GeneratorSettings.PlanetSettings.RingSettings.MaxPlanetRingWidth) / 2; m_ringWidthSlider.Value = m_ringWidthSlider.DefaultValue.Value; @@ -393,7 +394,7 @@ private void BuildRingMenu() vector.Y += 0.025f; - m_ringAngleXSlider = new MyGuiControlSlider(vector + new Vector2(0.001f, 0f), -45, 45, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); + m_ringAngleXSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), -45, 45, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); m_ringAngleXSlider.Size = new Vector2(0.285f, 1f); m_ringAngleXSlider.DefaultValue = 0; m_ringAngleXSlider.Value = m_ringAngleXSlider.DefaultValue.Value; @@ -427,7 +428,7 @@ private void BuildRingMenu() vector.Y += 0.025f; - m_ringAngleYSlider = new MyGuiControlSlider(vector + new Vector2(0.001f, 0f), -45, 45, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); + m_ringAngleYSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), -45, 45, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); m_ringAngleYSlider.Size = new Vector2(0.285f, 1f); m_ringAngleYSlider.DefaultValue = 0; m_ringAngleYSlider.Value = m_ringAngleYSlider.DefaultValue.Value; @@ -461,7 +462,7 @@ private void BuildRingMenu() vector.Y += 0.025f; - m_ringAngleZSlider = new MyGuiControlSlider(vector + new Vector2(0.001f, 0f), -45, 45, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); + m_ringAngleZSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), -45, 45, intValue: false, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ANGLE); m_ringAngleZSlider.Size = new Vector2(0.285f, 1f); m_ringAngleZSlider.DefaultValue = 0; m_ringAngleZSlider.Value = m_ringAngleZSlider.DefaultValue.Value; @@ -495,7 +496,7 @@ private void BuildRingMenu() vector.Y += 0.025f; - m_ringRoidSizeSlider = new MyGuiControlSlider(vector + new Vector2(0.001f, 0f), 128, 1028, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ROID_SIZE); + m_ringRoidSizeSlider = new MyGuiControlClickableSlider(vector + new Vector2(0.001f, 0f), 128, 1028, intValue: true, toolTip: MyPluginTexts.TOOLTIPS.ADMIN_RING_ROID_SIZE); m_ringRoidSizeSlider.Size = new Vector2(0.285f, 1f); m_ringRoidSizeSlider.DefaultValue = 500; m_ringRoidSizeSlider.Value = m_ringRoidSizeSlider.DefaultValue.Value; @@ -530,6 +531,16 @@ private void BuildRingMenu() Controls.Add(m_planetListBox); + m_ringAngleXSlider.Enabled = false; + m_ringAngleYSlider.Enabled = false; + m_ringAngleZSlider.Enabled = false; + m_ringDistanceSlider.Enabled = false; + m_ringWidthSlider.Enabled = false; + m_ringRoidSizeSlider.Enabled = false; + m_addRingButton.Enabled = false; + m_removeRingButton.Enabled = false; + m_teleportToRingButton.Enabled = false; + LoadPlanetsInWorld(); } diff --git a/SEWorldGenPlugin/GUI/PluginSettingsGui.cs b/SEWorldGenPlugin/GUI/PluginSettingsGui.cs index cb50d24..c1105d6 100644 --- a/SEWorldGenPlugin/GUI/PluginSettingsGui.cs +++ b/SEWorldGenPlugin/GUI/PluginSettingsGui.cs @@ -1,6 +1,7 @@ using Sandbox; using Sandbox.Game.Localization; using Sandbox.Graphics.GUI; +using SEWorldGenPlugin.GUI.Controls; using SEWorldGenPlugin.ObjectBuilders; using SEWorldGenPlugin.Utilities; using System; @@ -43,16 +44,16 @@ public class PluginSettingsGui : MyGuiScreenBase private MyGuiControlCheckbox m_moonGpsCheck; private MyGuiControlCheckbox m_beltGpsCheck; private MyGuiControlCombobox m_asteroidGeneratorCombo; - private MyGuiControlSlider m_asteroidDensitySlider; - private MyGuiControlSlider m_objAmountSlider; - private MyGuiControlSlider m_orbDistanceSlider; - private MyGuiControlSlider m_sizeMultiplierSlider; - private MyGuiControlSlider m_sizeCapSlider; - private MyGuiControlSlider m_moonProbSlider; - private MyGuiControlSlider m_ringWidthSlider; - private MyGuiControlSlider m_ringProbSlider; - private MyGuiControlSlider m_beltHeightSlider; - private MyGuiControlSlider m_beltProbSlider; + private MyGuiControlClickableSlider m_asteroidDensitySlider; + private MyGuiControlClickableSlider m_objAmountSlider; + private MyGuiControlClickableSlider m_orbDistanceSlider; + private MyGuiControlClickableSlider m_sizeMultiplierSlider; + private MyGuiControlClickableSlider m_sizeCapSlider; + private MyGuiControlClickableSlider m_moonProbSlider; + private MyGuiControlClickableSlider m_ringWidthSlider; + private MyGuiControlClickableSlider m_ringProbSlider; + private MyGuiControlClickableSlider m_beltHeightSlider; + private MyGuiControlClickableSlider m_beltProbSlider; private MyGuiControlButton m_okButton; @@ -119,16 +120,16 @@ public void BuildControls() m_beltGpsCheck = new MyGuiControlCheckbox(); m_asteroidGeneratorCombo = new MyGuiControlCombobox(null, new Vector2(x2, 0.04f)); x2 += 0.05f; - m_asteroidDensitySlider = new MyGuiControlSlider(Vector2.Zero, 0.1f, 1f, x2, 0.6f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ROID_DENS_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); - m_objAmountSlider = new MyGuiControlSlider(Vector2.Zero, 0f, 100f, x2, 15f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SYS_OBJ_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); - m_orbDistanceSlider = new MyGuiControlSlider(Vector2.Zero, 500f, 100000f, x2, 50500f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ORB_DIST_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); - m_sizeMultiplierSlider = new MyGuiControlSlider(Vector2.Zero, 1f, 10f, x2, 2f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_MUL_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); - m_sizeCapSlider = new MyGuiControlSlider(Vector2.Zero, 120f, 2400f, x2, 1200f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_CAP_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); - m_moonProbSlider = new MyGuiControlSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.MOON_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); - m_ringWidthSlider = new MyGuiControlSlider(Vector2.Zero, 10000f, 100000f, x2, 15000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_WIDTH_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); - m_ringProbSlider = new MyGuiControlSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); - m_beltHeightSlider = new MyGuiControlSlider(Vector2.Zero, 4000f, 40000f, x2, 22000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_HEIGHT_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); - m_beltProbSlider = new MyGuiControlSlider(Vector2.Zero, 0f, 1f, x2, 0.4f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); + m_asteroidDensitySlider = new MyGuiControlClickableSlider(Vector2.Zero, 0.1f, 1f, x2, 0.6f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ROID_DENS_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); + m_objAmountSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 100f, x2, 15f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SYS_OBJ_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); + m_orbDistanceSlider = new MyGuiControlClickableSlider(Vector2.Zero, 500f, 100000f, x2, 50500f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.ORB_DIST_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); + m_sizeMultiplierSlider = new MyGuiControlClickableSlider(Vector2.Zero, 1f, 10f, x2, 2f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_MUL_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); + m_sizeCapSlider = new MyGuiControlClickableSlider(Vector2.Zero, 120f, 2400f, x2, 1200f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.SIZE_CAP_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); + m_moonProbSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.MOON_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); + m_ringWidthSlider = new MyGuiControlClickableSlider(Vector2.Zero, 10000f, 100000f, x2, 15000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_WIDTH_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); + m_ringProbSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.5f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.RING_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); + m_beltHeightSlider = new MyGuiControlClickableSlider(Vector2.Zero, 4000f, 40000f, x2, 22000f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_HEIGHT_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: true); + m_beltProbSlider = new MyGuiControlClickableSlider(Vector2.Zero, 0f, 1f, x2, 0.4f, null, null, 0, 0.8f, 0.05f, "White", MyPluginTexts.TOOLTIPS.BELT_PROB_SLIDER, MyGuiControlSliderStyleEnum.Default, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, intValue: false); m_asteroidDensityValue = MakeLabel(String.Format("{0:0.00}", m_asteroidDensitySlider.Value)); m_asteroidDensityValue.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; diff --git a/SEWorldGenPlugin/SEWorldGenPlugin.csproj b/SEWorldGenPlugin/SEWorldGenPlugin.csproj index b4a9cdb..d5555c4 100644 --- a/SEWorldGenPlugin/SEWorldGenPlugin.csproj +++ b/SEWorldGenPlugin/SEWorldGenPlugin.csproj @@ -197,6 +197,7 @@ + diff --git a/SEWorldGenPlugin/Utilities/MyPluginTexts.cs b/SEWorldGenPlugin/Utilities/MyPluginTexts.cs index c08800c..4435696 100644 --- a/SEWorldGenPlugin/Utilities/MyPluginTexts.cs +++ b/SEWorldGenPlugin/Utilities/MyPluginTexts.cs @@ -30,7 +30,7 @@ public class ToolTips public readonly string ADMIN_RING_DISTANCE = "The distance of the ring to the planet in meters"; public readonly string ADMIN_RING_WIDTH = "The width of the ring in meters"; - public readonly string ADMIN_RING_ANGLE = "The angle of the ring in degrees"; + public readonly string ADMIN_RING_ANGLE = "The angle of the ring around the wanted axis in degrees"; public readonly string ADMIN_RING_ROID_SIZE = "The size of the asteroids in the ring in meters"; public readonly string ADMIN_ADD_RING_BUTTON = "Adds the ring to the planet"; public readonly string ADMIN_REMOVE_RING_BUTTON = "Removes the ring from the planet. All previously generated Asteroids will stay.";