From de9fc3b64f98f701864efe3f9f0c6d14a7ecd337 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 18:49:48 +0000 Subject: [PATCH 1/3] fix: Improve asset packing to include all resource folders and fix UI button positioning - Modified packAssets method to scan all texture subdirectories in resources folder instead of relying on in-memory textures - Added support for packing all texture folders: gui, paperdolls, resources, spells, tilesets, updater, faces, fonts, items, misc, animations, entities - Added support for packing fonts folder (.xnb files) when present - Added support for packing updater folder files when present - Fixed UI button positioning in FrmUploadToServer by moving Login, Upload, and Close buttons up from Y=240 to Y=215 to prevent them from being cut off at the bottom of the form - Improved asset collection to directly scan the rootDirectory parameter instead of using cached GameContentManager textures This ensures all asset folders are properly packed regardless of what's currently loaded in the editor's memory. --- .../Forms/FrmUploadToServer.Designer.cs | 8 +-- Intersect.Editor/Forms/frmMain.cs | 72 ++++++++++++++++--- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/Intersect.Editor/Forms/FrmUploadToServer.Designer.cs b/Intersect.Editor/Forms/FrmUploadToServer.Designer.cs index 2189fa43d4..10a52eff4e 100644 --- a/Intersect.Editor/Forms/FrmUploadToServer.Designer.cs +++ b/Intersect.Editor/Forms/FrmUploadToServer.Designer.cs @@ -121,7 +121,7 @@ private void InitializeComponent() // this.lblStatus.AutoSize = true; this.lblStatus.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220))))); - this.lblStatus.Location = new System.Drawing.Point(12, 187); + this.lblStatus.Location = new System.Drawing.Point(12, 185); this.lblStatus.Name = "lblStatus"; this.lblStatus.Size = new System.Drawing.Size(0, 13); this.lblStatus.TabIndex = 8; @@ -138,7 +138,7 @@ private void InitializeComponent() // // btnLogin // - this.btnLogin.Location = new System.Drawing.Point(206, 240); + this.btnLogin.Location = new System.Drawing.Point(206, 215); this.btnLogin.Name = "btnLogin"; this.btnLogin.Padding = new System.Windows.Forms.Padding(5); this.btnLogin.Size = new System.Drawing.Size(85, 28); @@ -150,7 +150,7 @@ private void InitializeComponent() // btnUpload // this.btnUpload.Enabled = false; - this.btnUpload.Location = new System.Drawing.Point(297, 240); + this.btnUpload.Location = new System.Drawing.Point(297, 215); this.btnUpload.Name = "btnUpload"; this.btnUpload.Padding = new System.Windows.Forms.Padding(5); this.btnUpload.Size = new System.Drawing.Size(85, 28); @@ -161,7 +161,7 @@ private void InitializeComponent() // btnClose // this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnClose.Location = new System.Drawing.Point(388, 240); + this.btnClose.Location = new System.Drawing.Point(388, 215); this.btnClose.Name = "btnClose"; this.btnClose.Padding = new System.Windows.Forms.Padding(5); this.btnClose.Size = new System.Drawing.Size(84, 28); diff --git a/Intersect.Editor/Forms/frmMain.cs b/Intersect.Editor/Forms/frmMain.cs index d41bfff53e..8bbddbf73b 100644 --- a/Intersect.Editor/Forms/frmMain.cs +++ b/Intersect.Editor/Forms/frmMain.cs @@ -1846,21 +1846,39 @@ public static void packAssets(string rootDirectory, Form parentForm = null) Globals.PackingProgressForm.SetProgress(Strings.AssetPacking.collecting, 20, false); Application.DoEvents(); var toPack = new HashSet(); - foreach (var tex in GameContentManager.TilesetTextures) - { - toPack.Add(tex); - } - foreach (var tex in GameContentManager.FogTextures) + // Scan all texture directories in the resources folder + var textureDirectories = new[] { - toPack.Add(tex); - } + "tilesets", "fogs", "gui", "paperdolls", "resources", "spells", + "faces", "fonts", "items", "misc", "animations", "entities", + "images", "updater" + }; - foreach (var tex in GameContentManager.AllTextures) + foreach (var dir in textureDirectories) { - if (!toPack.Contains(tex)) + var dirPath = Path.Combine(resourcesDirectory, dir); + if (!Directory.Exists(dirPath)) + { + continue; + } + + var pngFiles = Directory.GetFiles(dirPath, "*.png", SearchOption.TopDirectoryOnly); + foreach (var pngFile in pngFiles) { - toPack.Add(tex); + try + { + var relativePath = Path.GetRelativePath(rootDirectory, pngFile); + var texture = new Texture(pngFile); + toPack.Add(texture); + } + catch (Exception ex) + { + Intersect.Core.ApplicationContext.Context.Value?.Logger.LogWarning( + ex, + $"Failed to load texture: {pngFile}" + ); + } } } @@ -1939,6 +1957,40 @@ public static void packAssets(string rootDirectory, Form parentForm = null) musicPackSize ); + // Package up fonts if the directory exists + var fontsDirectory = Path.Combine(resourcesDirectory, "fonts"); + if (Directory.Exists(fontsDirectory) && Directory.GetFiles(fontsDirectory, "*.xnb").Length > 0) + { + Globals.PackingProgressForm.SetProgress("Packing fonts...", 93, false); + Application.DoEvents(); + AssetPacker.PackageAssets( + fontsDirectory, + "*.xnb", + packsDirectory, + "fonts.index", + "fonts", + ".asset", + soundPackSize + ); + } + + // Package up updater files if the directory exists + var updaterDirectory = Path.Combine(resourcesDirectory, "updater"); + if (Directory.Exists(updaterDirectory) && Directory.GetFiles(updaterDirectory, "*.*").Length > 0) + { + Globals.PackingProgressForm.SetProgress("Packing updater files...", 96, false); + Application.DoEvents(); + AssetPacker.PackageAssets( + updaterDirectory, + "*.*", + packsDirectory, + "updater.index", + "updater", + ".asset", + soundPackSize + ); + } + Globals.PackingProgressForm.SetProgress(Strings.AssetPacking.done, 100, false); Application.DoEvents(); Thread.Sleep(1000); From e2ac7621440d08bd707c243130129e041cd0125a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 18:55:19 +0000 Subject: [PATCH 2/3] fix: Remove fonts and updater file packing - client doesn't support unpacking them The client loads fonts and updater .xnb files directly from the file system and doesn't have support for unpacking them from asset packs. Only sounds and music have AssetPacker support on the client side. Changes: - Removed fonts directory from texture scanning (contains only .xnb files, not PNGs) - Kept updater directory in texture scanning (can contain PNG files like progressbar.png) - Removed fonts.index packing code (not supported by client) - Removed updater.index packing code (not supported by client) - Added comments explaining why these directories are handled differently - Textures (PNG files) are still packed from all appropriate folders including updater This ensures only assets that the client can unpack are included in asset packs. --- Intersect.Editor/Forms/frmMain.cs | 40 ++++--------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/Intersect.Editor/Forms/frmMain.cs b/Intersect.Editor/Forms/frmMain.cs index 8bbddbf73b..5ad35a96b7 100644 --- a/Intersect.Editor/Forms/frmMain.cs +++ b/Intersect.Editor/Forms/frmMain.cs @@ -1851,9 +1851,10 @@ public static void packAssets(string rootDirectory, Form parentForm = null) var textureDirectories = new[] { "tilesets", "fogs", "gui", "paperdolls", "resources", "spells", - "faces", "fonts", "items", "misc", "animations", "entities", - "images", "updater" + "faces", "items", "misc", "animations", "entities", "images", "updater" }; + // Note: fonts directory is excluded because it contains only .xnb files, not PNG textures + // updater directory is included because it can contain PNG files like progressbar.png foreach (var dir in textureDirectories) { @@ -1957,39 +1958,8 @@ public static void packAssets(string rootDirectory, Form parentForm = null) musicPackSize ); - // Package up fonts if the directory exists - var fontsDirectory = Path.Combine(resourcesDirectory, "fonts"); - if (Directory.Exists(fontsDirectory) && Directory.GetFiles(fontsDirectory, "*.xnb").Length > 0) - { - Globals.PackingProgressForm.SetProgress("Packing fonts...", 93, false); - Application.DoEvents(); - AssetPacker.PackageAssets( - fontsDirectory, - "*.xnb", - packsDirectory, - "fonts.index", - "fonts", - ".asset", - soundPackSize - ); - } - - // Package up updater files if the directory exists - var updaterDirectory = Path.Combine(resourcesDirectory, "updater"); - if (Directory.Exists(updaterDirectory) && Directory.GetFiles(updaterDirectory, "*.*").Length > 0) - { - Globals.PackingProgressForm.SetProgress("Packing updater files...", 96, false); - Application.DoEvents(); - AssetPacker.PackageAssets( - updaterDirectory, - "*.*", - packsDirectory, - "updater.index", - "updater", - ".asset", - soundPackSize - ); - } + // Note: Fonts and updater files are NOT packed because the client + // loads them directly from the file system and doesn't support unpacking them Globals.PackingProgressForm.SetProgress(Strings.AssetPacking.done, 100, false); Application.DoEvents(); From 460e1364d3eb29f0b82107ce102457465eb7bc92 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 28 Dec 2025 19:01:12 +0000 Subject: [PATCH 3/3] fix: Correct texture path handling in asset packing and upload exclusion Fixed two critical issues with asset packing and uploading: 1. Asset Packing Path Format: - Changed texture paths to use relative format matching GameContentManager - Textures now use paths like "resources/items/sword.png" (relative to root) - This ensures .meta files contain correct paths for upload exclusion logic - Paths are normalized with forward slashes for cross-platform compatibility 2. Upload Exclusion Logic Fix: - Fixed texture exclusion to work with full relative paths in .meta files - Removed redundant Path.Combine that was creating incorrect double "resources/" prefix - Now correctly matches packed texture filenames like "resources/items/sword.png" - Exclusion logic now properly excludes source files when uploading packed assets These changes ensure that when asset packing is enabled, only the packed .asset and .meta files are uploaded, and the original source PNG/WAV/OGG files are correctly excluded. --- Intersect.Editor/Forms/FrmUploadToServer.cs | 4 ++-- Intersect.Editor/Forms/frmMain.cs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Intersect.Editor/Forms/FrmUploadToServer.cs b/Intersect.Editor/Forms/FrmUploadToServer.cs index 771ecdf80d..1260fd5679 100644 --- a/Intersect.Editor/Forms/FrmUploadToServer.cs +++ b/Intersect.Editor/Forms/FrmUploadToServer.cs @@ -443,7 +443,7 @@ private async void btnUpload_Click(object sender, EventArgs e) .Where(frameObject => frameObject.TryGetValue("filename", out _)) .Select(frameObject => frameObject["filename"]?.Value()) .Where(filename => !string.IsNullOrWhiteSpace(filename)) - .Select(filename => Path.Combine(resourcesDirectoryName, filename!).Replace('\\', '/').ToLower(CultureInfo.CurrentCulture)) + .Select(filename => filename!.Replace('\\', '/').ToLower(CultureInfo.CurrentCulture)) .OfType(); } catch @@ -598,7 +598,7 @@ private async void btnUpload_Click(object sender, EventArgs e) .Where(frameObject => frameObject.TryGetValue("filename", out _)) .Select(frameObject => frameObject["filename"]?.Value()) .Where(filename => !string.IsNullOrWhiteSpace(filename)) - .Select(filename => Path.Combine(resourcesDirectoryName, filename!).Replace('\\', '/').ToLower(CultureInfo.CurrentCulture)) + .Select(filename => filename!.Replace('\\', '/').ToLower(CultureInfo.CurrentCulture)) .OfType(); } catch diff --git a/Intersect.Editor/Forms/frmMain.cs b/Intersect.Editor/Forms/frmMain.cs index 5ad35a96b7..7bd671cf1d 100644 --- a/Intersect.Editor/Forms/frmMain.cs +++ b/Intersect.Editor/Forms/frmMain.cs @@ -1869,8 +1869,10 @@ public static void packAssets(string rootDirectory, Form parentForm = null) { try { - var relativePath = Path.GetRelativePath(rootDirectory, pngFile); - var texture = new Texture(pngFile); + // Use path relative to root directory matching old GameContentManager format + // Example: "resources/items/sword.png" + var relativePath = Path.GetRelativePath(rootDirectory, pngFile).Replace('\\', '/'); + var texture = new Texture(relativePath); toPack.Add(texture); } catch (Exception ex)