Skip to content

Commit d3969ce

Browse files
committed
Adjusted BmConverter to allow converting non-0 BM pages.
Added support to Resource Dumper for dumping multipage BMs.
1 parent b47aa2f commit d3969ce

File tree

13 files changed

+1031
-60
lines changed

13 files changed

+1031
-60
lines changed

Assets/Dark Forces Showcase/PauseMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task BeginLoadingAsync() {
3636
if (waitPal != null) {
3737
DfBitmap waitBm = await ResourceCache.Instance.GetBitmapAsync("WAIT.BM");
3838
if (waitBm != null) {
39-
Texture2D wait = ResourceCache.Instance.ImportBitmap(waitBm, waitPal);
39+
Texture2D wait = ResourceCache.Instance.ImportBitmap(waitBm.Pages[0], waitPal);
4040
Rect rect = new Rect(0, 0, wait.width, wait.height);
4141
this.loading.sprite = Sprite.Create(wait, rect, new Vector2(0.5f, 0.5f));
4242
this.loading.color = Color.white;

Assets/Dark Forces Showcase/Resource Dumper/ResourceDumper.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,15 @@ await this.SaveTextureAsPngAsync(
489489

490490
foreach (int i in lightLevels) {
491491
parameters["lightlevel"] = i < 0 ? "" : i.ToString();
492-
await this.SaveTextureAsPngAsync(
493-
ResourceCache.Instance.ImportBitmap(bm, pal, i < 0 ? null : cmp, i, false, true),
494-
this.FillOutputTemplate(this.Settings.ConvertedImageFilenameFormat, parameters, outputParameters)
495-
);
492+
493+
foreach ((DfBitmap.Page page, int index) in bm.Pages.Select((x, i) => (x, i))) {
494+
parameters["index"] = index.ToString();
495+
496+
await this.SaveTextureAsPngAsync(
497+
ResourceCache.Instance.ImportBitmap(page, pal, i < 0 ? null : cmp, i, false, true),
498+
this.FillOutputTemplate(this.Settings.ConvertedBmFilenameFormat, parameters, outputParameters)
499+
);
500+
}
496501
}
497502
}
498503
}
@@ -940,6 +945,19 @@ await this.SaveTextureAsPngAsync(
940945
}
941946

942947
public async void DumpAsync() {
948+
if (string.IsNullOrWhiteSpace(this.Settings.BaseOutputFolder) || File.Exists(this.Settings.BaseOutputFolder)) {
949+
await DfMessageBox.Instance.ShowAsync("Base Output Folder is set to an invalid location. Please specify a folder.");
950+
return;
951+
}
952+
if (!Directory.Exists(this.Settings.BaseOutputFolder)) {
953+
try {
954+
Directory.CreateDirectory(this.Settings.BaseOutputFolder);
955+
} catch (Exception) {
956+
await DfMessageBox.Instance.ShowAsync("Could not create base output folder. Please verify the location you specified is accurate.");
957+
return;
958+
}
959+
}
960+
943961
await PauseMenu.Instance.BeginLoadingAsync();
944962

945963
DataContractJsonSerializer serializer = new(typeof(ResourceDumperSettings), new DataContractJsonSerializerSettings() {
@@ -1255,6 +1273,7 @@ public class ResourceDumperSettings {
12551273
public string BaseOutputFormat { get; set; } = @"{output}\{inputpath}\{file}";
12561274
public bool PreferThreeCharacterExtensions { get; set; } = false;
12571275
public string ConvertedImageFilenameFormat { get; set; } = @"{inputname}.{inputext}-{palette}{lightlevel}.{outputext}";
1276+
public string ConvertedBmFilenameFormat { get; set; } = @"{inputname}.{inputext}-{palette}{lightlevel}-{index}.{outputext}";
12581277
public string ConvertedAnimFilenameFormat { get; set; } = @"{inputname}.{inputext}-{palette}\{index}.{outputext}";
12591278
public string ConvertedWaxFilenameFormat { get; set; } = @"{inputname}.{inputext}-{palette}{lightlevel}\{wax}.{sequence}.{frame}.{outputext}";
12601279
public string ConvertedPalPlttFilenameFormat { get; set; } = @"{inputname}.{inputext}.{format}{lightlevel}.{outputext}";

0 commit comments

Comments
 (0)