alchemyst/ui/mainwindow/window.go
anton.gurov ed5a425dab updates
2019-10-25 18:47:10 +03:00

52 lines
1.1 KiB
Go

package mainwindow
import (
"fmt"
"lab.zaar.be/thefish/alchemyst-go/util"
blt "lab.zaar.be/thefish/bearlibterminal"
)
type MainWindow struct {
ctx util.ClientCtx
layers []LayerInterface
}
func Init(ctx util.ClientCtx) *MainWindow {
ctx.Logger().Info().Msgf("Opening main window...")
mw := MainWindow{ctx: ctx}
mw.Open()
return &mw
}
func (mw *MainWindow) Open() {
config := mw.ctx.Config()
blt.Open()
//blt.Set("window: size=80x25, title="+config.Title+" v"+string(version)+"; font: ./fonts/Monaco-Linux.ttf, size=10")
blt.Set(
fmt.Sprintf(
//"window: size=%dx%d, title='%s v%s'; font: ./resources/fonts-bitmap/ibmnew8x12.png, size=8x12;",
"window: size=%dx%d, title='%s v%s'; font: %s, size=8x16;",
//"window: size=%dx%d, title='%s v%s'",
config.MainWindowSizeX,
config.MainWindowSizeY,
config.Title,
config.Version,
config.Font,
),
)
}
func (mw *MainWindow) Close() {
mw.ctx.Logger().Info().Msg("Closing main window...")
blt.Close()
}
func (mw *MainWindow) Render() {
for _, l := range mw.layers {
l.Render()
}
}
func (mw *MainWindow) AddLayer(li LayerInterface) {
mw.layers = append(mw.layers, li)
}