public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MyCommonTexts.ScreenCaptionLoadWorld); var origin = new Vector2(-0.4375f, -0.3f); Vector2 buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui; m_sessionsTable = new MyGuiControlTable(); m_sessionsTable.Position = origin + new Vector2(buttonSize.X * 1.1f, 0f); m_sessionsTable.Size = new Vector2(1075f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 0.15f); m_sessionsTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_sessionsTable.ColumnsCount = 2; m_sessionsTable.VisibleRowsCount = 17; m_sessionsTable.ItemSelected += OnTableItemSelected; m_sessionsTable.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick; m_sessionsTable.ItemConfirmed += OnTableItemConfirmedOrDoubleClick; m_sessionsTable.SetCustomColumnWidths(new float[] { 0.65f, 0.35f }); m_sessionsTable.SetColumnComparison(0, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData)); m_sessionsTable.SetColumnComparison(1, (a, b) => ((DateTime)a.UserData).CompareTo((DateTime)b.UserData)); Controls.Add(m_sessionsTable); Vector2 buttonOrigin = origin + buttonSize * 0.5f; Vector2 buttonDelta = MyGuiConstants.MENU_BUTTONS_POSITION_DELTA; // Continue last game // Load // Edit // Save // Delete Controls.Add(m_continueLastSave = MakeButton(buttonOrigin + buttonDelta * 0, MyCommonTexts.LoadScreenButtonContinueLastGame, OnContinueLastGameClick)); Controls.Add(m_loadButton = MakeButton(buttonOrigin + buttonDelta * 1, MyCommonTexts.LoadScreenButtonLoad, OnLoadClick)); Controls.Add(m_editButton = MakeButton(buttonOrigin + buttonDelta * 2, MyCommonTexts.LoadScreenButtonEditSettings, OnEditClick)); Controls.Add(m_saveButton = MakeButton(buttonOrigin + buttonDelta * 3, MyCommonTexts.LoadScreenButtonSaveAs, OnSaveAsClick)); Controls.Add(m_deleteButton = MakeButton(buttonOrigin + buttonDelta * 4, MyCommonTexts.LoadScreenButtonDelete, OnDeleteClick)); m_publishButton = MakeButton(buttonOrigin + buttonDelta * 6, MyCommonTexts.LoadScreenButtonPublish, OnPublishClick); if (!MyFakes.XB1_PREVIEW) { Controls.Add(m_publishButton); } m_publishButton.SetToolTip(MyTexts.GetString(MyCommonTexts.LoadScreenButtonTooltipPublish)); m_continueLastSave.Enabled = false; m_continueLastSave.DrawCrossTextureWhenDisabled = false; m_loadButton.DrawCrossTextureWhenDisabled = false; m_editButton.DrawCrossTextureWhenDisabled = false; m_deleteButton.DrawCrossTextureWhenDisabled = false; m_saveButton.DrawCrossTextureWhenDisabled = false; m_publishButton.DrawCrossTextureWhenDisabled = false; CloseButtonEnabled = true; if (m_state == StateEnum.ListLoaded) m_state = StateEnum.ListNeedsReload; }
protected override Graphics.GUI.MyGuiControlTable CreateScenarioTable() { var scenarioTable = new MyGuiControlTable(); scenarioTable.Position = new Vector2(-0.42f, -0.435f + MARGIN_TOP); scenarioTable.Size = new Vector2(0.38f, 1.8f); scenarioTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; scenarioTable.VisibleRowsCount = 18; scenarioTable.ColumnsCount = 2; scenarioTable.SetCustomColumnWidths(new float[] { 0.085f, 0.905f }); scenarioTable.SetColumnName(1, MyTexts.Get(MyCommonTexts.Name)); scenarioTable.ItemSelected += OnTableItemSelected; return scenarioTable; }
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 override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MyCommonTexts.ScreenCaptionWorkshop); var origin = new Vector2(-0.4375f, -0.3f); Vector2 buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui; m_worldsTable = new MyGuiControlTable(); m_worldsTable.Position = origin + new Vector2(buttonSize.X * 1.1f, 0f); m_worldsTable.Size = new Vector2(1075f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f); m_worldsTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_worldsTable.ColumnsCount = 1; m_worldsTable.VisibleRowsCount = 17; m_worldsTable.ItemSelected += OnTableItemSelected; m_worldsTable.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick; m_worldsTable.ItemConfirmed += OnTableItemConfirmedOrDoubleClick; m_worldsTable.SetCustomColumnWidths(new float[] { 1.0f }); m_worldsTable.SetColumnComparison(0, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData)); Controls.Add(m_worldsTable); Vector2 buttonOrigin = origin + buttonSize * 0.5f; Vector2 buttonDelta = MyGuiConstants.MENU_BUTTONS_POSITION_DELTA; // Load Controls.Add(m_loadButton = MakeButton(buttonOrigin + buttonDelta * 0, MyCommonTexts.ScreenLoadSubscribedWorldCopyAndLoad, MyCommonTexts.ToolTipWorkshopCopyAndLoad, OnLoadClick)); Controls.Add(m_copyButton = MakeButton(buttonOrigin + buttonDelta * 1, MyCommonTexts.ScreenLoadSubscribedWorldCopyWorld, MyCommonTexts.ToolTipWorkshopCopyWorld, OnCopyClick)); Controls.Add(m_openInWorkshopButton = MakeButton(buttonOrigin + buttonDelta * 2, MyCommonTexts.ScreenLoadSubscribedWorldOpenInWorkshop, MyCommonTexts.ToolTipWorkshopOpenInWorkshop, OnOpenInWorkshopClick)); Controls.Add(m_refreshButton = MakeButton(buttonOrigin + buttonDelta * 3, MyCommonTexts.ScreenLoadSubscribedWorldRefresh, MyCommonTexts.ToolTipWorkshopRefresh, OnRefreshClick)); Controls.Add(m_browseWorkshopButton = MakeButton(buttonOrigin + buttonDelta * 4, MyCommonTexts.ScreenLoadSubscribedWorldBrowseWorkshop, MyCommonTexts.ToolTipWorkshopBrowseWorkshop, OnBrowseWorkshopClick)); m_loadButton.DrawCrossTextureWhenDisabled = false; m_openInWorkshopButton.DrawCrossTextureWhenDisabled = false; CloseButtonEnabled = true; }
private void OnTableDoubleclick(MyGuiControlTable sender, Sandbox.Graphics.GUI.MyGuiControlTable.EventArgs args) { if (sender.SelectedRow != null) { ((MyGps)sender.SelectedRow.UserData).ShowOnHud ^= true; MySession.Static.Gpss.ChangeShowOnHud(MySession.LocalPlayerId, ((MyGps)sender.SelectedRow.UserData).Hash, ((MyGps)sender.SelectedRow.UserData).ShowOnHud); } }
public void Init(MyGuiControlParent menuParent, MyGuiControlParent panelParent, MyEntity interactedEntity, MyEntity openInventoryInteractedEntity) { m_interactedEntityRepresentative = GetInteractedEntityRepresentative(interactedEntity); m_openInventoryInteractedEntityRepresentative = GetInteractedEntityRepresentative(openInventoryInteractedEntity); if(menuParent == null) MySandboxGame.Log.WriteLine("menuParent is null"); if(panelParent == null) MySandboxGame.Log.WriteLine("panelParent is null"); if (menuParent == null || panelParent == null) return; m_shipsInRange = (MyGuiControlCombobox)menuParent.Controls.GetControlByName("ShipsInRange"); m_button = (MyGuiControlButton)menuParent.Controls.GetControlByName("SelectShip"); m_shipsData = (MyGuiControlTable)panelParent.Controls.GetControlByName("ShipsData"); //sort by status by default m_columnToSort = 2; m_button.ButtonClicked += Menu_ButtonClicked; m_shipsData.ItemDoubleClicked += shipsData_ItemDoubleClicked; m_shipsData.ColumnClicked += shipsData_ColumnClicked; m_shipsInRange.ItemSelected += shipsInRange_ItemSelected; Refresh(); }
private void OnTableItemSelected(MyGuiControlTable sender, Sandbox.Graphics.GUI.MyGuiControlTable.EventArgs args) { trySync(); if (sender.SelectedRow != null) { enableEditBoxes(true); m_buttonDelete.Enabled = true; FillRight((MyGps)sender.SelectedRow.UserData); } else { enableEditBoxes(false); m_buttonDelete.Enabled = false; ClearRight(); } }
private void OnTableItemSelected(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { m_selectedRow = sender.SelectedRow; m_selectedTable = sender; if (sender == m_modsTableEnabled) m_modsTableDisabled.SelectedRowIndex = null; if (sender == m_modsTableDisabled) m_modsTableEnabled.SelectedRowIndex = null; if (MyInput.Static.IsAnyCtrlKeyPressed()) OnTableItemConfirmedOrDoubleClick(sender, eventArgs); }
private void RefreshGameList() { m_selectedRow = null; m_selectedTable = null; ListReader<MyObjectBuilder_Checkpoint.ModItem> lastActiveMods; if (m_keepActiveMods) { var tmp = new List<MyObjectBuilder_Checkpoint.ModItem>(m_modsTableEnabled.RowsCount); GetActiveMods(tmp); lastActiveMods = tmp; } else { lastActiveMods = m_modListToEdit; } m_keepActiveMods = true; GetWorldMods(lastActiveMods); m_modsTableEnabled.Clear(); m_modsTableDisabled.Clear(); AddHeaders(); foreach (var mod in lastActiveMods) { if (mod.PublishedFileId == 0) { var title = new StringBuilder(mod.Name); var modFullPath = Path.Combine(MyFileSystem.ModsPath, mod.Name); var toolTip = new StringBuilder(modFullPath); var modState = MyTexts.Get(MySpaceTexts.ScreenMods_LocalMod); Color? textColor = null; MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_LOCAL; if (!Directory.Exists(modFullPath) && !File.Exists(modFullPath)) { toolTip = MyTexts.Get(MySpaceTexts.ScreenMods_MissingLocalMod); modState = toolTip; textColor = MyHudConstants.MARKER_COLOR_RED; } AddMod(true, title, toolTip, modState, icon, mod, textColor); } else { var title = new StringBuilder(); var toolTip = new StringBuilder(); var modState = MyTexts.Get(MySpaceTexts.ScreenMods_WorkshopMod); Color? textColor = null; var subscribedItem = GetSubscribedItem(mod.PublishedFileId); if (subscribedItem != null) { title.Append(subscribedItem.Title); var shortLen = Math.Min(subscribedItem.Description.Length, 128); var newlineIndex = subscribedItem.Description.IndexOf("\n"); if (newlineIndex > 0) shortLen = Math.Min(shortLen, newlineIndex - 1); toolTip.Append(subscribedItem.Description.Substring(0, shortLen)); } else { title.Append(mod.PublishedFileId.ToString()); toolTip = MyTexts.Get(MySpaceTexts.ScreenMods_MissingDetails); textColor = MyHudConstants.MARKER_COLOR_RED; } MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP; AddMod(true, title, toolTip, modState, icon, mod, textColor); } } if (!Directory.Exists(MyFileSystem.ModsPath)) Directory.CreateDirectory(MyFileSystem.ModsPath); foreach (var modFullPath in Directory.GetDirectories(MyFileSystem.ModsPath, "*", SearchOption.TopDirectoryOnly)) { var modName = Path.GetFileName(modFullPath); if (m_worldLocalMods.Contains(modName)) continue; if (Directory.GetFileSystemEntries(modFullPath).Length == 0) continue; if (MyFakes.ENABLE_MOD_CATEGORIES) { if (!CheckSearch(modName)) continue; } var titleSB = new StringBuilder(modName); var descriptionSB = modFullPath; var modStateSB = MyTexts.GetString(MySpaceTexts.ScreenMods_LocalMod); var publishedFileId = MySteamWorkshop.GetWorkshopIdFromLocalMod(modFullPath); MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_LOCAL; var row = new MyGuiControlTable.Row(new MyObjectBuilder_Checkpoint.ModItem(modName, 0)); row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(), toolTip: modStateSB, icon: icon)); row.AddCell(new MyGuiControlTable.Cell(text: titleSB, toolTip: descriptionSB)); m_modsTableDisabled.Add(row); } if (m_subscribedMods != null) { foreach (var mod in m_subscribedMods) { if (m_worldWorkshopMods.Contains(mod.PublishedFileId)) continue; if (MyFakes.ENABLE_MOD_CATEGORIES) { bool add = false; foreach (var tag in mod.Tags) { if (m_selectedCategories.Contains(tag.ToLower()) || m_selectedCategories.Count == 0) { add = true; break; } } if (!CheckSearch(mod.Title)) continue; if (!add) continue; } var titleSB = new StringBuilder(mod.Title); var shortLen = Math.Min(mod.Description.Length, 128); var newlineIndex = mod.Description.IndexOf("\n"); if (newlineIndex > 0) shortLen = Math.Min(shortLen, newlineIndex - 1); var descriptionSB = new StringBuilder(); var modStateSB = MyTexts.GetString(MySpaceTexts.ScreenMods_WorkshopMod); var path = Path.Combine(MyFileSystem.ModsPath, string.Format("{0}.sbm", mod.PublishedFileId)); if (mod.Description.Length != 0) descriptionSB.AppendLine(path); else descriptionSB.Append(path); descriptionSB.Append(mod.Description.Substring(0, shortLen)); MyGuiHighlightTexture icon = MyGuiConstants.TEXTURE_ICON_MODS_WORKSHOP; var row = new MyGuiControlTable.Row(new MyObjectBuilder_Checkpoint.ModItem(null, mod.PublishedFileId)); row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(), toolTip: modStateSB, icon: icon)); row.AddCell(new MyGuiControlTable.Cell(text: titleSB, toolTip: descriptionSB.ToString())); m_modsTableDisabled.Add(row); } } }
private void OnServerTableItemDoubleClick(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { JoinSelectedServer(); }
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; }
private void OnTableItemSelected(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { if (m_gamesTable.SelectedRow != null) { m_joinButton.Enabled = true; } else { m_joinButton.Enabled = false; } }
public void Close() { UnregisterEvents(); // left controls m_selectedFaction = null; m_tableFactions = null; m_buttonCreate = null; m_buttonJoin = null; m_buttonCancelJoin = null; m_buttonLeave = null; m_buttonSendPeace = null; m_buttonCancelPeace = null; m_buttonAcceptPeace = null; m_buttonMakeEnemy = null; // right controls m_labelFactionName = null; m_labelFactionDesc = null; m_labelFactionPriv = null; m_labelMembers = null; m_labelAutoAcceptMember = null; m_labelAutoAcceptPeace = null; m_checkAutoAcceptMember = null; m_checkAutoAcceptPeace = null; m_textFactionDesc = null; m_textFactionPriv = null; m_tableMembers = null; m_buttonKick = null; m_buttonAcceptJoin = null; m_controlsParent = null; }
void OnTableItemSelected(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { m_selectedRow = eventArgs.RowIndex; FillRight(); }
private Tuple<string, MyWorldInfo> FindSave(MyGuiControlTable.Row row) { string savePath = (string)row.UserData; var entry = m_availableSaves.Find((x) => x.Item1 == savePath); return entry; }
protected virtual void BuildControls() { Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.65f, 0.1f); AddCaption(MySpaceTexts.ScreenCaptionScenario); //RIGHT: int numControls = 0; var nameLabel = MakeLabel(MySpaceTexts.Name); var descriptionLabel = MakeLabel(MySpaceTexts.Description); var difficultyLabel = MakeLabel(MySpaceTexts.Difficulty); var onlineModeLabel = MakeLabel(MySpaceTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MySpaceTexts.MaxPlayers); float width = 0.284375f + 0.025f; m_nameTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_NAME_LENGTH); m_descriptionTextbox = new MyGuiControlTextbox(maxLength: MySession.MAX_DESCRIPTION_LENGTH); m_difficultyCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_difficultyCombo.AddItem((int)0, MySpaceTexts.DifficultyEasy); m_difficultyCombo.AddItem((int)1, MySpaceTexts.DifficultyNormal); m_difficultyCombo.AddItem((int)2, MySpaceTexts.DifficultyHard); m_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_maxPlayersSlider = new MyGuiControlSlider( position: Vector2.Zero, width: m_onlineMode.Size.X, minValue: 2, maxValue: 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.05f, intValue: true ); m_scenarioTypesList = new MyGuiControlList(); //BUTTONS m_removeButton = new MyGuiControlButton(position: buttonsOrigin, size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonRemove), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_publishButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f + m_removeButton.Size.X, 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonPublish), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_createButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2*(0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonCreateNew), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_browseWorkshopButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(3*(0.01f + m_removeButton.Size.X), 0f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonBrowseWorkshop), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_refreshButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.0f, m_removeButton.Size.Y+0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonRefresh), onButtonClick: OnRefreshButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_openInWorkshopButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2((0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.buttonOpenInWorkshop), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_okButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(2 * (0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(3 * (0.01f + m_removeButton.Size.X), m_removeButton.Size.Y + 0.01f), size: buttonSize, text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_onlineMode.ItemSelected += OnOnlineModeSelect; m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MySpaceTexts.WorldSettings_OnlineModeOffline); m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MySpaceTexts.WorldSettings_OnlineModePrivate); m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MySpaceTexts.WorldSettings_OnlineModeFriends); m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MySpaceTexts.WorldSettings_OnlineModePublic); m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; // Add controls in pairs; label first, control second. They will be laid out automatically this way. Controls.Add(nameLabel); Controls.Add(m_nameTextbox); //m_nameTextbox.Enabled = false; Controls.Add(descriptionLabel); Controls.Add(m_descriptionTextbox); //m_descriptionTextbox.Enabled = false; Controls.Add(difficultyLabel); Controls.Add(m_difficultyCombo); m_difficultyCombo.Enabled = false; Controls.Add(onlineModeLabel); Controls.Add(m_onlineMode); m_onlineMode.Enabled = false; Controls.Add(m_maxPlayersLabel); Controls.Add(m_maxPlayersSlider); float labelSize = 0.12f; float MARGIN_TOP = 0.1f; float MARGIN_LEFT = 0.42f;// m_isNewGame ? 0.315f : 0.08f; // Automatic layout. Vector2 originL, originC; Vector2 controlsDelta = new Vector2(0f, 0.052f); float rightColumnOffset; originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP); originC = originL + new Vector2(labelSize, 0f); rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f; foreach (var control in Controls) { control.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; if (control is MyGuiControlLabel) control.Position = originL + controlsDelta * numControls; else control.Position = originC + controlsDelta * numControls++; } //BRIEFING: //var textBackgroundPanel = AddCompositePanel(MyGuiConstants.TEXTURE_RECTANGLE_DARK, new Vector2(0f,0f), new Vector2(0.43f, 0.422f), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP); //textBackgroundPanel.InnerHeight = 6; MyGuiControlParent briefing = new MyGuiControlParent();//new Vector2(0f, 0f), new Vector2(0.43f, 0.422f)); var briefingScrollableArea = new MyGuiControlScrollablePanel( scrolledControl: briefing) { Name = "BriefingScrollableArea", ScrollbarVEnabled = true, Position = new Vector2(-0.02f, -0.12f), Size = new Vector2(0.43f, 0.422f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, BackgroundTexture = MyGuiConstants.TEXTURE_SCROLLABLE_LIST, ScrolledAreaPadding = new MyGuiBorderThickness(0.005f), }; Controls.Add(briefingScrollableArea); //inside scrollable area: m_descriptionBox = AddMultilineText(offset: new Vector2(0.0f, 0.0f), size: new Vector2(1f, 1f), selectable: false); briefing.Controls.Add(m_descriptionBox); //LEFT: m_scenarioTable = new MyGuiControlTable(); m_scenarioTable.Position = new Vector2(-0.42f, -0.5f+MARGIN_TOP); m_scenarioTable.Size = new Vector2(0.38f, 1.8f); m_scenarioTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scenarioTable.VisibleRowsCount = 20; m_scenarioTable.ColumnsCount = 2; m_scenarioTable.SetCustomColumnWidths(new float[] { 0.085f, 0.905f }); m_scenarioTable.SetColumnName(1, MyTexts.Get(MySpaceTexts.Name)); m_scenarioTable.ItemSelected += OnTableItemSelected; //m_scenarioTable.ItemDoubleClicked += OnTableItemConfirmedOrDoubleClick; //m_scenarioTable.ItemConfirmed += OnTableItemConfirmedOrDoubleClick; Controls.Add(m_scenarioTable); //BUTTONS: Controls.Add(m_removeButton); m_removeButton.Enabled = false; Controls.Add(m_publishButton); m_publishButton.Enabled = false; Controls.Add(m_createButton); m_createButton.Enabled = false; Controls.Add(m_browseWorkshopButton); m_browseWorkshopButton.Enabled = false; Controls.Add(m_refreshButton); Controls.Add(m_openInWorkshopButton); m_openInWorkshopButton.Enabled = false; Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; SetDefaultValues(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); CloseButtonEnabled = true; var caption = AddCaption(MyCommonTexts.ScreenCaptionPlayers); var captionCenter = MyUtils.GetCoordCenterFromAligned(caption.Position, caption.Size, caption.OriginAlign); var captionBottomCenter = captionCenter + new Vector2(0f, 0.5f * caption.Size.Y); Vector2 sizeScale = Size.Value / MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.SizeGui; Vector2 topLeft = -0.5f * Size.Value + sizeScale * MyGuiConstants.TEXTURE_SCREEN_BACKGROUND.PaddingSizeGui * 1.1f; float verticalSpacing = 0.0045f; m_lobbyTypeCombo = new MyGuiControlCombobox( position: new Vector2(-topLeft.X, captionBottomCenter.Y + verticalSpacing), openAreaItemsCount: 3); m_lobbyTypeCombo.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Private, MyCommonTexts.ScreenPlayersLobby_Private); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.FriendsOnly, MyCommonTexts.ScreenPlayersLobby_Friends); m_lobbyTypeCombo.AddItem((int)LobbyTypeEnum.Public, MyCommonTexts.ScreenPlayersLobby_Public); m_lobbyTypeCombo.SelectItemByKey((int)MyMultiplayer.Static.GetLobbyType()); MyGuiControlBase aboveControl; m_inviteButton = new MyGuiControlButton( position: new Vector2(-m_lobbyTypeCombo.Position.X, m_lobbyTypeCombo.Position.Y + m_lobbyTypeCombo.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Invite)); aboveControl = m_inviteButton; m_promoteButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Promote)); aboveControl = m_promoteButton; m_demoteButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Demote)); aboveControl = m_demoteButton; m_kickButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Kick)); aboveControl = m_kickButton; m_banButton = new MyGuiControlButton( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.Get(MyCommonTexts.ScreenPlayers_Ban)); aboveControl = m_banButton; var maxPlayersLabel = new MyGuiControlLabel( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y + verticalSpacing), originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, text: MyTexts.GetString(MyCommonTexts.MaxPlayers)); aboveControl = maxPlayersLabel; m_maxPlayersSlider = new MyGuiControlSlider( position: aboveControl.Position + new Vector2(0f, aboveControl.Size.Y), width: 0.15f, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, minValue: 2, maxValue: MyMultiplayer.Static != null ? MyMultiplayer.Static.MaxPlayers : 16, labelText: new StringBuilder("{0}").ToString(), labelDecimalPlaces: 0, labelSpaceWidth: 0.02f, defaultValue: Sync.IsServer ? MySession.Static.MaxPlayers : MyMultiplayer.Static.MemberLimit, intValue: true); m_maxPlayersSlider.ValueChanged = MaxPlayersSlider_Changed; aboveControl = m_maxPlayersSlider; m_playersTable = new MyGuiControlTable() { Position = new Vector2(-m_inviteButton.Position.X, m_inviteButton.Position.Y), Size = new Vector2(1200f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f) - m_inviteButton.Size * 1.05f, VisibleRowsCount = 21, OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, ColumnsCount = 5, }; float PlayerNameWidth = 0.3f; float FactionTagWidth = 0.1f; float FactionNameWidth = MyPerGameSettings.EnableMutePlayer ? 0.3f : 0.34f; float MutedWidth = MyPerGameSettings.EnableMutePlayer ? 0.13f : 0; m_playersTable.SetCustomColumnWidths(new float[] { PlayerNameWidth, FactionTagWidth, FactionNameWidth, MutedWidth, 1 - PlayerNameWidth - FactionTagWidth - FactionNameWidth - MutedWidth }); m_playersTable.SetColumnName(PlayerNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_PlayerName)); m_playersTable.SetColumnName(PlayerFactionTagColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionTag)); m_playersTable.SetColumnName(PlayerFactionNameColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_FactionName)); m_playersTable.SetColumnName(PlayerMutedColumn, new StringBuilder(MyTexts.GetString(MyCommonTexts.ScreenPlayers_Muted))); m_playersTable.SetColumnName(GameAdminColumn, MyTexts.Get(MyCommonTexts.ScreenPlayers_GameAdmin)); m_playersTable.SetColumnComparison(0, (a, b) => (a.Text.CompareToIgnoreCase(b.Text))); m_playersTable.ItemSelected += playersTable_ItemSelected; // CH: To show the clients correctly, we would need to know, whether the game is a dedicated-server-hosted game. // We don't know that, so I just show all clients with players foreach (var player in Sync.Players.GetOnlinePlayers()) { if (player.Id.SerialId != 0) continue; for (int i = 0; i < m_playersTable.RowsCount; ++i) { var row = m_playersTable.GetRow(i); if (row.UserData is ulong && (ulong)row.UserData == player.Id.SteamId) continue; } AddPlayer(player.Id.SteamId); } m_inviteButton.ButtonClicked += inviteButton_ButtonClicked; m_promoteButton.ButtonClicked += promoteButton_ButtonClicked; m_demoteButton.ButtonClicked += demoteButton_ButtonClicked; m_kickButton.ButtonClicked += kickButton_ButtonClicked; m_banButton.ButtonClicked += banButton_ButtonClicked; m_lobbyTypeCombo.ItemSelected += lobbyTypeCombo_OnSelect; Controls.Add(m_inviteButton); Controls.Add(m_promoteButton); Controls.Add(m_demoteButton); Controls.Add(m_kickButton); Controls.Add(m_banButton); Controls.Add(m_playersTable); Controls.Add(m_lobbyTypeCombo); Controls.Add(m_maxPlayersSlider); Controls.Add(maxPlayersLabel); UpdateButtonsEnabledState(); }
protected void playersTable_ItemSelected(MyGuiControlTable table, MyGuiControlTable.EventArgs args) { Debug.Assert(table == m_playersTable); UpdateButtonsEnabledState(); }
public void Init(IMyGuiControlsParent controlsParent) { m_controlsParent = controlsParent; //left: m_searchIns = (MyGuiControlTextbox)m_controlsParent.Controls.GetControlByName("SearchIns"); m_searchIns.TextChanged += searchIns_TextChanged; m_searchInsClear = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("SearchInsClear"); m_searchInsClear.ButtonClicked += searchInsClear_ButtonClicked; m_tableIns = (MyGuiControlTable)controlsParent.Controls.GetControlByName("TableINS"); m_tableIns.SetColumnComparison(0, TableSortingComparison); m_tableIns.ItemSelected += OnTableItemSelected; m_tableIns.ItemDoubleClicked += OnTableDoubleclick; //bottom buttons m_buttonAdd = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("buttonAdd"); m_buttonAddCurrent = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("buttonFromCurrent"); m_buttonAddFromClipboard = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("buttonFromClipboard"); m_buttonDelete = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("buttonDelete"); m_buttonAdd.ButtonClicked += OnButtonPressedNew; m_buttonAddFromClipboard.ButtonClicked += OnButtonPressedNewFromClipboard; m_buttonAddCurrent.ButtonClicked += OnButtonPressedNewFromCurrent; m_buttonDelete.ButtonClicked += OnButtonPressedDelete; //right: m_labelInsName = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelInsName"); m_panelInsName = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("panelInsName"); m_labelInsDesc = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelInsDesc"); m_panelInsDesc = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("textInsDesc"); m_labelInsX = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelInsX"); m_xCoord = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("textInsX"); m_labelInsY = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelInsY"); m_yCoord = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("textInsY"); m_labelInsZ = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelInsZ"); m_zCoord = (MyGuiControlTextbox)controlsParent.Controls.GetControlByName("textInsZ"); m_labelInsShowOnHud=(MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelInsShowOnHud"); m_checkInsShowOnHud = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("checkInsShowOnHud"); m_checkInsShowOnHud.IsCheckedChanged += OnShowOnHudChecked; m_buttonCopy = (MyGuiControlButton)m_controlsParent.Controls.GetControlByName("buttonToClipboard"); m_buttonCopy.ButtonClicked += OnButtonPressedCopy; m_labelSaveWarning = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("TerminalTab_GPS_SaveWarning"); m_labelSaveWarning.Visible = false; HookSyncEvents(); MySession.Static.Gpss.GpsChanged += OnInsChanged; MySession.Static.Gpss.ListChanged += OnListChanged; //int ret = MySession.Static.Inss.ScanText("df INS:nefinalni 3:1:2.3:1: INS:nefinalni 4:2:2.3:2:"); MySession.Static.Gpss.DiscardOld(); PopulateList(); m_previousHash = null; enableEditBoxes(false); m_buttonDelete.Enabled = false; }
private void OnFactionsTableItemSelected(MyGuiControlTable sender, Sandbox.Graphics.GUI.MyGuiControlTable.EventArgs args) { if (sender.SelectedRow != null) { m_selectedFaction = (MyFaction)sender.SelectedRow.UserData; m_labelFactionName.Text = string.Format("{0}.{1}", m_selectedFaction.Tag, m_selectedFaction.Name); m_textFactionDesc.Text = new StringBuilder(m_selectedFaction.Description); m_textFactionPriv.Text = new StringBuilder(m_selectedFaction.PrivateInfo); RefreshTableMembers(); } m_tableMembers.Sort(false); RefreshJoinButton(); RefreshDiplomacyButtons(); RefreshFactionProperties(); }
protected override void OnTableItemSelected(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { base.OnTableItemSelected(sender, eventArgs); if (eventArgs.RowIndex<2) { m_publishButton.Enabled = false; m_onlineMode.Enabled = false; m_onlineMode.SelectItemByIndex(0); m_editButton.Enabled = false; } else { m_publishButton.Enabled = false; m_onlineMode.Enabled = true; m_editButton.Enabled = false; if (m_scenarioTable.SelectedRow != null) { m_publishButton.Enabled = true; Tuple<string, MyWorldInfo> t = FindSave(m_scenarioTable.SelectedRow); if (t.Item1 != WORKSHOP_PATH_TAG) m_editButton.Enabled = true; } } }
private void OnTableItemSelected(MyGuiControlTable sender, Sandbox.Graphics.GUI.MyGuiControlTable.EventArgs args) { RefreshRightSideButtons(sender.SelectedRow); }
private void OnServerTableItemSelected(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { if (sender.SelectedRow == null) return; var server = (GameServerItem)sender.SelectedRow.UserData; if (server == null) return; IPEndPoint endpoint = server.NetAdr; if (endpoint == null) return; var cell = sender.SelectedRow.GetCell(5); if (cell == null) return; var toolTip = cell.ToolTip; if (toolTip == null) return; if (eventArgs.MouseButton == MyMouseButtonsEnum.Right) { m_contextMenu.CreateNewContextMenu(); var action = m_selectedPage == m_favoritesPage ? ContextMenuFavoriteAction.Remove : ContextMenuFavoriteAction.Add; var itemText = MySpaceTexts.JoinGame_Favorites_Remove; if (action == ContextMenuFavoriteAction.Add) { itemText = MySpaceTexts.JoinGame_Favorites_Add; } m_contextMenu.AddItem(MyTexts.Get(itemText), userData: new ContextMenuFavoriteActionItem() { Server = server, Action = action }); m_contextMenu.Activate(); } else { m_contextMenu.Deactivate(); } MySandboxGame.Services.SteamService.SteamAPI.GetServerRules(endpoint.Address.ToIPv4NetworkOrder(), (ushort)endpoint.Port, delegate(Dictionary<string, string> rules) { if (rules == null) return; if (rules.Count == 0) return; if (toolTip == null) return; if (toolTip.ToolTips == null) return; if (toolTip.ToolTips.Count == 0) return; try { int modCount = 0; int.TryParse(rules[MyMultiplayer.ModCountTag], out modCount); if (modCount > 0) { if (toolTip.ToolTips[0] == null) return; if (toolTip.ToolTips[0].Text == null) return; var text = toolTip.ToolTips[0].Text.Clear(); int displayedModsMax = 15; int lastMod = Math.Min(displayedModsMax, modCount - 1); for (int i = 0; i < modCount; ++i) { if (displayedModsMax-- <= 0) { text.Append("..."); break; } if (lastMod-- <= 0) text.Append(rules[MyMultiplayer.ModItemTag + i.ToString()]); else text.AppendLine(rules[MyMultiplayer.ModItemTag + i.ToString()]); } toolTip.RecalculateSize(); } } catch (System.Collections.Generic.KeyNotFoundException) { MySandboxGame.Log.WriteLine(string.Format("Server returned corrupted rules: Address = {0}, Name = '{1}'", server.NetAdr, server.Name)); } }, delegate() { MySandboxGame.Log.WriteLine(string.Format("Failed to get server rules: Address = {0}, Name = '{1}'", server.NetAdr, server.Name)); if (toolTip == null) return; if (toolTip.ToolTips == null) return; if (toolTip.ToolTips.Count == 0) return; if (toolTip.ToolTips[0] == null) return; if (toolTip.ToolTips[0].Text == null) return; var text = toolTip.ToolTips[0].Text.Clear(); text.Append(MyTexts.Get(MySpaceTexts.JoinGame_BadModsListResponse)); toolTip.RecalculateSize(); }); }
private void shipsData_ColumnClicked(MyGuiControlTable sender, int column) { m_columnToSort = column; }
private void MoveSelectedItem(MyGuiControlTable from, MyGuiControlTable to) { to.Add(from.SelectedRow); from.RemoveSelectedRow(); m_selectedRow = from.SelectedRow; }
public void Init(IMyGuiControlsParent controlsParent) { m_controlsParent = controlsParent; RefreshUserInfo(); m_tableFactions = (MyGuiControlTable)controlsParent.Controls.GetControlByName("FactionsTable"); m_tableFactions.SetColumnComparison(0, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData)); m_tableFactions.SetColumnComparison(1, (a, b) => ((StringBuilder)a.UserData).CompareToIgnoreCase((StringBuilder)b.UserData)); m_tableFactions.ItemSelected += OnFactionsTableItemSelected; RefreshTableFactions(); m_tableFactions.SortByColumn(1); m_buttonCreate = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCreate"); m_buttonJoin = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonJoin"); m_buttonCancelJoin = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCancelJoin"); m_buttonLeave = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonLeave"); m_buttonSendPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonSendPeace"); m_buttonCancelPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonCancelPeace"); m_buttonAcceptPeace = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAcceptPeace"); m_buttonMakeEnemy = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonEnemy"); m_buttonCreate.ShowTooltipWhenDisabled = true; m_buttonCreate.TextEnum = MySpaceTexts.TerminalTab_Factions_Create; m_buttonJoin.TextEnum = MySpaceTexts.TerminalTab_Factions_Join; m_buttonCancelJoin.TextEnum = MySpaceTexts.TerminalTab_Factions_CancelJoin; m_buttonLeave.TextEnum = MySpaceTexts.TerminalTab_Factions_Leave; m_buttonSendPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_Friend; m_buttonCancelPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_CancelPeaceRequest; m_buttonAcceptPeace.TextEnum = MySpaceTexts.TerminalTab_Factions_AcceptPeaceRequest; m_buttonMakeEnemy.TextEnum = MySpaceTexts.TerminalTab_Factions_Enemy; m_buttonJoin.SetToolTip(MySpaceTexts.TerminalTab_Factions_JoinToolTip); m_buttonSendPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_FriendToolTip); m_buttonCreate.ButtonClicked += OnCreateClicked; m_buttonJoin.ButtonClicked += OnJoinClicked; m_buttonCancelJoin.ButtonClicked += OnCancelJoinClicked; m_buttonLeave.ButtonClicked += OnLeaveClicked; m_buttonSendPeace.ButtonClicked += OnFriendClicked; m_buttonCancelPeace.ButtonClicked += OnCancelPeaceRequestClicked; m_buttonAcceptPeace.ButtonClicked += OnAcceptFriendClicked; m_buttonMakeEnemy.ButtonClicked += OnEnemyClicked; // RIGHT SIDE m_labelFactionName = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionName"); m_labelFactionDesc = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionDesc"); m_labelFactionPriv = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionPrivate"); m_labelMembers = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembers"); m_labelAutoAcceptMember = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembersAcceptEveryone"); m_labelAutoAcceptPeace = (MyGuiControlLabel)controlsParent.Controls.GetControlByName("labelFactionMembersAcceptPeace"); m_labelFactionDesc.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_CreateFactionDescription).ToString(); m_labelFactionPriv.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_Private).ToString(); m_labelMembers.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_Members).ToString(); m_labelAutoAcceptMember.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_AutoAccept).ToString(); m_labelAutoAcceptPeace.Text = MyTexts.Get(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequest).ToString(); m_labelAutoAcceptMember.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptToolTip); m_labelAutoAcceptPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequestToolTip); m_textFactionDesc = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("textFactionDesc"); m_textFactionPriv = (MyGuiControlMultilineText)controlsParent.Controls.GetControlByName("textFactionPrivate"); m_textFactionDesc.BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK; m_textFactionPriv.BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK; m_tableMembers = (MyGuiControlTable)controlsParent.Controls.GetControlByName("tableMembers"); m_tableMembers.SetColumnComparison(1, (a, b) => ((int)((MyMemberComparerEnum)a.UserData)).CompareTo((int)((MyMemberComparerEnum)b.UserData))); m_tableMembers.ItemSelected += OnTableItemSelected; m_checkAutoAcceptMember = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("checkFactionMembersAcceptEveryone"); m_checkAutoAcceptPeace = (MyGuiControlCheckbox)controlsParent.Controls.GetControlByName("checkFactionMembersAcceptPeace"); m_checkAutoAcceptMember.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptToolTip); m_checkAutoAcceptPeace.SetToolTip(MySpaceTexts.TerminalTab_Factions_AutoAcceptRequestToolTip); m_checkAutoAcceptMember.IsCheckedChanged += OnAutoAcceptChanged; m_checkAutoAcceptPeace.IsCheckedChanged += OnAutoAcceptChanged; m_buttonEdit = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonEdit"); m_buttonPromote = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonPromote"); m_buttonKick = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonKick"); m_buttonAcceptJoin = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAcceptJoin"); m_buttonDemote = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonDemote"); m_buttonAddNpc = (MyGuiControlButton)controlsParent.Controls.GetControlByName("buttonAddNpc"); m_buttonEdit.TextEnum = MyCommonTexts.Edit; m_buttonPromote.TextEnum = MyCommonTexts.Promote; m_buttonKick.TextEnum = MyCommonTexts.Kick; m_buttonAcceptJoin.TextEnum = MyCommonTexts.Accept; m_buttonDemote.TextEnum = MyCommonTexts.Demote; m_buttonAddNpc.TextEnum = MySpaceTexts.AddNpcToFaction; m_buttonAddNpc.SetToolTip(MySpaceTexts.AddNpcToFactionHelp); m_buttonEdit.ButtonClicked += OnCreateClicked; m_buttonPromote.ButtonClicked += OnPromotePlayerClicked; m_buttonKick.ButtonClicked += OnKickPlayerClicked; m_buttonAcceptJoin.ButtonClicked += OnAcceptJoinClicked; m_buttonDemote.ButtonClicked += OnDemoteClicked; m_buttonAddNpc.ButtonClicked += OnNewNpcClicked; MySession.Static.Factions.FactionCreated += OnFactionCreated; MySession.Static.Factions.FactionEdited += OnFactionEdited; MySession.Static.Factions.FactionStateChanged += OnFactionsStateChanged; MySession.Static.Factions.FactionAutoAcceptChanged += OnAutoAcceptChanged; Refresh(); }
private void OnTableItemConfirmedOrDoubleClick(MyGuiControlTable sender, MyGuiControlTable.EventArgs eventArgs) { if (sender.SelectedRow == null) return; var moveTo = sender == m_modsTableEnabled ? m_modsTableDisabled : m_modsTableEnabled; MoveSelectedItem(sender, moveTo); }
private int TableSortingComparison(MyGuiControlTable.Cell a, MyGuiControlTable.Cell b) { if (((MyGps)a.UserData).DiscardAt != null && ((MyGps)b.UserData).DiscardAt != null || ((MyGps)a.UserData).DiscardAt == null && ((MyGps)b.UserData).DiscardAt == null) {//sort by name return a.Text.CompareToIgnoreCase(b.Text); } else {//final first if (((MyGps)a.UserData).DiscardAt == null) return -1; else return 1; } }
private void RefreshRightSideButtons(MyGuiControlTable.Row selected) { m_buttonPromote.Enabled = false; m_buttonKick.Enabled = false; m_buttonAcceptJoin.Enabled = false; m_buttonDemote.Enabled = false; if (selected != null) { var data = (MyFactionMember)selected.UserData; m_selectedUserId = data.PlayerId; var identity = Sync.Players.TryGetIdentity(data.PlayerId); m_selectedUserName = identity.DisplayName; if (m_selectedUserId != MySession.Static.LocalPlayerId) { if (m_userIsFounder && m_userFaction.IsLeader(m_selectedUserId)) { m_buttonKick.Enabled = true; m_buttonDemote.Enabled = true; } else if (m_userIsFounder && m_userFaction.IsMember(m_selectedUserId)) { m_buttonKick.Enabled = true; m_buttonPromote.Enabled = true; } else if (m_userIsLeader && m_userFaction.IsMember(m_selectedUserId) && !m_userFaction.IsLeader(m_selectedUserId) && !m_userFaction.IsFounder(m_selectedUserId)) { m_buttonKick.Enabled = true; } else if ((m_userIsLeader || m_userIsFounder) && m_userFaction.JoinRequests.ContainsKey(m_selectedUserId)) m_buttonAcceptJoin.Enabled = true; } } }
public void Close() { if (m_shipsInRange != null) { m_shipsInRange.ItemSelected -= shipsInRange_ItemSelected; m_shipsInRange.ClearItems(); m_shipsInRange = null; } if (m_shipsData != null) { m_shipsData.ItemDoubleClicked -= shipsData_ItemDoubleClicked; m_shipsData.ColumnClicked -= shipsData_ColumnClicked; m_shipsData.Clear(); m_shipsData = null; } if (m_button != null) { m_button.ButtonClicked -= Menu_ButtonClicked; m_button = null; } }