public override void PreOpen() { base.PreOpen(); ModLister.RebuildModList(); modsInListOrderDirty = true; selectedMod = ModsInListOrder().FirstOrDefault(); activeModsWhenOpenedHash = ModLister.InstalledModsListHash(activeOnly: true); RecacheSelectedModRequirements(); foreach (ModMetaData mod in ModLister.AllInstalledMods) { ModContentPack modContentPack = LoadedModManager.RunningModsListForReading.FirstOrDefault((ModContentPack p) => mod.SamePackageId(p.PackageId)); if (modContentPack != null) { mod.translationMod = !modContentPack.AnyNonTranslationContentLoaded() && modContentPack.AnyTranslationsLoaded(); continue; } List <string> list = (from d in mod.RootDir.EnumerateDirectories() select d.Name).ToList(); for (int i = 0; i < translationOnlyModFolders.Count; i++) { if (list.Count == translationOnlyModFolders[i].Count && list.ListsEqualIgnoreOrder(translationOnlyModFolders[i])) { mod.translationMod = true; break; } } } }
public override void PreOpen() { base.PreOpen(); ModLister.RebuildModList(); this.selectedMod = this.ModsInListOrder().FirstOrDefault <ModMetaData>(); this.activeModsWhenOpenedHash = ModLister.InstalledModsListHash(true); }
private static void PostCloseDetour(this Page_ModsConfig self) { if (SettingsHandler.LastRestartOnClose.Value != RestartOnClose) { SettingsHandler.LastRestartOnClose.Value = RestartOnClose; HugsLibController.Instance.Settings.SaveChanges(); } ModsConfig.Save(); int activeModsWhenOpenedHash = (int)typeof(Page_ModsConfig).GetField("activeModsWhenOpenedHash", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(self); if (activeModsWhenOpenedHash != ModLister.InstalledModsListHash(true)) { if (RestartOnClose) { PlatformHandler.RestartRimWorld(); } //Copy of source from here bool assemblyWasLoaded = LoadedModManager.RunningMods.Any((ModContentPack m) => m.LoadedAnyAssembly); LongEventHandler.QueueLongEvent(delegate { PlayDataLoader.ClearAllPlayData(); PlayDataLoader.LoadAllPlayData(false); if (assemblyWasLoaded) { LongEventHandler.ExecuteWhenFinished(delegate { Find.WindowStack.Add(new Dialog_MessageBox("ModWithAssemblyWasUnloaded".Translate(), null, null, null, null, null, false)); }); } }, "LoadingLongEvent", true, null); } }
public override void PreOpen() { base.PreOpen(); ModLister.RebuildModList(); selectedMod = ModsInListOrder().FirstOrDefault(); activeModsWhenOpenedHash = ModLister.InstalledModsListHash(activeOnly: true); }
public override void PostClose() { ModsConfig.Save(); if (this.activeModsWhenOpenedHash != ModLister.InstalledModsListHash(true)) { ModsConfig.RestartFromChangedMods(); } }
public override void PreOpen() { base.PreOpen(); ModLister.RebuildModList(); modsInListOrderDirty = true; selectedMod = ModsInListOrder().FirstOrDefault(); activeModsWhenOpenedHash = ModLister.InstalledModsListHash(activeOnly: true); RecacheSelectedModRequirements(); }
public override void PostClose() { ModsConfig.Save(); foreach (ModMetaData item in ModsConfig.ActiveModsInLoadOrder) { item.UnsetPreviewImage(); } Resources.UnloadUnusedAssets(); if (activeModsWhenOpenedHash != ModLister.InstalledModsListHash(activeOnly: true)) { ModsConfig.RestartFromChangedMods(); } }
public override void DoWindowContents(Rect rect) { Rect mainRect = GetMainRect(rect, 0f, ignoreTitle: true); GUI.BeginGroup(mainRect); Text.Font = GameFont.Small; float num = 0f; if (Widgets.ButtonText(new Rect(17f, num, 316f, 30f), "OpenSteamWorkshop".Translate())) { SteamUtility.OpenSteamWorkshopPage(); } num += 30f; if (Widgets.ButtonText(new Rect(17f, num, 316f, 30f), "GetModsFromForum".Translate())) { Application.OpenURL("http://rimworldgame.com/getmods"); } num += 30f; num += 17f; filter = Widgets.TextField(new Rect(0f, num, 350f, 30f), filter); num += 30f; num += 10f; float num2 = 47f; Rect rect2 = new Rect(0f, num, 350f, mainRect.height - num - num2); Widgets.DrawMenuSection(rect2); float height = (float)ModLister.AllInstalledMods.Count() * 26f + 8f; Rect rect3 = new Rect(0f, 0f, rect2.width - 16f, height); Widgets.BeginScrollView(rect2, ref modListScrollPosition, rect3); Rect rect4 = rect3.ContractedBy(4f); Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.ColumnWidth = rect4.width; float num3 = modListScrollPosition.y - 26f; float num4 = modListScrollPosition.y + rect2.height; listing_Standard.Begin(rect4); int num5 = ReorderableWidget.NewGroup(delegate(int from, int to) { ModsConfig.Reorder(from, to); modsInListOrderDirty = true; }, ReorderableDirection.Vertical); int num6 = 0; foreach (ModMetaData item in ModsInListOrder()) { float num7 = (float)num6 * 26f; bool active = item.Active; Rect rect5 = new Rect(0f, (float)num6 * 26f, listing_Standard.ColumnWidth, 26f); if (active) { ReorderableWidget.Reorderable(num5, rect5); } if (num7 >= num3 && num7 <= num4) { DoModRow(rect5, item, num6, num5); } num6++; } int downloadingItemsCount = WorkshopItems.DownloadingItemsCount; for (int i = 0; i < downloadingItemsCount; i++) { DoModRowDownloading(listing_Standard, num6); num6++; } listing_Standard.End(); Widgets.EndScrollView(); num += rect2.height; num += 10f; if (Widgets.ButtonText(new Rect(17f, num, 316f, 30f), "ResolveModOrder".Translate())) { ModsConfig.TrySortMods(); modsInListOrderDirty = true; } Rect position = new Rect(rect2.xMax + 17f, 0f, mainRect.width - rect2.width - 17f, mainRect.height); GUI.BeginGroup(position); if (selectedMod != null) { Text.Font = GameFont.Medium; Rect rect6 = new Rect(0f, 0f, position.width, 40f); Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect6, selectedMod.Name.Truncate(rect6.width)); Text.Anchor = TextAnchor.UpperLeft; Rect position2 = new Rect(0f, rect6.yMax, 0f, 20f); if (selectedMod.PreviewImage != null) { position2.width = Mathf.Min(selectedMod.PreviewImage.width, position.width); position2.height = (float)selectedMod.PreviewImage.height * (position2.width / (float)selectedMod.PreviewImage.width); float num8 = Mathf.Ceil(position.height * 0.37f); if (position2.height > num8) { float height2 = position2.height; position2.height = num8; position2.width *= position2.height / height2; } if (position2.height > 300f) { position2.width *= 300f / position2.height; position2.height = 300f; } position2.x = position.width / 2f - position2.width / 2f; GUI.DrawTexture(position2, selectedMod.PreviewImage, ScaleMode.ScaleToFit); } float num9 = position2.yMax + 10f; Text.Font = GameFont.Small; float num10 = num9; if (!selectedMod.Author.NullOrEmpty()) { Widgets.Label(new Rect(0f, num10, position.width / 2f, Text.LineHeight), "Author".Translate() + ": " + selectedMod.Author); num10 += Text.LineHeight; } if (!selectedMod.PackageId.NullOrEmpty()) { GUI.color = Color.gray; Widgets.Label(new Rect(0f, num10, position.width / 2f, Text.LineHeight), "ModPackageId".Translate() + ": " + selectedMod.PackageIdPlayerFacing); num10 += Text.LineHeight; GUI.color = Color.white; } float num11 = num9; WidgetRow widgetRow = new WidgetRow(position.width, num11, UIDirection.LeftThenUp); if (SteamManager.Initialized && selectedMod.OnSteamWorkshop) { if (widgetRow.ButtonText("Unsubscribe".Translate())) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(selectedMod.Name), delegate { selectedMod.enabled = false; Workshop.Unsubscribe(selectedMod); Notify_SteamItemUnsubscribed(selectedMod.GetPublishedFileId()); }, destructive: true)); } if (widgetRow.ButtonText("WorkshopPage".Translate())) { SteamUtility.OpenWorkshopPage(selectedMod.GetPublishedFileId()); } num11 += 25f; } if (!selectedMod.IsCoreMod) { Text.Anchor = TextAnchor.UpperRight; Rect rect7 = new Rect(position.width - 300f, num11, 300f, Text.LineHeight); if (!selectedMod.VersionCompatible) { GUI.color = Color.red; } Widgets.Label(rect7, "ModTargetVersion".Translate() + ": " + selectedMod.SupportedVersionsReadOnly.Select(delegate(System.Version v) { string text = (VersionControl.IsCompatible(v) ? "<color=green>" : "<color=red>"); string text2 = "</color>"; return((v.Build > 0) ? $"{text}{v.Major.ToString()}.{v.Minor.ToString()}.{v.Build.ToString()}{text2}" : $"{text}{v.Major.ToString()}.{v.Minor.ToString()}{text2}"); }).ToCommaList()); GUI.color = Color.white; num11 += Text.LineHeight; } if (anyReqsCached) { Text.Anchor = TextAnchor.MiddleRight; TaggedString taggedString = "ModDisplayFulfilledRequirements".Translate(); float num12 = Text.CalcSize(taggedString).x + 24f + 4f; Rect rect8 = new Rect(position.width - num12, num11, num12, 24f); bool flag = displayFullfilledRequirements; Widgets.CheckboxLabeled(rect8, taggedString, ref displayFullfilledRequirements); if (flag != displayFullfilledRequirements) { RecacheSelectedModRequirements(); } num11 += 34f; } Text.Anchor = TextAnchor.UpperLeft; float num13 = Mathf.Max(num10, num11) + (anyReqsCached ? 10f : 17f); Rect outRect = new Rect(0f, num13, position.width, position.height - num13 - 40f); float width = outRect.width - 16f; float num14 = Text.CalcHeight(selectedMod.Description, width); num14 = Mathf.Min(num14 * 1.25f, num14 + 200f); Rect viewRect = new Rect(0f, 0f, width, num14 + modRequirementsHeightCached + (anyReqsInfoToShowCached ? 10f : 0f)); float num15 = ((viewRect.height > outRect.height) ? 16f : 0f); Widgets.BeginScrollView(outRect, ref modDescriptionScrollPosition, viewRect); float num16 = 0f; if (anyReqsInfoToShowCached) { num16 = DoRequirementSection(position.width - num15); num16 += 10f; } Widgets.Label(new Rect(0f, num16, viewRect.width - num15, viewRect.height - num16), selectedMod.Description); Widgets.EndScrollView(); if (Prefs.DevMode && SteamManager.Initialized && selectedMod.CanToUploadToWorkshop() && Widgets.ButtonText(new Rect(0f, position.yMax - 40f, 200f, 40f), Workshop.UploadButtonLabel(selectedMod.GetPublishedFileId()))) { List <string> list = selectedMod.loadFolders?.GetIssueList(selectedMod); if (selectedMod.HadIncorrectlyFormattedVersionInMetadata) { Messages.Message("MessageModNeedsWellFormattedTargetVersion".Translate(VersionControl.CurrentMajor + "." + VersionControl.CurrentMinor), MessageTypeDefOf.RejectInput, historical: false); } else if (selectedMod.HadIncorrectlyFormattedPackageId) { Find.WindowStack.Add(new Dialog_MessageBox("MessageModNeedsWellFormattedPackageId".Translate())); } else if (!list.NullOrEmpty()) { Find.WindowStack.Add(new Dialog_MessageBox("ModHadLoadFolderIssues".Translate() + "\n" + list.ToLineList(" - "))); } else { Find.WindowStack.Add(new Dialog_ConfirmModUpload(selectedMod, delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation("ConfirmContentAuthor".Translate(), delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); Workshop.Upload(selectedMod); }, destructive: true); dialog_MessageBox.buttonAText = "Yes".Translate(); dialog_MessageBox.buttonBText = "No".Translate(); dialog_MessageBox.interactionDelay = 6f; Find.WindowStack.Add(dialog_MessageBox); })); } } if (!selectedMod.Url.NullOrEmpty()) { Text.Anchor = TextAnchor.MiddleLeft; float num17 = Mathf.Min(position.width / 2f, Text.CalcSize(selectedMod.Url).x); if (Widgets.ButtonText(new Rect(position.width - num17, outRect.yMax, num17, position.yMax - outRect.yMax), selectedMod.Url.Truncate(num17), drawBackground: false)) { Application.OpenURL(selectedMod.Url); } Text.Anchor = TextAnchor.UpperLeft; } } GUI.EndGroup(); GUI.EndGroup(); Text.Font = GameFont.Tiny; TaggedString taggedString2 = "GameVersionIndicator".Translate() + ": " + VersionControl.CurrentVersionString; float x = Text.CalcSize(taggedString2).x; Widgets.Label(new Rect(0f, rect.height - 15f, x, Text.LineHeight), taggedString2); Text.Font = GameFont.Small; int num18 = ModLister.InstalledModsListHash(activeOnly: true); if (activeModsHash == -1 || activeModsHash != num18) { modWarningsCached = ModsConfig.GetModWarnings(); RecacheSelectedModRequirements(); activeModsHash = num18; modsInListOrderDirty = true; } }