Code: Select all
public void SetLanguage(string newLanguage)
{
DialogueManager.instance.SetLanguage(newLanguage);
UpdateCharacterNames();
UpdateSubtitleText();
DialogueManager.UpdateResponses();
}
public void UpdateSubtitleText()
{
var subtitle = DialogueManager.currentConversationState.subtitle;
subtitle.formattedText.text = FormattedText.Parse(subtitle.dialogueEntry.currentDialogueText);
DialogueManager.standardUISubtitlePanel.ShowSubtitle(subtitle);
// (^ Alternatively you could just set the subtitle panel's subtitleText.text.)
}
public void UpdateCharacterNames()
{
var conversation = DialogueManager.masterDatabase.GetConversation(DialogueManager.currentConversationState.subtitle.dialogueEntry.conversationID);
var actorIDs = new HashSet<int>();
conversation.dialogueEntries.ForEach(entry => actorIDs.Add(entry.ActorID));
foreach (var actorID in actorIDs)
{
var characterInfo = DialogueManager.conversationModel.GetCharacterInfo(actorID);
characterInfo.Name = PixelCrushers.DialogueSystem.CharacterInfo.GetLocalizedDisplayNameInDatabase(characterInfo.nameInDatabase);
// Update Variable["Actor"] or Variable["Conversant"] if applicable:
if (actorID == DialogueManager.conversationModel.actorInfo.id)
{
DialogueLua.SetVariable("Actor", characterInfo.Name);
}
else if (actorID == DialogueManager.conversationModel.conversantInfo.id)
{
DialogueLua.SetVariable("Conversant", characterInfo.Name);
}
}
}