Example #1
0
    public void ApplySettings()
    {
        link       = InputLink.text;
        bloom      = Toggle_Bloom.isOn;
        motionblur = Toggle_MotionBlur.isOn;

        resolutionIndex = dropdown_resolution.value;
        Screen.SetResolution(resolutions[dropdown_resolution.value].width, resolutions[dropdown_resolution.value].height, Screen.fullScreen);

        SettingsAndControls.Settings.SetSetting("link", new SACString(link), Setting.SettingType.STRING);
        SettingsAndControls.Settings.SetSetting("bloom", new SACBool(bloom), Setting.SettingType.BOOLEAN);
        SettingsAndControls.Settings.SetSetting("blur", new SACBool(motionblur), Setting.SettingType.BOOLEAN);
        SettingsAndControls.Settings.SetSetting("resolution_index", new SACInt(resolutionIndex), Setting.SettingType.INTEGER);
        SettingsAndControls.Save();

        if (gameObject.name == "SettingsPanel")
        {
            //display messagebox from login module
            LoginModule loginModule = GameObject.FindGameObjectWithTag("GameController").GetComponent <LoginModule>();
            loginModule.messagePrompt("Settings has been changed successfully", 2);
        }
        else if (gameObject.name == "InGameSettingsPanel")
        {
            gameObject.SetActive(false);
        }
    }
Example #2
0
    IEnumerator dbPassUpdate(string settingsLink, string accPassword, string newPassword, string confPassword)
    {
        // get link for password update module
        string link = "http://" + settingsLink + "/game_client/update_password.php";

        WWWForm passwordForm = new WWWForm();

        // check if new password and confirm new password exactly match
        if (txt_accPassword.text != string.Empty && txt_newPassword.text != string.Empty && txt_confirmNewPassword.text != string.Empty && txt_newPassword.text.Length > 8)
        {
            if (newPassword == confPassword)
            {
                // get user credentials for user update reference
                string userID   = login_module.userID;
                string username = login_module.accountUsername;
                int    accLevel = int.Parse(login_module.accountLevel);

                // send appropriate data for update
                passwordForm.AddField("accPassword", accPassword);
                passwordForm.AddField("accID", userID);
                passwordForm.AddField("accUsername", username);
                passwordForm.AddField("accLevel", accLevel);

                passwordForm.AddField("newPassword", newPassword);

                WWW wwwRequest = new WWW(link, passwordForm);

                // disable controls that may interrupt the process
                btnUpdate.interactable = false;
                //btnUpdate.GetComponent<Text>().text = "Processing requests...";

                btnPanelClose.interactable = false;

                yield return(wwwRequest);

                Debug.Log(wwwRequest.text);

                // display response after processing the request
                if (wwwRequest.text == "success")
                {
                    // display success message
                    login_module.messagePrompt("Account password updated successfully!", 2);
                    gameObject.SetActive(false);
                }
                else if (wwwRequest.text == "mismatch")
                {
                    // display password mismatch message
                    login_module.messagePrompt("Invalid account password!", 1);
                }
                else
                {
                    // display failure message
                    login_module.messagePrompt("Account password updated failed!", 1);
                }

                btnUpdate.interactable = true;
                //btnUpdate.GetComponent<Text>().text = "Update Password";

                btnPanelClose.interactable = true;
            }
            else
            {
                // display error message box and clear values to all textbox on the password panel
                login_module.messagePrompt("Confirm password doesn't match!", 1);
            }
        }
        else
        {
            if (txt_newPassword.text.Length < 8)
            {
                login_module.messagePrompt("Password should be at least 8 characters long!", 1);
            }
            else
            {
                login_module.messagePrompt("Fill the required fields!", 1);
            }
        }

        txt_accPassword.text        = null;
        txt_newPassword.text        = null;
        txt_confirmNewPassword.text = null;
    }