Browse Source

Flowcharts use a localisation id property when exporting strings #8

master
chrisgregan 10 years ago
parent
commit
f5e1c89936
  1. 3
      Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs
  2. 6
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs
  3. 14
      Assets/Fungus/Flowchart/Scripts/Language.cs

3
Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs

@ -23,6 +23,7 @@ namespace Fungus
protected SerializedProperty hideComponentsProp;
protected SerializedProperty runSlowDurationProp;
protected SerializedProperty saveSelectionProp;
protected SerializedProperty localizationIdProp;
protected SerializedProperty variablesProp;
protected virtual void OnEnable()
@ -32,6 +33,7 @@ namespace Fungus
hideComponentsProp = serializedObject.FindProperty("hideComponents");
runSlowDurationProp = serializedObject.FindProperty("runSlowDuration");
saveSelectionProp = serializedObject.FindProperty("saveSelection");
localizationIdProp = serializedObject.FindProperty("localizationId");
variablesProp = serializedObject.FindProperty("variables");
}
@ -48,6 +50,7 @@ namespace Fungus
EditorGUILayout.PropertyField(hideComponentsProp);
EditorGUILayout.PropertyField(runSlowDurationProp);
EditorGUILayout.PropertyField(saveSelectionProp);
EditorGUILayout.PropertyField(localizationIdProp);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();

6
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -109,6 +109,12 @@ namespace Fungus
[Tooltip("Saves the selected block and commands when saving the scene.")]
public bool saveSelection = true;
/**
* Unique identifier for identifying this flowchart in localized string keys.
*/
[Tooltip("Unique identifier for this flowchart in localized string keys. An id must be provided for Language string export to work.")]
public string localizationId = "";
/**
* Unique id to assign to the next created item.
* Increases monotonically every time a new item is added to the Flowchart.

14
Assets/Fungus/Flowchart/Scripts/Language.cs

@ -112,6 +112,12 @@ namespace Fungus
Flowchart[] flowcharts = GameObject.FindObjectsOfType<Flowchart>();
foreach (Flowchart flowchart in flowcharts)
{
// Have to set a unique localization id to export strings
if (flowchart.localizationId.Length == 0)
{
continue;
}
Block[] blocks = flowchart.GetComponentsInChildren<Block>();
foreach (Block block in blocks)
{
@ -124,14 +130,14 @@ namespace Fungus
System.Type type = command.GetType();
if (type == typeof(Say))
{
stringID = "SAY." + flowchart.name + "." + command.itemId;
stringID = "SAY." + flowchart.localizationId + "." + command.itemId;
Say sayCommand = command as Say;
standardText = sayCommand.storyText;
description = sayCommand.description;
}
else if (type == typeof(Menu))
{
stringID = "MENU." + flowchart.name + "." + command.itemId;
stringID = "MENU." + flowchart.localizationId + "." + command.itemId;
Menu menuCommand = command as Menu;
standardText = menuCommand.text;
description = menuCommand.description;
@ -233,7 +239,7 @@ namespace Fungus
// Parse header row
string[] columnNames = csvTable[0];
if (columnNames.Length < 5)
if (columnNames.Length < 4)
{
// No languages defined in CSV file
return;
@ -259,7 +265,7 @@ namespace Fungus
Dictionary<string, Flowchart> flowchartDict = new Dictionary<string, Flowchart>();
foreach (Flowchart flowChart in GameObject.FindObjectsOfType<Flowchart>())
{
flowchartDict[flowChart.name] = flowChart;
flowchartDict[flowChart.localizationId] = flowChart;
}
for (int i = 1; i < csvTable.Length; ++i)

Loading…
Cancel
Save