diff --git a/internal/app/border_view.go b/internal/app/border_view.go new file mode 100644 index 0000000..a85bc7c --- /dev/null +++ b/internal/app/border_view.go @@ -0,0 +1,32 @@ +package app + +import ( + "github.com/gdamore/tcell/v2" + "github.com/jordanorelli/astro-domu/internal/math" +) + +type borderedView struct { + inner view +} + +func (b borderedView) handleEvent(e tcell.Event) change { + return b.inner.handleEvent(e) +} + +func (b borderedView) draw(img canvas, st *state) { + bounds := img.bounds() + img.setTile(0, 0, tile{r: '┌'}) + img.setTile(bounds.Width-1, 0, tile{r: '┐'}) + img.setTile(0, bounds.Height-1, tile{r: '└'}) + img.setTile(bounds.Width-1, bounds.Height-1, tile{r: '┘'}) + for x := 1; x < bounds.Width-1; x++ { + img.setTile(x, 0, tile{r: '─'}) + img.setTile(x, bounds.Height-1, tile{r: '─'}) + } + for y := 1; y < bounds.Height-1; y++ { + img.setTile(0, y, tile{r: '│'}) + img.setTile(bounds.Width-1, y, tile{r: '│'}) + } + + b.inner.draw(cut(img, math.Rect{math.Vec{1, 1}, bounds.Width - 2, bounds.Height - 2}), st) +} diff --git a/internal/app/menu_list.go b/internal/app/menu_list.go index e9791c9..b78066d 100644 --- a/internal/app/menu_list.go +++ b/internal/app/menu_list.go @@ -33,7 +33,7 @@ func (m *menuList) handleEvent(e tcell.Event) change { } func (m *menuList) draw(img canvas, _ *state) { - fill(img, tcell.StyleDefault.Background(tcell.NewRGBColor(64, 32, 32))) + // fill(img, tcell.StyleDefault.Background(tcell.NewRGBColor(64, 32, 32))) for i, choice := range m.choices { if i == m.highlight { writeString(img, "▷ "+choice.name, math.Vec{0, i}, tcell.StyleDefault) diff --git a/internal/app/ui.go b/internal/app/ui.go index b4346a0..ad126d7 100644 --- a/internal/app/ui.go +++ b/internal/app/ui.go @@ -201,22 +201,24 @@ var inGameView = &containerView{ children: []*node{ { frame: math.Rect{math.Vec{0, 0}, 4, 4}, - view: &gameView{}, + view: borderedView{&gameView{}}, }, { frame: math.Rect{math.Vec{4, 0}, 4, 4}, - view: &menuList{ - choices: []menuItem{ - menuItem{name: "chocolate"}, - menuItem{name: "vanilla"}, - menuItem{name: "strawberry"}, - menuItem{name: "banana"}, + view: borderedView{ + &menuList{ + choices: []menuItem{ + menuItem{name: "chocolate"}, + menuItem{name: "vanilla"}, + menuItem{name: "strawberry"}, + menuItem{name: "banana"}, + }, }, }, }, { frame: math.Rect{math.Vec{0, 4}, 8, 4}, - view: &chatView{}, + view: borderedView{inner: &chatView{}}, }, }, }