예제 #1
0
파일: Options.cs 프로젝트: shobu13/aomi
    public void UpdateFile(OptionsSerializer serializer)
    {
        options = serializer;

        TextWriter writer = new StreamWriter("Assets/option.json");

        writer.Write(JsonUtility.ToJson(serializer));
        writer.Close();
    }
예제 #2
0
    public static void deserialize(OptionsSerializer ser)
    {
        fullscreen      = ser.fullscreen;
        resolutionIndex = ser.resolutionIndex;
        textureQuality  = ser.textureQuality;
        antialiasing    = ser.antialiasing;
        vSync           = ser.vSync;

        musicVolume = ser.musicVolume;
    }
예제 #3
0
    private void Start()
    {
        OptionsData data = OptionsSerializer.Load();

        if (data != null)
        {
            generalVolumeSlider.value = data.generalVolume;
            musicVolumeSlider.value   = data.musicVolume;
            effectsVolumeSlider.value = data.effectsVolume;
        }
    }
예제 #4
0
    public void SaveOptions()
    {
        OptionsData data = new OptionsData
        {
            generalVolume = generalVolumeSlider.value,
            musicVolume   = musicVolumeSlider.value,
            effectsVolume = effectsVolumeSlider.value
        };

        OptionsSerializer.Save(data);
    }
예제 #5
0
    public void SaveSettings()
    {
        // Create a new serializer version of Options and update so all variables are current.
        OptionsSerializer serializer = new OptionsSerializer();

        serializer.Update();

        string jsonData = JsonUtility.ToJson(serializer, true);

        File.WriteAllText(Application.persistentDataPath + "/gamesettings.json", jsonData);
    }
예제 #6
0
    private void Start()
    {
        OptionsData data = OptionsSerializer.Load();

        if (data != null)
        {
            SetGeneralVolume(data.generalVolume);
            SetMusicVolume(data.musicVolume);
            SetEffectsVolume(data.effectsVolume);
        }
    }
예제 #7
0
    void Start()
    {
        // First, check for a custom graphics file.
        if (System.IO.File.Exists(Application.persistentDataPath + "/gamesettings.json"))
        {
            // A file exists, load the data from said file
            OptionsSerializer ser      = new OptionsSerializer();
            string            jsonData = File.ReadAllText(Application.persistentDataPath + "/gamesettings.json");
            ser = JsonUtility.FromJson <OptionsSerializer>(jsonData);

            Options.deserialize(ser);
        }
        else
        {
            // No file exists for user-defined graphics. Create one using the unity quality settings
            OptionsSerializer ser = new OptionsSerializer();
            ser.fullscreen      = Screen.fullScreen;
            ser.resolutionIndex = 0;
            ser.textureQuality  = QualitySettings.masterTextureLimit;
            switch (QualitySettings.antiAliasing)
            {
            case 0:
                ser.antialiasing = 0;
                break;

            case 2:
                ser.antialiasing = 1;
                break;

            case 4:
                ser.antialiasing = 2;
                break;

            case 8:
                ser.antialiasing = 3;
                break;

            case 16:
                ser.antialiasing = 4;
                break;

            default:
                ser.antialiasing = 0;
                break;
            }
            ser.vSync       = QualitySettings.vSyncCount;
            ser.musicVolume = 0.5f;

            string jsonData = JsonUtility.ToJson(ser, true);
            File.WriteAllText(Application.persistentDataPath + "/gamesettings.json", jsonData);
        }
    }
예제 #8
0
        private void EnsureSolutionOptionsFileCreated()
        {
            bool solutionConfigExists = File.Exists(_solutionConfigurationPath);

            if (!solutionConfigExists)
            {
                using (FileStream fstream = File.Open(_solutionConfigurationPath, FileMode.Create))
                {
                    OptionsSerializer serializer = new OptionsSerializer();
                    serializer.Serialize(fstream, OptionsProviderRegistry.CurrentOptions);
                    fstream.Flush();
                }
            }
        }
