Update catalog_export implementation, assets and documentation

This commit is contained in:
cthangover committed 2026-10-31 15:28:48 +03:00
1 parent 2085c2dcc9
commit 5632be8cba
2 files changed
+10 -6

No files matched your search

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 135 KiB

+10 -6
View File
@@ -1,3 +1,5 @@
namespace Cthangover.Core.UI.Tool.CatalogExport
{
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -10,8 +12,6 @@ using Cthangover.Mods.Interface.Tool;
using Cthangover.Tools.Common; using Cthangover.Tools.Common;
using Godot; using Godot;
namespace Cthangover.Core.UI.Tool.CatalogExport
{
/// <summary> /// <summary>
/// Developer tool that builds a catalog entry (JSON for the online mod /// Developer tool that builds a catalog entry (JSON for the online mod
/// catalog) from a locally installed mod's manifest. Ported out of the old /// catalog) from a locally installed mod's manifest. Ported out of the old
@@ -26,6 +26,8 @@ namespace Cthangover.Core.UI.Tool.CatalogExport
/// </summary> /// </summary>
public partial class CatalogExportWindow : ToolWindow public partial class CatalogExportWindow : ToolWindow
{ {
private void OnDownloadUrlChanged(string text) => UpdatePreview();
private static readonly string[] Statuses = { "stable", "beta", "deprecated", "archived" }; private static readonly string[] Statuses = { "stable", "beta", "deprecated", "archived" };
private static readonly CategoryType[] Categories = Enum.GetValues<CategoryType>(); private static readonly CategoryType[] Categories = Enum.GetValues<CategoryType>();
@@ -130,7 +132,9 @@ namespace Cthangover.Core.UI.Tool.CatalogExport
AddReadOnly("mods/author", _modInfo.Author ?? "—"); AddReadOnly("mods/author", _modInfo.Author ?? "—");
_formHost.AddChild(ToolUi.Section("tools/catalog_export/metadata")); _formHost.AddChild(ToolUi.Section("tools/catalog_export/metadata"));
_urlEdit = ToolUi.Field(_formHost, "mods/catalog_download_url", ToolUi.Text("https://…/" + modId + ".zip", _ => UpdatePreview())); var archiveName = System.IO.File.Exists(_modInfo.FileProvider.RootPath)
? System.IO.Path.GetFileName(_modInfo.FileProvider.RootPath) : modId + ".zip";
_urlEdit = ToolUi.Field(_formHost, "mods/catalog_download_url", ToolUi.Text("https://…/" + archiveName, OnDownloadUrlChanged));
_statusOpt = ToolUi.Field(_formHost, "mods/catalog_status", new OptionButton()); _statusOpt = ToolUi.Field(_formHost, "mods/catalog_status", new OptionButton());
foreach (var status in Statuses) foreach (var status in Statuses)
_statusOpt.AddItem(status); _statusOpt.AddItem(status);
@@ -310,9 +314,9 @@ namespace Cthangover.Core.UI.Tool.CatalogExport
{ {
var entry = BuildExportEntry(); var entry = BuildExportEntry();
var modsRoot = ModRegistry.ModsPath; var modsRoot = ModRegistry.ModsPath;
var isZip = _modInfo.FileProvider.RootPath.EndsWith(".zip", StringComparison.OrdinalIgnoreCase); var isArchive = System.IO.File.Exists(_modInfo.FileProvider.RootPath);
var path = isZip var path = isArchive
? ModCatalogExporter.ExportFromZip(_modInfo, entry, modsRoot) ? ModCatalogExporter.ExportFromArchive(_modInfo, entry, modsRoot)
: ModCatalogExporter.ExportFromFolder(_modInfo, entry, modsRoot); : ModCatalogExporter.ExportFromFolder(_modInfo, entry, modsRoot);
SetStatus(string.Format(ToolUi.Tr("tools/catalog_export/exported"), path), ToolStatusKind.Ok); SetStatus(string.Format(ToolUi.Tr("tools/catalog_export/exported"), path), ToolStatusKind.Ok);
} }