Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ManagedBlam Support: New bitmap automatic compression and override settings, migrated janky ShaderGen code to MB #56

Merged
merged 36 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
34024a5
ManagedBlam bitmap compression initial work - awful method
Pepper-Man Jun 17, 2024
66c38a5
Run ManagedBlam through Osoyoos proof of concept
Pepper-Man Jun 18, 2024
75d5e90
Working prototype for changing bitmap settings
Pepper-Man Jun 18, 2024
4cbfb05
Exclude non-diffuse bitmaps
Pepper-Man Jun 18, 2024
61ed887
Apply settings for diffuse, normal, bump and material textures
Pepper-Man Jun 18, 2024
ac4357a
Fix capitalisation
Pepper-Man Jun 18, 2024
b09c8d8
Dynamically locate exe from EK. Error messagebox when not found. Only…
Pepper-Man Jun 18, 2024
4539cf9
Fix to enable ODST support
Pepper-Man Jun 18, 2024
2599040
Remove unused library imports, and DLL reference to old version of Ma…
Pepper-Man Jun 18, 2024
f9fc645
Migrate Generate Shaders feature over to ManagedBlam. Deleted now unu…
Pepper-Man Jun 19, 2024
1515d67
Remove Creative Commons license info. Update README to .NET6.0 downlo…
Pepper-Man Jun 19, 2024
57755cb
Update LICENSE formatting.md
Pepper-Man Jun 19, 2024
962433d
Add extra debug output
Pepper-Man Jun 19, 2024
54ec148
Merge branch 'master' of https://github.com/Pepper-Man/Osoyoos-Launcher
Pepper-Man Jun 19, 2024
d9a6a9b
Reference assembly for ManagedBlam.dll
Pepper-Man Jun 20, 2024
ec4ebb7
Reference assembly generated by Refasmer
Pepper-Man Jun 20, 2024
9de63c7
Restore shadergen code/resources to maintain H2 compatibility, includ…
Pepper-Man Jun 20, 2024
5f647f6
Revert shadergen changes to non-managedblam. Removed unnecessary meth…
Pepper-Man Jun 23, 2024
c666808
Move bitmap MB code into separate file+class. Separated ManagedBlam c…
Pepper-Man Jun 23, 2024
36d0697
Remove unused list
Pepper-Man Jun 23, 2024
7333e7b
Resolve ambiguous path issue using backport of Path.GetRelativePath. …
Pepper-Man Jun 23, 2024
87ac4ab
Add section to readme about reference assembly
Pepper-Man Jun 23, 2024
456ab7e
Improve handling of compression type enum
Pepper-Man Jun 23, 2024
6588f35
Move getting bitmap path into helper function. Grab EK path more simp…
Pepper-Man Jun 23, 2024
3694a97
Revert ToolkitLauncher.csproj back to current release build
Pepper-Man Jun 23, 2024
1421da8
Initial project merge
Pepper-Man Jun 24, 2024
065008a
Configure correct build info for both projects
Pepper-Man Jun 24, 2024
c0b93e4
Fix unsafe code build error
Pepper-Man Jun 24, 2024
11dcf02
Merge pull request #2 from Pepper-Man/single-solution
Pepper-Man Jun 24, 2024
b8609e6
Define tag field/block access paths to avoid repeating magic strings
Pepper-Man Jun 24, 2024
f1e03f8
Remove old solution file
Pepper-Man Jun 24, 2024
fb337bc
Delete .github/workflows/dotnet-5.yml
num0005 Jun 24, 2024
968c9e0
Switch to new style SDK for the helper + x64 for all executables.
num0005 Jun 24, 2024
d8ac261
test next dotnet versions.
num0005 Jun 24, 2024
1f76864
Don't attempt to publish the MB project.
num0005 Jun 24, 2024
fdd2797
Use the x64 build path.
num0005 Jun 24, 2024
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
59 changes: 0 additions & 59 deletions .github/workflows/dotnet-5.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/dotnet-6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: launcher
path: Launcher\bin\Release\net6.0-windows\win-x64\publish\
path: Launcher\bin\Release\x64\net6.0-windows\win-x64\publish\

