Skip to content

Commit

Permalink
Vox Pack TTS Modifications
Browse files Browse the repository at this point in the history
Made it so that Voice Packs can be exempted from the Random Text Generation like the Custom Voice Lines are, while also making it possible to include them for the Text to Speech process.
  • Loading branch information
Knuxfan24 committed Oct 13, 2022
1 parent f52b46f commit e4c5133
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
4 changes: 3 additions & 1 deletion MarathonRandomiser/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@
<CheckBox x:Name="CheckBox_Text_Buttons" Content="Randomise Button Icons" IsChecked="true"/>
<CheckBox x:Name="CheckBox_Text_Generate" Content="Generate Random Text" Click="Dependency_CheckBox_Changed"/>
<CheckBox x:Name="CheckBox_Text_Generate_Enforce" Content="Enforce Word Length" IsEnabled="false" IsChecked="true"/>
<CheckBox x:Name="CheckBox_Text_Generate_TTS" Content="Use Text to Speech" IsEnabled="false"/>
<CheckBox x:Name="CheckBox_Text_Generate_Vox" Content="Include Vox Packs" IsEnabled="false" IsChecked="false" Click="Dependency_CheckBox_Changed"/>
<CheckBox x:Name="CheckBox_Text_Generate_TTS" Content="Use Text to Speech" IsEnabled="false" Click="Dependency_CheckBox_Changed"/>
<CheckBox x:Name="CheckBox_Text_Generate_TTSVox" Content="Include Vox Packs" IsEnabled="false" IsChecked="false"/>
<CheckBox x:Name="CheckBox_Text_Colour" Content="Randomly Colour Text" Click="Dependency_CheckBox_Changed"/>
<Label x:Name="Label_Text_Colour_Weight" Content="Weight:" Background="{x:Null}" BorderBrush="{x:Null}" IsEnabled="False"/>
<hc:NumericUpDown x:Name="NumericUpDown_Text_Colour_Weight" Minimum="1" Maximum="100" Value="10" Margin="10,0,10,0" SelectionBrush="#FFB146C2" IsEnabled="False"/>
Expand Down
49 changes: 42 additions & 7 deletions MarathonRandomiser/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,45 @@ private void Dependency_CheckBox_Changed(object sender, RoutedEventArgs e)
case "CheckBox_Text_Generate":
CheckBox_Text_Generate_Enforce.IsEnabled = NewCheckedStatus;
if (TextBox_General_GameExecutable.Text.EndsWith(".xex"))
{
CheckBox_Text_Generate_Vox.IsEnabled = NewCheckedStatus;
CheckBox_Text_Generate_TTS.IsEnabled = NewCheckedStatus;
if (!NewCheckedStatus)
{
CheckBox_Text_Generate_TTSVox.IsEnabled = false;
}
else
{
if (CheckBox_Text_Generate_TTS.IsChecked == true)
{
CheckBox_Text_Generate_TTSVox.IsEnabled = true;
}
}
}
break;
case "CheckBox_Text_Generate_Vox":
if (!NewCheckedStatus)
{
CheckBox_Text_Generate_TTSVox.IsEnabled = false;
}
else
{
if (CheckBox_Text_Generate_TTS.IsChecked == true)
{
CheckBox_Text_Generate_TTSVox.IsEnabled = true;
}
}
break;
case "CheckBox_Text_Generate_TTS":
CheckBox_Text_Generate_TTSVox.IsChecked = false;
if (CheckBox_Text_Generate_Vox.IsChecked == false)
CheckBox_Text_Generate_TTSVox.IsEnabled = false;
else
CheckBox_Text_Generate_TTSVox.IsEnabled = NewCheckedStatus;
break;
case "CheckBox_Text_Colour":
Label_Text_Colour_Weight.IsEnabled = NewCheckedStatus;
NumericUpDown_Text_Colour_Weight.IsEnabled = NewCheckedStatus;
break;

