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)))); })); } }
private void ReloadFiles() { selectedFile = null; spSaves.Clear(); mpReplays.Clear(); foreach (FileInfo file in GenFilePaths.AllSavedGameFiles) { var saveFile = new SaveFile(Path.GetFileNameWithoutExtension(file.Name), false, file); using (var stream = file.OpenRead()) ReadSaveInfo(stream, saveFile); spSaves.Add(saveFile); } var replaysDir = new DirectoryInfo(GenFilePaths.FolderUnderSaveData("MpReplays")); foreach (var file in replaysDir.GetFiles("*.zip", MpVersion.IsDebug ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).OrderByDescending(f => f.LastWriteTime)) { var replay = Replay.ForLoading(file); if (!replay.LoadInfo()) { continue; } var displayName = Path.ChangeExtension(file.FullName.Substring(Multiplayer.ReplaysDir.Length + 1), null); var saveFile = new SaveFile(displayName, true, file) { gameName = replay.info.name, protocol = replay.info.protocol, replaySections = replay.info.sections.Count }; mpReplays.Add(saveFile); if (!replay.info.rwVersion.NullOrEmpty()) { saveFile.rwVersion = replay.info.rwVersion; saveFile.modIds = replay.info.modIds.ToArray(); saveFile.modNames = replay.info.modNames.ToArray(); saveFile.modAssemblyHashes = replay.info.modAssemblyHashes.ToArray(); } else { using (var zip = replay.ZipFile) ReadSaveInfo(zip["world/000_save"].OpenReader(), saveFile); } } }
private void ReloadFiles() { selectedFile = null; spSaves.Clear(); mpReplays.Clear(); foreach (FileInfo file in GenFilePaths.AllSavedGameFiles) { spSaves.Add( new SaveFile(Path.GetFileNameWithoutExtension(file.Name), false, file) { rwVersion = ScribeMetaHeaderUtility.GameVersionOf(file) } ); } var replaysDir = new DirectoryInfo(GenFilePaths.FolderUnderSaveData("MpReplays")); if (!replaysDir.Exists) { replaysDir.Create(); } foreach (var file in replaysDir.GetFiles("*.zip").OrderByDescending(f => f.LastWriteTime)) { var replay = Replay.ForLoading(file); replay.LoadInfo(); mpReplays.Add( new SaveFile(Path.GetFileNameWithoutExtension(file.Name), true, file) { gameName = replay.info.name, protocol = replay.info.protocol } ); } }
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.PackageId == 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 break; } yield return(new FloatMenuOption("Debug info", () => { Find.WindowStack.Add(new DebugTextWindow(UserReadableDesyncInfo.GenerateFromReplay(Replay.ForLoading(save.file)))); })); yield return(new FloatMenuOption("Subscribe to Steam mods", () => { for (int i = 0; i < save.modIds.Length; i++) { if (!ulong.TryParse(save.modIds[i], out ulong id)) { continue; } Log.Message($"Subscribed to: {save.modNames[i]}"); SteamUGC.SubscribeItem(new PublishedFileId_t(id)); } })); }
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; } }