Esempio n. 1
0
        bool LoadMod(string path)
        {
            try
            {
                ZipFile zf = ZipFile.Read(path);
                string  modInfoJsonText = "";
                Image   modIcon         = null;

                if (zf.ContainsEntry("modinfo.json"))
                {
                    modInfoJsonText = Zip.ReadText(zf["modinfo.json"]);
                }

                if (zf.ContainsEntry("modicon.png"))
                {
                    CrcCalculatorStream crc = zf["modicon.png"].OpenReader();
                    modIcon = Image.FromStream(crc);
                    crc.Close();
                }
                zf.Dispose();

                ModInfo modInfo = new ModInfo(path, modInfoJsonText, modIcon);

                if (!ModIDs.Contains(modInfo.ToString()))
                {
                    Mods.Add(modInfo);
                    ModIDs.Add(modInfo.ToString());
                    LF_ModList();
                    return(true);
                }
                else
                {
                    this.latestException = new Exception("This mod is already loaded. If you want to update it, remove the old version first.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                this.latestException = ex;
                return(false);
            }
        }
Esempio n. 2
0
 void RemoveMod(ModInfo mod)
 {
     File.Delete(mod.FileName);
     this.Mods.Remove(mod);
     this.ModIDs.Remove(mod.ToString());
 }