コード例 #1
0
        // Reorder the active mods list.
        protected void ReorderSelectedMod(int order)
        {
            if (!selectedFromActive)
            {
                return;
            }
            int currentIndex = selectedIndex;
            int swapIndex    = selectedIndex + order;

            if (swapIndex < 0 || swapIndex > activeMods.Count - 1)
            {
                return;
            }
            InstalledMod swappedMod = activeMods[swapIndex];

            activeMods[swapIndex]    = activeMods[currentIndex];
            activeMods[currentIndex] = swappedMod;
            selectedIndex            = swapIndex;
            selectedFromActive       = true;
            selectedFromAvailable    = false;
            if (order < 0)
            {
                SoundDefOf.TickHigh.PlayOneShotOnCamera();
            }
            else
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera();
            }
        }
コード例 #2
0
        private async void uninstallToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InstalledMod mod = (InstalledMod)selected.Tag;

            if (mod.preventRemoval)
            {
                MessageBox.Show($"Removal of '{ mod.ToString() }' was cancelled because " +
                                $"this plugin is required for all mods to work.\nIf you want to remove all mods, please go to the settings tab.", "Uninstall cancelled.",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (mod.usedBy.Count > 0)
            {
                MessageBox.Show($"You are willing to remove '{ mod.ToString() }', please not that this mod is currently being used by { mod.usedBy.Count } other mods:\n\n" +
                                string.Join("\n", mod.usedBy) +
                                $"\n\nYou must first uninstall the mods above to succeed uninstalling this mod!", "Uninstall cancelled.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            ProgressChange($"Removing mod { mod.ToString() }...", 0f);

            if (await beatSaber.UninstallMod(mod, false, progress))
            {
                ProgressChange($"Removal of { mod.ToString() } succeeded.", 1f);

                UpdateModList();
                ShowNotification($"The mod { mod.ToString() } was successfully removed from Beat Saber.");
            }
            else
            {
                ProgressChange($"Removal of { mod.ToString() } failed!", 1f);
            }
        }
コード例 #3
0
        private void InstallMod()
        {
            if (string.IsNullOrEmpty(Settings.amongUsPath))
            {
                Utils.Alert("Can' t install mods as no Among Us path is set!", AlertForm.enmType.Error);
                return;
            }

            _mainform.DisableTabs();
            btnInstallMod.Enabled   = false;
            cbAvailableMods.Enabled = false;

            string parent = Directory.GetParent(Settings.amongUsPath).FullName;

            int    id   = GetCurrentId();
            string dest = Settings.folderName + "_" + ModUpdater.availableMods[id].Name.Replace(" ", "");

            _currentModPath = Path.Combine(parent, dest);

            bool copyOk = CopyAUFolder();

            _currentInstallingMod                 = new InstalledMod();
            _currentInstallingMod.Name            = ModUpdater.availableMods[id].Name;
            _currentInstallingMod.Preview_url     = ModUpdater.availableMods[id].Preview_url;
            _currentInstallingMod.Location        = _currentModPath;
            _currentInstallingMod.Id              = id;
            _currentInstallingMod.Description     = ModUpdater.availableMods[id].Description;
            _currentInstallingMod.DownloadBepInEx = ModUpdater.availableMods[id].DownloadBepInEx;
            _currentInstallingMod.NeedsAppid      = ModUpdater.availableMods[id].NeedsAppid;

            if (copyOk)
            {
                DownloadBepInEx();
            }
        }
コード例 #4
0
        // The constructor takes the mod for which it will display information as an argument.
        public Dialog_ModInfo(InstalledMod mod) : base()
        {
            // Standard configuration from the base class.
            this.doCloseButton = true;

            // Store the mod.
            this.mod = mod;
        }
コード例 #5
0
		// The constructor takes the mod for which it will display information as an argument.
		public Dialog_ModInfo(InstalledMod mod) : base()
		{
			// Standard configuration from the base class.
			this.doCloseButton = true;

			// Store the mod.
			this.mod = mod;
		}
コード例 #6
0
        // Move the selected mod to bottom of the active list.
        protected void MoveModToBottom()
        {
            if (!selectedFromActive)
            {
                return;
            }
            int          currentIndex = selectedIndex;
            InstalledMod movedMod     = activeMods[currentIndex];

            for (int i = currentIndex; i < activeMods.Count - 1; i++)
            {
                activeMods[i] = activeMods[i + 1];
            }
            activeMods[activeMods.Count - 1] = movedMod;
            selectedIndex         = activeMods.Count - 1;
            selectedFromActive    = true;
            selectedFromAvailable = false;
            SoundDefOf.TickHigh.PlayOneShotOnCamera();
        }
コード例 #7
0
        // Move the selected mod to top of the active list.
        protected void MoveModToTop()
        {
            if (!selectedFromActive)
            {
                return;
            }
            int          currentIndex = selectedIndex;
            InstalledMod movedMod     = activeMods[currentIndex];

            for (int i = currentIndex; i > 0; i--)
            {
                activeMods[i] = activeMods[i - 1];
            }
            activeMods[0]         = movedMod;
            selectedIndex         = 0;
            selectedFromActive    = true;
            selectedFromAvailable = false;
            SoundDefOf.TickHigh.PlayOneShotOnCamera();
        }
コード例 #8
0
        // Open a dialog to display the information about the mod that is normally
        // displayed in the main mods config window in vanilla.
        protected void ShowInfoForSelectedMod()
        {
            // Figure out which mod is the selected mod
            InstalledMod mod = null;

            if (selectedFromActive)
            {
                mod = activeMods[selectedIndex];
            }
            else if (selectedFromAvailable)
            {
                mod = availableMods[selectedIndex];
            }
            else
            {
                return;
            }

            // Open the dialog
            Find.WindowStack.Add(new Dialog_ModInfo(mod));
        }
コード例 #9
0
        // Move the selected mod from the active list back into the available list.
        protected void DeactivateSelectedMod()
        {
            if (!selectedFromActive)
            {
                return;
            }
            InstalledMod mod = activeMods[selectedIndex];

            availableMods.Add(mod);

            // We want to keep the available mods alphabetical, so after we add the mod
            // back into the list, we sort the list.  Having to re-sort every time the
            // list changes isn't great, but it's fast enough that we don't have to look
            // for some other strategy.
            availableMods.Sort((InstalledMod a, InstalledMod b) => {
                return(a.Name.CompareTo(b.Name));
            });

            activeMods.RemoveAt(selectedIndex);
            SelectActiveMod(selectedIndex);
            SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera();
        }
コード例 #10
0
ファイル: FormModInfo.cs プロジェクト: CodeStix/Beat-Modder
        public FormModInfo(Mod mod, InstalledMod localMod = null)
        {
            this.localMod = localMod;
            this.mod      = mod;

            InitializeComponent();

            if (mod != null)
            {
                textBoxName.Text        = mod.Name + Environment.NewLine + "\tby " + mod.author.username;
                textBoxDescription.Text = mod.description + Environment.NewLine + Environment.NewLine + "Category: " + mod.category;
                labelVersion.Text       = mod.Version;
                labelGameVersion.Text   = "game " + mod.GameVersion;
            }

            if (localMod != null)
            {
                textBoxBinaryFile.Text = $"Binary file: { localMod.binaryFile.file }";

                if (localMod.preventRemoval)
                {
                    buttonRemovable.Visible = true;
                }

                if (mod == null)
                {
                    textBoxName.Text             = localMod.Name;
                    linkLabel.Visible            = false;
                    buttonDirectDownload.Enabled = false;
                    textBoxDescription.Text      = "No description.";
                    labelVersion.Text            = localMod.Version;
                    labelGameVersion.Text        = "game " + localMod.GameVersion;
                }
            }

            CreateTree();
        }
コード例 #11
0
        private Task <int> CheckForAndInstallModUpdates(IProgress <ProgressReport> progress = null)
        {
            return(Task.Run(async() =>
            {
                progress?.Report(new ProgressReport($"Checking for mod updates...", 0f));

                List <KeyValuePair <InstalledMod, Mod> > outDatedMods = beatSaber.EnumerateOutdatedMods().ToList();
                int updatedCount = 0;

                for (int i = 0; i < outDatedMods.Count; i++)
                {
                    InstalledMod oldVersion = outDatedMods[i].Key;
                    Mod newVersion = outDatedMods[i].Value;

                    if (null != await beatSaber.UpdateMod(oldVersion, newVersion, ProgressReport.Partial(progress, (float)i / outDatedMods.Count * (1f / outDatedMods.Count), 1f / outDatedMods.Count)))
                    {
                        updatedCount++;
                    }
                }

                if (updatedCount > 0)
                {
                    progress?.Report(new ProgressReport($"{ updatedCount } mods were updated succesfully!", 1f));
                }
                else if (outDatedMods.Count == 0)
                {
                    progress?.Report(new ProgressReport($"All mods are up-to-date!", 1f));
                }
                else
                {
                    progress?.Report(new ProgressReport($"There was a problem updating mods.", 1f));
                }

                return updatedCount;
            }));
        }