예제 #9
0
        public override void Save(Options options)
        {
            _options = options;
            using (MemoryStream cloneStream = new MemoryStream())
                using (FileStream fstream = new FileStream(_filePath, FileMode.Create, FileAccess.Write))
                {
                    OptionsSerializer serializer = new OptionsSerializer();
                    serializer.Serialize(cloneStream, options);

                    cloneStream.Position = 0;
                    cloneStream.CopyTo(fstream);
                    cloneStream.Position = 0;
                    _options             = serializer.Deserialize(cloneStream);
                }
        }
예제 #10
0
        public override void Save(Options options)
        {
            _options = options;
            using (MemoryStream cloneStream = new MemoryStream())
            using (FileStream fstream = new FileStream(_filePath, FileMode.Create, FileAccess.Write))
            {
                OptionsSerializer serializer = new OptionsSerializer();
                serializer.Serialize(cloneStream, options);

                cloneStream.Position = 0;
                cloneStream.CopyTo(fstream);
                cloneStream.Position = 0;
                _options = serializer.Deserialize(cloneStream);
            }
        }
예제 #11
0
파일: FormOptions.cs 프로젝트: Pumpet/Robin
        internal static FormsConfig CreateFromXML(string xml)
        {
            FormsConfig config = null;

            if (!string.IsNullOrWhiteSpace(xml))
            {
                try {
                    config = OptionsSerializer.LoadXML <FormsConfig>(xml);
                }
                catch (Exception ex) {
                    Loger.SendMess(ex, $"Ошибка загрузки параметров форм из строки");
                    xml = null;
                }
            }
            if (string.IsNullOrWhiteSpace(xml))
            {
                config = new FormsConfig();
            }
            return(config);
        }
예제 #12
0
    public void LoadSettings()
    {
        // Load data
        OptionsSerializer serializer = new OptionsSerializer();

        File.ReadAllText(Application.persistentDataPath + "/gamesettings.json");
        serializer = JsonUtility.FromJson <OptionsSerializer>(File.ReadAllText(Application.persistentDataPath + "/gamesettings.json"));

        // Transfer data into static Options class
        Options.deserialize(serializer);

        // Update values
        musicSlider.value = Options.musicVolume;

        vSyncDropdown.value        = Options.vSync;
        antialiasingDropdown.value = Options.antialiasing;
        textureDropdown.value      = Options.textureQuality;
        resolutionDropdown.value   = Options.resolutionIndex;
        fullscreenToggle.isOn      = Options.fullscreen;
        Screen.fullScreen          = Options.fullscreen;
        resolutionDropdown.RefreshShownValue();
    }
예제 #13
0
파일: Options.cs 프로젝트: shobu13/aomi
    public OptionsSerializer GetOptions()
    {
        OptionsSerializer optionResult = new OptionsSerializer();

        try
        {
            TextReader reader;
            reader = new StreamReader("Assets/option.json");
            string result = reader.ReadToEnd();
            reader.Close();

            optionResult = JsonUtility.FromJson <OptionsSerializer>(result);
        }
        catch (FileNotFoundException e)
        {
            TextWriter writer;
            writer = new StreamWriter("Assets/option.json");
            writer.Write(JsonUtility.ToJson(optionResult));
            writer.Close();
            Debug.Log(e);
        }
        return(optionResult);
    }
예제 #14
0
파일: FormOptions.cs 프로젝트: Pumpet/Robin
        /// <summary>Заполняет контейнер параметров форм из файла. Если файла нет - создает новый.
        /// </summary>
        /// <param name="fileName">имя файла, по умолчанию: Forms + имя приложения.xml</param>
        /// <returns>контейнер параметров форм</returns>
        internal static FormsConfig CreateFromFile(string fileName = "")
        {
            FormsConfig config = null;

            if (string.IsNullOrWhiteSpace(fileName))
            {
                fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Forms" + Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName) + ".xml");
            }
            try {
                if (!File.Exists(fileName))
                {
                    OptionsSerializer.Save(fileName, new FormsConfig());
                }
                config = OptionsSerializer.Load <FormsConfig>(fileName);
                if (config != null)
                {
                    config.fileName = fileName;
                }
            }
            catch (Exception ex) {
                Loger.SendMess(ex, $"Ошибка загрузки параметров форм из файла {fileName}");
            }
            return(config);
        }
