Exemple #1
0
    public void LoadAllCFGs()
    {
        ControlMap cMap = gameObject.GetComponent <ControlMap>();
        DataMap    dMap = gameObject.GetComponent <DataMap>();

        if (File.Exists(Application.dataPath + "/data.cfg"))
        {
            dMap.LoadData();
            Debug.Log("Loaded Data File");
        }
        else
        {
            dMap = RegisterDefaultData(dMap);
        }
        if (File.Exists(Application.dataPath + "/controls.cfg"))
        {
            cMap.LoadData();
            Debug.Log("Loaded Controls File");
        }
        else
        {
            cMap = RegisterDefaultControls(cMap);
        }
    }
Exemple #2
0
    //Options Menu Window
    void OptionsMenu(int windowID)
    {
        float left  = 40;
        float top   = 80;
        float pad   = 5;
        float lh    = 40;
        float width = (Screen.width / 2) - 150;

        if (windowID == 5)       //Gameplay
        {
            GUI.skin            = list;
            _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 500), _windowScrollPos[4], new Rect(0, 0, width, 500));
            GUI.Label(new Rect(0, (lh + pad) * 0, 500, lh), "Player Name");
            _playerName = GUI.TextField(new Rect(0, (lh + pad) * 1, 250, lh), _playerName);
            _mouseMode  = GUI.Toggle(new Rect(0, (lh + pad) * 2, 250, lh), _mouseMode, "Mouse Controlled Mode");
            GUI.EndScrollView();
            if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply"))
            {
                PlayerPrefs.SetString("name", _playerName);
                _data.RegisterData("MouseMode", _mouseMode);
                SaveSettings();
            }

            if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert"))
            {
                LoadSettings();
                _playerName = PlayerPrefs.GetString("name");
            }
        }
        if (windowID == 6)       //Audio
        {
            lh                  = 40;
            GUI.skin            = list;
            _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 500), _windowScrollPos[4], new Rect(0, 0, width, 500));
            GUI.Label(new Rect(0, (lh + pad) * 0, 500, lh), "Master Volume - " + Round(_masterVol, 100));
            _masterVol = GUI.HorizontalSlider(new Rect(0, (lh + pad) * 1, 250, lh), _masterVol, 0, 100);
            GUI.Label(new Rect(0, (lh + pad) * 2, 500, lh), "Master Volume - " + Round(_bgmVol, 100));
            _bgmVol = GUI.HorizontalSlider(new Rect(0, (lh + pad) * 3, 250, lh), _bgmVol, 0, 100);
            GUI.Label(new Rect(0, (lh + pad) * 4, 500, lh), "Master Volume - " + Round(_sfxVol, 100));
            _sfxVol = GUI.HorizontalSlider(new Rect(0, (lh + pad) * 5, 250, lh), _sfxVol, 0, 100);
            GUI.EndScrollView();
            if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply"))
            {
                _data.RegisterData("BGM_Vol", _bgmVol);
                _data.RegisterData("SFX_Vol", _sfxVol);
                _data.RegisterData("Master_Vol", _masterVol);
                SaveSettings();
            }
            if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert"))
            {
                LoadSettings();
                _bgmVol    = _data.GetFloat("BGM_Vol");
                _sfxVol    = _data.GetFloat("SFX_Vol");
                _masterVol = _data.GetFloat("Master_Vol");
            }
        }
        if (windowID == 7)       //Video
        {
            GUI.skin = list;
            if (_resolutions == null)
            {
                _resolutions = Screen.resolutions;
            }
            _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 340), _windowScrollPos[4], new Rect(0, 0, width - 16, ((lh + pad) * 10f) + lh + 25));
            _vSync = GUI.Toggle(new Rect(0, (lh + pad) * 0, 250, lh), _vSync, "VSync");
            GUI.Label(new Rect(0, (lh + pad) * 1f, 250, lh), "Resolution");
            if (GUI.Button(new Rect(0, ((lh + pad) * 1.5f), 400, 64), _resolutions[_resIndex].width + "x" + _resolutions[_resIndex].height + " " + _resolutions[_resIndex].refreshRate + "Hz"))
            {
                _resIndex++;
                if (_resIndex > _resolutions.Length - 1)
                {
                    _resIndex = 0;
                }
            }
            _fullscreen = GUI.Toggle(new Rect(0, (lh + pad) * 3f, 400, lh), _fullscreen, "Fullscreen");
            GUI.Label(new Rect(0, (lh + pad) * 4f, 400, lh), "Anti-Ailiasing");
            if (GUI.Button(new Rect(0, (lh + pad) * 4.5f, 400, 64), _AA + "x"))
            {
                if (_AA == 0)
                {
                    _AA = 1;
                }
                _AA *= 2;
                if (_AA > 8)
                {
                    _AA = 0;
                }
            }
            _aniso = GUI.Toggle(new Rect(0, (lh + pad) * 6f, 400, lh), _aniso, "Anisotropic Filtering");
            GUI.Label(new Rect(0, (lh + pad) * 7f, 400, lh), "Texture Quality");
            if (GUI.Button(new Rect(0, (lh + pad) * 7.5f, 400, 64), _texQualityNames[_texQuality]))
            {
                _texQuality++;
                if (_texQuality > 3)
                {
                    _texQuality = 0;
                }
            }
            GUI.Label(new Rect(0, (lh + pad) * 9f, 400, lh), "Pixel Light Count: " + _pixelLights);
            _pixelLights = (int)GUI.HorizontalSlider(new Rect(20, (lh + pad) * 10f, 350, lh), _pixelLights, 1, 100);

            GUI.EndScrollView();
            if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply"))
            {
                _data.RegisterData("VSync", _vSync);
                _data.RegisterData("Res_Width", _resolutions[_resIndex].width);
                _resWidth = _resolutions[_resIndex].width;
                _data.RegisterData("Res_Height", _resolutions[_resIndex].height);
                _resHeight = _resolutions[_resIndex].height;
                _data.RegisterData("Res_Refresh", _resolutions[_resIndex].refreshRate);
                _resRefresh = _resolutions[_resIndex].refreshRate;
                _data.RegisterData("Fullscreen", _fullscreen);
                _data.RegisterData("Anti_Aliasing", _AA);
                _data.RegisterData("Aniso_Filtering", _aniso);
                _data.RegisterData("Tex_Quality", _texQuality);
                _data.RegisterData("PixelLights", _pixelLights);
                SaveSettings();
            }
            if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert"))
            {
                LoadSettings();
                //_vSync = _data.GetBool("VSync");
            }
        }
        if (windowID == 8)
        {
            if (_listeningTo >= 0)
            {
                ListenToKeys();
            }
            lh                  = 64;
            pad                 = 0;
            GUI.skin            = list;
            _windowScrollPos[4] = GUI.BeginScrollView(new Rect(left, top, width, 340), _windowScrollPos[4], new Rect(0, 0, width - 16, ((lh + pad) * _setControls.controlKeys.Count)));
            for (int i = 0; i < _setControls.controlKeys.Count; i++)
            {
                GUI.Label(new Rect(0, (lh + pad) * (i), 250, lh), _setControls.controlNames[i]);
                if (GUI.Button(new Rect(width / 3.5f, (lh + pad) * (i), 250, lh), _setControls.controlKeys[i].ToString()))
                {
                    _listeningTo      = i;
                    Screen.lockCursor = true;
                }
            }
            GUI.EndScrollView();
            if (GUI.Button(new Rect(left, 420, width / 2, 64), "Apply"))
            {
                _controls = _setControls;
                SaveSettings();
            }
            if (GUI.Button(new Rect((width / 2) + left + pad, 420, width / 2, 64), "Revert"))
            {
                _controls.LoadData();
                LoadSettings();
            }
        }
    }