Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions UoFiddler.Controls/Classes/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ public static class Options
/// </summary>
public static bool DarkMode { get; set; }

/// <summary>
/// When true, exported image filenames embed the ID in hexadecimal form (e.g. "Item 0x00FF.png").
/// When false, decimal form is used. Runtime flag set from AppSettings at startup.
/// </summary>
public static bool ExportFilenameInHex { get; set; } = true;

/// <summary>
/// When <see cref="ExportFilenameInHex"/> is false, controls whether decimal IDs are zero-padded
/// to 5 digits ("00255") or written without padding ("255"). Runtime flag set from AppSettings.
/// </summary>
public static bool ExportFilenameDecimalPadded { get; set; } = true;

/// <summary>
/// Defines the cmd to Send Client to Loc
/// </summary>
Expand Down
17 changes: 17 additions & 0 deletions UoFiddler.Controls/Classes/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ public static bool ConvertStringToInt(string text, out int result)
return int.TryParse(text, NumberStyles.Integer, null, out result);
}

/// <summary>
/// Formats an ID for inclusion in an exported filename, honoring the user's
/// hex/decimal preference in <see cref="Options.ExportFilenameInHex"/> and
/// <see cref="Options.ExportFilenameDecimalPadded"/>.
/// </summary>
public static string FormatExportId(int id)
{
if (Options.ExportFilenameInHex)
{
return $"0x{id:X4}";
}

return Options.ExportFilenameDecimalPadded
? id.ToString("D5")
: id.ToString();
}

public static unsafe Bitmap ConvertBmp(Bitmap bmp)
{
BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format16bppArgb1555);
Expand Down
4 changes: 2 additions & 2 deletions UoFiddler.Controls/Forms/AnimationEditForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ private void OnClickExportToVD(object sender, EventArgs e)
}

string path = Options.OutputPath;
string fileName = Path.Combine(path, $"anim{_fileType}_0x{_currentBody:X}.vd");
string fileName = Path.Combine(path, $"anim{_fileType}_{Utils.FormatExportId(_currentBody)}.vd");
AnimationEdit.ExportToVD(_fileType, _currentBody, fileName);

FileSavedDialog.Show(FindForm(), Options.OutputPath, "Animation saved successfully.");
Expand Down Expand Up @@ -2240,7 +2240,7 @@ private void OnClickExportAllToVD(object sender, EventArgs e)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"anim{_fileType}_0x{index:X}.vd");
string fileName = Path.Combine(dialog.SelectedPath, $"anim{_fileType}_{Utils.FormatExportId(index)}.vd");
AnimationEdit.ExportToVD(_fileType, index, fileName);
}

Expand Down
2 changes: 1 addition & 1 deletion UoFiddler.Controls/Forms/ItemDetailForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private void SaveImage(ImageFormat imageFormat)
}

string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string fileName = Path.Combine(Options.OutputPath, $"Item 0x{_index:X}.{fileExtension}");
string fileName = Path.Combine(Options.OutputPath, $"Item {Utils.FormatExportId(_index)}.{fileExtension}");

using (Bitmap bit = new Bitmap(Art.GetStatic(_index).Width, Art.GetStatic(_index).Height))
{
Expand Down
2 changes: 1 addition & 1 deletion UoFiddler.Controls/UserControls/AnimDataControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ private void OnClick_ExportAsGif(object sender, EventArgs e)
{
if (_selAnimdataEntry != null)
{
var outputFile = Path.Combine(Options.OutputPath, $"AnimData 0x{_currentSelect:X}.gif");
var outputFile = Path.Combine(Options.OutputPath, $"AnimData {Utils.FormatExportId(_currentSelect)}.gif");
MainPictureBox.Frames.ToGif(outputFile, delay: 150, showFrameBounds: MainPictureBox.ShowFrameBounds);
MessageBox.Show($"Saved to {outputFile}");
}
Expand Down
6 changes: 3 additions & 3 deletions UoFiddler.Controls/UserControls/AnimationListControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ private void ExtractImage(ImageFormat imageFormat)
}

string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string fileName = Path.Combine(Options.OutputPath, $"{what} {_currentSelect}.{fileExtension}");
string fileName = Path.Combine(Options.OutputPath, $"{what} {Utils.FormatExportId(_currentSelect)}.{fileExtension}");

Bitmap sourceBitmap = MainPictureBox.CurrentFrame?.Bitmap;

Expand Down Expand Up @@ -926,7 +926,7 @@ private void ExportAnimationFrames(ImageFormat imageFormat)
}

