Skip to content

Commit

Permalink
current keystrokes state
Browse files Browse the repository at this point in the history
  • Loading branch information
Timtam committed Aug 11, 2024
1 parent 9c35991 commit cd48c39
Show file tree
Hide file tree
Showing 13 changed files with 502 additions and 62 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/push_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ on:
branches:
- main
- development
tags:
- '**'

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- name: Dump job github var
env:
GITHUB_VAR: ${{ toJson(github) }}
run: echo "$GITHUB_VAR"
-
name: Checkout
uses: actions/checkout@v3
Expand All @@ -28,6 +34,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push Docker dev image
if: startsWith(github.ref, 'refs/heads/development')
uses: docker/build-push-action@v6
with:
context: .
Expand Down
Binary file added client/sfx/select_slot.opus
Binary file not shown.
Binary file added client/sfx/slot_unavailable.opus
Binary file not shown.
14 changes: 13 additions & 1 deletion client/src/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Game, GameMode, Hit, Player } from "./entities"
import { Game, GameMode, Hit, Player, Slot } from "./entities"

export enum Sfx {
joinGame,
Expand All @@ -7,6 +7,8 @@ export enum Sfx {
payToken,
playHit,
receiveToken,
selectSlot,
slotUnavailable,
stopHit,
youClaim,
youFail,
Expand All @@ -17,6 +19,7 @@ export enum Sfx {

export interface SfxData {
sfx: Sfx
pan?: number
}

export interface PlaySfxData extends SfxData {}
Expand Down Expand Up @@ -77,6 +80,14 @@ export interface TokenReceivedData {
game_mode: GameMode
}

export interface SlotSelectedData {
slot: Slot | null
slot_count: number
from_year: number
to_year: number
unavailable: boolean
}

export enum Events {
claimedHit = "Claimed hit",
gameEnded = "Game ended",
Expand All @@ -90,5 +101,6 @@ export enum Events {
scored = "Scored",
sfxEnded = "Sfx ended",
skippedHit = "Skipped hit",
slotSelected = "Slot selected",
tokenReceived = "Token received",
}
18 changes: 17 additions & 1 deletion client/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect } from "react"
import { useCallback, useEffect, useState } from "react"
import { useNavigate } from "react-router-dom"

export const useRevalidate = () => {
Expand Down Expand Up @@ -30,3 +30,19 @@ export const useRevalidateOnInterval = ({
[revalidate],
)
}

export const useModalShown = (): boolean => {
let [shown, setShown] = useState(false)

useEffect(() => {
let id = setInterval(() => {
setShown(document.querySelector(".modal") !== null)
}, 50)

return () => {
clearInterval(id)
}
}, [])

return shown
}
28 changes: 27 additions & 1 deletion client/src/locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,29 @@
"confirmHeading": "Du musst nun bestätigen, ob <0>{{player}}</0> den Titel und Interpreten korrekt erraten hat. Sei fair!",
"confirmText": "Hat <0>{{player}}</0> den Titel und Interpreten korrekt erraten?",
"no": "Nein",
"noShortcut": "Alt+Umschalt+N",
"yes": "Ja",
"yesShortcut": "Alt+Umschalt+Y",
"guessText": "Wo, glaubst du, gehört dieser Hit hin?",
"waitingText": "Dies sind die Möglichkeiten:",
"dontIntercept": "Keine Vermutung äußern",
"beforeYear": "vor {{year}}",
"afterYear": "nach {{year}}",
"betweenYears": "von {{year1}} bis {{year2}}",
"submitGuess": "Vermutung abschicken",
"submitGuessShortcut": "Alt+Umschalt+Enter",
"selectSlotFirst": "Wähle erst eine Möglichkeit",
"cannotSubmitGuess": "Du kannst derzeit keine Vermutung abgeben",
"game_one": "Spiel",
"gameActions": "Spielaktionen:",
"leaveGame": "Spiel verlassen",
"leaveGameShortcut": "Alt+Umschalt+Q",
"joinGame": "Spiel beitreten",
"joinGameShortcut": "Alt+Umschalt+J",
"stopGame": "Spiel stoppen",
"stopGameShortcut": "Alt+Umschalt+S",
"startGame": "Spiel starten",
"startGameShortcut": "Alt+Umschalt+S",
"name": "Name",
"token_one": "Chip",
"token_other": "Chips",
Expand Down Expand Up @@ -110,8 +117,11 @@
"save": "Speichern",
"sfxVolume": "Lautstärke der Sound Effekte",
"publicGame": "Öffentliches Spiel",
"publicGameShortcut": "Alt+Umschalt+U",
"privateGame": "Privates Spiel",
"privateGameShortcut": "Alt+Umschalt+R",
"localGame": "Lokales Spiel",
"localGameShortcut": "Alt+Umschalt+L",
"addPlayer": "Lokalen Spieler hinzufügen",
"addPlayerNotLocalGame": "Du kannst lokale Spieler nur in einem lokalen Spiel hinzufügen",
"addPlayerNotWaiting": "Du kannst lokale Spieler nur hinzufügen, während das Spiel gestoppt ist",
Expand Down Expand Up @@ -144,6 +154,22 @@
"guessNothing": "{{player}} behauptet nichts Gegenteiliges",
"guess": "{{player}} vermutet: {{guess}}",
"youReceivedToken": "Du hast einen Token erhalten, da du Künstler und Titel dieses Hits wusstest",
"otherReceivedToken": "{{player}} hat einen Token erhalten, da der Künstler und Titel dieses Hits genannt wurde"
"otherReceivedToken": "{{player}} hat einen Token erhalten, da der Künstler und Titel dieses Hits genannt wurde",
"keyboardShortcut_one": "Tastenkombination",
"keyboardShortcut_other": "Tastenkombinationen",
"section": "Abschnitt",
"action": "Aktion",
"game": "Spiel",
"confirmYes": "Titel und Interpret des Hits wurde richtig erraten",
"confirmNo": "Titel und Interpret des Hits wurde nicht richtig erraten",
"selectPreviousSlot": "Vorherigen Slot auswählen",
"selectPreviousSlotShortcut": "Alt+Umschalt+Pfeil nach oben",
"selectNextSlot": "Nächsten Slot auswählen",
"selectNextSlotShortcut": "Alt+Umschalt+Pfeil nach unten",
"selectNoSlot": "Keinen Slot auswählen",
"selectNoSlotShortcut": "Alt+Umschalt+Rücktaste",
"playerStatsNotification": "{{player}}: {{hits}} Hits, {{tokens}} Chips",
"speakPlayerInfo": "Sprich wichtige Informationen zu Spieler {{player}}",
"speakPlayerInfoShortcut": "Alt+Umschalt+{{player}}"
}
}
28 changes: 27 additions & 1 deletion client/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,29 @@
"confirmHeading": "You now need to confirm if <0>{{player}}</0> guessed title and artist of the song correctly. Be fair!",
"confirmText": "Did <0>{{player}}</0> guess artist and title correctly?",
"no": "No",
"noShortcut": "Alt+Shift+N",
"yes": "Yes",
"yesShortcut": "Alt+Shift+Y",
"guessText": "Where do you think this hit belongs?",
"waitingText": "These are the possible slots:",
"dontIntercept": "Don't intercept",
"beforeYear": "before {{year}}",
"afterYear": "after {{year}}",
"betweenYears": "between {{year1}} and {{year2}}",
"submitGuess": "Submit guess",
"submitGuessShortcut": "Alt+Shift+Return",
"selectSlotFirst": "Select a slot first",
"cannotSubmitGuess": "You cannot submit a guess right now",
"game_one": "Game",
"gameActions": "Game actions:",
"leaveGame": "Leave game",
"leaveGameShortcut": "Alt+Shift+Q",
"joinGame": "Join game",
"joinGameShortcut": "Alt+Shift+J",
"stopGame": "Stop game",
"stopGameShortcut": "Alt+Shift+S",
"startGame": "Start game",
"startGameShortcut": "Alt+Shift+S",
"name": "Name",
"token_one": "Token",
"token_other": "Tokens",
Expand Down Expand Up @@ -110,8 +117,11 @@
"save": "Save",
"sfxVolume": "SFX Volume",
"publicGame": "Public game",
"publicGameShortcut": "Alt+Shift+U",
"privateGame": "Private game",
"privateGameShortcut": "Alt+Shift+R",
"localGame": "Local game",
"localGameShortcut": "Alt+Shift+L",
"addPlayer": "Add local player",
"addPlayerNotLocalGame": "You can only add local players in a local game",
"addPlayerNotWaiting": "You can only add local players while the game is stopped",
Expand Down Expand Up @@ -144,6 +154,22 @@
"guessNothing": "{{player}} doesn't intercept",
"guess": "{{player}} guesses: {{guess}}",
"youReceivedToken": "You received a token for guessing artist and title of this hit correctly",
"otherReceivedToken": "{{player}} received a token for guessing artist and title of this hit correctly"
"otherReceivedToken": "{{player}} received a token for guessing artist and title of this hit correctly",
"keyboardShortcut_one": "Keyboard shortcut",
"keyboardShortcut_other": "Keyboard shortcuts",
"section": "Abschnitt",
"action": "Aktion",
"game": "Game",
"confirmYes": "title and artist of the hit was guessed correctly",
"confirmNo": "title and artist of the hit was guessed incorrectly",
"selectPreviousSlot": "Select previous slot",
"selectPreviousSlotShortcut": "Alt+Shift+Up arrow",
"selectNextSlot": "Select next slot",
"selectNextSlotShortcut": "Alt+Shift+Down arrow",
"selectNoSlot": "Select no slot",
"selectNoSlotShortcut": "Alt+Shift+Backspace",
"playerStatsNotification": "{{player}}: {{hits}} hits, {{tokens}} tokens",
"speakPlayerInfo": "Speak important information about player {{player}}",
"speakPlayerInfoShortcut": "Alt+Shift+{{player}}"
}
}
14 changes: 14 additions & 0 deletions client/src/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { LinkContainer } from "react-router-bootstrap"
import { useNavigate } from "react-router-dom"
import { User } from "./entities"
import Settings from "./settings"
import Shortcuts from "./shortcuts"

