/// <summary> /// Displays the window GUI for confirming to merge teams. /// </summary> private void MergeTeamsWarningWindow(int id) { //Get window size data. Vector2 sWndSize = new Vector2(Screen.width * Consts.Lobby_MergeTeamWarning_WindowSize.x, Screen.height * Consts.Lobby_MergeTeamWarning_WindowSize.y); Vector2 sWndPos = (new Vector2(Screen.width, Screen.height) - sWndSize) * 0.5f; //Label. Vector2 sLblOffset = new Vector2(Screen.width * Consts.Lobby_MergeTeamWarning_LabelOffset.x, Screen.height * Consts.Lobby_MergeTeamWarning_LabelOffset.y); Rect labelBounds = new Rect(sWndPos.x + sLblOffset.x, sWndPos.y + sLblOffset.y, sWndSize.x - (2.0f * sLblOffset.x), sWndSize.y - (2.0f * sLblOffset.y)); GUI.Label(labelBounds, Consts.Lobby_MergeTeamWarning_Warning); //"OK" and "Cancel" buttons. Vector2 sBttnSize = new Vector2(Screen.width * Consts.Lobby_MergeTeamWarning_ButtonsSize.x, Screen.height * Consts.Lobby_MergeTeamWarning_ButtonsSize.y); float sBttnSpacing = Screen.width * Consts.Lobby_MergeTeamWarning_ButtonSpacing, sBttnYOffset = Screen.height * Consts.Lobby_MergeTeamWarning_ButtonYOffset; Rect button = new Rect(sWndPos.x + (0.5f * sWndSize.x) - (0.5f * sBttnSpacing) - sBttnSize.x, sWndPos.y + sWndSize.y - sBttnYOffset - sBttnSize.y, sBttnSize.x, sBttnSize.y); if (GUI.Button(button, "Cancel")) { confirmMergeTeams = false; } button.center += new Vector2(sBttnSpacing + sBttnSize.x, 0.0f); if (GUI.Button(button, "Continue")) { TryBuildMatchData(false); nextScreen = new GenerateLevelMenuScreen(MatchData, Consts, Owner); } }
protected override MenuScreen ProtectedUpdate(MenuScreen.ScreenLayout layout) { if (advance) { GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), Owner.BackgroundTexture); return(new GenerateLevelMenuScreen(MatchData, Consts, Owner)); } //If the players just confirmed merging teams, exit. if (nextScreen != null) { return(nextScreen); } //If the players don't need to confirm merging teams, do the normal display. if (!confirmMergeTeams) { DrawTitleString("Lobby", layout.Title); //Buttons. MenuScreen vale; vale = DrawButtonMenu(layout.ButtonMenu, new GUIContent[] { new GUIContent("Back"), new GUIContent("Continue"), }, new GetData <MenuScreen>[] { () => { return(new CreateMatchMenuScreen(MatchData, Consts, Owner)); }, () => { //Try to build the match data. if (TryBuildMatchData(true)) { advance = true; return(this); } else { confirmMergeTeams = true; nextScreen = null; return(this); } }, }, null); if (vale != null) { return(vale); } //Players. for (int i = 0; i < 4; ++i) { playerDatas[i] = PlayerGUI(i, playerDatas[i]); } } //Otherwise, show the confirmation window. else { Vector2 sWndSize = new Vector2(Screen.width * Consts.Lobby_MergeTeamWarning_WindowSize.x, Screen.height * Consts.Lobby_MergeTeamWarning_WindowSize.y); Vector2 sWndPos = (new Vector2(Screen.width, Screen.height) - sWndSize) * 0.5f; Rect windBounds = new Rect(sWndPos.x, sWndPos.y, sWndSize.x, sWndSize.y); GUI.Window(1, windBounds, MergeTeamsWarningWindow, "Team merge warning"); } return(this); }