rename mode to view

master
Jordan Orelli 4 years ago
parent eec726bce4
commit 9f2067e3d0

@ -15,7 +15,7 @@ type UI struct {
*blammo.Log *blammo.Log
PlayerName string PlayerName string
screen tcell.Screen screen tcell.Screen
mode Mode view view
client *wire.Client client *wire.Client
} }
@ -44,7 +44,7 @@ func (ui *UI) Run() {
for _, e := range welcome.Contents { for _, e := range welcome.Contents {
entities[e.ID] = e entities[e.ID] = e
} }
ui.mode = &roomDisplay{ ui.view = &roomDisplay{
width: welcome.Size[0], width: welcome.Size[0],
height: welcome.Size[1], height: welcome.Size[1],
entities: entities, entities: entities,
@ -102,8 +102,8 @@ func (ui *UI) clearTerminal() {
func (ui *UI) handleNotifications(c <-chan wire.Response) { func (ui *UI) handleNotifications(c <-chan wire.Response) {
for n := range c { for n := range c {
ui.Info("ignoring notification: %v", n) ui.Info("ignoring notification: %v", n)
ui.mode.notify(n.Body) ui.view.notify(n.Body)
ui.mode.draw(ui) ui.view.draw(ui)
ui.screen.Show() ui.screen.Show()
} }
ui.Info("notifications channel is closed so we must be done") ui.Info("notifications channel is closed so we must be done")
@ -132,7 +132,7 @@ func (ui *UI) writeString(x, y int, s string, style tcell.Style) {
func (ui *UI) handleUserInput() bool { func (ui *UI) handleUserInput() bool {
ui.screen.Clear() ui.screen.Clear()
ui.mode.draw(ui) ui.view.draw(ui)
for { for {
e := ui.screen.PollEvent() e := ui.screen.PollEvent()
@ -152,9 +152,9 @@ func (ui *UI) handleUserInput() bool {
} }
} }
ui.mode.handleEvent(ui, e) ui.view.handleEvent(ui, e)
ui.screen.Clear() ui.screen.Clear()
ui.mode.draw(ui) ui.view.draw(ui)
ui.screen.Show() ui.screen.Show()
} }
} }

@ -6,7 +6,7 @@ import (
"github.com/jordanorelli/astro-domu/internal/wire" "github.com/jordanorelli/astro-domu/internal/wire"
) )
type Mode interface { type view interface {
handleEvent(*UI, tcell.Event) bool handleEvent(*UI, tcell.Event) bool
notify(wire.Value) notify(wire.Value)
draw(*UI) draw(*UI)
Loading…
Cancel
Save