ui starting, menu screen, ingame help

This commit is contained in:
2019-11-08 03:36:26 +03:00
parent 4532320ce3
commit cb7718860a
11 changed files with 271 additions and 40 deletions

View File

@ -6,12 +6,12 @@ import (
)
type Layer struct {
idx int
Idx int
defaultColor uint32
}
func (layer *Layer) before() *Layer {
blt.Layer(layer.idx)
blt.Layer(layer.Idx)
return layer
}
@ -61,6 +61,7 @@ func (Layer *Layer) PutToBase(x,y int, symbol interface{}, fg uint32, bg uint32)
rnes := []rune(symbol.(string))
prevColor := uint32(blt.State(blt.TK_COLOR))
prevBgColor := uint32(blt.State(blt.TK_BKCOLOR))
blt.Layer(0)
blt.BkColor(bg)
blt.Color(fg)
if (len(rnes)) > 0 {
@ -87,7 +88,13 @@ func (layer Layer) Put(x, y int, symbol interface{}) {
}
func (layer Layer) Print(x, y int, txt string) (w, h int) {
return blt.Print(x, y, txt)
w, h = blt.Print(x, y, txt)
//blt.Layer(0)
return w, h
}
func (layer Layer) PrintInside(rect *types.Rect, text string, alignment int) (width int, height int) {
return blt.PrintExt(rect.X + 2, rect.Y + 2, rect.W - 4, rect.H - 4, alignment, text)
}
func (layer *Layer) Decorate(f func(args ...interface{})) func(args ...interface{}) {
@ -99,7 +106,10 @@ func (layer *Layer) Decorate(f func(args ...interface{})) func(args ...interface
}
func (layer *Layer) ClearRect(r *types.Rect) {
prevLayer := int(blt.State(blt.TK_LAYER))
blt.Layer(layer.Idx)
blt.ClearArea(r.X, r.Y, r.W, r.H)
blt.Layer(prevLayer)
}
func (layer *Layer) ClearArea(x,y,w,h int) {

View File

@ -24,7 +24,7 @@ func Init(ctx util.ClientCtx) *MainWindow {
func (mw *MainWindow) AddLayer(name string, idx int, colorName string) *MainWindow {
c := blt.ColorFromName(colorName)
mw.layers[name] = &Layer{idx: idx, defaultColor: c}
mw.layers[name] = &Layer{Idx: idx, defaultColor: c}
return mw
}

View File

@ -43,9 +43,9 @@ type UiWindow struct {
fillage types.RectFill
}
func (layer *Layer) NewWindow(x, y, w, h int) *UiWindow {
func (layer *Layer) NewWindow(rect *types.Rect) *UiWindow {
return &UiWindow{
Rect: types.NewRect(x, y, w, h),
Rect: rect,
layer: layer,
}
}

View File

@ -105,8 +105,8 @@ func (vp *ViewPort) Render(state *gamestate.GameState) {
vp.Fov.ComputeFov(state.Level, playerCoords, vp.TorchRadius)
}
vp.layer.ClearArea(0, 7, 20, 1)
vp.layer.Print(0,7, fmt.Sprintf("pcds: %v", playerCoords))
//vp.layer.ClearArea(0, 7, 20, 1)
//vp.layer.Print(0,7, fmt.Sprintf("pcds: %v", playerCoords))
if redraw {