### Sound API: Get, Add, Remove, and Save Sound Effects Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt This snippet explains how to retrieve sound effects by ID, access their properties like buffer size, save them to WAV files, add new custom sounds, remove existing ones, and save all changes. It uses the Ultima library for sound management. ```csharp using System; using System.IO; using Ultima; // Get a sound by ID int soundId = 0x0057; // Example sound effect UoSound sound = Sounds.GetSound(soundId); if (sound != null) { Console.WriteLine($"Sound ID: {sound.Id}"); Console.WriteLine($"Sound Name: {sound.Name}"); Console.WriteLine($"Buffer size: {sound.Buffer.Length} bytes"); // Save sound as WAV file string outputPath = $"sound_{soundId:X4}.wav"; File.WriteAllBytes(outputPath, sound.Buffer); Console.WriteLine($"Sound saved to {outputPath}"); } else { Console.WriteLine("Sound not found"); } // Add a new sound byte[] wavData = File.ReadAllBytes("custom_sound.wav"); var newSound = new UoSound(0x1000, "Custom Sound", wavData); Sounds.Add(0x1000, newSound); // Remove a sound Sounds.Remove(soundId); // Save changes Sounds.Save(@"C:\UO\Modified"); // Check if a sound exists if (Sounds.IsValidSound(soundId)) { Console.WriteLine($"Sound {soundId} is valid"); } ``` -------------------------------- ### Set Export Path in C# Source: https://github.com/jedi661/uofiddlerpixel/blob/master/Data/ExportUOL/ExportUOL.cs Readme, Ravenel.htm Defines the default directory path for exporting static map data. This path can be customized to suit user preferences and project structure. The script automatically creates the directory if it does not exist. ```csharp private const string ExportPath = @"C:\\Documents and Settings\\Owner\\My Documents\\UOLandscaper\\Exports"; ``` -------------------------------- ### Update AnimationList.xml for UO Fiddler Source: https://github.com/jedi661/uofiddlerpixel/blob/master/UoFiddler/UOFiddlerHelp/AnimationInstallationEng.html This snippet shows how to add a new animation entry to the AnimationList.xml file. This ensures the animation is listed correctly when UO Fiddler starts. The file is located in the AppData\Roaming\UoFiddler directory. It requires a name for the animation and its corresponding body address. ```xml My New Animation 1000 ``` -------------------------------- ### Manage Ultima Online Client Paths in C# Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Shows how to configure and manage Ultima Online client file paths using the Files API. This includes setting the client directory manually, loading from the registry, retrieving the root directory, and accessing specific file paths. It also demonstrates checking for different client file formats (MUL vs. UOP) and managing data caching. ```csharp using System; using System.Collections.Generic; using Ultima; // Set the UO client directory manually string clientPath = @"C:\Program Files\Electronic Arts\Ultima Online Classic"; Files.SetMulPath(clientPath); // Or load from registry Files.LoadDirectory(); // Attempts to find UO installation automatically // Get the configured root directory string rootDir = Files.RootDir; Console.WriteLine($"UO Client Path: {rootDir}"); // Get specific file path string artPath = Files.GetFilePath("art.mul"); Console.WriteLine($"Art.mul location: {artPath}"); string gumpPath = Files.GetFilePath("gumpart.mul"); Console.WriteLine($"Gumpart.mul location: {gumpPath}"); // Access the file path dictionary Dictionary mulPaths = Files.MulPath; foreach (var kvp in mulPaths) { Console.WriteLine($"{kvp.Key} => {kvp.Value}"); } // Check if specific files exist if (!string.IsNullOrEmpty(Files.GetFilePath("artLegacyMUL.uop"))) { Console.WriteLine("Client uses UOP format (High Seas+)"); } else if (!string.IsNullOrEmpty(Files.GetFilePath("art.mul"))) { Console.WriteLine("Client uses MUL format (Legacy)"); } // Enable/disable caching Files.CacheData = true; // Enable data caching for better performance ``` -------------------------------- ### AnimData Block and Entry Structure Source: https://github.com/jedi661/uofiddlerpixel/blob/master/UoFiddler/UOFiddlerHelp/FileFormatsEnglisch.html Defines the structure of blocks and entries within the AnimData.mul file. Each block contains eight entries, with each entry holding frame data, unknown byte, frame count, interval, and start delay. ```c++ struct AnimDataBlock { int header; // Unknown Entry entries[8]; }; struct Entry { signed char frameData[64]; // May be less than 64 bytes unsigned char unknown; unsigned char frameCount; unsigned char frameInterval; // Move to next frame every (frameInterval * 50) ms unsigned char frameStart; // Delay before animation starts (frameStart * 50ms) }; ``` -------------------------------- ### Multi API: Load, Render, and Import House Structures Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt This code illustrates loading multi-component structures (like houses) by ID, accessing their properties such as dimensions and tile data, rendering them to an image, and importing new structures from external files. It utilizes the Ultima library for multi manipulation. ```csharp using System; using System.Drawing; using Ultima; // Load a multi structure (e.g., a house) int multiId = 0x0064; // Small house MultiComponentList multi = Multis.GetComponents(multiId); if (multi != null) { Console.WriteLine($"Multi dimensions: {multi.Width}x{multi.Height}"); Console.WriteLine($"Center point: ({multi.Center.X}, {multi.Center.Y})"); Console.WriteLine($"Min: ({multi.Min.X}, {multi.Min.Y}, {multi.Min.Z})"); Console.WriteLine($"Max: ({multi.Max.X}, {multi.Max.Y}, {multi.Max.Z})"); // Get sorted tile list MultiTileEntry[] tiles = multi.SortedTiles; Console.WriteLine($"Total tiles: {tiles.Length}"); foreach (var tile in tiles) { Console.WriteLine($"ItemID: 0x{tile.ItemId:X4}, " + $""Pos: ({tile.OffsetX}, {tile.OffsetY}, {tile.OffsetZ}), " + $""Flags: 0x{tile.Flags:X8}"); } // Render multi to image int maximumHeight = 200; // Max render height Bitmap multiImage = multi.GetImage(maximumHeight); if (multiImage != null) { multiImage.Save("house.png", System.Drawing.Imaging.ImageFormat.Png); } } // Import multi from file string filePath = @"C:\UO\Houses\custom_house.txt"; Multis.ImportFromFile(multiId, filePath, Multis.ImportType.TXT); // Load from multicache (placed houses) string cacheFile = @"C:\UO\Data\Multicache.dat"; MultiComponentList cachedMulti = Multis.LoadFromCache(cacheFile); ``` -------------------------------- ### Load Static Item Graphics using Art API Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Demonstrates how to load static item artwork from MUL or UOP files using the Art API. It includes initializing file paths, retrieving a specific item by its ID, saving the resulting bitmap, and checking for valid item IDs. ```csharp using System; using System.Drawing; using Ultima; // Initialize file paths (usually done once at startup) Files.SetMulPath(@"C:\Program Files\Electronic Arts\Ultima Online Classic"); // Get a static item graphic (e.g., a sword at ID 0x0F61) int itemId = 0x0F61; Bitmap itemBitmap = Art.GetStatic(itemId); if (itemBitmap != null) { // Display or manipulate the bitmap itemBitmap.Save("sword.png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine($"Item size: {itemBitmap.Width}x{itemBitmap.Height}"); } else { Console.WriteLine("Item not found or invalid"); } // Check if an item ID is valid before loading if (Art.IsValidStatic(itemId)) { // Get the maximum item ID supported by this client version int maxId = Art.GetMaxItemId(); // Returns 0xFFDC for High Seas, 0x7FFF for SA, 0x3FFF for older Console.WriteLine($"Client supports up to item ID: 0x{maxId:X}"); } ``` -------------------------------- ### Create UoFiddler Custom Plugin in C# Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Demonstrates how to create a custom plugin for UoFiddler by inheriting from PluginBase. This includes initializing the plugin, adding custom menu items to the plugin dropdown, and creating new tab pages with interactive elements. Dependencies include UoFiddler's plugin interfaces and system libraries. ```csharp using System; using System.Windows.Forms; using UoFiddler.Controls.Plugin; using UoFiddler.Controls.Plugin.Interfaces; public class MyCustomPlugin : PluginBase { private IPluginHost _host; public override string Name => "My Custom Plugin"; public override string Description => "Example plugin demonstrating UoFiddler extension"; public override string Author => "Your Name"; public override string Version => "1.0.0"; public override IPluginHost Host { get => _host; set => _host = value; } public override void Initialize() { // Called when plugin loads Console.WriteLine($"{Name} initialized"); } public override void Unload() { // Called when plugin unloads Console.WriteLine($"{Name} unloaded"); } public override void ModifyPluginToolStrip(ToolStripDropDownButton toolStrip) { // Add menu item to Plugin dropdown var menuItem = new ToolStripMenuItem("My Custom Tool"); menuItem.Click += (sender, e) => { // Get selected item from main form int selectedId = _host.GetSelectedIdFromItemsControl(); MessageBox.Show($"Selected item ID: 0x{selectedId:X4}", Name); // Export item data ExportItemData(selectedId); }; toolStrip.DropDownItems.Add(menuItem); } public override void ModifyTabPages(TabControl tabControl) { // Add custom tab page var customTab = new TabPage("My Tool"); var panel = new Panel { Dock = DockStyle.Fill }; var button = new Button { Text = "Process All Items", Dock = DockStyle.Top }; button.Click += (sender, e) => ProcessAllItems(); panel.Controls.Add(button); customTab.Controls.Add(panel); tabControl.TabPages.Add(customTab); } private void ExportItemData(int itemId) { // Access Art API through Ultima namespace var bitmap = Ultima.Art.GetStatic(itemId); var itemData = Ultima.TileData.ItemTable[itemId]; if (bitmap != null) { string output = $"ID: 0x{itemId:X4}\n" + $"Name: {itemData.Name}\n" + $"Size: {bitmap.Width}x{bitmap.Height}\n" + $"Weight: {itemData.Weight}\n" + $"Flags: {itemData.Flags}"; System.IO.File.WriteAllText($"item_{itemId:X4}.txt", output); } } private void ProcessAllItems() { int maxId = Ultima.Art.GetMaxItemId(); int processed = 0; for (int i = 0; i <= maxId; i++) { if (Ultima.Art.IsValidStatic(i)) { // Process valid items processed++; } } MessageBox.Show($"Processed {processed} items", Name); } } ``` -------------------------------- ### Unified File Access with C# FileIndex API Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Shows how to use the FileIndex API to access data from both MUL/IDX and UOP file formats. It covers creating a FileIndex instance, seeking specific entries by ID, retrieving entry details (length, extra data, patched status), reading entry data into a byte array, validating entries, and accessing index properties. Requires System.IO and Ultima namespaces. ```csharp using System; using System.IO; using Ultima; // Create FileIndex for art files // Automatically detects MUL or UOP format FileIndex artIndex = new FileIndex( "Artidx.mul", // IDX file name "Art.mul", // MUL file name "artLegacyMUL.uop", // UOP file name 0x14000, // Maximum entries 4, // Patch file index (-1 for none) ".tga", // UOP file extension 0x13FDC, // Additional index (-1 for none) false // Extra data flag ); // Seek to an entry and get stream int itemId = 0x4F61; // Static item with 0x4000 offset Stream stream = artIndex.Seek(itemId, out int length, out int extra, out bool patched); if (stream != null) { Console.WriteLine($"Entry found - Length: {length}, Extra: {extra}, Patched: {patched}"); // Read data byte[] data = new byte[length]; stream.Read(data, 0, length); // Process data... Console.WriteLine($"Read {data.Length} bytes"); } else { Console.WriteLine("Entry not found or invalid"); } // Check if entry is valid if (artIndex.Valid(itemId, out int validLength, out int validExtra)) { Console.WriteLine($"Entry is valid: {validLength} bytes"); } // Get index properties Console.WriteLine($"Index length: {artIndex.IndexLength}"); Console.WriteLine($"IDX file length: {artIndex.IdxLength}"); ``` -------------------------------- ### Multi API - House and Structure Components Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Load and manipulate multi (house/building) structures. This API allows loading multi components, accessing their properties like dimensions and tile data, rendering them to images, and importing/loading them from various sources. ```APIDOC ## Multi API - House and Structure Components ### Description Load and manipulate multi (house/building) structures. This API allows loading multi components, accessing their properties like dimensions and tile data, rendering them to images, and importing/loading them from various sources. ### Method GET, POST (Implied for Import/Save) ### Endpoint /api/multi ### Parameters #### Path Parameters - **multiId** (int) - Required - The ID of the multi structure. #### Query Parameters None explicitly defined. #### Request Body - **filePath** (string) - Required for `ImportFromFile` - The path to the file to import. - **importType** (enum) - Optional for `ImportFromFile` - Specifies the format of the import file (e.g., TXT). ### Request Example ```csharp // Load a multi structure (e.g., a house) int multiId = 0x0064; // Small house MultiComponentList multi = Multis.GetComponents(multiId); if (multi != null) { // Render multi to image int maximumHeight = 200; // Max render height Bitmap multiImage = multi.GetImage(maximumHeight); if (multiImage != null) { multiImage.Save("house.png", System.Drawing.Imaging.ImageFormat.Png); } } // Import multi from file string filePath = @"C:\UO\Houses\custom_house.txt"; Multis.ImportFromFile(multiId, filePath, Multis.ImportType.TXT); // Load from multicache (placed houses) string cacheFile = @"C:\UO\Data\Multicache.dat"; MultiComponentList cachedMulti = Multis.LoadFromCache(cacheFile); ``` ### Response #### Success Response (200) - **MultiComponentList object** (object) - Contains properties like `Width`, `Height`, `Center`, `Min`, `Max`, and `SortedTiles`. #### Response Example ```json { "Width": 10, "Height": 10, "Center": {"X": 5, "Y": 5}, "Min": {"X": 0, "Y": 0, "Z": 0}, "Max": {"X": 9, "Y": 9, "Z": 5}, "SortedTiles": [ { "ItemId": "0xXXXX", "OffsetX": 0, "OffsetY": 0, "OffsetZ": 0, "Flags": "0xXXXXXX" }, ... ] } ``` ``` -------------------------------- ### Hue API: Load, Apply, and Save Color Hues Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt This snippet demonstrates how to load hues by index, access their color palettes, apply them to images (either fully or partially on grayscale pixels), and save modified hues. It relies on the Ultima library for image and hue manipulation. ```csharp using System; using System.Drawing; using Ultima; // Get a hue by index (0-2999) int hueIndex = 1153; // A red hue Hue hue = Hues.List[hueIndex]; Console.WriteLine($"Hue Name: {hue.Name}"); Console.WriteLine($"Color Range: {hue.TableStart} to {hue.TableEnd}"); // Access the 32-color palette for (int i = 0; i < 32; i++) { ushort color = hue.Colors[i]; Console.WriteLine($"Color {i}: 0x{color:X4}"); } // Apply hue to an image Bitmap originalItem = Art.GetStatic(0x0F61); // Sword bool onlyHueGrayPixels = false; // False = hue all pixels, True = only grayscale if (originalItem != null) { // Create hued version hue.ApplyTo(originalItem, onlyHueGrayPixels); originalItem.Save("hued_sword.png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine("Hued image saved"); } // Partial hue example (only gray pixels) Bitmap armor = Art.GetStatic(0x1415); // Chain coif Hue blueHue = Hues.List[1154]; if (armor != null) { blueHue.ApplyTo(armor, true); // Only hue gray/metal parts armor.Save("blue_armor.png", System.Drawing.Imaging.ImageFormat.Png); } // Save modified hues Hues.Save(@"C:\UO\Modified"); ``` -------------------------------- ### Import Items from PNG Directory - C# Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Imports item assets from PNG files in a specified directory and applies them to the game's static art. It parses filenames to extract item IDs, loads bitmaps, and replaces existing assets. The operation is saved if any modifications occur. Dependencies include System.Drawing and Ultima. ```csharp using System; using System.Drawing; using System.IO; using Ultima; // Batch replace items from directory public void ImportItemsFromDirectory(string inputDirectory) { var files = Directory.GetFiles(inputDirectory, "item_*.png"); int imported = 0; foreach (string file in files) { string fileName = Path.GetFileNameWithoutExtension(file); // Parse "item_0F61.png" to get ID 0x0F61 if (fileName.StartsWith("item_")) { string hexId = fileName.Substring(5); if (int.TryParse(hexId, System.Globalization.NumberStyles.HexNumber, null, out int itemId)) { Bitmap bmp = new Bitmap(file); Art.ReplaceStatic(itemId, bmp); imported++; } } } if (Art.Modified) { Art.Save(inputDirectory); Console.WriteLine($"Imported {imported} items"); } } ``` -------------------------------- ### FileIndex API - Low-Level File Access Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Provides a unified interface for accessing game data stored in MUL/IDX and UOP file formats. Allows seeking, reading, and validating file entries. ```APIDOC ## FileIndex API - Low-Level File Access ### Description Unified interface for accessing both MUL/IDX and UOP file formats. Allows seeking to specific entries and retrieving their data streams. ### Constructor - **FileIndex(string idxFileName, string mulFileName, string uopFileName, int maxEntries, int patchIndex, string uopExtension, int additionalIndex, bool extraDataFlag)** - Initializes a FileIndex object. Automatically detects MUL or UOP format. ### Methods - **Seek(int entryId, out int length, out int extra, out bool patched)** - Seeks to the specified entry ID and returns a Stream object for reading. Outputs the entry length, extra data size, and if the entry was patched. - **Valid(int entryId, out int validLength, out int validExtra)** - Checks if the entry ID is valid and returns its length and extra data size. ### Properties - **IndexLength**: Gets the total number of entries in the index. - **IdxLength**: Gets the file size of the IDX file. ### Example Usage (C#) ```csharp using System; using System.IO; using Ultima; // Create FileIndex for art files // Automatically detects MUL or UOP format FileIndex artIndex = new FileIndex( "Artidx.mul", // IDX file name "Art.mul", // MUL file name "artLegacyMUL.uop", // UOP file name 0x14000, // Maximum entries 4, // Patch file index (-1 for none) ".tga", // UOP file extension 0x13FDC, // Additional index (-1 for none) false // Extra data flag ); // Seek to an entry and get stream int itemId = 0x4F61; // Static item with 0x4000 offset Stream stream = artIndex.Seek(itemId, out int length, out int extra, out bool patched); if (stream != null) { Console.WriteLine($"Entry found - Length: {length}, Extra: {extra}, Patched: {patched}"); // Read data byte[] data = new byte[length]; stream.Read(data, 0, length); // Process data... Console.WriteLine($"Read {data.Length} bytes"); } else { Console.WriteLine("Entry not found or invalid"); } // Check if entry is valid if (artIndex.Valid(itemId, out int validLength, out int validExtra)) { Console.WriteLine($"Entry is valid: {validLength} bytes"); } // Get index properties Console.WriteLine($"Index length: {artIndex.IndexLength}"); Console.WriteLine($"IDX file length: {artIndex.IdxLength}"); ``` ``` -------------------------------- ### Export Items to PNG - C# Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Exports all valid static items from the game's art assets to individual PNG files in a specified directory. It iterates through all possible item IDs, checks for validity, and saves the corresponding bitmap if found. Dependencies include System.Drawing and Ultima. ```csharp using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; using Ultima; // Export all valid static items to PNG public void ExportAllItems(string outputDirectory) { Directory.CreateDirectory(outputDirectory); int maxId = Art.GetMaxItemId(); int exported = 0; for (int i = 0; i <= maxId; i++) { if (Art.IsValidStatic(i)) { Bitmap bmp = Art.GetStatic(i); if (bmp != null) { string fileName = Path.Combine(outputDirectory, $"item_{i:X4}.png"); bmp.Save(fileName, ImageFormat.Png); exported++; } } } Console.WriteLine($"Exported {exported} items to {outputDirectory}"); } ``` -------------------------------- ### Art API - Replacing and Saving Graphics Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Allows for the replacement of existing artwork and land tiles with custom images, as well as saving these changes back to MUL files. Supports removing items and reloading assets. ```APIDOC ## Art API - Replacing and Saving Graphics ### Description Allows for the replacement of existing artwork and land tiles with custom images, as well as saving these changes back to MUL files. Supports removing items and reloading assets. ### Method PUT / POST (Implicit for replacements/saves) ### Endpoint N/A (Class methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (handled via Bitmap objects in code) ### Request Example ```csharp using System.Drawing; using Ultima; // Load a custom image Bitmap customSword = new Bitmap("custom_sword.png"); // Replace a static item int itemId = 0x0F61; Art.ReplaceStatic(itemId, customSword); // Replace a land tile Bitmap customGrass = new Bitmap("custom_grass.png"); Art.ReplaceLand(0x03, customGrass); // Remove an item (marks as deleted) Art.RemoveStatic(0x1000); // Check if changes were made if (Art.Modified) { // Save changes to MUL files string outputPath = @"C:\UO\Modified"; Art.Save(outputPath); // Creates art.mul and artidx.mul Console.WriteLine("Art files saved successfully"); // Reload to clear cache Art.Reload(); } ``` ### Response #### Success Response (200) - **Art.Modified** (bool) - Indicates if any modifications were made. #### Response Example ```json { "message": "Art files saved successfully to C:\\UO\\Modified and reloaded.", "modified": true } ``` ``` -------------------------------- ### Load Land Tile Graphics using Art API Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Shows how to load land tile graphics, which are 44x44 pixel diamond-shaped terrain textures. The code includes retrieving a land tile by its ID, saving it, and checking for its validity. It also clarifies the internal ID ranges for land tiles and static items. ```csharp using System.Drawing; using Ultima; // Get a land tile (e.g., grass at ID 0x03) int landId = 0x03; Bitmap landBitmap = Art.GetLand(landId); if (landBitmap != null) { // Land tiles are always 44x44 diamonds Console.WriteLine($"Land tile size: {landBitmap.Width}x{landBitmap.Height}"); landBitmap.Save("grass_tile.png", System.Drawing.Imaging.ImageFormat.Png); } // Check validity if (Art.IsValidLand(landId)) { Console.WriteLine($"Land tile {landId} exists"); } // Land tiles are stored in range 0x0000-0x3FFF // Static items are stored in range 0x4000+ (offset by 0x4000 internally) ``` -------------------------------- ### Art API - Loading Static Item Graphics Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Provides methods to load static item graphics from Ultima Online's art assets. You can retrieve item graphics by their ID and check for validity. ```APIDOC ## Art API - Loading Static Item Graphics ### Description Provides methods to load static item graphics from Ultima Online's art assets. You can retrieve item graphics by their ID and check for validity. ### Method GET (Implicit) ### Endpoint N/A (Class methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp using System; using System.Drawing; using Ultima; // Initialize file paths (usually done once at startup) Files.SetMulPath(@"C:\Program Files\Electronic Arts\Ultima Online Classic"); // Get a static item graphic (e.g., a sword at ID 0x0F61) int itemId = 0x0F61; Bitmap itemBitmap = Art.GetStatic(itemId); if (itemBitmap != null) { // Display or manipulate the bitmap itemBitmap.Save("sword.png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine($"Item size: {itemBitmap.Width}x{itemBitmap.Height}"); } else { Console.WriteLine("Item not found or invalid"); } // Check if an item ID is valid before loading if (Art.IsValidStatic(itemId)) { // Get the maximum item ID supported by this client version int maxId = Art.GetMaxItemId(); // Returns 0xFFDC for High Seas, 0x7FFF for SA, 0x3FFF for older Console.WriteLine($"Client supports up to item ID: 0x{maxId:X}"); } ``` ### Response #### Success Response (200) - **itemBitmap** (Bitmap) - The loaded graphic of the item. - **maxId** (int) - The maximum item ID supported by the client. #### Response Example ```json { "message": "Item loaded successfully and saved to sword.png", "itemId": "0x0F61", "dimensions": "64x64", "maxSupportedItemId": "0xFFDC" } ``` ``` -------------------------------- ### Replace and Save Graphics using Art API Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Explains how to replace existing artwork for static items and land tiles with custom images and save these modifications back to MUL files. It covers replacing, removing, saving changes, and reloading the art data. The `Art.Modified` property indicates if any changes have been made. ```csharp using System.Drawing; using Ultima; // Load a custom image Bitmap customSword = new Bitmap("custom_sword.png"); // Replace a static item int itemId = 0x0F61; Art.ReplaceStatic(itemId, customSword); // Replace a land tile Bitmap customGrass = new Bitmap("custom_grass.png"); Art.ReplaceLand(0x03, customGrass); // Remove an item (marks as deleted) Art.RemoveStatic(0x1000); // Check if changes were made if (Art.Modified) { // Save changes to MUL files string outputPath = @"C:\UO\Modified"; Art.Save(outputPath); // Creates art.mul and artidx.mul Console.WriteLine("Art files saved successfully"); // Reload to clear cache Art.Reload(); } ``` -------------------------------- ### Apply Hue to Armor Items - C# Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Applies a specified hue to all armor items within the game assets. It iterates through items, checks if they are armor using TileFlags, applies the hue to gray pixels, and saves the modified assets. Dependencies include System.Drawing, Ultima, and TileData. ```csharp using System; using System.Drawing; using Ultima; // Apply hue to all armor items public void HueAllArmor(int hueIndex) { Hue hue = Hues.List[hueIndex]; int maxId = Art.GetMaxItemId(); int processed = 0; for (int i = 0; i <= maxId; i++) { ItemData itemData = TileData.ItemTable[i]; // Check if item is armor if ((itemData.Flags & TileFlag.Armor) != 0) { Bitmap bmp = Art.GetStatic(i); if (bmp != null) { hue.ApplyTo(bmp, true); // Only hue gray pixels Art.ReplaceStatic(i, bmp); processed++; } } } Console.WriteLine($"Applied hue to {processed} armor items"); Art.Save(@"C:\UO\Hued"); } ``` -------------------------------- ### Load, Manipulate, and Save Textures with C# Texture API Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Demonstrates how to load textures by ID, check their existence, replace them with custom images (ensuring correct dimensions), save modified textures to a specified directory, and retrieve the total texture count. Requires the System.Drawing and Ultima namespaces. ```csharp using System; using System.Drawing; using Ultima; // Get a texture (64x64 or 128x128) int textureId = 0x05; // Example texture Bitmap texture = Textures.GetTexture(textureId); if (texture != null) { Console.WriteLine($"Texture size: {texture.Width}x{texture.Height}"); texture.Save($"texture_{textureId:X4}.png", System.Drawing.Imaging.ImageFormat.Png); } // Test if texture exists if (Textures.TestTexture(textureId)) { Console.WriteLine($"Texture {textureId} exists"); } // Replace a texture Bitmap customTexture = new Bitmap("custom_texture.png"); // Texture must be 64x64 or 128x128 if (customTexture.Width == 64 && customTexture.Height == 64) { Textures.Replace(textureId, customTexture); Console.WriteLine("Texture replaced"); } else { Console.WriteLine("Invalid texture size - must be 64x64 or 128x128"); } // Save changes Textures.Save(@"C:\\UO\\Modified"); // Get texture count int maxTextures = 0x1000; // Typical maximum Console.WriteLine($"Processing up to {maxTextures} textures"); ``` -------------------------------- ### Art API - Loading Land Tile Graphics Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Enables retrieval of land tile graphics, which are represented as 44x44 pixel diamond-shaped terrain textures. Includes functionality to check the validity of land tile IDs. ```APIDOC ## Art API - Loading Land Tile Graphics ### Description Enables retrieval of land tile graphics, which are represented as 44x44 pixel diamond-shaped terrain textures. Includes functionality to check the validity of land tile IDs. ### Method GET (Implicit) ### Endpoint N/A (Class methods) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp using System.Drawing; using Ultima; // Get a land tile (e.g., grass at ID 0x03) int landId = 0x03; Bitmap landBitmap = Art.GetLand(landId); if (landBitmap != null) { // Land tiles are always 44x44 diamonds Console.WriteLine($"Land tile size: {landBitmap.Width}x{landBitmap.Height}"); landBitmap.Save("grass_tile.png", System.Drawing.Imaging.ImageFormat.Png); } // Check validity if (Art.IsValidLand(landId)) { Console.WriteLine($"Land tile {landId} exists"); } // Land tiles are stored in range 0x0000-0x3FFF // Static items are stored in range 0x4000+ (offset by 0x4000 internally) ``` ### Response #### Success Response (200) - **landBitmap** (Bitmap) - The loaded 44x44 diamond-shaped land tile graphic. #### Response Example ```json { "message": "Land tile loaded and saved to grass_tile.png", "landId": "0x03", "dimensions": "44x44" } ``` ``` -------------------------------- ### Manage UI Elements (Gumps) using Gump API Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Details the Gump API for managing UI elements such as buttons, backgrounds, and borders stored in gumpart.mul or UOP archives. This includes retrieving gumps by ID, saving them as images, checking for their existence, replacing them with custom graphics, removing them, and saving all changes. ```csharp using System.Drawing; using Ultima; // Get a gump graphic (e.g., a button at ID 0x0A40) int gumpId = 0x0A40; Bitmap gumpBitmap = Gumps.GetGump(gumpId); if (gumpBitmap != null) { gumpBitmap.Save($"gump_{gumpId:X4}.png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine($"Gump dimensions: {gumpBitmap.Width}x{gumpBitmap.Height}"); } // Check if gump exists if (Gumps.IsValidIndex(gumpId)) { // Get raw gump data with dimensions Bitmap rawGump = Gumps.GetGump(gumpId, out int width, out int height); Console.WriteLine($"Raw dimensions from file: {width}x{height}"); } // Replace a gump Bitmap customButton = new Bitmap("custom_button.png"); Gumps.ReplaceGump(gumpId, customButton); // Remove a gump Gumps.RemoveGump(0x1234); // Save changes Gumps.Save(@"C:\UO\Modified"); // Get total gump count int count = Gumps.GetCount(); Console.WriteLine($"Total gumps: {count}"); ``` -------------------------------- ### Sound API - Sound Effect Management Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Access and manage sound effects from sound.mul or soundLegacyMUL.uop. This API allows retrieving sound data, saving sounds to WAV files, adding new sounds, removing existing ones, and checking for sound validity. ```APIDOC ## Sound API - Sound Effect Management ### Description Access and manage sound effects from sound.mul or soundLegacyMUL.uop. This API allows retrieving sound data, saving sounds to WAV files, adding new sounds, removing existing ones, and checking for sound validity. ### Method GET, POST, DELETE (Implied by operations like GetSound, Add, Remove, Save) ### Endpoint /api/sounds ### Parameters #### Path Parameters - **soundId** (int) - Required - The ID of the sound effect. #### Query Parameters None explicitly defined. #### Request Body - **UoSound object** (object) - Required for `Add` operation - Contains `Id`, `Name`, and `Buffer` (byte array). ### Request Example ```csharp // Get a sound by ID int soundId = 0x0057; // Example sound effect UoSound sound = Sounds.GetSound(soundId); if (sound != null) { // Save sound as WAV file string outputPath = $"sound_{soundId:X4}.wav"; File.WriteAllBytes(outputPath, sound.Buffer); } // Add a new sound byte[] wavData = File.ReadAllBytes("custom_sound.wav"); var newSound = new UoSound(0x1000, "Custom Sound", wavData); Sounds.Add(0x1000, newSound); // Remove a sound Sounds.Remove(soundId); // Save changes Sounds.Save(@"C:\UO\Modified"); ``` ### Response #### Success Response (200) - **UoSound object** (object) - Contains `Id`, `Name`, and `Buffer` (byte array). #### Response Example ```json { "Id": "0x0057", "Name": "Example Sound", "Buffer": "BASE64_ENCODED_WAV_DATA" } ``` ``` -------------------------------- ### Access and Modify Item and Land Tile Properties Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Enables access to and modification of item and land tile properties, including flags, names, and attributes. This API allows querying details like weight, height, and animation for items, and texture IDs and impassable flags for land tiles. Changes can be saved, and the tile data can be initialized or reloaded. ```csharp using System; using Ultima; // Access item properties int itemId = 0x0F61; // Sword ItemData itemData = TileData.ItemTable[itemId]; Console.WriteLine($"Item Name: {itemData.Name}"); Console.WriteLine($"Weight: {itemData.Weight}"); Console.WriteLine($"Height: {itemData.Height}"); Console.WriteLine($"Animation: 0x{itemData.Animation:X4}"); // Check item flags if ((itemData.Flags & TileFlag.Weapon) != 0) { Console.WriteLine("This is a weapon"); } if ((itemData.Flags & TileFlag.Wearable) != 0) { Console.WriteLine("This item can be worn"); } // Modify item properties itemData.Name = "Custom Sword"; itemData.Weight = 10; itemData.Flags |= TileFlag.ArticleA; // Add "a" article TileData.ItemTable[itemId] = itemData; // Access land tile properties int landId = 0x03; // Grass LandData landData = TileData.LandTable[landId]; Console.WriteLine($"Land Name: {landData.Name}"); Console.WriteLine($"Texture ID: {landData.TextureId}"); // Check land flags if ((landData.Flags & TileFlag.Impassable) != 0) { Console.WriteLine("Cannot walk on this terrain"); } // Save changes TileData.Save(@"C:\\UO\\Modified"); // Initialize/reload TileData.Initialize(); ``` -------------------------------- ### Access and Render World Map Data Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Provides access to world map data, including terrain and static objects. This API allows retrieving map dimensions, rendering specific sections of the map with or without static objects, and managing map diff files. It also supports resetting map caches. ```csharp using System; using System.Drawing; using Ultima; // Access predefined map instances Map felucca = Map.Felucca; // Map 0: 6144x4096 Map trammel = Map.Trammel; // Map 1: 6144x4096 Map ilshenar = Map.Ilshenar; // Map 2: 2304x1600 Map malas = Map.Malas; // Map 3: 2560x2048 Map tokuno = Map.Tokuno; // Map 4: 1448x1448 Map terMur = Map.TerMur; // Map 5: 1280x4096 // Get map dimensions Console.WriteLine($"Felucca size: {felucca.Width}x{felucca.Height}"); // Render a section of the map int x = 1000, y = 1000; int width = 200, height = 200; bool includeStatics = true; Bitmap mapImage = felucca.GetImage(x, y, width, height, includeStatics); if (mapImage != null) { mapImage.Save("map_section.png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine("Map section saved"); } // Enable/disable diff files (map patches) Map.UseDiff = true; // Enable mapdif/stadif files Map.Reload(); // Reload all maps with new diff setting // Reset map cache to free memory felucca.ResetCache(); ``` -------------------------------- ### Texture Management API Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Provides functionality to load, test, replace, and save texture files used in land tile rendering. Textures are expected to be 64x64 or 128x128 pixels. ```APIDOC ## Texture API - Texture Management ### Description Load and manipulate texture files used for land tile rendering. Textures must be 64x64 or 128x128 pixels. ### Methods - **GetTexture(int textureId)** - Returns a Bitmap object for the specified texture ID. - **TestTexture(int textureId)** - Returns true if the texture ID exists, false otherwise. - **Replace(int textureId, Bitmap texture)** - Replaces an existing texture with the provided Bitmap. The Bitmap must be 64x64 or 128x128. - **Save(string directoryPath)** - Saves all modified textures to the specified directory. ### Example Usage (C#) ```csharp using System; using System.Drawing; using Ultima; // Get a texture (64x64 or 128x128) int textureId = 0x05; // Example texture Bitmap texture = Textures.GetTexture(textureId); if (texture != null) { Console.WriteLine($"Texture size: {texture.Width}x{texture.Height}"); texture.Save($"texture_{textureId:X4}.png", System.Drawing.Imaging.ImageFormat.Png); } // Test if texture exists if (Textures.TestTexture(textureId)) { Console.WriteLine($"Texture {textureId} exists"); } // Replace a texture Bitmap customTexture = new Bitmap("custom_texture.png"); // Texture must be 64x64 or 128x128 if (customTexture.Width == 64 && customTexture.Height == 64) { Textures.Replace(textureId, customTexture); Console.WriteLine("Texture replaced"); } else { Console.WriteLine("Invalid texture size - must be 64x64 or 128x128"); } // Save changes Textures.Save(@"C:\UO\Modified"); // Get texture count int maxTextures = 0x1000; // Typical maximum Console.WriteLine($"Processing up to {maxTextures} textures"); ``` ``` -------------------------------- ### Configure Export Path - C# Source: https://github.com/jedi661/uofiddlerpixel/blob/master/UoFiddler/Data/ExportUOL/ExportUOL.cs Readme, Ravenel.htm This code snippet defines the constant string for the export path where static XML files will be saved. It specifies a direct path to a user's 'My Documents' folder. Ensure this path is correctly set to your desired export directory. ```csharp private const string ExportPath = @"C:\Documents and Settings\Owner\My Documents\UOLandscaper\Exports"; ``` -------------------------------- ### Hue API - Color Palette Management Source: https://context7.com/jedi661/uofiddlerpixel/llms.txt Load and apply color hues to graphics for equipment dyeing and effects. This API allows you to retrieve hue information, access its color palette, and apply hues to images, including partial application to grayscale pixels. Modified hues can also be saved. ```APIDOC ## Hue API - Color Palette Management ### Description Load and apply color hues to graphics for equipment dyeing and effects. This API allows you to retrieve hue information, access its color palette, and apply hues to images, including partial application to grayscale pixels. Modified hues can also be saved. ### Method GET, POST, PUT, DELETE (Implied by operations like ApplyTo, Save) ### Endpoint /api/hues ### Parameters #### Path Parameters - **hueIndex** (int) - Required - The index of the hue to retrieve (0-2999). #### Query Parameters None explicitly defined, but operations like `onlyHueGrayPixels` could be considered query parameters in a RESTful context. #### Request Body Not applicable for retrieval, but implied for operations like `Add` or `Save`. ### Request Example ```csharp // Get a hue by index (0-2999) int hueIndex = 1153; // A red hue Hue hue = Hues.List[hueIndex]; // Apply hue to an image Bitmap originalItem = Art.GetStatic(0x0F61); // Sword bool onlyHueGrayPixels = false; // False = hue all pixels, True = only grayscale if (originalItem != null) { // Create hued version hue.ApplyTo(originalItem, onlyHueGrayPixels); originalItem.Save("hued_sword.png", System.Drawing.Imaging.ImageFormat.Png); } // Save modified hues Hues.Save(@"C:\UO\Modified"); ``` ### Response #### Success Response (200) - **Hue object** (object) - Contains `Name`, `TableStart`, `TableEnd`, and `Colors` (array of ushort). #### Response Example ```json { "Name": "Red Hue", "TableStart": 0, "TableEnd": 31, "Colors": [ "0xXXXX", "0xXXXX", ... ] } ``` ```