slight refactor, gofmt
This commit is contained in:
68
ui/mainwindow/uiwindow.go
Normal file
68
ui/mainwindow/uiwindow.go
Normal file
@ -0,0 +1,68 @@
|
||||
package mainwindow
|
||||
|
||||
import "lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
|
||||
var noborder = types.RectFill{
|
||||
Top: "▄",
|
||||
Bottom: "▀",
|
||||
Left: "▐",
|
||||
Right: "▌",
|
||||
TopLeft: "▗",
|
||||
TopRight: "▖",
|
||||
BottomLeft: "▝",
|
||||
BottomRight: "▘",
|
||||
Body: "█",
|
||||
}
|
||||
|
||||
var splash = types.RectFill{
|
||||
Top: "█",
|
||||
Bottom: "█",
|
||||
Left: "█",
|
||||
Right: "█",
|
||||
TopLeft: "█",
|
||||
TopRight: "█",
|
||||
BottomLeft: "█",
|
||||
BottomRight: "█",
|
||||
Body: "█",
|
||||
}
|
||||
|
||||
var doubleBorder = types.RectFill{
|
||||
Top: "═",
|
||||
Bottom: "═",
|
||||
Left: "║",
|
||||
Right: "║",
|
||||
TopLeft: "╔",
|
||||
TopRight: "╗",
|
||||
BottomLeft: "╚",
|
||||
BottomRight: "╝",
|
||||
}
|
||||
|
||||
type UiWindow struct {
|
||||
*types.Rect
|
||||
layer *Layer
|
||||
fillage types.RectFill
|
||||
}
|
||||
|
||||
func (layer *Layer) NewWindow(x, y, w, h int) *UiWindow {
|
||||
return &UiWindow{
|
||||
Rect: types.NewRect(x, y, w, h),
|
||||
layer: layer,
|
||||
}
|
||||
}
|
||||
|
||||
func (uiw *UiWindow) NoBorder() {
|
||||
uiw.RenderToLayer(noborder, uiw.layer)
|
||||
}
|
||||
|
||||
func (uiw *UiWindow) Splash() {
|
||||
uiw.RenderToLayer(splash, uiw.layer)
|
||||
}
|
||||
|
||||
func (uiw *UiWindow) DoubleBordered(title string) {
|
||||
uiw.RenderToLayer(doubleBorder, uiw.layer)
|
||||
if len(title) > (uiw.W - 2) {
|
||||
title = title[:(uiw.W - 2)]
|
||||
}
|
||||
centerX := uiw.X + (uiw.W / 2)
|
||||
uiw.layer.Print(centerX-(len(title)/2)-1, uiw.Y, "╡"+title+"╞")
|
||||
}
|
Reference in New Issue
Block a user