case "CheckBox_XNCP_Colours":
Expand All @@ -701,11 +739,6 @@ private void Dependency_CheckBox_Changed(object sender, RoutedEventArgs e)
NumericUpDown_XNCP_Scale_Max.IsEnabled = NewCheckedStatus;
break;

case "CheckBox_Text_Colour":
Label_Text_Colour_Weight.IsEnabled = NewCheckedStatus;
NumericUpDown_Text_Colour_Weight.IsEnabled = NewCheckedStatus;
break;

case "CheckBox_Episode_Generate":
CheckBox_Episode_TownMissions.IsEnabled = NewCheckedStatus;
Label_Episode_CutsceneChance.IsEnabled = NewCheckedStatus;
Expand Down Expand Up @@ -2488,7 +2521,9 @@ await Task.Run(() => SceneRandomiser.Process(luaFile, sceneLightAmbient, sceneLi
bool? textButtons = CheckBox_Text_Buttons.IsChecked;
bool? textGenerate = CheckBox_Text_Generate.IsChecked;
bool? textGenerateEnforce = CheckBox_Text_Generate_Enforce.IsChecked;
bool? textGenerateVox = CheckBox_Text_Generate_Vox.IsChecked;
bool? textGenerateTTS = CheckBox_Text_Generate_TTS.IsChecked;
bool? textGenerateTTSVox = CheckBox_Text_Generate_TTSVox.IsChecked;
bool? textColour = CheckBox_Text_Colour.IsChecked;
int textColourWeight = (int)NumericUpDown_Text_Colour_Weight.Value;
bool? textShuffle = CheckBox_Text_Shuffle.IsChecked;
Expand Down Expand Up @@ -2559,7 +2594,7 @@ await Task.Run(() => SceneRandomiser.Process(luaFile, sceneLightAmbient, sceneLi
foreach (string mstFile in mstFiles)
{
UpdateLogger($"Generating random text for '{mstFile}'.");
await Task.Run(() => TextRandomiser.TextGenerator(mstFile, wordList, textGenerateEnforce));
await Task.Run(() => TextRandomiser.TextGenerator(mstFile, wordList, textGenerateEnforce, textGenerateVox));

// If this is a Hint MST and we're using the TTS, then generate the audio.
// Also make sure this is a 360 target, just in case.
Expand All @@ -2576,7 +2611,7 @@ await Task.Run(() => SceneRandomiser.Process(luaFile, sceneLightAmbient, sceneLi
foreach (var message in ttsMST.Data.Messages)
{
// If this is a custom hint or has no placeholders then skip it.
if (message.Name.Contains("hint_custom") || message.Name.StartsWith("vox_") || message.Placeholders == null)
if (message.Name.Contains("hint_custom") || (message.Name.StartsWith("vox_") && textGenerateVox == false) || message.Placeholders == null)
continue;

UpdateLogger($"Generating Text to Speech for random dialog in '{message.Name}'.");
Expand Down
6 changes: 3 additions & 3 deletions MarathonRandomiser/Randomisers/TextRandomiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ public static async Task ShuffleText(string[] mstFiles)
/// <param name="mstFile">The path to the MST to process.</param>
/// <param name="wordList">The list of English words.</param>
/// <param name="enforce">Whether or not we need to enforce the word length.</param>
public static async Task TextGenerator(string mstFile, string[] wordList, bool? enforce)
public static async Task TextGenerator(string mstFile, string[] wordList, bool? enforce, bool? vox)
{
// Load the MST.
MessageTable mst = new(mstFile);

// Loop through each Message Entry in this MST.
foreach (Message? message in mst.Data.Messages)
{
// Skip hints added from the Custom Voice Lines option (Voice Packs are OK though).
if (message.Name.Contains("hint_custom"))
// Skip hints added from the Custom Voice Lines option and Voice Pack ones if they're disabled.
if (message.Name.Contains("hint_custom") || (message.Name.StartsWith("vox_") && vox == false))
continue;

// Edit the New Lines, New Text Boxes and Placeholder Calls so they can be preserved.
Expand Down

0 comments on commit e4c5133

Please sign in to comment.