Private
Public Access
1
0

add presentation mode enhancements: refine visuals, integrate HTML-based interface for presentation mode, align assets display and player states, and handle real-time JS callbacks
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Failing after 1m36s

This commit is contained in:
Sebastian Unterschütz
2026-04-22 20:28:16 +02:00
parent c1fb3bcef0
commit d5c1e2ec82
11 changed files with 526 additions and 115 deletions

View File

@@ -4,6 +4,7 @@
package main
import (
"encoding/base64"
"log"
"syscall/js"
)
@@ -181,3 +182,41 @@ func (g *Game) sendLobbyPlayersToJS() {
log.Printf("🏷️ Team-Name an JavaScript gesendet: '%s' (isHost: %v)", teamName, isHost)
}
}
// notifyPresentationStarted benachrichtigt JS dass der Presi-Modus aktiv ist
func (g *Game) notifyPresentationStarted(roomID string, qrCode []byte) {
if presFunc := js.Global().Get("onPresentationStarted"); !presFunc.IsUndefined() {
// Konvertiere QR Code zu Base64 für JS
qrBase64 := ""
if qrCode != nil {
qrBase64 = "data:image/png;base64," + base64.StdEncoding.EncodeToString(qrCode)
}
presFunc.Invoke(roomID, qrBase64)
log.Printf("📺 Präsentationsmodus an JS signalisiert: %s", roomID)
}
}
// updatePresentationState sendet den aktuellen Status (Spieler, Emotes) an JS
func (g *Game) updatePresentationState() {
if updateFunc := js.Global().Get("onPresentationUpdate"); !updateFunc.IsUndefined() {
g.stateMutex.Lock()
players := g.gameState.Players
g.stateMutex.Unlock()
// Vereinfachte Spieler-Daten für JS
jsPlayers := make([]interface{}, 0)
for _, p := range players {
if !p.IsAlive || p.Name == "PRESENTATION" {
continue
}
jsPlayers = append(jsPlayers, map[string]interface{}{
"id": p.ID,
"x": p.X,
"y": p.Y,
"vy": p.VY,
"state": p.State,
})
}
updateFunc.Invoke(jsPlayers)
}
}