コード例 #1
0
        public ExceptionLogger(Mod m, Repo r)
        {
            this.version = m.version;
            this.url = r.url;
            this.id = m.id;

            this.type = ExceptionType.MOD;
        }
コード例 #2
0
        public LocalMod(bool localInstall, String installPath, String localId, String serverId, Repo source, bool enabled, String name, String description, int version, String versionCode)
        {
            this.localId = localId;
            this.localInstall = localInstall;
            this.installPath = installPath;
            this.source = source;
            this.enabled = enabled;

            this.id = serverId;
            this.name = name;
            this.description = description;
            this.version = version;
            this.versionCode = versionCode;

            this.queueForUninstall = false;
        }
コード例 #3
0
        public bool tryToFetchModList(Repo repo)
        {
            String modlist = null;
            try {
                WebClientTimeOut client = new WebClientTimeOut ();
                modlist = client.DownloadString (new Uri(repo.url+"modlist"));
            } catch (WebException ex) {
                Console.WriteLine (ex);
                repositories.Remove (repo);
                return false;
            }

            ModListMessage message = null;
            try {
                JsonReader reader = new JsonReader();
                message = reader.Read(modlist, typeof(ModListMessage)) as ModListMessage;
            } catch {
                repositories.Remove (repo);
                return false;
            }

            if (message == null) {
                repositories.Remove (repo);
                return false;
            }

            if (!message.msg.Equals("success")) {
                repositories.Remove (repo);
                return false;
            }

            modsPerRepo.Add (repo, new List<Item>(message.data));
            return true;
        }
コード例 #4
0
 public void removeRepository(Repo repo)
 {
     repositories.Remove (repo);
     updateRepoList ();
 }
コード例 #5
0
 public Mod getModOnRepo(Repo source, LocalMod localMod)
 {
     foreach (Repo repo in repositories)
         if (repo.Equals (source))
             return (Mod)modsPerRepo [repo].Find (localMod.Equals);
     return null;
 }
コード例 #6
0
 public List<Item> getModListForRepo(Repo source)
 {
     List<Item> modlist = null;
     foreach (Repo repo in repositories)
         if (repo.Equals (source))
                 modlist = modsPerRepo [repo];
     if (modlist != null) {
         modlist = modlist.FindAll (delegate(Item mod) {
             foreach (LocalMod lmod in modManager.installedMods) {
                 if (lmod.Equals(mod) && lmod.source.Equals(source))
                     return false;
             }
             return true;
         });
     }
     return modlist;
 }
コード例 #7
0
        public void installMod(Repo repo, Mod mod)
        {
            String newID = this.generateUniqueID ();
            String installPath = modsPath + Path.DirectorySeparatorChar + newID + Path.DirectorySeparatorChar + mod.name + ".mod.dll";

            LocalMod lmod = new LocalMod (false, installPath, newID, mod.id, repo, false, mod.name, mod.description, mod.version, mod.versionCode);

            String folder = modsPath + Path.DirectorySeparatorChar + newID + Path.DirectorySeparatorChar;
            if (Directory.Exists (folder))
            {
                Directory.Delete (folder);
            }
            Directory.CreateDirectory (folder);

            if (this.updateMod (lmod)) {
                this.installedMods.Add (lmod);

                //add hooks
                loader.loadModStatic (lmod.installPath);
            } else {
                Extensions.DeleteDirectory (folder);
            }
        }