Example #1
0
        private static int readCfg()
        {
            string json = File.ReadAllText(_cfgLocation);

            try {
                mainCfg values = JsonConvert.DeserializeObject <mainCfg>(json);
                // TODO: implement old config version handling
                if (String.IsNullOrEmpty(values.version))
                {
                    return(2);
                }

                MCC_home      = values.MCC_home;
                MCC_version   = String.IsNullOrEmpty(values.MCC_version) ? getCurrentBuild() : values.MCC_version;
                backup_dir    = values.backup_dir;
                modpack_dir   = values.modpack_dir;
                deleteOldBaks = values.deleteOldBaks;
                patched       = values.patched;
            } catch (JsonSerializationException) {
                return(1);
            } catch (JsonReaderException) {
                return(1);
            } catch (KeyNotFoundException) {
                return(1);
            }
            if (patched == null)
            {
                return(2);
            }

            return(0);
        }
Example #2
0
        public static bool createDefaultCfg()
        {
            _cfg = new mainCfg();
            // default values declared here so that mainCfg class does not implicitly set defaults and bypass warning triggers
            MCC_home      = @"C:\Program Files (x86)\Steam\steamapps\common\Halo The Master Chief Collection";
            MCC_version   = getCurrentBuild(); // sets MCC_version to null if not found
            backup_dir    = @".\backups";
            modpack_dir   = @".\modpacks";
            deleteOldBaks = false;
            patched       = new Dictionary <string, Dictionary <string, string> >();

            saveCfg();
            form1.showMsg("A default configuration file has been created. Please review and update it as needed.", "Info");

            return(true);
        }