-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As requested in #17, all control sliders that are associated with the…
… plugin can now be clicked while holding control, to be able to enter a number rather than using the slider.
- Loading branch information
Showing
5 changed files
with
83 additions
and
35 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
SEWorldGenPlugin/GUI/Controls/MyGuiControlClickableSlider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters