// Just an ease of use function for pausing the game in a way that updates the UI private static void PauseGame() { GameStateSim.Pause(); Panel_TopBar topBar = GameUI.m_Instance.m_TopBar; Time.timeScale = 0f; topBar.m_PausedSim = true; topBar.m_PauseSimButton.gameObject.SetActive(false); topBar.m_UnPauseSimButton.gameObject.SetActive(true); AudioMixerManager.PauseSimulationSFX(); InterfaceAudio.Play("ui_simulation_pause"); }
private void MultiplayerWindow(int id) { try { scrollPosition = GUILayout.BeginScrollView(scrollPosition); // top info / credits GUILayout.BeginHorizontal(GUI.skin.box); { GUILayout.Label("Mod created by Conqu3red.", GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); // connection Vertical(() => { Horizontal(() => { GUILayout.FlexibleSpace(); DrawHeader("Connection"); GUILayout.FlexibleSpace(); }); Horizontal(() => { GUILayout.Label("Server IP:"); GUIValues.ip = GUILayout.TextField(GUIValues.ip, GUILayout.Width(inputWidth)); }); Horizontal(() => { GUILayout.Label("Server Port:"); GUIValues.port = GUILayout.TextField(GUIValues.port, GUILayout.Width(inputWidth)); }); Horizontal(() => { GUILayout.Label("Session Name:"); GUIValues.sessionName = GUILayout.TextField(GUIValues.sessionName, GUILayout.Width(inputWidth)); }); Horizontal(() => { GUILayout.Label("(optional) Session Password:"******"(optional) Session Invite:"); GUIValues.invite = GUILayout.PasswordField(GUIValues.invite, '*', GUILayout.Width(inputWidth)); }); /*Horizontal(() => { * GUIValues.secureConnection = GUILayout.Toggle(GUIValues.secureConnection, "Connect using TLS/SSL"); * });*/ if (clientConnecting) { GUILayout.Button("Connecting..."); } else if (!clientEnabled) { if (GUILayout.Button("Connect")) { InterfaceAudio.Play("ui_menu_select"); Connect(); } } else { if (GUILayout.Button(communication.isOwner ? "Disconnect (Closes Session)" : "Disconnect")) { InterfaceAudio.Play("ui_menu_select"); Disconnect(); } } if (GUIValues.ConnectionResponse != "") { GUILayout.Label(GUIValues.ConnectionResponse); } }, GUI.skin.box); if (clientEnabled && communication.isOwner) { Vertical(() => { Horizontal(() => { GUILayout.FlexibleSpace(); DrawHeader("Host Options"); GUILayout.FlexibleSpace(); }); // set password Horizontal(() => { GUIValues.changingPassword = GUILayout.PasswordField(GUIValues.changingPassword, '*', GUILayout.Width(inputWidth)); if (GUILayout.Button("Set password")) { InterfaceAudio.Play("ui_menu_select"); setPassword(); } }); Horizontal(() => { GUIValues.userCap = GUILayout.TextField(GUIValues.userCap, GUILayout.Width(inputWidth)); if (GUILayout.Button("Set user cap")) { InterfaceAudio.Play("ui_menu_select"); setUserCap(); } }); if (serverInfo != null) { Horizontal(() => { GUILayout.Label("Lobby Mode:"); var lobby_mode_selected = new GUIStyle(GUI.skin.button); lobby_mode_selected.normal.textColor = Color.green; lobby_mode_selected.hover.textColor = Color.green; var modes = Enum.GetValues(typeof(LobbyMode)); foreach (LobbyMode mode in modes) { if ( GUILayout.Button(mode.ToString().ToLower(), serverInfo.lobbyMode == mode ? lobby_mode_selected : GUI.skin.button, GUILayout.Width(150f) ) ) { InterfaceAudio.Play("ui_menu_select"); serverInfo.lobbyMode = mode; setLobbyMode(mode); } } }); } Horizontal(() => { GUIValues.acceptingConnections = GUILayout.Toggle(GUIValues.acceptingConnections, "Accepting Connections"); if (GUIValues.acceptingConnections != GUIValues._acceptingConnectionsPrevFrame) { InterfaceAudio.Play("ui_settings_toggle"); setAcceptConnections(); } GUIValues._acceptingConnectionsPrevFrame = GUIValues.acceptingConnections; }); if (serverInfo != null && serverInfo.lobbyMode == LobbyMode.INVITE_ONLY) { // create invites Horizontal(() => { GUILayout.Label("number of allowed invite uses:"); GUIValues.inviteUses = GUILayout.TextField(GUIValues.inviteUses, GUILayout.Width(inputWidth)); }); if (GUILayout.Button("Create invite")) { InterfaceAudio.Play("ui_menu_select"); CreateInvite(); } // revoke invite/clear invites (backend implementation needed) if (GUIValues.InviteResponse != "") { Horizontal(() => { GUILayout.TextField(GUIValues.InviteResponse, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Close")) { GUIValues.InviteResponse = ""; } }); } } // sync with all users if (GUILayout.Button("Sync layout with all connected users")) { InterfaceAudio.Play("ui_menu_select"); syncLayout(); } if (serverInfo != null && serverInfo.playerNames.Length > 0) { // Kick user Horizontal(() => { GUILayout.Label("(optional) Kick reason:"); GUIValues.kickUserReason = GUILayout.TextField(GUIValues.kickUserReason, GUILayout.Width(inputWidth)); }); foreach (string playerName in serverInfo.playerNames) { Horizontal(() => { GUILayout.Label(playerName, GUILayout.Width(inputWidth)); if (GUILayout.Button("Kick")) { InterfaceAudio.Play("ui_menu_select"); KickUser(playerName); } }); } if (GUIValues.kickResponse != "") { GUILayout.Label(GUIValues.kickResponse); } } // set lobby mode }, GUI.skin.box); } else if (clientEnabled) { Vertical(() => { Horizontal(() => { GUILayout.FlexibleSpace(); DrawHeader("Client Options"); GUILayout.FlexibleSpace(); }); // sync layout if (GUILayout.Button("Request layout sync from host")) { InterfaceAudio.Play("ui_menu_select"); syncLayout(); } }, GUI.skin.box); } if (clientEnabled && serverInfo != null) { Vertical(() => { Horizontal(() => { GUILayout.FlexibleSpace(); DrawHeader("Connection Details"); GUILayout.FlexibleSpace(); }); GUILayout.Label($"Session Lobby Mode: {serverInfo.lobbyMode}"); GUILayout.Label($"Connected Users: {serverInfo.userCount}/{serverInfo.userCap}"); GUILayout.Label($"Accepting New Connections: {serverInfo.acceptingConnections}"); GUILayout.Label($"Session frozen: {serverInfo.isFrozen}"); //if (GUILayout.Button("Refresh")) ConnectionInfo(); }, GUI.skin.box); } GUILayout.EndScrollView(); } catch (ArgumentException ex) { instance.Logger.LogError(ex.Message); } }