Skip to content

Commit d655f5d

Browse files
authored
Merge pull request #225 from ChaosEngine/dev
Dev -> Master
2 parents 472b47b + 43e1a46 commit d655f5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2464
-1099
lines changed

src/InkBall.Module/Areas/InkBall/Pages/Game.cshtml

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@inject Microsoft.AspNetCore.Authorization.IAuthorizationService authorization
44
@model GameModel
55
@{
6-
ViewData["Title"] = "Game";
6+
ViewData["Title"] = "ib:game.title";
77

88
HtmlHelpers.RenderHeaderSection(this, Url, commonUIConfigureOptions);
99

@@ -32,53 +32,50 @@
3232
surrender_win_cancel_name = "cancel";
3333
}
3434
}
35-
<h3 class="inkgame">
36-
Inball Game
37-
</h3>
35+
<h3 class="inkgame" data-i18n='ib:game.title'>Inkball Game</h3>
3836
<p class="inkgame">
3937
<!-- Debug State -->
4038
iGameID=<span id="gameID"></span>,
4139
iPlayerID=<span id="playerID"></span>,
42-
<span id="whichPlayer"></span> playing with <span id="whichColor"></span>
43-
(<span id='Player1Name'>@Model.Game.Player1?.UserName</span> vs <span id='Player2Name'>@P2Name</span>)
40+
<span id="whichPlayer"></span> <span data-i18n='ib:game.playingWith'>playing with</span> <span id="whichColor"></span>
41+
(<span id='Player1Name'>@Model.Game.Player1?.UserName</span> <span data-i18n='ib:game.vs'>vs</span> <span id='Player2Name'>@P2Name</span>)
4442
</p>
4543
<div class="container inkgame">
4644
<form action="GamesList" method="post" asp-antiforgery="true" class="row">
4745
<input type='hidden' name='GameID' />
4846
<div class="col-xs-6 col-sm-auto ps-0">
49-
<a id='Pause' href='GamesList' class="btn btn-outline-primary">pause</a>
50-
<input id='SurrenderButton' type='submit' name='action' value="@surrender_win_cancel_name" class='btn btn-outline-primary' disabled />
47+
<a id='Pause' href='GamesList' class="btn btn-outline-primary" data-i18n='ib:game.pause'>pause</a>
48+
<button id='SurrenderButton' type='submit' name='action' value="@surrender_win_cancel_name" class='btn btn-outline-primary' disabled data-i18n='ib:game.surrender'>surrender</button>
5149
</div>
5250
<div class="col-xs-6 col-sm-auto ps-0">
53-
<input id="StopAndDraw" type="button" value="Stop and Draw" class='btn btn-warning' disabled />
54-
<input id="CancelPath" type="button" value="Cancel path" class='btn btn-primary' disabled />
51+
<button id="StopAndDraw" type="button" class='btn btn-warning' disabled data-i18n='ib:game.stopAndDraw'>Stop and Draw</button>
52+
<button id="CancelPath" type="button" class='btn btn-primary' disabled data-i18n='ib:game.cancelPath'>Cancel path</button>
5553
</div>
5654
@if(bServiceModeVisible)
5755
{
5856
<fieldset id="serviceMenu" class="col-xs-6 col-sm-auto pb-1 border border-2">
59-
<legend class="mb-0 fs-6 w-auto float-none text-center">Service Menu</legend>
57+
<legend class="mb-0 fs-6 w-auto float-none text-center" data-i18n='ib:game.serviceMenu'>Service Menu</legend>
6058

61-
<div id="testArea" class="d-inline d-none dropdown dropend">
62-
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="ddlTest" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
63-
Test
64-
</button>
59+
<div class="d-inline dropdown dropend">
60+
<button class="btn btn-secondary btn-sm dropdown-toggle" type="button" id="ddlTest" data-bs-toggle="dropdown"
61+
aria-haspopup="true" aria-expanded="false" data-i18n='ib:game.smTest'>Tests</button>
6562
<ul class="dropdown-menu" aria-labelledby="ddlTest">
66-
<li><a class="dropdown-item" href="#" id="TestBuildGraph">Build current graph</a></li>
67-
<li><a class="dropdown-item" href="#" id="TestConcaveman">Concaveman</a></li>
68-
<li><a class="dropdown-item" href="#" id="TestMarkAllCycles">Mark all cycles</a></li>
69-
<li><a class="dropdown-item" href="#" id="TestGroupPoints">Group points recurse</a></li>
70-
<li><a class="dropdown-item" href="#" id="TestFindSurroundablePoints">Find surroundable points</a></li>
71-
<li><a class="dropdown-item" href="#" id="TestDFS2">DFS 2</a></li>
72-
<li><a class="dropdown-item" href="#" id="FloodFill">Flood fill</a></li>
73-
<li><a class="dropdown-item" href="#" id="AStar">A-Star</a></li>
74-
<li><a class="dropdown-item" href="#" id="Clustering">Clustering</a></li>
63+
<li><a class="dropdown-item" href="#" id="TestBuildGraph" data-i18n='ib:game.testBuildGraph'>Build current graph</a></li>
64+
<li><a class="dropdown-item" href="#" id="TestConcaveman" data-i18n='ib:game.testConcaveman'>Concaveman</a></li>
65+
<li><a class="dropdown-item" href="#" id="TestMarkAllCycles" data-i18n='ib:game.testMarkAllCycles'>Mark all cycles</a></li>
66+
<li><a class="dropdown-item" href="#" id="TestGroupPoints" data-i18n='ib:game.testGroupPoints'>Group points recurse</a></li>
67+
<li><a class="dropdown-item" href="#" id="TestFindSurroundablePoints" data-i18n='ib:game.testFindSurroundablePoints'>Find surroundable points</a></li>
68+
<li><a class="dropdown-item" href="#" id="TestDFS2" data-i18n='ib:game.testDFS2'>DFS 2</a></li>
69+
<li><a class="dropdown-item" href="#" id="FloodFill" data-i18n='ib:game.floodFill'>Flood fill</a></li>
70+
<li><a class="dropdown-item" href="#" id="AStar" data-i18n='ib:game.aStar'>A-Star</a></li>
71+
<li><a class="dropdown-item" href="#" id="Clustering" data-i18n='ib:game.clustering'>Clustering</a></li>
7572
</ul>
7673
</div>
7774

7875
<input id="cbSrvMnuRed" type="checkbox" class="btn-check" name="options" autocomplete="off">
79-
<label class="btn btn-outline-danger btn-sm" for="cbSrvMnuRed">Place Red</label>
76+
<label class="btn btn-outline-danger btn-sm" for="cbSrvMnuRed" data-i18n='ib:game.placeRed'>Place Red</label>
8077
<input id="cbSrvMnuBlue" type="checkbox" class="btn-check" name="options" autocomplete="off">
81-
<label class="btn btn-outline-primary btn-sm" for="cbSrvMnuBlue">Place Blue</label>
78+
<label class="btn btn-outline-primary btn-sm" for="cbSrvMnuBlue" data-i18n='ib:game.placeBlue'>Place Blue</label>
8279
</fieldset>
8380
}
8481
</form>
@@ -94,14 +91,16 @@
9491
<svg id="screen" class="col-auto p-0 mb-3 mx-auto boardsize-@(Model.Game.iBoardWidth)x@(Model.Game.iBoardHeight)">
9592
</svg>
9693
<div class="col msgchat" data-otherplayerid="@(Model.Game.GetOtherPlayer()?.iId)">
94+
<ul id="messagesList" class="list-group list-group-flush pt-1"></ul>
9795
<div class="input-group">
9896
<input id="messageInput" type="text" class="form-control" placeholder="Message..." aria-label="Message to send" aria-describedby="sendButton"
99-
onkeyup="document.querySelector('#sendButton').disabled = this.value == ''" disabled />
97+
onkeyup="document.querySelector('#sendButton').disabled = this.value == ''" disabled
98+
data-i18n='[aria-label]ib:game.message2Send;[placeholder]ib:game.messageDot3' />
10099
<div class="input-group-append ps-2">
101-
<input id="sendButton" type="button" value="Send Message" class="btn btn-secondary" disabled />
100+
<button id="sendButton" type="button" class="btn btn-secondary" disabled
101+
data-i18n='ib:game.sendMessage'>Send Message</button>
102102
</div>
103103
</div>
104-
<ul id="messagesList" class="list-group list-group-flush pt-1"></ul>
105104
</div>
106105
</div>
107106
</div>
@@ -115,18 +114,20 @@
115114
}
116115
</environment>
117116
<environment exclude="Development">
118-
<script src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr@8.0.7/dist/browser/signalr.min.js" integrity="sha256-4opyCjWbN8sBV1jVQ/kIcw7Vu+R42wlQa7aIfxgxNTg=" crossorigin="anonymous"></script>
117+
<script src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr@9.0.6/dist/browser/signalr.min.js" integrity="sha256-jraBfD/OIUtdfdCuNkkhYV/bu9rQjvBwP9SvJjPfNFA=" crossorigin="anonymous"></script>
119118
@if (useMessagePackBinaryTransport)
120119
{
121120
<script type='module' src="https://cdn.jsdelivr.net/npm/[email protected]/dist/msgpack5.min.js" integrity="sha256-AxiBUMElqJXwwKZro5eMMWVExjtxeZSUQ/4nC4oCU2E=" crossorigin="anonymous"></script>
122-
<script type='module' src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr-protocol-msgpack@8.0.7/dist/browser/signalr-protocol-msgpack.min.js" integrity="sha256-3vx/CZAhuWYVd8BYbOG6FnZXX9eUtP2ppROxUGMcydc=" crossorigin="anonymous"></script>
121+
<script type='module' src="https://cdn.jsdelivr.net/npm/@@microsoft/signalr-protocol-msgpack@9.0.6/dist/browser/signalr-protocol-msgpack.min.js" integrity="sha256-zkuXgPxCwwSmRkPySavNgcUMzdRT9n+F8+M/5U0yVU4=" crossorigin="anonymous"></script>
123122
}
124123
</environment>
125124
<script type='module'>
126125
import { InkBallGame } from "@Url.Content(Constants.WwwIncludeInkballJS)";
127-
126+
127+
window.addEventListener('DOMContentLoaded', InkBallGame.OnGameDOMContentLoaded);
128+
128129
window.addEventListener('load', async () => {
129-
const gameOptions = {
130+
await InkBallGame.OnGameLoad({
130131
inkBallHubName: '@hubName',
131132
iGameID: @Model.Game.iId,
132133
iPlayerID: @Model.Player.iId,
@@ -151,9 +152,7 @@
151152
@:PointsAsJavaScriptArray: null,
152153
@:PathsAsJavaScriptArray: null
153154
}
154-
};
155-
156-
await InkBallGame.OnLoad(gameOptions);
155+
});
157156
});
158157
159158
window.addEventListener('beforeunload', InkBallGame.OnBeforeUnload);