export default function Navigation({ user }: { user: User | null }) {
let navigate = useNavigate()
const { t } = useTranslation()
let [showSettings, setShowSettings] = useState(false)
let [showShortcuts, setShowShortcuts] = useState(false)
let [_, setWelcome] = useLocalStorage("welcome")

return (
Expand Down Expand Up @@ -48,6 +50,14 @@ export default function Navigation({ user }: { user: User | null }) {
{t("welcome")}
</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link
aria-expanded="false"
onClick={() => setShowShortcuts(true)}
>
{t("keyboardShortcut", { count: 2 })}
</Nav.Link>
</Nav.Item>
<Nav.Item>
<Nav.Link
aria-expanded="false"
Expand Down Expand Up @@ -167,6 +177,10 @@ export default function Navigation({ user }: { user: User | null }) {
show={showSettings}
onHide={() => setShowSettings(false)}
/>
<Shortcuts
show={showShortcuts}
onHide={() => setShowShortcuts(false)}
/>
</>
)
}
9 changes: 1 addition & 8 deletions client/src/notification-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const TIMER_DURATION: number = 150
export default function NotificationPlayer({ user }: { user: User | null }) {
let { t } = useTranslation()
let [politeness, setPoliteness] = useState<"polite" | "assertive">("polite")
let [hidden, setHidden] = useState<boolean>(true)
let output = useRef<HTMLParagraphElement | null>(null)
let events = useRef<SpeechEvent[]>([])
let timer = useRef<ReturnType<typeof setTimeout> | null>(null)
Expand All @@ -42,7 +41,6 @@ export default function NotificationPlayer({ user }: { user: User | null }) {
const handleSpeechEvent = () => {
if (events.current.length === 0) {
if (output.current) output.current.innerHTML = ""
setHidden(true)
timer.current = null
return
}
Expand Down Expand Up @@ -76,11 +74,7 @@ export default function NotificationPlayer({ user }: { user: User | null }) {
},
})
if (timer.current === null) {
setHidden(false)
timer.current = setTimeout(
handleSpeechEvent,
TIMER_DURATION,
)
handleSpeechEvent()
}
},
)
Expand Down Expand Up @@ -360,7 +354,6 @@ export default function NotificationPlayer({ user }: { user: User | null }) {
aria-atomic={true}
ref={output}
className="visually-hidden"
aria-hidden={hidden}
/>
)
}
Loading

0 comments on commit cd48c39

Please sign in to comment.