private void DoScenarioListEntry(Rect rect, Scenario scen) { bool flag = this.curScen == scen; Widgets.DrawOptionBackground(rect, flag); MouseoverSounds.DoRegion(rect); Rect rect2 = rect.ContractedBy(4f); Text.Font = GameFont.Small; Rect rect3 = rect2; rect3.height = Text.CalcHeight(scen.name, rect3.width); Widgets.Label(rect3, scen.name); Text.Font = GameFont.Tiny; Rect rect4 = rect2; rect4.yMin = rect3.yMax; Widgets.Label(rect4, scen.GetSummary()); if (scen.enabled) { WidgetRow widgetRow = new WidgetRow(rect.xMax, rect.y, UIDirection.LeftThenDown, 99999f, 4f); if (scen.Category == ScenarioCategory.CustomLocal && widgetRow.ButtonIcon(TexButton.DeleteX, "Delete".Translate(), new Color?(GenUI.SubtleMouseoverColor))) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(scen.File.Name), delegate { scen.File.Delete(); ScenarioLister.MarkDirty(); }, true, null)); } if (scen.Category == ScenarioCategory.SteamWorkshop && widgetRow.ButtonIcon(TexButton.DeleteX, "Unsubscribe".Translate(), new Color?(GenUI.SubtleMouseoverColor))) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(scen.File.Name), delegate { scen.enabled = false; if (this.curScen == scen) { this.curScen = null; this.EnsureValidSelection(); } Workshop.Unsubscribe(scen); }, true, null)); } if (scen.GetPublishedFileId() != PublishedFileId_t.Invalid) { if (widgetRow.ButtonIcon(ContentSource.SteamWorkshop.GetIcon(), "WorkshopPage".Translate(), null)) { SteamUtility.OpenWorkshopPage(scen.GetPublishedFileId()); } if (scen.CanToUploadToWorkshop()) { widgetRow.Icon(Page_SelectScenario.CanUploadIcon, "CanBeUpdatedOnWorkshop".Translate()); } } if (!flag && Widgets.ButtonInvisible(rect, false)) { this.curScen = scen; SoundDefOf.Click.PlayOneShotOnCamera(null); } } }
private static void DrawCrossPromotions(ref Rect canvas, IEnumerable <CrossPromotion> promotions) { var backgroundRect = new Rect( canvas.xMin, canvas.yMin, canvas.width, PromotionsHeight); var outRect = backgroundRect.ContractedBy(SmallMargin / 2); var height = (int)outRect.height; var width = promotions.Sum(p => p.NormalizedWidth(height)) + (promotions.Count() - 1) * SmallMargin; if (width > outRect.width) { height -= 16; // recalculate total width width = promotions.Sum(p => p.NormalizedWidth(height)) + (promotions.Count() - 1) * SmallMargin; } var viewRect = new Rect( canvas.xMin, canvas.yMin, width, height); var pos = viewRect.min; canvas.yMin += PromotionsHeight + SmallMargin; Widgets.DrawBoxSolid(backgroundRect, SlightlyDarkBackground); if (Mouse.IsOver(outRect) && Event.current.type == EventType.ScrollWheel) { _scrollPosition.x += Event.current.delta.y * Constants.ScrollSpeed; } Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect); foreach (var promotion in promotions) { var normalizedWidth = promotion.NormalizedWidth(height); var rect = new Rect(pos.x, pos.y, normalizedWidth, height); if (Widgets.ButtonImage(rect, promotion.Preview, new Color(.9f, .9f, .9f), Color.white)) { if (!promotion.Installed) { var options = Utilities.NewOptions; options.Add(new FloatMenuOption(I18n.WorkshopPage(promotion.Name), () => SteamUtility.OpenWorkshopPage(promotion.FileId))); options.Add(Resolvers.SubscribeOption(promotion.Name, promotion.FileId.ToString())); Utilities.FloatMenu(options); } else { var button = ModButtonManager.AllButtons.FirstOrDefault(b => b.Name == promotion.Name); if (button != null) { Page_BetterModConfig.Instance.Selected = button; } } } TooltipHandler.TipRegion(rect, promotion.Name + "\n\n" + promotion.Description); pos.x += normalizedWidth + SmallMargin; } Widgets.EndScrollView(); }
private static void OnItemSubmitted(SubmitItemUpdateResult_t result, bool IOFailure) { if (IOFailure || result.m_eResult != EResult.k_EResultOK) { Workshop.uploadingHook = null; Dialog_WorkshopOperationInProgress.CloseAll(); Log.Error("Workshop: OnItemSubmitted failure. Result: " + result.m_eResult.GetLabel(), false); Find.WindowStack.Add(new Dialog_MessageBox("WorkshopSubmissionFailed".Translate(new object[] { GenText.SplitCamelCase(result.m_eResult.GetLabel()) }), null, null, null, null, null, false, null, null)); } else { SteamUtility.OpenWorkshopPage(Workshop.uploadingHook.PublishedFileId); Messages.Message("WorkshopUploadSucceeded".Translate(new object[] { Workshop.uploadingHook.Name }), MessageTypeDefOf.TaskCompletion, false); if (Prefs.LogVerbose) { Log.Message("Workshop: Item submit result: " + result.m_eResult, false); } } Workshop.curStage = WorkshopInteractStage.None; Workshop.submitResult = null; }
private static Action CreateModRowActionSteam(ModMetaDataEnhanced mod) { return(new Action(() => { List <FloatMenuOption> options = new List <FloatMenuOption> { new FloatMenuOption("InstallLocal".Translate(), () => Find.WindowStack.Add(new InstallModDialog(mod))), new FloatMenuOption("Rename".ToString(), () => StartRename(mod)), new FloatMenuOptionColorPicker((color) => mod.TextColor = color, MenuOptionPriority.Default, textColors), new FloatMenuOption("OpenWorkshopPage".Translate(), () => { SteamUtility.OpenWorkshopPage(mod.OriginalMetaData.GetPublishedFileId()); }), new FloatMenuOption("Unsubscribe".Translate(), () => { RemoveMod(mod); }) }; Find.WindowStack.Add((Window) new FloatMenu(options)); })); }
private void DoModRow(Rect r, ModMetaData mod, int index, int reorderableGroup) { bool active = mod.Active; Action clickAction = null; if (mod.Source == ContentSource.SteamWorkshop) { clickAction = delegate { SteamUtility.OpenWorkshopPage(mod.GetPublishedFileId()); }; } ContentSourceUtility.DrawContentSource(r, mod.Source, clickAction); r.xMin += 28f; bool selected = mod == selectedMod; Rect rect = r; if (mod.enabled) { string text = ""; if (active) { text += "DragToReorder".Translate() + ".\n"; } if (!mod.VersionCompatible) { GUI.color = Color.yellow; if (!text.NullOrEmpty()) { text += "\n"; } text = ((!mod.MadeForNewerVersion) ? ((string)(text + "ModNotMadeForThisVersion".Translate())) : ((string)(text + "ModNotMadeForThisVersion_Newer".Translate()))); } if (active && !modWarningsCached.NullOrEmpty() && !modWarningsCached[index].NullOrEmpty()) { GUI.color = Color.red; if (!text.NullOrEmpty()) { text += "\n"; } text += modWarningsCached[index]; } GUI.color = FilteredColor(GUI.color, mod.Name); if (!text.NullOrEmpty()) { TooltipHandler.TipRegion(rect, new TipSignal(text, mod.GetHashCode() * 3311)); } float num = rect.width - 24f; if (active) { GUI.DrawTexture(new Rect(rect.xMax - 48f + 2f, rect.y, 24f, 24f), TexButton.DragHash); num -= 24f; } Text.Font = GameFont.Small; string label = mod.Name.Truncate(num, truncatedModNamesCache); bool checkOn = active; if (Widgets.CheckboxLabeledSelectable(rect, label, ref selected, ref checkOn)) { selectedMod = mod; RecacheSelectedModRequirements(); } if (active && !checkOn && mod.IsCoreMod) { ModMetaData coreMod = mod; Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDisableCoreMod".Translate(), delegate { coreMod.Active = false; truncatedModNamesCache.Clear(); })); } else { if (!active && checkOn) { foreach (ModMetaData item in ModsConfig.ActiveModsInLoadOrder) { if (item.PackageIdNonUnique.Equals(mod.PackageIdNonUnique, StringComparison.InvariantCultureIgnoreCase)) { Find.WindowStack.Add(new Dialog_MessageBox("MessageModWithPackageIdAlreadyEnabled".Translate(mod.PackageIdPlayerFacing, item.Name))); return; } } } if (checkOn != active) { mod.Active = checkOn; } truncatedModNamesCache.Clear(); } } else { GUI.color = FilteredColor(Color.gray, mod.Name); Widgets.Label(rect, mod.Name); } GUI.color = Color.white; }
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; } }
public override void DoWindowContents(Rect rect) { Rect mainRect = base.GetMainRect(rect, 0f, true); GUI.BeginGroup(mainRect); Text.Font = GameFont.Small; float num = 0f; Rect rect2 = new Rect(17f, num, 316f, 30f); if (Widgets.ButtonText(rect2, "OpenSteamWorkshop".Translate(), true, false, true)) { SteamUtility.OpenSteamWorkshopPage(); } num += 30f; Rect rect3 = new Rect(17f, num, 316f, 30f); if (Widgets.ButtonText(rect3, "GetModsFromForum".Translate(), true, false, true)) { Application.OpenURL("http://rimworldgame.com/getmods"); } num += 30f; num += 17f; this.filter = Widgets.TextField(new Rect(0f, num, 350f, 30f), this.filter); num += 30f; num += 10f; Rect rect4 = new Rect(0f, num, 350f, mainRect.height - num); Widgets.DrawMenuSection(rect4); float height = (float)ModLister.AllInstalledMods.Count <ModMetaData>() * 26f + 8f; Rect rect5 = new Rect(0f, 0f, rect4.width - 16f, height); Widgets.BeginScrollView(rect4, ref this.modListScrollPosition, rect5, true); Rect rect6 = rect5.ContractedBy(4f); Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.ColumnWidth = rect6.width; listing_Standard.Begin(rect6); int reorderableGroup = ReorderableWidget.NewGroup(delegate(int from, int to) { ModsConfig.Reorder(from, to); }, ReorderableDirection.Vertical, -1f, null); int num2 = 0; foreach (ModMetaData current in this.ModsInListOrder()) { this.DoModRow(listing_Standard, current, num2, reorderableGroup); num2++; } int downloadingItemsCount = WorkshopItems.DownloadingItemsCount; for (int i = 0; i < downloadingItemsCount; i++) { this.DoModRowDownloading(listing_Standard, num2); num2++; } listing_Standard.End(); Widgets.EndScrollView(); Rect position = new Rect(rect4.xMax + 17f, 0f, mainRect.width - rect4.width - 17f, mainRect.height); GUI.BeginGroup(position); if (this.selectedMod != null) { Text.Font = GameFont.Medium; Rect rect7 = new Rect(0f, 0f, position.width, 40f); Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect7, this.selectedMod.Name.Truncate(rect7.width, null)); Text.Anchor = TextAnchor.UpperLeft; if (!this.selectedMod.IsCoreMod) { Rect rect8 = rect7; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.LowerRight; if (!this.selectedMod.VersionCompatible) { GUI.color = Color.red; } Widgets.Label(rect8, "ModTargetVersion".Translate(this.selectedMod.TargetVersion)); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } Rect position2 = new Rect(0f, rect7.yMax, 0f, 20f); if (this.selectedMod.previewImage != null) { position2.width = Mathf.Min((float)this.selectedMod.previewImage.width, position.width); position2.height = (float)this.selectedMod.previewImage.height * (position2.width / (float)this.selectedMod.previewImage.width); if (position2.height > 300f) { position2.width *= 300f / position2.height; position2.height = 300f; } position2.x = position.width / 2f - position2.width / 2f; GUI.DrawTexture(position2, this.selectedMod.previewImage, ScaleMode.ScaleToFit); } Text.Font = GameFont.Small; float num3 = position2.yMax + 10f; if (!this.selectedMod.Author.NullOrEmpty()) { Rect rect9 = new Rect(0f, num3, position.width / 2f, 25f); Widgets.Label(rect9, "Author".Translate() + ": " + this.selectedMod.Author); } if (!this.selectedMod.Url.NullOrEmpty()) { float num4 = Mathf.Min(position.width / 2f, Text.CalcSize(this.selectedMod.Url).x); Rect rect10 = new Rect(position.width - num4, num3, num4, 25f); Text.WordWrap = false; if (Widgets.ButtonText(rect10, this.selectedMod.Url, false, false, true)) { Application.OpenURL(this.selectedMod.Url); } Text.WordWrap = true; } WidgetRow widgetRow = new WidgetRow(position.width, num3 + 25f, UIDirection.LeftThenUp, 99999f, 4f); if (SteamManager.Initialized && this.selectedMod.OnSteamWorkshop) { if (widgetRow.ButtonText("Unsubscribe", null, true, false)) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(this.selectedMod.Name), delegate { this.selectedMod.enabled = false; Workshop.Unsubscribe(this.selectedMod); this.Notify_SteamItemUnsubscribed(this.selectedMod.GetPublishedFileId()); }, true, null)); } if (widgetRow.ButtonText("WorkshopPage".Translate(), null, true, false)) { SteamUtility.OpenWorkshopPage(this.selectedMod.GetPublishedFileId()); } } float num5 = num3 + 25f + 24f; Rect outRect = new Rect(0f, num5, position.width, position.height - num5 - 40f); float width = outRect.width - 16f; Rect rect11 = new Rect(0f, 0f, width, Text.CalcHeight(this.selectedMod.Description, width)); Widgets.BeginScrollView(outRect, ref this.modDescriptionScrollPosition, rect11, true); Widgets.Label(rect11, this.selectedMod.Description); Widgets.EndScrollView(); if (Prefs.DevMode && SteamManager.Initialized && this.selectedMod.CanToUploadToWorkshop()) { Rect rect12 = new Rect(0f, position.yMax - 40f, 200f, 40f); if (Widgets.ButtonText(rect12, Workshop.UploadButtonLabel(this.selectedMod.GetPublishedFileId()), true, false, true)) { if (!VersionControl.IsWellFormattedVersionString(this.selectedMod.TargetVersion)) { Messages.Message("MessageModNeedsWellFormattedTargetVersion".Translate(VersionControl.CurrentVersionString), MessageTypeDefOf.RejectInput, false); } else { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation("ConfirmContentAuthor".Translate(), delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); Workshop.Upload(this.selectedMod); }, true, null); dialog_MessageBox.buttonAText = "Yes".Translate(); dialog_MessageBox.buttonBText = "No".Translate(); dialog_MessageBox.interactionDelay = 6f; Find.WindowStack.Add(dialog_MessageBox); }, true, null)); } } } } GUI.EndGroup(); GUI.EndGroup(); }
private void DoModRow(Listing_Standard listing, ModMetaData mod, int index, int reorderableGroup) { Rect rect = listing.GetRect(26f); if (mod.Active) { ReorderableWidget.Reorderable(reorderableGroup, rect, false); } Action clickAction = null; if (mod.Source == ContentSource.SteamWorkshop) { clickAction = delegate { SteamUtility.OpenWorkshopPage(mod.GetPublishedFileId()); }; } ContentSourceUtility.DrawContentSource(rect, mod.Source, clickAction); rect.xMin += 28f; bool flag = mod == this.selectedMod; bool active = mod.Active; Rect rect2 = rect; if (mod.enabled) { string text = string.Empty; if (mod.Active) { text = text + "DragToReorder".Translate() + ".\n\n"; } if (!mod.VersionCompatible) { GUI.color = Color.red; if (mod.MadeForNewerVersion) { text += "ModNotMadeForThisVersion_Newer".Translate(); } else { text += "ModNotMadeForThisVersion".Translate(); } } GUI.color = this.FilteredColor(GUI.color, mod.Name); if (!text.NullOrEmpty()) { TooltipHandler.TipRegion(rect2, new TipSignal(text, mod.GetHashCode() * 3311)); } float num = rect2.width - 24f; if (mod.Active) { Rect position = new Rect(rect2.xMax - 48f + 2f, rect2.y, 24f, 24f); GUI.DrawTexture(position, TexButton.DragHash); num -= 24f; } Text.Font = GameFont.Small; string label = mod.Name.Truncate(num, this.truncatedModNamesCache); if (Widgets.CheckboxLabeledSelectable(rect2, label, ref flag, ref active)) { this.selectedMod = mod; } if (mod.Active && !active && mod.IsCoreMod) { ModMetaData coreMod = mod; Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDisableCoreMod".Translate(), delegate { coreMod.Active = false; this.truncatedModNamesCache.Clear(); }, false, null)); } else { mod.Active = active; this.truncatedModNamesCache.Clear(); } } else { GUI.color = this.FilteredColor(Color.gray, mod.Name); Widgets.Label(rect2, mod.Name); } GUI.color = Color.white; }
internal static void DoWindowContents(this Page_ModsConfig instance, Rect rect) { Rect mainRect = (Rect)AccessTools.Method(typeof(Page_ModsConfig), "GetMainRect").Invoke(instance, new object[] { rect, 0f, true }); GUI.BeginGroup(mainRect); Text.Font = GameFont.Small; float num = 0f; Rect rect2 = new Rect(17f, num, 316f, 30f); if (Widgets.ButtonText(rect2, "OpenSteamWorkshop".Translate(), true, false, true)) { SteamUtility.OpenSteamWorkshopPage(); } num += 30f; Rect rect3 = new Rect(17f, num, 316f, 30f); if (Widgets.ButtonText(rect3, "GetModsFromForum".Translate(), true, false, true)) { Application.OpenURL("http://rimworldgame.com/getmods"); } num += 30f; num += 17f; // Modlist Rect rect4 = new Rect(0f, num, 350f, mainRect.height - num); Widgets.DrawMenuSection(rect4, true); float height = (float)(ModLister.AllInstalledMods.Count <ModMetaData>() * 34 + 300); Rect rect5 = new Rect(0f, 26f, rect4.width - 16f, height); Widgets.BeginScrollView(rect4, ref modListScrollPosition, rect5, true); Rect rect6 = rect5.ContractedBy(4f); Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.ColumnWidth = rect6.width; listing_Standard.Begin(rect6); Rect searchBox = listing_Standard.GetRect(26f); searchString = TextEntryWidgets.TextEntryWithPlaceHolder(searchBox, searchString, "SearchPlaceHolder".Translate()); int reorderableGroup = -1; if (!SearchInProgress) { reorderableGroup = ReorderableWidget.NewGroup(delegate(int from, int to) { AccessTools.Method(typeof(ModsConfig), "Reorder").Invoke(null, new object[] { from, to }); SoundDefOf.TickHigh.PlayOneShotOnCamera(null); }); } int num2 = 0; foreach (ModMetaDataEnhanced current in ModsInListOrder()) { DoModRow(listing_Standard, current, num2, reorderableGroup); num2++; } for (int i = 0; i < WorkshopItems.DownloadingItemsCount; i++) { DoModRowDownloading(listing_Standard, num2); num2++; } listing_Standard.End(); Widgets.EndScrollView(); // selected mod details Rect position = new Rect(rect4.xMax + 17f, 0f, mainRect.width - rect4.width - 17f, mainRect.height); GUI.BeginGroup(position); if (selectedMod != null) { Text.Font = GameFont.Medium; Rect rect7 = new Rect(0f, 0f, position.width, 40f); Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect7, selectedMod.OriginalMetaData.Name.Truncate(rect7.width, null)); Text.Anchor = TextAnchor.UpperLeft; if (!selectedMod.OriginalMetaData.IsCoreMod) { Rect rect8 = rect7; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.LowerRight; if (!selectedMod.OriginalMetaData.VersionCompatible) { GUI.color = Color.red; } Widgets.Label(rect8, "ModTargetVersion".Translate(new object[] { selectedMod.OriginalMetaData.TargetVersion })); GUI.color = Color.white; Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } Rect position2 = new Rect(0f, rect7.yMax, 0f, 20f); if (selectedMod.OriginalMetaData.previewImage != null) { position2.width = Mathf.Min((float)selectedMod.OriginalMetaData.previewImage.width, position.width); position2.height = (float)selectedMod.OriginalMetaData.previewImage.height * (position2.width / (float)selectedMod.OriginalMetaData.previewImage.width); if (position2.height > 300f) { position2.width *= 300f / position2.height; position2.height = 300f; } position2.x = position.width / 2f - position2.width / 2f; GUI.DrawTexture(position2, selectedMod.OriginalMetaData.previewImage, ScaleMode.ScaleToFit); } Text.Font = GameFont.Small; float num3 = position2.yMax + 10f; if (!selectedMod.OriginalMetaData.Author.NullOrEmpty()) { Rect rect9 = new Rect(0f, num3, position.width / 2f, 25f); Widgets.Label(rect9, "Author".Translate() + ": " + selectedMod.OriginalMetaData.Author); } if (!selectedMod.OriginalMetaData.Url.NullOrEmpty()) { float num4 = Mathf.Min(position.width / 2f, Text.CalcSize(selectedMod.OriginalMetaData.Url).x); Rect rect10 = new Rect(position.width - num4, num3, num4, 25f); Text.WordWrap = false; if (Widgets.ButtonText(rect10, selectedMod.OriginalMetaData.Url, false, false, true)) { Application.OpenURL(selectedMod.OriginalMetaData.Url); } Text.WordWrap = true; } WidgetRow widgetRow = new WidgetRow(position.width, num3 + 25f, UIDirection.LeftThenUp, 99999f, 4f); if (SteamManager.Initialized && selectedMod.OriginalMetaData.OnSteamWorkshop) { if (widgetRow.ButtonText("Unsubscribe", null, true, false)) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(new object[] { selectedMod.OriginalMetaData.Name }), delegate { selectedMod.OriginalMetaData.enabled = false; AccessTools.Method(typeof(Workshop), "Unsubscribe").Invoke(null, new object[] { selectedMod.OriginalMetaData }); AccessTools.Method(typeof(Page_ModsConfig), "Notify_SteamItemUnsubscribed").Invoke(instance, new object[] { selectedMod.OriginalMetaData.GetPublishedFileId() }); }, true, null)); } if (widgetRow.ButtonText("WorkshopPage".Translate(), null, true, false)) { SteamUtility.OpenWorkshopPage(selectedMod.OriginalMetaData.GetPublishedFileId()); } } float num5 = num3 + 25f + 24f; Rect outRect = new Rect(0f, num5, position.width, position.height - num5 - 40f); float width = outRect.width - 16f; Rect rect11 = new Rect(0f, 0f, width, Text.CalcHeight(selectedMod.OriginalMetaData.Description, width)); Widgets.BeginScrollView(outRect, ref modDescriptionScrollPosition, rect11, true); Widgets.Label(rect11, selectedMod.OriginalMetaData.Description); Widgets.EndScrollView(); if (Prefs.DevMode && SteamManager.Initialized && selectedMod.OriginalMetaData.CanToUploadToWorkshop()) { Rect rect12 = new Rect(0f, position.yMax - 40f, 200f, 40f); if (Widgets.ButtonText(rect12, Workshop.UploadButtonLabel(selectedMod.OriginalMetaData.GetPublishedFileId()), true, false, true)) { if (!VersionControl.IsWellFormattedVersionString(selectedMod.OriginalMetaData.TargetVersion)) { Messages.Message("MessageModNeedsWellFormattedTargetVersion".Translate(new object[] { VersionControl.CurrentVersionString }), MessageSound.RejectInput); } else { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(null); Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation("ConfirmContentAuthor".Translate(), delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(null); AccessTools.Method(typeof(Workshop), "Upload").Invoke(null, new object[] { selectedMod.OriginalMetaData }); }, true, null); dialog_MessageBox.buttonAText = "Yes".Translate(); dialog_MessageBox.buttonBText = "No".Translate(); dialog_MessageBox.interactionDelay = 6f; Find.WindowStack.Add(dialog_MessageBox); }, true, null)); } } } } GUI.EndGroup(); GUI.EndGroup(); DoBottomLeftWindowContents(rect); DoBottomRightWindowContents(rect); }
static void ContentPart(Rect mainRect, float leftColumn, ModMetaData mod, Page_ModsConfig page) { var workshopMods = WorkshopItems.AllSubscribedItems.Select(wi => wi.PublishedFileId.m_PublishedFileId).ToList(); var mainModID = mod.GetPublishedFileId().m_PublishedFileId; var promoMods = CrossPromotion.promotionMods.ToArray(); var thisMod = promoMods.FirstOrDefault(m => m.m_nPublishedFileId.m_PublishedFileId == mainModID); var isLocalFile = ModLister.AllInstalledMods.Any(meta => meta.GetPublishedFileId().m_PublishedFileId == mainModID && meta.Source == ContentSource.LocalFolder); var isSubbed = workshopMods.Contains(mainModID); if (CrossPromotion.lastPresentedMod != mainModID) { leftScroll = Vector2.zero; rightScroll = Vector2.zero; CrossPromotion.lastPresentedMod = mainModID; new Thread(() => { foreach (var promoMod in promoMods) { CrossPromotion.UpdateVotingStatus(promoMod.m_nPublishedFileId.m_PublishedFileId, (result2, failure2) => { CrossPromotion.allVoteStati[promoMod.m_nPublishedFileId.m_PublishedFileId] = (result2.m_eResult == EResult.k_EResultOK) ? result2.m_bVotedUp : (bool?)null; }); } }).Start(); } var description = thisMod.m_rgchDescription; if (description == null || description.Length == 0) { description = mod.Description; } var outRect = new Rect(0f, 0f, leftColumn, mainRect.height); var width = outRect.width - 20f; var imageRect = new Rect(0f, 0f, width, width * mod.previewImage.height / mod.previewImage.width); var textRect = new Rect(0f, 24f + 10f + imageRect.height, width, Text.CalcHeight(description, width)); var innerRect = new Rect(0f, 0f, width, imageRect.height + 20f + 8f + 10f + textRect.height); Widgets.BeginScrollView(outRect, ref leftScroll, innerRect, true); GUI.DrawTexture(imageRect, mod.previewImage, ScaleMode.ScaleToFit); var widgetRow = new WidgetRow(imageRect.xMax, imageRect.yMax + 8f, UIDirection.LeftThenDown, width, 8f); if (isLocalFile == false) { if (widgetRow.ButtonText("Unsubscribe".Translate(), null, true, true)) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(mod.Name), delegate { mod.enabled = false; new Thread(() => { AccessTools.Method(typeof(Workshop), "Unsubscribe").Invoke(null, new object[] { mod }); AccessTools.Method(typeof(Page_ModsConfig), "Notify_SteamItemUnsubscribed").Invoke(page, new object[] { mainModID }); }).Start(); }, true, null)); } } if (isSubbed) { if (widgetRow.ButtonText("WorkshopPage".Translate(), null, true, true)) { SteamUtility.OpenWorkshopPage(new PublishedFileId_t(mainModID)); } } if (Prefs.DevMode && mod.CanToUploadToWorkshop()) { widgetRow = new WidgetRow(imageRect.xMin, imageRect.yMax + 8f, UIDirection.RightThenDown, width, 8f); if (widgetRow.ButtonText("Upload", null, true, true)) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), delegate { AccessTools.Method(typeof(Workshop), "Upload").Invoke(null, new object[] { mod }); }, true, null)); } } Widgets.Label(textRect, description); Widgets.EndScrollView(); }