예제 #1
0
        private void handleModDownload(bool install = false)
        {
            using (var tasker = new Tasks.Tasker(parentForm))
                using (var taskerForm = new TaskerForm())
                {
                    tasker.AttachViews(new TaskerTaskbar(), taskerForm);
                    tasker.SetStatusImage(Resources.sign_cogs);
                    tasker.SetTitle(Resources.Processing);

                    List <string> selectedMods = new List <string>();
                    foreach (ListViewItem item in modList.SelectedItems)
                    {
                        var mod = (Repository.Repository.Item)(item.Tag);
                        tasker.AddTasks(GetItemDownloadTask(mod));

                        if (mod.Kind == Repository.Repository.ItemKind.Hmod)
                        {
                            selectedMods.Add(mod.RawName);
                        }
                    }

                    if (install && selectedMods.Count > 0)
                    {
                        tasker.AddTasks(new MembootTasks(MembootTasks.MembootTaskType.MembootRecovery, forceRecoveryReload: false));
                        tasker.AddTask(ShellTasks.ShellCommand("touch /user-recovery.flag"));
                        tasker.AddTask(ShellTasks.ShellCommand("touch /mod-recovery.flag"));
                        tasker.AddTask(ShellTasks.MountBase);
                        tasker.AddTask((Tasker innerTasker, object syncObject) =>
                        {
                            tasker.AddTasks(new MembootTasks(MembootTasks.MembootTaskType.ProcessMods, selectedMods.ToArray()));
                            return(Conclusion.Success);
                        });
                    }

                    tasker.Start();

                    foreach (var mod in selectedMods)
                    {
                        var found = installedMods.Where((o) => o.RawName.Equals(mod, System.StringComparison.CurrentCultureIgnoreCase)).ToArray();
                        foreach (var foundMod in found)
                        {
                            installedMods.Remove(foundMod);
                        }
                    }

                    installedMods.AddRange(Hmod.Hmod.GetMods(true, selectedMods.ToArray(), parentForm));
                    CoreCollection.HmodInfo = installedMods.ToArray();
                    CoreCollection.Load();
                }
        }
예제 #2
0
        public SelectForm(bool onlyInstalledMods, bool allowDropMods, string[] filesToAdd = null)
        {
            InitializeComponent();
            this.onlyInstalledMods = onlyInstalledMods;

            switch (ConfigIni.Instance.hmodListSort)
            {
            case ListSort.Category:
                categoryToolStripMenuItem.Checked = true;
                break;

            case ListSort.EmulatedSystem:
                emulatedSystemToolStripMenuItem.Checked = true;
                break;

            case ListSort.Creator:
                creatorToolStripMenuItem.Checked = true;
                break;
            }

            hmods.AddRange(Hmod.GetMods(hakchi.CanInteract && onlyInstalledMods, null, this));

            if (!onlyInstalledMods)
            {
                CoreCollection.HmodInfo = hmods.ToArray();
                CoreCollection.Load();
            }

            populateList();

            if (filesToAdd != null)
            {
                AddMods(filesToAdd);
            }
            this.AllowDrop = allowDropMods;
        }