string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string fileName = Path.Combine(Options.OutputPath, $"{what} {_currentSelect}");
string fileName = Path.Combine(Options.OutputPath, $"{what} {Utils.FormatExportId(_currentSelect)}");

for (int i = 0; i < MainPictureBox.Frames?.Count; ++i)
{
Expand Down Expand Up @@ -981,7 +981,7 @@ private void ExportSingleFrame(ImageFormat imageFormat)
}

string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string fileName = Path.Combine(Options.OutputPath, $"{what} {_currentSelect}");
string fileName = Path.Combine(Options.OutputPath, $"{what} {Utils.FormatExportId(_currentSelect)}");

Bitmap bit = MainPictureBox.Frames[(int)listView1.SelectedItems[0].Tag].Bitmap;
using (Bitmap newBitmap = new Bitmap(bit.Width, bit.Height))
Expand Down
4 changes: 2 additions & 2 deletions UoFiddler.Controls/UserControls/FontsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ private void OnClickExport(object sender, EventArgs e)
string path = Options.OutputPath;
string fileType = (int)treeView.SelectedNode.Parent.Tag == 1 ? "Unicode" : "ASCII";
string fileName = (int)treeView.SelectedNode.Parent.Tag == 1
? Path.Combine(path, $"{fileType} {(int)treeView.SelectedNode.Tag} 0x{FontsTileView.SelectedIndices[0]:X}.tiff")
: Path.Combine(path, $"{fileType} {(int)treeView.SelectedNode.Tag} 0x{_fonts[FontsTileView.SelectedIndices[0]] + AsciiFontOffset:X}.tiff");
? Path.Combine(path, $"{fileType} {(int)treeView.SelectedNode.Tag} {Utils.FormatExportId(FontsTileView.SelectedIndices[0])}.tiff")
: Path.Combine(path, $"{fileType} {(int)treeView.SelectedNode.Tag} {Utils.FormatExportId(_fonts[FontsTileView.SelectedIndices[0]] + AsciiFontOffset)}.tiff");

