private void OnJoinLobby(MyGuiControlButton obj) { JoinSelectedLobby(); }
public void OnCancelClick(MyGuiControlButton sender) { CloseScreen(); MyGuiManager.AddScreen(new MyGuiScreenEditorGroups()); }
private void OnRefreshFavoritesServersClick(MyGuiControlButton obj) { RefreshFavoritesGameList(); }
private void OnAcceptFriendClicked(MyGuiControlButton sender) { MySession.Static.Factions.AcceptPeace(m_userFaction.FactionId, m_selectedFaction.FactionId); }
private void OnEnemyClicked(MyGuiControlButton sender) { MySession.Static.Factions.DeclareWar(m_userFaction.FactionId, m_selectedFaction.FactionId); }
private void OnAllowedGroupsTextClick(MyGuiControlButton button) { m_allowedGroups.IsChecked = !m_allowedGroups.IsChecked; }
private void OnCreateClicked(MyGuiControlButton sender) { MyGuiSandbox.AddScreen(new MyGuiScreenCreateOrEditFaction(ref m_userFaction)); }
private void OnClickGameWeb(MyGuiControlButton sender) { MyGuiSandbox.OpenUrl(MyPerGameSettings.GameWebUrl, UrlOpenMode.SteamOrExternalWithConfirm); }
private void OnClickPlayers(MyGuiControlButton obj) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.PlayersScreen)); }
// Because only main menu's controla depends on fullscreen pixel coordinates (not normalized), after we change // screen resolution we need to recreate controls too. Otherwise they will be still on old/bad positions, and // for example when changing from 1920x1200 to 800x600 they would be out of screen public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); // Enable background fade when we're in game, but in main menu we disable it. var buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui; Vector2 leftButtonPositionOrigin = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM) + new Vector2(buttonSize.X / 2f, 0f); Vector2 rightButtonPositionOrigin = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM) + new Vector2(-buttonSize.X / 2f, 0f); // In main menu if (MyGuiScreenGamePlay.Static == null) { EnabledBackgroundFade = false; // Left main menu part var a = MyGuiManager.GetSafeFullscreenRectangle(); var fullScreenSize = new Vector2(a.Width / (a.Height * (4 / 3f)), 1f); // New Game // Load world // Join world // Workshop // // Options // Help // Credits // Exit to windows int buttonIndex = MyPerGameSettings.MultiplayerEnabled ? 8 : 7; if (MyFakes.XB1_PREVIEW) { buttonIndex = MyPerGameSettings.MultiplayerEnabled ? 7 : 6; } Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonNewWorld, OnClickNewWorld)); Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonLoadWorld, OnClickLoad)); if (MyPerGameSettings.MultiplayerEnabled) { Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonJoinWorld, OnJoinWorld)); } if (!MyFakes.XB1_PREVIEW) { #if !XB1 // XB1_NOWORKSHOP Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonSubscribedWorlds, OnClickSubscribedWorlds, MyCommonTexts.ToolTipMenuSubscribedWorlds)); #endif // !XB1 } --buttonIndex; Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonOptions, OnClickOptions)); Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonHelp, OnClickHelp)); Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonCredits, OnClickCredits)); Controls.Add(MakeButton(leftButtonPositionOrigin - (buttonIndex--) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonExitToWindows, OnClickExitToWindows)); Vector2 textRightTopPosition = MyGuiManager.GetScreenTextRightTopPosition(); Vector2 position = textRightTopPosition + 8f * MyGuiConstants.CONTROLS_DELTA + new Vector2(-.1f, .06f); } else // In-game { MyAnalyticsHelper.ReportActivityStart(null, "show_main_menu", string.Empty, "gui", string.Empty); EnabledBackgroundFade = true; int buttonRowIndex = Sync.MultiplayerActive ? 6 : 5; // Save // Load button (only on dev) // // Options // Help // Exit to main menu var saveButton = MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonSave, OnClickSaveWorld); var saveAsButton = MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.LoadScreenButtonSaveAs, OnClickSaveAs); if (!Sync.IsServer || (MySession.Static.Battle)) { saveButton.Enabled = false; saveButton.ShowTooltipWhenDisabled = true; saveButton.SetToolTip(MyCommonTexts.NotificationClientCannotSave); saveAsButton.Enabled = false; saveButton.ShowTooltipWhenDisabled = true; saveButton.SetToolTip(MyCommonTexts.NotificationClientCannotSave); } Controls.Add(saveButton); Controls.Add(saveAsButton); // --buttonRowIndex; // empty line if (Sync.MultiplayerActive) { Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonPlayers, OnClickPlayers)); } Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonOptions, OnClickOptions)); Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonHelp, OnClickHelp)); Controls.Add(MakeButton(leftButtonPositionOrigin - ((float)(--buttonRowIndex)) * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyCommonTexts.ScreenMenuButtonExitToMainMenu, OnExitToMainMenuClick)); } var logoPanel = new MyGuiControlPanel( position: MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, 54, 84), size: MyGuiConstants.TEXTURE_KEEN_LOGO.MinSizeGui, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP ); logoPanel.BackgroundTexture = MyGuiConstants.TEXTURE_KEEN_LOGO; Controls.Add(logoPanel); // Recommend button Vector2 pos = rightButtonPositionOrigin - 8f * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA; Controls.Add(MakeButton(pos, MyCommonTexts.ScreenMenuButtonRecommend, OnClickRecommend)); m_newsControl = new MyGuiControlNews() { Position = MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM) - 7f * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, Size = new Vector2(0.4f, 0.28f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP, }; Controls.Add(m_newsControl); var webButton = MakeButton( MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM, 70), MySpaceTexts.Blank, OnClickGameWeb); webButton.Text = MyPerGameSettings.GameWebUrl; webButton.VisualStyle = MyGuiControlButtonStyleEnum.UrlText; Controls.Add(webButton); var reportButton = MakeButton( new Vector2(m_newsControl.Position.X, m_newsControl.Position.Y + m_newsControl.Size.Y), //MyGuiManager.ComputeFullscreenGuiCoordinate(MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM, 140,80), MyCommonTexts.ReportBug, OnClickReportBug); reportButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP; reportButton.VisualStyle = MyGuiControlButtonStyleEnum.UrlText; Controls.Add(reportButton); m_newsControl.State = MyGuiControlNews.StateEnum.Loading; DownloadNews(); CheckLowMemSwitchToLow(); }
private void OnClickReportBug(MyGuiControlButton obj) { MyGuiSandbox.OpenUrl(MyPerGameSettings.BugReportUrl, UrlOpenMode.SteamOrExternalWithConfirm, MyTexts.AppendFormat(new StringBuilder(), MyCommonTexts.MessageBoxTextOpenBrowser, "forums.keenswh.com")); }
void HelpButtonClicked(MyGuiControlButton button) { MyGuiSandbox.OpenUrlWithFallback(MySteamConstants.URL_BROWSE_WORKSHOP_INGAMESCRIPTS_HELP, "Steam Workshop"); }
void OpenWorkshopButtonClicked(MyGuiControlButton button) { DisableButtons(); MyScreenManager.AddScreen(new MyGuiIngameScriptsPage(ScriptSelected, GetCode, WorkshopWindowClosed)); }
void cancelButton_OnButtonClick(MyGuiControlButton sender) { CloseScreen(); }
private void OnShowOnlySameModsClick(MyGuiControlButton button) { m_showOnlyWithSameMods.IsChecked = !m_showOnlyWithSameMods.IsChecked; }
private void OnClickCredits(MyGuiControlButton sender) { //opens dialog screen with list of trailers, where could be selected animation to play MyGuiSandbox.AddScreen(new MyGuiScreenGameCredits()); }
private void OnFriendsOnlyTextClick(MyGuiControlButton button) { m_showOnlyFriends.IsChecked = !m_showOnlyFriends.IsChecked; }
private void OnClickHelp(MyGuiControlButton sender) { MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HelpScreen)); }
private void BlockSearchClear_ButtonClicked(MyGuiControlButton obj) { m_blockSearch.Text = ""; }
void OnClickSaveAs(MyGuiControlButton sender) { MyGuiSandbox.AddScreen(new MyGuiScreenSaveAs(MySession.Static.Name)); }
private void OnCancelJoinClicked(MyGuiControlButton sender) { MySession.Static.Factions.CancelJoinRequest(m_selectedFaction.FactionId, MySession.LocalPlayerId); }
void OnRestoreButtonClicked(MyGuiControlButton button) { m_atmosphereSettings = m_originalAtmosphereSettings; RecreateControls(false); UpdateAtmosphere(); }
private void OnCancelPeaceRequestClicked(MyGuiControlButton sender) { MySession.Static.Factions.CancelPeaceRequest(m_userFaction.FactionId, m_selectedFaction.FactionId); }
void OnResetButtonClicked(MyGuiControlButton button) { m_atmosphereSettings = MyAtmosphereSettings.Defaults(); RecreateControls(false); UpdateAtmosphere(); }
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_buttonEdit.TextEnum = MySpaceTexts.Edit; m_buttonPromote.TextEnum = MySpaceTexts.Promote; m_buttonKick.TextEnum = MySpaceTexts.Kick; m_buttonAcceptJoin.TextEnum = MySpaceTexts.Accept; m_buttonDemote.TextEnum = MySpaceTexts.Demote; m_buttonEdit.ButtonClicked += OnCreateClicked; m_buttonPromote.ButtonClicked += OnPromotePlayerClicked; m_buttonKick.ButtonClicked += OnKickPlayerClicked; m_buttonAcceptJoin.ButtonClicked += OnAcceptJoinClicked; m_buttonDemote.ButtonClicked += OnDemoteClicked; MySession.Static.Factions.FactionCreated += OnFactionCreated; MySession.Static.Factions.FactionEdited += OnFactionEdited; MySession.Static.Factions.FactionStateChanged += OnFactionsStateChanged; MySession.Static.Factions.FactionAutoAcceptChanged += OnAutoAcceptChanged; Refresh(); }
void InitPageControls(MyGuiControlTabPage page) { page.Controls.Clear(); var origin = new Vector2(-0.64f, -0.35f); Vector2 buttonSize = MyGuiControlButton.GetVisualStyle(MyGuiControlButtonStyleEnum.Default).NormalTexture.MinSizeGui; m_gamesTable = new MyGuiControlTable(); m_gamesTable.Position = origin + new Vector2(buttonSize.X, 0f); m_gamesTable.Size = new Vector2(1465f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, 1f); m_gamesTable.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_gamesTable.VisibleRowsCount = 16; page.Controls.Add(m_gamesTable); Vector2 buttonOrigin = origin + new Vector2(0.28f, 0.66f); Vector2 buttonDelta = new Vector2(0.2f, 0.0f); int numControls = 0; page.Controls.Add(m_joinButton = MakeButton(buttonOrigin + buttonDelta * numControls++, MySpaceTexts.ScreenMenuButtonJoinWorld, MySpaceTexts.ScreenMenuButtonJoinWorld, null)); page.Controls.Add(m_refreshButton = MakeButton(buttonOrigin + buttonDelta * numControls++, MySpaceTexts.ScreenLoadSubscribedWorldRefresh, MySpaceTexts.ScreenLoadSubscribedWorldRefresh, null)); m_joinButton.Enabled = false; var checkboxPos = buttonOrigin + new Vector2(-0.09f, -0.02f) + numControls * buttonDelta; var checkBoxDelta = new Vector2(0.0f, 0.04f); var blockSearchLabel = new MyGuiControlLabel() { Position = checkboxPos + new Vector2(0f, -0.04f), Size = new Vector2(0.05f, 0.02f), TextEnum = MySpaceTexts.JoinGame_SearchLabel }; page.Controls.Add(blockSearchLabel); m_blockSearch = new MyGuiControlTextbox() { Position = blockSearchLabel.Position + new Vector2(0.255f, 0f), Size = new Vector2(0.27f, 0.02f) }; m_blockSearch.SetToolTip(MySpaceTexts.JoinGame_SearchTooltip); m_blockSearch.TextChanged += OnBlockSearchTextChanged; page.Controls.Add(m_blockSearch); m_blockSearchClear = new MyGuiControlButton() { Position = m_blockSearch.Position + new Vector2(0.13f, 0f), OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER, VisualStyle = MyGuiControlButtonStyleEnum.Close }; m_blockSearchClear.ButtonClicked += BlockSearchClear_ButtonClicked; page.Controls.Add(m_blockSearchClear); numControls = 0; m_showOnlyCompatibleText = new MyGuiControlButton( position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0), text: MyTexts.Get(MySpaceTexts.MultiplayerCompatibleVersions), toolTip: MyTexts.GetString(MySpaceTexts.MultiplayerCompatibleVersions), onButtonClick: OnShowOnlyCompatibleTextClick, visualStyle: MyGuiControlButtonStyleEnum.ClickableText, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); page.Controls.Add(m_showOnlyCompatibleText); bool compatibleChecked = true; if (m_showOnlyCompatibleGames != null) { compatibleChecked = m_showOnlyCompatibleGames.IsChecked; } m_showOnlyCompatibleGames = new MyGuiControlCheckbox(checkboxPos + checkBoxDelta * numControls++, null, null, MySandboxGame.Config.MultiplayerShowCompatible, MyGuiControlCheckboxStyleEnum.Debug, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_showOnlyCompatibleGames.IsChecked = compatibleChecked; page.Controls.Add(m_showOnlyCompatibleGames); bool showSameMods = true; if (m_showOnlyWithSameMods != null) { showSameMods = m_showOnlyWithSameMods.IsChecked; } m_showOnlyWithSameMods = new MyGuiControlCheckbox( position: checkboxPos + checkBoxDelta * numControls, visualStyle: MyGuiControlCheckboxStyleEnum.Debug, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_showOnlyWithSameMods.IsChecked = showSameMods; page.Controls.Add(m_showOnlyWithSameMods); m_showOnlyWithSameText = new MyGuiControlButton( position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0), text: MyTexts.Get(MySpaceTexts.MultiplayerJoinSameGameData), toolTip: MyTexts.GetString(MySpaceTexts.MultiplayerJoinSameGameData), onButtonClick: OnShowOnlySameModsClick, visualStyle: MyGuiControlButtonStyleEnum.ClickableText, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); page.Controls.Add(m_showOnlyWithSameText); checkboxPos = buttonOrigin + new Vector2(-0.09f, -0.02f) + 3 * buttonDelta; numControls = 0; bool showOnlyFriends = false; if (m_showOnlyFriends != null) { showOnlyFriends = m_showOnlyFriends.IsChecked; } m_showOnlyFriends = new MyGuiControlCheckbox( position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0), visualStyle: MyGuiControlCheckboxStyleEnum.Debug, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_showOnlyFriends.IsChecked = showOnlyFriends; page.Controls.Add(m_showOnlyFriends); m_showOnlyFriendsText = new MyGuiControlButton( position: checkboxPos + checkBoxDelta * numControls++ + new Vector2(buttonSize.Y, 0), text: MyTexts.Get(MySpaceTexts.MultiplayerJoinFriendsGames), toolTip: MyTexts.GetString(MySpaceTexts.MultiplayerJoinFriendsGames), onButtonClick: OnFriendsOnlyTextClick, visualStyle: MyGuiControlButtonStyleEnum.ClickableText, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); page.Controls.Add(m_showOnlyFriendsText); bool allowedGroups = true; if (m_allowedGroups != null) { allowedGroups = m_allowedGroups.IsChecked; } m_allowedGroups = new MyGuiControlCheckbox( position: checkboxPos + checkBoxDelta * numControls + new Vector2(buttonSize.Y * 0.5f, 0), visualStyle: MyGuiControlCheckboxStyleEnum.Debug, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_allowedGroups.IsChecked = allowedGroups; page.Controls.Add(m_allowedGroups); m_allowedGroupsText = new MyGuiControlButton( position: checkboxPos + checkBoxDelta * numControls++ + new Vector2(buttonSize.Y, 0), text: MyTexts.Get(MySpaceTexts.MultiplayerJoinAllowedGroups), toolTip: MyTexts.GetString(MySpaceTexts.MultiplayerJoinAllowedGroups), onButtonClick: OnAllowedGroupsTextClick, visualStyle: MyGuiControlButtonStyleEnum.ClickableText, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); page.Controls.Add(m_allowedGroupsText); }
protected virtual void BuildControls() { Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2 - new Vector2(0.23f, 0.03f); if (m_isNewGame) { AddCaption(MyCommonTexts.ScreenCaptionCustomWorld); } else { AddCaption(MyCommonTexts.ScreenCaptionEditSettings); } int numControls = 0; var nameLabel = MakeLabel(MyCommonTexts.Name); var descriptionLabel = MakeLabel(MyCommonTexts.Description); var gameModeLabel = MakeLabel(MyCommonTexts.WorldSettings_GameMode); var onlineModeLabel = MakeLabel(MyCommonTexts.WorldSettings_OnlineMode); m_maxPlayersLabel = MakeLabel(MyCommonTexts.MaxPlayers); var environmentLabel = MakeLabel(MySpaceTexts.WorldSettings_EnvironmentHostility); var scenarioLabel = MakeLabel(MySpaceTexts.WorldSettings_Scenario); 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_onlineMode = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_environment = 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_asteroidAmountLabel = MakeLabel(MySpaceTexts.Asteroid_Amount); m_asteroidAmountCombo = new MyGuiControlCombobox(size: new Vector2(width, 0.04f)); m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected; m_scenarioTypesList = new MyGuiControlList(); // Ok/Cancel m_okButton = new MyGuiControlButton(position: buttonsOrigin - new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); m_cancelButton = new MyGuiControlButton(position: buttonsOrigin + new Vector2(0.01f, 0f), size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM); m_creativeModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeCreative), onButtonClick: OnCreativeClick); m_creativeModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeCreative); m_survivalModeButton = new MyGuiControlButton(visualStyle: MyGuiControlButtonStyleEnum.Small, highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_GameModeSurvival), onButtonClick: OnSurvivalClick); m_survivalModeButton.SetToolTip(MySpaceTexts.ToolTipWorldSettingsModeSurvival); m_onlineMode.ItemSelected += OnOnlineModeSelect; m_onlineMode.AddItem((int)MyOnlineModeEnum.OFFLINE, MyCommonTexts.WorldSettings_OnlineModeOffline); m_onlineMode.AddItem((int)MyOnlineModeEnum.PRIVATE, MyCommonTexts.WorldSettings_OnlineModePrivate); m_onlineMode.AddItem((int)MyOnlineModeEnum.FRIENDS, MyCommonTexts.WorldSettings_OnlineModeFriends); m_onlineMode.AddItem((int)MyOnlineModeEnum.PUBLIC, MyCommonTexts.WorldSettings_OnlineModePublic); m_environment.AddItem((int)MyEnvironmentHostilityEnum.SAFE, MySpaceTexts.WorldSettings_EnvironmentHostilitySafe); m_environment.AddItem((int)MyEnvironmentHostilityEnum.NORMAL, MySpaceTexts.WorldSettings_EnvironmentHostilityNormal); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysm); m_environment.AddItem((int)MyEnvironmentHostilityEnum.CATACLYSM_UNREAL, MySpaceTexts.WorldSettings_EnvironmentHostilityCataclysmUnreal); m_environment.ItemSelected += HostilityChanged; if (m_isNewGame) { m_scenarioTypesGroup = new MyGuiControlRadioButtonGroup(); m_scenarioTypesGroup.SelectedChanged += scenario_SelectedChanged; foreach (var scenario in MyDefinitionManager.Static.GetScenarioDefinitions()) { if (!scenario.Public && !MyFakes.ENABLE_NON_PUBLIC_SCENARIOS) { continue; } var button = new MyGuiControlScenarioButton(scenario); m_scenarioTypesGroup.Add(button); m_scenarioTypesList.Controls.Add(button); } } m_nameTextbox.SetToolTip(string.Format(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsName), MySession.MIN_NAME_LENGTH, MySession.MAX_NAME_LENGTH)); m_descriptionTextbox.SetToolTip(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsDescription)); m_environment.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsEnvironment)); m_onlineMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsOnlineMode)); m_maxPlayersSlider.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsMaxPlayer)); m_asteroidAmountCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsAsteroidAmount)); m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; var advanced = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Advanced), onButtonClick: OnAdvancedClick); var mods = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_Mods), onButtonClick: OnModsClick); m_worldGeneratorButton = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_WorldGenerator), onButtonClick: OnWorldGeneratorClick); // Add controls in pairs; label first, control second. They will be laid out automatically this way. Controls.Add(nameLabel); Controls.Add(m_nameTextbox); Controls.Add(descriptionLabel); Controls.Add(m_descriptionTextbox); Controls.Add(gameModeLabel); Controls.Add(m_creativeModeButton); Controls.Add(onlineModeLabel); Controls.Add(m_onlineMode); Controls.Add(m_maxPlayersLabel); Controls.Add(m_maxPlayersSlider); if (MyFakes.ENABLE_METEOR_SHOWERS) { Controls.Add(environmentLabel); Controls.Add(m_environment); } if (m_isNewGame && MyFakes.ENABLE_PLANETS == false) { Controls.Add(m_asteroidAmountLabel); Controls.Add(m_asteroidAmountCombo); } var autoSaveLabel = MakeLabel(MyCommonTexts.WorldSettings_AutoSave); m_autoSave = new MyGuiControlCheckbox(); m_autoSave.SetToolTip(new StringBuilder().AppendFormat(MyCommonTexts.ToolTipWorldSettingsAutoSave, MyObjectBuilder_SessionSettings.DEFAULT_AUTOSAVE_IN_MINUTES).ToString()); Controls.Add(autoSaveLabel); Controls.Add(m_autoSave); var scenarioEditModeLabel = MakeLabel(MySpaceTexts.WorldSettings_ScenarioEditMode); m_scenarioEditMode = new MyGuiControlCheckbox(); m_scenarioEditMode.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettings_ScenarioEditMode)); Controls.Add(scenarioEditModeLabel); Controls.Add(m_scenarioEditMode); if (MyFakes.ENABLE_WORKSHOP_MODS) { Controls.Add(mods); } Controls.Add(advanced); if (m_isNewGame && MyFakes.ENABLE_PLANETS == true) { Controls.Add(m_worldGeneratorButton); } float labelSize = 0.20f; float MARGIN_TOP = 0.12f; float MARGIN_BOTTOM = 0.12f; float MARGIN_LEFT = m_isNewGame ? 0.315f : 0.08f; float MARGIN_RIGHT = m_isNewGame ? 0.075f : 0.045f; // 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++; } } Controls.Add(m_survivalModeButton); m_survivalModeButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; m_survivalModeButton.Position = m_creativeModeButton.Position + new Vector2(m_onlineMode.Size.X, 0); if (m_isNewGame) { Vector2 scenarioPosition = new Vector2(-0.375f, nameLabel.Position.Y); m_nameTextbox.Size = m_onlineMode.Size; m_descriptionTextbox.Size = m_nameTextbox.Size; scenarioLabel.Position = scenarioPosition; m_scenarioTypesList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scenarioTypesList.Position = scenarioLabel.Position + new Vector2(0, 0.02f); m_scenarioTypesList.Size = new Vector2(0.19f, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP); Controls.Add(scenarioLabel); Controls.Add(m_scenarioTypesList); MyGuiControlSeparatorList m_verticalLine = new MyGuiControlSeparatorList(); Vector2 position = nameLabel.Position + new Vector2(-0.025f, -0.02f); m_verticalLine.AddVertical(position, m_size.Value.Y - MARGIN_BOTTOM - MARGIN_TOP + 0.04f); Controls.Add(m_verticalLine); } var pos2 = advanced.Position; //pos2.X = m_isNewGame ? 0.160f : 0.0f; pos2.X = Size.HasValue ? Size.Value.X / 2.0f - advanced.Size.X - MARGIN_RIGHT : 0.0f; advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; advanced.Position = pos2; mods.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; mods.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, 0); m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = advanced.Position - new Vector2(advanced.Size.X + 0.017f, -0.06f); Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; }
private void OnShowOnlyCompatibleTextClick(MyGuiControlButton button) { m_showOnlyCompatibleGames.IsChecked = !m_showOnlyCompatibleGames.IsChecked; }
private void OnLoadGroup(MyGuiControlButton sender) { CloseScreen(); MyGuiManager.AddScreen(new MyGuiScreenEditorSelectSector()); }
private void OnRefreshLobbiesClick(MyGuiControlButton obj) { LoadPublicLobbies(); }