Skip to content

Commit

Permalink
Adjusted BmConverter to allow converting non-0 BM pages.
Browse files Browse the repository at this point in the history
Added support to Resource Dumper for dumping multipage BMs.
  • Loading branch information
The-MAZZTer committed Jul 29, 2022
1 parent b47aa2f commit d3969ce
Show file tree
Hide file tree
Showing 13 changed files with 1,031 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Assets/Dark Forces Showcase/PauseMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task BeginLoadingAsync() {
if (waitPal != null) {
DfBitmap waitBm = await ResourceCache.Instance.GetBitmapAsync("WAIT.BM");
if (waitBm != null) {
Texture2D wait = ResourceCache.Instance.ImportBitmap(waitBm, waitPal);
Texture2D wait = ResourceCache.Instance.ImportBitmap(waitBm.Pages[0], waitPal);
Rect rect = new Rect(0, 0, wait.width, wait.height);
this.loading.sprite = Sprite.Create(wait, rect, new Vector2(0.5f, 0.5f));
this.loading.color = Color.white;
Expand Down
27 changes: 23 additions & 4 deletions Assets/Dark Forces Showcase/Resource Dumper/ResourceDumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,15 @@ await this.SaveTextureAsPngAsync(

foreach (int i in lightLevels) {
parameters["lightlevel"] = i < 0 ? "" : i.ToString();
await this.SaveTextureAsPngAsync(
ResourceCache.Instance.ImportBitmap(bm, pal, i < 0 ? null : cmp, i, false, true),
this.FillOutputTemplate(this.Settings.ConvertedImageFilenameFormat, parameters, outputParameters)
);

foreach ((DfBitmap.Page page, int index) in bm.Pages.Select((x, i) => (x, i))) {
parameters["index"] = index.ToString();

await this.SaveTextureAsPngAsync(
ResourceCache.Instance.ImportBitmap(page, pal, i < 0 ? null : cmp, i, false, true),
this.FillOutputTemplate(this.Settings.ConvertedBmFilenameFormat, parameters, outputParameters)
);
}
}
}
}
Expand Down Expand Up @@ -940,6 +945,19 @@ await this.SaveTextureAsPngAsync(
}

public async void DumpAsync() {
if (string.IsNullOrWhiteSpace(this.Settings.BaseOutputFolder) || File.Exists(this.Settings.BaseOutputFolder)) {
await DfMessageBox.Instance.ShowAsync("Base Output Folder is set to an invalid location. Please specify a folder.");
return;
}
if (!Directory.Exists(this.Settings.BaseOutputFolder)) {
try {
Directory.CreateDirectory(this.Settings.BaseOutputFolder);
} catch (Exception) {
await DfMessageBox.Instance.ShowAsync("Could not create base output folder. Please verify the location you specified is accurate.");
return;
}
}

await PauseMenu.Instance.BeginLoadingAsync();

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

0 comments on commit d3969ce

Please sign in to comment.