Skip to content

Commit

Permalink
Localized strings for various panels #377
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jan 14, 2024
1 parent c792b8e commit b46c3fa
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 26 deletions.
10 changes: 5 additions & 5 deletions Assets/VoxelEditor/GUI/BevelGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override void WindowGUI()

Vector3 selectionSize = voxelArray.selectionBounds.size;
if (selectionSize == Vector3.zero)
ActionBarLabel("Select edges to bevel...");
ActionBarLabel(StringSet.BevelInstruction);
else
ActionBarLabel(SelectionString(selectionSize));

Expand Down Expand Up @@ -105,16 +105,16 @@ public override void WindowGUI()
voxelEdge = voxelArray.GetSelectedBevel();
}

GUILayout.Label("Bevel:", StyleSet.labelTitle);
GUILayout.Label(StringSet.BevelHeader, StyleSet.labelTitle);

if (!voxelArray.SomethingIsSelected())
{
GUILayout.Label("(none selected)");
GUILayout.Label(StringSet.BevelNoSelection);
return;
}

TutorialGUI.TutorialHighlight("bevel shape");
GUILayout.Label("Shape:");
GUILayout.Label(StringSet.BevelShapeHeader);
var newBevelType = (VoxelEdge.BevelType)GUILayout.SelectionGrid((int)voxelEdge.bevelType,
new Texture[] {
IconSet.no,
Expand All @@ -127,7 +127,7 @@ public override void WindowGUI()
TutorialGUI.ClearHighlight();

TutorialGUI.TutorialHighlight("bevel size");
GUILayout.Label("Size:");
GUILayout.Label(StringSet.BevelSizeHeader);
var newBevelSize = (VoxelEdge.BevelSize)GUILayout.SelectionGrid((int)voxelEdge.bevelSize,
new Texture[] {
IconSet.bevelIcons.quarter,
Expand Down
2 changes: 1 addition & 1 deletion Assets/VoxelEditor/GUI/CreateSubstanceGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void WindowGUI()

SelectionGUI();
GUILayout.FlexibleSpace();
ActionBarLabel("Push or pull to create a substance");
ActionBarLabel(StringSet.CreateSubstanceInstruction);

GUILayout.FlexibleSpace();

Expand Down
8 changes: 4 additions & 4 deletions Assets/VoxelEditor/GUI/DataImportGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public override void WindowGUI()
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label("Loading world...");
GUILayout.Label(StringSet.LoadingWorld);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
Expand All @@ -66,12 +66,12 @@ public override void WindowGUI()
scroll = GUILayout.BeginScrollView(scroll);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(GUIUtils.MenuContent("Import file", IconSet.import),
if (GUILayout.Button(GUIUtils.PadContent(StringSet.ImportFile, IconSet.import),
StyleSet.buttonLarge))
NativeGalleryWrapper.ImportAudioStream(ImportWorldHandler);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Label("Or import from a world...");
GUILayout.Label(StringSet.ImportFromWorldHeader);
for (int i = 0; i < worldPaths.Count; i++)
{
string path = worldPaths[i];
Expand Down Expand Up @@ -132,7 +132,7 @@ public override void WindowGUI()
if (errorMessage != null)
ActionBarGUI.ActionBarLabel(errorMessage);
else
ActionBarGUI.ActionBarLabel("World contains no " + type.ToString() + " files.");
ActionBarGUI.ActionBarLabel(StringSet.NoDataInWorld(type.ToString()));
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/VoxelEditor/GUI/DrawSelectGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override void WindowGUI()
voxelArray.ClearSelection();
}
}
EditGUI("Tap and drag to select");
EditGUI(StringSet.DrawSelectInstruction);
GUILayout.FlexibleSpace();
GUIUtils.EndHorizontalClipped();
if (HighlightedActionBarButton(IconSet.done))
Expand Down
8 changes: 5 additions & 3 deletions Assets/VoxelEditor/GUI/EntityPickerGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class EntityPickerGUI : ActionBarGUI
{
public System.Action<ICollection<Entity>> handler;
public bool allowNone = true, allowMultiple = true, allowNull = false;
public string nullName = "None";
public string nullName = StringSet.EntityPickNone;

private VoxelArrayEditor.SelectionState selectionState;

Expand Down Expand Up @@ -52,20 +52,22 @@ public override void WindowGUI()
SelectionGUI();

if (allowNull)
{
if (ActionBarButton(nullName))
{
handler(new Entity[] { null });
Destroy(this);
}
}

GUILayout.FlexibleSpace();

// TODO: not efficient to keep generating a list of selected entities
int numSelectedEntities = voxelArray.GetSelectedEntities().Count;
if (numSelectedEntities == 0)
ActionBarLabel("Pick an object...");
ActionBarLabel(StringSet.EntityPickInstruction);
else
ActionBarLabel(numSelectedEntities + " objects selected");
ActionBarLabel(StringSet.EntityPickCount(numSelectedEntities));

GUILayout.FlexibleSpace();

Expand Down
6 changes: 3 additions & 3 deletions Assets/VoxelEditor/GUI/EntityReferencePropertyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ public static string GetName()
{
Entity entity = targetEntities[currentTargetEntityI];
if (entity == null)
return "None";
return GUIPanel.StringSet.EntityRefNone;
else if (entity == currentEntity)
return "Self";
return GUIPanel.StringSet.EntityRefSelf;
else if (entity == behaviorTarget)
return "Target";
return GUIPanel.StringSet.EntityRefTarget;
else
return entity.ToString();
}
Expand Down
13 changes: 7 additions & 6 deletions Assets/VoxelEditor/GUI/FilterGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class FilterGUI : GUIPanel

public override void WindowGUI()
{
if (GUILayout.Button(GUIUtils.MenuContent("Specific object", IconSet.singleObject),
if (GUILayout.Button(
GUIUtils.MenuContent(StringSet.FilterSpecificObject, IconSet.singleObject),
OverflowMenuGUI.buttonStyle.Value))
{
EntityPickerGUI picker = gameObject.AddComponent<EntityPickerGUI>();
Expand All @@ -30,11 +31,11 @@ public override void WindowGUI()
};
Destroy(this);
}
if (GUILayout.Button(GUIUtils.MenuContent("Tags", IconSet.entityTag),
if (GUILayout.Button(GUIUtils.MenuContent(StringSet.FilterTags, IconSet.entityTag),
OverflowMenuGUI.buttonStyle.Value))
{
TagPickerGUI picker = gameObject.AddComponent<TagPickerGUI>();
picker.title = "Filter by tags";
picker.title = StringSet.FilterTagsTitle;
picker.multiple = true;
if (current is ActivatedSensor.MultipleTagFilter)
picker.multiSelection = (current as ActivatedSensor.MultipleTagFilter).tagBits;
Expand All @@ -46,11 +47,11 @@ public override void WindowGUI()
};
Destroy(this);
}
if (GUILayout.Button(GUIUtils.MenuContent("Active behavior", IconSet.behavior),
if (GUILayout.Button(GUIUtils.MenuContent(StringSet.FilterActiveBehavior, IconSet.behavior),
OverflowMenuGUI.buttonStyle.Value))
{
TypePickerGUI picker = gameObject.AddComponent<TypePickerGUI>();
picker.title = "Filter by active behavior";
picker.title = StringSet.FilterActiveBehaviorTitle;
picker.categoryNames = GameScripts.behaviorTabNames;
picker.categories = GameScripts.behaviorTabs;
picker.handler = (PropertiesObjectType type) =>
Expand All @@ -59,7 +60,7 @@ public override void WindowGUI()
};
Destroy(this);
}
if (GUILayout.Button(GUIUtils.MenuContent("Anything", IconSet.objectType),
if (GUILayout.Button(GUIUtils.MenuContent(StringSet.FilterAnything, IconSet.objectType),
OverflowMenuGUI.buttonStyle.Value))
{
handler(new ActivatedSensor.EntityTypeFilter(Entity.objectType));
Expand Down
2 changes: 1 addition & 1 deletion Assets/VoxelEditor/GUI/PropertiesGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void OnDestroy()

public override void WindowGUI()
{
string targetButtonText = StringSet.TargetEntity(StringSet.EntitySelf);
string targetButtonText = StringSet.TargetEntity(StringSet.EntityRefSelf);
if (targetEntityIsActivator)
targetButtonText = StringSet.TargetEntity(StringSet.EntityActivators);
else if (targetEntity != null)
Expand Down
54 changes: 52 additions & 2 deletions Assets/VoxelEditor/GUI/localization/GUIStringSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,56 @@ public class GUIStringSet
"Tap to pick paint...";
public virtual string SelectFillPaintInstruction =>
"Tap to fill paint...";
public virtual string CreateSubstanceInstruction =>
"Push or pull to create a substance";
public virtual string DrawSelectInstruction =>
"Tap and drag to select";
public virtual string EntityPickNone =>
"None";
public virtual string EntityPickInstruction =>
"Pick an object...";
public virtual string EntityPickCount(int count) =>
$"{count} objects selected";

// Type names
public virtual string Substance =>
"Substance";
public virtual string Object =>
"Object";

// Bevel
public virtual string BevelInstruction =>
"Select edges to bevel...";
public virtual string BevelHeader =>
"Bevel:";
public virtual string BevelNoSelection =>
"(none selected)";
public virtual string BevelShapeHeader =>
"Shape:";
public virtual string BevelSizeHeader =>
"Size:";

// Data import
public virtual string ImportFile =>
"Import file";
public virtual string ImportFromWorldHeader =>
"Or import from a world...";
public virtual string NoDataInWorld(string type) =>
$"World contains no {type} files.";

// Filter
public virtual string FilterSpecificObject =>
"Specific object";
public virtual string FilterTags =>
"Tags";
public virtual string FilterTagsTitle =>
"Filter by tags";
public virtual string FilterActiveBehavior =>
"Active behavior";
public virtual string FilterActiveBehaviorTitle =>
"Filter by active behavior";
public virtual string FilterAnything =>
"Anything";

// Properties panel
public virtual string PropertiesDifferent =>
Expand Down Expand Up @@ -132,11 +176,17 @@ public class GUIStringSet
"None";
public virtual string TargetEntity(string name) =>
$"Target: {name}";
public virtual string EntitySelf =>
"Self";
public virtual string EntityActivators =>
"Activators";

// Property GUIs
public virtual string EntityRefNone =>
"None";
public virtual string EntityRefSelf =>
"Self";
public virtual string EntityRefTarget =>
"Target";

// Help menu
public virtual string HelpMenuTitle =>
"Help";
Expand Down

0 comments on commit b46c3fa

Please sign in to comment.