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()); }
/// <summary> /// Handles a ctrl click on one of the thumbs to open a direct input window. /// </summary> private bool HandleClickOnThumb() { if (!MyInput.Static.IsAnyCtrlKeyPressed() || !MyInput.Static.IsNewPrimaryButtonPressed()) { return(false); } double min = 0; double max = 0; double current = 0; MyGuiSliderThumb clickedThumb = null; if (m_minThumb.IsHighlighted() || m_minThumb.IsFocused()) { min = m_minValue; max = m_maxThumb.CurrentValue; current = m_minThumb.CurrentValue; clickedThumb = m_minThumb; } if (m_maxThumb.IsHighlighted() || m_maxThumb.IsFocused()) { min = m_minThumb.CurrentValue; max = m_maxValue; current = m_maxThumb.CurrentValue; clickedThumb = m_maxThumb; } if (clickedThumb == null) { return(false); } MyGuiScreenDialogAmount dialog = new MyGuiScreenDialogAmount((float)min, (float)max, MyCommonTexts.DialogAmount_SetValueCaption, parseAsInteger: m_intMode, defaultAmount: (float)current, backgroundTransition: MySandboxGame.Config.UIBkOpacity, guiTransition: MySandboxGame.Config.UIOpacity); dialog.OnConfirmed += delegate(float value) { clickedThumb.CurrentValue = value; RefreshInternals(); }; MyGuiSandbox.AddScreen(dialog); return(true); }
private void ShowAmountTransferDialog(MyPhysicalInventoryItem inventoryItem, Action<float> onConfirmed) { var amount = inventoryItem.Amount; var obType = inventoryItem.Content.TypeId; int maxDecimalDigits = 0; bool asInteger = true; if (obType == typeof(MyObjectBuilder_Ore) || obType == typeof(MyObjectBuilder_Ingot)) { maxDecimalDigits = MyInventoryConstants.GUI_DISPLAY_MAX_DECIMALS; asInteger = false; } var dialog = new MyGuiScreenDialogAmount(0, (float)amount, MyCommonTexts.DialogAmount_AddAmountCaption, minMaxDecimalDigits: maxDecimalDigits, parseAsInteger: asInteger); dialog.OnConfirmed += onConfirmed; MyGuiSandbox.AddScreen(dialog); }
private static bool OnAntennaSliderClicked(MyGuiControlSlider arg) { if (MyInput.Static.IsAnyCtrlKeyPressed()) { float min = MyHudMarkerRender.Denormalize(0); float max = MyHudMarkerRender.Denormalize(1); float val = MyHudMarkerRender.Denormalize(arg.Value); bool parseAsInteger = true; if (parseAsInteger && System.Math.Abs(min) < 1.0f) // This allows the user to enter 0 as input min = 0; // TODO: allocations, needs GUI redo MyGuiScreenDialogAmount dialog = new MyGuiScreenDialogAmount(min, max, parseAsInteger: parseAsInteger, defaultAmount: val, caption: MyCommonTexts.DialogAmount_SetValueCaption); dialog.OnConfirmed += (v) => { arg.Value = MyHudMarkerRender.Normalize(v); }; MyGuiSandbox.AddScreen(dialog); return true; } return false; }