...
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="simulation-layout">
|
<div class="simulation-layout" tabindex="0" @onkeydown="HandleKeyDown" @ref="layoutDiv">
|
||||||
<div class="sim-controls d-flex align-items-center justify-content-between mb-3 flex-wrap gap-2">
|
<div class="sim-controls d-flex align-items-center justify-content-between mb-3 flex-wrap gap-2">
|
||||||
<div class="d-flex align-items-center gap-2">
|
<div class="d-flex align-items-center gap-2">
|
||||||
<button class="btn btn-outline-light btn-sm" @onclick="PrevTurn" disabled="@(SimService.Data.CurrentTurn <= 0)">
|
<button class="btn btn-outline-light btn-sm" @onclick="PrevTurn" disabled="@(SimService.Data.CurrentTurn <= 0)">
|
||||||
@@ -263,6 +263,7 @@ else
|
|||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
private ElementReference layoutDiv;
|
||||||
private TurnEvent? CurrentEvent => SimService.Data.CurrentTurn > 0 && SimService.Data.CurrentTurn <= SimService.Data.Events.Count
|
private TurnEvent? CurrentEvent => SimService.Data.CurrentTurn > 0 && SimService.Data.CurrentTurn <= SimService.Data.Events.Count
|
||||||
? SimService.Data.Events[SimService.Data.CurrentTurn - 1]
|
? SimService.Data.Events[SimService.Data.CurrentTurn - 1]
|
||||||
: null;
|
: null;
|
||||||
@@ -297,6 +298,18 @@ else
|
|||||||
SimService.Data.CurrentTurn++;
|
SimService.Data.CurrentTurn++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleKeyDown(KeyboardEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == "ArrowLeft") PrevTurn();
|
||||||
|
else if (e.Key == "ArrowRight") NextTurn();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
await layoutDiv.FocusAsync();
|
||||||
|
}
|
||||||
|
|
||||||
private void RandomizeEvents()
|
private void RandomizeEvents()
|
||||||
{
|
{
|
||||||
SimService.RandomizeEvents();
|
SimService.RandomizeEvents();
|
||||||
|
|||||||
Reference in New Issue
Block a user