From a8c37a88a40c74840b36f477a359af1009c7d2a1 Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Fri, 13 Nov 2026 11:45:36 +0100
Subject: [PATCH 01/18] Stop Multis preview flicker when switching entries
Update the preview once per selection change and hold panel redraw while the preview moves.
---
.../UserControls/MultisControl.Designer.cs | 4 +-
.../UserControls/MultisControl.cs | 126 +++++++++++++++---
2 files changed, 108 insertions(+), 22 deletions(-)
diff --git a/UoFiddler.Controls/UserControls/MultisControl.Designer.cs b/UoFiddler.Controls/UserControls/MultisControl.Designer.cs
index ef5650a6..e7284868 100644
--- a/UoFiddler.Controls/UserControls/MultisControl.Designer.cs
+++ b/UoFiddler.Controls/UserControls/MultisControl.Designer.cs
@@ -225,7 +225,7 @@ private void InitializeComponent()
listViewMultiColumn.Width = 240;
listViewMulti.Columns.Add(listViewMultiColumn);
listViewMulti.RetrieveVirtualItem += OnRetrieveMultiVirtualItem;
- listViewMulti.SelectedIndexChanged += AfterSelect_Multi;
+ listViewMulti.SelectedIndexChanged += OnMulSelectionChanged;
//
// contextMenuStrip2
//
@@ -811,7 +811,7 @@ private void InitializeComponent()
listViewUopColumn.Width = 240;
listViewUop.Columns.Add(listViewUopColumn);
listViewUop.RetrieveVirtualItem += OnRetrieveUopVirtualItem;
- listViewUop.SelectedIndexChanged += AfterSelect_UopMulti;
+ listViewUop.SelectedIndexChanged += OnUopSelectionChanged;
//
// contextMenuStripUop
//
diff --git a/UoFiddler.Controls/UserControls/MultisControl.cs b/UoFiddler.Controls/UserControls/MultisControl.cs
index 714957c3..41225114 100644
--- a/UoFiddler.Controls/UserControls/MultisControl.cs
+++ b/UoFiddler.Controls/UserControls/MultisControl.cs
@@ -14,6 +14,7 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
+using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Xml;
using Ultima;
@@ -168,6 +169,9 @@ private void SelectUopRow(int rowPos)
private bool _previewFitMode = true;
private Bitmap _mulBitmap;
private Bitmap _uopBitmap;
+ private bool _mulSelectPending;
+ private bool _uopSelectPending;
+ private Panel _redrawSuspendedPanel;
private bool _isPanning;
private Point _panStartScreen;
private double _zoomLevel = 1.0;
@@ -352,8 +356,28 @@ public void ChangeMulti(int id, MultiComponentList multi)
ControlEvents.FireMultiChangeEvent(this, id);
}
+ // A virtual ListView raises SelectedIndexChanged twice per click (deselect, then select).
+ // Defer to one update so the empty in-between state never reaches the preview.
+ private void OnMulSelectionChanged(object sender, EventArgs e)
+ {
+ if (_mulSelectPending)
+ {
+ return;
+ }
+
+ _mulSelectPending = true;
+ BeginInvoke(() =>
+ {
+ if (_mulSelectPending && !IsDisposed)
+ {
+ AfterSelect_Multi(this, EventArgs.Empty);
+ }
+ });
+ }
+
private void AfterSelect_Multi(object sender, EventArgs e)
{
+ _mulSelectPending = false;
int id = GetSelectedMulId();
MultiComponentList multi = id >= 0 ? Multis.GetComponents(id) : MultiComponentList.Empty;
if (multi == MultiComponentList.Empty)
@@ -407,18 +431,57 @@ private void RebuildMulIds(bool includeEmpty)
private void UpdateMulPictureBox()
{
- if (_previewFitMode || _mulBitmap == null)
+ WithoutPanelRedraw(panelMultiScroll, () =>
+ {
+ if (_previewFitMode || _mulBitmap == null)
+ {
+ MultiPictureBox.Dock = DockStyle.Fill;
+ MultiPictureBox.Cursor = Cursors.Default;
+ }
+ else
+ {
+ MultiPictureBox.Dock = DockStyle.None;
+ CenterPictureBox(MultiPictureBox, panelMultiScroll, GetZoomedSize(_mulBitmap.Size));
+ MultiPictureBox.Cursor = Cursors.Hand;
+ }
+ });
+ MultiPictureBox.Invalidate();
+ }
+
+ private const int _wmSetRedraw = 0x000B;
+ private const uint _rdwInvalidate = 0x0001;
+ private const uint _rdwErase = 0x0004;
+ private const uint _rdwAllChildren = 0x0080;
+ private const uint _rdwFrame = 0x0400;
+
+ [DllImport("user32.dll")]
+ private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport("user32.dll")]
+ private static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, uint flags);
+
+ // Moving and resizing the preview takes several window moves (dock, size, location, panel
+ // auto-scroll), and each one shows on screen. Hold the panel's redraw until all are done.
+ private void WithoutPanelRedraw(Panel panel, Action change)
+ {
+ if (!panel.IsHandleCreated || _redrawSuspendedPanel == panel)
{
- MultiPictureBox.Dock = DockStyle.Fill;
- MultiPictureBox.Cursor = Cursors.Default;
+ change();
+ return;
}
- else
+
+ _redrawSuspendedPanel = panel;
+ SendMessage(panel.Handle, _wmSetRedraw, IntPtr.Zero, IntPtr.Zero);
+ try
{
- MultiPictureBox.Dock = DockStyle.None;
- CenterPictureBox(MultiPictureBox, panelMultiScroll, GetZoomedSize(_mulBitmap.Size));
- MultiPictureBox.Cursor = Cursors.Hand;
+ change();
+ }
+ finally
+ {
+ SendMessage(panel.Handle, _wmSetRedraw, new IntPtr(1), IntPtr.Zero);
+ _redrawSuspendedPanel = null;
+ RedrawWindow(panel.Handle, IntPtr.Zero, IntPtr.Zero, _rdwInvalidate | _rdwErase | _rdwAllChildren | _rdwFrame);
}
- MultiPictureBox.Invalidate();
}
private void OnPaint_MultiPic(object sender, PaintEventArgs e)
@@ -991,8 +1054,26 @@ private void LoadUopTree()
}
}
+ private void OnUopSelectionChanged(object sender, EventArgs e)
+ {
+ if (_uopSelectPending)
+ {
+ return;
+ }
+
+ _uopSelectPending = true;
+ BeginInvoke(() =>
+ {
+ if (_uopSelectPending && !IsDisposed)
+ {
+ AfterSelect_UopMulti(this, EventArgs.Empty);
+ }
+ });
+ }
+
private void AfterSelect_UopMulti(object sender, EventArgs e)
{
+ _uopSelectPending = false;
int id = GetSelectedUopId();
MultiComponentList multi = id >= 0 ? Multis.GetUopComponents(id) : MultiComponentList.Empty;
if (multi == MultiComponentList.Empty)
@@ -1031,17 +1112,20 @@ private void RefreshUopBitmap()
private void UpdateUopPictureBox()
{
- if (_previewFitMode || _uopBitmap == null)
- {
- UopPictureBox.Dock = DockStyle.Fill;
- UopPictureBox.Cursor = Cursors.Default;
- }
- else
+ WithoutPanelRedraw(panelUopScroll, () =>
{
- UopPictureBox.Dock = DockStyle.None;
- CenterPictureBox(UopPictureBox, panelUopScroll, GetZoomedSize(_uopBitmap.Size));
- UopPictureBox.Cursor = Cursors.Hand;
- }
+ if (_previewFitMode || _uopBitmap == null)
+ {
+ UopPictureBox.Dock = DockStyle.Fill;
+ UopPictureBox.Cursor = Cursors.Default;
+ }
+ else
+ {
+ UopPictureBox.Dock = DockStyle.None;
+ CenterPictureBox(UopPictureBox, panelUopScroll, GetZoomedSize(_uopBitmap.Size));
+ UopPictureBox.Cursor = Cursors.Hand;
+ }
+ });
UopPictureBox.Invalidate();
}
@@ -1129,7 +1213,8 @@ private void OnPanelMultiScroll_Resize(object sender, EventArgs e)
{
if (!_previewFitMode && _mulBitmap != null)
{
- CenterPictureBox(MultiPictureBox, panelMultiScroll, GetZoomedSize(_mulBitmap.Size));
+ WithoutPanelRedraw(panelMultiScroll,
+ () => CenterPictureBox(MultiPictureBox, panelMultiScroll, GetZoomedSize(_mulBitmap.Size)));
}
}
@@ -1137,7 +1222,8 @@ private void OnPanelUopScroll_Resize(object sender, EventArgs e)
{
if (!_previewFitMode && _uopBitmap != null)
{
- CenterPictureBox(UopPictureBox, panelUopScroll, GetZoomedSize(_uopBitmap.Size));
+ WithoutPanelRedraw(panelUopScroll,
+ () => CenterPictureBox(UopPictureBox, panelUopScroll, GetZoomedSize(_uopBitmap.Size)));
}
}
From 54fb3b6af657c82be11a84d728ec51a5200d2677 Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Sat, 14 Nov 2026 01:50:47 +0100
Subject: [PATCH 02/18] Read and write UO Architect design files (.uoa and
Designs.idx/bin)
---
Ultima/UoaDesignFile.cs | 241 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 241 insertions(+)
create mode 100644 Ultima/UoaDesignFile.cs
diff --git a/Ultima/UoaDesignFile.cs b/Ultima/UoaDesignFile.cs
new file mode 100644
index 00000000..af3d238a
--- /dev/null
+++ b/Ultima/UoaDesignFile.cs
@@ -0,0 +1,241 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace Ultima
+{
+ ///
+ /// One design in a UO Architect file: what its header says, and where its items are.
+ ///
+ public sealed class UoaDesign
+ {
+ public string Name { get; internal set; }
+
+ public string Category { get; internal set; }
+
+ public string Subsection { get; internal set; }
+
+ /// Size as UO Architect stored it; not always the extent of the items.
+ public int Width { get; internal set; }
+
+ public int Height { get; internal set; }
+
+ public int ItemCount { get; internal set; }
+
+ /// The .uoa file, or the .idx of an idx + bin design set.
+ public string FileName { get; internal set; }
+
+ /// Position of the design within its file, from 0.
+ public int Index { get; internal set; }
+
+ /// Where the item records start: in the .uoa itself, or in the .bin of a design set.
+ internal long ItemsPosition { get; set; }
+
+ internal bool InDesignSet { get; set; }
+ }
+
+ ///
+ /// Reads and writes UO Architect designs. Layouts as in UO Architect 2.7:
+ ///
+ /// - .uoa version 1: one design. Version 2: a count, then that many designs.
+ /// - A design: name, category, subsection (each a flag byte, then a length-prefixed string
+ /// when the flag is 1), width, height, user width, user height, item count (int32 each), then
+ /// per item six int16: id, x, y, z, level, hue.
+ /// - Design set (Designs.idx + Designs.bin): the idx holds a count, a version (0) and per
+ /// design the same header followed by the int64 position and int32 count of its records in
+ /// the bin; a bin record is int32 type (0 or 1), id, x, y, z, level, and hue when type is 1.
+ ///
+ /// A multi has no item hue or level, so reading drops them and writing stores 0.
+ ///
+ public static class UoaDesignFile
+ {
+ private const int _itemSize = 12;
+
+ ///
+ /// The designs a file holds, without reading their items. Takes a .uoa (either version) or
+ /// the .idx of a design set. An unreadable or foreign file gives an empty list.
+ ///
+ public static List ReadHeaders(string fileName)
+ {
+ var designs = new List();
+ try
+ {
+ using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
+ using (var reader = new BinaryReader(fs))
+ {
+ if (fileName.EndsWith(".idx", StringComparison.OrdinalIgnoreCase))
+ {
+ int count = reader.ReadInt32();
+ if (reader.ReadInt32() != 0 || count < 0)
+ {
+ return designs;
+ }
+
+ for (int i = 0; i < count; ++i)
+ {
+ UoaDesign design = ReadHeader(reader, fileName, i, countFollows: false);
+ design.ItemsPosition = reader.ReadInt64();
+ design.ItemCount = reader.ReadInt32();
+ design.InDesignSet = true;
+ designs.Add(design);
+ }
+
+ return designs;
+ }
+
+ short version = reader.ReadInt16();
+ int total = version == 1 ? 1 : version == 2 ? reader.ReadInt16() : 0;
+ for (int i = 0; i < total; ++i)
+ {
+ UoaDesign design = ReadHeader(reader, fileName, i, countFollows: true);
+ design.ItemsPosition = fs.Position;
+ fs.Seek((long)design.ItemCount * _itemSize, SeekOrigin.Current);
+ if (fs.Position > fs.Length)
+ {
+ break; // cut short: what was read so far stands
+ }
+
+ designs.Add(design);
+ }
+ }
+ }
+ catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException)
+ {
+ // What was read before the file ran out is returned.
+ }
+
+ return designs;
+ }
+
+ private static UoaDesign ReadHeader(BinaryReader reader, string fileName, int index, bool countFollows)
+ {
+ var design = new UoaDesign
+ {
+ FileName = fileName,
+ Index = index,
+ Name = ReadString(reader),
+ Category = ReadString(reader),
+ Subsection = ReadString(reader),
+ Width = reader.ReadInt32(),
+ Height = reader.ReadInt32()
+ };
+ reader.ReadInt32(); // user width
+ reader.ReadInt32(); // user height
+ if (countFollows)
+ {
+ design.ItemCount = reader.ReadInt32();
+ if (design.ItemCount < 0)
+ {
+ throw new IOException("Negative item count");
+ }
+ }
+
+ return design;
+ }
+
+ /// The items of a design as a multi. Hue and level are dropped; Z is kept within a multi's range.
+ public static MultiComponentList Load(UoaDesign design)
+ {
+ var entries = new List(Math.Max(0, design.ItemCount));
+ string path = design.InDesignSet ? Path.ChangeExtension(design.FileName, ".bin") : design.FileName;
+ using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
+ using (var reader = new BinaryReader(fs))
+ {
+ fs.Seek(design.ItemsPosition, SeekOrigin.Begin);
+ for (int i = 0; i < design.ItemCount; ++i)
+ {
+ int id, x, y, z;
+ if (design.InDesignSet)
+ {
+ int type = reader.ReadInt32();
+ id = reader.ReadInt32();
+ x = reader.ReadInt32();
+ y = reader.ReadInt32();
+ z = reader.ReadInt32();
+ reader.ReadInt32(); // level
+ if (type == 1)
+ {
+ reader.ReadInt32(); // hue
+ }
+ }
+ else
+ {
+ id = (ushort)reader.ReadInt16();
+ x = reader.ReadInt16();
+ y = reader.ReadInt16();
+ z = reader.ReadInt16();
+ reader.ReadInt16(); // level
+ reader.ReadInt16(); // hue
+ }
+
+ entries.Add(new MultiComponentList.MultiTileEntry
+ {
+ ItemId = (ushort)id,
+ OffsetX = (short)x,
+ OffsetY = (short)y,
+ OffsetZ = (short)Math.Clamp(z, sbyte.MinValue, sbyte.MaxValue),
+ Flags = 1,
+ Unk1 = 0
+ });
+ }
+ }
+
+ return entries.Count == 0 ? MultiComponentList.Empty : new MultiComponentList(entries);
+ }
+
+ ///
+ /// Writes designs as a .uoa: version 1 for one design, version 2 (a batch) for several.
+ ///
+ public static void Write(string fileName, IReadOnlyList<(string Name, string Category, string Subsection, MultiComponentList Multi)> designs)
+ {
+ using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
+ using (var writer = new BinaryWriter(fs))
+ {
+ if (designs.Count == 1)
+ {
+ writer.Write((short)1);
+ }
+ else
+ {
+ writer.Write((short)2);
+ writer.Write((short)designs.Count);
+ }
+
+ foreach ((string name, string category, string subsection, MultiComponentList multi) in designs)
+ {
+ WriteString(writer, name);
+ WriteString(writer, category);
+ WriteString(writer, subsection);
+ writer.Write(multi.Width);
+ writer.Write(multi.Height);
+ writer.Write(multi.Width); // user width
+ writer.Write(multi.Height); // user height
+ writer.Write(multi.SortedTiles.Length);
+ foreach (MultiComponentList.MultiTileEntry tile in multi.SortedTiles)
+ {
+ writer.Write((short)tile.ItemId);
+ writer.Write(tile.OffsetX);
+ writer.Write(tile.OffsetY);
+ writer.Write(tile.OffsetZ);
+ writer.Write((short)0); // level
+ writer.Write((short)0); // hue
+ }
+ }
+ }
+ }
+
+ internal static string ReadString(BinaryReader reader)
+ {
+ return reader.ReadByte() == 0 ? null : reader.ReadString();
+ }
+
+ internal static void WriteString(BinaryWriter writer, string value)
+ {
+ writer.Write((byte)(value == null ? 0 : 1));
+ if (value != null)
+ {
+ writer.Write(value);
+ }
+ }
+ }
+}
From b98aa4a32bea03f33364756d9bf54afeaa45402e Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Sat, 14 Nov 2026 01:50:48 +0100
Subject: [PATCH 03/18] Import UOHE and WorldForge multi designs and export
every importable format
---
Ultima/MultiComponentList.cs | 354 ++++++++++++++++++++++++++++++++++-
Ultima/Multis.cs | 4 +-
2 files changed, 356 insertions(+), 2 deletions(-)
diff --git a/Ultima/MultiComponentList.cs b/Ultima/MultiComponentList.cs
index a599aea8..0e33b764 100644
--- a/Ultima/MultiComponentList.cs
+++ b/Ultima/MultiComponentList.cs
@@ -203,6 +203,7 @@ public MultiComponentList(string fileName, Multis.ImportType type)
_min = _max = Point.Empty;
int itemCount;
+ List parsed = null;
switch (type)
{
@@ -350,7 +351,17 @@ public MultiComponentList(string fileName, Multis.ImportType type)
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var reader = new BinaryReader(fs))
{
- if (reader.ReadInt16() != 1) // Version check
+ // Version 1 holds one design; version 2 is a batch, of which the first
+ // design is read here (UoaDesignFile reads them all).
+ short uoaVersion = reader.ReadInt16();
+ if (uoaVersion == 2)
+ {
+ if (reader.ReadInt16() < 1)
+ {
+ return;
+ }
+ }
+ else if (uoaVersion != 1)
{
return;
}
@@ -623,11 +634,217 @@ public MultiComponentList(string fileName, Multis.ImportType type)
break;
}
+ case Multis.ImportType.UOX3:
+ parsed = ReadUox3(fileName);
+ break;
+ case Multis.ImportType.XML:
+ parsed = ReadXml(fileName);
+ break;
+ case Multis.ImportType.UOH:
+ parsed = ReadUoh(fileName);
+ break;
+ case Multis.ImportType.WORLDFORGE:
+ parsed = ReadWorldForge(fileName);
+ break;
+ }
+
+ if (parsed != null)
+ {
+ // Formats read into a list: take the tiles and their bounds from it.
+ SortedTiles = parsed.ToArray();
+ if (SortedTiles.Length > 0)
+ {
+ _min = new Point(int.MaxValue, int.MaxValue);
+ _max = new Point(int.MinValue, int.MinValue);
+ foreach (MultiTileEntry e in SortedTiles)
+ {
+ _min.X = Math.Min(_min.X, e.OffsetX);
+ _min.Y = Math.Min(_min.Y, e.OffsetY);
+ _max.X = Math.Max(_max.X, e.OffsetX);
+ _max.Y = Math.Max(_max.Y, e.OffsetY);
+ MaxHeight = Math.Max(MaxHeight, e.OffsetZ);
+ }
+ }
}
ConvertList();
}
+ private static MultiTileEntry Entry(int id, int x, int y, int z, int flags = 1, int unk1 = 0)
+ {
+ return new MultiTileEntry
+ {
+ ItemId = (ushort)id,
+ OffsetX = (short)x,
+ OffsetY = (short)y,
+ OffsetZ = (short)Math.Clamp(z, sbyte.MinValue, sbyte.MaxValue),
+ Flags = flags,
+ Unk1 = unk1
+ };
+ }
+
+ ///
+ /// A number written as decimal or as 0x hex.
+ ///
+ private static int ParseNumber(string text)
+ {
+ text = text.Trim();
+ return text.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
+ ? int.Parse(text[2..], System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture)
+ : int.Parse(text, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
+ }
+
+ ///
+ /// UOX3 house items, as writes them:
+ /// [HOUSE ITEM n] { ITEM=0x.. X=.. Y=.. Z=.. }.
+ ///
+ private static List ReadUox3(string fileName)
+ {
+ var list = new List();
+ int id = -1, x = 0, y = 0, z = 0;
+ foreach (string raw in File.ReadLines(fileName, Encoding.GetEncoding(1252)))
+ {
+ string line = raw.Trim();
+ if (line.StartsWith('['))
+ {
+ id = -1;
+ x = y = z = 0;
+ continue;
+ }
+
+ if (line == "}" && id >= 0)
+ {
+ list.Add(Entry(id, x, y, z));
+ id = -1;
+ continue;
+ }
+
+ int equals = line.IndexOf('=');
+ if (equals <= 0)
+ {
+ continue;
+ }
+
+ string key = line[..equals].Trim().ToUpperInvariant();
+ string value = line[(equals + 1)..];
+ switch (key)
+ {
+ case "ITEM":
+ id = ParseNumber(value);
+ break;
+ case "X":
+ x = ParseNumber(value);
+ break;
+ case "Y":
+ y = ParseNumber(value);
+ break;
+ case "Z":
+ z = ParseNumber(value);
+ break;
+ }
+ }
+
+ return list;
+ }
+
+ ///
+ /// The XML writes: <Entry><Item X Y Z ID Flags Unk1 />.
+ ///
+ private static List ReadXml(string fileName)
+ {
+ var list = new List();
+ var dom = new XmlDocument();
+ dom.Load(fileName);
+ foreach (XmlElement item in dom.GetElementsByTagName("Item"))
+ {
+ string flags = item.GetAttribute("Flags");
+ string unk1 = item.GetAttribute("Unk1");
+ list.Add(Entry(
+ ParseNumber(item.GetAttribute("ID")),
+ ParseNumber(item.GetAttribute("X")),
+ ParseNumber(item.GetAttribute("Y")),
+ ParseNumber(item.GetAttribute("Z")),
+ flags.Length > 0 ? ParseNumber(flags) : 1,
+ unk1.Length > 0 ? ParseNumber(unk1) : 0));
+ }
+
+ return list;
+ }
+
+ ///
+ /// A UO House Editor design: a header line ("UOHE File ver 1.00",width,height,base), then
+ /// one line per item: floor,x,y,altitude,item id (decimal). Floor 0 is the foundation with
+ /// altitudes from 0; floor 1 starts at the base height and every further floor 20 higher.
+ ///
+ private static List ReadUoh(string fileName)
+ {
+ var list = new List();
+ string[] lines = File.ReadAllLines(fileName, Encoding.GetEncoding(1252));
+ if (lines.Length == 0 || !lines[0].StartsWith("\"UOHE File", StringComparison.OrdinalIgnoreCase))
+ {
+ throw new InvalidDataException("Not a UOHE design file");
+ }
+
+ string[] header = lines[0].Split(',');
+ int baseHeight = header.Length > 3 ? ParseNumber(header[3]) : 7;
+
+ for (int i = 1; i < lines.Length; ++i)
+ {
+ string[] parts = lines[i].Split(',');
+ if (parts.Length < 5)
+ {
+ continue;
+ }
+
+ int floor = ParseNumber(parts[0]);
+ int altitude = ParseNumber(parts[3]);
+ int z = floor == 0 ? altitude : baseHeight + ((floor - 1) * 20) + altitude;
+ list.Add(Entry(ParseNumber(parts[4]), ParseNumber(parts[1]), ParseNumber(parts[2]), z));
+ }
+
+ return list;
+ }
+
+ ///
+ /// A WorldForge export: <tile id x y z hue /> elements in world coordinates, moved so
+ /// the lowest X, Y and Z are 0. Hues are not part of a multi and are dropped.
+ ///
+ private static List ReadWorldForge(string fileName)
+ {
+ var dom = new XmlDocument();
+ dom.Load(fileName);
+ var tiles = new List<(int Id, int X, int Y, int Z)>();
+ foreach (XmlNode node in dom.GetElementsByTagName("*"))
+ {
+ if (node is XmlElement tile && tile.LocalName.Equals("tile", StringComparison.OrdinalIgnoreCase) && tile.HasAttribute("id"))
+ {
+ tiles.Add((ParseNumber(tile.GetAttribute("id")), ParseNumber(tile.GetAttribute("x")),
+ ParseNumber(tile.GetAttribute("y")), ParseNumber(tile.GetAttribute("z"))));
+ }
+ }
+
+ var list = new List(tiles.Count);
+ if (tiles.Count == 0)
+ {
+ return list;
+ }
+
+ int minX = int.MaxValue, minY = int.MaxValue, minZ = int.MaxValue;
+ foreach (var t in tiles)
+ {
+ minX = Math.Min(minX, t.X);
+ minY = Math.Min(minY, t.Y);
+ minZ = Math.Min(minZ, t.Z);
+ }
+
+ foreach (var t in tiles)
+ {
+ list.Add(Entry(t.Id, t.X - minX, t.Y - minY, t.Z - minZ));
+ }
+
+ return list;
+ }
+
public MultiComponentList(List arr)
{
_min = _max = Point.Empty;
@@ -849,6 +1066,141 @@ private MultiComponentList()
Tiles = Array.Empty();
}
+ // The exports below mirror what the matching imports read. Where an import skips a field
+ // (UO Architect's category, level and hue, the cache header's other numbers), the export
+ // writes a neutral value: only this reader's view of those formats is known here.
+
+ private static void WriteUOAString(BinaryWriter writer, string value)
+ {
+ writer.Write((byte)(value == null ? 0 : 1));
+ if (value != null)
+ {
+ writer.Write(value);
+ }
+ }
+
+ /// UO Architect binary design (.uoa), version 1: one design with a name and its items.
+ public void ExportToUOABinaryFile(string fileName, string name)
+ {
+ using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
+ using (var writer = new BinaryWriter(fs))
+ {
+ writer.Write((short)1); // version
+ WriteUOAString(writer, name);
+ WriteUOAString(writer, null); // category
+ WriteUOAString(writer, null); // subsection
+ writer.Write(Width);
+ writer.Write(Height);
+ writer.Write(Width); // user width
+ writer.Write(Height); // user height
+ writer.Write(SortedTiles.Length);
+ for (int i = 0; i < SortedTiles.Length; ++i)
+ {
+ writer.Write((short)SortedTiles[i].ItemId);
+ writer.Write(SortedTiles[i].OffsetX);
+ writer.Write(SortedTiles[i].OffsetY);
+ writer.Write(SortedTiles[i].OffsetZ);
+ writer.Write((short)0); // level
+ writer.Write((short)0); // hue
+ }
+ }
+ }
+
+ ///
+ /// UO Architect design set: name.idx and name.bin next to
+ /// , holding this one design (index version 0, item records of type 0).
+ ///
+ public void ExportToDesignerFiles(string fileName, string name)
+ {
+ string root = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(fileName)) ?? string.Empty, Path.GetFileNameWithoutExtension(fileName));
+ using (var idxfs = new FileStream(root + ".idx", FileMode.Create, FileAccess.Write))
+ using (var binfs = new FileStream(root + ".bin", FileMode.Create, FileAccess.Write))
+ using (var idx = new BinaryWriter(idxfs))
+ using (var bin = new BinaryWriter(binfs))
+ {
+ idx.Write(1); // designs
+ idx.Write(0); // version
+ WriteUOAString(idx, name);
+ WriteUOAString(idx, null); // category
+ WriteUOAString(idx, null); // subsection
+ idx.Write(Width);
+ idx.Write(Height);
+ idx.Write(Width); // user width
+ idx.Write(Height); // user height
+ idx.Write(0L); // position of the first record in the bin
+ idx.Write(SortedTiles.Length);
+
+ for (int i = 0; i < SortedTiles.Length; ++i)
+ {
+ bin.Write(0); // record type
+ bin.Write((int)SortedTiles[i].ItemId);
+ bin.Write((int)SortedTiles[i].OffsetX);
+ bin.Write((int)SortedTiles[i].OffsetY);
+ bin.Write((int)SortedTiles[i].OffsetZ);
+ bin.Write(0); // level
+ }
+ }
+ }
+
+ ///
+ /// Client multi cache text (Multicache.dat) holding this one design: a header line whose third
+ /// number is the item count, then one line per item: id, flags, x, y, z.
+ ///
+ public void ExportToCacheFile(string fileName)
+ {
+ using (var tex = new StreamWriter(new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite), Encoding.GetEncoding(1252)))
+ {
+ tex.WriteLine($"0 0 {SortedTiles.Length} 0 0 0 0");
+ for (int i = 0; i < SortedTiles.Length; ++i)
+ {
+ tex.WriteLine(
+ $"{SortedTiles[i].ItemId} {SortedTiles[i].Flags} {SortedTiles[i].OffsetX} {SortedTiles[i].OffsetY} {SortedTiles[i].OffsetZ}");
+ }
+ }
+ }
+
+ ///
+ /// UO House Editor (UOHE) design: the header line, then floor, x, y, altitude, item id per item.
+ /// Items below are on floor 0 (the foundation) with their Z as
+ /// altitude; above it a floor is 20 high. X and Y start at 0.
+ ///
+ public void ExportToUohFile(string fileName, int baseHeight = 7)
+ {
+ using (var tex = new StreamWriter(new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite), Encoding.GetEncoding(1252)))
+ {
+ tex.WriteLine($"\"UOHE File ver 1.00\",{Width},{Height},{baseHeight}");
+ for (int i = 0; i < SortedTiles.Length; ++i)
+ {
+ int z = SortedTiles[i].OffsetZ;
+ int floor = z < baseHeight ? 0 : 1 + ((z - baseHeight) / 20);
+ int altitude = floor == 0 ? z : z - baseHeight - ((floor - 1) * 20);
+ tex.WriteLine($"{floor},{SortedTiles[i].OffsetX - _min.X},{SortedTiles[i].OffsetY - _min.Y},{altitude},{SortedTiles[i].ItemId}");
+ }
+ }
+ }
+
+ /// WorldForge tile list: one tile element per item with id, x, y, z and hue 0, from 0,0.
+ public void ExportToWorldForgeFile(string fileName)
+ {
+ var settings = new XmlWriterSettings { Indent = true };
+ using (XmlWriter xml = XmlWriter.Create(fileName, settings))
+ {
+ xml.WriteStartElement("tiles");
+ for (int i = 0; i < SortedTiles.Length; ++i)
+ {
+ xml.WriteStartElement("tile");
+ xml.WriteAttributeString("id", SortedTiles[i].ItemId.ToString(System.Globalization.CultureInfo.InvariantCulture));
+ xml.WriteAttributeString("x", (SortedTiles[i].OffsetX - _min.X).ToString(System.Globalization.CultureInfo.InvariantCulture));
+ xml.WriteAttributeString("y", (SortedTiles[i].OffsetY - _min.Y).ToString(System.Globalization.CultureInfo.InvariantCulture));
+ xml.WriteAttributeString("z", SortedTiles[i].OffsetZ.ToString(System.Globalization.CultureInfo.InvariantCulture));
+ xml.WriteAttributeString("hue", "0");
+ xml.WriteEndElement();
+ }
+
+ xml.WriteEndElement();
+ }
+ }
+
public void ExportToTextFile(string fileName)
{
using (var tex = new StreamWriter(new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite), Encoding.GetEncoding(1252)))
diff --git a/Ultima/Multis.cs b/Ultima/Multis.cs
index ed2c2a0e..eb0b73e7 100644
--- a/Ultima/Multis.cs
+++ b/Ultima/Multis.cs
@@ -58,7 +58,9 @@ public enum ImportType
UOX3,
MULTICACHE,
UOADESIGN,
- XML
+ XML,
+ UOH, // UO House Editor (UOHE) design
+ WORLDFORGE // WorldForge tile export
}
///
From 97fc5d7122c042f50b97ca44e9b0cd4631adc6d9 Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Sat, 14 Nov 2026 01:50:48 +0100
Subject: [PATCH 04/18] Resolve a plugin's dependencies from plugins\\
---
UoFiddler.Controls/Plugin/PluginServices.cs | 55 +++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/UoFiddler.Controls/Plugin/PluginServices.cs b/UoFiddler.Controls/Plugin/PluginServices.cs
index c42178d1..2c7d47d0 100644
--- a/UoFiddler.Controls/Plugin/PluginServices.cs
+++ b/UoFiddler.Controls/Plugin/PluginServices.cs
@@ -12,6 +12,8 @@
using System;
using System.IO;
using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Runtime.Loader;
using Microsoft.Extensions.Logging;
using UoFiddler.Controls.Classes;
using UoFiddler.Controls.Plugin.Interfaces;
@@ -53,6 +55,8 @@ public void FindPlugins(string path)
return;
}
+ RegisterDependencyResolver(path);
+
foreach (string fileOn in Directory.GetFiles(path, "*.dll"))
{
try
@@ -86,6 +90,57 @@ public void ClosePlugins()
AvailablePlugins.Clear();
}
+ private static string _dependencyRoot;
+
+ ///
+ /// Lets a plugin ship third-party libraries in a subfolder of the plugin directory
+ /// (plugins\PluginName\). Files directly in the plugin directory are all loaded as plugins,
+ /// so dependencies cannot sit there.
+ ///
+ private static void RegisterDependencyResolver(string pluginDirectory)
+ {
+ bool first = _dependencyRoot == null;
+ _dependencyRoot = pluginDirectory;
+ if (!first)
+ {
+ return;
+ }
+
+ AssemblyLoadContext.Default.Resolving += (context, name) =>
+ {
+ string path = FindDependency(name.Name + ".dll");
+ return path == null ? null : context.LoadFromAssemblyPath(path);
+ };
+
+ AssemblyLoadContext.Default.ResolvingUnmanagedDll += (_, libraryName) =>
+ {
+ string path = FindDependency(libraryName)
+ ?? (libraryName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)
+ ? null
+ : FindDependency(libraryName + ".dll"));
+ return path != null && NativeLibrary.TryLoad(path, out IntPtr handle) ? handle : IntPtr.Zero;
+ };
+ }
+
+ private static string FindDependency(string fileName)
+ {
+ if (!Directory.Exists(_dependencyRoot))
+ {
+ return null;
+ }
+
+ foreach (string directory in Directory.GetDirectories(_dependencyRoot))
+ {
+ string candidate = Path.Combine(directory, fileName);
+ if (File.Exists(candidate))
+ {
+ return candidate;
+ }
+ }
+
+ return null;
+ }
+
private void AddPlugin(string fileName)
{
Assembly pluginAssembly = Assembly.LoadFrom(fileName);
From b6015cfaf1c550e209030e8c5766dd1ff570f74c Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Sat, 14 Nov 2026 01:50:48 +0100
Subject: [PATCH 05/18] Keep plugin settings in the profile
---
UoFiddler.Controls/Classes/Options.cs | 6 ++++++
UoFiddler/Classes/FiddlerOptions.cs | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/UoFiddler.Controls/Classes/Options.cs b/UoFiddler.Controls/Classes/Options.cs
index a3ae8e72..26964eca 100644
--- a/UoFiddler.Controls/Classes/Options.cs
+++ b/UoFiddler.Controls/Classes/Options.cs
@@ -86,6 +86,12 @@ public static class Options
///
public static List PluginsToLoad { get; set; } = new List();
+ ///
+ /// Settings plugins keep in the profile, by name. A plugin prefixes its names with its own
+ /// (e.g. "MultiEditor.Grid"); the values are saved and loaded with the profile as text.
+ ///
+ public static Dictionary PluginSettings { get; set; } = new Dictionary();
+
///
/// Defines which muls are loaded
///
diff --git a/UoFiddler/Classes/FiddlerOptions.cs b/UoFiddler/Classes/FiddlerOptions.cs
index f562fee5..11a9312f 100644
--- a/UoFiddler/Classes/FiddlerOptions.cs
+++ b/UoFiddler/Classes/FiddlerOptions.cs
@@ -251,6 +251,19 @@ public static void SaveProfile()
}
}
+ if (Options.PluginSettings.Count > 0)
+ {
+ comment = dom.CreateComment("Plugin settings");
+ sr.AppendChild(comment);
+ foreach (KeyValuePair setting in System.Linq.Enumerable.OrderBy(Options.PluginSettings, s => s.Key, StringComparer.Ordinal))
+ {
+ XmlElement xmlSetting = dom.CreateElement("PluginSetting");
+ xmlSetting.SetAttribute("name", setting.Key);
+ xmlSetting.SetAttribute("value", setting.Value ?? string.Empty);
+ sr.AppendChild(xmlSetting);
+ }
+ }
+
comment = dom.CreateComment("Path settings");
sr.AppendChild(comment);
elem = dom.CreateElement("RootPath");
@@ -487,6 +500,12 @@ public static void LoadProfile(string filename)
Options.PluginsToLoad.Add(name);
}
+ Options.PluginSettings.Clear();
+ foreach (XmlElement xSetting in xOptions.SelectNodes("PluginSetting"))
+ {
+ Options.PluginSettings[xSetting.GetAttribute("name")] = xSetting.GetAttribute("value");
+ }
+
elem = (XmlElement)xOptions.SelectSingleNode("RootPath");
if (elem != null)
{
From b2cb961b2494783f709b042b9e29f7a90017b508 Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Sat, 14 Nov 2026 01:50:48 +0100
Subject: [PATCH 06/18] Let plugins add to the Map tab's context menu with the
clicked location
---
UoFiddler.Controls/Plugin/PluginEvents.cs | 19 +++++++++++++++++++
UoFiddler.Controls/UserControls/MapControl.cs | 1 +
2 files changed, 20 insertions(+)
diff --git a/UoFiddler.Controls/Plugin/PluginEvents.cs b/UoFiddler.Controls/Plugin/PluginEvents.cs
index 7c6ad53d..2934c768 100644
--- a/UoFiddler.Controls/Plugin/PluginEvents.cs
+++ b/UoFiddler.Controls/Plugin/PluginEvents.cs
@@ -9,7 +9,10 @@
*
***************************************************************************/
+using System;
+using System.Drawing;
using System.Windows.Forms;
+using Ultima;
namespace UoFiddler.Controls.Plugin
{
@@ -30,5 +33,21 @@ public static void FireModifyItemShowContextMenuEvent(ContextMenuStrip contextme
{
ModifyItemsControlContextMenuEvent?.Invoke(contextmenu);
}
+
+ ///
+ /// OnLoad called in MapControl to modify its context menu. gives
+ /// the shown map and the map location of the right click that opened the menu.
+ ///
+ public delegate void ModifyMapControlContextMenuHandler(ContextMenuStrip contextmenu, Func<(Map Map, Point Location)> clickedAt);
+
+ ///
+ /// OnLoad called in MapControl to modify its context menu
+ ///
+ public static event ModifyMapControlContextMenuHandler ModifyMapControlContextMenuEvent;
+
+ public static void FireModifyMapControlContextMenuEvent(ContextMenuStrip contextmenu, Func<(Map Map, Point Location)> clickedAt)
+ {
+ ModifyMapControlContextMenuEvent?.Invoke(contextmenu, clickedAt);
+ }
}
}
\ No newline at end of file
diff --git a/UoFiddler.Controls/UserControls/MapControl.cs b/UoFiddler.Controls/UserControls/MapControl.cs
index 563a5b54..6e83ab06 100644
--- a/UoFiddler.Controls/UserControls/MapControl.cs
+++ b/UoFiddler.Controls/UserControls/MapControl.cs
@@ -167,6 +167,7 @@ private void OnLoad(object sender, EventArgs e)
ControlEvents.MapNameChangeEvent += OnMapNameChangeEvent;
ControlEvents.MapSizeChangeEvent += OnMapSizeChangeEvent;
ControlEvents.FilePathChangeEvent += OnFilePathChangeEvent;
+ Plugin.PluginEvents.FireModifyMapControlContextMenuEvent(contextMenuStrip1, () => (CurrentMap, _currentPoint));
}
_loaded = true;
}
From 271a4018037e562ca9a02d9c26be9aa10b7808e9 Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Sat, 14 Nov 2026 01:50:49 +0100
Subject: [PATCH 07/18] Add 1,697 tiles to the multi editor tile groups and a
tile rotation table
---
.../MultiRotationTable.xml | 3927 +++++++++++++++++
UoFiddler.Plugin.MultiEditor/multieditor.xml | 1785 ++++++++
2 files changed, 5712 insertions(+)
create mode 100644 UoFiddler.Plugin.MultiEditor/MultiRotationTable.xml
diff --git a/UoFiddler.Plugin.MultiEditor/MultiRotationTable.xml b/UoFiddler.Plugin.MultiEditor/MultiRotationTable.xml
new file mode 100644
index 00000000..6bd41562
--- /dev/null
+++ b/UoFiddler.Plugin.MultiEditor/MultiRotationTable.xml
@@ -0,0 +1,3927 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/UoFiddler.Plugin.MultiEditor/multieditor.xml b/UoFiddler.Plugin.MultiEditor/multieditor.xml
index 4228b22c..dfd53d58 100644
--- a/UoFiddler.Plugin.MultiEditor/multieditor.xml
+++ b/UoFiddler.Plugin.MultiEditor/multieditor.xml
@@ -1426,6 +1426,9 @@
+
+
+
@@ -1441,6 +1444,10 @@
+
+
+
+
@@ -1777,6 +1784,10 @@
+
+
+
+
@@ -1898,6 +1909,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -8743,6 +8848,11 @@
+
+
+
+
+
@@ -9108,4 +9218,1679 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 6a9746cec9b00134e0be34f7aa81ca34535739d0 Mon Sep 17 00:00:00 2001
From: AsY!um- <377468+AsYlum-@users.noreply.github.com>
Date: Sat, 14 Nov 2026 01:51:07 +0100
Subject: [PATCH 08/18] Replace the multi editor with an OpenGL editor, version
3.0.0
Tool palette, document tabs, tile browser with house styles, blueprints and UO Architect designs, floors, plan view and preview.
---
.../Classes/ArtMetrics.cs | 38 +
.../Classes/EditCommand.cs | 92 +
.../Classes/GroupTransform.cs | 263 ++
.../Classes/HouseStyles.cs | 246 ++
.../Classes/IMultiViewSettings.cs | 30 +
.../Classes/MapExtract.cs | 92 +
.../Classes/MultiEditorComponentList.cs | 1629 ++++------
.../Classes/MultiTile.cs | 290 ++
.../Classes/PlanView.cs | 253 ++
.../Classes/Prefabs.cs | 123 +
.../Classes/RotationTable.cs | 108 +
.../Classes/TileFavorites.cs | 152 +
.../Classes/WallPlanner.cs | 259 ++
.../Editing/EditorSession.Commands.cs | 804 +++++
.../Editing/EditorSession.cs | 756 +++++
.../Editing/FloorPattern.cs | 576 ++++
.../Editing/LassoTool.cs | 123 +
.../Forms/ShortcutsHelpForm.Designer.cs | 99 -
.../Forms/ShortcutsHelpForm.cs | 77 -
.../MultiEditorPluginBase.cs | 99 +-
.../Properties/Resources.Designer.cs | 63 -
.../Rendering/ArtAtlas.cs | 199 ++
.../Rendering/ArtPixels.cs | 152 +
.../Rendering/Camera2D.cs | 107 +
.../Rendering/GlCanvas.cs | 469 +++
.../Rendering/SceneRenderer.cs | 593 ++++
.../Rendering/ShaderProgram.cs | 74 +
.../Rendering/SpriteBatch.cs | 311 ++
.../Tools/DrawTool.cs | 67 +
.../Tools/EditorTool.cs | 243 ++
.../Tools/HousePartTools.cs | 625 ++++
.../Tools/LineTool.cs | 65 +
.../Tools/PasteTool.cs | 136 +
.../Tools/PlaneDragTool.cs | 145 +
.../Tools/RectFillTool.cs | 51 +
.../Tools/RemoveTool.cs | 67 +
.../Tools/SelectTool.cs | 153 +
.../Tools/TileClickTools.cs | 77 +
.../Tools/WallTool.cs | 41 +
.../UI/DesignLibraryPanel.Designer.cs | 262 ++
.../UI/DesignLibraryPanel.cs | 368 +++
.../UI/DesignLibraryPanel.resx | 126 +
UoFiddler.Plugin.MultiEditor/UI/DocumentIO.cs | 481 +++
.../UI/DocumentIOPickDialog.Designer.cs | 217 ++
.../UI/DocumentIOPickDialog.cs | 242 ++
.../DocumentIOPickDialog.resx} | 4 +-
.../UI/DocumentIOSaveDialog.Designer.cs | 295 ++
.../UI/DocumentIOSaveDialog.cs | 354 +++
.../UI/DocumentIOSaveDialog.resx | 120 +
.../UI/EditorCommands.cs | 383 +++
.../UI/EditorSettings.cs | 169 ++
.../UI/EditorSettingsDialog.Designer.cs | 439 +++
.../UI/EditorSettingsDialog.cs | 187 ++
.../UI/EditorSettingsDialog.resx | 120 +
.../UI/FloorsDialog.Designer.cs | 217 ++
.../UI/FloorsDialog.cs | 141 +
.../UI/FloorsDialog.resx | 120 +
.../UI/InspectorPanel.Designer.cs | 700 +++++
.../UI/InspectorPanel.cs | 594 ++++
.../UI/InspectorPanel.resx | 123 +
.../UI/MapExtractForm.Designer.cs | 256 ++
.../UI/MapExtractForm.cs | 50 +
.../UI/MapExtractForm.resx | 120 +
.../UI/MultiEditorControl.Designer.cs | 543 ++++
.../UI/MultiEditorControl.cs | 1806 +++++++++++
.../MultiEditorControl.resx} | 2 +-
.../UI/NewMultiDialog.Designer.cs | 200 ++
.../UI/NewMultiDialog.cs | 138 +
.../UI/NewMultiDialog.resx | 120 +
.../UI/NumbersPromptForm.Designer.cs | 75 +
.../UI/NumbersPromptForm.cs | 67 +
.../UI/NumbersPromptForm.resx | 120 +
.../UI/ShortcutsForm.Designer.cs | 76 +
.../UI/ShortcutsForm.cs | 87 +
.../UI/ShortcutsForm.resx | 120 +
.../UI/TextPromptForm.Designer.cs | 96 +
.../UI/TextPromptForm.cs | 33 +
.../UI/TextPromptForm.resx | 120 +
.../UI/TileBrowserCatalog.cs | 284 ++
.../UI/TileBrowserGrid.cs | 745 +++++
.../UI/TileBrowserHouseGallery.cs | 408 +++
.../UI/TileBrowserPanel.Designer.cs | 539 ++++
.../UI/TileBrowserPanel.cs | 2071 +++++++++++++
.../UI/TileBrowserPanel.resx | 147 +
.../UI/TileBrowserThumbnails.cs | 180 ++
.../UoFiddler.Plugin.MultiEditor.csproj | 160 +-
.../MultiEditorControl.Designer.cs | 1237 --------
.../UserControls/MultiEditorControl.cs | 2682 -----------------
.../UserControls/MultiEditorControl.resx | 869 ------
.../images/AltitudeButton.bmp | Bin 1350 -> 0 bytes
.../images/AltitudeButton_Selected.bmp | Bin 1350 -> 0 bytes
.../images/AltitudeButton_Selected.psd | Bin 2886 -> 0 bytes
.../images/DrawButton.bmp | Bin 1350 -> 0 bytes
.../images/DrawButton_Selected.bmp | Bin 1350 -> 0 bytes
.../images/Help-Icon-16.png | Bin 330 -> 0 bytes
.../images/LineDrawButton.bmp | Bin 1062 -> 0 bytes
.../images/LineDrawButton_Selected.bmp | Bin 1062 -> 0 bytes
.../images/PipetteButton.bmp | Bin 1062 -> 0 bytes
.../images/PipetteButton_Selected.bmp | Bin 1350 -> 0 bytes
.../images/RectFillButton.bmp | Bin 1062 -> 0 bytes
.../images/RectFillButton_Selected.bmp | Bin 1062 -> 0 bytes
.../images/RemoveButton.bmp | Bin 1350 -> 0 bytes
.../images/RemoveButton_Selected.bmp | Bin 1350 -> 0 bytes
.../images/SelectButton.bmp | Bin 1350 -> 0 bytes
.../images/SelectButton_Selected.bmp | Bin 1350 -> 0 bytes
.../images/TransButton.bmp | Bin 1350 -> 0 bytes
.../images/TransButton_Selected.bmp | Bin 1350 -> 0 bytes
.../images/TransButton_Selected.psd | Bin 2863 -> 0 bytes
.../images/VirtualFloorButton.bmp | Bin 1062 -> 0 bytes
.../images/VirtualFloorButton_Selected.bmp | Bin 1350 -> 0 bytes
.../images/VirtualFloorButton_Selected.psd | Bin 2929 -> 0 bytes
.../images/treeViewImage.bmp | Bin 822 -> 0 bytes
112 files changed, 22574 insertions(+), 6186 deletions(-)
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/ArtMetrics.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/EditCommand.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/GroupTransform.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/HouseStyles.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/IMultiViewSettings.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/MapExtract.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/MultiTile.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/PlanView.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/Prefabs.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/RotationTable.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/TileFavorites.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Classes/WallPlanner.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Editing/EditorSession.Commands.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Editing/EditorSession.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Editing/FloorPattern.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Editing/LassoTool.cs
delete mode 100644 UoFiddler.Plugin.MultiEditor/Forms/ShortcutsHelpForm.Designer.cs
delete mode 100644 UoFiddler.Plugin.MultiEditor/Forms/ShortcutsHelpForm.cs
delete mode 100644 UoFiddler.Plugin.MultiEditor/Properties/Resources.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Rendering/ArtAtlas.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Rendering/ArtPixels.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Rendering/Camera2D.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Rendering/GlCanvas.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Rendering/SceneRenderer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Rendering/ShaderProgram.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Rendering/SpriteBatch.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/DrawTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/EditorTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/HousePartTools.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/LineTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/PasteTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/PlaneDragTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/RectFillTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/RemoveTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/SelectTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/TileClickTools.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/Tools/WallTool.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DesignLibraryPanel.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DesignLibraryPanel.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DesignLibraryPanel.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DocumentIO.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DocumentIOPickDialog.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DocumentIOPickDialog.cs
rename UoFiddler.Plugin.MultiEditor/{Properties/Resources.resx => UI/DocumentIOPickDialog.resx} (97%)
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DocumentIOSaveDialog.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DocumentIOSaveDialog.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/DocumentIOSaveDialog.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/EditorCommands.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/EditorSettings.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/EditorSettingsDialog.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/EditorSettingsDialog.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/EditorSettingsDialog.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/FloorsDialog.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/FloorsDialog.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/FloorsDialog.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/InspectorPanel.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/InspectorPanel.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/InspectorPanel.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/MapExtractForm.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/MapExtractForm.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/MapExtractForm.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/MultiEditorControl.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/MultiEditorControl.cs
rename UoFiddler.Plugin.MultiEditor/{Forms/ShortcutsHelpForm.resx => UI/MultiEditorControl.resx} (99%)
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/NewMultiDialog.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/NewMultiDialog.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/NewMultiDialog.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/NumbersPromptForm.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/NumbersPromptForm.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/NumbersPromptForm.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/ShortcutsForm.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/ShortcutsForm.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/ShortcutsForm.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TextPromptForm.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TextPromptForm.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TextPromptForm.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TileBrowserCatalog.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TileBrowserGrid.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TileBrowserHouseGallery.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TileBrowserPanel.Designer.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TileBrowserPanel.cs
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TileBrowserPanel.resx
create mode 100644 UoFiddler.Plugin.MultiEditor/UI/TileBrowserThumbnails.cs
delete mode 100644 UoFiddler.Plugin.MultiEditor/UserControls/MultiEditorControl.Designer.cs
delete mode 100644 UoFiddler.Plugin.MultiEditor/UserControls/MultiEditorControl.cs
delete mode 100644 UoFiddler.Plugin.MultiEditor/UserControls/MultiEditorControl.resx
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/AltitudeButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/AltitudeButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/AltitudeButton_Selected.psd
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/DrawButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/DrawButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/Help-Icon-16.png
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/LineDrawButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/LineDrawButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/PipetteButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/PipetteButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/RectFillButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/RectFillButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/RemoveButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/RemoveButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/SelectButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/SelectButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/TransButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/TransButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/TransButton_Selected.psd
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/VirtualFloorButton.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/VirtualFloorButton_Selected.bmp
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/VirtualFloorButton_Selected.psd
delete mode 100644 UoFiddler.Plugin.MultiEditor/images/treeViewImage.bmp
diff --git a/UoFiddler.Plugin.MultiEditor/Classes/ArtMetrics.cs b/UoFiddler.Plugin.MultiEditor/Classes/ArtMetrics.cs
new file mode 100644
index 00000000..d49a4689
--- /dev/null
+++ b/UoFiddler.Plugin.MultiEditor/Classes/ArtMetrics.cs
@@ -0,0 +1,38 @@
+/***************************************************************************
+ *
+ * $Author: MuadDib & Turley
+ *
+ * "THE BEER-WARE LICENSE"
+ * As long as you retain this notice you can do whatever you want with
+ * this stuff. If we meet some day, and you think this stuff is worth it,
+ * you can buy me a beer in return.
+ *
+ ***************************************************************************/
+
+
+using System.Drawing;
+using Ultima;
+
+namespace UoFiddler.Plugin.MultiEditor.Classes
+{
+ ///
+ /// Size of a static's art, which places a tile on the canvas.
+ ///
+ internal static class ArtMetrics
+ {
+ public static bool TryGetSize(ushort id, out int width, out int height)
+ {
+ Bitmap bmp = id != 0xFFFF ? Art.GetStatic(id) : null;
+ if (bmp == null)
+ {
+ width = 0;
+ height = 0;
+ return false;
+ }
+
+ width = bmp.Width;
+ height = bmp.Height;
+ return true;
+ }
+ }
+}
diff --git a/UoFiddler.Plugin.MultiEditor/Classes/EditCommand.cs b/UoFiddler.Plugin.MultiEditor/Classes/EditCommand.cs
new file mode 100644
index 00000000..e57ba7ff
--- /dev/null
+++ b/UoFiddler.Plugin.MultiEditor/Classes/EditCommand.cs
@@ -0,0 +1,92 @@
+/***************************************************************************
+ *
+ * $Author: Turley
+ *
+ * "THE BEER-WARE LICENSE"
+ * As long as you retain this notice you can do whatever you want with
+ * this stuff. If we meet some day, and you think this stuff is worth it,
+ * you can buy me a beer in return.
+ *
+ ***************************************************************************/
+
+using System.Collections.Generic;
+
+namespace UoFiddler.Plugin.MultiEditor.Classes
+{
+ ///
+ /// The saved fields of a tile, used to put a changed tile back.
+ ///
+ internal readonly record struct TileState(ushort Id, int X, int Y, int Z, bool Invisible)
+ {
+ public static TileState Of(MultiTile tile) => new(tile.Id, tile.X, tile.Y, tile.Z, tile.Invisible);
+
+ public void ApplyTo(MultiTile tile)
+ {
+ tile.Id = Id;
+ tile.Invisible = Invisible;
+ tile.X = X;
+ tile.Y = Y;
+ tile.Z = Z;
+ }
+ }
+
+ ///
+ /// One undo step: the tiles an edit added, removed and changed, and the multi size before and
+ /// after. Tiles are kept as the same objects, so references to them survive undo and redo.
+ ///
+ internal sealed class EditCommand
+ {
+ public EditCommand(string action, int width, int height)
+ {
+ Action = action;
+ OldWidth = NewWidth = width;
+ OldHeight = NewHeight = height;
+ }
+
+ public string Action { get; }
+
+ public HashSet Added { get; } = new();
+
+ public HashSet Removed { get; } = new();
+
+ ///
+ /// State of each changed tile before the edit. Tiles added by the same edit are not listed.
+ ///
+ public Dictionary Before { get; } = new();
+
+ ///
+ /// State of each changed tile after the edit, filled in when the edit ends.
+ ///
+ public Dictionary After { get; } = new();
+
+ public int OldWidth { get; }
+
+ public int OldHeight { get; }
+
+ public int NewWidth { get; set; }
+
+ public int NewHeight { get; set; }
+
+ public bool IsEmpty => Added.Count == 0 && Removed.Count == 0 && Before.Count == 0 &&
+ OldWidth == NewWidth && OldHeight == NewHeight;
+
+ public void CaptureAfter()
+ {
+ After.Clear();
+ foreach (MultiTile tile in new List(Before.Keys))
+ {
+ TileState after = TileState.Of(tile);
+
+ // A tile changed and changed back is no change at all.
+ if (after == Before[tile])
+ {
+ Before.Remove(tile);
+ }
+ else
+ {
+ After[tile] = after;
+ }
+ }
+ }
+ }
+}
diff --git a/UoFiddler.Plugin.MultiEditor/Classes/GroupTransform.cs b/UoFiddler.Plugin.MultiEditor/Classes/GroupTransform.cs
new file mode 100644
index 00000000..93bdd463
--- /dev/null
+++ b/UoFiddler.Plugin.MultiEditor/Classes/GroupTransform.cs
@@ -0,0 +1,263 @@
+/***************************************************************************
+ *
+ * $Author: Turley
+ *
+ * "THE BEER-WARE LICENSE"
+ * As long as you retain this notice you can do whatever you want with
+ * this stuff. If we meet some day, and you think this stuff is worth it,
+ * you can buy me a beer in return.
+ *
+ ***************************************************************************/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace UoFiddler.Plugin.MultiEditor.Classes
+{
+ internal enum GroupTransformKind
+ {
+ RotateLeft,
+ RotateRight,
+ MirrorX,
+ MirrorY
+ }
+
+ ///
+ /// Rotates or mirrors a group of tiles. Graphics in UO never turn, so a piece that faces a way
+ /// (a stair, roof slope, door) is swapped for the piece of its style that faces the new way.
+ /// Walls sit on cell edges, not in cells: they are turned into edges, the edges transformed,
+ /// and the wall pieces chosen again, so corners and posts come out right.
+ ///
+ internal static class GroupTransform
+ {
+ private static readonly Dictionary _directions = new Dictionary
+ {
+ ["North"] = (0, -1), ["East"] = (1, 0), ["South"] = (0, 1), ["West"] = (-1, 0)
+ };
+
+ // Door pieces: the end of the wall the hinge is at, and the swing.
+ private static readonly Dictionary _doors = new Dictionary
+ {
+ ["Piece3"] = ((-1, 0), true), ["Piece4"] = ((1, 0), false), ["Piece1"] = ((-1, 0), false), ["Piece2"] = ((1, 0), true),
+ ["Piece5"] = ((0, 1), true), ["Piece6"] = ((0, -1), false), ["Piece7"] = ((0, 1), false), ["Piece8"] = ((0, -1), true)
+ };
+
+ private static readonly string[] _windowPairs = { "WindowS", "WindowE", "AltWindowS", "AltWindowE", "SecondAltWindowS", "SecondAltWindowE" };
+
+ private static (int A, int B, int C, int D) Matrix(GroupTransformKind kind) => kind switch
+ {
+ // (x, y) -> (A*x + B*y, C*x + D*y)
+ GroupTransformKind.RotateLeft => (0, 1, -1, 0),
+ GroupTransformKind.RotateRight => (0, -1, 1, 0),
+ GroupTransformKind.MirrorX => (-1, 0, 0, 1),
+ _ => (1, 0, 0, -1)
+ };
+
+ public static bool SwapsAxes(GroupTransformKind kind) => kind is GroupTransformKind.RotateLeft or GroupTransformKind.RotateRight;
+
+ ///
+ /// The tiles to add for the transformed group, placed so the group's box keeps its top-left
+ /// cell. Every tile of is replaced.
+ ///
+ public static List<(ushort Id, int X, int Y, int Z, bool Invisible, int Extra)> Apply(
+ IReadOnlyCollection group, HouseStyles styles, RotationTable table, GroupTransformKind kind)
+ {
+ var m = Matrix(kind);
+ bool mirror = (m.A * m.D) - (m.B * m.C) < 0;
+
+ (double X, double Y) Map(double x, double y) => ((m.A * x) + (m.B * y), (m.C * x) + (m.D * y));
+ (int X, int Y) MapCell(int x, int y)
+ {
+ var c = Map(x + 0.5, y + 0.5);
+ return ((int)Math.Floor(c.X), (int)Math.Floor(c.Y));
+ }
+
+ // An edge of cell (x, y): its midpoint and direction move; the result is a +Y edge (S)
+ // or a +X edge (E) of some cell.
+ (bool South, int X, int Y) MapEdge(bool south, int x, int y)
+ {
+ var mid = south ? Map(x + 0.5, y + 1) : Map(x + 1, y + 0.5);
+ var dir = south ? Map(1, 0) : Map(0, 1);
+ return Math.Abs(dir.X) > 0.5
+ ? (true, (int)Math.Floor(mid.X), (int)Math.Round(mid.Y) - 1)
+ : (false, (int)Math.Round(mid.X) - 1, (int)Math.Floor(mid.Y));
+ }
+
+ string MapDirection(string label)
+ {
+ var d = _directions[label];
+ var t = Map(d.X, d.Y);
+ return _directions.First(kv => kv.Value == ((int)Math.Round(t.X), (int)Math.Round(t.Y))).Key;
+ }
+
+ // Keep the group's top-left: shift by the change of the cell box's corner.
+ int minX = group.Min(t => t.X), minY = group.Min(t => t.Y);
+ var mapped = group.Select(t => MapCell(t.X, t.Y)).ToList();
+ int shiftX = minX - mapped.Min(c => c.X);
+ int shiftY = minY - mapped.Min(c => c.Y);
+
+ var result = new List<(ushort, int, int, int, bool, int)>();
+ var walls = new Dictionary<(HouseStyle Style, int Z), (HashSet<(int, int)> S, HashSet<(int, int)> E, Dictionary<(int, int), string> Windows)>();
+ var doorCells = new HashSet<(int, int, int)>();
+ var doorEdges = new List<(int Z, bool South, int X, int Y)>();
+
+ foreach (MultiTile tile in group)
+ {
+ styles.TryGetRole(tile.Id, out HouseStyle style, out string slot);
+
+ if (style?.Kind == HousePartKind.Wall && slot != "Post")
+ {
+ if (!walls.TryGetValue((style, tile.Z), out var layer))
+ {
+ walls[(style, tile.Z)] = layer = (new HashSet<(int, int)>(), new HashSet<(int, int)>(), new Dictionary<(int, int), string>());
+ }
+
+ bool isSouth = slot == "Corner" || slot.StartsWith("South", StringComparison.Ordinal) || slot.EndsWith('S');
+ bool isEast = slot == "Corner" || slot.StartsWith("East", StringComparison.Ordinal) || slot.EndsWith('E');
+ foreach (bool south in new[] { true, false })
+ {
+ if (south ? !isSouth : !isEast)
+ {
+ continue;
+ }
+
+ var e = MapEdge(south, tile.X, tile.Y);
+ var cell = (e.X + shiftX, e.Y + shiftY);
+ (e.South ? layer.S : layer.E).Add(cell);
+
+ int window = Array.IndexOf(_windowPairs, slot);
+ if (window >= 0)
+ {
+ // A window keeps its kind on the wall's new axis.
+ layer.Windows[cell] = _windowPairs[(window & ~1) + (e.South ? 0 : 1)];
+ }
+ }
+
+ continue;
+ }
+
+ if (style?.Kind == HousePartKind.Wall)
+ {
+ // Posts are rebuilt from the edges.
+ continue;
+ }
+
+ var (nx, ny) = MapCell(tile.X, tile.Y);
+ ushort id = tile.Id;
+
+ if (style?.Kind == HousePartKind.Door && _doors.TryGetValue(slot, out var door))
+ {
+ // A door is an edge too: it moves like one and swaps to the piece hinged the new way.
+ var e = MapEdge(WallPlanner.DoorAlongX(slot), tile.X, tile.Y);
+ (nx, ny) = (e.X, e.Y);
+ var h = Map(door.Hinge.X, door.Hinge.Y);
+ var hinge = ((int)Math.Round(h.X), (int)Math.Round(h.Y));
+ bool clockwise = door.Clockwise ^ mirror;
+ string newSlot = _doors.First(kv => kv.Value == (hinge, clockwise)).Key;
+ id = style.Get(newSlot) is var doorId and not 0 ? doorId : id;
+ doorCells.Add((nx + shiftX, ny + shiftY, tile.Z));
+ doorEdges.Add((tile.Z, e.South, nx + shiftX, ny + shiftY));
+ }
+ else if (style != null && slot != null)
+ {
+ string newSlot = TurnSlot(slot, MapDirection, SwapsAxes(kind));
+ if (newSlot != slot && style.Get(newSlot) is var turned and not 0)
+ {
+ id = turned;
+ }
+ }
+ else if (kind == GroupTransformKind.RotateLeft)
+ {
+ // Not in the client tables: the facing table, which only knows quarter turns.
+ id = table.TurnLeft(id);
+ }
+ else if (kind == GroupTransformKind.RotateRight)
+ {
+ id = table.TurnRight(id);
+ }
+
+ result.Add((id, nx + shiftX, ny + shiftY, tile.Z, tile.Invisible, tile.Extra));
+ }
+
+ foreach (var ((style, z), layer) in walls)
+ {
+ // Doors count as wall edges, so the wall joins them; their cells keep the door.
+ foreach (var door in doorEdges.Where(d => d.Z == z))
+ {
+ (door.South ? layer.S : layer.E).Add((door.X, door.Y));
+ }
+
+ int x0 = layer.S.Concat(layer.E).Min(c => c.Item1) - 1;
+ int y0 = layer.S.Concat(layer.E).Min(c => c.Item2) - 1;
+ int x1 = layer.S.Concat(layer.E).Max(c => c.Item1);
+ int y1 = layer.S.Concat(layer.E).Max(c => c.Item2);
+ for (int x = x0; x <= x1; ++x)
+ {
+ for (int y = y0; y <= y1; ++y)
+ {
+ if (doorCells.Contains((x, y, z)))
+ {
+ continue;
+ }
+
+ string column = WallPlanner.PieceFor(layer.S, layer.E, x, y);
+ if (column is "South1" or "South2" or "South3" or "East1" or "East2" or "East3" &&
+ layer.Windows.TryGetValue((x, y), out string window))
+ {
+ column = window;
+ }
+
+ ushort id = column != null ? style.Get(column) : (ushort)0;
+ if (id != 0)
+ {
+ result.Add((id, x, y, z, false, 0));
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ ///
+ /// The column a direction-named piece moves to: North/East/South/West and their dents and
+ /// T pieces turn; crosspieces swap axes when the group turns a quarter.
+ ///
+ private static string TurnSlot(string slot, Func mapDirection, bool swapsAxes)
+ {
+ foreach (string direction in _directions.Keys)
+ {
+ if (slot == direction)
+ {
+ return mapDirection(direction);
+ }
+ }
+
+ foreach (string suffix in new[] { "Dent", "TPiece" })
+ {
+ // NDent, ETPiece ...: the first letter is the direction.
+ if (slot.Length == 1 + suffix.Length && slot.EndsWith(suffix, StringComparison.Ordinal))
+ {
+ string direction = _directions.Keys.First(d => d[0] == slot[0]);
+ return mapDirection(direction)[0] + suffix;
+ }
+ }
+
+ if (swapsAxes)
+ {
+ if (slot == "NSCrosspiece")
+ {
+ return "EWCrosspiece";
+ }
+
+ if (slot == "EWCrosspiece")
+ {
+ return "NSCrosspiece";
+ }
+ }
+
+ return slot;
+ }
+ }
+}
diff --git a/UoFiddler.Plugin.MultiEditor/Classes/HouseStyles.cs b/UoFiddler.Plugin.MultiEditor/Classes/HouseStyles.cs
new file mode 100644
index 00000000..06ba1c33
--- /dev/null
+++ b/UoFiddler.Plugin.MultiEditor/Classes/HouseStyles.cs
@@ -0,0 +1,246 @@
+/***************************************************************************
+ *
+ * $Author: Turley
+ *
+ * "THE BEER-WARE LICENSE"
+ * As long as you retain this notice you can do whatever you want with
+ * this stuff. If we meet some day, and you think this stuff is worth it,
+ * you can buy me a beer in return.
+ *
+ ***************************************************************************/
+
+using System.Collections.Generic;
+using UoFiddler.Controls.Classes.TilesInfo;
+
+namespace UoFiddler.Plugin.MultiEditor.Classes
+{
+ internal enum HousePartKind
+ {
+ Wall,
+ Floor,
+ Door,
+ Stair,
+ Roof,
+ Misc,
+ Teleporter
+ }
+
+ ///
+ /// One row of a client house design table (walls.txt, floors.txt ...): a named set of pieces,
+ /// each under the column label the client uses (South1, Corner, F3, MultiNorth ...).
+ ///
+ internal sealed class HouseStyle
+ {
+ private readonly Dictionary _slots = new Dictionary();
+
+ public HouseStyle(HousePartKind kind, string group, string name)
+ {
+ Kind = kind;
+ Group = group;
+ Name = name;
+ }
+
+ public HousePartKind Kind { get; }
+
+ /// The category name (the first style's comment), grouping a material's styles.
+ public string Group { get; }
+
+ public string Name { get; }
+
+ public IReadOnlyDictionary Slots => _slots;
+
+ /// A piece to show for the style in lists.
+ public ushort IconId { get; private set; }
+
+ /// The piece under a column label, or 0 when the style has none.
+ public ushort Get(string label) => _slots.TryGetValue(label, out ushort id) ? id : (ushort)0;
+
+ internal void Add(string label, ushort id)
+ {
+ _slots[label] = id;
+ if (IconId == 0)
+ {
+ IconId = id;
+ }
+ }
+
+ public override string ToString() => Name;
+ }
+
+ ///
+ /// The client's house design tables, read once per client, with a lookup from tile id to the
+ /// style and column it belongs to.
+ ///
+ internal sealed class HouseStyles
+ {
+ private static readonly Dictionary _kinds = new Dictionary
+ {
+ ["Walls"] = HousePartKind.Wall,
+ ["Floors"] = HousePartKind.Floor,
+ ["Doors"] = HousePartKind.Door,
+ ["Stairs"] = HousePartKind.Stair,
+ ["Roof"] = HousePartKind.Roof,
+ ["Misc"] = HousePartKind.Misc,
+ ["Teleporters"] = HousePartKind.Teleporter
+ };
+
+ private readonly Dictionary _roles = new Dictionary();
+
+ private HouseStyles()
+ {
+ }
+
+ public List Styles { get; } = new List();
+
+ public List Errors { get; } = new List();
+
+ ///
+ /// Reads the tables. With a floors.txt row, which is a
+ /// palette of up to 16 tiles often in several colours, becomes one style per colour, so a
+ /// floor laid with a style does not mix them.
+ ///
+ public static HouseStyles Load(bool splitFloorsByColour = false)
+ {
+ var result = new HouseStyles();
+ List files = TileGroupRegistry.LoadAll(out List errors);
+ foreach (TileGroupFile file in files)
+ {
+ if (!_kinds.TryGetValue(file.DisplayName, out HousePartKind kind))
+ {
+ continue;
+ }
+
+ foreach (TileCategory category in file.Categories)
+ {
+ foreach (TileStyle tileStyle in category.Styles)
+ {
+ var style = new HouseStyle(kind, category.Name, tileStyle.Name);
+ foreach (TileSlot slot in tileStyle.Slots)
+ {
+ // Stairs list stair multis; they are multi ids, not art.
+ bool multiColumn = slot.Label.StartsWith("Multi", System.StringComparison.Ordinal);
+ if (slot.IsEmpty || slot.TileId > ushort.MaxValue || (!multiColumn && !slot.IsValid))
+ {
+ continue;
+ }
+
+ style.Add(slot.Label, (ushort)slot.TileId);
+ }
+
+ if (style.Slots.Count == 0)
+ {
+ continue;
+ }
+
+ IEnumerable parts = splitFloorsByColour && kind == HousePartKind.Floor
+ ? SplitByColour(style)
+ : new[] { style };
+ foreach (HouseStyle part in parts)
+ {
+ result.Styles.Add(part);
+ foreach (KeyValuePair piece in part.Slots)
+ {
+ // Stair multi columns hold multi ids, not art.
+ if (!piece.Key.StartsWith("Multi", System.StringComparison.Ordinal))
+ {
+ result._roles.TryAdd(piece.Value, (part, piece.Key));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ result.Errors.AddRange(errors);
+ return result;
+ }
+
+ /// How far apart two radar colours may be (RGB distance) and still count as one floor colour.
+ private const int _sameColour = 20;
+
+ ///
+ /// Splits a floor row into styles of one colour each, by the tiles' radar colours. Pieces keep
+ /// their column labels; a tile listed twice counts once. Each part is named after its tiles'
+ /// tiledata name, numbered where a row has several of the same, and grouped under the row's name.
+ ///
+ private static List SplitByColour(HouseStyle style)
+ {
+ var clusters = new List<(System.Drawing.Color Colour, List> Pieces)>();
+ var seen = new HashSet();
+ foreach (KeyValuePair piece in style.Slots)
+ {
+ if (!seen.Add(piece.Value))
+ {
+ continue;
+ }
+
+ System.Drawing.Color colour = Ultima.Helpers.HueHelpers.HueToColor(Ultima.RadarCol.GetItemColor(piece.Value));
+ int index = clusters.FindIndex(c =>
+ {
+ int dr = c.Colour.R - colour.R, dg = c.Colour.G - colour.G, db = c.Colour.B - colour.B;
+ return (dr * dr) + (dg * dg) + (db * db) <= _sameColour * _sameColour;
+ });
+ if (index < 0)
+ {
+ clusters.Add((colour, new List> { piece }));
+ }
+ else
+ {
+ clusters[index].Pieces.Add(piece);
+ }
+ }
+
+ if (clusters.Count <= 1)
+ {
+ return new List { style };
+ }
+
+ var names = new List();
+ foreach (var (_, pieces) in clusters)
+ {
+ string name = Ultima.TileData.ItemTable[pieces[0].Value].Name?.Trim();
+ if (string.IsNullOrEmpty(name) || name.StartsWith("Missing", System.StringComparison.OrdinalIgnoreCase))
+ {
+ name = style.Name;
+ }
+
+ names.Add(char.ToUpperInvariant(name[0]) + name.Substring(1));
+ }
+
+ var result = new List();
+ for (int i = 0; i < clusters.Count; i++)
+ {
+ string name = names[i];
+ if (names.FindAll(n => n == name).Count > 1)
+ {
+ name += " " + (names.GetRange(0, i + 1).FindAll(n => n == names[i]).Count);
+ }
+
+ var part = new HouseStyle(style.Kind, style.Name, name);
+ foreach (KeyValuePair piece in clusters[i].Pieces)
+ {
+ part.Add(piece.Key, piece.Value);
+ }
+
+ result.Add(part);
+ }
+
+ return result;
+ }
+
+ /// The style and column a tile id is listed under, when any.
+ public bool TryGetRole(ushort id, out HouseStyle style, out string slot)
+ {
+ if (_roles.TryGetValue(id, out var role))
+ {
+ style = role.Style;
+ slot = role.Slot;
+ return true;
+ }
+
+ style = null;
+ slot = null;
+ return false;
+ }
+ }
+}
diff --git a/UoFiddler.Plugin.MultiEditor/Classes/IMultiViewSettings.cs b/UoFiddler.Plugin.MultiEditor/Classes/IMultiViewSettings.cs
new file mode 100644
index 00000000..7bfd77f2
--- /dev/null
+++ b/UoFiddler.Plugin.MultiEditor/Classes/IMultiViewSettings.cs
@@ -0,0 +1,30 @@
+/***************************************************************************
+ *
+ * $Author: MuadDib & Turley
+ *
+ * "THE BEER-WARE LICENSE"
+ * As long as you retain this notice you can do whatever you want with
+ * this stuff. If we meet some day, and you think this stuff is worth it,
+ * you can buy me a beer in return.
+ *
+ ***************************************************************************/
+
+
+namespace UoFiddler.Plugin.MultiEditor.Classes
+{
+ ///
+ /// The view options the edited multi depends on.
+ ///
+ internal interface IMultiViewSettings
+ {
+ /// Z of the virtual floor.
+ int DrawFloorZ { get; }
+
+ /// Tiles flagged as walls are not shown, and so not removed by area edits.
+ bool HideWalls { get; }
+
+ bool ShowWalkables { get; }
+
+ bool ShowDoubleSurface { get; }
+ }
+}
diff --git a/UoFiddler.Plugin.MultiEditor/Classes/MapExtract.cs b/UoFiddler.Plugin.MultiEditor/Classes/MapExtract.cs
new file mode 100644
index 00000000..2b8a4257
--- /dev/null
+++ b/UoFiddler.Plugin.MultiEditor/Classes/MapExtract.cs
@@ -0,0 +1,92 @@
+/***************************************************************************
+ *
+ * $Author: Turley
+ *
+ * "THE BEER-WARE LICENSE"
+ * As long as you retain this notice you can do whatever you want with
+ * this stuff. If we meet some day, and you think this stuff is worth it,
+ * you can buy me a beer in return.
+ *
+ ***************************************************************************/
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using Ultima;
+using UoFiddler.Plugin.MultiEditor.Tools;
+using UoFiddler.Plugin.MultiEditor.UI;
+
+namespace UoFiddler.Plugin.MultiEditor.Classes
+{
+ /// An area of a facet to copy statics from.
+ internal sealed record MapArea(Map Map, int X, int Y, int Width, int Height, int MinZ, int MaxZ, bool NewDesign);
+
+ ///
+ /// Copies the statics of a map area into multi tiles, so a building on the map can be edited
+ /// as a design. Land tiles are not copied.
+ ///
+ internal static class MapExtract
+ {
+ public static readonly (string Name, Func