Skip to content

Commit

Permalink
Fix custom NPCs not getting a voice
Browse files Browse the repository at this point in the history
  • Loading branch information
Platonymous committed Feb 12, 2020
1 parent 5b31cb1 commit 717b79c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions PelicanTTS/PelicanTTSMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public override void Entry(IModHelper helper)
_helper = helper;
config = Helper.ReadConfig<ModConfig>();

Helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
Helper.Events.GameLoop.OneSecondUpdateTicked += GameLoop_OneSecondUpdateTicked;

helper.ConsoleCommands.Add("tts_update", "Updates new NPCs", (s,p) => setUpNPCConfig());

Helper.WriteConfig<ModConfig>(config);
string tmppath = Path.Combine(Path.Combine(Environment.CurrentDirectory, "Content"), "TTS");
Expand All @@ -51,7 +53,15 @@ public override void Entry(IModHelper helper)

}

private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
private void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e)
{
setUpNPCConfig();
setUpConfig();
Helper.Events.GameLoop.OneSecondUpdateTicked -= GameLoop_OneSecondUpdateTicked;

}

private void setUpNPCConfig()
{
var npcs = Helper.Content.Load<Dictionary<string, string>>("Data//NPCDispositions", ContentSource.GameContent);
foreach (string npc in npcs.Keys)
Expand All @@ -61,8 +71,8 @@ private void GameLoop_GameLaunched(object sender, GameLaunchedEventArgs e)
}
config.Rate = Math.Max(50, Math.Min(config.Rate, 200));
Helper.WriteConfig<ModConfig>(config);
setUpConfig();
}

public static Dictionary<string, MenuVoiceSetup> activeVoiceSetup = new Dictionary<string, MenuVoiceSetup>();
public static int activeRate = 100;
public static float activeVolume = 1;
Expand Down
4 changes: 2 additions & 2 deletions PelicanTTS/SpeechHandlerPolly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ public static string getVoice(string name, bool female = true)
speakerName = name;

string t = PelicanTTSMod.i18n.Get(name);
if (t.ToString() != "")
if (t.ToString() != "" && !t.Contains("no translation"))
return t;

return "default_" + (female ? "female" : "male");
return PelicanTTSMod.i18n.Get("default_" + (female ? "female" : "male"));
}


Expand Down
2 changes: 1 addition & 1 deletion PelicanTTS/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "PelicanTTS",
"Author": "Platonymous",
"Version": "1.8.8",
"Version": "1.8.9",
"Description": "Text-To-Speech Mod",
"UniqueID": "Platonymous.PelicanTTS",
"EntryDll": "PelicanTTS.dll",
Expand Down
Binary file added _releases/PelicanTTS 1.8.9.zip
Binary file not shown.

0 comments on commit 717b79c

Please sign in to comment.