if ((int)treeView.SelectedNode.Parent.Tag == 1)
{
Expand Down
4 changes: 2 additions & 2 deletions UoFiddler.Controls/UserControls/GumpControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ private void Extract_Image_ClickPng(object sender, EventArgs e)
private static void ExportGumpImage(int index, ImageFormat imageFormat)
{
string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string fileName = Path.Combine(Options.OutputPath, $"Gump 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(Options.OutputPath, $"Gump {Utils.FormatExportId(index)}.{fileExtension}");

using (Bitmap bit = new Bitmap(Gumps.GetGump(index)))
{
Expand Down Expand Up @@ -792,7 +792,7 @@ private void ExportAllGumps(ImageFormat imageFormat)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"Gump 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(dialog.SelectedPath, $"Gump {Utils.FormatExportId(index)}.{fileExtension}");
var gump = Gumps.GetGump(index);
if (gump is null)
{
Expand Down
4 changes: 2 additions & 2 deletions UoFiddler.Controls/UserControls/ItemsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ private static void ExportItemImage(int index, ImageFormat imageFormat)
}

string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string fileName = Path.Combine(Options.OutputPath, $"Item 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(Options.OutputPath, $"Item {Utils.FormatExportId(index)}.{fileExtension}");

using (Bitmap bit = new Bitmap(Art.GetStatic(index)))
{
Expand Down Expand Up @@ -821,7 +821,7 @@ private void ExportAllItemImages(ImageFormat imageFormat)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"Item 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(dialog.SelectedPath, $"Item {Utils.FormatExportId(index)}.{fileExtension}");
var artBitmap = Art.GetStatic(index);
if (artBitmap is null)
{
Expand Down
4 changes: 2 additions & 2 deletions UoFiddler.Controls/UserControls/LandTilesControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ private static void ExportLandTileImage(int index, ImageFormat imageFormat)
}

string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string fileName = Path.Combine(Options.OutputPath, $"Landtile 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(Options.OutputPath, $"Landtile {Utils.FormatExportId(index)}.{fileExtension}");

using (Bitmap bit = new Bitmap(Art.GetLand(index)))
{
Expand Down Expand Up @@ -652,7 +652,7 @@ private void ExportAllLandTiles(ImageFormat imageFormat)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"Landtile 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(dialog.SelectedPath, $"Landtile {Utils.FormatExportId(index)}.{fileExtension}");
var landTile = Art.GetLand(index);
if (landTile is null)
{
Expand Down
6 changes: 3 additions & 3 deletions UoFiddler.Controls/UserControls/LightControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void OnClickExportBmp(object sender, EventArgs e)

string path = Options.OutputPath;
int i = (int)treeViewLights.SelectedNode.Tag;
string fileName = Path.Combine(path, $"Light {i}.bmp");
string fileName = Path.Combine(path, $"Light {Utils.FormatExportId(i)}.bmp");
Light.GetLight(i).Save(fileName, ImageFormat.Bmp);
FileSavedDialog.Show(FindForm(), fileName, "Light saved successfully.");
}
Expand All @@ -363,7 +363,7 @@ private void OnClickExportTiff(object sender, EventArgs e)

string path = Options.OutputPath;
int i = (int)treeViewLights.SelectedNode.Tag;
string fileName = Path.Combine(path, $"Light {i}.tiff");
string fileName = Path.Combine(path, $"Light {Utils.FormatExportId(i)}.tiff");
Ultima.Light.GetLight(i).Save(fileName, ImageFormat.Tiff);
FileSavedDialog.Show(FindForm(), fileName, "Light saved successfully.");
}
Expand All @@ -377,7 +377,7 @@ private void OnClickExportJpg(object sender, EventArgs e)

string path = Options.OutputPath;
int i = (int)treeViewLights.SelectedNode.Tag;
string fileName = Path.Combine(path, $"Light {i}.jpg");
string fileName = Path.Combine(path, $"Light {Utils.FormatExportId(i)}.jpg");
Ultima.Light.GetLight(i).Save(fileName, ImageFormat.Jpeg);
FileSavedDialog.Show(FindForm(), fileName, "Light saved successfully.");
}
Expand Down
36 changes: 18 additions & 18 deletions UoFiddler.Controls/UserControls/MultisControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private void ExtractMultiImage(ImageFormat imageFormat, Color backgroundColor)

string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string floorSuffix = HeightChangeMulti.Value > 0 ? $"_Z{HeightChangeMulti.Value:000}" : string.Empty;
string fileName = Path.Combine(Options.OutputPath, $"Multi 0x{int.Parse(TreeViewMulti.SelectedNode.Name):X4}{floorSuffix}.{fileExtension}");
string fileName = Path.Combine(Options.OutputPath, $"Multi {Utils.FormatExportId(int.Parse(TreeViewMulti.SelectedNode.Name))}{floorSuffix}.{fileExtension}");
SaveImage(_mulBitmap, fileName, imageFormat, backgroundColor);
FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
}
Expand Down Expand Up @@ -539,7 +539,7 @@ private void OnExportTextFile(object sender, EventArgs e)
int id = int.Parse(TreeViewMulti.SelectedNode.Name);

string path = Options.OutputPath;
string fileName = Path.Combine(path, $"Multi 0x{id:X}.txt");
string fileName = Path.Combine(path, $"Multi {Utils.FormatExportId(id)}.txt");
multi.ExportToTextFile(fileName);

FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
Expand All @@ -561,7 +561,7 @@ private void OnExportWscFile(object sender, EventArgs e)
int id = int.Parse(TreeViewMulti.SelectedNode.Name);

string path = Options.OutputPath;
string fileName = Path.Combine(path, $"Multi 0x{id:X}.wsc");
string fileName = Path.Combine(path, $"Multi {Utils.FormatExportId(id)}.wsc");
multi.ExportToWscFile(fileName);

FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
Expand All @@ -583,7 +583,7 @@ private void OnExportUOAFile(object sender, EventArgs e)
int id = int.Parse(TreeViewMulti.SelectedNode.Name);

string path = Options.OutputPath;
string fileName = Path.Combine(path, $"Multi 0x{id:X}.uoa");
string fileName = Path.Combine(path, $"Multi {Utils.FormatExportId(id)}.uoa");
multi.ExportToUOAFile(fileName);

FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
Expand Down Expand Up @@ -687,7 +687,7 @@ private void ExportAllMultis(ImageFormat imageFormat, Color backgroundColor)
}

const int maximumMultiHeight = 127;
string fileName = Path.Combine(dialog.SelectedPath, $"Multi 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(dialog.SelectedPath, $"Multi {Utils.FormatExportId(index)}.{fileExtension}");

using (Bitmap multiBitmap = ((MultiComponentList)_refMarker.TreeViewMulti.Nodes[i].Tag)?.GetImage(maximumMultiHeight))
{
Expand Down Expand Up @@ -727,7 +727,7 @@ private void OnClick_SaveAllText(object sender, EventArgs e)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"Multi 0x{index:X4}.txt");
string fileName = Path.Combine(dialog.SelectedPath, $"Multi {Utils.FormatExportId(index)}.txt");
multi.ExportToTextFile(fileName);
}

Expand Down Expand Up @@ -760,7 +760,7 @@ private void OnClick_SaveAllUOA(object sender, EventArgs e)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"Multi 0x{index:X4}.uoa");
string fileName = Path.Combine(dialog.SelectedPath, $"Multi {Utils.FormatExportId(index)}.uoa");
multi.ExportToUOAFile(fileName);
}

Expand Down Expand Up @@ -793,7 +793,7 @@ private void OnClick_SaveAllWSC(object sender, EventArgs e)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"Multi 0x{index:X4}.wsc");
string fileName = Path.Combine(dialog.SelectedPath, $"Multi {Utils.FormatExportId(index)}.wsc");
multi.ExportToWscFile(fileName);
}

