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

Add support for custom FMOD banks for H3, ODST and Reach #54

Merged
merged 2 commits into from
May 9, 2024
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
9 changes: 6 additions & 3 deletions Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,8 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="8"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="{Binding SelectedIndex, Converter={StaticResource ToolkitToSpaceConverter}, ConverterParameter=7, ElementName=toolkit_selection}"/>
<ColumnDefinition Width="{Binding SelectedIndex, Converter={StaticResource ToolkitToSpaceConverter}, ConverterParameter=9, ElementName=toolkit_selection}"/>
<ColumnDefinition Width="8"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<GroupBox Grid.Column="0" x:Name="class_type" Header="Class" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=12, ElementName=toolkit_selection}">
<ComboBox x:Name="class_dropdown" ItemsSource="{Binding SelectedIndex, Converter={StaticResource ProfiletoContent}, ConverterParameter=15, ElementName=toolkit_selection}" SelectedIndex="0" VerticalAlignment="Center" ToolTip="Select the class to set for the sound on first import."/>
Expand All @@ -812,13 +812,16 @@
<ComboBoxItem Content="Multi Layer"/>
</ComboBox>
</GroupBox>
<GroupBox Grid.Column="4" x:Name="compression_box" Header="Compression Type" VerticalAlignment="Stretch" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=6, ElementName=toolkit_selection}">
<GroupBox Grid.Column="4" x:Name="compression_box" Header="Compression Type" VerticalAlignment="Stretch" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=6, ElementName=toolkit_selection}">
<ComboBox x:Name="sound_compression_type" VerticalAlignment="Center" SelectedIndex="2" ToolTip="Select the compression type to use for the sound.">
<ComboBoxItem Content="Uncompressed"/>
<ComboBoxItem Content="ADPCM"/>
<ComboBoxItem Content="Opus"/>
</ComboBox>
</GroupBox>
<GroupBox Grid.Column="4" x:Name="custom_bank_box" Header="Custom Bank Extension" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="{Binding SelectedIndex, Converter={StaticResource ProfiletoVisibility}, ConverterParameter=26, ElementName=toolkit_selection}">
<TextBox x:Name="bank_extension" VerticalAlignment="Center" ToolTip="Enter a custom FMOD bank extension. Will be created if it does not exist. Leave blank to use default SFX/Language FMODs." BorderBrush="{StaticResource brushWatermarkBorder}" Foreground="{DynamicResource TextColor}" Background="{DynamicResource brushTextboxBackground}" CaretBrush="{DynamicResource TextColor}" MinHeight="22" MaxHeight="22"></TextBox>
</GroupBox>
</Grid>
<Grid Grid.Row="6">
<Button x:Name="import_sound" Content="Import Sound" VerticalAlignment="Bottom" Click="import_sound_Click" IsEnabled="{Binding Text.Length, ElementName=import_sound_path, Mode=OneWay}" ToolTip="Import the sound!"/>
Expand Down
3 changes: 2 additions & 1 deletion Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,12 +1220,13 @@
sound_command_type sound_command = (sound_command_type)sound_import_type.SelectedIndex;
codec_type platform = (codec_type)platform_type.SelectedIndex;
string class_name = class_dropdown.SelectedItem.ToString();
string custom_extension = bank_extension.Text.ToString();

string sound_path = import_sound_path.Text;
string bitrate_value = bitrate_slider.Value.ToString();
string ltf_path = "data\\" + import_ltf_path.Text;

await toolkit.ImportSound(sound_path, platform.ToString(), bitrate_value, ltf_path, sound_command.ToString(), class_name, ((ComboBoxItem)sound_compression_type.SelectedItem).Content.ToString().ToLower());
await toolkit.ImportSound(sound_path, platform.ToString(), bitrate_value, ltf_path, sound_command.ToString(), class_name, ((ComboBoxItem)sound_compression_type.SelectedItem).Content.ToString().ToLower(), custom_extension);
}

private void spaces_PreviewKeyDown(object sender, KeyEventArgs e)
Expand Down Expand Up @@ -1882,7 +1883,7 @@
}
}

private async Task ConvertFBX()

Check warning on line 1886 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 1886 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 @@ -1918,7 +1919,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 1922 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 1922 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 @@ -1945,7 +1946,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 1949 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 1949 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 @@ -1975,7 +1976,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 1979 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 1979 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 @@ -2052,7 +2053,7 @@
}

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

