コード例 #1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            bool allDone         = true;
            bool allDownloadDone = true;

            for (int i = 0; i < modList.Count; i++)
            {
                ModInfo mod = modList[i];

                if (mod.updateState != modListView.Items[i].SubItems[5].Text)
                {
                    modListView.Items[i].SubItems[5].Text = mod.updateState;
                }

                if (mod.findQueued && !mod.isWorking)
                {
                    LockButtons();
                    mod.FindWebsiteUri();
                }
                else if (mod.checkQueued && !mod.isWorking)
                {
                    LockButtons();
                    mod.CheckForUpdate(Main.acces.mcVersion);
                }
                else if (mod.downloadQueued && !mod.isWorking && !downloadBusy)
                {
                    LockButtons();
                    downloadBusy = true;
                    mod.UpdateMod();
                }

                if (mod.downloadBusy)
                {
                    allDownloadDone = false;
                }
                if (mod.checkQueued || mod.downloadQueued || mod.findQueued)
                {
                    allDone = false;
                }

                if (mod.updateList)
                {
                    mod.updateList = false;

                    if (selectedIndex == i)
                    {
                        UpdateModFields();
                    }

                    modListView.Items[i].SubItems[1].Text = mod.uriState;
                    modListView.Items[i].SubItems[2].Text = mod.versionLocal;
                    modListView.Items[i].SubItems[3].Text = mod.versionLatest;
                    modListView.Items[i].SubItems[4].Text = mod.releaseDate;

                    modListView.Items[i].SubItems[6].Text  = mod.newFileName;
                    modListView.Items[i].SubItems[7].Text  = mod.website1;
                    modListView.Items[i].SubItems[8].Text  = mod.website2;
                    modListView.Items[i].SubItems[9].Text  = mod.website3;
                    modListView.Items[i].SubItems[10].Text = mod.website4;
                }
            }

            if (allDownloadDone)
            {
                downloadBusy = false;
            }
            if (allDone && action)
            {
                UpdateModList();
                UnlockButtons();
            }
        }
コード例 #2
0
 private void SelectItem(int index)
 {
     selectedMod   = modList[index];
     selectedIndex = index;
     UpdateModFields();
 }
コード例 #3
0
        private void DownloadFile()
        {
            SettingManager settings = new SettingManager();
            string         version  = settings.minecraftVersionLoad;

            if (stuffIndex == 3)
            {
                if (!File.Exists(cd + "\\plugins\\TechnicLauncher.exe"))
                {
                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri("http://launcher.technicpack.net/launcher4/308/TechnicLauncher.exe"), cd + "\\plugins\\TechnicLauncher.exe");
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }

            else if (stuffIndex == 4)
            {
                if (!File.Exists(cd + "\\plugins\\server_template\\RUN.bat"))
                {
                    Directory.Delete(cd + "\\plugins\\server_template", true);
                    Directory.CreateDirectory(cd + "\\plugins\\server_template");
                    Directory.CreateDirectory(cd + "\\temp");

                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri("https://dl.dropboxusercontent.com/u/46484032/TMC/ServerTemplate.zip"), cd + "\\temp\\server.zip");
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }

            else if (stuffIndex == 5)
            {
                if (version != "" && !File.Exists(cd + "\\plugins\\server_template\\minecraft_server." + version + ".jar"))
                {
                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri("https://s3.amazonaws.com/Minecraft.Download/versions/" + version + "/minecraft_server." + version + ".jar"), cd + "\\plugins\\server_template\\minecraft_server." + version + ".jar");
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }

            else if (stuffIndex == 6)
            {
                if (!Directory.Exists(cd + "\\plugins\\client_template\\bin\\natives"))
                {
                    Directory.CreateDirectory(cd + "\\temp");
                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri("https://dl.dropboxusercontent.com/u/46484032/TMC/ClientTemplate.zip"), cd + "\\temp\\client.zip");
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }

            else if (stuffIndex == 7)
            {
                if (version != "" && !File.Exists(cd + "\\plugins\\client_template\\bin\\minecraft.jar"))
                {
                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri("https://s3.amazonaws.com/Minecraft.Download/versions/" + version + "/" + version + ".jar"), cd + "\\plugins\\client_template\\bin\\minecraft.jar");
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }

            else if (stuffIndex == 8)
            {
                if (version != "" && !File.Exists(cd + "\\plugins\\client_template\\bin\\" + version + ".json"))
                {
                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri("https://s3.amazonaws.com/Minecraft.Download/versions/" + version + "/" + version + ".json"), cd + "\\plugins\\client_template\\bin\\" + version + ".json");
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }

            else if (stuffIndex == 9)
            {
                if (version != "" && Directory.GetFiles(cd + "\\plugins\\potionidhelper").Length == 0)
                {
                    ModInfo pih = new ModInfo("potionidhelper.jar");
                    pih.website = "http://minecraft.curseforge.com/mc-mods/231384-potion-id-helper";
                    pih.UpdateModValues();
                    pih.CheckForUpdate(version);

                    while (pih.checkBusy)
                    {
                    }

                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri(pih.dlSite), cd + "\\plugins\\potionidhelper\\" + pih.newFileName);
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }

            else if (stuffIndex == 10)
            {
                if (!coreExists)
                {
                    foreach (string file in Directory.GetFiles(cd + "\\plugins\\potionidhelper"))
                    {
                        if (file.Contains("brandonscore"))
                        {
                            coreExists = true;
                            break;
                        }
                    }
                }

                if (version != "" && !coreExists)
                {
                    ModInfo bc = new ModInfo("brandonscore.jar");
                    bc.website = "http://minecraft.curseforge.com/mc-mods/231382-brandons-core";
                    bc.UpdateModValues();
                    bc.CheckForUpdate(version);

                    while (bc.checkBusy)
                    {
                    }

                    WebClient client = new WebClient();
                    client.DownloadFileAsync(new Uri(bc.dlSite), cd + "\\plugins\\potionidhelper\\" + bc.newFileName);
                    client.DownloadFileCompleted   += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                    client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                }
                else
                {
                    taskDone = true;
                }

                return;
            }
        }