Ejemplo n.º 1
0
    public KeybindInfo Find(string name)
    {
        KeybindInfo output = null;

        if (!binds.TryGetValue(name, out output))
        {
            Debug.LogError("Key '" + name + "' doesn't exist in keybinds.");
        }
        return(output);
    }
Ejemplo n.º 2
0
        public ChangeKeybindUI(KeybindInfo keybindInfo)
        {
            InitializeComponent();
            kbi = keybindInfo;
            this.lblPressAnyKey.Visible = false;

            this.textBoxKeyBind.Text           = kbi.Key;
            this.checkBoxCTRLModifier.Checked  = kbi.bUseCTRLModifier;
            this.checkBoxALTModifier.Checked   = kbi.bUseALTModifier;
            this.checkBoxSHIFTModifier.Checked = kbi.bUseSHIFTModifier;
        }
Ejemplo n.º 3
0
 void GetAnyKeyForKeybinding()
 {
     foreach (KeyCode kc in validKeyCodes)
     {
         if (Input.GetKeyDown(kc) && kc != KeyCode.Escape)
         {
             KeybindInfo info = GameSettings.keybinds.Find(options.keybindToChange);
             info.keyCode            = kc;
             options.keybindToChange = null;
             return;
         }
     }
 }
Ejemplo 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;
            }
        }
    }