예제 #15
0
파일: FormOptions.cs 프로젝트: Pumpet/Robin
 /// <summary>Запись контейнера в файл
 /// </summary>
 internal void Save()
 {
     OptionsSerializer.Save(fileName, this);
 }
예제 #16
0
        static void Main()
        {
            foreach (var proc in Process.GetProcessesByName(PKStudioLauncherName))
            {
                if (proc.Id != Process.GetCurrentProcess().Id)
                {
                    return;
                }
            }

            var tool        = string.Empty;
            var toolPath    = string.Empty;
            var toolVersion = string.Empty;
            var pkPath      = string.Empty;

            if (File.Exists(OptionsPath))
            {
                var serializer = OptionsSerializer.BackState(OptionsPath);

                foreach (var option in serializer.SOptions)
                {
                    var envOption = option as EnvironmentOption;
                    if (envOption != null)
                    {
                        tool        = EnvironmentOption.GetToolString(envOption.Tool);
                        toolPath    = envOption.Path;
                        toolVersion = envOption.Version;
                    }

                    var verOption = option as PKVersionOption;
                    if (verOption != null)
                    {
                        pkPath = verOption.PKVersion.Path;
                    }
                }
            }

            var path = "";
            var portingKitRegistryValue = Environment.GetEnvironmentVariable("SPOCLIENT");
            var spoClientPath           = "";

            if (string.IsNullOrEmpty(portingKitRegistryValue) || !Directory.Exists(portingKitRegistryValue))
            {
                portingKitRegistryValue = pkPath;
            }
            if (string.IsNullOrEmpty(portingKitRegistryValue) || !Directory.Exists(portingKitRegistryValue))
            {
                portingKitRegistryValue = Helper.GetPortingKitRegistryValue("", "InstallRoot");
            }
            if (!string.IsNullOrEmpty(portingKitRegistryValue) && Directory.Exists(portingKitRegistryValue))
            {
                path = portingKitRegistryValue;
            }

            if (!Directory.Exists(path) || !Directory.Exists(path + @"\DeviceCode\Targets\"))
            {
                using (var of = new SetSPOForm())
                {
                    if (of.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        Console.WriteLine(@".NET Micro Framework Porting Kit directory was not found. Waiting for exit...");
                        Process.GetCurrentProcess().WaitForExit();
                    }
                    else
                    {
                        if (Directory.Exists(path + @"\DeviceCode\Targets\"))
                        {
                            spoClientPath = of.Path;
                        }
                        else
                        {
                            Console.WriteLine(@".NET Micro Framework Porting Kit directory was not found. Waiting for exit...");
                            Process.GetCurrentProcess().WaitForExit();
                        }
                    }
                }
            }
            else
            {
                Environment.SetEnvironmentVariable("SPOCLIENT", path);
                spoClientPath = path;
            }


            if (spoClientPath.Substring(spoClientPath.Length - 1, 1) != @"\")
            {
                spoClientPath += @"\";
            }
            path = string.Format("{0}setenv_base.cmd {1} {2} {3}", spoClientPath, tool, toolVersion, toolPath);

            foreach (var proc in Process.GetProcessesByName("PKStudio"))
            {
                Console.WriteLine(@"Another running copy of PKStudio has been detected. Waiting for exit...");
                proc.WaitForExit();
            }
            if (File.Exists(PKStudioPath))
            {
                var process = new Process();
                var info    = process.StartInfo;
                info.FileName = Environment.ExpandEnvironmentVariables("%comspec%");
                info.RedirectStandardInput = true;
                info.UseShellExecute       = false;
                info.WindowStyle           = ProcessWindowStyle.Hidden;
                if (process.Start())
                {
                    process.StandardInput.WriteLine(path);
                    process.StandardInput.WriteLine(PKStudioPath);
                }
            }
            else
            {
                Console.WriteLine(@"PKStudio executable not found.");
            }
        }
예제 #17
0
파일: FormOptions.cs 프로젝트: Pumpet/Robin
 internal string GetXML()
 {
     return(OptionsSerializer.GetXML(this));
 }
예제 #18
0
파일: Options.cs 프로젝트: shobu13/aomi
 // Use this for initialization
 void Start()
 {
     options = GetOptions();
 }