Skip to content

Commit

Permalink
Localized strings for help menu; #377
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Jan 14, 2024
1 parent 677909b commit ce65647
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 37 deletions.
3 changes: 2 additions & 1 deletion Assets/Menu/MenuGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public override void WindowGUI()
if (selection == 0)
{
TutorialGUI.StartTutorial(Tutorials.INTRO_TUTORIAL, null, null, null);
HelpGUI.OpenDemoWorld(StringSet.IntroTutorialWorldName, "Templates/indoor");
HelpGUI.OpenDemoWorld(StringSet.TutorialWorldName(StringSet.TutorialIntro),
"Templates/indoor");
}
else if (selection == 1)
{
Expand Down
74 changes: 41 additions & 33 deletions Assets/VoxelEditor/GUI/HelpGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

public class HelpGUI : GUIPanel
{
private static readonly string[] DEMO_WORLD_NAMES = new string[]
{ "Doors", "Hovercraft", "Character AI", "Platform Game", "Shapes", "Logic", "Impossible Hallway", "Conveyor", "Ball Pit" };
private static readonly string[] DEMO_WORLD_FILES = new string[]
{ "doors", "hovercraft", "ai", "platforms", "shapes", "logic", "impossible_hallway", "conveyor", "ball_pit" };

public VoxelArrayEditor voxelArray;
public TouchListener touchListener;

Expand All @@ -20,14 +15,15 @@ public class HelpGUI : GUIPanel

public void Start()
{
title = "Help";
title = StringSet.HelpMenuTitle;
}

public override void WindowGUI()
{
int oldTab = tab;
tab = GUILayout.SelectionGrid(tab,
new string[] { "Tutorials", "Demo Worlds" }, 2, StyleSet.buttonTab);
new string[] { StringSet.HelpTutorials, StringSet.HelpDemoWorlds }, 2,
StyleSet.buttonTab);
if (oldTab != tab)
{
scroll = Vector2.zero;
Expand All @@ -43,52 +39,64 @@ public override void WindowGUI()

private void TutorialsTab()
{
if (HelpButton("Introduction"))
StartTutorial(Tutorials.INTRO_TUTORIAL, "Introduction", forceIndoor: true);
if (HelpButton("Painting"))
StartTutorial(Tutorials.PAINT_TUTORIAL, "Painting");
if (HelpButton("Bevels"))
StartTutorial(Tutorials.BEVEL_TUTORIAL, "Bevels");
if (HelpButton("Substances"))
StartTutorial(Tutorials.SUBSTANCE_TUTORIAL, "Substances", forceIndoor: true);
if (HelpButton("Objects"))
StartTutorial(Tutorials.OBJECT_TUTORIAL, "Objects");
if (HelpButton("Tips and Shortcuts"))
if (HelpButton(StringSet.TutorialIntro))
StartTutorial(Tutorials.INTRO_TUTORIAL, StringSet.TutorialIntro, forceIndoor: true);
if (HelpButton(StringSet.TutorialPainting))
StartTutorial(Tutorials.PAINT_TUTORIAL, StringSet.TutorialPainting);
if (HelpButton(StringSet.TutorialBevels))
StartTutorial(Tutorials.BEVEL_TUTORIAL, StringSet.TutorialBevels);
if (HelpButton(StringSet.TutorialSubstances))
StartTutorial(Tutorials.SUBSTANCE_TUTORIAL,
StringSet.TutorialSubstances, forceIndoor: true);
if (HelpButton(StringSet.TutorialObjects))
StartTutorial(Tutorials.OBJECT_TUTORIAL, StringSet.TutorialObjects);
if (HelpButton(StringSet.TutorialTips))
{
LargeMessageGUI.ShowLargeMessageDialog(gameObject, StringSet.TutorialTipsAndShortcuts);
LargeMessageGUI.ShowLargeMessageDialog(gameObject, StringSet.TutorialTipsMessage);
Destroy(this);
}
if (HelpButton("Advanced Game Logic 1"))
if (HelpButton(StringSet.TutorialAdvancedGameLogic1))
{
StartTutorial(Tutorials.ADVANCED_GAME_LOGIC_TUTORIAL_1);
OpenDemoWorld("Tutorial - Advanced game logic 1", "Tutorials/advanced_game_logic_1");
OpenDemoWorld(StringSet.TutorialWorldName(StringSet.TutorialAdvancedGameLogic1),
"Tutorials/advanced_game_logic_1");
}
if (HelpButton("Advanced Game Logic 2"))
StartTutorial(Tutorials.ADVANCED_GAME_LOGIC_TUTORIAL_2, "Advanced game logic 2", forceIndoor: true);
if (HelpButton(StringSet.TutorialAdvancedGameLogic2))
StartTutorial(Tutorials.ADVANCED_GAME_LOGIC_TUTORIAL_2,
StringSet.TutorialAdvancedGameLogic2, forceIndoor: true);
}

private void DemoWorldsTab()
{
for (int i = 0; i < DEMO_WORLD_NAMES.Length; i++)
{
if (HelpButton(DEMO_WORLD_NAMES[i]))
{
OpenDemoWorld("Demo - " + DEMO_WORLD_NAMES[i],
"Demos/" + DEMO_WORLD_FILES[i]);
Destroy(this);
}
}
DemoWorldButton(StringSet.DemoDoors, "doors");
DemoWorldButton(StringSet.DemoHovercraft, "hovercraft");
DemoWorldButton(StringSet.DemoAI, "ai");
DemoWorldButton(StringSet.DemoPlatforms, "platforms");
DemoWorldButton(StringSet.DemoShapes, "shapes");
DemoWorldButton(StringSet.DemoLogic, "logic");
DemoWorldButton(StringSet.DemoImpossibleHallway, "impossible_hallway");
DemoWorldButton(StringSet.DemoConveyor, "conveyor");
DemoWorldButton(StringSet.DemoBallPit, "ball_pit");
}

private bool HelpButton(string text) => GUILayout.Button(text, StyleSet.buttonLarge);

private void DemoWorldButton(string name, string file)
{
if (HelpButton(name))
{
OpenDemoWorld(StringSet.DemoWorldName(name), "Demos/" + file);
Destroy(this);
}
}

private void StartTutorial(TutorialPageFactory[] tutorial, string worldName = null,
bool forceIndoor = false)
{
TutorialGUI.StartTutorial(tutorial, gameObject, voxelArray, touchListener);
if (worldName != null && (voxelArray == null ||
(voxelArray.type != VoxelArray.WorldType.INDOOR && forceIndoor)))
OpenDemoWorld("Tutorial - " + worldName, "Templates/indoor");
OpenDemoWorld(StringSet.TutorialWorldName(worldName), "Templates/indoor");
Destroy(this);
}

Expand Down
50 changes: 47 additions & 3 deletions Assets/VoxelEditor/GUI/localization/GUIStringSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public class GUIStringSet
"A world with that name already exists.";
public virtual string UntitledWorldName(System.DateTime date) =>
$"Untitled {date:yyyy-MM-dd HHmmss}";
public virtual string IntroTutorialWorldName =>
"Tutorial - Introduction";

// Main menu overflow
public virtual string OpenHelp =>
Expand All @@ -64,6 +62,52 @@ public class GUIStringSet
"Videos";
public virtual string Donate =>
"Donate";

// Help menu
public virtual string HelpMenuTitle =>
"Help";
public virtual string HelpTutorials =>
"Tutorials";
public virtual string HelpDemoWorlds =>
"Demo Worlds";
public virtual string TutorialWorldName(string name) =>
$"Tutorial - {name}";
public virtual string DemoWorldName(string name) =>
$"Demo - {name}";
public virtual string TutorialIntro =>
"Introduction";
public virtual string TutorialPainting =>
"Painting";
public virtual string TutorialBevels =>
"Bevels";
public virtual string TutorialSubstances =>
"Substances";
public virtual string TutorialObjects =>
"Objects";
public virtual string TutorialTips =>
"Tips and Shortcuts";
public virtual string TutorialAdvancedGameLogic1 =>
"Advanced Game Logic 1";
public virtual string TutorialAdvancedGameLogic2 =>
"Advanced Game Logic 2";
public virtual string DemoDoors =>
"Doors";
public virtual string DemoHovercraft =>
"Hovercraft";
public virtual string DemoAI =>
"Character AI";
public virtual string DemoPlatforms =>
"Platform Game";
public virtual string DemoShapes =>
"Shapes";
public virtual string DemoLogic =>
"Logic";
public virtual string DemoImpossibleHallway =>
"Impossible Hallway";
public virtual string DemoConveyor =>
"Conveyor";
public virtual string DemoBallPit =>
"Ball Pit";

// Tutorial messages...
// Tutorials use <i>italics</i> to mark commands for the user.
Expand Down Expand Up @@ -203,7 +247,7 @@ public class GUIStringSet
"If you build some obstacles, you'll notice that the ball can float and move through walls. <i>Add a Character behavior to fix this. (check the Physics tab)</i>";
public virtual string TutorialObjectNext =>
"Read the <i>Advanced Game Logic</i> tutorial to learn how to add more complex interactivity to games.";
public virtual string TutorialTipsAndShortcuts =>
public virtual string TutorialTipsMessage =>
@"• Double tap to select an entire wall. The selection will be bounded by already-selected faces.
• Triple tap a face to select <i>all</i> faces connected to it. The selection will be bounded by already-selected faces.
• Triple tap a substance to select the entire substance.
Expand Down

0 comments on commit ce65647

Please sign in to comment.