Exemple #1
0
        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 mod in this.ModsInListOrder())
            {
                this.DoModRow(listing_Standard, mod, 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(new object[]
                    {
                        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(new object[]
                        {
                            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(new object[]
                            {
                                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();
        }
Exemple #2
0
 public override void ExtraOnGUI()
 {
     base.ExtraOnGUI();
     VersionControl.DrawInfoInCorner();
 }
Exemple #3
0
        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(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), 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);
                        }, destructive: true));
                    }
                }
                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;
            }
        }