Skip to content

Commit

Permalink
server/templates/view/game/play: Added the native JS 'requestFullscreen'
Browse files Browse the repository at this point in the history
Which works perfectly.

Also upgraded the code to GO 1.21 and upgraded 'ebiteui' to master which has the fix
to wok on versions greater thatn 1.20
  • Loading branch information
xescugc committed Mar 3, 2024
1 parent 54161e5 commit f6c92b8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ builds:
goarm: ""
gomips: ""
flags:
- -go=go-1.20.8
- -go=go-1.21.0
- -out=maze-wars
- -hooksdir=.xgohooks/
- -targets=darwin/amd64
Expand All @@ -42,7 +42,7 @@ builds:
goarm: ""
gomips: ""
flags:
- -go=go-1.20.8
- -go=go-1.21.0
- -out=maze-wars
- -hooksdir=.xgohooks/
- -targets=linux/amd64
Expand All @@ -52,7 +52,7 @@ builds:
goarm: ""
gomips: ""
flags:
- -go=go-1.20.8
- -go=go-1.21.0
- -out=maze-wars
- -hooksdir=.xgohooks/
- -targets=windows/amd64
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.maze-wars.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.8 as builder
FROM golang:1.21.0 as builder

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.maze-wars.prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.8 as builder
FROM golang:1.21.0 as builder

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/adrg/xdg v0.4.0
github.com/ebitenui/ebitenui v0.5.5
github.com/ebitenui/ebitenui v0.5.6-0.20240228194824-a73d28dc4078
github.com/gofrs/uuid v4.4.0+incompatible
github.com/golang/mock v1.6.0
github.com/gorilla/handlers v1.5.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/ebitengine/purego v0.6.0-alpha.3.0.20240118143548-886e3a0b044a h1:rNw
github.com/ebitengine/purego v0.6.0-alpha.3.0.20240118143548-886e3a0b044a/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/ebitenui/ebitenui v0.5.5 h1:L9UCWmiMlo4sG5TavQKmjfsnwMmYqkld2tXWZMmKkSA=
github.com/ebitenui/ebitenui v0.5.5/go.mod h1:CkzAwu9Ks32P+NC/7+iypdLA85Wqnn93UztPFE+kAH4=
github.com/ebitenui/ebitenui v0.5.6-0.20240228194824-a73d28dc4078 h1:IV5XaJRGp8c/dRpjzMFsibEtw4OEha1BwEXMz5atVdg=
github.com/ebitenui/ebitenui v0.5.6-0.20240228194824-a73d28dc4078/go.mod h1:CkzAwu9Ks32P+NC/7+iypdLA85Wqnn93UztPFE+kAH4=
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
Expand Down
28 changes: 14 additions & 14 deletions server/templates/views/game/play.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
var btn = document.getElementById(fullscreen);
var iframe = document.getElementById("iframe");

// Even if in fullscreen the button cannot be seen
// we'll keep the logic to make it add/remove the
// class
btn.onclick = function(event) {
if (iframe.classList.contains(fullscreen)) {
iframe.classList.remove(fullscreen)
function toggleFullscreen() {
let elem = document.querySelector("iframe");

if (!document.fullscreenElement) {
elem.requestFullscreen().catch((err) => {
alert(
`Error attempting to enable fullscreen mode: ${err.message} (${err.name})`,
);
});
} else {
iframe.classList.add(fullscreen)
}
};
document.addEventListener("keydown", function (e) {
e = e || window.event;
if (e.key === "Escape") {
iframe.classList.remove(fullscreen)
document.exitFullscreen();
}
});
}

btn.onclick = toggleFullscreen

</script>
{{ end}}

0 comments on commit f6c92b8

Please sign in to comment.