void LoadControls() { // Background texture unloaded in base m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ProgressBackground", flags: TextureFlags.IgnoreQuality); m_wheelTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\Loading", flags: TextureFlags.IgnoreQuality); m_size = new Vector2(598 / 1600f, 368 / 1200f); Controls.Add(new MyGuiControlLabel(this, new Vector2(0.0f, -0.05f), null, m_progressText, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE * 0.86f, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)); float deltaX = (m_enableCancel) ? 0.08f : 0.0f; float deltaY = 0.035f; Controls.Add(new MyGuiControlRotatingWheel(this, new Vector2(-deltaX, deltaY), MyGuiConstants.ROTATING_WHEEL_COLOR, MyGuiConstants.ROTATING_WHEEL_DEFAULT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, m_wheelTexture)); // Sometimes we don't want to allow user to cancel pending progress screen if (m_enableCancel) { var cancelButton = new MyGuiControlButton(this, new Vector2(deltaX, deltaY), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(cancelButton); } m_controlsCreated = true; }
public override void RecreateControls(bool contructor) { Controls.Clear(); AddCaption(MyTextsWrapperEnum.Options, new Vector2(0, 0.005f)); Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.146f); MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED; int index = 0; Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Game, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnGameClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Video, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnVideoClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, m_showVideoOption ? (MyTextsWrapperEnum?)null : MyTextsWrapperEnum.FeatureAccessibleOnlyFromMainMenu)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Audio, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAudioClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + index++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Controls, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnControlsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); var backButton = new MyGuiControlButton(this, new Vector2(0, 0.178f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, menuButtonTextAlignement, OnBackClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(backButton); }
static MyGuiScreenMessageBox() { m_typesConfiguration = new MyMessageBoxConfiguration[MyMwcUtils.GetMaxValueFromEnum <MyMessageBoxType>() + 1]; m_typesConfiguration[(int)MyMessageBoxType.MESSAGE] = new MyMessageBoxConfiguration( MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\MessageBackground_blue", flags: TextureFlags.IgnoreQuality), MyGuiConstants.MESSAGE_BOX_MESSAGE_TEXT_COLOR, MyGuiConstants.MESSAGE_BOX_MESSAGE_BACKGROUND_COLOR, MyGuiConstants.MESSAGE_BOX_MESSAGE_BUTTON_BACKGROUND_COLOR, MyGuiConstants.MESSAGE_BOX_MESSAGE_ROTATING_WHEEL_COLOR, MyGuiConstants.MESSAGE_BOX_MESSAGE_BACKGROUND_INTERFERENCE_VIDEO_COLOR, MyGuiManager.GetFontMinerWarsBlue(), MyGuiManager.GetConfirmButton()); m_typesConfiguration[(int)MyMessageBoxType.ERROR] = new MyMessageBoxConfiguration( MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\MessageBackground_red", flags: TextureFlags.IgnoreQuality), MyGuiConstants.MESSAGE_BOX_ERROR_TEXT_COLOR, MyGuiConstants.MESSAGE_BOX_ERROR_BACKGROUND_COLOR, MyGuiConstants.MESSAGE_BOX_ERROR_BUTTON_BACKGROUND_COLOR, MyGuiConstants.MESSAGE_BOX_ERROR_ROTATING_WHEEL_COLOR, MyGuiConstants.MESSAGE_BOX_ERROR_BACKGROUND_INTERFERENCE_VIDEO_COLOR, MyGuiManager.GetFontMinerWarsWhite(), MyGuiManager.GetMessageBoxButton()); m_typesConfiguration[(int)MyMessageBoxType.NULL] = new MyMessageBoxConfiguration( MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\MessageBackground_blue", flags: TextureFlags.IgnoreQuality), MyGuiConstants.MESSAGE_BOX_NULL_TEXT_COLOR, MyGuiConstants.MESSAGE_BOX_NULL_BACKGROUND_COLOR, MyGuiConstants.MESSAGE_BOX_NULL_BUTTON_BACKGROUND_COLOR, MyGuiConstants.MESSAGE_BOX_NULL_ROTATING_WHEEL_COLOR, MyGuiConstants.MESSAGE_BOX_NULL_BACKGROUND_INTERFERENCE_VIDEO_COLOR, MyGuiManager.GetFontMinerWarsBlue(), MyGuiManager.GetConfirmButton()); }
public override void LoadContent() { base.LoadContent(); Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.145f); const MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED; Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 0 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.DifficultyEasy, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnEasyClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 1 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.DifficultyNormal, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnNormalClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 2 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.DifficultyHard, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnHardClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); var exitButton = new MyGuiControlButton(this, new Vector2(0, 0.1460f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, menuButtonTextAlignement, OnBackClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(exitButton); SetControlIndex(2); }
public MyGuiScreenHostGame(MyGuiScreenBase closeAfterSuccessfulEnter) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(574f / 1600f, 695 / 1200f), false, MyGuiManager.GetSandboxBackgoround()) { m_closeAfterSuccessfulEnter = closeAfterSuccessfulEnter; m_enableBackgroundFade = true; AddCaption(MyTextsWrapperEnum.HostGame, new Vector2(0, 0.005f)); Debug.Assert(m_size != null, "m_size != null"); Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.146f); const MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED; MyTextsWrapperEnum?officialSectorsForbidden = null; MyTextsWrapperEnum?buttonsForbidden = null; MyTextsWrapperEnum?friendsSectorsForbidden = null; if (MyClientServer.LoggedPlayer != null) { if ((MyClientServer.LoggedPlayer.GetCanAccessDemo() == false) && (MyClientServer.LoggedPlayer.GetCanSave() == false)) { officialSectorsForbidden = MyTextsWrapperEnum.NotAccessRightsToTestBuild; buttonsForbidden = MyTextsWrapperEnum.NotAccessRightsToTestBuild; friendsSectorsForbidden = MyTextsWrapperEnum.NotAccessRightsToTestBuild; } else if (MyClientServer.LoggedPlayer.IsDemoUser()) { friendsSectorsForbidden = MyTextsWrapperEnum.NotAvailableInDemoMode; } } Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 0 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.SandboxSectors, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnSandboxSectorsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, officialSectorsForbidden)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 1 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.YourSectors, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnMySectorsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, buttonsForbidden)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 2 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.FriendsSectors, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnFriendsSectorsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, friendsSectorsForbidden)); var backButton = new MyGuiControlButton(this, new Vector2(0, 0.178f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, menuButtonTextAlignement, OnBackClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(backButton); }
protected override void LoadControls() { base.LoadControls(); var pos = GetNextControlPosition() - MyGuiConstants.CONTROLS_DELTA + new Vector2(0.07f, -0.02f); m_takeControl = new MyGuiControlButton(this, pos, new Vector2(0.14f, 0.051f), Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.AcquireControl, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE_SMALLER, MyGuiControlButtonTextAlignment.CENTERED, OnControlClick, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, true, true, true, drawCrossTextureWhenDisabled: false); Controls.Add(m_takeControl); m_takeControl.DrawRedTextureWhenDisabled = false; UpdateTakeControlState(); }
public MyGuiScreenProfile() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, new Vector2(574f / 1600f, 850 / 1200f)) { m_enableBackgroundFade = true; bool displayLogoutButton = !(MyGuiScreenGamePlay.Static != null && (MyGuiScreenGamePlay.Static.IsGameActive() || MyGuiScreenGamePlay.Static.IsEditorActive())); displayLogoutButton = displayLogoutButton && !MySteam.IsActive && (MyClientServer.LoggedPlayer != null && MyClientServer.LoggedPlayer.GetUserId() != MyPlayerLocal.OFFLINE_MODE_USERID); m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ProfileBackground", flags: TextureFlags.IgnoreQuality); if (displayLogoutButton) { m_size += new Vector2(0, MyGuiConstants.BACK_BUTTON_SIZE.Y); } AddCaption(MyTextsWrapperEnum.Profile, new Vector2(0, 0.005f)); Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.145f); MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED; float positionMultiplierY = 0; Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + positionMultiplierY * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.UserInfo, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnInfoClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); positionMultiplierY++; if (displayLogoutButton) { // Don't display LOGOUT button while player is in active game - because I don't know what to do after logout in this case and it's not needed there Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + positionMultiplierY * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Logout, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnLogoutClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); positionMultiplierY++; } var backButton = new MyGuiControlButton(this, new Vector2(0, 0.2695f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, menuButtonTextAlignement, OnBackClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(backButton); }
protected override void LoadControls() { base.LoadControls(); var pos = GetNextControlPosition() - MyGuiConstants.CONTROLS_DELTA + new Vector2(0.07f, -0.02f); /* * Controls.Add(m_acquireControl = new MyGuiControlButton(this, pos , new Vector2(MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X * 2f, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y), MyGuiConstants.BUTTON_BACKGROUND_COLOR, * MyTextsWrapperEnum.AcquireControl, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAcquireControlClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, true)); */ m_acquireControl = new MyGuiControlButton(this, pos, new Vector2(0.14f, 0.051f), MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.AcquireControl, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE_SMALLER, MyGuiControlButtonTextAlignment.CENTERED, OnAcquireControlClick, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, true, true); m_acquireControl.Enabled = m_entity.Enabled; Controls.Add(m_acquireControl); m_acquireControl.DrawRedTextureWhenDisabled = false; UpdateAcquireState(); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); Controls.Clear(); if (!contructor) { m_entityUseControl.ClearAfterRemove(); } m_entityUseControl = m_entity.GetGuiControl(this); m_entityUseControl.SetPosition(new Vector2(-0.013f, -0.27f)); m_entityUseControl.ParentScreen = this; Controls.Add(m_entityUseControl); var exitButton = new MyGuiControlButton(this, new Vector2(0f, 0.3490f), new Vector2(0.161f, 0.0637f), Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Exit, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnExitClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(exitButton); }
public override void RecreateControls(bool contructor) { base.RecreateControls(contructor); Controls.Clear(); m_entitiesGuiList = new MyGuiControlList( this, new Vector2(0.0034f, -0.030f), new Vector2(0.489f, 0.65f), Vector4.Zero, null,//MyTextsWrapper.Get(MyTextsWrapperEnum.SecurityControlHUB), MyGuiManager.GetBlankTexture(), new Vector2(0.01f, 0.0f)); if (!contructor) { foreach (var entityGui in m_entitiesGui) { entityGui.ClearAfterRemove(); } } m_entitiesGui.Clear(); foreach (IMyUseableEntity connectedEntity in m_prefabSecurityControlHUB.ConnectedEntities) { MyEntity entity = connectedEntity as MyEntity; if (!entity.Visible) { continue; } Debug.Assert((connectedEntity.UseProperties.UseType & MyUseType.FromHUB) != 0); IMyHasGuiControl entityWithGuiControl = connectedEntity as IMyHasGuiControl; Debug.Assert(entityWithGuiControl != null); // if entity is not hacked and could be hacked from HUB, then try hack it if (!connectedEntity.UseProperties.IsHacked && (connectedEntity.UseProperties.HackType & MyUseType.FromHUB) != 0) { if (m_useBy.HackingTool != null && m_useBy.HackingTool.HackingLevel >= connectedEntity.UseProperties.HackingLevel) { connectedEntity.UseProperties.IsHacked = true; } } MyGuiControlEntityUse entityGui = entityWithGuiControl.GetGuiControl(m_entitiesGuiList); entityGui.ParentScreen = this; m_entitiesGui.Add(entityGui); } m_entitiesGuiList.InitControls(m_entitiesGui); Controls.Add(m_entitiesGuiList); var exitButton = new MyGuiControlButton( this, new Vector2(0f, 0.3740f), new Vector2(0.161f, 0.0637f), Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Exit, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnExitClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(exitButton); }
private void AddControls() { Controls.Clear(); AddCaption(MyTextsWrapperEnum.PlayStory, new Vector2(0, 0.005f)); Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.147f); Vector2 buttonDelta = new Vector2(0.15f, 0); const MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED; MyTextsWrapperEnum?otherButtonsForbidden = null; MyTextsWrapperEnum?newGameForbidden = null; //MyTextsWrapperEnum newGameText = MyTextsWrapperEnum.StartDemo; int buttonPositionCounter = 0; if (MyClientServer.LoggedPlayer != null) { if ((MyClientServer.LoggedPlayer.GetCanAccessDemo() == false) && (MyClientServer.LoggedPlayer.GetCanSave() == false)) { //Uncomment when other buttons functionality implemented newGameForbidden = MyTextsWrapperEnum.NotAvailableInDemoMode; //otherButtonsForbidden = newGameForbidden = MyTextsWrapperEnum.NotAccessRightsToTestBuild; } else if (MyClientServer.LoggedPlayer.IsDemoUser()) { //Uncomment when other buttons functionality implemented newGameForbidden = null; otherButtonsForbidden = MyTextsWrapperEnum.NotAvailableInDemoMode; } else if (MyClientServer.LoggedPlayer.GetCanSave() == true) { //newGameText = MyTextsWrapperEnum.NewGame; newGameForbidden = null; } ParallelTasks.Parallel.Start(CheckCheckpointAndChapter); } // New Game / Start Demo var newGameButton = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.NewGame, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnNewGameClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, newGameForbidden); // Continue last game m_continueLastGame = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.ContinueLastGame, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnLoadLastCheckpointClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, MyFakes.LOAD_LAST_CHECKPOINT_ENABLED, otherButtonsForbidden); m_continueLastGame.DrawRedTextureWhenDisabled = false; // Show load checkpoint first (it's unknown whether checkpoint exists var tmp = newGameButton.GetPosition(); newGameButton.SetPosition(m_continueLastGame.GetPosition()); m_continueLastGame.SetPosition(tmp); Controls.Add(m_continueLastGame); Controls.Add(newGameButton); m_continueLastGame.Enabled = false; // Load Chapter m_loadChapter = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.LoadChapter, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnLoadChapterClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, //MyClientServer.LoggedPlayer != null && MyClientServer.LoggedPlayer.GetCanAccessEditorForStory() true /* && !otherButtonsForbidden.HasValue*/, otherButtonsForbidden); m_loadChapter.DrawRedTextureWhenDisabled = false; Controls.Add(m_loadChapter); m_loadChapter.Enabled = false; // Load Checkpoint //var loadCheckpoint = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, // MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, // MyTextsWrapperEnum.LoadCheckpoint, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, // OnLoadCheckpointClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, // MyClientServer.LoggedPlayer != null && MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()/* && !otherButtonsForbidden.HasValue*/, otherButtonsForbidden); //loadCheckpoint.DrawRedTextureWhenDisabled = false; //Controls.Add(loadCheckpoint); // Join friend’s game - Coop mode var join = new MyGuiControlButton(this, menuPositionOrigin + buttonPositionCounter++ *MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.JoinFriendGame, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnJoinFriendGameClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, otherButtonsForbidden); join.DrawRedTextureWhenDisabled = false; Controls.Add(join); var backButton = new MyGuiControlButton(this, new Vector2(0, 0.178f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, menuButtonTextAlignement, OnBackClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(backButton); }
public MyGuiScreenLogin(string username, string password, MyGuiScreenBase openAfterSuccessfulLogin, bool simple = false) : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null) { m_simple = simple; m_enableBackgroundFade = true; m_openAfterSuccessfulLogin = openAfterSuccessfulLogin; m_size = new Vector2(1030f / 1600f, 674 / 1200f); m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\LoginBackground", flags: TextureFlags.IgnoreQuality); // If user presses enter in any control, we call this method. It's default ENTER. this.OnEnterCallback = delegate { OnOkClick(null); }; Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.07f, -m_size.Value.Y / 2.0f + 0.149f); Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.25f, -m_size.Value.Y / 2.0f + 0.149f); AddCaption(MyTextsWrapperEnum.Login); // Player name Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 0 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.PlayerName, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_usernameTextbox = new MyGuiControlTextbox(this, controlsOriginRight + 0 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, username, MyMwcValidationConstants.USERNAME_LENGTH_MAX, MyGuiConstants.DEFAULT_CONTROL_NONACTIVE_COLOR /*TEXTBOX_BACKGROUND_COLOR*/, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); Controls.Add(m_usernameTextbox); // Password Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Password, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //m_passwordTextbox = new MyGuiControlTextbox(this, controlsOriginRight + 1 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_WIDTH / 2.0f, 0), true, MyGuiConstants.LABEL_TEXT_COLOR); m_passwordTextbox = new MyGuiControlTextbox(this, controlsOriginRight + 1 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, password, MyMwcValidationConstants.PASSWORD_LENGTH_MAX, MyGuiConstants.DEFAULT_CONTROL_NONACTIVE_COLOR /*TEXTBOX_BACKGROUND_COLOR*/, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); Controls.Add(m_passwordTextbox); bool remember = MyConfig.RememberUsernameAndPassword; bool autologin = MyConfig.Autologin; m_hidePasswordCheckbox = new MyGuiControlCheckbox(this, new Vector2(0.1950f, -0.0793f), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE, MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null, true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null); //m_hidePasswordCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight - 0.025f * Vector2.UnitX + MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_SIZE.X / 2.0f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_hidePasswordCheckbox); m_hidePasswordCheckbox.OnCheck = OnChangePasswordType; OnChangePasswordType(m_hidePasswordCheckbox); // Remember m_rememberCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + 2.25f * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE, MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null, remember, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null); if (!m_simple) { Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 2.25f * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.RememberMe, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_rememberCheckbox); } // Auto-login m_autologinCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + 3.25f * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE.X / 2.0f, 0), MyGuiConstants.CHECKBOX_WITH_GLOW_SIZE, MyGuiManager.GetCheckboxOffTexture(), MyGuiManager.GetCheckboxOnTexture(), null, autologin, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, true, null); if (!m_simple) { Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3.25f * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Autologin, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_autologinCheckbox); } // Buttons APPLY and BACK Vector2 buttonDelta = new Vector2(0.1f, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f); var okButton = new MyGuiControlButton(this, new Vector2(-0.1861f, 0.1611f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); var cancelButton = new MyGuiControlButton(this, new Vector2(-0.0461f, 0.1611f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); var registerButton = new MyGuiControlButton(this, new Vector2(0.1924f, 0.1611f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, Vector4.One, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Register, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnRegisterClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(okButton); Controls.Add(cancelButton); if (!m_simple) { Controls.Add(registerButton); } // Hide password Controls.Add(new MyGuiControlLabel(this, new Vector2(0.2164f, -0.0793f), null, MyTextsWrapperEnum.HidePassword, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); }
// Buttons must be created here because in this screen's constructor we might have not been logged in public override void LoadContent() { base.LoadContent(); Vector2 menuPositionOrigin = new Vector2(0.0f, -m_size.Value.Y / 2.0f + 0.145f); const MyGuiControlButtonTextAlignment menuButtonTextAlignement = MyGuiControlButtonTextAlignment.CENTERED; MyTextsWrapperEnum?yourSectorsButtonForbidden = null; MyTextsWrapperEnum?storySectorsButtonsForbidden = null; MyTextsWrapperEnum?mmoSectorsButtonsForbidden = null; if (MyClientServer.LoggedPlayer != null) { //if (true/*(MyClientServer.LoggedPlayer.GetCanAccessDemo() == false) && (MyClientServer.LoggedPlayer.GetCanAccessStory() == false)*/) //{ // yourSectorsButtonForbidden = MyTextsWrapperEnum.NotAccessRightsToTestBuild; //} if (!MyClientServer.LoggedPlayer.GetCanAccessEditorForStory()) { storySectorsButtonsForbidden = MyTextsWrapperEnum.AvailableOnlyForAdministrators; } if (true /*MyClientServer.LoggedPlayer.GetCanAccessEditorForMMO() == false*/) { mmoSectorsButtonsForbidden = MyTextsWrapperEnum.AvailableOnlyForAdministrators; } } // Buttons My Sectors and Friends Sectors Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 0 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.SandboxSectors, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnSandboxSectorsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, storySectorsButtonsForbidden)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 1 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.YourSectors, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnYourSectorsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, yourSectorsButtonForbidden)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 2 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.StorySectors, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnStorySectorsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, storySectorsButtonsForbidden)); Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 3 * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MAIN_MENU_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.MmoSectors, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnMmoSectorsClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, mmoSectorsButtonsForbidden)); var exitButton = new MyGuiControlButton(this, new Vector2(0, 0.1460f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, menuButtonTextAlignement, OnBackClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(exitButton); /* * * Controls.Add(new MyGuiControlButton(this, menuPositionOrigin + 3.5f * MyGuiConstants.MENU_BUTTONS_POSITION_DELTA, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, * MyTextsWrapperEnum.Back, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnBackClick, menuButtonTextAlignement, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); * */ }
public MyGuiScreenOptionsControls() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null) { m_size = new Vector2(1110f / 1600f, 1127f / 1200f); m_backgroundTexture = MyTextureManager.GetTexture <MyTexture2D>("Textures\\GUI\\BackgroundScreen\\ControlsBackground", flags: TextureFlags.IgnoreQuality); m_enableBackgroundFade = true; AddCaption(MyTextsWrapperEnum.Controls, new Vector2(0, 0.005f)); MyGuiManager.GetInput().TakeSnapshot(); m_controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.06f, -m_size.Value.Y / 2.0f + 0.102f); m_controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.333f, -m_size.Value.Y / 2.0f + 0.102f); #region Add Revert, OK, Cancel and selection combobox /* * // Buttons Revert, OK and CANCEL * float buttonsY = m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f; * Controls.Add(new MyGuiControlButton(this, * new Vector2((MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.X + 0.015f) * -1, buttonsY), * MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, * * MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnOkClick, * MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); * Controls.Add(new MyGuiControlButton(this, * new Vector2(0, buttonsY), * MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, * MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancelClick, * MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); * Controls.Add(new MyGuiControlButton(this, * new Vector2(m_controlsOriginRight.X + MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X, buttonsY), * new Vector2(MyGuiConstants.BUTTON_DEFAULTS_WIDTH, MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y), MyGuiConstants.BUTTON_BACKGROUND_COLOR, * MyTextsWrapperEnum.Revert, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnResetDefaultsClick, * MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); */ var okButton = new MyGuiControlButton(this, new Vector2(-0.1942f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnOkClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); var cancelButton = new MyGuiControlButton(this, new Vector2(-0.0597f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnCancelClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); var resetButton = new MyGuiControlButton(this, new Vector2(0.1942f, 0.3435f), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE_SMALL, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyGuiManager.GetConfirmButton(), null, null, MyTextsWrapperEnum.Revert, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, MyGuiControlButtonTextAlignment.CENTERED, OnResetDefaultsClick, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true, true); Controls.Add(okButton); Controls.Add(cancelButton); Controls.Add(resetButton); // Page selection combobox m_currentControlType = MyGuiControlTypeEnum.General; var cBoxPosition = m_controlsOriginRight + 0.5f * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, 0) - new Vector2(0.065f, 0); m_controlTypeList = new MyGuiControlCombobox(this, cBoxPosition, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.General, MyTextsWrapperEnum.General); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Navigation, MyTextsWrapperEnum.Navigation); // There are no controls for this category now, so hide it completely and uncomment, when we have new comms controls //m_controlTypeList.AddItem((int)MyGuiInputTypeEnum.Communications, MyTextsWrapperEnum.Comms); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Weapons, MyTextsWrapperEnum.Weapons); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.SpecialWeapons, MyTextsWrapperEnum.SpecialWeapons); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems1, MyTextsWrapperEnum.Systems1); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Systems2, MyTextsWrapperEnum.Systems2); m_controlTypeList.AddItem((int)MyGuiControlTypeEnum.Editor, MyTextsWrapperEnum.Editor); m_controlTypeList.SelectItemByKey((int)m_currentControlType); Controls.Add(m_controlTypeList); #endregion AddControls(); ActivateControls(m_currentControlType); }
public override void Draw() { MyTexture2D buttonTexture = null; MyTexture2D backgroundTexture = null; if (m_controlTexture == null) { if (m_size.HasValue && m_size.Value.Y < MyGuiConstants.MAIN_MENU_BUTTON_SIZE.Y) { buttonTexture = MyGuiManager.GetConfirmButton(); } else { buttonTexture = MyGuiManager.GetButtonTexture(); } } else { if (IsMouseOver() && m_mouseButtonPressed && m_pressedTexture != null) { buttonTexture = m_pressedTexture; } else if (IsMouseOver() && m_hoverTexture != null) { buttonTexture = m_hoverTexture; } else { buttonTexture = m_controlTexture; } } backgroundTexture = MyGuiManager.GetButtonTextureBg(buttonTexture); bool isNotImplementedForbidenOrDisabled = !m_implementedFeature || m_accessForbiddenReason != null || !Enabled; Vector4 backgroundColor, textColor; if (!UseSwitchMode) { bool isHighlighted = IsMouseOverOrKeyboardActive() && (m_highlightType == MyGuiControlHighlightType.WHEN_ACTIVE || (m_highlightType == MyGuiControlHighlightType.WHEN_CURSOR_OVER && IsMouseOver())); backgroundColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER) : (isHighlighted ? m_backgroundColor.Value * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_backgroundColor.Value); textColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : m_textColor * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER) : (isHighlighted ? m_textColor * MyGuiConstants.CONTROL_MOUSE_OVER_BACKGROUND_COLOR_MULTIPLIER : m_textColor); } else { backgroundColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_COLOR_VECTOR : m_backgroundColor.Value * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER * 2) : (m_backgroundColor.Value * 0.75f); textColor = isNotImplementedForbidenOrDisabled ? (DrawRedTextureWhenDisabled ? MyGuiConstants.DISABLED_BUTTON_TEXT_COLOR : m_textColor * MyGuiConstants.DISABLED_BUTTON_NON_RED_MULTIPLIER * 2) : (m_textColor * 0.75f); } if (backgroundTexture != null && m_useBackground) { // Draw background texture MyGuiManager.DrawSpriteBatch(backgroundTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, Color.White, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Draw background texture if (buttonTexture != null) { MyGuiManager.DrawSpriteBatch(buttonTexture, m_parent.GetPositionAbsolute() + m_position, m_size.Value * m_scale, GetColorAfterTransitionAlpha(backgroundColor), MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } // Draw cross texture if (isNotImplementedForbidenOrDisabled && DrawCrossTextureWhenDisabled) { MyGuiManager.DrawSpriteBatch(MyGuiManager.GetLockedButtonTexture(), m_parent.GetPositionAbsolute() + m_position, m_size.Value * MyGuiConstants.LOCKBUTTON_SIZE_MODIFICATION, MyGuiConstants.DISABLED_BUTTON_COLOR, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER); } if (Text != null) { Vector2 textPosition; MyGuiDrawAlignEnum textDrawAlign; if (m_textAlignment == MyGuiControlButtonTextAlignment.CENTERED) { textPosition = m_parent.GetPositionAbsolute() + m_position; textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER; } else if (m_textAlignment == MyGuiControlButtonTextAlignment.LEFT) { // This will move text few pixels from button's left border textPosition = m_parent.GetPositionAbsolute() + m_position - new Vector2(m_size.Value.X / 2.0f, 0) + new Vector2(MyGuiConstants.BUTTON_TEXT_OFFSET.X, 0); textDrawAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; } else { throw new MyMwcExceptionApplicationShouldNotGetHere(); } textPosition += TextOffset; MyGuiManager.DrawString(MyGuiManager.GetFontMinerWarsBlue(), Text, textPosition, m_textScale, GetColorAfterTransitionAlpha(textColor), textDrawAlign); } //ShowToolTip(); }