From 181e40fccd6219a356b5d6e0a079dfeb74cc8d09 Mon Sep 17 00:00:00 2001 From: Matej Dedina Date: Thu, 20 Jun 2024 21:35:49 +0200 Subject: [PATCH] minor changes to keyboard game mode --- hiravrt/Views/Pages/Game/Keyboard.razor | 253 +++++++++++++++--------- hiravrt/wwwroot/css/game/Keyboard.css | 34 ++++ 2 files changed, 194 insertions(+), 93 deletions(-) diff --git a/hiravrt/Views/Pages/Game/Keyboard.razor b/hiravrt/Views/Pages/Game/Keyboard.razor index 5fbc874..4920e12 100644 --- a/hiravrt/Views/Pages/Game/Keyboard.razor +++ b/hiravrt/Views/Pages/Game/Keyboard.razor @@ -3,7 +3,8 @@ @using hiravrt.Controllers @using hiravrt.Controllers.Nav @using hiravrt.Models.Game -@using System.Text.RegularExpressions; +@using System.Text.RegularExpressions +@using System.Text @rendermode InteractiveServer @inject MainController mc @@ -15,6 +16,10 @@ @code { enum SyllableState { UNSET, CORRECT, INTERMEDIATE, WRONG, } + + enum KeyboardType { GRID_LATIN, TRUE_LATIN, } + private KeyboardType currentKeyboard = KeyboardType.GRID_LATIN; + private bool isDigraph = false; private bool isDiacritic = false; @@ -63,12 +68,6 @@ ratioBefore = ratioAfter = (wrong, correct); } - private void ResetSyllableStates() { - foreach (string s in SyllableStates.Keys) { - SyllableStates[s] = SyllableState.UNSET; - } - } - protected override void OnInitialized() { base.OnInitialized(); ResetProgressBar(); @@ -87,7 +86,13 @@ isDiacritic = !isDiacritic; } - async Task checkClick(string syllable) { + private void ResetSyllableStates() { + foreach (string s in SyllableStates.Keys) { + SyllableStates[s] = SyllableState.UNSET; + } + } + + protected async Task checkClick(string syllable) { if (!SyllableStates.ContainsKey(syllable)) throw new ArgumentException(syllable + " is not a valid syllable."); if (IsChecking) return; @@ -129,7 +134,7 @@ IsChecking = false; } - private async void HandleKeypress(KeyboardEventArgs input) { + protected async void HandleKeypress(KeyboardEventArgs input) { string setInput = input.Key.ToUpper(); if (monographVowels.Contains(setInput)) { @@ -152,9 +157,8 @@ StateHasChanged(); return; } - - if (input.Key == "q") OnReset(); } + } @{ @@ -177,6 +181,10 @@ if (ratio.Item1 + ratio.Item2 == 0) return "0%"; return (100.0 / (ratio.Item1 + ratio.Item2) * ratio.Item2).ToString().Replace(",", ".") + "%"; } + + string getKeyboardTypeState(KeyboardType type) { + return type == currentKeyboard ? "on" : "off"; + } }
@@ -242,91 +250,150 @@

@mc.GameC.KeyboardModel.CorrectSyllable

-
- @if (isDigraph) { - - - - - - - - } else { - - - - - - - + + +
+ @if (isDigraph) { + + + + + + + + } else { + + + + + + + + } +
+ +
+ + @switch (currentKeyboard) { + case KeyboardType.GRID_LATIN : { + @if (isDiacritic) { +
+ + + + + + + +
+ +
+ + + + + + +
+ } else { +
+ + + + + + + +
+ +
+ + + + + @if (isDigraph) { + + + + } else { + + + + } +
+ } + break; } -
- -
- - @if (isDiacritic) { -
- - - - - - - -
- -
- - - - - - -
- -
- - - - - - -
- } else { -
- - - - - - - -
- -
- - - - - @if (isDigraph) { - - - + case KeyboardType.TRUE_LATIN: { + @if (isDiacritic) { +
+ + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + +
} else { - - - +
+ + + + + + + +
+ +
+ + + + + @if (isDigraph) { + + + + } else { + + + + } +
+ +
+ + + + + + +
} -
- -
- - - - - - -
+ break; + } }
\ No newline at end of file diff --git a/hiravrt/wwwroot/css/game/Keyboard.css b/hiravrt/wwwroot/css/game/Keyboard.css index 74be3ba..15a1bfc 100644 --- a/hiravrt/wwwroot/css/game/Keyboard.css +++ b/hiravrt/wwwroot/css/game/Keyboard.css @@ -168,3 +168,37 @@ article#keyboard-gamemode-sub-article:focus { border: none; outline: none; } + +nav#keyboard-types { + display: grid; + grid-template-columns: repeat(2, 1fr); + margin-top: 0.5em; + margin-bottom: 0.5em; + margin-left: 2px; + margin-right: 2px; + grid-column-start: 1; + grid-column-end: -1; +} + +a.keyboard-types-section-off, a.keyboard-types-section-on { + user-select: none; + display: grid; + align-content: center; + height: 2.5em; + cursor: pointer; + text-align: center; +} + +a.keyboard-types-section-on { + background-color: #353535; + color: #D9D9D9; +} + +a.keyboard-types-section-off { + background-color: #D9D9D9; + color: #353535; +} + +a.keyboard-types-section-off:hover, a.keyboard-types-section-on:hover { + text-decoration: underline; +}