private IEnumerable <FloatMenuOption> SaveFloatMenu(SaveFile save)
        {
            var saveMods = new StringBuilder();

            for (int i = 0; i < save.modIds.Length; i++)
            {
                var modName = save.modNames[i];
                var modId   = save.modIds[i];
                var prefix  = ModLister.AllInstalledMods.Any(m => m.Identifier == modId) ? "+" : "-";
                saveMods.Append($"{prefix} {modName}\n");
            }

            var activeMods = LoadedModManager.RunningModsListForReading.Join(m => "+ " + m.Name, "\n");

            yield return(new FloatMenuOption("MpSeeModList".Translate(), () =>
            {
                Find.WindowStack.Add(new TwoTextAreas_Window($"RimWorld {save.rwVersion}\nSave mod list:\n\n{saveMods}", $"RimWorld {VersionControl.CurrentVersionString}\nActive mod list:\n\n{activeMods}"));
            }));

            yield return(new FloatMenuOption("Rename".Translate(), () =>
            {
                Find.WindowStack.Add(new Dialog_RenameFile(save.file, () => ReloadFiles()));
            }));

            if (MpVersion.IsDebug)
            {
                yield return(new FloatMenuOption("Debug info", () =>
                {
                    Find.WindowStack.Add(new DebugTextWindow(DesyncDebugInfo.Get(Replay.ForLoading(save.file))));
                }));
            }
        }
Beispiel #2
0
        private void DrawSaveList(List <SaveFile> saves, float width, ref float y)
        {
            for (int i = 0; i < saves.Count; i++)
            {
                var  saveFile  = saves[i];
                Rect entryRect = new Rect(0, y, width, 40);

                if (saveFile == selectedFile)
                {
                    Widgets.DrawRectFast(entryRect, new Color(1f, 1f, 0.7f, 0.1f));

                    var lineColor = new Color(1, 1, 1, 0.3f);
                    Widgets.DrawLine(entryRect.min, entryRect.TopRightCorner(), lineColor, 2f);
                    Widgets.DrawLine(entryRect.min + new Vector2(2, 1), entryRect.BottomLeftCorner() + new Vector2(2, -1), lineColor, 2f);
                    Widgets.DrawLine(entryRect.BottomLeftCorner(), entryRect.max, lineColor, 2f);
                    Widgets.DrawLine(entryRect.TopRightCorner() - new Vector2(2, -1), entryRect.max - new Vector2(2, 1), lineColor, 2f);
                }
                else if (i % 2 == 0)
                {
                    Widgets.DrawAltRect(entryRect);
                }

                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(entryRect.Right(10), saveFile.fileName);
                Text.Anchor = TextAnchor.UpperLeft;

                GUI.color = new Color(0.6f, 0.6f, 0.6f);
                Text.Font = GameFont.Tiny;

                var infoText = new Rect(entryRect.xMax - 120, entryRect.yMin + 3, 120, entryRect.height);
                Widgets.Label(infoText, saveFile.file.LastWriteTime.ToString("g"));

                if (saveFile.gameName != null)
                {
                    Widgets.Label(infoText.Down(16), saveFile.gameName.Truncate(110));
                }
                else
                {
                    GUI.color = saveFile.VersionColor;
                    Widgets.Label(infoText.Down(16), (saveFile.rwVersion ?? "???").Truncate(110));
                }

                if (saveFile.replay && saveFile.protocol != MpVersion.Protocol)
                {
                    GUI.color = new Color(0.8f, 0.8f, 0);
                    var outdated = new Rect(infoText.x - 70, infoText.y + 8f, 70, 24f);
                    Widgets.Label(outdated, "MpReplayOutdated".Translate());

                    TooltipHandler.TipRegion(
                        outdated,
                        "MpReplayOutdatedDesc".Translate(saveFile.protocol, MpVersion.Protocol)
                        );
                }

                Text.Font = GameFont.Small;
                GUI.color = Color.white;

                if (Widgets.ButtonInvisible(entryRect))
                {
                    if (saveFile.replay && Event.current.button == 1 && MpVersion.IsDebug)
                    {
                        Find.WindowStack.Add(new DebugTextWindow(DesyncDebugInfo.Get(Replay.ForLoading(saveFile.file))));
                    }
                    else
                    {
                        selectedFile = saveFile;
                    }
                }

                y += 40;
            }
        }