Ejemplo n.º 1
0
 public static void Initialize()
 {
     WarbandConfig._fileName = Utilities.GetConfigsPath() + "WarbandCasualtyLogConfig.txt";
     if (!File.Exists(WarbandConfig._fileName))
     {
         WarbandConfig.Save();
     }
     else
     {
         var streamReader = new StreamReader(WarbandConfig._fileName);
         var text         = streamReader.ReadToEnd();
         streamReader.Close();
         if (string.IsNullOrEmpty(text))
         {
             WarbandConfig.Save();
         }
         else
         {
             var array = text.Split('\n');
             for (var i = 0; i < array.Length; i++)
             {
                 var array2   = array[i].Split('=');
                 var property = typeof(WarbandConfig).GetProperty(array2[0]);
                 if (property == null)
                 {
                     SubModule.invalidConfigFlag = true;
                 }
                 else
                 {
                     var text2 = array2[1];
                     try
                     {
                         if (property.PropertyType == typeof(string))
                         {
                             var customAttribute = property.GetCustomAttribute <WarbandConfig.ConfigPropertyString>();
                             if (customAttribute.IsValidValue(text2))
                             {
                                 property.SetValue(null, text2);
                             }
                             else
                             {
                                 SubModule.invalidConfigFlag = true;
                             }
                         }
                         else
                         {
                             SubModule.invalidConfigFlag = true;
                         }
                     }
                     catch
                     {
                         SubModule.invalidConfigFlag = true;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();
            WarbandConfig.Initialize();
            var harmony = new Harmony("top.hirtol.warbandcasualty.patch");

            harmony.PatchAll();
            LogPatch.loadConfigValues();
            WarbandConfig.Save();
        }
Ejemplo n.º 3
0
 protected override void OnSubModuleUnloaded()
 {
     WarbandConfig.Save();
 }