Private
Public Access
1
0

add togglePresentationMode_WASM: enable F1 key handling, refine CSS styles, and adjust asset scaling logic
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Failing after 1m41s

This commit is contained in:
Sebastian Unterschütz
2026-04-22 20:44:31 +02:00
parent e7609dc50e
commit be76d025da
3 changed files with 68 additions and 15 deletions

View File

@@ -105,6 +105,32 @@ func (g *Game) setupJavaScriptBridge() {
return nil
})
// togglePresentationMode_WASM()
togglePresFunc := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
log.Println("⌨️ F1: Toggle Presentation Mode")
// Simulate F1 key press in WASM
if g.appState == StatePresentation {
g.appState = StateMenu
g.disconnectFromServer()
// JS Callback to hide screen
js.Global().Call("showMainMenu")
} else {
g.appState = StatePresentation
g.presAssets = nil
g.presQuoteTime = time.Now()
g.gameMode = "coop"
g.isHost = true
g.roomID = "PRES" + generateRoomCode()
g.playerName = "PRESENTATION"
go g.connectAndStart()
joinURL := "https://escape-from-school.de/?room=" + g.roomID
g.presQRCode = generateQRCode(joinURL)
g.notifyPresentationStarted_Platform(g.roomID)
}
return nil
})
// Im globalen Scope registrieren
js.Global().Set("startGame", startGameFunc)
js.Global().Set("requestLeaderboard", requestLeaderboardFunc)
@@ -112,6 +138,7 @@ func (g *Game) setupJavaScriptBridge() {
js.Global().Set("setSFXVolume", setSFXVolumeFunc)
js.Global().Set("startGameFromLobby_WASM", startGameFromLobbyFunc)
js.Global().Set("setTeamName_WASM", setTeamNameFunc)
js.Global().Set("togglePresentationMode_WASM", togglePresFunc)
log.Println("✅ JavaScript Bridge registriert")
log.Printf("🔍 window.startGame defined: %v", !js.Global().Get("startGame").IsUndefined())