-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
65 lines (52 loc) · 1.14 KB
/
Copy pathmain.go
File metadata and controls
65 lines (52 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"github.com/hajimehoshi/ebiten/v2"
"log"
"macroboard/internal/windows_api"
)
type Game struct {
keyboard *KeyBoard
}
func NewGame() *Game {
fp, err := getConfigFilePath()
if err != nil {
log.Fatal(err)
}
fmt.Println("Config Path:", fp)
config, err := NewConfigFromFile(fp)
if err != nil {
panic(err)
}
kb := NewKeyBoard(&config.KeyBoardOptions)
for _, k := range config.Keys {
if len(k.RuneValue) > 1 {
// DO SOMETHING?
}
r := []rune(k.RuneValue)
kb.RegisterKey(k.Label, r[0])
}
return &Game{keyboard: kb}
}
func (g *Game) Update() (err error) {
g.keyboard.Update()
return
}
func (g *Game) Draw(screen *ebiten.Image) {
g.keyboard.Draw(screen)
}
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
return g.keyboard.bpWidth, g.keyboard.bpHeight
}
func main() {
go windows_api.TrackActiveWindow()
g := NewGame()
ebiten.SetWindowSize(g.keyboard.bpWidth, g.keyboard.bpHeight)
ebiten.SetWindowFloating(true)
ebiten.SetWindowDecorated(true)
ebiten.SetRunnableOnUnfocused(true)
ebiten.SetWindowTitle("MacroBoard")
if err := ebiten.RunGame(g); err != nil {
log.Fatal(err)
}
}