Esempio n. 1
0
 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);
 }
Esempio n. 2
0
    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);
        }
    }
Esempio n. 3
0
    public void DrawGUI()
    {
        GUIStyle smallButton = GUI.skin.GetStyle("smallButton");

        if (page == 0)
        {
            if (GUILayout.Button("Music"))
            {
                page = 1;
            }
            if (GUILayout.Button("Back", smallButton))
            {
                menu.SetPage(MenuPage.None);
            }
        }

        if (page == 1)
        {
            // music
            GUILayout.Space(10);
            scroll = GUILayout.BeginScrollView(scroll);
            GUIStyle style = new GUIStyle(GUI.skin.GetStyle("SmallButtonOdd"))
            {
                fontSize = 14, alignment = TextAnchor.MiddleRight
            };
            GUIStyle styleText = new GUIStyle(GUI.skin.GetStyle("LabelOdd"))
            {
                wordWrap = true, fontSize = 14, alignment = TextAnchor.MiddleLeft
            };
            if (GameSettings.userPlaylist.Count > 0)
            {
                GUILayout.Label("My music", new GUIStyle(GUI.skin.label)
                {
                    wordWrap = true, fontSize = 18
                });
                foreach (ExternalSong s in GameSettings.userPlaylist.ToArray())
                {
                    GUILayout.Space(1);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(s.song.name, styleText);
                    if (GUILayout.Button("Remove", style, GUILayout.MaxWidth(style.CalcSize(new GUIContent("Remove")).x), GUILayout.ExpandHeight(true)))
                    {
                        s.Dispose();
                        GameSettings.userPlaylist.Remove(s);
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Space(1);
                }
                GUILayout.Space(10);
            }
            GUILayout.Label("Inbuilt music", new GUIStyle(GUI.skin.label)
            {
                wordWrap = true, fontSize = 18
            });
            foreach (Song s in Global.playlist)
            {
                GUILayout.Space(1);
                GUILayout.BeginHorizontal();
                style = new GUIStyle(GUI.skin.GetStyle(s.enabled ? "SmallButtonOdd" : "SmallButtonDisabled"))
                {
                    fontSize = 14, alignment = TextAnchor.MiddleRight
                };
                styleText = new GUIStyle(GUI.skin.GetStyle(s.enabled ? "LabelOdd" : "LabelDisabled"))
                {
                    wordWrap = true, fontSize = 14, alignment = TextAnchor.MiddleLeft
                };
                GUILayout.Label(s.name, styleText);
                if (s.enabled)
                {
                    if (GUILayout.Button("Disable", style, GUILayout.MaxWidth(style.CalcSize(new GUIContent("Disable")).x), GUILayout.ExpandHeight(true)))
                    {
                        s.enabled = false;
                    }
                }
                else
                {
                    if (GUILayout.Button("Enable", style, GUILayout.MaxWidth(style.CalcSize(new GUIContent("Disable")).x), GUILayout.ExpandHeight(true)))
                    {
                        s.enabled = true;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(1);
            }
            GUILayout.EndScrollView();
            GUILayout.Space(10);
            if (GUILayout.Button("Add", smallButton))
            {
                menu.StartCoroutine(AddMusic());
            }
            if (GUILayout.Button("Back", smallButton))
            {
                page = 0;
                GameSettings.Save();
            }
        }
    }
Esempio n. 4
0
    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;
            }
        }
    }