Пример #1
0
        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("MpOpenSaveFolder".Translate(), () =>
            {
                ShellOpenDirectory.Execute(save.file.DirectoryName);
            }));

            yield return(new FloatMenuOption("MpFileRename".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++)
                {
                    // todo these aren't steam ids
                    if (!ulong.TryParse(save.modIds[i], out ulong id))
                    {
                        continue;
                    }
                    Log.Message($"Subscribed to: {save.modNames[i]}");
                    SteamUGC.SubscribeItem(new PublishedFileId_t(id));
                }
            }));
        }
 private static void AddOwnWidgets()
 {
     // publish logs button
     AddLogWindowWidget((window, area, message, row) => {
         var prevColor = GUI.color;
         GUI.color     = shareButtonColor;
         if (row.ButtonText("HugsLib_logs_shareBtn".Translate()))
         {
             HugsLibController.Instance.LogUploader.ShowPublishPrompt();
         }
         GUI.color = prevColor;
     });
     // Files drop-down menu
     AddLogWindowWidget((window, area, message, row) => {
         if (row.ButtonText("HugsLib_logs_filesBtn".Translate()))
         {
             Find.WindowStack.Add(new FloatMenu(new List <FloatMenuOption> {
                 new FloatMenuOption("HugsLib_logs_openLogFile".Translate(), () => {
                     ShellOpenLog.Execute();
                 }),
                 new FloatMenuOption("HugsLib_logs_openSaveDir".Translate(), () => {
                     ShellOpenDirectory.Execute(GenFilePaths.SaveDataFolderPath);
                 }),
                 new FloatMenuOption("HugsLib_logs_openModsDir".Translate(), () => {
                     ShellOpenDirectory.Execute(GenFilePaths.ModsFolderName);
                 })
             }));
         }
     });
     // copy button
     AddLogWindowWidget((window, area, message, row) => {
         if (message != null)
         {
             if (row.ButtonText("HugsLib_logs_copy".Translate()))
             {
                 CopyMessage(message);
             }
         }
     }, WidgetAlignMode.Right);
 }