Exemplo n.º 1
0
        private void DataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            Mod selectedMod = TableManager.GetCurrentlySelectedMod();

            if (dataGridView1.SelectedRows.Count == 1 && !ModManager.IsReadOnly)
            {
                DataGridViewRow selectedRow = dataGridView1.SelectedRows[0];
                int             newModIndex = selectedRow.Index;

                // If shift is held, that means we are changing the order
                if (canAdjustOrder && ModifierKeys == Keys.Shift && selectedMod != null && previouslySelectedMod != null && previouslySelectedMod != selectedMod)
                {
                    AMLUtils.InvokeUI(() =>
                    {
                        ModManager.SwapMod(previouslySelectedMod, newModIndex, false);
                        previouslySelectedMod = null;
                        canAdjustOrder        = false;
                        TableManager.Refresh();
                        canAdjustOrder = true;

                        dataGridView1.ClearSelection();
                        dataGridView1.Rows[newModIndex].Selected = true;
                        dataGridView1.CurrentCell = dataGridView1.Rows[newModIndex].Cells[0];
                        selectedMod = ModManager.Mods[newModIndex];

                        foreach (Mod mod in ModManager.Mods)
                        {
                            mod.Dirty = true;                                  // Update all the priorities on disk to be safe
                        }
                        ModManager.FullUpdate();
                    });
                }
            }

            previouslySelectedMod = selectedMod;

            RefreshModInfoLabel();
        }
Exemplo n.º 2
0
        private void RefreshModInfoLabel()
        {
            AMLUtils.InvokeUI(() =>
            {
                Mod selectedMod = TableManager?.GetCurrentlySelectedMod();
                if (selectedMod == null)
                {
                    AdjustModInfoText("");
                    return;
                }

                string kosherDescription = selectedMod.CurrentModData.Description;
                if (!string.IsNullOrEmpty(kosherDescription) && kosherDescription.Length > 200)
                {
                    kosherDescription = kosherDescription.Substring(0, 200) + "...";
                }

                string kosherSync = "N/A";
                switch (selectedMod.CurrentModData.Sync)
                {
                case SyncMode.None:
                    kosherSync = "None";
                    break;

                case SyncMode.ClientOnly:
                    kosherSync = "Client only";
                    break;

                case SyncMode.ServerOnly:
                    kosherSync = "Server only";
                    break;

                case SyncMode.ServerAndClient:
                    kosherSync = "Server and client";
                    break;
                }

                long knownSize = -1;
                try
                {
                    knownSize = ModManager.GetSizeOnDisk(selectedMod);
                }
                catch (Exception ex)
                {
                    if (!(ex is IOException) && !(ex is FileNotFoundException))
                    {
                        throw;
                    }
                }

                string additionalData = "";
                if (knownSize >= 0)
                {
                    additionalData += "\nSize: " + AMLUtils.FormatFileSize(knownSize);
                }

                bool hasHomepage = !string.IsNullOrEmpty(selectedMod.CurrentModData.Homepage) && AMLUtils.IsValidUri(selectedMod.CurrentModData.Homepage);

                string realText = "Name: " + selectedMod.CurrentModData.Name;
                if (!string.IsNullOrEmpty(kosherDescription))
                {
                    realText += "\nDescription: " + kosherDescription;
                }
                realText += "\nSync: " + kosherSync;
                realText += additionalData;
                realText += hasHomepage ? "\nWebsite: " : "";

                AdjustModInfoText(realText, hasHomepage ? selectedMod.CurrentModData.Homepage : "");
            });
        }