Exemplo n.º 1
0
 void RenderLoadFromSaveButton(Rect LoadFromSaveRect)
 {
     if (Widgets.ButtonText(LoadFromSaveRect, "ChangeLoadedMods".Translate()))
     {
         if (Current.ProgramState == ProgramState.Entry)
         {
             ModsConfig.SetActiveToList(ScribeMetaHeaderUtility.loadedModIdsList);
         }
         ModsConfig.SaveFromList(ScribeMetaHeaderUtility.loadedModIdsList);
         ModsConfig.RestartFromChangedMods();
     }
 }
Exemplo n.º 2
0
        public override void DrawButtons(Rect inRect)
        {
            var btnWidth = 90f;
            var gap      = 10f;

            Rect btnRect = new Rect(gap, inRect.height - ButtonHeight - 10f, btnWidth, ButtonHeight);

            if (Widgets.ButtonText(btnRect, "Details".Translate()))
            {
                var defs = mods.defInfo.Where(kv => kv.Value.status != DefCheckStatus.OK).Join(kv => $"{kv.Key}: {kv.Value.status}", delimiter: "\n");

                Find.WindowStack.Add(new TextAreaWindow($"Mismatches:\n\n{defs}"));
            }

            btnRect.x += btnWidth + gap;

            if (Widgets.ButtonText(btnRect, "MpModList".Translate()))
            {
                ShowModList(mods);
            }
            btnRect.x += btnWidth + gap;

            btnRect.width = 140f;
            if (Widgets.ButtonText(btnRect, "MpSyncModList".Translate()))
            {
                Log.Message("MP remote host's modIds: " + string.Join(", ", mods.remoteModIds));
                Log.Message("MP remote host's workshopIds: " + string.Join(", ", mods.remoteWorkshopModIds));

                LongEventHandler.QueueLongEvent(() => {
                    ModManagement.DownloadWorkshopMods(mods.remoteWorkshopModIds);
                    try {
                        ModManagement.RebuildModsList();
                        ModsConfig.SetActiveToList(mods.remoteModIds.ToList());
                        ModsConfig.Save();
                        ModManagement.PromptRestartAndReconnect(mods.remoteAddress, mods.remotePort);
                    }
                    catch (Exception e) {
                        Log.Error($"MP mod sync error: {e.GetType()} {e.Message}");
                    }
                }, "MpDownloadingWorkshopMods", true, null);
            }

            btnRect.x    += btnRect.width + gap;
            btnRect.width = btnWidth;

            if (Widgets.ButtonText(btnRect, "CloseButton".Translate()))
            {
                Close();
            }
        }
        private void SyncModsAndConfigs(bool syncConfigs)
        {
            Log.Message("MP remote host's modIds: " + string.Join(", ", mods.remoteModIds));
            Log.Message("MP remote host's workshopIds: " + string.Join(", ", mods.remoteWorkshopModIds));

            LongEventHandler.QueueLongEvent(() => {
                try {
                    ModManagement.DownloadWorkshopMods(mods.remoteWorkshopModIds);
                }
                catch (InvalidOperationException e) {
                    Log.Warning($"MP Workshop mod download error: {e.Message}");
                    var missingMods = ModManagement.GetNotInstalledMods(mods.remoteModIds).ToList();
                    if (missingMods.Any())
                    {
                        Find.WindowStack.Add(new DebugTextWindow(
                                                 $"Failed to connect to Workshop.\nThe following mods are missing, please install them:\n"
                                                 + missingMods.Join(s => $"- {s}", "\n")
                                                 ));
                        return;
                    }
                }

                try {
                    ModManagement.RebuildModsList();
                    ModsConfig.SetActiveToList(mods.remoteModIds.ToList());
                    ModsConfig.Save();
                    if (syncConfigs)
                    {
                        ModManagement.ApplyHostModConfigFiles(mods.remoteModConfigs);
                    }
                    ModManagement.PromptRestartAndReconnect(mods.remoteAddress, mods.remotePort);
                }
                catch (Exception e) {
                    Log.Error($"MP mod sync error: {e.GetType()} {e.Message}");
                    Find.WindowStack.Add(new DebugTextWindow($"Failed to sync mods: {e.GetType()} {e.Message}"));
                }
            }, "MpDownloadingWorkshopMods", true, null);
        }
Exemplo n.º 4
0
 public static void Notify_ModOrderChanged()
 {
     ModsConfig.SetActiveToList(ActiveMods.Select(m => m.Identifier).ToList());
     Notify_RecacheIssues();
 }
Exemplo n.º 5
0
 public static void Notify_ModListChanged()
 {
     Notify_RecacheModMetaData();
     ModsConfig.SetActiveToList(ActiveMods.Select(m => m.PackageId).ToList());
     Notify_RecacheIssues();
 }