release:
if: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: windows-latest
strategy:
matrix: # https://stackoverflow.com/a/68940067/16608030 hopefully this still works
dotnet: [ {version: '5.0.x', path: net5.0-windows}, {version: '6.0.x', path: net6.0-windows} ]
dotnet: [ {version: '6.0.x', path: net6.0-windows}, {version: '8.0.x', path: net8.0-windows}, {version: '9.0.x', path: net9.0-windows} ]
env:
DOTNET_CLI_TELEMETRY_OPTOUT : true
steps:
Expand All @@ -37,6 +37,6 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: launcher
path: Launcher\bin\Release\${{ matrix.dotnet.path}}\win-x64\publish\
path: Launcher\bin\x64\Release\${{ matrix.dotnet.path}}\win-x64\publish\


7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
*/bin/*
/Launcher/bin/*
*/obj/*
*.vs/*
*.zip
*.exe
*.dll
!/OsoyoosMB/ref/ManagedBlam.dll
!/packages/Resource.Embedder.2.1.1/tasks/net46/*.dll
/icon_assets.7z
/Launcher/Properties/launchSettings.json
/OsoyoosMB/.vs/*
/OsoyoosMB/OsoyoosMB/obj/*
/OsoyoosMB/OsoyoosMB/bin/*
/OsoyoosMB/OsoyoosMB/.vs/*
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017 num0005
Copyright (c) 2017 num0005
Copyright (c) 2022 Osoyoos Launcher Contributors

Unless otherwise noted files in this repository are licensed under the terms of the MIT license (reproduced below).
Expand Down
16 changes: 16 additions & 0 deletions Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
<x:Type TypeName="local:ThemeType"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="BitmapCompressionTypeValues" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="local:BitmapCompressionType"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources>
<Grid Background="{DynamicResource WindowPrimaryColor}">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -521,6 +526,17 @@
<ComboBoxItem Content="Sprites"/>
<ComboBoxItem Content="Interface"/>
</ComboBox>
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="bitmap_compression_type" SelectedIndex="0" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=25, ElementName=toolkit_selection}" ToolTip="Set compression for imported images. Automatically forces &quot;pretty&quot; curve mode." Margin="0,0,208,8" Grid.RowSpan="2" ItemsSource="{Binding Source={StaticResource BitmapCompressionTypeValues}}"></ComboBox>
<Label Grid.Column="1" x:Name="compression_type_label" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{DynamicResource TextColor}" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=25, ElementName=toolkit_selection}" Content="Compression Type" Margin="195,0,89,0" RenderTransformOrigin="0.5,0.5">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<CheckBox Grid.Row="2" Grid.Column="1" x:Name="debug_plate" Content="Debug Plate" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="{DynamicResource TextColor}" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=1, ElementName=toolkit_selection}" ToolTip="Dump the plate for debugging (you likely don't need this)."/>
</Grid>
</GroupBox>
Expand Down
39 changes: 38 additions & 1 deletion Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Xml.Linq;
using System.Threading;
using System.Reflection;
using System.Runtime.Serialization;

namespace ToolkitLauncher
{
Expand Down Expand Up @@ -414,6 +415,41 @@
ui_music
}

[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum BitmapCompressionType
{
[Description("Default")]
[EnumMember(Value = "0")]
Default,
[Description("DXT5")]
[EnumMember(Value = "15")]
DXT5,
[Description("DXT1")]
[EnumMember(Value = "13")]
DXT1,
[Description("24-bit Color + 8-bit Alpha")]
[EnumMember(Value = "16")]
Color24BitAlpha8Bit,
[Description("Best Compressed Color")]
[EnumMember(Value = "1")]
BestCompressedColor,
[Description("Uncompressed")]
[EnumMember(Value = "2")]
Uncompressed
}

// Return the associated EnumMember string value given the selected value of the compression type above
public static class EnumExtensions
{
public static string GetEnumMemberValue(this Enum enumValue)
{
var fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
var attribute = (EnumMemberAttribute)fieldInfo.GetCustomAttributes(typeof(EnumMemberAttribute), false)[0];

return attribute.Value;
}
}

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
Expand Down Expand Up @@ -1081,7 +1117,8 @@
private async void CompileImage(object sender, RoutedEventArgs e)
{
string listEntry = BitmapCompile.bitmapType[bitmap_compile_type.SelectedIndex];
await toolkit.ImportBitmaps(compile_image_path.Text, listEntry, debug_plate.IsChecked is true);
BitmapCompressionType selectedComp = (BitmapCompressionType)bitmap_compression_type.SelectedItem; // Convert selected compression string to enum value
await toolkit.ImportBitmaps(compile_image_path.Text, listEntry, selectedComp.GetEnumMemberValue(), toolkit.GetDataDirectory(), debug_plate.IsChecked is true);
}

private async void PackageLevel(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -1883,7 +1920,7 @@
}
}

private async Task ConvertFBX()

Check warning on line 1923 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 1923 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
HRToolkit tool = toolkit as HRToolkit;

Expand Down Expand Up @@ -1919,7 +1956,7 @@
if (!(bool)show_output.IsChecked)
Thread.Sleep(250);

tool.GR2FromFBX(f, getFilepath(f) + ".json", getFilepath(f) + ".gr2", (json_rebuild.IsChecked == true) ? "recreate_json" : "", (bool)show_output.IsChecked);

Check warning on line 1959 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 1959 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
count++;
}
}
Expand All @@ -1946,7 +1983,7 @@
if (!(bool)show_output.IsChecked)
Thread.Sleep(250);

tool.GR2FromFBX(f, getFilepath(f) + ".json", getFilepath(f) + ".gr2", (json_rebuild.IsChecked == true) ? "recreate_json" : "", (bool)show_output.IsChecked);

Check warning on line 1986 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 1986 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
count++;
}
}
Expand Down Expand Up @@ -1976,7 +2013,7 @@
if (!(bool)show_output.IsChecked)
Thread.Sleep(250);

tool.GR2FromFBX(f, getFilepath(f) + ".json", getFilepath(f) + ".gr2", (json_rebuild.IsChecked == true) ? "recreate_json" : "", (bool)show_output.IsChecked);

Check warning on line 2016 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 2016 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
count++;
}
}
Expand Down Expand Up @@ -2053,7 +2090,7 @@
}

// Generate a Sidecar when the user has opted to create one for a model
private async Task GenerateModelSidecar()

Check warning on line 2093 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 2093 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
XDocument srcTree = new XDocument(
new XElement("Metadata", WriteHeader(),
Expand All @@ -2071,7 +2108,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateStructureSidecar()

Check warning on line 2111 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 2111 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
XDocument srcTree = new XDocument(
new XElement("Metadata", WriteHeader(),
Expand All @@ -2093,7 +2130,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateDecoratorSidecar()

Check warning on line 2133 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 2133 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
XDocument srcTree = new XDocument(
new XElement("Metadata", WriteHeader(),
Expand All @@ -2113,7 +2150,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateParticleSidecar()

Check warning on line 2153 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 2153 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
XDocument srcTree = new XDocument(
new XElement("Metadata", WriteHeader(),
Expand All @@ -2133,7 +2170,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateCinematicSidecar()

Check warning on line 2173 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 2173 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
XDocument srcTree = new XDocument(
new XElement("Metadata", WriteHeader(),
Expand Down Expand Up @@ -2172,7 +2209,7 @@
new XElement("OutputTagCollection",
new XElement("OutputTag", new XAttribute("Type", "cinematic_scene"), dataPath + "\\" + assetName))
));
XElement co = null;

Check warning on line 2212 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'co' is assigned but its value is never used

Check warning on line 2212 in Launcher/MainWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'co' is assigned but its value is never used
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/H1AToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public async Task JMSFromFBX(string fbxPath, string jmsPath, string geo_class)
/// <param name="path"></param>
/// <param name="type"></param>
/// <returns></returns>
override public async Task ImportBitmaps(string path, string type, bool debug_plate)
override public async Task ImportBitmaps(string path, string type, string compression, string data_path, bool debug_plate)
{
await RunTool(ToolType.Tool, new List<string>() { "bitmaps", path, type, debug_plate.ToString() });
}
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/H1Toolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override async Task ImportSound(string path, string platform, string bitr
await RunTool(ToolType.Tool, new List<string>() { "sounds", path, platform, bitrate });
}

override public async Task ImportBitmaps(string path, string type, bool debug_plate)
override public async Task ImportBitmaps(string path, string type, string compression, string data_path, bool debug_plate)
{
await RunTool(ToolType.Tool, new List<string>() { "bitmaps", path });
}
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/H2AToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected override string sapienWindowClass
get => "Sapien";
}

override public async Task ImportBitmaps(string path, string type, bool debug_plate)
override public async Task ImportBitmaps(string path, string type, string compression, string data_path, bool debug_plate)
{
await RunTool(ToolType.Tool, new() { "bitmaps", path, type, debug_plate.ToString() });
}
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/H2Toolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected virtual string sapienWindowClass
get => "Sapien";
}

override public async Task ImportBitmaps(string path, string type, bool debug_plate)
override public async Task ImportBitmaps(string path, string type, string compression, string data_path, bool debug_plate)
{
string bitmaps_command = "bitmaps";
if (Profile.CommunityTools || Profile.BuildType == build_type.release_mcc)
Expand Down
12 changes: 11 additions & 1 deletion Launcher/ToolkitInterface/H3Toolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@ protected string sapienWindowClass
get => "Sapien";
}

override public async Task ImportBitmaps(string path, string type, bool debug_plate)
override public async Task ImportBitmaps(string path, string type, string compression, string data_path, bool debug_plate)
{
// First import
await RunTool(ToolType.Tool, new List<string>() { debug_plate ? "bitmaps-debug" : "bitmaps", path });

// Call managedblam
bool MB_success = ManagedBlam.RunMBBitmaps(BaseDirectory, path, compression);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q, couldn't this be run before importing the bitmaps and generate like dummy bitmaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps, i can try that


if (MB_success)
{
// Reimport bitmaps
await RunTool(ToolType.Tool, new List<string>() { debug_plate ? "bitmaps-debug" : "bitmaps", path });
}
}

override public async Task ImportUnicodeStrings(string path)
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/ToolkitBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public record ImportArgs(
/// <param name="path">Directory containing the bitmaps</param>
/// <param name="type">The type of bitmap to import it by</param>
/// <param name="debug_plate">MCC H1A: Whether or not we dump plate data to the data folder for inspection</param>
public abstract Task ImportBitmaps(string path, string type, bool debug_plate = false);
public abstract Task ImportBitmaps(string path, string type, string compression, string data_path, bool debug_plate = false);

/// <summary>
/// How build cache will handle resources
Expand Down
1 change: 1 addition & 0 deletions Launcher/ToolkitLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<Platforms>AnyCPU;x64;x86</Platforms>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
Expand Down
51 changes: 51 additions & 0 deletions Launcher/Utility/ManagedBlam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace ToolkitLauncher.Utility
{
public class ManagedBlam
{
public static bool RunMBBitmaps(string ek_path, string tag_path, string compression_type)
{
string exe_path = Path.Combine(ek_path, @"bin\OsoyoosMB.exe");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arguably this should be a new tool path not just hardcoded, would make it easier when debugging, etc. Could be a future improvement.


if (File.Exists(exe_path))
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = exe_path,
Arguments = $"getbitmapdata \"{ek_path}\" \"{tag_path.TrimEnd('\\')}\" \"{compression_type}\"",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};

try
{
// Start the process
using (System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo))
{
process.WaitForExit();
return true;
}
}
catch
{
// Handle any errors that might occur
MessageBox.Show("Unspecified ManagedBlam error.\nBitmaps have still been imported, but settings will not be applied.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
else
{
// User likely hasnt put the second exe in the right place
MessageBox.Show($"Error: Cannot find \"{exe_path}\".\nMake sure the OsoyoosMB.exe is in your editing kit's \"bin\" folder.\nBitmaps have still been imported, but settings will not be applied.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}

}
}
}
6 changes: 6 additions & 0 deletions OsoyoosMB/OsoyoosMB/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
Loading
Loading