aboutsummaryrefslogtreecommitdiff
path: root/go/dummy-ui/main.go
blob: cf49813e4175019825f4ea42491873e4d9810c43 (plain)
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
package main

import (
	"fmt"
	"image/color"

	"github.com/hajimehoshi/ebiten/v2"

	"muhq.space/muhqs-game/go/font"
	"muhq.space/muhqs-game/go/ui"
)

type app struct {
	ui.Collection
	windowWidth  int
	windowHeight int
}

func (a *app) Update() error {
	if a.Widgets() == nil {
		a.build()
	}

	return a.Collection.Update()
}

func (a *app) build() {
	nc := ui.NewNumberChoice(a.windowWidth-ui.NUMBER_CHOICE_WIDTH,
		a.windowHeight-ui.NUMBER_CHOICE_HEIGHT,
		0,
		func(nc *ui.NumberChoice) {
			fmt.Println(nc.GetChoosen())
		})
	a.AddWidget(nc)

	tbBg := ui.NewFixedTextBox(100, 100, 200, 200, "c").Bg(color.White).Fg(color.Black).Centering(true)
	a.AddWidget(tbBg)
	// tb := ui.NewAutoTextBox(100, 100, "Nasenbär\nZweite Zeile")
	// a.AddWidget(tb)
}

func (a *app) Layout(width, height int) (int, int) {
	return a.windowWidth, a.windowHeight
}

func main() {
	font.InitFont()
	app := &app{windowWidth: 800, windowHeight: 1000}
	ebiten.SetWindowSize(app.windowWidth, app.windowHeight)
	ebiten.SetWindowTitle("Muhq's Game")
	_ = ebiten.RunGame(app)
}