コード例 #1
0
        private void FormConstruct()
        {
            try
            {
                read_fsgame();
                load_other();
                set_image();
                load_list_saves();
                //               load_leng();

                var cfg = new OgseConfig();
                OgseConfigSerializer.Instance.Load(cfg);
                this.propertyGrid1.SelectedObject = cfg;
                this.propertyGrid1.HelpVisible    = true;
                var cfg2 = new OgseGraphics();
                OgseGraphicsSerializer.Instance.Load(Data.ShaderConfigPath, cfg2);
                this.propertyGrid2.SelectedObject = cfg2;
                string tmp = new string('\r', 29);
                Utils.INI.GetPrivateProfileString("mod_ver", "mod_ver", "", tmp, 30, Data.VersionPath);
                // test
                string test_for_morons = new string('\r', 29);
                //if (Utils.INI.GetPrivateProfileString("mod_ver", "mod_ver", "", test_for_morons, 30, Data.RootAppPath) != 0)
                //    File.Copy(Environment.CurrentDirectory + "\\ogse_config.ltx", Environment.CurrentDirectory + "\\gamedata\\config\\tuning\\ogse_config.ltx", true);
                // test end

                // защита от удаления/отсутствия локализации
                if (!File.Exists(Environment.CurrentDirectory + "\\gamedata.db_xlocale") && File.Exists(Environment.CurrentDirectory + "\\localization\\" + lang + "\\gamedata.db_xlocale"))
                {
                    File.Copy(Environment.CurrentDirectory + "\\localization\\" + lang + "\\gamedata.db_xlocale", Environment.CurrentDirectory + "\\gamedata.db_xlocale", true);
                }

                ApplyButton.Enabled = false;
                if (Directory.Exists(Data.SavesDir))
                {
                    File.Delete(Data.SavesDir + "\\wreset");
                    this.button4.Enabled = true;
                }
                else
                {
                    this.button4.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                this.Close();
            }
        }
コード例 #2
0
        public void Save(OgseConfig cfg)
        {
            string actorLtx = Data.ActorLtxFilePath;

            #region numeric
            Utils.INI.WritePrivateProfileString("inventory", "max_weight", ConvertDecimalToString(cfg.ves), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("actor_condition", "max_walk_weight", ConvertDecimalToString(cfg.ves + 10), actorLtx);
            Utils.INI.WritePrivateProfileString("options", "treasure_dropout", ConvertDecimalToString(100 - cfg.verojatnost_tajnik), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "random_news_delta", ConvertDecimalToString(cfg.chastota_news), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "t_surge", ConvertDecimalToString(cfg.period_vibros), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "t_common", ConvertDecimalToString(cfg.period_resp_old), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "aes_timer", ConvertDecimalToString(cfg.tajmer_chaes), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "s_time_factor", ConvertDecimalToString(cfg.time_factor), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("alife", "time_factor", ConvertDecimalToString(cfg.time_factor), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "fov_volume", ConvertDecimalToString(cfg.fov_volume), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "suit_probability", ConvertDecimalToString(cfg.suit_prob), Data.RootAppPath);
            Utils.INI.WritePrivateProfileString("options", "exo_probability", ConvertDecimalToString(cfg.exo_prob), Data.RootAppPath);
            #endregion

            #region params check

            WriteCheckboxValueToIni(cfg.sluchajnie_tajniki, "options", "option_random_treasure");
            WriteCheckboxValueToIni(cfg.otobr_soderj_tajnikov, "options", "treasure_need_text");
            WriteCheckboxValueToIni(cfg.dinamic_news, "options", "random_news");
            WriteCheckboxValueToIni(cfg.dop_spawn, "options", "additional_spawn");
            WriteCheckboxValueToIni(cfg.plohoe_samochustv, "options", "bleed_enable");
            //  WriteCheckboxValueToIni(cfg.ammo_on_belt, "options", "ammunition_on_belt");
            WriteCheckboxValueToIni(cfg.poboch_lek, "options", "poison_drugs");
            WriteCheckboxValueToIni(cfg.medlen_lek, "options", "slow_drugs");
            WriteBoolValueToIni(cfg.pnv_disabling, "wpn_addon_setup", "cheat_nv_block");
            WriteBoolValueToIni(cfg.pnv_autostart, "wpn_addon_setup", "cheat_nv_scope_autoenable");

            string value = "0";
            if (cfg.weather_type == E_WEATHER.Bright)
            {
                value = "1";
            }
            else if (cfg.weather_type == E_WEATHER.Rainy)
            {
                value = "2";
            }
            else
            {
                value = "0";
            }
            Utils.INI.WritePrivateProfileString("options", "weather_type", value, Data.RootAppPath);

            value = "0";
            if (cfg.popadanie_po_ger == E_ACTOR_HIT.All)
            {
                value = "2";
            }
            else if (cfg.popadanie_po_ger == E_ACTOR_HIT.OnlyCameraShake)
            {
                value = "1";
            }
            else
            {
                value = "0";
            }
            Utils.INI.WritePrivateProfileString("options", "oh_shit_im_hit", value, Data.RootAppPath);

            #endregion

            #region start time
            int    hour = cfg.start_time.Hour;
            string Hour = hour.ToString();

            int    minute = cfg.start_time.Minute;
            string Minute = minute.ToString();

            if (hour < 10)
            {
                Hour = "0" + Hour;
            }
            if (minute < 10)
            {
                Minute = "0" + Minute;
            }


            Utils.INI.WritePrivateProfileString("alife", "start_time", String.Format("{0}:{1}:00", Hour, Minute), Data.RootAppPath);
            #endregion
        }
コード例 #3
0
        public void Load(OgseConfig cfg)
        {
            try
            {
                #region numeric
                cfg.ves = (int)GetDecimalFromIni("inventory", "max_weight", Data.RootAppPath);
                cfg.verojatnost_tajnik = (int)(100 - GetDecimalFromIni("options", "treasure_dropout", Data.RootAppPath));
                cfg.chastota_news      = (int)GetDecimalFromIni("options", "random_news_delta", Data.RootAppPath);
                cfg.period_vibros      = (int)GetDecimalFromIni("options", "t_surge", Data.RootAppPath);
                cfg.period_resp_old    = (int)GetDecimalFromIni("options", "t_common", Data.RootAppPath);
                cfg.tajmer_chaes       = (int)GetDecimalFromIni("options", "aes_timer", Data.RootAppPath);
                cfg.time_factor        = (int)GetDecimalFromIni("options", "s_time_factor", Data.RootAppPath);
                cfg.fov_volume         = (int)GetDecimalFromIni("options", "fov_volume", Data.RootAppPath);
                cfg.suit_prob          = (int)GetDecimalFromIni("options", "suit_probability", Data.RootAppPath);
                cfg.exo_prob           = (int)GetDecimalFromIni("options", "exo_probability", Data.RootAppPath);
                #endregion

                #region params check

                cfg.sluchajnie_tajniki    = SetCheckboxValueFromIni("options", "option_random_treasure");
                cfg.otobr_soderj_tajnikov = SetCheckboxValueFromIni("options", "treasure_need_text");
                cfg.dinamic_news          = SetCheckboxValueFromIni("options", "random_news");
                cfg.dop_spawn             = SetCheckboxValueFromIni("options", "additional_spawn");
                cfg.plohoe_samochustv     = SetCheckboxValueFromIni("options", "bleed_enable");
                // cfg.ammo_on_belt = SetCheckboxValueFromIni("options", "ammunition_on_belt");
                cfg.poboch_lek    = SetCheckboxValueFromIni("options", "poison_drugs");
                cfg.medlen_lek    = SetCheckboxValueFromIni("options", "slow_drugs");
                cfg.pnv_disabling = SetCheckboxValueFromIni("wpn_addon_setup", "cheat_nv_block");
                cfg.pnv_autostart = SetCheckboxValueFromIni("wpn_addon_setup", "cheat_nv_scope_autoenable");
                #endregion

                int value = GetIntValueFromIni("options", "weather_type");
                switch (value)
                {
                case 1:
                    cfg.weather_type = E_WEATHER.Bright;
                    break;

                case 2:
                    cfg.weather_type = E_WEATHER.Rainy;
                    break;

                default:
                    cfg.weather_type = E_WEATHER.Default;
                    break;
                }

                value = GetIntValueFromIni("options", "oh_shit_im_hit");
                switch (value)
                {
                case 1:
                    cfg.popadanie_po_ger = E_ACTOR_HIT.OnlyCameraShake;
                    break;

                case 2:
                    cfg.popadanie_po_ger = E_ACTOR_HIT.All;
                    break;

                default:
                    cfg.popadanie_po_ger = E_ACTOR_HIT.Off;
                    break;
                }

                #region start time


                string   StartTime = (new Utils.IniFile(Data.RootAppPath)).IniReadValue("alife", "start_time", "");
                string[] time      = StartTime.Split(':');

                try
                {
                    cfg.start_time = new DateTime(2012, 5, 1, Convert.ToInt32(time[0]), Convert.ToInt32(time[1]), Convert.ToInt32(time[2].Trim()));
                }
                catch (Exception)
                {
                    //MessageBox.Show("Ошибка при попытке сконвертировать параметр:\nstart_time\n" + except.Message);
                }
                #endregion
            }
            catch (Exception)
            {
                //MessageBox.Show("Error 446\n" + e.Message);
            }
        }
コード例 #4
0
        private void FormConstruct()
        {
            try
            {
                read_fsgame();
                load_other();
                set_image();
                load_list_saves();
                //               load_leng();

                #region About
                try
                {
                    about_mod.LoadFile("localization//" + lang + "//ogse_about_mod.rtf", RichTextBoxStreamType.RichText);
                }
                catch
                {
                    about_mod.Text = res.GetString("CANT_FIND_FILE") + " ogse_about_mod.rtf";
                }
                try
                {
                    team.LoadFile("localization//" + lang + "//ogse_about.rtf", RichTextBoxStreamType.RichText);
                }
                catch
                {
                    team.Text = res.GetString("CANT_FIND_FILE") + " ogse_about.rtf";
                }
                try
                {
                    features.LoadFile("localization//" + lang + "//ogse_features.rtf", RichTextBoxStreamType.RichText);
                }
                catch
                {
                    features.Text = res.GetString("CANT_FIND_FILE") + " ogse_features.rtf";
                }
                #endregion

                var cfg = new OgseConfig();
                OgseConfigSerializer.Instance.Load(cfg);
                this.propertyGrid1.SelectedObject = cfg;
                this.propertyGrid1.HelpVisible    = true;
                var cfg2 = new OgseGraphics();
                OgseGraphicsSerializer.Instance.Load(Data.ShaderConfigPath, cfg2);
                this.propertyGrid2.SelectedObject = cfg2;
                string tmp = new string('\r', 29);
                Utils.INI.GetPrivateProfileString("mod_ver", "mod_ver", "", tmp, 30, Data.VersionPath);
                // test
                string test_for_morons = new string('\r', 29);
                if (Utils.INI.GetPrivateProfileString("mod_ver", "mod_ver", "", test_for_morons, 30, Data.RootAppPath) != 0)
                {
                    File.Copy(Environment.CurrentDirectory + "\\ogse_config.ltx", Environment.CurrentDirectory + "\\gamedata\\config\\tuning\\ogse_config.ltx", true);
                }
                // test end

                // защита от удаления/отсутствия локализации
                if (!File.Exists(Environment.CurrentDirectory + "\\gamedata.db_xlocale"))
                {
                    File.Copy(Environment.CurrentDirectory + "\\localization\\" + lang + "\\gamedata.db_xlocale", Environment.CurrentDirectory + "\\gamedata.db_xlocale", true);
                }

                // specific code for first launch after patch 2.07/8
                if (File.Exists(Environment.CurrentDirectory + "\\patch_2_08_cleanup"))
                {
                    OgseConfigSerializer.Instance.Save(this.propertyGrid1.SelectedObject as OgseConfig);
                    var cfg_new = new OgseConfig();
                    OgseConfigSerializer.Instance.Load(cfg_new);
                    this.propertyGrid1.SelectedObject = cfg_new;
                    File.Copy(Environment.CurrentDirectory + "\\localization\\" + lang + "\\gamedata.db_xlocale", Environment.CurrentDirectory + "\\gamedata.db_xlocale", true);
                    if (Directory.Exists(Data.LogsPath) && Directory.Exists(Data.ShaderCache))
                    {
                        Directory.Delete(Data.ShaderCache, true);
                    }

                    // specific code for 2.10 revised
                    //gamedata/config/tuning
                    if (Directory.Exists(Environment.CurrentDirectory + "\\gamedata\\config\\tuning\\") && File.Exists(Environment.CurrentDirectory + "\\gamedata\\config\\tuning\\ogse_config.ltx"))
                    {
                        File.Copy(Environment.CurrentDirectory + "\\gamedata\\config\\tuning\\ogse_config.ltx", Environment.CurrentDirectory + "\\gamedata_new\\config\\tuning\\ogse_config.ltx", true);
                    }

                    // gamedata/shaders
                    if (Directory.Exists(Environment.CurrentDirectory + "\\gamedata\\shaders\\r2\\") && File.Exists(Environment.CurrentDirectory + "\\gamedata\\shaders\\r2\\configurator_defines.h"))
                    {
                        File.Copy(Environment.CurrentDirectory + "\\gamedata\\shaders\\r2\\configurator_defines.h", Environment.CurrentDirectory + "\\gamedata_new\\shaders\\r2\\configurator_defines.h", true);
                    }

                    Directory.Delete(Environment.CurrentDirectory + "\\gamedata\\", true);
                    Directory.Move(Environment.CurrentDirectory + "\\gamedata_new\\", Environment.CurrentDirectory + "\\gamedata\\");

                    if (!File.Exists(Environment.CurrentDirectory + "\\gamedata\\config\\tuning\\ogse_config.ltx"))
                    {
                        File.Copy(Environment.CurrentDirectory + "\\ogse_config.ltx", Environment.CurrentDirectory + "\\gamedata\\config\\tuning\\ogse_config.ltx", true);
                    }
                    if (!File.Exists(Environment.CurrentDirectory + "\\gamedata\\shaders\\r2\\configurator_defines.h"))
                    {
                        File.Copy(Environment.CurrentDirectory + "\\configurator_defines.h", Environment.CurrentDirectory + "\\gamedata\\shaders\\r2\\configurator_defines.h", true);
                    }

                    File.Delete(Environment.CurrentDirectory + "\\patch_2_08_cleanup");
                }

                ApplyButton.Enabled  = false;
                this.button2.Enabled = false;
                this.button3.Enabled = false;
                if (Directory.Exists(Data.SavesDir))
                {
                    File.Delete(Data.SavesDir + "\\wreset");
                    this.button4.Enabled = true;
                }
                else
                {
                    this.button4.Enabled = false;
                }
                this.label6.Text          = tmp;
                this.label7.Text          = "";
                this.label8.Text          = "";
                this.label9.Visible       = false;
                this.progressBar2.Visible = false;
                this.richTextBox1.Enabled = false;

                //            find_upd();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                this.Close();
            }
        }