Execute BlockGame game actions only if _running is true, added localization functions and italian strings to the blockgame UI (#2601)
* BlockGamePlayerAction are only executed if _running is true, added italian localization file for blockgame UI * Added localization functions and files for BlockGame arcade. Removed unused public variable added in the previous commit. * Added new line to end of file blockgame.yml * Update Content.Client/Arcade/BlockGameMenu.cs Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> * Moved EndLeft,EndRight and SoftdropEnd actions out of the condition as per suggestion by Paul. * Added Loc.GetString() to "Nanotrasen" and "Nanotrasen Block Game" to enable transliteration of the name in other alphabets as per suggestion of Remie. Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,7 @@ using Robust.Client.UserInterface;
|
|||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ namespace Content.Client.Arcade
|
|||||||
|
|
||||||
public BlockGameMenu(BlockGameBoundUserInterface owner)
|
public BlockGameMenu(BlockGameBoundUserInterface owner)
|
||||||
{
|
{
|
||||||
Title = "Nanotrasen Block Game";
|
Title = Loc.GetString("Nanotrasen Block Game");
|
||||||
_owner = owner;
|
_owner = owner;
|
||||||
|
|
||||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
||||||
@@ -115,7 +116,7 @@ namespace Content.Client.Arcade
|
|||||||
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
||||||
};
|
};
|
||||||
|
|
||||||
menuContainer.AddChild(new Label{Text = "Highscores"});
|
menuContainer.AddChild(new Label{Text = Loc.GetString("Highscores")});
|
||||||
menuContainer.AddChild(new Control{CustomMinimumSize = new Vector2(1,10)});
|
menuContainer.AddChild(new Control{CustomMinimumSize = new Vector2(1,10)});
|
||||||
|
|
||||||
var highScoreBox = new HBoxContainer();
|
var highScoreBox = new HBoxContainer();
|
||||||
@@ -135,7 +136,7 @@ namespace Content.Client.Arcade
|
|||||||
menuContainer.AddChild(new Control{CustomMinimumSize = new Vector2(1,10)});
|
menuContainer.AddChild(new Control{CustomMinimumSize = new Vector2(1,10)});
|
||||||
_highscoreBackButton = new Button
|
_highscoreBackButton = new Button
|
||||||
{
|
{
|
||||||
Text = "Back",
|
Text = Loc.GetString("Back"),
|
||||||
TextAlign = Label.AlignMode.Center
|
TextAlign = Label.AlignMode.Center
|
||||||
};
|
};
|
||||||
_highscoreBackButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.Pause);
|
_highscoreBackButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.Pause);
|
||||||
@@ -180,7 +181,7 @@ namespace Content.Client.Arcade
|
|||||||
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
SizeFlagsVertical = SizeFlags.ShrinkCenter
|
||||||
};
|
};
|
||||||
|
|
||||||
menuContainer.AddChild(new Label{Text = "Gameover!",Align = Label.AlignMode.Center});
|
menuContainer.AddChild(new Label{Text = Loc.GetString("Gameover!"),Align = Label.AlignMode.Center});
|
||||||
menuContainer.AddChild(new Control{CustomMinimumSize = new Vector2(1,10)});
|
menuContainer.AddChild(new Control{CustomMinimumSize = new Vector2(1,10)});
|
||||||
|
|
||||||
|
|
||||||
@@ -190,7 +191,7 @@ namespace Content.Client.Arcade
|
|||||||
|
|
||||||
_finalNewGameButton = new Button
|
_finalNewGameButton = new Button
|
||||||
{
|
{
|
||||||
Text = "New Game",
|
Text = Loc.GetString("New Game"),
|
||||||
TextAlign = Label.AlignMode.Center
|
TextAlign = Label.AlignMode.Center
|
||||||
};
|
};
|
||||||
_finalNewGameButton.OnPressed += (e) =>
|
_finalNewGameButton.OnPressed += (e) =>
|
||||||
@@ -241,7 +242,7 @@ namespace Content.Client.Arcade
|
|||||||
|
|
||||||
_newGameButton = new Button
|
_newGameButton = new Button
|
||||||
{
|
{
|
||||||
Text = "New Game",
|
Text = Loc.GetString("New Game"),
|
||||||
TextAlign = Label.AlignMode.Center
|
TextAlign = Label.AlignMode.Center
|
||||||
};
|
};
|
||||||
_newGameButton.OnPressed += (e) =>
|
_newGameButton.OnPressed += (e) =>
|
||||||
@@ -253,7 +254,7 @@ namespace Content.Client.Arcade
|
|||||||
|
|
||||||
_scoreBoardButton = new Button
|
_scoreBoardButton = new Button
|
||||||
{
|
{
|
||||||
Text = "Scoreboard",
|
Text = Loc.GetString("Scoreboard"),
|
||||||
TextAlign = Label.AlignMode.Center
|
TextAlign = Label.AlignMode.Center
|
||||||
};
|
};
|
||||||
_scoreBoardButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.ShowHighscores);
|
_scoreBoardButton.OnPressed += (e) => _owner.SendAction(BlockGamePlayerAction.ShowHighscores);
|
||||||
@@ -263,7 +264,7 @@ namespace Content.Client.Arcade
|
|||||||
|
|
||||||
_unpauseButton = new Button
|
_unpauseButton = new Button
|
||||||
{
|
{
|
||||||
Text = "Unpause",
|
Text = Loc.GetString("Unpause"),
|
||||||
TextAlign = Label.AlignMode.Center,
|
TextAlign = Label.AlignMode.Center,
|
||||||
Visible = false
|
Visible = false
|
||||||
};
|
};
|
||||||
@@ -341,7 +342,7 @@ namespace Content.Client.Arcade
|
|||||||
|
|
||||||
_pauseButton = new Button
|
_pauseButton = new Button
|
||||||
{
|
{
|
||||||
Text = "Pause",
|
Text = Loc.GetString("Pause"),
|
||||||
TextAlign = Label.AlignMode.Center
|
TextAlign = Label.AlignMode.Center
|
||||||
};
|
};
|
||||||
_pauseButton.OnPressed += (e) => TryPause();
|
_pauseButton.OnPressed += (e) => TryPause();
|
||||||
@@ -413,7 +414,7 @@ namespace Content.Client.Arcade
|
|||||||
nextBlockPanel.AddChild(nextCenterContainer);
|
nextBlockPanel.AddChild(nextCenterContainer);
|
||||||
grid.AddChild(nextBlockPanel);
|
grid.AddChild(nextBlockPanel);
|
||||||
|
|
||||||
grid.AddChild(new Label{Text = "Next", Align = Label.AlignMode.Center});
|
grid.AddChild(new Label{Text = Loc.GetString("Next"), Align = Label.AlignMode.Center});
|
||||||
|
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
@@ -451,7 +452,7 @@ namespace Content.Client.Arcade
|
|||||||
holdBlockPanel.AddChild(holdCenterContainer);
|
holdBlockPanel.AddChild(holdCenterContainer);
|
||||||
grid.AddChild(holdBlockPanel);
|
grid.AddChild(holdBlockPanel);
|
||||||
|
|
||||||
grid.AddChild(new Label{Text = "Hold", Align = Label.AlignMode.Center});
|
grid.AddChild(new Label{Text = Loc.GetString("Hold"), Align = Label.AlignMode.Center});
|
||||||
|
|
||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
@@ -518,24 +519,24 @@ namespace Content.Client.Arcade
|
|||||||
{
|
{
|
||||||
var globalPlacementText = globalPlacement == null ? "-" : $"#{globalPlacement}";
|
var globalPlacementText = globalPlacement == null ? "-" : $"#{globalPlacement}";
|
||||||
var localPlacementText = localPlacement == null ? "-" : $"#{localPlacement}";
|
var localPlacementText = localPlacement == null ? "-" : $"#{localPlacement}";
|
||||||
_finalScoreLabel.Text = $"Global: {globalPlacementText}\nLocal: {localPlacementText}\nPoints: {amount}";
|
_finalScoreLabel.Text = Loc.GetString("Global") + $": {globalPlacementText}\n" + Loc.GetString("Local") + $": {localPlacementText}\n" + Loc.GetString("Points") + $": {amount}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePoints(int points)
|
public void UpdatePoints(int points)
|
||||||
{
|
{
|
||||||
_pointsLabel.Text = $"Points: {points}";
|
_pointsLabel.Text = Loc.GetString("Points") + $": {points}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateLevel(int level)
|
public void UpdateLevel(int level)
|
||||||
{
|
{
|
||||||
_levelLabel.Text = $"Level {level + 1}";
|
_levelLabel.Text = Loc.GetString("Level") + $" {level + 1}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateHighscores(List<BlockGameMessages.HighScoreEntry> localHighscores,
|
public void UpdateHighscores(List<BlockGameMessages.HighScoreEntry> localHighscores,
|
||||||
List<BlockGameMessages.HighScoreEntry> globalHighscores)
|
List<BlockGameMessages.HighScoreEntry> globalHighscores)
|
||||||
{
|
{
|
||||||
var localHighscoreText = "Station:\n";
|
var localHighscoreText = Loc.GetString("Station") + ":\n";
|
||||||
var globalHighscoreText = "Nanotrasen:\n";
|
var globalHighscoreText = Loc.GetString("Nanotrasen") + ":\n";
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
localHighscoreText += $"#{i + 1} " + (localHighscores.Count > i
|
localHighscoreText += $"#{i + 1} " + (localHighscores.Count > i
|
||||||
|
|||||||
@@ -537,21 +537,17 @@ namespace Content.Server.GameObjects.Components.Arcade
|
|||||||
private bool RotateCheck(Vector2i position) => BorderCheck(position) && LowerBoundCheck(position) && ClearCheck(position);
|
private bool RotateCheck(Vector2i position) => BorderCheck(position) && LowerBoundCheck(position) && ClearCheck(position);
|
||||||
|
|
||||||
public void ProcessInput(BlockGamePlayerAction action)
|
public void ProcessInput(BlockGamePlayerAction action)
|
||||||
|
{
|
||||||
|
if (_running)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case BlockGamePlayerAction.StartLeft:
|
case BlockGamePlayerAction.StartLeft:
|
||||||
_leftPressed = true;
|
_leftPressed = true;
|
||||||
break;
|
break;
|
||||||
case BlockGamePlayerAction.EndLeft:
|
|
||||||
_leftPressed = false;
|
|
||||||
break;
|
|
||||||
case BlockGamePlayerAction.StartRight:
|
case BlockGamePlayerAction.StartRight:
|
||||||
_rightPressed = true;
|
_rightPressed = true;
|
||||||
break;
|
break;
|
||||||
case BlockGamePlayerAction.EndRight:
|
|
||||||
_rightPressed = false;
|
|
||||||
break;
|
|
||||||
case BlockGamePlayerAction.Rotate:
|
case BlockGamePlayerAction.Rotate:
|
||||||
TrySetRotation(Next(_currentRotation, false));
|
TrySetRotation(Next(_currentRotation, false));
|
||||||
break;
|
break;
|
||||||
@@ -562,12 +558,26 @@ namespace Content.Server.GameObjects.Components.Arcade
|
|||||||
_softDropPressed = true;
|
_softDropPressed = true;
|
||||||
if (_accumulatedFieldFrameTime > Speed) _accumulatedFieldFrameTime = Speed; //to prevent jumps
|
if (_accumulatedFieldFrameTime > Speed) _accumulatedFieldFrameTime = Speed; //to prevent jumps
|
||||||
break;
|
break;
|
||||||
case BlockGamePlayerAction.SoftdropEnd:
|
|
||||||
_softDropPressed = false;
|
|
||||||
break;
|
|
||||||
case BlockGamePlayerAction.Harddrop:
|
case BlockGamePlayerAction.Harddrop:
|
||||||
PerformHarddrop();
|
PerformHarddrop();
|
||||||
break;
|
break;
|
||||||
|
case BlockGamePlayerAction.Hold:
|
||||||
|
HoldPiece();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case BlockGamePlayerAction.EndLeft:
|
||||||
|
_leftPressed = false;
|
||||||
|
break;
|
||||||
|
case BlockGamePlayerAction.EndRight:
|
||||||
|
_rightPressed = false;
|
||||||
|
break;
|
||||||
|
case BlockGamePlayerAction.SoftdropEnd:
|
||||||
|
_softDropPressed = false;
|
||||||
|
break;
|
||||||
case BlockGamePlayerAction.Pause:
|
case BlockGamePlayerAction.Pause:
|
||||||
_running = false;
|
_running = false;
|
||||||
_component.UserInterface?.SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Pause, _started));
|
_component.UserInterface?.SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Pause, _started));
|
||||||
@@ -579,9 +589,6 @@ namespace Content.Server.GameObjects.Components.Arcade
|
|||||||
_component.UserInterface?.SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Game));
|
_component.UserInterface?.SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Game));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BlockGamePlayerAction.Hold:
|
|
||||||
HoldPiece();
|
|
||||||
break;
|
|
||||||
case BlockGamePlayerAction.ShowHighscores:
|
case BlockGamePlayerAction.ShowHighscores:
|
||||||
_running = false;
|
_running = false;
|
||||||
_component.UserInterface?.SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Highscores, _started));
|
_component.UserInterface?.SendMessage(new BlockGameMessages.BlockGameSetScreenMessage(BlockGameMessages.BlockGameScreen.Highscores, _started));
|
||||||
|
|||||||
43
Resources/Locale/it-IT/blockgame.yml
Normal file
43
Resources/Locale/it-IT/blockgame.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
- msgid: New Game
|
||||||
|
msgstr: Nuova Partita
|
||||||
|
|
||||||
|
- msgid: Scoreboard
|
||||||
|
msgstr: Classifica
|
||||||
|
|
||||||
|
- msgid: Pause
|
||||||
|
msgstr: Pausa
|
||||||
|
|
||||||
|
- msgid: Unpause
|
||||||
|
msgstr: Riprendi
|
||||||
|
|
||||||
|
- msgid: Gameover!
|
||||||
|
msgstr: Partita Finita!
|
||||||
|
|
||||||
|
- msgid: Highscores
|
||||||
|
msgstr: Record
|
||||||
|
|
||||||
|
- msgid: Back
|
||||||
|
msgstr: Indietro
|
||||||
|
|
||||||
|
- msgid: Next
|
||||||
|
msgstr: Prossimo
|
||||||
|
|
||||||
|
- msgid: Hold
|
||||||
|
msgstr: Conservato
|
||||||
|
|
||||||
|
- msgid: Global
|
||||||
|
msgstr: Globale
|
||||||
|
|
||||||
|
- msgid: Local
|
||||||
|
msgstr: Locale
|
||||||
|
|
||||||
|
- msgid: Points
|
||||||
|
msgstr: Punti
|
||||||
|
|
||||||
|
- msgid: Level
|
||||||
|
msgstr: Livello
|
||||||
|
|
||||||
|
- msgid: Station
|
||||||
|
msgstr: Stazione
|
||||||
|
|
||||||
Reference in New Issue
Block a user