Skip to content

Commit

Permalink
Merge pull request #61 from Pepper-Man/master
Browse files Browse the repository at this point in the history
Fix bitmap exports using opposite format, remove trailing "_00_00" from exported bitmap names for easier re-imports
  • Loading branch information
num0005 authored Jul 16, 2024
2 parents 5aea094 + ff6310d commit 6942bce
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@
</Grid>
</Grid>
</TabItem>
<TabItem Header="Extract Tags" Margin="-2,15,0,-17" IsEnabled="{Binding SelectedIndex, Converter={StaticResource ProfiletoIsEnabled}, ConverterParameter=h2|mcc + h3 + hr + h4, ElementName=toolkit_selection}" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=h2|mcc + h3 + hr + h4, ElementName=toolkit_selection}">
<TabItem Header="Extract Tags" Margin="-2,14,0,-17" IsEnabled="{Binding SelectedIndex, Converter={StaticResource ProfiletoIsEnabled}, ConverterParameter=h2|mcc + h3 + hr + h4, ElementName=toolkit_selection}" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=h2|mcc + h3 + hr + h4, ElementName=toolkit_selection}">
<Grid Background="{DynamicResource WindowSecondaryColor}">
<Grid.RowDefinitions>
<RowDefinition Height="5"/>
Expand Down
10 changes: 8 additions & 2 deletions Launcher/ToolkitInterface/H2AToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,15 @@ async Task ExtractJMS(string type)
string bitmapsDir = Path.Join(dataPath, Path.GetDirectoryName(path));
Directory.CreateDirectory(bitmapsDir);
if (bitmapsAsTGA)
await RunTool(ToolType.Tool, new() { "export-bitmap-dds", basename, bitmapsDir + "\\" }, OutputMode.closeShell);
else
{
await RunTool(ToolType.Tool, new() { "export-bitmap-tga", basename, bitmapsDir + "\\" }, OutputMode.closeShell);
FixBitmapName(Path.Join(dataPath, basename) + "_00_00.tga");
}
else
{
await RunTool(ToolType.Tool, new() { "export-bitmap-dds", basename, bitmapsDir + "\\" }, OutputMode.closeShell);
FixBitmapName(Path.Join(dataPath, basename) + "_00_00.dds");
}
break;
case ".multilingual_unicode_string_list":
await RunTool(ToolType.Tool, new() { "extract-unicode-strings", basename }, OutputMode.closeShell);
Expand Down
10 changes: 8 additions & 2 deletions Launcher/ToolkitInterface/H3Toolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,15 @@ public override async Task ExtractTags(string path, bool h2MoveDir, bool bitmaps
string bitmapsDir = Path.Join(dataPath, Path.GetDirectoryName(path));
Directory.CreateDirectory(bitmapsDir);
if (bitmapsAsTGA)
await RunTool(ToolType.Tool, new() { "export-bitmap-dds", basename, bitmapsDir + "\\" }, OutputMode.closeShell);
else
{
await RunTool(ToolType.Tool, new() { "export-bitmap-tga", basename, bitmapsDir + "\\" }, OutputMode.closeShell);
FixBitmapName(Path.Join(dataPath, basename) + "_00_00.tga");
}
else
{
await RunTool(ToolType.Tool, new() { "export-bitmap-dds", basename, bitmapsDir + "\\" }, OutputMode.closeShell);
FixBitmapName(Path.Join(dataPath, basename) + "_00_00.dds");
}
break;
case ".multilingual_unicode_string_list":
await RunTool(ToolType.Tool, new() { "extract-unicode-strings", basename }, OutputMode.closeShell);
Expand Down
27 changes: 27 additions & 0 deletions Launcher/ToolkitInterface/ToolkitBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -662,5 +662,32 @@ public static (string ScenarioPath, string ScenarioName, string BspName) SplitSt
}

public ProfileSettingsLauncher Profile { get; }

public static void FixBitmapName(string textureFile)
{
if (File.Exists(textureFile))
{
// Check if the file name ends with "_00_00" and has a .dds or .tga extension
if ((textureFile.EndsWith("_00_00.dds") || textureFile.EndsWith("_00_00.tga")))
{
// Remove the "_00_00" part from the file name
string newFileName = textureFile.Substring(0, textureFile.Length - 10) + Path.GetExtension(textureFile);

string newFilePath = Path.Combine(textureFile, newFileName);

File.Move(textureFile, newFilePath);

Trace.WriteLine($"Renamed: {textureFile} to {newFileName}");
}
else
{
Trace.WriteLine($"Texture file {textureFile} does not have trailing \"_00_00\"");
}
}
else
{
Trace.WriteLine($"Attempted to fix name of {textureFile}, but it does not exist");
}
}
}
}

0 comments on commit 6942bce

Please sign in to comment.