From fa732377c785f9e99df5774e36ee072bb0b5bfb0 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Mon, 9 Nov 2020 23:58:47 +0000 Subject: [PATCH] styling --- internal/app/chat_view.go | 19 ++++++++++++++----- internal/app/game_view.go | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/internal/app/chat_view.go b/internal/app/chat_view.go index 3cfbf24..0c2b7a4 100644 --- a/internal/app/chat_view.go +++ b/internal/app/chat_view.go @@ -48,18 +48,27 @@ func (c *chatView) handleEvent(e tcell.Event) change { func (c *chatView) draw(img canvas, st *state) { bounds := img.bounds() - fill(img, tcell.StyleDefault.Background(tcell.NewRGBColor(32, 32, 32))) + style := tcell.StyleDefault.Background(tcell.NewRGBColor(32, 32, 32)) + fill(img, style) chatHeight := bounds.Height - 1 + for i := 0; i < math.Min(chatHeight, len(st.history)); i++ { msg := st.history[len(st.history)-1-i] - s := fmt.Sprintf("%12s: %s", msg.From, msg.Text) - writeString(img, s, math.Vec{0, bounds.Height - 2 - i}, tcell.StyleDefault) + nameText := fmt.Sprintf("%12s: ", msg.From) + if msg.From == st.playerName { + style := style.Foreground(tcell.NewRGBColor(255, 32, 32)) + writeString(img, nameText, math.Vec{0, bounds.Height - 2 - i}, style) + } else { + style := style.Foreground(tcell.NewRGBColor(32, 32, 255)) + writeString(img, nameText, math.Vec{0, bounds.Height - 2 - i}, style) + } + writeString(img, msg.Text, math.Vec{14, bounds.Height - 2 - i}, style) } - writeString(img, c.composing, math.Vec{0, bounds.Height - 1}, tcell.StyleDefault) + writeString(img, c.composing, math.Vec{0, bounds.Height - 1}, style) if c.inFocus { - cursor := tile{r: tcell.RuneBlock, style: tcell.StyleDefault.Blink(true)} + cursor := tile{r: tcell.RuneBlock, style: style.Blink(true)} img.setTile(len([]rune(c.composing)), bounds.Height-1, cursor) } } diff --git a/internal/app/game_view.go b/internal/app/game_view.go index e5d3672..ab2a143 100644 --- a/internal/app/game_view.go +++ b/internal/app/game_view.go @@ -34,7 +34,7 @@ func (v *gameView) handleEvent(e tcell.Event) change { } func (v *gameView) draw(img canvas, st *state) { - fill(img, tcell.StyleDefault.Background(tcell.NewRGBColor(128, 128, 128))) + fill(img, tcell.StyleDefault.Background(tcell.NewRGBColor(0, 0, 12))) v.drawHeader(img, st) // fill in background dots first