Skip to content

Commit

Permalink
Revert "merged a huge portion of keystrokes support"
Browse files Browse the repository at this point in the history
This reverts commit d412d60.
  • Loading branch information
Timtam committed Aug 11, 2024
1 parent 19fe750 commit 9c35991
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 372 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/push_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ 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 @@ -34,7 +28,6 @@ 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 removed client/sfx/select_slot.opus
Binary file not shown.
Binary file removed client/sfx/slot_unavailable.opus
Binary file not shown.
14 changes: 1 addition & 13 deletions client/src/events.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Game, GameMode, Hit, Player, Slot } from "./entities"
import { Game, GameMode, Hit, Player } from "./entities"

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

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

export interface PlaySfxData extends SfxData {}
Expand Down Expand Up @@ -80,14 +77,6 @@ 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 @@ -101,6 +90,5 @@ export enum Events {
scored = "Scored",
sfxEnded = "Sfx ended",
skippedHit = "Skipped hit",
slotSelected = "Slot selected",
tokenReceived = "Token received",
}
18 changes: 1 addition & 17 deletions client/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect, useState } from "react"
import { useCallback, useEffect } from "react"
import { useNavigate } from "react-router-dom"

export const useRevalidate = () => {
Expand Down Expand Up @@ -30,19 +30,3 @@ 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
}
18 changes: 9 additions & 9 deletions client/src/locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"otherInterceptHeading": "Du kannst jetzt für <0>{{player}}</0> eine andere Vermutung äußern",
"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 (Alt+Umschalt+N)",
"yes": "Ja (Alt+Umschalt+Y)",
"no": "Nein",
"yes": "Ja",
"guessText": "Wo, glaubst du, gehört dieser Hit hin?",
"waitingText": "Dies sind die Möglichkeiten:",
"dontIntercept": "Keine Vermutung äußern",
Expand All @@ -47,10 +47,10 @@
"cannotSubmitGuess": "Du kannst derzeit keine Vermutung abgeben",
"game_one": "Spiel",
"gameActions": "Spielaktionen:",
"leaveGame": "Spiel verlassen (Alt+Umschalt+Q)",
"joinGame": "Spiel beitreten (Alt+Umschalt+J)",
"stopGame": "Spiel stoppen (Alt+Umschalt+S)",
"startGame": "Spiel starten (Alt+Umschalt+S)",
"leaveGame": "Spiel verlassen",
"joinGame": "Spiel beitreten",
"stopGame": "Spiel stoppen",
"startGame": "Spiel starten",
"name": "Name",
"token_one": "Chip",
"token_other": "Chips",
Expand Down Expand Up @@ -109,9 +109,9 @@
"gameSettingsPacks": "Wähle alle die Packs aus, welche in diesem Spiel genutzt werden sollen:",
"save": "Speichern",
"sfxVolume": "Lautstärke der Sound Effekte",
"publicGame": "Öffentliches Spiel (Alt+Umschalt+U)",
"privateGame": "Privates Spiel (Alt+Umschalt+R)",
"localGame": "Lokales Spiel (Alt+Umschalt+L)",
"publicGame": "Öffentliches Spiel",
"privateGame": "Privates Spiel",
"localGame": "Lokales Spiel",
"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
18 changes: 9 additions & 9 deletions client/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"otherInterceptHeading": "You can now make another guess for <0>{{player}}</0>",
"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 (Alt+Shift+N)",
"yes": "Yes (Alt+Shift+Y)",
"no": "No",
"yes": "Yes",
"guessText": "Where do you think this hit belongs?",
"waitingText": "These are the possible slots:",
"dontIntercept": "Don't intercept",
Expand All @@ -47,10 +47,10 @@
"cannotSubmitGuess": "You cannot submit a guess right now",
"game_one": "Game",
"gameActions": "Game actions:",
"leaveGame": "Leave game (Alt+Shift+Q)",
"joinGame": "Join game (Alt+Shift+J)",
"stopGame": "Stop game (Alt+Shift+S)",
"startGame": "Start game (Alt+Shift+S)",
"leaveGame": "Leave game",
"joinGame": "Join game",
"stopGame": "Stop game",
"startGame": "Start game",
"name": "Name",
"token_one": "Token",
"token_other": "Tokens",
Expand Down Expand Up @@ -109,9 +109,9 @@
"gameSettingsPacks": "Check all the packs you want to use in this game:",
"save": "Save",
"sfxVolume": "SFX Volume",
"publicGame": "Public game (Alt+Shift+U)",
"privateGame": "Private game (Alt+Shift+R)",
"localGame": "Local game (Alt+Shift+L)",
"publicGame": "Public game",
"privateGame": "Private game",
"localGame": "Local game",
"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
9 changes: 8 additions & 1 deletion client/src/notification-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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 @@ -41,6 +42,7 @@ 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 @@ -74,7 +76,11 @@ export default function NotificationPlayer({ user }: { user: User | null }) {
},
})
if (timer.current === null) {
handleSpeechEvent()
setHidden(false)
timer.current = setTimeout(
handleSpeechEvent,
TIMER_DURATION,
)
}
},
)
Expand Down Expand Up @@ -354,6 +360,7 @@ export default function NotificationPlayer({ user }: { user: User | null }) {
aria-atomic={true}
ref={output}
className="visually-hidden"
aria-hidden={hidden}
/>
)
}
48 changes: 17 additions & 31 deletions client/src/pages/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
SkippedHitData,
TokenReceivedData,
} from "../events"
import { useModalShown } from "../hooks"
import GameService from "../services/games.service"
import AddLocalPlayerScreen from "./game/add-local-player"
import GameEndScreen from "./game/end-screen"
Expand Down Expand Up @@ -71,13 +70,6 @@ export function Game() {
let navigate = useNavigate()
let { t } = useTranslation()
let [winner, setWinner] = useImmer<Player | null>(null)
let modalShown = useModalShown()

const joinOrLeaveGame = async () => {
if (game.players.some((p) => p.id === user?.id))
await gameService.leave(game.id)
else await gameService.join(game.id)
}

const startOrStopGame = async () => {
if (game.state === GameState.Open) {
Expand Down Expand Up @@ -281,37 +273,26 @@ export function Game() {

// register keystrokes
useEffect(() => {
let handleJoinGame = {
onPressed: () => {
joinOrLeaveGame()
},
}
let handleLeaveGame = {
onPressed: () => {
joinOrLeaveGame()
},
}
let handleStartOrStopGame = {
let startOrStopHandler = {
onPressed: () => {
startOrStopGame()
},
}

if (!modalShown) {
bindKeyCombo("alt + shift + j", handleJoinGame)
bindKeyCombo("alt + shift + q", handleLeaveGame)

if (canStartOrStopGame()) {
bindKeyCombo("alt + shift + s", handleStartOrStopGame)
}
if (
!showSettings &&
!showHits.some((s) => s) &&
!showAddPlayer &&
!gameEndedState &&
canStartOrStopGame()
) {
bindKeyCombo("alt + s", startOrStopHandler)
}

return () => {
unbindKeyCombo("alt + shift + j", handleJoinGame)
unbindKeyCombo("alt + shift + q", handleLeaveGame)
unbindKeyCombo("alt + shift + s", handleStartOrStopGame)
unbindKeyCombo("alt + s", startOrStopHandler)
}
}, [game, user, modalShown])
}, [showSettings, showHits, showAddPlayer, gameEndedState, game, user])

const canStartOrStopGame = (): boolean => {
return (
Expand Down Expand Up @@ -340,7 +321,11 @@ export function Game() {
game.state !== GameState.Open &&
!game.players.some((p) => p.id === user?.id)
}
onClick={joinOrLeaveGame}
onClick={async () => {
if (game.players.some((p) => p.id === user?.id))
await gameService.leave(game.id)
else await gameService.join(game.id)
}}
>
{game.players.some((p) => p.id === user?.id)
? t("leaveGame")
Expand All @@ -352,6 +337,7 @@ export function Game() {
className="me-2"
disabled={!canStartOrStopGame()}
onClick={startOrStopGame}
aria-keyshortcuts="Alt+S"
>
{canStartOrStopGame()
? game.state !== GameState.Open
Expand Down
Loading

0 comments on commit 9c35991

Please sign in to comment.