void OnVideoTextboxChanged(MyGuiControlTextbox source) { if (source.Text.Length == 0 || MyGuiSandbox.IsUrlWhitelisted(source.Text)) { source.SetToolTip((MyToolTips)null); source.ColorMask = Vector4.One; m_okButton.Enabled = true; } else { source.SetToolTip(MySpaceTexts.WwwLinkNotAllowed); source.ColorMask = Color.Red.ToVector4(); m_okButton.Enabled = false; } }
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; }
protected static readonly Vector2 MIDDLE_PART_ORIGIN = -RESERVED_SIZE / 2 + new Vector2(0, 0.17f);//you can use this to put items into right place in the middle public MyGuiScreenTrigger(MyTrigger trg, Vector2 size) : base(null, MyGuiConstants.SCREEN_BACKGROUND_COLOR, size + RESERVED_SIZE) { size += RESERVED_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_textboxMessage = new MyGuiControlTextbox( position: m_itemPos, defaultText: trg.Message, maxLength: 85); m_textboxName.Position = m_textboxName.Position - new Vector2(m_textboxMessage.Size.X / 2, 0);//line to the left of textbox Controls.Add(m_textboxName); Controls.Add(m_textboxMessage); //below middle part, position from bottom: m_itemPos.Y = Size.Value.Y * 0.5f - 0.3f; m_wwwLabel = new MyGuiControlLabel( position: m_itemPos, text: MyTexts.Get(MySpaceTexts.GuiTriggerWwwLink).ToString() ); m_itemPos.Y += m_wwwLabel.Size.Y + VERTICAL_OFFSET; m_wwwTextbox = new MyGuiControlTextbox( position: m_itemPos, defaultText: trg.WwwLink, maxLength: 300); m_itemPos.Y += m_wwwTextbox.Size.Y + VERTICAL_OFFSET; m_wwwLabel.Position = m_wwwLabel.Position - new Vector2(m_wwwTextbox.Size.X / 2, 0);//line to the left of textbox m_wwwTextbox.TextChanged += OnWwwTextChanged; Controls.Add(m_wwwLabel); Controls.Add(m_wwwTextbox); m_nextMisLabel = new MyGuiControlLabel( position: m_itemPos, text: MyTexts.Get(MySpaceTexts.GuiTriggerNextMission).ToString() ); m_itemPos.Y += m_wwwLabel.Size.Y + VERTICAL_OFFSET; m_nextMisTextbox = new MyGuiControlTextbox( position: m_itemPos, defaultText: m_trigger.NextMission, maxLength: 300); m_itemPos.Y += m_wwwTextbox.Size.Y + VERTICAL_OFFSET; m_nextMisLabel.Position = m_nextMisLabel.Position - new Vector2(m_nextMisTextbox.Size.X / 2, 0);//line to the left of textbox m_nextMisTextbox.SetToolTip(MySpaceTexts.GuiTriggerNextMissionTooltip); Controls.Add(m_nextMisLabel); Controls.Add(m_nextMisTextbox); Vector2 buttonOrigin = new Vector2(0f, Size.Value.Y * 0.5f - 0.05f); 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_okButton); Controls.Add(m_cancelButton); OnWwwTextChanged(m_wwwTextbox); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); var left = -0.23f; var top = -0.23f; var spacingV = 0.045f; var buttonSize = new Vector2(0.29f, 0.052f); var composite = new MyGuiControlCompositePanel() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2(0.46f, 0.46f) }; left += 0.005f; top += 0.007f; var panel = new MyGuiControlPanel() { OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, Position = new Vector2(left, top), Size = new Vector2(0.451f, 0.038f), BackgroundTexture = MyGuiConstants.TEXTURE_HIGHLIGHT_DARK }; left += 0.005f; top += 0.003f; // LABELS var headerText = MyTexts.GetString((m_editFaction == null) ? MySpaceTexts.TerminalTab_Factions_CreateFaction : MySpaceTexts.TerminalTab_Factions_EditFaction); var headerLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top), text: headerText); top += 0.01f; var shortcutLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionTag)); var nameLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + 2f * spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionName)); var descLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + 3f * spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionDescription)); var secretLabel = new MyGuiControlLabel(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, size: buttonSize, position: new Vector2(left, top + 4f * spacingV), text: MyTexts.GetString(MySpaceTexts.TerminalTab_Factions_CreateFactionPrivateInfo)); shortcutLabel.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionTagToolTip); secretLabel.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionPrivateInfoToolTip); Controls.Add(composite); Controls.Add(panel); Controls.Add(headerLabel); Controls.Add(shortcutLabel); Controls.Add(nameLabel); Controls.Add(descLabel); Controls.Add(secretLabel); // INPUTS var iLeft = 0.06f; var iTop = -0.15f; m_shortcut = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop), maxLength: 3, defaultText: (m_editFaction != null) ? m_editFaction.Tag : ""); m_name = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop + spacingV), maxLength: 64, defaultText: (m_editFaction != null) ? m_editFaction.Name : ""); m_desc = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop + 2f * spacingV), maxLength: 512, defaultText: (m_editFaction != null) ? m_editFaction.Description : ""); m_privInfo = new MyGuiControlTextbox(position: new Vector2(iLeft, iTop + 3f * spacingV), maxLength: 512, defaultText: (m_editFaction != null) ? m_editFaction.PrivateInfo : ""); m_shortcut.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionTagToolTip); m_privInfo.SetToolTip(MySpaceTexts.TerminalTab_Factions_CreateFactionPrivateInfoToolTip); Controls.Add(m_shortcut); Controls.Add(m_name); Controls.Add(m_desc); Controls.Add(m_privInfo); // BUTTONS top -= 0.003f; Controls.Add(new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM, size: buttonSize, position: new Vector2(left, -top), text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick)); Controls.Add(new MyGuiControlButton(originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM, size: buttonSize, position: new Vector2(-left, -top), text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick)); }
protected virtual void BuildControls() { if (m_isNewGame) { //AddCaption(MyCommonTexts.ScreenCaptionCustomWorld); } else { AddCaption(MyCommonTexts.ScreenCaptionEditSettings); } int numControls = 0; float MARGIN_TOP = m_isNewGame ? 0.18f : 0.1f; float MARGIN_BOTTOM = 0.11f; float MARGIN_LEFT = m_isNewGame ? 0.23f : 0.03f; float MARGIN_RIGHT = m_isNewGame ? 0.03f : 0.03f; float MARGIN_BOTTOM_LISTBOX = 0.015f; // Automatic layout. Vector2 originL, originC, sizeL, sizeC, sizeControls; Vector2 controlsDelta = new Vector2(0f, 0.052f); float rightColumnOffset; originL = -m_size.Value / 2 + new Vector2(MARGIN_LEFT, MARGIN_TOP) + controlsDelta / 2; sizeControls = m_size.Value / 2 - originL; sizeControls.X -= MARGIN_RIGHT + 0.005f; sizeControls.Y -= MARGIN_BOTTOM; sizeL = sizeControls * (m_isNewGame ? 0.44f : 0.395f); originC = originL + new Vector2(sizeL.X, 0f); sizeC = sizeControls - sizeL; //rightColumnOffset = originC.X + m_onlineMode.Size.X - labelSize - 0.017f; // Button positioning Vector2 buttonSize = MyGuiConstants.BACK_BUTTON_SIZE; Vector2 buttonsOrigin = m_size.Value / 2; buttonsOrigin.X -= MARGIN_RIGHT; buttonsOrigin.Y -= 0.03f; 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 soundModeLabel = MakeLabel(MySpaceTexts.WorldSettings_SoundMode); 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(sizeC.X, 0.04f)); m_environment = new MyGuiControlCombobox(size: new Vector2(sizeC.X, 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(sizeC.X, 0.04f)); m_asteroidAmountCombo.ItemSelected += m_asteroidAmountCombo_ItemSelected; m_soundModeCombo = new MyGuiControlCombobox(size: new Vector2(sizeC.X, 0.04f)); m_scenarioTypesList = new MyGuiControlList(); // Ok/Cancel m_cancelButton = new MyGuiControlButton(position: buttonsOrigin, size: buttonSize, text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM); buttonsOrigin.X -= m_cancelButton.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X; m_okButton = new MyGuiControlButton(position: buttonsOrigin, size: buttonSize, text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkButtonClick, originAlign: MyGuiDrawAlignEnum.HORISONTAL_RIGHT_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; m_soundModeCombo.AddItem((int)MySoundModeEnum.Arcade, MySpaceTexts.WorldSettings_ArcadeSound); m_soundModeCombo.AddItem((int)MySoundModeEnum.Realistic, MySpaceTexts.WorldSettings_RealisticSound); if (m_isNewGame) { if (MyDefinitionManager.Static.GetScenarioDefinitions().Count == 0) { MyDefinitionManager.Static.LoadScenarios(); } m_scenarioTypesGroup = new MyGuiControlRadioButtonGroup(); m_scenarioTypesGroup.SelectedChanged += scenario_SelectedChanged; RefreshCustomWorldsList(); } 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_soundModeCombo.SetToolTip(MyTexts.GetString(MySpaceTexts.ToolTipWorldSettingsSoundMode)); m_nameTextbox.TextChanged += m_nameTextbox_TextChanged; m_soundModeCombo.ItemSelected += m_soundModeCombo_ItemSelected; var advanced = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MySpaceTexts.WorldSettings_Advanced), onButtonClick: OnAdvancedClick); #if !XB1 // XB1_NOWORKSHOP var mods = new MyGuiControlButton(highlightType: MyGuiControlHighlightType.WHEN_ACTIVE, text: MyTexts.Get(MyCommonTexts.WorldSettings_Mods), onButtonClick: OnModsClick); #endif // !XB1 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); if (MyFakes.ENABLE_NEW_SOUNDS) { Controls.Add(soundModeLabel); Controls.Add(m_soundModeCombo); } 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 blockLimitsLabel = MakeLabel(MyCommonTexts.WorldSettings_BlockLimits); m_blockLimits = new MyGuiControlCheckbox(); m_blockLimits.IsCheckedChanged = blockLimits_CheckedChanged; m_blockLimits.SetToolTip(MyTexts.GetString(MyCommonTexts.ToolTipWorldSettingsBlockLimits)); Controls.Add(blockLimitsLabel); Controls.Add(m_blockLimits); 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); #if !XB1 // XB1_NOWORKSHOP if (!MyFakes.XB1_PREVIEW) { if (MyFakes.ENABLE_WORKSHOP_MODS) { Controls.Add(mods); } } #endif // !XB1 Controls.Add(advanced); // Uncomment to show the World generator button again if (m_isNewGame && MyFakes.ENABLE_PLANETS == true) { Controls.Add(m_worldGeneratorButton); } 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); m_nameTextbox.Size = m_onlineMode.Size; m_descriptionTextbox.Size = m_nameTextbox.Size; if (m_isNewGame) { Vector2 scenarioPosition = -m_size.Value / 2 + new Vector2(0.015f, MARGIN_TOP); m_scenarioTypesList.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_scenarioTypesList.Position = scenarioPosition; m_scenarioTypesList.Size = new Vector2(MyGuiConstants.LISTBOX_WIDTH, m_size.Value.Y - 0.02f - MARGIN_TOP); 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; #if !XB1 // XB1_NOWORKSHOP mods.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; mods.Position = advanced.Position - new Vector2(advanced.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X, 0); #endif // !XB1 m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = advanced.Position - new Vector2(advanced.Size.X + MyGuiConstants.GENERIC_BUTTON_SPACING.X, -0.06f); if (MyFakes.XB1_PREVIEW) { var pos2p = m_worldGeneratorButton.Position; pos2p.X = Size.HasValue ? Size.Value.X / 2.0f - m_worldGeneratorButton.Size.X - MARGIN_RIGHT : 0.0f; m_worldGeneratorButton.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; m_worldGeneratorButton.Position = pos2p; advanced.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM; if (m_isNewGame) { advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0); } else { advanced.Position = m_worldGeneratorButton.Position - new Vector2(m_worldGeneratorButton.Size.X + 0.017f, 0.008f); } } Controls.Add(m_okButton); Controls.Add(m_cancelButton); CloseButtonEnabled = true; }
/// <summary> /// Builds the menu to spawn planets /// </summary> /// <param name="table">Tablet to add editing elements to</param> private void CreatePlanetSpawnMenu(MyGuiControlParentTableLayout table) { var settings = MySettingsSession.Static.Settings.GeneratorSettings; MyGuiControlLabel defLabel = new MyGuiControlLabel(null, null, "Planet"); table.AddTableRow(defLabel); m_planetDefList = new MyGuiControlListbox(); m_planetDefList.VisibleRowsCount = 8; m_planetDefList.MultiSelect = false; table.AddTableRow(m_planetDefList); table.AddTableSeparator(); MyGuiControlLabel sizeLabel = new MyGuiControlLabel(null, null, "Planet size"); table.AddTableRow(sizeLabel); m_planetSizeSlider = new MyGuiControlClickableSlider(null, 1f, settings.PlanetSettings.PlanetSizeCap, m_usableWidth - 0.1f, intValue: true, showLabel: true, labelSuffix: " m"); m_planetSizeSlider.DefaultValue = Math.Min(120000, settings.PlanetSettings.PlanetSizeCap); m_planetSizeSlider.Value = m_planetSizeSlider.DefaultValue.Value; m_planetSizeSlider.SetToolTip(MyPluginTexts.TOOLTIPS.ADMIN_PLANET_DIAM); table.AddTableRow(m_planetSizeSlider); table.AddTableSeparator(); MyGuiControlLabel nameLabel = new MyGuiControlLabel(null, null, "Name"); table.AddTableRow(nameLabel); m_nameBox = new MyGuiControlTextbox(); m_nameBox.Size = new Vector2(m_usableWidth, m_nameBox.Size.Y); m_nameBox.SetToolTip(MyPluginTexts.TOOLTIPS.ADMIN_NAME); table.AddTableRow(m_nameBox); table.AddTableSeparator(); m_spawnPlanetButton = MyPluginGuiHelper.CreateDebugButton(m_usableWidth, "Spawn planet", delegate(MyGuiControlButton button) { OnSpawnPlanet(); }); m_spawnPlanetButton.Enabled = false; m_spawnPlanetButton.SetToolTip(MyPluginTexts.TOOLTIPS.ADMIN_PLANET_SPAWN); table.AddTableRow(m_spawnPlanetButton); m_spawnPlanetCoordsButton = MyPluginGuiHelper.CreateDebugButton(m_usableWidth, "Spawn planet at coordinates", delegate(MyGuiControlButton button) { OnSpawnPlanet(true); }); m_spawnPlanetCoordsButton.Enabled = false; m_spawnPlanetCoordsButton.SetToolTip(MyPluginTexts.TOOLTIPS.ADMIN_PLANET_SPAWN_COORD); table.AddTableRow(m_spawnPlanetCoordsButton); m_planetDefList.ItemClicked += delegate(MyGuiControlListbox box) { if (box.SelectedItems[box.SelectedItems.Count - 1] != null) { m_spawnPlanetButton.Enabled = true; m_spawnPlanetCoordsButton.Enabled = true; } else { m_spawnPlanetButton.Enabled = false; m_spawnPlanetCoordsButton.Enabled = false; } }; LoadPlanetDefs(m_planetDefList); }
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++, MyCommonTexts.ScreenMenuButtonJoinWorld, MyCommonTexts.ScreenMenuButtonJoinWorld, null)); page.Controls.Add(m_refreshButton = MakeButton(buttonOrigin + buttonDelta * numControls++, MyCommonTexts.ScreenLoadSubscribedWorldRefresh, MyCommonTexts.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 = MyCommonTexts.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(MyCommonTexts.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, ActivateOnMouseRelease = true }; 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(MyCommonTexts.MultiplayerCompatibleVersions), toolTip: MyTexts.GetString(MyCommonTexts.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(MyCommonTexts.MultiplayerJoinSameGameData), toolTip: MyTexts.GetString(MyCommonTexts.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(MyCommonTexts.MultiplayerJoinFriendsGames), toolTip: MyTexts.GetString(MyCommonTexts.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(MyCommonTexts.MultiplayerJoinAllowedGroups), toolTip: MyTexts.GetString(MyCommonTexts.MultiplayerJoinAllowedGroups), onButtonClick: OnAllowedGroupsTextClick, visualStyle: MyGuiControlButtonStyleEnum.ClickableText, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); page.Controls.Add(m_allowedGroupsText); }