src/InkBall.Module/Areas/InkBall/Pages/Game.cshtml.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public GameModel(GamesContext dbContext, ILogger<BasePageModel> logger, IOptions
5454
public async Task<IActionResult> OnGetAsync()
5555
{
5656
if (!GameHub.WebSocketAllowedOrigins.Any())
57-
GameHub.WebSocketAllowedOrigins.Add($"{Request.Scheme}://{Request.Host}");
57+
GameHub.WebSocketAllowedOrigins.Add(Request.Host.Host);
5858
else
59-
GameHub.WebSocketAllowedOrigins.AddOrUpdate($"{Request.Scheme}://{Request.Host}");
59+
GameHub.WebSocketAllowedOrigins.AddOrUpdate(Request.Host.Host);
6060

6161
//https://developer.chrome.com/blog/enabling-shared-array-buffer/
6262
Response.Headers.Append("Cross-Origin-Embedder-Policy", "require-corp");
@@ -68,7 +68,7 @@ public async Task<IActionResult> OnGetAsync()
6868

6969
if (Game == null)
7070
{
71-
Message = "No active game for you";
71+
Message = "No active game for you;noActiveGame";
7272

7373
return RedirectToPage(HomeModel.ASPX);
7474
}
@@ -89,9 +89,9 @@ public async Task<IActionResult> OnGetViewAsync([FromServices] IAuthorizationSer
8989

9090

9191
if (!GameHub.WebSocketAllowedOrigins.Any())
92-
GameHub.WebSocketAllowedOrigins.Add($"{Request.Scheme}://{Request.Host}");
92+
GameHub.WebSocketAllowedOrigins.Add(Request.Host.Host);
9393
else
94-
GameHub.WebSocketAllowedOrigins.AddOrUpdate($"{Request.Scheme}://{Request.Host}");
94+
GameHub.WebSocketAllowedOrigins.AddOrUpdate(Request.Host.Host);
9595

9696
//https://developer.chrome.com/blog/enabling-shared-array-buffer/
9797
Response.Headers.Append("Cross-Origin-Embedder-Policy", "require-corp");
@@ -100,7 +100,7 @@ public async Task<IActionResult> OnGetViewAsync([FromServices] IAuthorizationSer
100100

101101
if (!ModelState.IsValid)//model.GameID <= 0
102102
{
103-
Message = "View only: Bad GameID";
103+
Message = "View only: Bad GameID;viewOnlyBadGameID";
104104

105105
return RedirectToPage(HomeModel.ASPX);
106106
}
@@ -113,7 +113,7 @@ public async Task<IActionResult> OnGetViewAsync([FromServices] IAuthorizationSer
113113
!int.TryParse(User.FindFirstValue(nameof(InkBalPlayerId)), out var inkBallPlayerId) || inkBallPlayerId <= 0 ||
114114
Game?.iPlayer1Id == inkBallPlayerId || Game?.iPlayer2Id == inkBallPlayerId)
115115
{
116-
Message = "View only: It is your game, or bad GameID";
116+
Message = "View only: It is your game, or bad GameID;viewOnlyYourGame";
117117

118118
return RedirectToPage(HomeModel.ASPX);
119119
}

src/InkBall.Module/Areas/InkBall/Pages/GamesList.cshtml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@inject Microsoft.AspNetCore.Authorization.IAuthorizationService authorization
55
@model GamesListModel
66
@{
7-
ViewData["Title"] = "Game list";
7+
ViewData["Title"] = "ib:list.title";
88

99
HtmlHelpers.RenderHeaderSection(this, Url, commonUIConfigureOptions);
1010

@@ -18,16 +18,16 @@
1818

1919
<div class='container inkgames'>
2020
<div class="table-responsive">
21-
<a href='Home' class='btn btn-outline-primary mt-4 m-sm-1'>Home</a>
21+
<a href='Home' class='btn btn-outline-primary mt-4 m-sm-1' data-i18n='ib:list.home'>Home</a>
2222
<table class='table game_tab'>
2323
<thead>
2424
<tr>
2525
<th scope='row'>#</th>
26-
<th scope='col'>Player 1</th>
27-
<th scope='col'>Player 2</th>
28-
<th scope='col'>Game state</th>
29-
<th scope='col'>Action</th>
30-
<th scope='col'>Game type</th>
26+
<th scope='col' data-i18n='ib:game.player1'>Player 1</th>
27+
<th scope='col' data-i18n='ib:game.player2'>Player 2</th>
28+
<th scope='col' data-i18n='ib:list.gameState'>Game state</th>
29+
<th scope='col' data-i18n='ib:list.action'>Action</th>
30+
<th scope='col' data-i18n='ib:list.gameType'>Game type</th>
3131
</tr>
3232
</thead>
3333
<tbody>
@@ -57,41 +57,41 @@
5757
switch (game.GameState)
5858
{
5959
case InkBallGame.GameStateEnum.AWAITING:
60-
<td class='fst-italic gtd'>waiting for another player</td>
60+
<td class='fst-italic gtd' data-i18n='ib:list.waiting'>waiting for another player</td>
6161
<td class='gtd'>
6262
@if (bIsMyOwnGame)
6363
{
64-
<a href='Game' class='btn btn-outline-primary'>Continue</a>
64+
<a href='Game' class='btn btn-outline-primary' data-i18n='ib:home.continue'>Continue</a>
6565
}
6666
else if (!bIsCurrentGameOk)
6767
{
6868
<form method='post'>
6969
<input type='hidden' name='GameID' value='@game.iId' />
70-
<input type='submit' name='action' value='Join' class='btn btn-outline-primary' />
70+
<button type='submit' name='action' value='Join' class='btn btn-outline-primary' data-i18n='ib:list.join'>Join</button>
7171
</form>
7272
}
7373
</td>
7474
break;
7575

7676
case InkBallGame.GameStateEnum.ACTIVE:
77-
<td class='fst-italic gtd'>game in progress</td>
77+
<td class='fst-italic gtd' data-i18n='ib:list.inProgress'>game in progress</td>
7878
<td class='gtd'>
7979
@if (bIsMyOwnGame)
8080
{
81-
<a href='Game' class="btn btn-outline-primary">Continue</a>
81+
<a href='Game' class="btn btn-outline-primary" data-i18n='ib:home.continue'>Continue</a>
8282
}
8383
else if (!bIsCurrentGameOk && bCanViewOtherPlayerGames)
8484
{
85-
<a href='Game?handler=View&[email protected]'>View only</a>
85+
<a href='Game?handler=View&[email protected]' data-i18n='ib:list.viewOnly'>View only</a>
8686
}
8787
</td>
8888
break;
8989

9090
case InkBallGame.GameStateEnum.INACTIVE:
91-
<td class='fst-italic gtd' colspan="2">game inactive</td>
91+
<td class='fst-italic gtd' colspan="2" data-i18n='ib:list.gameInactive'>game inactive</td>
9292
break;
9393
case InkBallGame.GameStateEnum.FINISHED:
94-
<td class='fst-italic gtd' colspan="2">game finished</td>
94+
<td class='fst-italic gtd' colspan="2" data-i18n='ib:list.gameFinished'>game finished</td>
9595
break;
9696
default:
9797
throw new ArgumentNullException(nameof(game.GameState), "bad game state");
@@ -100,16 +100,16 @@
100100
switch (game.GameType)
101101
{
102102
case InkBallGame.GameTypeEnum.FIRST_5_ADVANTAGE_PATHS:
103-
<td class='fst-italic gtd'>FIRST 5 ADVANTAGE PATHS</td>
103+
<td class='fst-italic gtd' data-i18n='ib:list.gameTypes.advantageOf5'>FIRST 5 ADVANTAGE PATHS</td>
104104
break;
105105
case InkBallGame.GameTypeEnum.FIRST_5_CAPTURES:
106-
<td class='fst-italic gtd'>FIRST 5 CAPTURES</td>
106+
<td class='fst-italic gtd' data-i18n='ib:list.gameTypes.first5Captures'>FIRST 5 CAPTURES</td>
107107
break;
108108
case InkBallGame.GameTypeEnum.FIRST_5_PATHS:
109-
<td class='fst-italic gtd'>FIRST 5 PATHS</td>
109+
<td class='fst-italic gtd' data-i18n='ib:list.gameTypes.first5Paths'>FIRST 5 PATHS</td>
110110
break;
111111
case InkBallGame.GameTypeEnum.FIRST_CAPTURE:
112-
<td class='fst-italic gtd'>FIRST CAPTURE</td>
112+
<td class='fst-italic gtd' data-i18n='ib:list.gameTypes.firstCapture'>FIRST CAPTURE</td>
113113
break;
114114
default:
115115
throw new ArgumentNullException(nameof(game.GameType), "bad game type");
@@ -122,7 +122,7 @@
122122
{
123123
<tr>
124124
<td colspan="6" class="h4 p-3 text-center gtd-nogame">
125-
<span>↓↓↓</span> No games, create below
125+
<span>↓↓↓</span> <span data-i18n='ib:list.noGamesCreate'>No games, create below</span>
126126
</td>
127127
</tr>
128128
}
@@ -133,37 +133,37 @@
133133
{
134134
<form method='post' class="was-validated">
135135
<fieldset class="g-3">
136-
<legend class="col-sm-12 col-md-4 col-lg-4 col-xl-3">New game creation</legend>
137-
<div class="row" role="group" aria-label="New game options">
136+
<legend class="col-sm-12 col-md-4 col-lg-4 col-xl-3" data-i18n='ib:list.newGameLeg'>New game creation</legend>
137+
<div class="row" role="group" aria-label="New game options" data-i18n='[aria-label]ib:list.newGameOpts'>
138138
<div class="col-sm-12 col-md-4 col-lg-4 col-xl-3">
139139
<select name='GameType' id='GameType' class="form-select" required>
140-
<option value='' selected='selected'>Choose game type</option>
141-
<optgroup label='Game types'>
142-
<option value='0'>First capture wins</option>
143-
<option value='1'>First 5 captures wins</option>
144-
<option value='2'>First 5 paths wins</option>
145-
<option value='3'>Advantage of 5 paths wins</option>
140+
<option value='' selected='selected' data-i18n='ib:home.chooseGameType'>Choose game type</option>
141+
<optgroup label='Game types' data-i18n='[label]ib:home.gameTypes.name'>
142+
<option value='0' data-i18n='ib:home.gameTypes.firstCapture'>First capture wins</option>
143+
<option value='1' data-i18n='ib:home.gameTypes.first5Captures'>First 5 captures wins</option>
144+
<option value='2' data-i18n='ib:home.gameTypes.first5Paths'>First 5 paths wins</option>
145+
<option value='3' data-i18n='ib:home.gameTypes.advantageOf5'>Advantage of 5 paths wins</option>
146146
</optgroup>
147147
</select>
148-
<div class="invalid-feedback">Invalid game type</div>
148+
<div class="invalid-feedback" data-i18n='ib:home.chooseGameType'>Invalid game type</div>
149149
</div>
150150
<div class="col-sm-12 col-md-4 col-lg-4 col-xl-3">
151151
<select name='BoardSize' id='BoardSize' class="form-select" required>
152-
<option value='' selected='selected'>Choose board size</option>
153-
<optgroup label='Board sizes'>
152+
<option value='' selected='selected' data-i18n='ib:home.boardSize.chooseBoardSize'>Choose board size</option>
153+
<optgroup label='Board sizes' data-i18n='[label]ib:home.boardSize.boardSizes'>
154154
<option value='20'>20 x 26</option>
155155
<option value='40'>40 x 52</option>
156156
<option value='64'>64 x 64</option>
157157
</optgroup>
158158
</select>
159-
<div class="invalid-feedback">Invalid bard size</div>
159+
<div class="invalid-feedback" data-i18n='ib:home.boardSize.chooseBoardSize'>Invalid board size</div>
160160
</div>
161161
<div class="col-sm-12 col-md-auto col-xl-3 form-check form-switch ps-2">
162162
<input type="checkbox" class="form-check-input form-control-input mx-1" name="CpuOponent" id="CpuOponent" />
163-
<label class="form-check-label" for="CpuOponent">Play against CPU</label>
163+
<label class="form-check-label" for="CpuOponent" data-i18n='ib:home.playAgainstCPU'>Play against CPU</label>
164164
</div>
165165
<div class="col-sm-12 col-md-auto">
166-
<input type='submit' name='action' value='New game' class='btn btn-primary' />
166+
<button type='submit' name='action' value='New game' class='btn btn-primary' data-i18n='ib:home.newGame'>New game</button>
167167
</div>
168168
</div>
169169
</fieldset>
@@ -174,5 +174,5 @@
174174
<script type='module'>
175175
import { ListOnLoad } from "@Url.Content(Constants.WwwIncludeInkballJS)";
176176
177-
ListOnLoad();
177+
ListOnLoad('@Model.Message');
178178
</script>

0 commit comments

Comments
 (0)