Skip to content

Commit

Permalink
Localized strings for action bar; #377
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jan 14, 2024
1 parent a41dfdf commit c792b8e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 24 deletions.
42 changes: 21 additions & 21 deletions Assets/VoxelEditor/GUI/ActionBarGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ protected void EditGUI(string message = null)
if (facesSelected && ActionBarButton(IconSet.create))
{
TypePickerGUI picker = gameObject.AddComponent<TypePickerGUI>();
picker.title = "Create";
picker.title = StringSet.CreateObjectTitle;
picker.categories = new PropertiesObjectType[][] {
GameScripts.entityTemplates, GameScripts.objectTemplates };
picker.categoryNames = new string[] { "Substance", "Object" };
picker.categoryNames = new string[] { StringSet.Substance, StringSet.Object };
picker.handler = (PropertiesObjectType type) =>
{
if (typeof(Substance).IsAssignableFrom(type.type))
Expand Down Expand Up @@ -139,49 +139,49 @@ private void BuildOverflowMenu()
var overflow = gameObject.AddComponent<OverflowMenuGUI>();
overflow.items = new OverflowMenuGUI.MenuItem[]
{
new OverflowMenuGUI.MenuItem("Help", IconSet.help, () => {
new OverflowMenuGUI.MenuItem(StringSet.OpenHelp, IconSet.help, () => {
var help = gameObject.AddComponent<HelpGUI>();
help.voxelArray = voxelArray;
help.touchListener = touchListener;
}),
new OverflowMenuGUI.MenuItem("World", IconSet.world, () => {
new OverflowMenuGUI.MenuItem(StringSet.OpenWorldProperties, IconSet.world, () => {
PropertiesGUI propsGUI = GetComponent<PropertiesGUI>();
if (propsGUI != null)
{
propsGUI.specialSelection = voxelArray.world;
propsGUI.normallyOpen = true;
}
}),
new OverflowMenuGUI.MenuItem("Select...", IconSet.select, () => {
new OverflowMenuGUI.MenuItem(StringSet.SelectSubmenu, IconSet.select, () => {
var selectMenu = gameObject.AddComponent<OverflowMenuGUI>();
selectMenu.depth = 1;
selectMenu.items = new OverflowMenuGUI.MenuItem[]
{
new OverflowMenuGUI.MenuItem("Draw", IconSet.draw, () => {
new OverflowMenuGUI.MenuItem(StringSet.SelectDraw, IconSet.draw, () => {
DrawSelectInterface();
}),
new OverflowMenuGUI.MenuItem("With Paint", IconSet.paint, () => {
new OverflowMenuGUI.MenuItem(StringSet.SelectWithPaint, IconSet.paint, () => {
SelectByPaintInterface();
}),
new OverflowMenuGUI.MenuItem("Fill Paint", IconSet.fill, () => {
new OverflowMenuGUI.MenuItem(StringSet.SelectFillPaint, IconSet.fill, () => {
FillPaintInterface();
}),
new OverflowMenuGUI.MenuItem("With Tag", IconSet.entityTag, () => {
new OverflowMenuGUI.MenuItem(StringSet.SelectWithTag, IconSet.entityTag, () => {
SelectByTagInterface();
})
};
}, stayOpen: true),
new OverflowMenuGUI.MenuItem("Bevel", IconSet.bevel, () => {
new OverflowMenuGUI.MenuItem(StringSet.OpenBevel, IconSet.bevel, () => {
var bevelGUI = gameObject.AddComponent<BevelActionBarGUI>();
bevelGUI.voxelArray = voxelArray;
bevelGUI.touchListener = touchListener;
}),
new OverflowMenuGUI.MenuItem("Revert", IconSet.undo, () => {
new OverflowMenuGUI.MenuItem(StringSet.RevertChanges, IconSet.undo, () => {
var dialog = gameObject.AddComponent<DialogGUI>();
dialog.title = "Are you sure?";
dialog.message = "Undo all changes since the world was opened?";
dialog.yesButtonText = "Yes";
dialog.noButtonText = "No";
dialog.title = StringSet.AreYouSure;
dialog.message = StringSet.ConfirmRevertChanges;
dialog.yesButtonText = StringSet.Yes;
dialog.noButtonText = StringSet.No;
dialog.yesButtonHandler = () => {
editorFile.Revert();
};
Expand Down Expand Up @@ -211,19 +211,19 @@ protected string SelectionString(Vector3 selectionSize)
if (selectionSize.x != 0)
{
if (selectionString != "")
selectionString += "x";
selectionString += StringSet.DimensionSeparator;
selectionString += Mathf.RoundToInt(selectionSize.x);
}
if (selectionSize.y != 0)
{
if (selectionString != "")
selectionString += "x";
selectionString += StringSet.DimensionSeparator;
selectionString += Mathf.RoundToInt(selectionSize.y);
}
if (selectionSize.z != 0)
{
if (selectionString != "")
selectionString += "x";
selectionString += StringSet.DimensionSeparator;
selectionString += Mathf.RoundToInt(selectionSize.z);
}
return selectionString;
Expand All @@ -233,7 +233,7 @@ protected string SelectionString(Vector3 selectionSize)
private void SelectByTagInterface()
{
TagPickerGUI tagPicker = gameObject.AddComponent<TagPickerGUI>();
tagPicker.title = "Select by tag";
tagPicker.title = StringSet.SelectWithTagTitle;
tagPicker.handler = (byte tag) =>
{
voxelArray.ClearSelection();
Expand All @@ -245,7 +245,7 @@ private void SelectByPaintInterface()
{
FacePickerGUI facePicker = gameObject.AddComponent<FacePickerGUI>();
facePicker.voxelArray = voxelArray;
facePicker.message = "Tap to pick paint...";
facePicker.message = StringSet.SelectWithPaintInstruction;
facePicker.clearStoredSelection = false;
facePicker.pickAction = () =>
{
Expand All @@ -261,7 +261,7 @@ private void FillPaintInterface()
{
FacePickerGUI facePicker = gameObject.AddComponent<FacePickerGUI>();
facePicker.voxelArray = voxelArray;
facePicker.message = "Tap to fill paint...";
facePicker.message = StringSet.SelectFillPaintInstruction;
facePicker.onlyFaces = true; // filling object doesn't make sense
facePicker.clearStoredSelection = false;
facePicker.pickAction = () =>
Expand Down
2 changes: 1 addition & 1 deletion Assets/VoxelEditor/GUI/LoadingGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public override Rect GetRect(Rect safeRect, Rect screenRect) =>
public override void WindowGUI()
{
GUILayout.FlexibleSpace();
GUILayout.Label("Loading world...", GUIUtils.LABEL_HORIZ_CENTERED.Value);
GUILayout.Label(StringSet.LoadingWorld, GUIUtils.LABEL_HORIZ_CENTERED.Value);
GUILayout.FlexibleSpace();
}
}
2 changes: 1 addition & 1 deletion Assets/VoxelEditor/GUI/PropertiesGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ private void EntityPropertiesGUI()
clone.paint = ((ObjectEntity)singleSelectedEntity).paint.PaintOnly();
var pickerGUI = gameObject.AddComponent<FacePickerGUI>();
pickerGUI.voxelArray = voxelArray;
pickerGUI.message = StringSet.CloneIntruction;
pickerGUI.message = StringSet.CloneInstruction;
pickerGUI.pickAction = () => voxelArray.PlaceObject(clone);
}
else if (singleSelectedEntity is Substance)
Expand Down
44 changes: 43 additions & 1 deletion Assets/VoxelEditor/GUI/localization/GUIStringSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ public class GUIStringSet
"OK";
public virtual string Done =>
"Done";
public virtual string AreYouSure =>
"Are you sure?";

public virtual string DimensionSeparator =>
"x";

public virtual string LoadingWorld =>
"Loading world...";

// Main menu
public virtual string WelcomeMessage =>
Expand Down Expand Up @@ -63,12 +71,46 @@ public virtual string UntitledWorldName(System.DateTime date) =>
public virtual string Donate =>
"Donate";

// Editor action bar
public virtual string CreateObjectTitle =>
"Create";
public virtual string OpenWorldProperties =>
"World";
public virtual string SelectSubmenu =>
"Select...";
public virtual string SelectDraw =>
"Draw";
public virtual string SelectWithPaint =>
"With Paint";
public virtual string SelectFillPaint =>
"Fill Paint";
public virtual string SelectWithTag =>
"With Tag";
public virtual string OpenBevel =>
"Bevel";
public virtual string RevertChanges =>
"Revert";
public virtual string ConfirmRevertChanges =>
"Undo all changes since the world was opened?";
public virtual string SelectWithTagTitle =>
"Select by tag";
public virtual string SelectWithPaintInstruction =>
"Tap to pick paint...";
public virtual string SelectFillPaintInstruction =>
"Tap to fill paint...";

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

// Properties panel
public virtual string PropertiesDifferent =>
"different";
public virtual string CloneEntity =>
"Clone";
public virtual string CloneIntruction =>
public virtual string CloneInstruction =>
"Tap to place clone";
public virtual string DeleteEntity =>
"Delete";
Expand Down

0 comments on commit c792b8e

Please sign in to comment.