Example #1
0
        private void modInfo_LinkClicked(object sender, EventArgs e)
        {
            Mod selectedMod = TableManager.GetCurrentlySelectedMod();

            if (selectedMod != null && !string.IsNullOrEmpty(selectedMod.CurrentModData.Homepage) && AMLUtils.IsValidUri(selectedMod.CurrentModData.Homepage))
            {
                Process.Start(selectedMod.CurrentModData.Homepage);
            }
        }
Example #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 : "");
            });
        }