private void SortSectors() { // Named sectors first m_mapsCombobox.CustomSortItems((a, b) => { bool aName = string.IsNullOrEmpty(m_sectorIdentifiers[a.Key].SectorName); bool bName = string.IsNullOrEmpty(m_sectorIdentifiers[b.Key].SectorName); return(aName == bName ? a.Value.ToString().CompareTo(b.Value.ToString()) : (aName ? 1 : -1)); }); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MyCommonTexts.ScreenCaptionGameOptions); var leftAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; var rightAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.025f, -m_size.Value.Y / 2.0f + 0.125f); Vector2 controlsOriginRight = new Vector2(m_size.Value.X / 2.0f - 0.025f, -m_size.Value.Y / 2.0f + 0.125f); Vector2 controlsDelta = new Vector2(0, 0.0525f); float rowIndex = 0; // Language var languageLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.Language)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign, }; m_languageCombobox = new MyGuiControlCombobox() { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; foreach (var languageId in MyLanguage.SupportedLanguages) { var description = MyTexts.Languages[languageId]; var name = description.Name; if (description.IsCommunityLocalized) { name += " *"; } m_languageCombobox.AddItem(languageId, name); } m_languageCombobox.CustomSortItems((a, b) => a.Key.CompareTo(b.Key)); m_languageCombobox.ItemSelected += m_languageCombobox_ItemSelected; rowIndex += 0.65f; m_localizationWebButton = new MyGuiControlButton( position: controlsOriginRight + rowIndex * controlsDelta, text: MyTexts.Get(MyCommonTexts.ScreenOptionsGame_MoreInfo), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f, onButtonClick: LocalizationWebButtonClicked, originAlign: rightAlign); m_localizationWebButton.VisualStyle = MyGuiControlButtonStyleEnum.ClickableText; var tmp = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_MoreInfo), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f); m_localizationWarningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_LocalizationWarning), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f) { Position = controlsOriginRight + rowIndex * controlsDelta - new Vector2(tmp.Size.X + 0.005f, 0), OriginAlign = rightAlign, }; rowIndex += 0.8f; if (MyFakes.ENABLE_NON_PUBLIC_GUI_ELEMENTS && MyGuiSkinManager.Static.SkinCount > 0) { m_skinLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_Skin)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign, }; m_skinCombobox = new MyGuiControlCombobox() { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; foreach (var skin in MyGuiSkinManager.Static.AvailableSkins) { m_skinCombobox.AddItem(skin.Key, skin.Value.DisplayNameText); } m_skinCombobox.SelectItemByKey(MyGuiSkinManager.Static.CurrentSkinId); rowIndex += 0.65f; m_skinWarningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_SkinWarning), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; rowIndex += 0.8f; } var buildingModeLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_BuildingMode)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign, }; m_buildingModeCombobox = new MyGuiControlCombobox() { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.SingleBlock, MyCommonTexts.ScreenOptionsGame_SingleBlock); m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.Line, MyCommonTexts.ScreenOptionsGame_Line); m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.Plane, MyCommonTexts.ScreenOptionsGame_Plane); m_buildingModeCombobox.ItemSelected += m_buildingModeCombobox_ItemSelected; // Notifications rowIndex++; var controlHintsLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ShowControlsHints)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_controlHintsCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowControlsHints)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_controlHintsCheckbox.IsCheckedChanged += checkboxChanged; // Rotation gizmo MyGuiControlLabel rotationHintsLabel = null; if (MyFakes.ENABLE_ROTATION_HINTS) { rowIndex++; rotationHintsLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ShowRotationHints)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_rotationHintsCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowRotationHints)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_rotationHintsCheckbox.IsCheckedChanged += checkboxChanged; } // Show crosshair? rowIndex++; var crosshairLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ShowCrosshair)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_crosshairCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowCrosshair)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_crosshairCheckbox.IsCheckedChanged += checkboxChanged; // Headbob rowIndex++; var headbobLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.Headbob)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_disableHeadbobCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.Headbob)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_disableHeadbobCheckbox.IsCheckedChanged += checkboxChanged; // Compress save games checkbox rowIndex++; var compressSavesLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.CompressSaveGames)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_compressSavesCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsCompressSaveGames)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_compressSavesCheckbox.IsCheckedChanged += checkboxChanged; rowIndex++; var showPlayerNamesOnHudLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_ShowPlayerNames)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_showPlayerNamesCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsShowPlayerNames)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_showPlayerNamesCheckbox.IsCheckedChanged += checkboxChanged; rowIndex++; var releasingAltResetsCameraLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_ReleasingAltResetsCamera)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_releasingAltResetsCameraCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsReleasingAltResetsCamera)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_releasingAltResetsCameraCheckbox.IsCheckedChanged += checkboxChanged; rowIndex++; var UIOpacityLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_UIOpacity)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_UIOpacitySlider = new MyGuiControlSlider(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsUIOpacity), minValue: 0.1f, maxValue: 1.0f, defaultValue: 1.0f) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_UIOpacitySlider.ValueChanged += sliderChanged; rowIndex++; var UIBkOpacityLabel = new MyGuiControlLabel(text: MyTexts.GetString(MyCommonTexts.ScreenOptionsGame_UIBkOpacity)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_UIBkOpacitySlider = new MyGuiControlSlider(toolTip: MyTexts.GetString(MyCommonTexts.ToolTipGameOptionsUIBkOpacity), minValue: 0, maxValue: 1.0f, defaultValue: 1.0f) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_UIBkOpacitySlider.ValueChanged += sliderChanged; rowIndex++; // Buttons OK and CANCEL var buttonOk = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Ok), onButtonClick: OnOkClick); var buttonCancel = new MyGuiControlButton(text: MyTexts.Get(MyCommonTexts.Cancel), onButtonClick: OnCancelClick); float buttonX = 0.01f; float buttonY = m_size.Value.Y / 2.0f - (buttonOk.Size.Y + 0.03f); buttonOk.Position = new Vector2(-buttonX, buttonY); buttonOk.OriginAlign = rightAlign; buttonCancel.Position = new Vector2(buttonX, buttonY); buttonCancel.OriginAlign = leftAlign; Controls.Add(languageLabel); Controls.Add(m_languageCombobox); Controls.Add(m_localizationWebButton); Controls.Add(m_localizationWarningLabel); if (MyFakes.ENABLE_NON_PUBLIC_GUI_ELEMENTS && MyGuiSkinManager.Static.SkinCount > 0) { Controls.Add(m_skinLabel); Controls.Add(m_skinCombobox); Controls.Add(m_skinWarningLabel); } Controls.Add(buildingModeLabel); Controls.Add(m_buildingModeCombobox); Controls.Add(controlHintsLabel); if (rotationHintsLabel != null) { Controls.Add(rotationHintsLabel); } Controls.Add(m_controlHintsCheckbox); if (m_rotationHintsCheckbox != null) { Controls.Add(m_rotationHintsCheckbox); } Controls.Add(crosshairLabel); Controls.Add(m_crosshairCheckbox); Controls.Add(headbobLabel); Controls.Add(m_disableHeadbobCheckbox); Controls.Add(compressSavesLabel); Controls.Add(m_compressSavesCheckbox); Controls.Add(showPlayerNamesOnHudLabel); Controls.Add(m_showPlayerNamesCheckbox); Controls.Add(releasingAltResetsCameraLabel); Controls.Add(m_releasingAltResetsCameraCheckbox); Controls.Add(UIOpacityLabel); Controls.Add(m_UIOpacitySlider); Controls.Add(UIBkOpacityLabel); Controls.Add(m_UIBkOpacitySlider); Controls.Add(buttonOk); Controls.Add(buttonCancel); // Update controls with values from config file UpdateControls(constructor); CloseButtonEnabled = true; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption(MySpaceTexts.ScreenCaptionGameOptions); var leftAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; var rightAlign = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.025f, -m_size.Value.Y / 2.0f + 0.125f); Vector2 controlsOriginRight = new Vector2(m_size.Value.X / 2.0f - 0.025f, -m_size.Value.Y / 2.0f + 0.125f); Vector2 controlsDelta = new Vector2(0, 0.0525f); float rowIndex = 0; // Language var languageLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.Language)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign, }; m_languageCombobox = new MyGuiControlCombobox() { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; foreach (var languageId in MyLanguage.SupportedLanguages) { var description = MyTexts.Languages[languageId]; var name = description.Name; if (description.IsCommunityLocalized) { name += " *"; } m_languageCombobox.AddItem(languageId, name); } m_languageCombobox.CustomSortItems((a, b) => a.Key.CompareTo(b.Key)); m_languageCombobox.ItemSelected += m_languageCombobox_ItemSelected; rowIndex += 0.65f; m_localizationWebButton = new MyGuiControlButton( position: controlsOriginRight + rowIndex * controlsDelta, text: MyTexts.Get(MySpaceTexts.ScreenOptionsGame_MoreInfo), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f, onButtonClick: LocalizationWebButtonClicked, implementedFeature: true, originAlign: rightAlign); m_localizationWebButton.VisualStyle = MyGuiControlButtonStyleEnum.ClickableText; var tmp = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScreenOptionsGame_MoreInfo), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f); m_localizationWarningLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScreenOptionsGame_LocalizationWarning), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.85f * 0.85f) { Position = controlsOriginRight + rowIndex * controlsDelta - new Vector2(tmp.Size.X + 0.005f, 0), OriginAlign = rightAlign, }; rowIndex += 0.8f; var buildingModeLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScreenOptionsGame_BuildingMode)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign, }; m_buildingModeCombobox = new MyGuiControlCombobox() { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.SingleBlock, MySpaceTexts.ScreenOptionsGame_SingleBlock); m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.Line, MySpaceTexts.ScreenOptionsGame_Line); m_buildingModeCombobox.AddItem((int)MyCubeBuilder.BuildingModeEnum.Plane, MySpaceTexts.ScreenOptionsGame_Plane); m_buildingModeCombobox.ItemSelected += m_buildingModeCombobox_ItemSelected; // Notifications rowIndex++; var controlHintsLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ShowControlsHints)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_controlHintsCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipGameOptionsShowControlsHints)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_controlHintsCheckbox.IsCheckedChanged += checkboxChanged; // Rotation gizmo rowIndex++; var rotationHintsLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ShowRotationHints)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_rotationHintsCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipGameOptionsShowRotationHints)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_rotationHintsCheckbox.IsCheckedChanged += checkboxChanged; // Show crosshair? rowIndex++; var crosshairLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ShowCrosshair)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_crosshairCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipGameOptionsShowCrosshair)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_crosshairCheckbox.IsCheckedChanged += checkboxChanged; // Headbob rowIndex++; var headbobLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.Headbob)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_disableHeadbobCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.Headbob)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_disableHeadbobCheckbox.IsCheckedChanged += checkboxChanged; // Compress save games checkbox rowIndex++; var compressSavesLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.CompressSaveGames)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_compressSavesCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipGameOptionsCompressSaveGames)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_compressSavesCheckbox.IsCheckedChanged += checkboxChanged; rowIndex++; var showPlayerNamesOnHudLabel = new MyGuiControlLabel(text: MyTexts.GetString(MySpaceTexts.ScreenOptionsGame_ShowPlayerNames)) { Position = controlsOriginLeft + rowIndex * controlsDelta, OriginAlign = leftAlign }; m_showPlayerNamesCheckbox = new MyGuiControlCheckbox(toolTip: MyTexts.GetString(MySpaceTexts.ToolTipGameOptionsShowPlayerNames)) { Position = controlsOriginRight + rowIndex * controlsDelta, OriginAlign = rightAlign, }; m_showPlayerNamesCheckbox.IsCheckedChanged += checkboxChanged; // Buttons OK and CANCEL var buttonOk = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.Ok), onButtonClick: OnOkClick); var buttonCancel = new MyGuiControlButton(text: MyTexts.Get(MySpaceTexts.Cancel), onButtonClick: OnCancelClick); float buttonX = 0.01f; float buttonY = m_size.Value.Y / 2.0f - (buttonOk.Size.Y + 0.03f); buttonOk.Position = new Vector2(-buttonX, buttonY); buttonOk.OriginAlign = rightAlign; buttonCancel.Position = new Vector2(buttonX, buttonY); buttonCancel.OriginAlign = leftAlign; Controls.Add(languageLabel); Controls.Add(m_languageCombobox); Controls.Add(m_localizationWebButton); Controls.Add(m_localizationWarningLabel); Controls.Add(buildingModeLabel); Controls.Add(m_buildingModeCombobox); Controls.Add(controlHintsLabel); Controls.Add(rotationHintsLabel); Controls.Add(m_controlHintsCheckbox); Controls.Add(m_rotationHintsCheckbox); Controls.Add(crosshairLabel); Controls.Add(m_crosshairCheckbox); Controls.Add(headbobLabel); Controls.Add(m_disableHeadbobCheckbox); Controls.Add(compressSavesLabel); Controls.Add(m_compressSavesCheckbox); Controls.Add(showPlayerNamesOnHudLabel); Controls.Add(m_showPlayerNamesCheckbox); Controls.Add(buttonOk); Controls.Add(buttonCancel); // Update controls with values from config file UpdateControls(constructor); CloseButtonEnabled = true; }