Replace mod text box by separate tab with workshop support (#263)

* Implement ModList tab which fetches and displays mod information from the workshop.

* ModListEditor: Implement drag and drop ordering, adding, removing and saving.

* Add SteamWorkshopService to VCS

* Add missing file to SteamworkshopService project.

* ModlistControl: Implement checkbox for hiding/showing dependency mods
disable until config is loaded.
design improvements.

* Add documentation for the new classes.

* Comply to naming conventions.

* Update Torch.Server.csproj

* Fix Mod.IsDependency not being serialized when saving

* Remove superfluous update of mod meta data.
Remove commented section in ConfigControl.xaml.

* Optimized SteamworkshopService according to commit review.

* Move SteamWorkshopService to Torch.Utils.SteamworkshopTools

* Remove debug output.

* Don't break stack trace with custom exception in SteamWorkshopTools.

* User ViewModel base class for ModItemInfo instead of implementing INotifyProperty directly.

* Wrap ModListControl in ScrollViewer.

* Rename SteamWorkshopTools utility to WebAPI.

* Revert steamkit call to use dynamic typing for clarity :/

* Mark webAPI based method for downloading workshop content as obsolete.

* Update Torch project definition.

* Disable building Torch client

* Update readme

* Change init order to ensure paths are initialized for plugins

* Reorder exception logging to reduce duplication

* Use thread safe queues in MtObservableCollectionBase

* Revert "Change init order to ensure paths are initialized for plugins"

This reverts commit 3f803b8107.

* Fix layout of ModListControl

* Combine Invokes to reduce allocations

* Replace string comparisons by string.Equals / string.IsNullOrEmpty

* Replace string comparisons by string.Equals / string.IsNullOrEmpty

* Use MtObservableList for Modlist to avoid race conditions.
This commit is contained in:
Tobias K
2019-02-02 12:26:55 +01:00
committed by Brant Martin
parent 4e2e58bb4c
commit f265f7e773
21 changed files with 1150 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
@@ -14,6 +15,7 @@ using Sandbox.Game;
using Sandbox.Game.Gui;
using Torch.API;
using Torch.API.Managers;
using Torch.Collections;
using Torch.Managers;
using Torch.Mod;
using Torch.Server.ViewModels;
@@ -94,7 +96,8 @@ namespace Torch.Server.Managers
//remove the Torch mod to avoid running multiple copies of it
DedicatedConfig.SelectedWorld.Checkpoint.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
foreach (var m in DedicatedConfig.SelectedWorld.Checkpoint.Mods)
DedicatedConfig.Mods.Add(m.PublishedFileId);
DedicatedConfig.Mods.Add(new ModItemInfo(m));
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
}
}
@@ -108,7 +111,8 @@ namespace Torch.Server.Managers
//remove the Torch mod to avoid running multiple copies of it
DedicatedConfig.SelectedWorld.Checkpoint.Mods.RemoveAll(m => m.PublishedFileId == TorchModCore.MOD_ID);
foreach (var m in DedicatedConfig.SelectedWorld.Checkpoint.Mods)
DedicatedConfig.Mods.Add(m.PublishedFileId);
DedicatedConfig.Mods.Add(new ModItemInfo(m));
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
}
}
@@ -119,11 +123,10 @@ namespace Torch.Server.Managers
private void ImportWorldConfig(WorldViewModel world, bool modsOnly = true)
{
var sb = new StringBuilder();
var mods = new MtObservableList<ModItemInfo>();
foreach (var mod in world.Checkpoint.Mods)
sb.AppendLine(mod.PublishedFileId.ToString());
DedicatedConfig.Mods = world.Checkpoint.Mods.Select(x => x.PublishedFileId).ToList();
mods.Add(new ModItemInfo(mod));
DedicatedConfig.Mods = mods;
Log.Debug("Loaded mod list from world");
@@ -151,7 +154,10 @@ namespace Torch.Server.Managers
return;
}
DedicatedConfig.Mods = checkpoint.Mods.Select(x => x.PublishedFileId).ToList();
var mods = new MtObservableList<ModItemInfo>();
foreach (var mod in checkpoint.Mods)
mods.Add(new ModItemInfo(mod));
DedicatedConfig.Mods = mods;
Log.Debug("Loaded mod list from world");
@@ -193,9 +199,14 @@ namespace Torch.Server.Managers
checkpoint.SessionName = DedicatedConfig.WorldName;
checkpoint.Settings = DedicatedConfig.SessionSettings;
checkpoint.Mods.Clear();
foreach (var modId in DedicatedConfig.Mods)
checkpoint.Mods.Add(new MyObjectBuilder_Checkpoint.ModItem(modId));
foreach (var mod in DedicatedConfig.Mods)
{
var savedMod = new MyObjectBuilder_Checkpoint.ModItem(mod.Name, mod.PublishedFileId, mod.FriendlyName);
savedMod.IsDependency = mod.IsDependency;
checkpoint.Mods.Add(savedMod);
}
Task.Run(() => DedicatedConfig.UpdateAllModInfosAsync());
MyObjectBuilderSerializer.SerializeXML(sandboxPath, false, checkpoint);