Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localization #20

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .localization/en-pt/murder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Bystander": "Scallywag",
"Bystander.Help.1": "Thar be a butcher on the loose. Don't get scuttled!",
"Bystander.Help.2": "Thar be a butcher on the loose. Find 'n scuttle 'im!",
"Bystander.Weapon": "wit' a secret weapon",
"Bystander.Win": "The Scallywags win!",
"Murderer": "Butcher",
"Murderer.Help": "Scuttle everyone 'n don't get caught.",
"Murderer.Win": "The Butcher wins!",
"Revolver": "Flintlock pistol",
"Knife": "Cutlass",
"Scoreboard.Players": "Pirates",
"Scoreboard.Name": "Name",
"Scoreboard.Clues": "Booty",
"Scoreboard.Ping": "Ping",
"MapVote.Title": "Map vote",
"MapVote.Subtitle": "Choose yer next map"
}
18 changes: 18 additions & 0 deletions .localization/en/murder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Bystander": "Bystander",
"Bystander.Help.1": "There is a murderer on the loose. Don't get killed!",
"Bystander.Help.2": "There is a murderer on the loose. Find and kill him!",
"Bystander.Weapon": "with a secret weapon",
"Bystander.Win": "The Bystanders win!",
"Murderer": "Murderer",
"Murderer.Help": "Kill everyone and don't get caught.",
"Murderer.Win": "The Murderer wins!",
"Revolver": "Revolver",
"Knife": "Knife",
"Scoreboard.Players": "Players",
"Scoreboard.Name": "Name",
"Scoreboard.Clues": "Clues",
"Scoreboard.Ping": "Ping",
"MapVote.Title": "Map vote",
"MapVote.Subtitle": "Choose your next map"
}
2 changes: 1 addition & 1 deletion code/Player/IEntityHint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public interface IEntityHint
/// </summary>
Panel DisplayHint( Player player )
{
return new UI.Hint() { HintText = DisplayInfo.For( (Entity)this ).Name };
return new UI.Hint() { HintText = $"#{DisplayInfo.For( (Entity)this ).Name}" };
}
}
8 changes: 4 additions & 4 deletions code/Player/Player.Hints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private void DisplayEntityHints()

if ( !player.IsFirstPersonMode || !player.TimeUntilClean )
{
DeleteHint();
DeleteHint( true );
return;
}

Expand All @@ -29,7 +29,7 @@ private void DisplayEntityHints()
}

if ( hint == _currentHint )
return;
return;

DeleteHint();

Expand All @@ -40,9 +40,9 @@ private void DisplayEntityHints()
_currentHint = hint;
}

private static void DeleteHint()
private static void DeleteHint( bool immediate = false )
{
_currentHintPanel?.Delete();
_currentHintPanel?.Delete( immediate );
_currentHintPanel = null;

_currentHint = null;
Expand Down
2 changes: 1 addition & 1 deletion code/States/MapSelectionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override void OnTimeUp()

protected override void OnStart()
{
Game.RootPanel?.AddChild<UI.MapSelect>();
Game.RootPanel?.AddChild<UI.MapVote>();
}

[ConCmd.Server]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@namespace Murder.UI

@attribute [StyleSheet("UI/Game/MapSelect/MapIcon.scss")]
@attribute [StyleSheet("UI/Game/MapVote/MapIcon.scss")]

@if (_data is null)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

@namespace Murder.UI

@attribute [StyleSheet("UI/Game/MapSelect/MapSelect.scss")]
@attribute [StyleSheet("UI/Game/MapVote/MapVote.scss")]

<root class="fullscreen-dark-background">
<div class="inner text-shadow">
<div class="header">
<div class="left">
<text class="title">Map Vote</text>
<text class="subtitle">Choose your next map</text>
<text class="title">#MapVote.Title</text>
<text class="subtitle">#MapVote.Subtitle</text>
</div>
<div class="right">
<text class="countdown">@GameState.Current.TimeLeftFormatted</text>
Expand All @@ -31,7 +31,7 @@
{
private Panel Maps { get; set; }

public MapSelect()
public MapVote()
{
// Delete unneeded UI elements.
foreach (var panel in Game.RootPanel.Children.ToList())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MapSelect
MapVote
{
pointer-events: all;
transition: all 0.15s ease-out;
Expand Down
2 changes: 1 addition & 1 deletion code/UI/Game/PostRoundPopup/PostRoundPopup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<root class="text-shadow">
<div class="container">
<text class="header" style="color: @WinningRole.GetColor().Hex">
@(WinningRole == Role.Murderer ? "The Murderer wins!" : "The Bystanders win!")
@(WinningRole == Role.Murderer ? "#Murderer.Win" : "#Bystander.Win")
</text>
<div class="content">
@{
Expand Down
6 changes: 3 additions & 3 deletions code/UI/Game/RoundStartPopup/RoundStartPopup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<text class="title">You are a @player.Role.GetTitle()</text>
@if (player.Carriable is Revolver)
{
<label class="subtitle">with a secret weapon.</label>
<label class="subtitle">#Bystander.Weapon</label>
}
<text>@HelpText()</text>
</root>
Expand All @@ -40,8 +40,8 @@

return player.Role switch
{
Role.Murderer => "Kill everyone and don't get caught.",
Role.Bystander => $"There is a murderer on the loose. {(player.Carriable is Revolver ? "Find and kill him" : "Dont get killed")}!",
Role.Murderer => "#Murderer.Help",
Role.Bystander => player.Carriable is Revolver ? "#Bystander.Help.2" : "Bystander.Help.1",
Role.None => string.Empty,
_ => string.Empty
};
Expand Down
13 changes: 6 additions & 7 deletions code/UI/Game/Scoreboard/ScoreboardGroup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
@attribute [StyleSheet("UI/Game/Scoreboard/ScoreboardGroup.scss")]

<root class="text-shadow header rounded-top background-color-primary">
<text class="name" text="Players" />
<label class="name">#Scoreboard.Players</label>
@if (GameState.Current is PostRound)
{
<div>
<text class="stat" text="Name"/>
<text class="stat" text="Clues"/>
</div>
<label class="stat">#Scoreboard.Name</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Label fix the spacing that you get when inserting inbetween tags?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@matekdev matekdev Feb 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be fine nvm, I'm assuming you checked.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I assume it's fixed. Either way I wanted to remove that annoying error with the text label.

<label class="stat">#Scoreboard.Clues</label>
}
<text class="stat" text="Ping"/>
<label class="stat">#Scoreboard.Ping</label>
</root>

@code {
@code
{
protected override int BuildHash()
{
return HashCode.Combine(GameState.Current is PostRound);
Expand Down
5 changes: 3 additions & 2 deletions code/UI/Player/PlayerInfo.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<text class="name" style="color: @player.Color.Hex" [email protected] />
@if (player.Role != Role.None)
{
<div><text class="role" style="color: @player.Role.GetColor().Hex" text=@player.Role.GetTitle() /></div>
<label class="role" style="color: @player.Role.GetColor().Hex">#@player.Role.GetTitle()</label>
}
</div>
<div>
Expand All @@ -38,6 +38,7 @@
protected override int BuildHash()
{
var player = Hud.DisplayedPlayer;
return HashCode.Combine(player.IsAlive(), player.Color.GetHashCode(), player.Role.GetHashCode(), player.Clues);

return HashCode.Combine(player.IsAlive(), player.Color, player.Role, player.Clues);
}
}