Expand Down Expand Up @@ -859,7 +859,7 @@ private void OnClick_SaveAllUox3(object sender, EventArgs e)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"Multi 0x{index:X4}.uox3");
string fileName = Path.Combine(dialog.SelectedPath, $"Multi {Utils.FormatExportId(index)}.uox3");
multi.ExportToUox3File(fileName);
}

Expand Down Expand Up @@ -904,7 +904,7 @@ private void OnExportUox3File(object sender, EventArgs e)
int id = int.Parse(TreeViewMulti.SelectedNode.Name);

string path = Options.OutputPath;
string fileName = Path.Combine(path, $"Multi 0x{id:X4}.uox3");
string fileName = Path.Combine(path, $"Multi {Utils.FormatExportId(id)}.uox3");
multi.ExportToUox3File(fileName);
FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
}
Expand Down Expand Up @@ -1288,7 +1288,7 @@ private void ExtractUopMultiImage(ImageFormat imageFormat, Color backgroundColor
string fileExtension = Utils.GetFileExtensionFor(imageFormat);
string floorSuffix = HeightChangeUop.Value > 0 ? $"_Z{HeightChangeUop.Value:000}" : string.Empty;
int id = int.Parse(treeViewUop.SelectedNode.Name);
string fileName = Path.Combine(Options.OutputPath, $"UopMulti 0x{id:X4}{floorSuffix}.{fileExtension}");
string fileName = Path.Combine(Options.OutputPath, $"UopMulti {Utils.FormatExportId(id)}{floorSuffix}.{fileExtension}");
SaveImage(_uopBitmap, fileName, imageFormat, backgroundColor);
FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
}
Expand All @@ -1301,7 +1301,7 @@ private void OnUopExportTextFile(object sender, EventArgs e)
}

