From 6e4f22f421daf33fe69fb8174038e26f7774c80d Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Thu, 21 May 2015 15:10:58 +0100 Subject: [PATCH] Localization id should default to use Flowchart object name #101 --- Assets/Fungus/Flowchart/Scripts/Flowchart.cs | 2 +- .../Fungus/Narrative/Scripts/Localization.cs | 35 +++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs index 4a3c7dd2..daeb85e6 100644 --- a/Assets/Fungus/Flowchart/Scripts/Flowchart.cs +++ b/Assets/Fungus/Flowchart/Scripts/Flowchart.cs @@ -112,7 +112,7 @@ namespace Fungus /** * Unique identifier for identifying this flowchart in localized string keys. */ - [Tooltip("Unique identifier for this flowchart in localized string keys. This id must be provided for localization string export to work.")] + [Tooltip("Unique identifier for this flowchart in localized string keys. If no id is specified then the name of the Flowchart object will be used.")] public string localizationId = ""; /** diff --git a/Assets/Fungus/Narrative/Scripts/Localization.cs b/Assets/Fungus/Narrative/Scripts/Localization.cs index 32414901..e861a534 100644 --- a/Assets/Fungus/Narrative/Scripts/Localization.cs +++ b/Assets/Fungus/Narrative/Scripts/Localization.cs @@ -138,7 +138,7 @@ namespace Fungus } /** - * Buidls a dictionary of localizable text items in the scene. + * Builds a dictionary of localizable text items in the scene. */ protected Dictionary FindTextItems() { @@ -160,10 +160,11 @@ namespace Fungus Flowchart[] flowcharts = GameObject.FindObjectsOfType(); foreach (Flowchart flowchart in flowcharts) { - // Have to set a unique localization id to export strings - if (flowchart.localizationId.Length == 0) + // If no localization id has been set then use the Flowchart name + string localizationId = flowchart.localizationId; + if (localizationId.Length == 0) { - continue; + localizationId = flowchart.name; } Block[] blocks = flowchart.GetComponentsInChildren(); @@ -182,7 +183,7 @@ namespace Fungus Say sayCommand = command as Say; standardText = sayCommand.storyText; description = sayCommand.description; - stringId = "SAY." + flowchart.localizationId + "." + sayCommand.itemId + "."; + stringId = "SAY." + localizationId + "." + sayCommand.itemId + "."; if (sayCommand.character != null) { stringId += sayCommand.character.nameText; @@ -194,7 +195,7 @@ namespace Fungus Menu menuCommand = command as Menu; standardText = menuCommand.text; description = menuCommand.description; - stringId = "MENU." + flowchart.localizationId + "." + menuCommand.itemId; + stringId = "MENU." + localizationId + "." + menuCommand.itemId; } else { @@ -373,9 +374,16 @@ namespace Fungus // Cache a lookup table of flowcharts in the scene Dictionary flowchartDict = new Dictionary(); - foreach (Flowchart flowChart in GameObject.FindObjectsOfType()) + foreach (Flowchart flowchart in GameObject.FindObjectsOfType()) { - flowchartDict[flowChart.localizationId] = flowChart; + // If no localization id has been set then use the Flowchart name + string localizationId = flowchart.localizationId; + if (localizationId.Length == 0) + { + localizationId = flowchart.name; + } + + flowchartDict[localizationId] = flowchart; } for (int i = 1; i < csvTable.Length; ++i) @@ -552,9 +560,16 @@ namespace Fungus // Cache a lookup table of flowcharts in the scene Dictionary flowchartDict = new Dictionary(); - foreach (Flowchart flowChart in GameObject.FindObjectsOfType()) + foreach (Flowchart flowchart in GameObject.FindObjectsOfType()) { - flowchartDict[flowChart.localizationId] = flowChart; + // If no localization id has been set then use the Flowchart name + string localizationId = flowchart.localizationId; + if (localizationId.Length == 0) + { + localizationId = flowchart.name; + } + + flowchartDict[localizationId] = flowchart; } string[] lines = textData.Split('\n');