Beispiel #1
0
    // ========================================
    // Load settings
    static Settings()
    {
        IniFile ini = new IniFile("Settings");

        SoundEnabled = ini.get(SOUND_ENABLED_KEY, true);
        MusicEnabled = ini.get(MUSIC_ENABLED_KEY, true);
    }
Beispiel #2
0
    /// <summary>
    /// Load options.
    /// </summary>
    public static void load()
    {
        Debug.Log("Loading settings");

#if PACKAGE_INI_FILE
        IniFile iniFile=new IniFile("Settings");

        if (iniFile.count()==0)
        {
            save();
            iniFile.load("Settings");
        }
#endif

        #region Game
#if OPTION_LANGUAGE
        LanguageManager languageManager=LanguageManager.Instance;
#if PACKAGE_INI_FILE
        mLanguage=iniFile.get          ("Game.Language", languageManager.GetSystemLanguage());
#else
        mLanguage=PlayerPrefs.GetString("Game.Language", languageManager.GetSystemLanguage());
#endif

        if (!languageManager.IsLanguageSupported(mLanguage))
        {
            mLanguage="en";
        }

        Debug.Log("Application language: "+mLanguage);
        languageManager.ChangeLanguage(mLanguage);
#endif

#if OPTION_DIFFICULTY
#if PACKAGE_INI_FILE
        mDifficulty=iniFile.get       ("Game.Difficulty", difficultyCount/2);
#else
        mDifficulty=PlayerPrefs.GetInt("Game.Difficulty", difficultyCount/2);
#endif

        Debug.Log("Difficulty:           "+mDifficulty.ToString());
#endif

#if OPTION_BLOOD
#if PACKAGE_INI_FILE
        mBlood=iniFile.get       ("Game.Blood", true);
#else
        mBlood=PlayerPrefs.GetInt("Game.Blood", 1)==1;
#endif

        Debug.Log("Blood:                "+mBlood.ToString());
#endif

#if OPTION_USE_HINTS
#if PACKAGE_INI_FILE
        mUseHints=iniFile.get       ("Game.UseHints", true);
#else
        mUseHints=PlayerPrefs.GetInt("Game.UseHints", 1)==1;
#endif

        Debug.Log("Use hints:            "+mUseHints.ToString());
#endif

#if OPTION_AUTOSAVE
#if PACKAGE_INI_FILE
        mAutosave=iniFile.get       ("Game.Autosave", true);
#else
        mAutosave=PlayerPrefs.GetInt("Game.Autosave", 1)==1;
#endif

        Debug.Log("Autosave:             "+mAutosave.ToString());
#endif
        #endregion

        #region Audio
#if OPTION_SOUND
#if PACKAGE_INI_FILE
        mSound=iniFile.get       ("Audio.Sound", true);
#else
        mSound=PlayerPrefs.GetInt("Audio.Sound", 1)==1;
#endif

        Debug.Log("Sound:          "+mSound.ToString());
#endif

#if OPTION_MASTER_VOLUME
#if PACKAGE_INI_FILE
        mMasterVolume=iniFile.get         ("Audio.MasterVolume", 1f);
#else
        mMasterVolume=PlayerPrefs.GetFloat("Audio.MasterVolume", 1f);
#endif

        Debug.Log("Master volume:  "+mMasterVolume.ToString());
#endif

#if OPTION_MUSIC_VOLUME
#if PACKAGE_INI_FILE
        mMusicVolume=iniFile.get         ("Audio.MusicVolume", 1f);
#else
        mMusicVolume=PlayerPrefs.GetFloat("Audio.MusicVolume", 1f);
#endif

        Debug.Log("Music volume:   "+mMusicVolume.ToString());
#endif

#if OPTION_VOICE_VOLUME
#if PACKAGE_INI_FILE
        mVoiceVolume=iniFile.get         ("Audio.VoiceVolume", 1f);
#else
        mVoiceVolume=PlayerPrefs.GetFloat("Audio.VoiceVolume", 1f);
#endif

        Debug.Log("Voice volume:   "+mVoiceVolume.ToString());
#endif

#if OPTION_EFFECTS_VOLUME
#if PACKAGE_INI_FILE
        mEffectsVolume=iniFile.get         ("Audio.EffectsVolume", 1f);
#else
        mEffectsVolume=PlayerPrefs.GetFloat("Audio.EffectsVolume", 1f);
#endif

        Debug.Log("Effects volume: "+mEffectsVolume.ToString());
#endif

#if OPTION_SUBTITLES
#if PACKAGE_INI_FILE
        mSubtitles=iniFile.get       ("Audio.Subtitles", true);
#else
        mSubtitles=PlayerPrefs.GetInt("Audio.Subtitles", 1)==1;
#endif

        Debug.Log("Subtitles:      "+mSubtitles.ToString());
#endif

        setAudioListenerVolume();
        #endregion

        #region Video
#if OPTION_SHOW_FPS
#if PACKAGE_INI_FILE
        mShowFPS=iniFile.get       ("Video.ShowFPS", false);
#else
        mShowFPS=PlayerPrefs.GetInt("Video.ShowFPS", 0)==1;
#endif

        Debug.Log("Show FPS:       "+mShowFPS.ToString());
        FPSCounter.isOn=mShowFPS;
#endif

#if OPTION_FULL_SCREEN_AND_RESOLUTION
#if PACKAGE_INI_FILE
        mFullScreen=iniFile.get          ("Video.FullScreen", true);
        mResolution=iniFile.get          ("Video.Resolution", "800x600");
#else
        mFullScreen=PlayerPrefs.GetInt   ("Video.FullScreen", 1)==1;
        mResolution=PlayerPrefs.GetString("Video.Resolution", "800x600");
#endif

        Debug.Log("Full screen:    "+mFullScreen.ToString());
        Debug.Log("Resolution:     "+mResolution);

        changeResolution();
#endif

#if OPTION_QUALITY
#if PACKAGE_INI_FILE
        mQuality=iniFile.get       ("Video.Quality", QualitySettings.GetQualityLevel());
#else
        mQuality=PlayerPrefs.GetInt("Video.Quality", QualitySettings.GetQualityLevel());
#endif
        if (mQuality>=QualitySettings.names.Length)
        {
            // TODO: Add custom quality
            mQuality=0;
        }

        Debug.Log("Video quality:  "+mQuality.ToString());
        QualitySettings.SetQualityLevel(mQuality);
#endif
        #endregion

        #region Controls
#if MENU_DEFINE_KEYS
        foreach (KeyMapping key in InputControl.getKeys())
        {
#if PACKAGE_INI_FILE
            key.primaryInput   = StringToCustomInput(iniFile.get          ("Controls."+key.name+".Primary",   key.primaryInput.ToString()));
            key.secondaryInput = StringToCustomInput(iniFile.get          ("Controls."+key.name+".Secondary", key.secondaryInput.ToString()));
            key.thirdInput     = StringToCustomInput(iniFile.get          ("Controls."+key.name+".Third",     key.thirdInput.ToString()));
#else
            key.primaryInput   = StringToCustomInput(PlayerPrefs.GetString("Controls."+key.name+".Primary",   key.primaryInput.ToString()));
            key.secondaryInput = StringToCustomInput(PlayerPrefs.GetString("Controls."+key.name+".Secondary", key.secondaryInput.ToString()));
            key.thirdInput     = StringToCustomInput(PlayerPrefs.GetString("Controls."+key.name+".Third",     key.thirdInput.ToString()));
#endif

            Debug.Log("Key: "+key.name+" ; Primary   = "+key.primaryInput.ToString());
            Debug.Log("Key: "+key.name+" ; Secondary = "+key.secondaryInput.ToString());
            Debug.Log("Key: "+key.name+" ; Third     = "+key.thirdInput.ToString());
        }
#endif

#if OPTION_ALWAYS_RUN
#if PACKAGE_INI_FILE
        mAlwaysRun=iniFile.get       ("Controls.AlwaysRun", false);
#else
        mAlwaysRun=PlayerPrefs.GetInt("Controls.AlwaysRun", 0)==1;
#endif

        Debug.Log("Always run:        "+mAlwaysRun.ToString());
#endif

#if OPTION_AUTO_AIM
#if PACKAGE_INI_FILE
        mAutoAim=iniFile.get       ("Controls.AutoAim", false);
#else
        mAutoAim=PlayerPrefs.GetInt("Controls.AutoAim", 0)==1;
#endif

        Debug.Log("Auto aim:          "+mAutoAim.ToString());
#endif

#if OPTION_MOUSE_SENSITIVITY
#if PACKAGE_INI_FILE
        mMouseSensitivity=iniFile.get         ("Controls.MouseSensitivity", 1f);
#else
        mMouseSensitivity=PlayerPrefs.GetFloat("Controls.MouseSensitivity", 1f);
#endif

        Debug.Log("Mouse sensitivity: "+mouseSensitivity.ToString());

#if PACKAGE_INPUT_CONTROL
        InputControl.mouseSensitivity=mMouseSensitivity;
#endif
#endif

#if OPTION_INVERT_MOUSE_Y
#if PACKAGE_INI_FILE
        mInvertMouseY=iniFile.get       ("Controls.InvertMouseY", false);
#else
        mInvertMouseY=PlayerPrefs.GetInt("Controls.InvertMouseY", 0)==1;
#endif

        Debug.Log("Invert mouse Y:    "+mInvertMouseY.ToString());

#if PACKAGE_INPUT_CONTROL
        InputControl.invertMouseY=mInvertMouseY;
#endif
#endif

#if OPTION_INPUT_DEVICE
#if PACKAGE_INI_FILE
        InputControl.preferredInputDevice=(InputDevice)iniFile.get       ("Controls.InputDevice", (int)InputDevice.Any);
#else
        InputControl.preferredInputDevice=(InputDevice)PlayerPrefs.GetInt("Controls.InputDevice", (int)InputDevice.Any);
#endif

        Debug.Log("Input device:      "+InputControl.preferredInputDevice.ToString());
#endif
        #endregion
    }