Skip to content

Commit bcc6614

Browse files
committed
Merge branch 'feature/input-viewer'
2 parents 8115623 + 5187186 commit bcc6614

File tree

123 files changed

+15439
-2487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+15439
-2487
lines changed

app.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"errors"
55
"fmt"
6+
inputviewer "ivan/input-viewer"
67
"ivan/timer"
78
"ivan/tracker"
89
"log"
@@ -18,9 +19,10 @@ const configPath = "assets/config.json"
1819
var errCloseApp = errors.New("user requested app close")
1920

2021
type App struct {
21-
tracker *tracker.Tracker
22-
timer *timer.Timer
23-
config config
22+
tracker *tracker.Tracker
23+
timer *timer.Timer
24+
inputViewer *inputviewer.InputViewer
25+
config config
2426

2527
saveDebounce func(func())
2628
}
@@ -61,6 +63,7 @@ func NewApp() (*App, error) {
6163
return &App{
6264
tracker: tracker,
6365
timer: timer,
66+
inputViewer: nil, // initialized on first frame to ensure we have a gamepad
6467
config: config,
6568
saveDebounce: debounce.New(1 * time.Second),
6669
}, nil
@@ -71,6 +74,10 @@ func (app *App) Update(screen *ebiten.Image) error {
7174
_, wheel := ebiten.Wheel()
7275
var shouldSave bool
7376

77+
if app.inputViewer == nil {
78+
app.inputViewer = inputviewer.NewInputViewer(app.config.InputViewer)
79+
}
80+
7481
switch {
7582
case inpututil.IsKeyJustPressed(ebiten.KeyEscape):
7683
if !app.timer.IsRunning() && !app.tracker.EatInput() {
@@ -147,6 +154,7 @@ func (app *App) Update(screen *ebiten.Image) error {
147154
func (app *App) Draw(screen *ebiten.Image) {
148155
app.tracker.Draw(screen)
149156
app.timer.Draw(screen)
157+
app.inputViewer.Draw(screen)
150158
}
151159

152160
func (app *App) Layout(w, h int) (int, int) {

assets/config.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
{
2+
"InputViewer": {
3+
"A": {"Type": "Button", "ID": 1, "Pos": {"X": 130, "Y": 384}, "Color": {"G": 255}},
4+
"B": {"Type": "Button", "ID": 3, "Pos": {"X": 134, "Y": 384}, "Color": {"R": 255}},
5+
"Start": {"Type": "Button", "ID": 7, "Pos": {"X": 138, "Y": 384}, "Color": {"R": 255, "G": 255, "B": 255}},
6+
"CLeft": {"Type": "Button", "ID": 0, "Pos": {"X": 142, "Y": 388}, "Color": {"R": 255, "G": 255}},
7+
"CUp": {"Type": "Axis", "ID": 4, "Dir": 1, "Pos": {"X": 146, "Y": 384}, "Color": {"R": 255, "G": 255}},
8+
"CDown": {"Type": "Button", "ID": 4, "Pos": {"X": 146, "Y": 392}, "Color": {"R": 255, "G": 255}},
9+
"CRight": {"Type": "Button", "ID": 2, "Pos": {"X": 150, "Y": 388}, "Color": {"R": 255, "G": 255}},
10+
"Z": {"Type": "Axis", "ID": 2, "Pos": {"X": 154, "Y": 384}, "Color": {"R": 255, "G": 255, "B": 255}},
11+
"R": {"Type": "Axis", "ID": 5, "Pos": {"X": 158, "Y": 384}, "Color": {"R": 255, "G": 255, "B": 255}},
12+
13+
"J": {"Type": "Axis", "IDX": 0, "IDY": 1, "Pos": {"X": 122, "Y": 388}, "Color": {"R": 255, "G": 255, "B": 255}}
14+
},
15+
216
"Binds": {
317
"0": "StartItemInput",
418
".": "DowngradeNext",

config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"encoding/json"
55
"image"
6+
inputviewer "ivan/input-viewer"
67
"ivan/tracker"
78
"os"
89
)
@@ -15,7 +16,8 @@ type config struct {
1516

1617
DungeonInputMedallionOrder, DungeonInputDungeonKP []string
1718

18-
Dimensions struct {
19+
InputViewer inputviewer.Config
20+
Dimensions struct {
1921
ItemTracker image.Rectangle
2022
Timer image.Rectangle
2123
HintTracker image.Rectangle

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ go 1.14
44

55
require (
66
github.com/bep/debounce v1.2.0
7-
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200420212212-258d9bec320e // indirect
87
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
9-
github.com/hajimehoshi/ebiten v1.12.0-alpha.2
10-
github.com/lithammer/fuzzysearch v1.1.0
11-
golang.org/x/exp v0.0.0-20200513190911-00229845015e // indirect
12-
golang.org/x/image v0.0.0-20200618115811-c13761719519
13-
golang.org/x/sys v0.0.0-20200620081246-981b61492c35 // indirect
8+
github.com/hajimehoshi/ebiten v1.12.0
9+
github.com/lithammer/fuzzysearch v1.1.1
10+
golang.org/x/exp v0.0.0-20200924195034-c827fd4f18b9 // indirect
11+
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5
12+
golang.org/x/sys v0.0.0-20201005065044-765f4ea38db3 // indirect
13+
golang.org/x/text v0.3.3 // indirect
1414
)

go.sum

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,86 @@ github.com/bep/debounce v1.2.0 h1:wXds8Kq8qRfwAOpAxHrJDbCXgC5aHSzgQb/0gKsHQqo=
44
github.com/bep/debounce v1.2.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
55
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4 h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=
66
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
7-
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200420212212-258d9bec320e h1:8ywu4ELC/6owgOZlZx75CyYS5AYwUT2L+hzPModKvag=
8-
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200420212212-258d9bec320e/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
9-
github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc=
10-
github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
7+
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200707082815-5321531c36a2 h1:Ac1OEHHkbAZ6EUnJahF0GKcU0FjPc/V8F1DvjhKngFE=
8+
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200707082815-5321531c36a2/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
9+
github.com/gofrs/flock v0.8.0 h1:MSdYClljsF3PbENUUEx85nkWfJSGfzYI9yEBZOJz6CY=
10+
github.com/gofrs/flock v0.8.0/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
1111
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
1212
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
13-
github.com/hajimehoshi/bitmapfont v1.2.0 h1:hw6OjRGdgmHUe56BPju/KU/QD/KLOiTQ+6t+TJpfSfU=
14-
github.com/hajimehoshi/bitmapfont v1.2.0/go.mod h1:h9QrPk6Ktb2neObTlAbma6Ini1xgMjbJ3w7ysmD7IOU=
15-
github.com/hajimehoshi/ebiten v1.12.0-alpha.2 h1:P5wHlBhj4VuH9VzYCKcGXa0qZDn7h5Xv2ny+tacmhIc=
16-
github.com/hajimehoshi/ebiten v1.12.0-alpha.2/go.mod h1:nNw7rcYp6tYzZO9Fwwn1fEXvSfv27tgMBgKSJTw2VyM=
17-
github.com/hajimehoshi/go-mp3 v0.2.2/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
13+
github.com/hajimehoshi/bitmapfont v1.3.0 h1:h6+HJQ+2MKT3lEVEArjVC4/h0qcFXlVsMTGuRijEnVA=
14+
github.com/hajimehoshi/bitmapfont v1.3.0/go.mod h1:/Qb7yVjHYNUV4JdqNkPs6BSZwLjKqkZOMIp6jZD0KgE=
15+
github.com/hajimehoshi/ebiten v1.12.0 h1:o1zlfI9Xctzm1QlSdZfxmWRRfRb64AKsafXgRq87oEA=
16+
github.com/hajimehoshi/ebiten v1.12.0/go.mod h1:0G/t1zdc19XZSPb9YggXN940uglPa6acoqD0+/vy2Qg=
17+
github.com/hajimehoshi/file2byteslice v0.0.0-20200812174855-0e5e8a80490e/go.mod h1:CqqAHp7Dk/AqQiwuhV1yT2334qbA/tFWQW0MD2dGqUE=
18+
github.com/hajimehoshi/go-mp3 v0.3.1/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
1819
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
19-
github.com/jakecoffman/cp v0.1.0/go.mod h1:a3xPx9N8RyFAACD644t2dj/nK4SuLg1v+jL61m2yVo4=
20+
github.com/hajimehoshi/oto v0.6.5-0.20200917193348-57f376f2c835/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
21+
github.com/jakecoffman/cp v1.0.0/go.mod h1:JjY/Fp6d8E1CHnu74gWNnU0+b9VzEdUVPoJxg2PsTQg=
2022
github.com/jfreymuth/oggvorbis v1.0.1/go.mod h1:NqS+K+UXKje0FUYUPosyQ+XTVvjmVjps1aEZH1sumIk=
2123
github.com/jfreymuth/vorbis v1.0.0/go.mod h1:8zy3lUAm9K/rJJk223RKy6vjCZTWC61NA2QD06bfOE0=
2224
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
2325
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
2426
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
25-
github.com/lithammer/fuzzysearch v1.1.0 h1:go9v8tLCrNTTlH42OAaq4eHFe81TDHEnlrMEb6R4f+A=
26-
github.com/lithammer/fuzzysearch v1.1.0/go.mod h1:Bqx4wo8lTOFcJr3ckpY6HA9lEIOO0H5HrkJ5CsN56HQ=
27+
github.com/lithammer/fuzzysearch v1.1.1 h1:8F9OAV2xPuYblToVohjanztdnPjbtA0MLgMvDKQ0Z08=
28+
github.com/lithammer/fuzzysearch v1.1.1/go.mod h1:H2bng+w5gsR7NlfIJM8ElGZI0sX6C/9uzGqicVXGU6c=
2729
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
2830
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
2931
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
30-
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
32+
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
3133
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3234
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
3335
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
36+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
3437
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
3538
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 h1:estk1glOnSVeJ9tdEZZc5mAMDZk5lNJNyJ6DvrBkTEU=
3639
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
37-
golang.org/x/exp v0.0.0-20200513190911-00229845015e h1:rMqLP+9XLy+LdbCXHjJHAmTfXCr93W7oruWA6Hq1Alc=
38-
golang.org/x/exp v0.0.0-20200513190911-00229845015e/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
40+
golang.org/x/exp v0.0.0-20200924195034-c827fd4f18b9 h1:0cRDak1hoWbor1hDM+mvD9xp3f1wcxvEubvb3AiP/5I=
41+
golang.org/x/exp v0.0.0-20200924195034-c827fd4f18b9/go.mod h1:1phAWC201xIgDyaFpmDeZkgf70Q4Pd/CNqfRtVPtxNw=
3942
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
4043
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
4144
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
42-
golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
43-
golang.org/x/image v0.0.0-20200618115811-c13761719519 h1:1e2ufUJNM3lCHEY5jIgac/7UTjd6cgJNdatjPdFWf34=
44-
golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
45+
golang.org/x/image v0.0.0-20200801110659-972c09e46d76/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
46+
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 h1:QelT11PB4FXiDEXucrfNckHoFxwt8USGY1ajP1ZF5lM=
47+
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
4548
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
4649
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
4750
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
48-
golang.org/x/mobile v0.0.0-20200329125638-4c31acba0007 h1:JxsyO7zPDWn1rBZW8FV5RFwCKqYeXnyaS/VQPLpXu6I=
49-
golang.org/x/mobile v0.0.0-20200329125638-4c31acba0007/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
51+
golang.org/x/mobile v0.0.0-20200801112145-973feb4309de h1:OVJ6QQUBAesB8CZijKDSsXX7xYVtUhrkY0gwMfbi4p4=
52+
golang.org/x/mobile v0.0.0-20200801112145-973feb4309de/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4=
5053
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
5154
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
52-
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
5355
golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
54-
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
56+
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
57+
golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
5558
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5659
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
5760
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
58-
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
61+
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
5962
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
60-
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
63+
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6164
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
6265
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6366
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6467
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6568
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
66-
golang.org/x/sys v0.0.0-20200327173247-9dae0f8f5775/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
67-
golang.org/x/sys v0.0.0-20200620081246-981b61492c35 h1:wb/9mP8eUAmHfkM8RmpeLq6nUA7c2i5+bQOtcDftjaE=
68-
golang.org/x/sys v0.0.0-20200620081246-981b61492c35/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
69+
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
70+
golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
71+
golang.org/x/sys v0.0.0-20201005065044-765f4ea38db3 h1:9Dt0vhJUQR70NuYBi/EFF+uAOebN40T4F1PZ7PKYrdw=
72+
golang.org/x/sys v0.0.0-20201005065044-765f4ea38db3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
6973
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
7074
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
7175
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
7276
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
77+
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
78+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
7379
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
7480
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
7581
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
7682
golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
7783
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
78-
golang.org/x/tools v0.0.0-20200330175517-31583a0dbbc8/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
84+
golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
7985
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
8086
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
81-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
82-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
83-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
87+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
88+
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
89+
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

input-viewer/input_viewer.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package inputviewer
2+
3+
import (
4+
"image"
5+
"image/color"
6+
"log"
7+
8+
"github.com/hajimehoshi/ebiten"
9+
"github.com/hajimehoshi/ebiten/ebitenutil"
10+
)
11+
12+
type Config struct {
13+
A, B, Z, R, Start InputButton
14+
CUp, CRight, CDown, CLeft InputButton
15+
16+
J InputJoystick
17+
}
18+
19+
type InputButton struct {
20+
Type string // (Button, Axis)
21+
ID int
22+
Dir int // -1 / 1
23+
24+
Pos image.Point
25+
Color color.RGBA
26+
}
27+
28+
type InputJoystick struct {
29+
IDX, IDY int
30+
31+
Pos image.Point
32+
Color color.RGBA
33+
}
34+
35+
func (i InputJoystick) axes(id int) (float64, float64) {
36+
return ebiten.GamepadAxis(id, i.IDX), ebiten.GamepadAxis(id, i.IDY)
37+
}
38+
39+
func (i InputButton) pressed(id int) bool {
40+
dir := 1.0
41+
if dir < 0 {
42+
dir = -1
43+
}
44+
45+
switch i.Type {
46+
case "Button":
47+
return ebiten.IsGamepadButtonPressed(id, ebiten.GamepadButton(i.ID))
48+
case "Axis":
49+
return ebiten.GamepadAxis(id, i.ID) > (dir * 0.15)
50+
}
51+
52+
return false
53+
}
54+
55+
type InputViewer struct {
56+
config Config
57+
id int
58+
}
59+
60+
func NewInputViewer(config Config) *InputViewer {
61+
ids := ebiten.GamepadIDs()
62+
if len(ids) == 0 {
63+
log.Printf("warning: no gamepad found")
64+
return nil
65+
}
66+
id := ids[0]
67+
68+
log.Printf("info: reading input from %s", ebiten.GamepadName(id))
69+
70+
return &InputViewer{
71+
config: config,
72+
id: id,
73+
}
74+
}
75+
76+
func (iv *InputViewer) Draw(screen *ebiten.Image) {
77+
if iv == nil { // allow ignoring input viewer
78+
return
79+
}
80+
81+
for _, v := range []*InputButton{
82+
&iv.config.A, &iv.config.B,
83+
&iv.config.Z, &iv.config.R,
84+
&iv.config.Start,
85+
&iv.config.CUp, &iv.config.CRight,
86+
&iv.config.CDown, &iv.config.CLeft,
87+
} {
88+
if !v.pressed(iv.id) {
89+
continue
90+
}
91+
92+
ebitenutil.DrawRect(
93+
screen,
94+
float64(v.Pos.X), float64(v.Pos.Y),
95+
2, 2,
96+
color.RGBA{v.Color.R, v.Color.G, v.Color.B, 0xFF},
97+
)
98+
}
99+
100+
j := iv.config.J
101+
x, y := j.axes(iv.id)
102+
ebitenutil.DrawRect(
103+
screen,
104+
float64(j.Pos.X)+4.0*x,
105+
float64(j.Pos.Y)+4.0*y,
106+
2, 2,
107+
color.RGBA{j.Color.R, j.Color.G, j.Color.B, 0xFF},
108+
)
109+
}

timer/timer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func New(dimensions image.Rectangle) (*Timer, error) {
4949
font: font,
5050
pos: dimensions.Min,
5151
size: dimensions.Size(),
52-
timeSize: text.MeasureString(format(time.Duration(0)), font),
52+
timeSize: text.BoundString(font, format(time.Duration(0))).Size(),
5353
}, nil
5454
}
5555

@@ -66,7 +66,7 @@ func format(d time.Duration) string {
6666
func (timer *Timer) Draw(screen *ebiten.Image) {
6767
pos := timer.pos.Add(image.Point{
6868
((timer.size.X - timer.timeSize.X) / 2),
69-
timer.timeSize.Y + ((timer.size.Y - timer.timeSize.Y) / 2) - 8,
69+
timer.timeSize.Y + ((timer.size.Y - timer.timeSize.Y) / 2),
7070
})
7171

7272
var str string

tracker/input.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (tracker *Tracker) idleHandleAction(a action) {
125125
}
126126
}
127127

128+
// nolint:funlen
128129
func (tracker *Tracker) inputAction(a action) {
129130
// Ensure we can _always_ leave using KP0
130131
if a == actionStartItemInput && !tracker.kbInputStateIs(inputStateIdle) {

vendor/github.com/go-gl/glfw/v3.3/glfw/c_glfw_freebsd.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-gl/glfw/v3.3/glfw/c_glfw_linbsd.go renamed to vendor/github.com/go-gl/glfw/v3.3/glfw/c_glfw_lin.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)