Skip to content

Commit

Permalink
Localize answer strings
Browse files Browse the repository at this point in the history
Action type 12 answer strings are now recovered from Internal_Strings table.
Allow IME input for answer, with expectation strings are translated or player enters in default English text.
Fallback to hardcoded string arrays on failure to read from string tables.
  • Loading branch information
Interkarma committed Oct 7, 2023
1 parent fb6bc23 commit e3a94e1
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
Expand Up @@ -3923,6 +3923,26 @@ MonoBehaviour:
m_Key: affiliationFormatString
m_Metadata:
m_Items: []
- m_Id: 401505019353362432
m_Key: answers_5404
m_Metadata:
m_Items: []
- m_Id: 401505141491494912
m_Key: answers_5406
m_Metadata:
m_Items: []
- m_Id: 401505212006133760
m_Key: answers_5423
m_Metadata:
m_Items: []
- m_Id: 401505274576760832
m_Key: answers_5424
m_Metadata:
m_Items: []
- m_Id: 401505331053064192
m_Key: answers_5464
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Expand Down
54 changes: 54 additions & 0 deletions Assets/Localization/StringTables/Internal_Strings_en.asset
Expand Up @@ -5149,5 +5149,59 @@ MonoBehaviour:
m_Localized: '{0} (rep:{1})'
m_Metadata:
m_Items: []
- m_Id: 401505019353362432
m_Localized: 'bow
bow arrow
crossbow
bows
crossbows'
m_Metadata:
m_Items: []
- m_Id: 401505141491494912
m_Localized: 'one
1'
m_Metadata:
m_Items: []
- m_Id: 401505212006133760
m_Localized: 'benefactor
the benefactor'
m_Metadata:
m_Items: []
- m_Id: 401505274576760832
m_Localized: 'shut up
shutup
shaddup'
m_Metadata:
m_Items: []
- m_Id: 401505331053064192
m_Localized: 'yes
ok
i agree
y
agreed
done
fine
okay
sure
yep'
m_Metadata:
m_Items: []
references:
version: 1
14 changes: 11 additions & 3 deletions Assets/Scripts/Internal/DaggerfallAction.cs
Expand Up @@ -58,6 +58,8 @@ public class DaggerfallAction : MonoBehaviour
float cooldown;

//lookup for action type12, temp. storing them here
// Note: These answer string arrays are now found in Internal_Strings table using keys: answers_5404, answers_5406, answers_5423, answers_5464
// Legacy answer strings here will be used for fallback
static Dictionary<int, string[]> actionTypeTwelveLookup = new Dictionary<int, string[]>()
{
{5404, new string[]{"bow","bow arrow","crossbow","bows","crossbows"}}, //sheogorath answer index = 5660
Expand Down Expand Up @@ -439,7 +441,7 @@ public void UserInputHandler(DaggerfallInputMessageBox sender, string userInput)
DaggerfallUnity.LogMessage(string.Format(("No answers to check for: {0} {1}"), this.gameObject.name, this.Index));
return;
}
userInput = userInput.ToLower();
userInput = userInput.ToLower(System.Globalization.CultureInfo.InvariantCulture);
for (int i = 0; i < type12_answers.Length; i++)
{
if (userInput == type12_answers[i].ToLower())
Expand Down Expand Up @@ -550,14 +552,20 @@ public static void ShowTextWithInput(GameObject triggerObj, DaggerfallAction thi
int textID = thisAction.Index + TYPE_12_TEXT_INDEX;
if (actionTypeTwelveLookup.ContainsKey(textID))
{
thisAction.type12_answers = actionTypeTwelveLookup[textID];
// Get localized answer strings
string answerKey = "answers_" + textID.ToString();
thisAction.type12_answers = TextManager.Instance.GetLocalizedTextList(answerKey, exception:false);

// Fallback to legacy answer strings
if (thisAction.type12_answers == null || thisAction.type12_answers.Length == 0 )
thisAction.type12_answers = actionTypeTwelveLookup[textID];
}
else
{
Debug.LogError(string.Format("Error: invalid key: {0} for action type 12, couldn't get answer(s)", textID));//todo - display error message
}
DaggerfallInputMessageBox inputBox = new DaggerfallInputMessageBox(DaggerfallUI.UIManager, textID, 20, " > ", false, true, null);
inputBox.AllowIME = false;
inputBox.AllowIME = true;
inputBox.ParentPanel.BackgroundColor = Color.clear;
inputBox.OnGotUserInput += thisAction.UserInputHandler;
inputBox.Show();
Expand Down

0 comments on commit e3a94e1

Please sign in to comment.