Mod config migration from plugin hub
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (NuGet) (push) Successful in 50s
Build / Build Nuget package (SharedCringe) (push) Successful in 58s
Build / Build Nuget package (CringePlugins) (push) Successful in 1m11s
Build / Build Launcher (push) Successful in 1m42s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 3m5s

Update ui when migrating pluginhub config
Added mod loader as a default plugin
Temp fix for pbs
This commit is contained in:
2025-05-13 04:04:22 -04:00
parent 3295afc447
commit 78880d2a78
4 changed files with 138 additions and 24 deletions

View File

@@ -33,6 +33,7 @@ internal class PluginListComponent : IRenderComponent
private bool _open = true;
private PackagesConfig _packagesConfig;
private readonly PackageSourceMapping _sourceMapping;
private readonly JsonSerializerOptions _serializerOptions = new(JsonSerializerDefaults.Web);
private ImmutableHashSet<PackageSource>? _selectedSources;
private readonly string _configPath;
private readonly string _gameFolder;
@@ -255,17 +256,50 @@ internal class PluginListComponent : IRenderComponent
if (BeginTabItem("Settings"))
{
var oldConfigPath = Path.Join(_gameFolder, "Plugins", "config.xml");
if (File.Exists(oldConfigPath) && Button("Migrate PluginLoader Config"))
if (File.Exists(oldConfigPath))
{
var configSerializer = new XmlSerializer(typeof(PluginLoaderConfig));
using var fs = File.OpenRead(oldConfigPath);
if (configSerializer.Deserialize(fs) is PluginLoaderConfig oldConfig)
if (Button("Migrate PluginLoader Plugins"))
{
_packagesConfig = oldConfig.Migrate(_packagesConfig);
var configSerializer = new XmlSerializer(typeof(PluginLoaderConfig));
using var fs = File.OpenRead(oldConfigPath);
if (configSerializer.Deserialize(fs) is PluginLoaderConfig oldConfig)
{
_packagesConfig = oldConfig.MigratePlugins(_packagesConfig);
Save(false);
Save(false);
_packages = _packagesConfig.Packages.ToImmutableDictionary(b => b.Id, b => b.Range, StringComparer.OrdinalIgnoreCase);
}
}
var hasModLodaer = _packages.ContainsKey("Plugin.ClientModLoader");
if (!hasModLodaer)
BeginDisabled();
if (Button("Migrate Pluginloader Mods"))
{
var configSerializer = new XmlSerializer(typeof(PluginLoaderConfig));
using var fs = File.OpenRead(oldConfigPath);
if (configSerializer.Deserialize(fs) is PluginLoaderConfig plConfig)
{
var dir = new DirectoryInfo(Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"CringeLauncher"));
var file = Path.Join(dir.FullName, "mods.json");
using var modsFile = File.Create(file);
JsonSerializer.Serialize(modsFile, plConfig.GetMods(), _serializerOptions);
}
}
if (!hasModLodaer)
{
if (IsItemHovered())
SetTooltip("Requires Plugin.ClientModLoader");
EndDisabled();
}
}
EndTabItem();