Browse Source

Localization id should default to use Flowchart object name #101

master
chrisgregan 10 years ago
parent
commit
6e4f22f421
  1. 2
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs
  2. 35
      Assets/Fungus/Narrative/Scripts/Localization.cs

2
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -112,7 +112,7 @@ namespace Fungus
/** /**
* Unique identifier for identifying this flowchart in localized string keys. * 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 = ""; public string localizationId = "";
/** /**

35
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<string, TextItem> FindTextItems() protected Dictionary<string, TextItem> FindTextItems()
{ {
@ -160,10 +160,11 @@ namespace Fungus
Flowchart[] flowcharts = GameObject.FindObjectsOfType<Flowchart>(); Flowchart[] flowcharts = GameObject.FindObjectsOfType<Flowchart>();
foreach (Flowchart flowchart in flowcharts) foreach (Flowchart flowchart in flowcharts)
{ {
// Have to set a unique localization id to export strings // If no localization id has been set then use the Flowchart name
if (flowchart.localizationId.Length == 0) string localizationId = flowchart.localizationId;
if (localizationId.Length == 0)
{ {
continue; localizationId = flowchart.name;
} }
Block[] blocks = flowchart.GetComponentsInChildren<Block>(); Block[] blocks = flowchart.GetComponentsInChildren<Block>();
@ -182,7 +183,7 @@ namespace Fungus
Say sayCommand = command as Say; Say sayCommand = command as Say;
standardText = sayCommand.storyText; standardText = sayCommand.storyText;
description = sayCommand.description; description = sayCommand.description;
stringId = "SAY." + flowchart.localizationId + "." + sayCommand.itemId + "."; stringId = "SAY." + localizationId + "." + sayCommand.itemId + ".";
if (sayCommand.character != null) if (sayCommand.character != null)
{ {
stringId += sayCommand.character.nameText; stringId += sayCommand.character.nameText;
@ -194,7 +195,7 @@ namespace Fungus
Menu menuCommand = command as Menu; Menu menuCommand = command as Menu;
standardText = menuCommand.text; standardText = menuCommand.text;
description = menuCommand.description; description = menuCommand.description;
stringId = "MENU." + flowchart.localizationId + "." + menuCommand.itemId; stringId = "MENU." + localizationId + "." + menuCommand.itemId;
} }
else else
{ {
@ -373,9 +374,16 @@ namespace Fungus
// Cache a lookup table of flowcharts in the scene // Cache a lookup table of flowcharts in the scene
Dictionary<string, Flowchart> flowchartDict = new Dictionary<string, Flowchart>(); Dictionary<string, Flowchart> flowchartDict = new Dictionary<string, Flowchart>();
foreach (Flowchart flowChart in GameObject.FindObjectsOfType<Flowchart>()) foreach (Flowchart flowchart in GameObject.FindObjectsOfType<Flowchart>())
{ {
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) for (int i = 1; i < csvTable.Length; ++i)
@ -552,9 +560,16 @@ namespace Fungus
// Cache a lookup table of flowcharts in the scene // Cache a lookup table of flowcharts in the scene
Dictionary<string, Flowchart> flowchartDict = new Dictionary<string, Flowchart>(); Dictionary<string, Flowchart> flowchartDict = new Dictionary<string, Flowchart>();
foreach (Flowchart flowChart in GameObject.FindObjectsOfType<Flowchart>()) foreach (Flowchart flowchart in GameObject.FindObjectsOfType<Flowchart>())
{ {
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'); string[] lines = textData.Split('\n');

Loading…
Cancel
Save