public MyGuiScreenTriggerLives(MyTrigger trg) : base(trg, new Vector2(WINSIZEX + 0.1f, WINSIZEY)) { float left = m_textboxMessage.Position.X-m_textboxMessage.Size.X/2; float top = -WINSIZEY / 2f + MIDDLE_PART_ORIGIN.Y; m_labelLives = new MyGuiControlLabel( originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top), size: new Vector2(0.01f, 0.035f), text: MyTexts.Get(MySpaceTexts.GuiTriggersLives).ToString() ); left += m_labelLives.Size.X + spacingH; m_lives = new MyGuiControlTextbox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2((WINSIZEX - spacingH) / 3 - 2 * spacingH - m_labelLives.Size.X, 0.035f), Type = MyGuiControlTextboxType.DigitsOnly, Name = "lives" }; m_lives.TextChanged += OnLivesChanged; AddCaption(MySpaceTexts.GuiTriggerCaptionLives); Controls.Add(m_labelLives); Controls.Add(m_lives); m_lives.Text = ((MyTriggerLives)trg).LivesLeft.ToString(); }
public MyGuiScreenTriggerTime(MyTrigger trg, MyStringId labelText) : base(trg, new Vector2(WINSIZEX + 0.1f, WINSIZEY)) { float left = m_textboxMessage.Position.X-m_textboxMessage.Size.X/2; float top = -WINSIZEY / 2f + MIDDLE_PART_ORIGIN.Y; m_labelTime = new MyGuiControlLabel( originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top), size: new Vector2(0.013f, 0.035f), text: MyTexts.Get(labelText).ToString()//text: MyTexts.Get(MySpaceTexts.GuiTriggerTimeLimit).ToString() ); left += m_labelTime.Size.X + spacingH; m_textboxTime = new MyGuiControlTextbox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2(0.05f, 0.035f), Type = MyGuiControlTextboxType.DigitsOnly, Name = "time" }; m_textboxTime.TextChanged += OnTimeChanged; Controls.Add(m_labelTime); Controls.Add(m_textboxTime); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); this.Controls.Add(new MyGuiControlLabel(new Vector2(0.0f, -0.10f), text: "Select the amount and type of items to spawn in your inventory", originAlign: MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); m_amountTextbox = new MyGuiControlTextbox(new Vector2(-0.2f, 0.0f), null, 9, null, MyGuiConstants.DEFAULT_TEXT_SCALE, MyGuiControlTextboxType.DigitsOnly); m_items = new MyGuiControlCombobox(new Vector2(0.2f, 0.0f), new Vector2(0.3f, 0.05f), null, null, 10, null); m_confirmButton = new MyGuiControlButton(new Vector2(0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Confirm")); m_cancelButton = new MyGuiControlButton(new Vector2(-0.21f, 0.10f), MyGuiControlButtonStyleEnum.Default, new Vector2(0.2f, 0.05f), null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, null, new System.Text.StringBuilder("Cancel")); foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions()) { var physicalItemDef = definition as MyPhysicalItemDefinition; if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false) continue; int key = m_physicalItemDefinitions.Count; m_physicalItemDefinitions.Add(physicalItemDef); m_items.AddItem(key, definition.DisplayNameText); } this.Controls.Add(m_amountTextbox); this.Controls.Add(m_items); this.Controls.Add(m_confirmButton); this.Controls.Add(m_cancelButton); m_amountTextbox.Text = string.Format("{0}", m_lastAmount); m_items.SelectItemByIndex(m_lastSelectedItem); m_confirmButton.ButtonClicked += confirmButton_OnButtonClick; m_cancelButton.ButtonClicked += cancelButton_OnButtonClick; }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); var fileName = MakeScreenFilepath("DialogAmount"); var fsPath = Path.Combine(MyFileSystem.ContentPath, fileName); MyObjectBuilder_GuiScreen objectBuilder; Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.DeserializeXML<MyObjectBuilder_GuiScreen>(fsPath, out objectBuilder); Init(objectBuilder); m_amountTextbox = (MyGuiControlTextbox)Controls.GetControlByName("AmountTextbox"); m_increaseButton = (MyGuiControlButton)Controls.GetControlByName("IncreaseButton"); m_decreaseButton = (MyGuiControlButton)Controls.GetControlByName("DecreaseButton"); m_confirmButton = (MyGuiControlButton)Controls.GetControlByName("ConfirmButton"); m_cancelButton = (MyGuiControlButton)Controls.GetControlByName("CancelButton"); m_errorLabel = (MyGuiControlLabel)Controls.GetControlByName("ErrorLabel"); m_captionLabel = (MyGuiControlLabel)Controls.GetControlByName("CaptionLabel"); m_captionLabel.Text = null; m_captionLabel.TextEnum = m_caption; m_errorLabel.Visible = false; m_amountTextbox.TextChanged += amountTextbox_TextChanged; m_increaseButton.ButtonClicked += increaseButton_OnButtonClick; m_decreaseButton.ButtonClicked += decreaseButton_OnButtonClick; m_confirmButton.ButtonClicked += confirmButton_OnButtonClick; m_cancelButton.ButtonClicked += cancelButton_OnButtonClick; RefreshAmountTextbox(); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); var fileName = MakeScreenFilepath("DialogAmount"); var fsPath = Path.Combine(MyFileSystem.ContentPath, fileName); MyObjectBuilder_GuiScreen objectBuilder; MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_GuiScreen>(fsPath, out objectBuilder); Init(objectBuilder); m_amountTextbox = (MyGuiControlTextbox)Controls.GetControlByName("AmountTextbox"); m_increaseButton = (MyGuiControlButton)Controls.GetControlByName("IncreaseButton"); m_decreaseButton = (MyGuiControlButton)Controls.GetControlByName("DecreaseButton"); m_confirmButton = (MyGuiControlButton)Controls.GetControlByName("ConfirmButton"); m_cancelButton = (MyGuiControlButton)Controls.GetControlByName("CancelButton"); m_errorLabel = (MyGuiControlLabel)Controls.GetControlByName("ErrorLabel"); m_captionLabel = (MyGuiControlLabel)Controls.GetControlByName("CaptionLabel"); m_captionLabel.Text = null; m_captionLabel.TextEnum = m_caption; m_errorLabel.Visible = false; m_amountTextbox.TextChanged += amountTextbox_TextChanged; m_increaseButton.ButtonClicked += increaseButton_OnButtonClick; m_decreaseButton.ButtonClicked += decreaseButton_OnButtonClick; m_confirmButton.ButtonClicked += confirmButton_OnButtonClick; m_cancelButton.ButtonClicked += cancelButton_OnButtonClick; m_confirmButton.TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; m_cancelButton.TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; RefreshAmountTextbox(); }
public void CutText(MyGuiControlTextbox sender) { //First off, we have to copy CopyText(sender); //Then we cut the text away from the form EraseText(sender); }
public void CopyText(MyGuiControlTextbox sender) { ClipboardText = sender.Text.Substring(Start, Length); Thread myth; myth = new Thread(new System.Threading.ThreadStart(CopyToClipboard)); myth.ApartmentState = ApartmentState.STA; myth.Start(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var caption = AddCaption(m_caption, VRageMath.Color.White.ToVector4()); m_nameBox = new MyGuiControlTextbox(new Vector2(0f, 0f), maxLength: m_maxTextLength); m_nameBox.Text = m_defaultName; m_nameBox.Size = new Vector2(m_textBoxWidth, 0.2f); Controls.Add(m_nameBox); Createbuttons(); }
public void EraseText(MyGuiControlTextbox sender) { if (Start == End) { return; } StringBuilder prefix = new StringBuilder(sender.Text.Substring(0, Start)); StringBuilder suffix = new StringBuilder(sender.Text.Substring(End)); sender.CarriagePositionIndex = Start; sender.Text = prefix.Append(suffix).ToString(); }
public void CopyText(MyGuiControlTextbox sender) { ClipboardText = sender.Text.Substring(Start, Length); if (!string.IsNullOrEmpty(ClipboardText)) { Thread thread = new Thread(() => System.Windows.Forms.Clipboard.SetText(ClipboardText)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } }
public void OnLivesChanged(MyGuiControlTextbox sender) { int? lives = StrToInt(sender.Text); if (lives != null && lives>0) { sender.ColorMask = Vector4.One; m_okButton.Enabled = true; } else { sender.ColorMask = Color.Red.ToVector4(); m_okButton.Enabled = false; } }
public void OnTimeChanged(MyGuiControlTextbox sender) { int? time = StrToInt(sender.Text); if (time != null && IsValid((int)time)) { sender.ColorMask = Vector4.One; m_okButton.Enabled = true; } else { sender.ColorMask = Color.Red.ToVector4(); m_okButton.Enabled = false; } }
public void CopyText(MyGuiControlTextbox sender) { #if !XB1 ClipboardText = sender.Text.Substring(Start, Length); if (!string.IsNullOrEmpty(ClipboardText)) { Thread thread = new Thread(() => System.Windows.Forms.Clipboard.SetText(ClipboardText)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } #else // XB1 System.Diagnostics.Debug.Assert(false, "Not Clipboard support on XB1!"); #endif // XB1 }
public MyGuiScreenTriggerBlockDestroyed(MyTrigger trig) : base(trig,new Vector2(0.5f,0.8f)) { trigger=(MyTriggerBlockDestroyed)trig; AddCaption(MySpaceTexts.GuiTriggerCaptionBlockDestroyed); var layout = new MyLayoutTable(this); layout.SetColumnWidthsNormalized(10, 30, 3, 30, 10); layout.SetRowHeightsNormalized(20, 35, 6, 4, 4, 5, 33); m_selectedBlocks = new MyGuiControlTable(); m_selectedBlocks.VisibleRowsCount = 8; m_selectedBlocks.ColumnsCount = 1; m_selectedBlocks.SetCustomColumnWidths(new float[]{1}); m_selectedBlocks.SetColumnName(0, MyTexts.Get(MySpaceTexts.GuiTriggerBlockDestroyed_ColumnName)); layout.AddWithSize(m_selectedBlocks, MyAlignH.Left, MyAlignV.Top, 1, 1, rowSpan: 1, colSpan: 3); m_buttonPaste = new MyGuiControlButton( text: MyTexts.Get(MySpaceTexts.GuiTriggerPasteBlocks), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, onButtonClick: OnPasteButtonClick ); m_buttonPaste.SetToolTip(MySpaceTexts.GuiTriggerPasteBlocksTooltip); layout.AddWithSize(m_buttonPaste, MyAlignH.Left, MyAlignV.Top, 2, 1, rowSpan: 1, colSpan: 1); m_buttonDelete = new MyGuiControlButton( text: MyTexts.Get(MySpaceTexts.GuiTriggerDeleteBlocks), visualStyle: MyGuiControlButtonStyleEnum.Rectangular, onButtonClick: OnDeleteButtonClick); layout.AddWithSize(m_buttonDelete, MyAlignH.Left, MyAlignV.Top, 2, 3, rowSpan: 1, colSpan: 1); m_labelSingleMessage = new MyGuiControlLabel( text: MyTexts.Get(MySpaceTexts.GuiTriggerBlockDestroyedSingleMessage).ToString() ); layout.AddWithSize(m_labelSingleMessage, MyAlignH.Left, MyAlignV.Top, 3, 1, rowSpan: 1, colSpan: 1); m_textboxSingleMessage = new MyGuiControlTextbox( defaultText: trigger.SingleMessage, maxLength: 85); layout.AddWithSize(m_textboxSingleMessage, MyAlignH.Left, MyAlignV.Top, 4, 1, rowSpan: 1, colSpan: 3); foreach(var block in trigger.Blocks) AddRow(block.Key); m_tempSb.Clear().Append(trigger.SingleMessage); m_textboxSingleMessage.SetText(m_tempSb); }
public void Init(IMyGuiControlsParent controlsParent) { m_playerList = (MyGuiControlListbox)controlsParent.Controls.GetControlByName("PlayerListbox"); m_factionList = (MyGuiControlListbox)controlsParent.Controls.GetControlByName("FactionListbox"); m_chatHistory = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("ChatHistory"); m_chatbox = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("Chatbox"); m_playerList.ItemsSelected += m_playerList_ItemsSelected; m_playerList.MultiSelect = false; m_factionList.ItemsSelected += m_factionList_ItemsSelected; m_factionList.MultiSelect = false; m_sendButton = (MyGuiControlButton)controlsParent.Controls.GetControlByName("SendButton"); m_sendButton.ButtonClicked += m_sendButton_ButtonClicked; m_chatbox.TextChanged += m_chatbox_TextChanged; m_chatbox.EnterPressed += m_chatbox_EnterPressed; if (MySession.Static.LocalCharacter != null) { MySession.Static.ChatSystem.PlayerMessageReceived += MyChatSystem_PlayerMessageReceived; MySession.Static.ChatSystem.FactionMessageReceived += MyChatSystem_FactionMessageReceived; MySession.Static.ChatSystem.GlobalMessageReceived += MyChatSystem_GlobalMessageReceived; MySession.Static.ChatSystem.FactionHistoryDeleted += ChatSystem_FactionHistoryDeleted; MySession.Static.ChatSystem.PlayerHistoryDeleted += ChatSystem_PlayerHistoryDeleted; } MySession.Static.Players.PlayersChanged += Players_PlayersChanged; RefreshLists(); m_chatbox.SetText(m_emptyText); m_sendButton.Enabled = false; if (MyMultiplayer.Static != null) { MyMultiplayer.Static.ChatMessageReceived += Multiplayer_ChatMessageReceived; } m_closed = false; }
public void PasteText(MyGuiControlTextbox sender) { //First we erase the selection EraseText(sender); var prefix = sender.Text.Substring(0, sender.CarriagePositionIndex); var suffix = sender.Text.Substring(sender.CarriagePositionIndex); Thread myth; myth = new Thread(new System.Threading.ThreadStart(PasteFromClipboard)); myth.ApartmentState = ApartmentState.STA; myth.Start(); //We have to wait for the thread to end to make sure we got the text myth.Join(); sender.Text = new StringBuilder(prefix).Append(ClipboardText).Append(suffix).ToString(); sender.CarriagePositionIndex = prefix.Length + ClipboardText.Length; Reset(sender); }
public MyGuiScreenSaveAs(MyWorldInfo copyFrom, string sessionPath, List<string> existingSessionNames) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(0.5f, 0.35f)) { EnabledBackgroundFade = true; AddCaption(MyCommonTexts.ScreenCaptionSaveAs); float textboxPositionY = -0.02f; m_nameTextbox = new MyGuiControlTextbox( position: new Vector2(0, textboxPositionY), defaultText: copyFrom.SessionName, maxLength: 75); m_okButton = new MyGuiControlButton( text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton( text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); Vector2 buttonOrigin = new Vector2(0f, Size.Value.Y * 0.4f); Vector2 buttonOffset = new Vector2(0.01f, 0f); m_okButton.Position = buttonOrigin - buttonOffset; m_cancelButton.Position = buttonOrigin + buttonOffset; Controls.Add(m_nameTextbox); Controls.Add(m_okButton); Controls.Add(m_cancelButton); m_nameTextbox.MoveCarriageToEnd(); m_copyFrom = copyFrom; m_sessionPath = sessionPath; m_existingSessionNames = existingSessionNames; CloseButtonEnabled = true; CloseButtonOffset = new Vector2(-0.005f, 0.0035f); OnEnterCallback = OnEnterPressed; }
public MyGuiScreenTrigger(MyTrigger trg, Vector2 size) : base(size, MyGuiConstants.SCREEN_BACKGROUND_COLOR, size) { Vector2 m_itemPos=new Vector2(); m_itemPos.Y = - size.Y / 2 + 0.1f; m_textboxName=new MyGuiControlLabel( position: m_itemPos, text: MyTexts.Get(MySpaceTexts.GuiTriggerMessage).ToString() ); m_itemPos.Y += m_textboxName.Size.Y + VERTICAL_OFFSET; m_trigger = trg; m_textbox = new MyGuiControlTextbox( position: m_itemPos, defaultText: trg.Message, maxLength: 85); m_itemPos.Y += m_textbox.Size.Y + VERTICAL_OFFSET + 0.2f; //line to the left of textbox m_textboxName.Position = m_textboxName.Position-new Vector2(m_textbox.Size.X / 2 , 0); Vector2 buttonOrigin = new Vector2(0f, Size.Value.Y * 0.4f); Vector2 buttonOffset = new Vector2(0.01f, 0f); m_okButton = new MyGuiControlButton( text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_okButton.Position = buttonOrigin - buttonOffset; m_cancelButton = new MyGuiControlButton( text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); m_cancelButton.Position = buttonOrigin + buttonOffset; Controls.Add(m_textboxName); Controls.Add(m_textbox); Controls.Add(m_okButton); Controls.Add(m_cancelButton); }
void m_chatbox_TextChanged(MyGuiControlTextbox obj) { m_chatboxText.Clear(); obj.GetText(m_chatboxText); if (m_chatboxText.Length == 0) { m_sendButton.Enabled = false; } else { if (MySession.Static.LocalCharacter != null) { m_sendButton.Enabled = true; } if (m_chatboxText.Length > MyChatConstants.MAX_CHAT_STRING_LENGTH) { m_chatboxText.Length = MyChatConstants.MAX_CHAT_STRING_LENGTH; m_chatbox.SetText(m_chatboxText); } } }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); var fileName = MakeScreenFilepath("DialogText"); var fsPath = Path.Combine(MyFileSystem.ContentPath, fileName); MyObjectBuilder_GuiScreen objectBuilder; MyObjectBuilderSerializer.DeserializeXML<MyObjectBuilder_GuiScreen>(fsPath, out objectBuilder); Init(objectBuilder); m_valueTextbox = (MyGuiControlTextbox)Controls.GetControlByName("ValueTextbox"); m_confirmButton = (MyGuiControlButton)Controls.GetControlByName("ConfirmButton"); m_cancelButton = (MyGuiControlButton)Controls.GetControlByName("CancelButton"); m_captionLabel = (MyGuiControlLabel)Controls.GetControlByName("CaptionLabel"); m_captionLabel.Text = null; m_captionLabel.TextEnum = m_caption; m_confirmButton.ButtonClicked += confirmButton_OnButtonClick; m_cancelButton.ButtonClicked += cancelButton_OnButtonClick; m_valueTextbox.Text = m_value; }
public MyGuiScreenChat(Vector2 position) : base(position, MyGuiConstants.SCREEN_BACKGROUND_COLOR, null) { MySandboxGame.Log.WriteLine("MyGuiScreenChat.ctor START"); EnabledBackgroundFade = false; m_isTopMostScreen = true; CanHideOthers = false; DrawMouseCursor = false; m_closeOnEsc = true; m_chatTextbox = new MyGuiControlTextbox( Vector2.Zero, null, ChatMessageBuffer.MAX_MESSAGE_SIZE); m_chatTextbox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_chatTextbox.Size = new Vector2(0.4f, 0.05f); m_chatTextbox.TextScale = 0.8f; m_chatTextbox.VisualStyle = MyGuiControlTextboxStyleEnum.Default; Controls.Add(m_chatTextbox); MySandboxGame.Log.WriteLine("MyGuiScreenChat.ctor END"); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); var fileName = MakeScreenFilepath("DialogAmount"); var fsPath = Path.Combine(MyFileSystem.ContentPath, fileName); MyObjectBuilder_GuiScreen objectBuilder; MyObjectBuilderSerializer.DeserializeXML<MyObjectBuilder_GuiScreen>(fsPath, out objectBuilder); Init(objectBuilder); m_amountTextbox = (MyGuiControlTextbox)Controls.GetControlByName("AmountTextbox"); m_increaseButton = (MyGuiControlButton)Controls.GetControlByName("IncreaseButton"); m_decreaseButton = (MyGuiControlButton)Controls.GetControlByName("DecreaseButton"); m_confirmButton = (MyGuiControlButton)Controls.GetControlByName("ConfirmButton"); m_cancelButton = (MyGuiControlButton)Controls.GetControlByName("CancelButton"); m_errorLabel = (MyGuiControlLabel)Controls.GetControlByName("ErrorLabel"); m_captionLabel = (MyGuiControlLabel)Controls.GetControlByName("CaptionLabel"); m_captionLabel.Text = null; m_captionLabel.TextEnum = m_caption; m_errorLabel.Visible = false; m_amountTextbox.TextChanged += amountTextbox_TextChanged; m_increaseButton.ButtonClicked += increaseButton_OnButtonClick; m_decreaseButton.ButtonClicked += decreaseButton_OnButtonClick; m_confirmButton.ButtonClicked += confirmButton_OnButtonClick; m_cancelButton.ButtonClicked += cancelButton_OnButtonClick; m_confirmButton.TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; m_cancelButton.TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; RefreshAmountTextbox(); //GR: in int have all text selected m_amountTextbox.SelectAll(); }
private void CreatePlanetsSpawnMenu(float separatorSize, float usableWidth) { float min = MyFakes.ENABLE_EXTENDED_PLANET_OPTIONS ? 100 : 19000; float max = /*MyFakes.ENABLE_EXTENDED_PLANET_OPTIONS ? (6378.1f * 1000 * 2) :*/ 120000f; MyGuiControlSlider slider = null; slider = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: min, maxValue: max, labelText: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug, intValue: true); slider.DebugScale = m_sliderDebugScale; slider.ColorMask = Color.White.ToVector4(); Controls.Add(slider); var label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(slider.Size.X + 0.005f, slider.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_currentPosition.Y += slider.Size.Y; m_currentPosition.Y += separatorSize; slider.ValueChanged += (MyGuiControlSlider s) => { StringBuilder sb = new StringBuilder(); MyValueFormatter.AppendDistanceInBestUnit(s.Value, sb); label.Text = sb.ToString(); m_procAsteroidSizeValue = s.Value; }; slider.Value = 8000; m_procAsteroidSeed = CreateSeedButton(m_procAsteroidSeedValue, usableWidth); m_planetCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetPlanetsGeneratorsDefinitions()) { m_planetCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_planetCombobox.ItemSelected += OnPlanetCombobox_ItemSelected; m_planetCombobox.SortItemsByValueText(); m_planetCombobox.SelectItemByIndex(0); } CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, x => { int seed = GetProceduralAsteroidSeed(m_procAsteroidSeed); CreatePlanet(seed, slider.Value); CloseScreenNow(); }); }
private int GetProceduralAsteroidSeed(MyGuiControlTextbox textbox) { int seed = 12345; if (!Int32.TryParse(textbox.Text, out seed)) { //if user didn't passed right seed we will try to calculate it from string : ) String text = textbox.Text; HashAlgorithm algorithm = SHA1.Create(); byte[] bytes = algorithm.ComputeHash(Encoding.UTF8.GetBytes(text)); //hash is too big to store it in int, so we take only first four bytes - it's more than fine, though int shift = 0; for (int i = 0; i < 4 && i < bytes.Length; ++i) { seed |= bytes[i] << shift; shift += 8; } } return seed; }
private MyGuiControlTextbox CreateSeedButton(string seedValue, float usableWidth) { var label = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); var textBox = new MyGuiControlTextbox(m_currentPosition, seedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); textBox.TextChanged += (MyGuiControlTextbox t) => { seedValue = t.Text; }; textBox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(textBox); m_currentPosition.Y += textBox.Size.Y; var button = CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, (MyGuiControlButton buttonClicked) => { textBox.Text = MyRandom.Instance.Next().ToString(); }); return textBox; }
private void CreateObjectsSpawnMenu(float separatorSize, float usableWidth) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Items), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemType), Vector4.One, m_scale); m_physicalObjectCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions()) { if (!definition.Public) continue; var physicalItemDef = definition as MyPhysicalItemDefinition; if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false) continue; int key = m_physicalItemDefinitions.Count; m_physicalItemDefinitions.Add(physicalItemDef); m_physicalObjectCombobox.AddItem(key, definition.DisplayNameText); } m_physicalObjectCombobox.SortItemsByValueText(); m_physicalObjectCombobox.SelectItemByIndex(m_lastSelectedFloatingObjectIndex); m_physicalObjectCombobox.ItemSelected += OnPhysicalObjectCombobox_ItemSelected; } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemAmount), Vector4.One, m_scale); m_amountTextbox = new MyGuiControlTextbox(m_currentPosition, m_amount.ToString(), 6, null, m_scale, MyGuiControlTextboxType.DigitsOnly); m_amountTextbox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_amountTextbox.TextChanged += OnAmountTextChanged; Controls.Add(m_amountTextbox); m_currentPosition.Y += separatorSize + m_amountTextbox.Size.Y; m_errorLabel = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_InvalidAmount), Color.Red.ToVector4(), m_scale); m_errorLabel.Visible = false; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnObject, OnSpawnPhysicalObject); m_currentPosition.Y += separatorSize; }
private void OnAmountTextChanged(MyGuiControlTextbox textbox) { m_errorLabel.Visible = false; }
public void Reset(MyGuiControlTextbox sender) { m_startIndex = m_endIndex = MathHelper.Clamp(sender.CarriagePositionIndex, 0, sender.Text.Length); }
private void CreateProceduralAsteroidsSpawnMenu(float separatorSize, float usableWidth) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), Vector4.One, m_scale); m_procAsteroidSize = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: 5.0f, maxValue: 500f, labelText: String.Empty, labelDecimalPlaces: 2, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); m_procAsteroidSize.DebugScale = m_sliderDebugScale; m_procAsteroidSize.ColorMask = Color.White.ToVector4(); Controls.Add(m_procAsteroidSize); MyGuiControlLabel label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(m_procAsteroidSize.Size.X + 0.005f, m_procAsteroidSize.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { label.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = m_procAsteroidSizeValue; m_currentPosition.Y += m_procAsteroidSize.Size.Y; m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); m_procAsteroidSeed = new MyGuiControlTextbox(m_currentPosition, m_procAsteroidSeedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); m_procAsteroidSeed.TextChanged += (MyGuiControlTextbox t) => { m_procAsteroidSeedValue = t.Text; }; m_procAsteroidSeed.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(m_procAsteroidSeed); m_currentPosition.Y += m_procAsteroidSize.Size.Y + separatorSize; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, generateSeedButton_OnButtonClick); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid); m_currentPosition.Y += separatorSize; }
void m_groupName_TextChanged(MyGuiControlTextbox obj) { if (string.IsNullOrEmpty(obj.Text) || CurrentBlocks.Count == 0) m_groupSave.Enabled = false; else m_groupSave.Enabled = true; }
void blockSearch_TextChanged(MyGuiControlTextbox obj) { if (obj.Text != "") { String[] tmpSearch = obj.Text.Split(' '); foreach (var item in m_blockListbox.Items) { String tmpName = item.Text.ToString().ToLower(); bool add = true; foreach (var search in tmpSearch) if (!tmpName.Contains(search.ToLower())) { add = false; break; } if (add) item.Visible = true; else item.Visible = false; } } else { foreach (var item in m_blockListbox.Items) item.Visible = true; } //SelectBlocks(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); if (m_asteroid_showPlanet) { CreatePlanetMenu(); return; } Vector2 cbOffset = new Vector2(-0.05f, 0.0f); Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top float textScale = 0.8f; float separatorSize = 0.01f; float usableWidth = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2; float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f; m_currentPosition = -m_size.Value / 2.0f; m_currentPosition += controlPadding; m_currentPosition.Y += hiddenPartTop; m_scale = textScale; var caption = AddCaption(MySpaceTexts.ScreenDebugSpawnMenu_Caption, Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop)); m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y + separatorSize; if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS || MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroids), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_SelectAsteroidType), Vector4.One, m_scale); var combo = AddCombo(); combo.AddItem(1, MySpaceTexts.ScreenDebugSpawnMenu_PredefinedAsteroids); combo.AddItem(2, MySpaceTexts.ScreenDebugSpawnMenu_ProceduralAsteroids); // DA: Remove from MySpaceTexts and just hardcode until release. Leave a todo so you don't forget about it before release of planets. combo.AddItem(3, MySpaceTexts.ScreenDebugSpawnMenu_Planets); combo.SelectItemByKey(m_asteroid_showPlanet ? 3 : m_asteroid_showPredefinedOrProcedural ? 1 : 2); combo.ItemSelected += () => { m_asteroid_showPredefinedOrProcedural = combo.GetSelectedKey() == 1; m_asteroid_showPlanet = combo.GetSelectedKey() == 3; RecreateControls(false); }; } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroid), Vector4.One, m_scale); m_asteroidCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMapStorageDefinitions()) { m_asteroidCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_asteroidCombobox.ItemSelected += OnAsteroidCombobox_ItemSelected; m_asteroidCombobox.SortItemsByValueText(); m_asteroidCombobox.SelectItemByIndex(m_lastSelectedAsteroidIndex); } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnLoadAsteroid); m_currentPosition.Y += separatorSize; } if (MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS && !m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), Vector4.One, m_scale); m_procAsteroidSize = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: 5.0f, maxValue: 500f, labelText: String.Empty, labelDecimalPlaces: 2, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); m_procAsteroidSize.DebugScale = m_sliderDebugScale; m_procAsteroidSize.ColorMask = Color.White.ToVector4(); Controls.Add(m_procAsteroidSize); MyGuiControlLabel label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(m_procAsteroidSize.Size.X + 0.005f, m_procAsteroidSize.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { label.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = m_procAsteroidSizeValue; m_currentPosition.Y += m_procAsteroidSize.Size.Y; m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); m_procAsteroidSeed = new MyGuiControlTextbox(m_currentPosition, m_procAsteroidSeedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); m_procAsteroidSeed.TextChanged += (MyGuiControlTextbox t) => { m_procAsteroidSeedValue = t.Text; }; m_procAsteroidSeed.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(m_procAsteroidSeed); m_currentPosition.Y += m_procAsteroidSize.Size.Y + separatorSize; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, generateSeedButton_OnButtonClick); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid); m_currentPosition.Y += separatorSize; } CreateObjectsSpawnMenu(separatorSize, usableWidth); }
private void CreatePlanetControls(MyGuiControlList list, float usableWidth) { var asteroidSizeLabel = CreateSliderWithDescription(list, usableWidth, 8000f, 120000f, MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), ref m_procAsteroidSize); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { asteroidSizeLabel.Text = MyValueFormatter.GetFormatedFloat(s.Value, 0) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = 8000.1f; m_procAsteroidSeed = CreateSeedButton(list, m_procAsteroidSeedValue, usableWidth); }
void amountTextbox_TextChanged(MyGuiControlTextbox obj) { m_amountTextbox.ColorMask = Vector4.One; m_errorLabel.Visible = false; }
private void OnSearchTextChanged(MyGuiControlTextbox sender) { if (sender.Text != "") { String[] tmpSearch = sender.Text.Split(' '); m_tmpSearch = tmpSearch.ToList(); } else m_tmpSearch.Clear(); RefreshGameList(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MySpaceTexts.ScreenCaptionWorkshop); var origin = new Vector2(-0.4375f, -0.375f); Vector2 tinyButtonsOrigin = new Vector2(-0.0015f, -4.5f * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA.Y); m_modsTableDisabled = new MyGuiControlTable(); if (MyFakes.ENABLE_MOD_CATEGORIES) { m_modsTableDisabled.Position = origin + new Vector2(0f, 0.1f); m_modsTableDisabled.VisibleRowsCount = 17; } else { m_modsTableDisabled.Position = origin; m_modsTableDisabled.VisibleRowsCount = 20; } m_modsTableDisabled.Size = new Vector2(m_size.Value.X * 0.4375f, 1.25f); m_modsTableDisabled.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_modsTableDisabled.ColumnsCount = 2; m_modsTableDisabled.ItemSelected += OnTableItemSelected; m_modsTableDisabled.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick; m_modsTableDisabled.ItemConfirmed += OnTableItemConfirmedOrDoubleClick; m_modsTableDisabled.SetCustomColumnWidths(new float[] { 0.085f, 0.905f }); m_modsTableDisabled.SetColumnComparison(1, (a, b) => (a.Text).CompareToIgnoreCase(b.Text)); Controls.Add(m_modsTableDisabled); m_modsTableEnabled = new MyGuiControlTable(); m_modsTableEnabled.Position = origin + new Vector2(m_modsTableDisabled.Size.X + 0.04f, 0f); m_modsTableEnabled.Size = new Vector2(m_size.Value.X * 0.4375f, 1.25f); m_modsTableEnabled.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_modsTableEnabled.ColumnsCount = 2; if (MyFakes.ENABLE_MOD_CATEGORIES) { m_modsTableEnabled.Position = new Vector2(m_modsTableEnabled.Position.X, m_modsTableDisabled.Position.Y - 0.065f); m_modsTableEnabled.VisibleRowsCount = 19; } else { m_modsTableEnabled.VisibleRowsCount = 20; } m_modsTableEnabled.ItemSelected += OnTableItemSelected; m_modsTableEnabled.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick; m_modsTableEnabled.ItemConfirmed += OnTableItemConfirmedOrDoubleClick; m_modsTableEnabled.SetCustomColumnWidths(new float[] { 0.085f, 0.905f }); Controls.Add(m_modsTableEnabled); Controls.Add(m_labelEnabled = MakeLabel(m_modsTableEnabled.Position + new Vector2(m_modsTableEnabled.Size.X / 2f, 0f), MySpaceTexts.ScreenMods_ActiveMods)); Controls.Add(m_labelDisabled = MakeLabel(m_modsTableDisabled.Position + new Vector2(m_modsTableDisabled.Size.X / 2f, 0f), MySpaceTexts.ScreenMods_AvailableMods)); Controls.Add(m_moveUpButton = MakeButtonTiny(tinyButtonsOrigin + 0 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, -MathHelper.PiOver2, MySpaceTexts.ToolTipScreenMods_MoveUp, MyGuiConstants.TEXTURE_BUTTON_ARROW_SINGLE, OnMoveUpClick)); Controls.Add(m_moveTopButton = MakeButtonTiny(tinyButtonsOrigin + 1 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, -MathHelper.PiOver2, MySpaceTexts.ToolTipScreenMods_MoveTop, MyGuiConstants.TEXTURE_BUTTON_ARROW_DOUBLE, OnMoveTopClick)); Controls.Add(m_moveBottomButton = MakeButtonTiny(tinyButtonsOrigin + 2 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MathHelper.PiOver2, MySpaceTexts.ToolTipScreenMods_MoveBottom, MyGuiConstants.TEXTURE_BUTTON_ARROW_DOUBLE, OnMoveBottomClick)); Controls.Add(m_moveDownButton = MakeButtonTiny(tinyButtonsOrigin + 3 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MathHelper.PiOver2, MySpaceTexts.ToolTipScreenMods_MoveDown, MyGuiConstants.TEXTURE_BUTTON_ARROW_SINGLE, OnMoveDownClick)); Controls.Add(m_moveLeftButton = MakeButtonTiny(tinyButtonsOrigin + 5 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MathHelper.Pi, MySpaceTexts.ToolTipScreenMods_MoveLeft, MyGuiConstants.TEXTURE_BUTTON_ARROW_SINGLE, OnMoveLeftClick)); Controls.Add(m_moveLeftAllButton = MakeButtonTiny(tinyButtonsOrigin + 6 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MathHelper.Pi, MySpaceTexts.ToolTipScreenMods_MoveLeftAll, MyGuiConstants.TEXTURE_BUTTON_ARROW_DOUBLE, OnMoveLeftAllClick)); Controls.Add(m_moveRightAllButton = MakeButtonTiny(tinyButtonsOrigin + 7 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, 0f, MySpaceTexts.ToolTipScreenMods_MoveRightAll, MyGuiConstants.TEXTURE_BUTTON_ARROW_DOUBLE, OnMoveRightAllClick)); Controls.Add(m_moveRightButton = MakeButtonTiny(tinyButtonsOrigin + 8 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, 0f, MySpaceTexts.ToolTipScreenMods_MoveRight, MyGuiConstants.TEXTURE_BUTTON_ARROW_SINGLE, OnMoveRightClick)); Controls.Add(m_publishModButton = MakeButton(m_modsTableDisabled.Position + new Vector2(0f, m_modsTableDisabled.Size.Y + 0.01f), MySpaceTexts.LoadScreenButtonPublish, MySpaceTexts.LoadScreenButtonPublish, OnPublishModClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)); Controls.Add(m_openInWorkshopButton = MakeButton(m_publishModButton.Position + new Vector2(m_publishModButton.Size.X + 0.04f, 0f), MySpaceTexts.ScreenLoadSubscribedWorldOpenInWorkshop, MySpaceTexts.ToolTipWorkshopOpenModInWorkshop, OnOpenInWorkshopClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)); Controls.Add(m_refreshButton = MakeButton(m_publishModButton.Position + new Vector2(0f, m_publishModButton.Size.Y + 0.01f), MySpaceTexts.ScreenLoadSubscribedWorldRefresh, MySpaceTexts.ToolTipWorkshopRefreshMod, OnRefreshClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)); Controls.Add(m_browseWorkshopButton = MakeButton(m_openInWorkshopButton.Position + new Vector2(0f, m_publishModButton.Size.Y + 0.01f), MySpaceTexts.ScreenLoadSubscribedWorldBrowseWorkshop, MySpaceTexts.ToolTipWorkshopBrowseWorkshop, OnBrowseWorkshopClick, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)); Controls.Add(m_cancelButton = MakeButton(m_modsTableEnabled.Position + m_modsTableEnabled.Size + new Vector2(0f, 0.01f), MySpaceTexts.Cancel, MySpaceTexts.Cancel, OnCancelClick, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP)); Controls.Add(m_okButton = MakeButton(m_cancelButton.Position - new Vector2(m_cancelButton.Size.X + 0.04f, 0f), MySpaceTexts.Ok, MySpaceTexts.Ok, OnOkClick, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP)); //category buttons if (MyFakes.ENABLE_MOD_CATEGORIES) { Vector2 buttonPosition = m_modsTableDisabled.Position + new Vector2(0.02f, -0.03f); Vector2 buttonOffset = new Vector2(0.0414f, 0f); var categories = MySteamWorkshop.ModCategories; int i = 0; for (; i < categories.Length; ++i) { Controls.Add(MakeButtonCategory(buttonPosition + buttonOffset * i, categories[i])); } var m_categoryCategorySelectButton = new MyGuiControlButton() { Position = (buttonPosition + buttonOffset * i) + new Vector2(-0.02f, -0.014f), Size = new Vector2(0.05f, 0.05f), Name = "SelectCategory", Text = "...", OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, VisualStyle = MyGuiControlButtonStyleEnum.Tiny, }; m_categoryCategorySelectButton.SetToolTip(MySpaceTexts.TooltipScreenMods_SelectCategories); m_categoryCategorySelectButton.ButtonClicked += OnSelectCategoryClicked; Controls.Add(m_categoryCategorySelectButton); Vector2 searchPosition = m_modsTableDisabled.Position + new Vector2(0.1625f, -0.08f); var searchBoxLabel = MakeLabel(searchPosition + new Vector2(-0.135f, 0.01f), MySpaceTexts.ScreenMods_SearchLabel); m_searchBox = new MyGuiControlTextbox(searchPosition); m_searchBox.Size = new Vector2(0.2f, 0.2f); m_searchBox.TextChanged += OnSearchTextChanged; m_searchClear = new MyGuiControlButton() { Position = searchPosition + new Vector2(0.077f, 0f), Size = new Vector2(0.045f, 0.05666667f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, VisualStyle = MyGuiControlButtonStyleEnum.Close, ActivateOnMouseRelease = true }; m_searchClear.ButtonClicked += OnSearchClear; Vector2 buttonsOffset = new Vector2(0, 0.05f); m_moveUpButton.Position += buttonsOffset; m_moveTopButton.Position += buttonsOffset; m_moveBottomButton.Position += buttonsOffset; m_moveDownButton.Position += buttonsOffset; m_moveLeftButton.Position += buttonsOffset; m_moveLeftAllButton.Position += buttonsOffset; m_moveRightAllButton.Position += buttonsOffset; m_moveRightButton.Position += buttonsOffset; Controls.Add(searchBoxLabel); Controls.Add(m_searchBox); Controls.Add(m_searchClear); m_labelDisabled.Position += new Vector2(0, -0.1f); } CloseButtonEnabled = true; }
public void OnRadiusChanged(MyGuiControlTextbox sender) { if (null != StrToDouble(sender.Text)) { sender.ColorMask = Vector4.One; m_okButton.Enabled = true; } else { sender.ColorMask = Color.Red.ToVector4(); m_okButton.Enabled = false; } }
public void Init(IMyGuiControlsParent controlsParent, MyPlayer controller, MyCubeGrid grid, MyTerminalBlock currentBlock, MyGridColorHelper colorHelper) { m_controlsParent = controlsParent; m_controller = controller; m_colorHelper = colorHelper; if (grid == null) { foreach (var control in controlsParent.Controls) control.Visible = false; var label = MyGuiScreenTerminal.CreateErrorLabel(MySpaceTexts.ScreenTerminalError_ShipNotConnected, "ErrorMessage"); controlsParent.Controls.Add(label); return; } m_terminalSystem = grid.GridSystems.TerminalSystem; m_tmpGroup = new MyBlockGroup(grid); m_blockSearch = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearch"); m_blockSearch.TextChanged += blockSearch_TextChanged; m_blockSearchClear = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("FunctionalBlockSearchClear"); m_blockSearchClear.ButtonClicked += blockSearchClear_ButtonClicked; m_blockListbox = (MyGuiControlListbox)m_controlsParent.Controls.GetControlByName("FunctionalBlockListbox"); m_blockNameLabel = (MyGuiControlLabel)m_controlsParent.Controls.GetControlByName("BlockNameLabel"); m_blockNameLabel.Text = ""; m_groupName = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("GroupName"); m_groupName.TextChanged += m_groupName_TextChanged; m_showAll = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("ShowAll"); m_showAll.Selected = m_showAllTerminalBlocks; m_showAll.ButtonClicked += showAll_Clicked; m_showAll.SetToolTip(MySpaceTexts.Terminal_ShowAllInTerminal); m_showAll.IconRotation = 0f; m_showAll.Icon = new MyGuiHighlightTexture { Normal = @"Textures\GUI\Controls\button_hide.dds", Highlight = @"Textures\GUI\Controls\button_unhide.dds", SizePx = new Vector2(40f, 40f), }; m_showAll.Size = new Vector2(0, 0); m_showAll.HighlightType = MyGuiControlHighlightType.FORCED; m_showAll.IconOriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_groupSave = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupSave"); m_groupSave.TextEnum = MySpaceTexts.TerminalButton_GroupSave; m_groupSave.TextAlignment = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; m_groupSave.ButtonClicked += groupSave_ButtonClicked; m_groupDelete = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("GroupDelete"); m_groupDelete.ButtonClicked += groupDelete_ButtonClicked; m_groupDelete.Enabled = false; m_blockListbox.ItemsSelected += blockListbox_ItemSelected; RefreshBlockList(); m_terminalSystem.BlockAdded += TerminalSystem_BlockAdded; m_terminalSystem.BlockRemoved += TerminalSystem_BlockRemoved; m_terminalSystem.GroupAdded += TerminalSystem_GroupAdded; m_terminalSystem.GroupRemoved += TerminalSystem_GroupRemoved; if (currentBlock != null) SelectBlocks(new MyTerminalBlock[] { currentBlock }); }
public MyGuiScreenTriggerPosition(MyTrigger trg) : base(trg, new Vector2(WINSIZEX+0.1f, WINSIZEY)) { float left = MIDDLE_PART_ORIGIN.X-WINSIZEX/2; float top = -WINSIZEY / 2f + MIDDLE_PART_ORIGIN.Y; //X,Y,Z: m_labelInsX = new MyGuiControlLabel( originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top), size: new Vector2(0.01f, 0.035f), text: MyTexts.Get(MySpaceTexts.TerminalTab_GPS_X).ToString() ); left += m_labelInsX.Size.X + spacingH; m_xCoord = new MyGuiControlTextbox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2((WINSIZEX - spacingH) / 3 - 2 * spacingH - m_labelInsX.Size.X, 0.035f), Name = "textX" }; m_xCoord.Enabled = false; left += m_xCoord.Size.X + spacingH; m_labelInsY = new MyGuiControlLabel( originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top), size: new Vector2(WINSIZEX - 0.012f, 0.035f), text: MyTexts.Get(MySpaceTexts.TerminalTab_GPS_Y).ToString() ); left += m_labelInsY.Size.X + spacingH; m_yCoord = new MyGuiControlTextbox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2((WINSIZEX - spacingH) / 3 - 2 * spacingH - m_labelInsY.Size.X, 0.035f), Name = "textY" }; m_yCoord.Enabled = false; left += m_yCoord.Size.X + spacingH; m_labelInsZ = new MyGuiControlLabel( originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top), size: new Vector2(0.01f, 0.035f), text: MyTexts.Get(MySpaceTexts.TerminalTab_GPS_Z).ToString() ); left += m_labelInsZ.Size.X + spacingH; m_zCoord = new MyGuiControlTextbox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2((WINSIZEX - spacingH) / 3 - 2 * spacingH - m_labelInsZ.Size.X, 0.035f), Name = "textZ" }; m_zCoord.Enabled = false; left = MIDDLE_PART_ORIGIN.X - WINSIZEX / 2; top += m_zCoord.Size.Y + VERTICAL_OFFSET; m_labelRadius = new MyGuiControlLabel( originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left, top), size: new Vector2(0.01f, 0.035f), text: MyTexts.Get(MySpaceTexts.GuiTriggerPositionRadius).ToString() ); left += m_labelRadius.Size.X + spacingH; m_radius = new MyGuiControlTextbox() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2((WINSIZEX - spacingH) / 3 - 2 * spacingH - m_labelInsZ.Size.X, 0.035f), Name = "radius" }; m_radius.TextChanged += OnRadiusChanged; left += m_radius.Size.X + spacingH + 0.05f; m_pasteButton = new MyGuiControlButton( text: MyTexts.Get(MySpaceTexts.GuiTriggerPasteGps), visualStyle : MyGuiControlButtonStyleEnum.Small, onButtonClick: OnPasteButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, position: new Vector2(left,top)); Controls.Add(m_labelInsX); Controls.Add(m_xCoord); Controls.Add(m_labelInsY); Controls.Add(m_yCoord); Controls.Add(m_labelInsZ); Controls.Add(m_zCoord); Controls.Add(m_labelRadius); Controls.Add(m_radius); Controls.Add(m_pasteButton); }
public void SelectAll(MyGuiControlTextbox sender) { m_startIndex = 0; m_endIndex = sender.Text.Length; sender.CarriagePositionIndex = sender.Text.Length; }