int id = int.Parse(treeViewUop.SelectedNode.Name);
string fileName = Path.Combine(Options.OutputPath, $"UopMulti 0x{id:X}.txt");
string fileName = Path.Combine(Options.OutputPath, $"UopMulti {Utils.FormatExportId(id)}.txt");
multi.ExportToTextFile(fileName);
FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
}
Expand All @@ -1314,7 +1314,7 @@ private void OnUopExportUOAFile(object sender, EventArgs e)
}

int id = int.Parse(treeViewUop.SelectedNode.Name);
string fileName = Path.Combine(Options.OutputPath, $"UopMulti 0x{id:X}.uoa");
string fileName = Path.Combine(Options.OutputPath, $"UopMulti {Utils.FormatExportId(id)}.uoa");
multi.ExportToUOAFile(fileName);
FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
}
Expand All @@ -1327,7 +1327,7 @@ private void OnUopExportWscFile(object sender, EventArgs e)
}

int id = int.Parse(treeViewUop.SelectedNode.Name);
string fileName = Path.Combine(Options.OutputPath, $"UopMulti 0x{id:X}.wsc");
string fileName = Path.Combine(Options.OutputPath, $"UopMulti {Utils.FormatExportId(id)}.wsc");
multi.ExportToWscFile(fileName);
FileSavedDialog.Show(FindForm(), fileName, "Multi saved successfully.");
}
Expand Down Expand Up @@ -1379,7 +1379,7 @@ private void ExportAllUopMultis(ImageFormat imageFormat, Color backgroundColor)
continue;
}

string fileName = Path.Combine(dialog.SelectedPath, $"UopMulti 0x{index:X4}.{fileExtension}");
string fileName = Path.Combine(dialog.SelectedPath, $"UopMulti {Utils.FormatExportId(index)}.{fileExtension}");
using Bitmap bitmap = multi.GetImage(maxHeight);
if (bitmap != null)
{
Expand Down Expand Up @@ -1410,7 +1410,7 @@ private void OnUopClick_SaveAllText(object sender, EventArgs e)
continue;
}

multi.ExportToTextFile(Path.Combine(dialog.SelectedPath, $"UopMulti 0x{index:X4}.txt"));
multi.ExportToTextFile(Path.Combine(dialog.SelectedPath, $"UopMulti {Utils.FormatExportId(index)}.txt"));
}

FileSavedDialog.Show(FindForm(), dialog.SelectedPath, "All UOP Multis saved successfully.");
Expand All @@ -1436,7 +1436,7 @@ private void OnUopClick_SaveAllUOA(object sender, EventArgs e)
continue;
}

multi.ExportToUOAFile(Path.Combine(dialog.SelectedPath, $"UopMulti 0x{index:X4}.uoa"));
multi.ExportToUOAFile(Path.Combine(dialog.SelectedPath, $"UopMulti {Utils.FormatExportId(index)}.uoa"));
}

FileSavedDialog.Show(FindForm(), dialog.SelectedPath, "All UOP Multis saved successfully.");
Expand All @@ -1462,7 +1462,7 @@ private void OnUopClick_SaveAllWSC(object sender, EventArgs e)
continue;
}

multi.ExportToWscFile(Path.Combine(dialog.SelectedPath, $"UopMulti 0x{index:X4}.wsc"));
multi.ExportToWscFile(Path.Combine(dialog.SelectedPath, $"UopMulti {Utils.FormatExportId(index)}.wsc"));
}

FileSavedDialog.Show(FindForm(), dialog.SelectedPath, "All UOP Multis saved successfully.");
Expand Down
Loading
Loading