Check warning on line 2056 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 2056 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 @@ -2070,7 +2071,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateStructureSidecar()

Check warning on line 2074 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 2074 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 @@ -2092,7 +2093,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateDecoratorSidecar()

Check warning on line 2096 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 2096 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 @@ -2112,7 +2113,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateParticleSidecar()

Check warning on line 2116 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 2116 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 @@ -2132,7 +2133,7 @@
MessageBox.Show("Sidecar Generated Successfully!");
}

private async Task GenerateCinematicSidecar()

Check warning on line 2136 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 2136 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 @@ -2171,7 +2172,7 @@
new XElement("OutputTagCollection",
new XElement("OutputTag", new XAttribute("Type", "cinematic_scene"), dataPath + "\\" + assetName))
));
XElement co = null;

Check warning on line 2175 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 2175 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/H1Toolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override async Task ImportModel(string path, ModelCompile importType, boo
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type)
public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type, string custom_extension)
{
await RunTool(ToolType.Tool, new List<string>() { "sounds", path, platform, bitrate });
}
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/H2AToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public override async Task ImportModel(string path, ModelCompile importType, boo
await RunTool(ToolType.Tool, args, true);
}

public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type)
public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type, string custom_extension)
{
await RunTool(ToolType.Tool, new List<string>() { sound_command.Replace("_", "-"), path, class_type, compression_type });
}
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/H2Toolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public override async Task ImportModel(string path, ModelCompile importType, boo
await RunTool(ToolType.Tool, new List<string>() { "append-animations", path });
}

public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type)
public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type, string custom_extension)
{
await RunTool(ToolType.Tool, new List<string>() { "import-lipsync", path, ltf_path });
}
Expand Down
11 changes: 9 additions & 2 deletions Launcher/ToolkitInterface/H3Toolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,16 @@ public static List<string> ImportAnimations(bool FPAnim, bool verboseAnim, bool
return args;
}

public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type)
public override async Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type, string custom_extension)
{
await RunTool(ToolType.Tool, new List<string>() { sound_command.Replace("_", "-"), path, class_type });
if (string.IsNullOrWhiteSpace(custom_extension))
{
await RunTool(ToolType.Tool, new List<string>() { sound_command.Replace("_", "-"), path, class_type });
}
else
{
await RunTool(ToolType.Tool, new List<string>() { sound_command.Replace("_", "-"), path, class_type, "-bank:" + custom_extension.ToLower() });
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Launcher/ToolkitInterface/ToolkitBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public enum ResourceMapUsage
/// <param name="class_type"></param>
/// <param name="compression_type"></param>
/// <returns></returns>
public abstract Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type);
public abstract Task ImportSound(string path, string platform, string bitrate, string ltf_path, string sound_command, string class_type, string compression_type, string custom_extension);

/// <summary>
/// Check whatever there is mutex preventing another instance of a tool from starting
Expand Down
13 changes: 12 additions & 1 deletion Launcher/UIHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ public override object Convert(object value, Type targetType, object parameter,
else
grid = new GridLength(1, (double)GridUnitType.Auto);
}
else if (parameter is string && Int32.Parse(parameter as string) == 23)
Copy link
Owner

Choose a reason for hiding this comment

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

these magic numbers should really be an enum...

{
if (MainWindow.halo_3 || MainWindow.halo_3_odst || MainWindow.halo_reach)
grid = new GridLength(8);
}
}
else
{
Expand All @@ -294,7 +299,8 @@ public override object Convert(object value, Type targetType, object parameter,
|| parameter is string && Int32.Parse(parameter as string) == 19
|| parameter is string && Int32.Parse(parameter as string) == 20
|| parameter is string && Int32.Parse(parameter as string) == 21
|| parameter is string && Int32.Parse(parameter as string) == 22)
|| parameter is string && Int32.Parse(parameter as string) == 22
|| parameter is string && Int32.Parse(parameter as string) == 23)
{
grid = new GridLength(1, GridUnitType.Star);
}
Expand Down Expand Up @@ -468,6 +474,11 @@ public override object Convert(object value, Type targetType, object parameter,
if (MainWindow.halo_3 || MainWindow.halo_3_odst)
vis = Visibility.Visible;
}
else if (parameter is string && Int32.Parse(parameter as string) == 26)
{
if (MainWindow.halo_3 || MainWindow.halo_3_odst || MainWindow.halo_reach)
vis = Visibility.Visible;
}
}
else
{
Expand Down
Loading