public void DrawGUI() { GUILayout.Label("Server name"); gameName = GUILayout.TextField(gameName, 64); GUILayout.Label("Server port (Default 25000)"); port = GUILayout.TextField(port); GUILayout.Label("Max players connected: " + (int)maxPlayers); maxPlayers = GUILayout.HorizontalSlider(maxPlayers, 1, 64); addToServerList = GUILayout.Toggle(addToServerList, "Show in server browser"); //GUILayout.Label("NAT Status: "+NatChecker.status); if (message.StartsWith("@spinner/")) { Spinner.Draw(message.Replace("@spinner/", "")); } else { GUILayout.Label(message); } if (GUILayout.Button("Start") || (Event.current.isKey && Event.current.keyCode == KeyCode.Return)) { StartServer(); } if (GUILayout.Button("Back", GUI.skin.GetStyle("smallButton"))) { menu.SetPage(MenuPage.None); } //GUIStyle thingStyle = new GUIStyle(GUI.skin.label); //thingStyle.fontSize = 18; //GUILayout.Label("If you're behind a router, you'll want to enable port forwarding for the port you use. This doesn't matter if you're playing alone.",thingStyle); }
public void DrawGUI() { GUILayout.Label("IP Adress:"); ip = GUILayout.TextField(ip); GUILayout.Label("Port (Default 25000)"); port = GUILayout.TextField(port); if (connectionStatus != null && connectionStatus.message != null) { if (connectionStatus.message.StartsWith("@spinner/")) { Spinner.Draw(connectionStatus.message.Replace("@spinner/", "")); } else { GUILayout.Label(connectionStatus.message); } } if (!connectionStatus.isConnecting) { if (GUILayout.Button("Connect") || (Event.current.isKey && Event.current.keyCode == KeyCode.Return)) { Connect(); } } else { if (GUILayout.Button("Cancel")) { Cancel(); } } if (GUILayout.Button("Back", GUI.skin.GetStyle("smallButton"))) { menu.SetPage(MenuPage.None); } }
public void DrawGUI() { GUIStyle smallButton = GUI.skin.GetStyle("smallButton"); if (page == 0) { if (GUILayout.Button("General")) { page = 1; } if (GUILayout.Button("Keybinds")) { page = 2; } if (GUILayout.Button("Profile")) { page = 3; } if (GUILayout.Button("Back", smallButton)) { menu.SetPage(MenuPage.None); } } if (page == 1) //General settings { enableTrails = GUILayout.Toggle(enableTrails, "Fancy ball trails"); fullscreen = GUILayout.Toggle(fullscreen, "Fullscreen"); vsync = GUILayout.Toggle(vsync, "Vsync"); Resolution currentRes = Screen.resolutions[(int)resolution]; GUILayout.Label("Resolution: " + currentRes.width + "x" + currentRes.height); resolution = GUILayout.HorizontalSlider(resolution, 0, Screen.resolutions.Length - 1); //GUILayout.Label ("Field of View: "+fov); //fov = (int)GUILayout.HorizontalSlider(fov,50,80); //AA buttons GUILayout.Label("Anti-aliasing: x" + aa); GUILayout.BeginHorizontal(); if (GUILayout.Button("Off", smallButton)) { aa = 0; } if (GUILayout.Button("x2", smallButton)) { aa = 2; } if (GUILayout.Button("x4", smallButton)) { aa = 4; } if (GUILayout.Button("x8", smallButton)) { aa = 8; } GUILayout.EndHorizontal(); //Dynamic shadows shadows = GUILayout.Toggle(shadows, "Dynamic Shedews"); //Camera speed for mouse / keyboard seperately GUILayout.Label("Camera speed (Mouse): " + (float)decimal.Round((decimal)sensitivityMouse, 1)); sensitivityMouse = GUILayout.HorizontalSlider(sensitivityMouse, 0.1f, 10); GUILayout.Label("Camera speed (Keyboard): " + (float)decimal.Round((decimal)sensitivityKeyboard, 1)); sensitivityKeyboard = GUILayout.HorizontalSlider(sensitivityKeyboard, 0.1f, 30); //sound volume GUILayout.Label("Sound volume: " + (float)decimal.Round((decimal)volume, 2) * 100 + "%"); volume = GUILayout.HorizontalSlider(volume, 0, 1); //Music toggle music = GUILayout.Toggle(music, "Music"); //sanic speed song sanicSpeedSong = GUILayout.Toggle(sanicSpeedSong, "Alt. song when going fast"); if (GUILayout.Button("Apply")) { Apply(); } if (GUILayout.Button("Back", smallButton)) { page = 0; UpdateVarsGeneral(); } } if (page == 2) //Keybind changer { foreach (KeyValuePair <string, KeybindInfo> bind in GameSettings.keybinds.GetAllBinds()) { GUILayout.BeginHorizontal(); GUILayout.Label(bind.Value.name, GUILayout.MaxWidth(200)); GUILayout.FlexibleSpace(); GUIStyle keycodeStyle = new GUIStyle(smallButton); keycodeStyle.alignment = TextAnchor.MiddleRight; if (GUILayout.Button(GameSettings.keybinds.GetKeyCodeName(bind.Value.keyCode), keycodeStyle, GUILayout.MaxWidth(200))) { keybindToChange = bind.Key; } GUILayout.EndHorizontal(); } if (GUILayout.Button("Reset keybinds", smallButton)) { GameSettings.keybinds = new Keybinds(); } if (string.IsNullOrEmpty(keybindToChange)) { if (GUILayout.Button("Apply")) { Apply(); } if (GUILayout.Button("Back", smallButton)) { page = 0; GameSettings.keybinds.LoadFromPrefs(); } } else { KeybindInfo info = GameSettings.keybinds.Find(keybindToChange); GUILayout.Label("Press a key to use for '" + info.name + "'. Escape to cancel."); } } if (page == 3) //Profile { if (GameSettings.user.UseGJ) //Logged in menu { GUILayout.Label("Signed in to Game Jolt as " + GameSettings.user.playerName); GUILayout.Label("'Remember me' is " + (GameSettings.user.rememberInfo ? "ON" : "OFF")); GUILayout.Label("Player status: " + PlayerTypeHandler.GetPlayerType(GameSettings.user.playerName)); if (GUILayout.Button("Log out")) { loginToken = GameSettings.user.token; loginName = GameSettings.user.playerName; GameSettings.user.token = ""; GameSettings.user.Save(); } } else //Anon menu { GUILayout.Label("Playing anonymously as '" + GameSettings.user.playerName + "'"); GUILayout.Label("'Remember me' is " + (GameSettings.user.rememberInfo ? "ON" : "OFF")); GUILayout.Label("Change your username:"******"Change", smallButton)) { GameSettings.user.playerName = anonName; } if (!GameSettings.user.offlineMode) { if (GUILayout.Button("Log in with Game Jolt", GUI.skin.GetStyle("smallbuttongreen"))) { page = 4; } } } if (GUILayout.Button("Back", smallButton)) { page = 0; UpdateVarsProfile(); } } if (page == 4) //Log in { GUILayout.Label("GJ username: "******"Focus"); loginName = GUILayout.TextField(loginName, 128); GUILayout.Label("User token: "); loginToken = GUILayout.PasswordField(loginToken, (char)0x25CF, 128); rememberMe = GUILayout.Toggle(rememberMe, "Remember me"); if ((GUILayout.Button("Log in") || (Event.current.isKey && Event.current.keyCode == KeyCode.Return)) && !isVerifying) { status = ""; if (loginName.Trim().Length <= 0) //Has the user typed something in the username field? { status = "You need to type an username."; } else if (loginToken.Trim().Length <= 0) //Has the user typed something in the token field? { status = "You need to type in your token."; } else //Log in with the Game Jolt API { status = "@spinner/Logging in..."; isVerifying = true; GJAPI.Users.Verify(loginName, loginToken); GJAPI.Users.VerifyCallback += LogInCallback; } } if (status.StartsWith("@spinner/")) { Spinner.Draw(status.Replace("@spinner/", "")); } else { GUILayout.Label(status); } if (GUILayout.Button("Back", smallButton) && !isVerifying) { page = 3; } } }
void OnGUI() { if (offset < 1) { return; } GUI.skin = skin; GUIStyle smallButton = GUI.skin.GetStyle("SmallButton"); GUIStyle smallButtonOdd = GUI.skin.GetStyle("SmallButtonOdd"); GUIStyle labelOdd = GUI.skin.GetStyle("LabelOdd"); int width = Mathf.Min(960, Screen.width - 400); int height = Screen.height; Rect rect = new Rect((Screen.width - 400) - (offset), Screen.height / 2 - height / 2, width, height); GUI.Box(rect, ""); GUILayout.BeginArea(rect); /*string sortmodeStr = ""; * if (serverList.Length > 0 && currentSortMode != ServerSortMode.None && header != "Refreshing..") { * sortmodeStr = ", sorting by "+GetSortModeString(currentSortMode); * if (isSortingReversed) { * sortmodeStr += " (reversed)"; * } * }*/ if (header.StartsWith("@spinner/")) { Spinner.Draw(header.Replace("@spinner/", "")); } else { GUILayout.Label(header); } scroll = GUILayout.BeginScrollView(scroll); //Column widths float serverNameMinWidth = 400; float statusWidth = 130; float playerCountWidth = 110; float versionWidth = 190; //Column labels GUILayout.BeginHorizontal(); GUIStyle sortModeStyle = new GUIStyle(smallButton); sortModeStyle.fontStyle = (currentSortMode == ServerSortMode.ServerName) ? FontStyle.Bold : FontStyle.Normal; if (GUILayout.Button("Server name", sortModeStyle, GUILayout.MinWidth(serverNameMinWidth), GUILayout.ExpandWidth(true))) { SortServers(ServerSortMode.ServerName, true); } sortModeStyle.fontStyle = (currentSortMode == ServerSortMode.Status) ? FontStyle.Bold : FontStyle.Normal; if (GUILayout.Button("Status", sortModeStyle, GUILayout.Width(statusWidth))) { SortServers(ServerSortMode.Status, true); } sortModeStyle.fontStyle = (currentSortMode == ServerSortMode.PlayerCount) ? FontStyle.Bold : FontStyle.Normal; if (GUILayout.Button("Players", sortModeStyle, GUILayout.Width(playerCountWidth))) { SortServers(ServerSortMode.PlayerCount, true); } sortModeStyle.fontStyle = (currentSortMode == ServerSortMode.Version) ? FontStyle.Bold : FontStyle.Normal; if (GUILayout.Button("Game version", sortModeStyle, GUILayout.Width(versionWidth))) { SortServers(ServerSortMode.Version, true); } GUILayout.EndHorizontal(); for (int i = 0; i < serverList.Length; i++) { GUIStyle labelStyle = GUI.skin.label; GUIStyle buttonStyle = smallButton; if (i % 2 == 0) { labelStyle = labelOdd; buttonStyle = smallButtonOdd; } GUILayout.BeginHorizontal(); ServerItem server = serverList[i]; //Server name if (GUILayout.Button(server.hostData.gameName, buttonStyle, GUILayout.MinWidth(serverNameMinWidth), GUILayout.ExpandWidth(true))) { Connect(server.hostData); } //Status GUILayout.Label(server.status, labelStyle, GUILayout.Width(statusWidth)); //Player count GUILayout.Label(server.hostData.connectedPlayers + "/" + server.hostData.playerLimit, labelStyle, GUILayout.Width(playerCountWidth)); //Version GUILayout.Label(server.versionString, labelStyle, GUILayout.Width(versionWidth)); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); //Bottom bar GUILayout.BeginHorizontal(); if (GUILayout.Button("Close", smallButton, GUILayout.ExpandWidth(false))) { Hide(); } if (GUILayout.Button("Refresh", smallButton, GUILayout.ExpandWidth(false))) { UpdateServerList(); } if (GUILayout.Button("Join by IP", smallButton, GUILayout.ExpandWidth(false))) { GetComponent <MenuMain>().SetPage(MenuPage.JoinGame); } if (connectionStatus.isConnecting) { if (GUILayout.Button("Cancel", smallButtonOdd, GUILayout.ExpandWidth(false))) { Cancel(); } } if (connectionStatus != null && connectionStatus.message != null) { if (connectionStatus.message.StartsWith("@spinner/")) { Spinner.Draw(connectionStatus.message.Replace("@spinner/", ""), null, 0); } else { GUILayout.Label(connectionStatus.message, GUILayout.ExpandWidth(true)); } } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
// Update is called once per frame void OnGUI() { if (started) { return; } GUI.skin = skin; GUIStyle smallButton = GUI.skin.GetStyle("smallButton"); int startX = Mathf.Max(0, Screen.width / 2 - 300); int startY = Mathf.Max(0, Screen.height / 2 - 150); Rect rect = new Rect( startX, startY, Mathf.Min(Screen.width - startX, 600), Mathf.Min(Screen.height - startY, 300) ); GUILayout.BeginArea(rect); GUIStyle centerStyle = new GUIStyle(GUI.skin.label); centerStyle.alignment = TextAnchor.MiddleCenter; if (isStarting) { GUILayout.FlexibleSpace(); Spinner.DrawAt(new Vector2(rect.width / 2 - 16, rect.height / 2 - 16 - 32)); GUILayout.Space(32); GUILayout.Label("Starting up...", centerStyle); GUILayout.FlexibleSpace(); } else if (isRemembering) //Don't show the login form if remembering { GUILayout.FlexibleSpace(); Spinner.DrawAt(new Vector2(rect.width / 2 - 16, rect.height / 2 - 16 - 32)); GUILayout.Space(32); GUILayout.Label("Logging in...", centerStyle); GUILayout.FlexibleSpace(); } else { if (method == LoginMethod.Undecided) { GUILayout.Label("Welcome to Sanicball!"); GUILayout.Label("Select an option below. Signing in with Game Jolt will in a future update let you submit your highscores online."); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Sign in with Game Jolt", GUI.skin.GetStyle("smallButtonGreen"))) { method = LoginMethod.GameJolt; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Stay anonymous", smallButton)) { method = LoginMethod.Anon; } GUILayout.EndHorizontal(); } if (method == LoginMethod.GameJolt) { GUILayout.Label("GJ username: "******"Focus"); username = GUILayout.TextField(username, 128); GUILayout.Label("User token: "); token = GUILayout.PasswordField(token, (char)0x25CF, 128); rememberMe = GUILayout.Toggle(rememberMe, "Remember me"); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if ((GUILayout.Button("Log in", smallButton) || (Event.current.isKey && Event.current.keyCode == KeyCode.Return)) && !isVerifying) { status = ""; if (username.Trim().Length <= 0) //Has the user typed something in the username field? { status = "You need to type an username."; } else if (token.Trim().Length <= 0) //Has the user typed something in the token field? { status = "You need to type in your token."; } else //Log in with the Game Jolt API { status = "@spinner/Logging in..."; isVerifying = true; GJAPI.Users.Verify(username, token); GJAPI.Users.VerifyCallback += LogInCallback; } } GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", smallButton)) { method = LoginMethod.Undecided; status = ""; } GUILayout.EndHorizontal(); } if (method == LoginMethod.Anon) { if (GameSettings.user.offlineMode) { GUILayout.Label("Failed to connect to Game Jolt! However, you can still play multiplayer anonymously."); } GUILayout.Label("Type the name you want to use:"); GUI.SetNextControlName("Focus"); username = GUILayout.TextField(username, 32); GUILayout.Label("Your name will be slightly grayed out in multiplayer to avoid impersonation."); rememberMe = GUILayout.Toggle(rememberMe, "Remember name"); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Okay", smallButton) || (Event.current.isKey && Event.current.keyCode == KeyCode.Return)) { status = ""; if (username.Trim().Length <= 0) { status = "You need to type something."; } else { Accept(); } } if (!GameSettings.user.offlineMode) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", smallButton)) { method = LoginMethod.Undecided; status = ""; } } GUILayout.EndHorizontal(); } if (status.StartsWith("@spinner/")) { Spinner.Draw(status.Replace("@spinner/", "")); } else { GUILayout.Label(status); } } GUILayout.EndArea(); }