new theme
This commit is contained in:
@@ -51,6 +51,26 @@ type Game struct {
|
||||
speech speechState
|
||||
dialog *runtimeDialog
|
||||
activeDialog string
|
||||
|
||||
// in-game message log for ChatLog widgets; ring buffer behavior.
|
||||
messages []LogMessage
|
||||
MaxLogLines int // 0 = unlimited (memory grows); set per-game.
|
||||
}
|
||||
|
||||
// LogKind classifies a chat-log entry — UI widgets style them differently.
|
||||
type LogKind int
|
||||
|
||||
const (
|
||||
LogAction LogKind = iota // player command ("> look at door")
|
||||
LogResponse // in-world reply / Say output
|
||||
LogSystem // game/system message
|
||||
)
|
||||
|
||||
// LogMessage is a single line in the chat-log buffer.
|
||||
type LogMessage struct {
|
||||
Speaker string // empty for actions / system
|
||||
Text string
|
||||
Kind LogKind
|
||||
}
|
||||
|
||||
// speechState is what the SpeechBubble widget renders. Mutated by Say.
|
||||
@@ -130,6 +150,48 @@ func (g *Game) FlashLine(text string) {
|
||||
g.flashTimer = 2.0
|
||||
}
|
||||
|
||||
// LogAction appends a player-command line (rendered with the prompt color
|
||||
// by ChatLog widgets).
|
||||
func (g *Game) LogAction(text string) {
|
||||
g.appendLog(LogMessage{Text: text, Kind: LogAction})
|
||||
}
|
||||
|
||||
// LogResponse appends a reply line (rendered with the response color).
|
||||
func (g *Game) LogResponse(speaker, text string) {
|
||||
g.appendLog(LogMessage{Speaker: speaker, Text: text, Kind: LogResponse})
|
||||
}
|
||||
|
||||
// LogSystem appends a system/meta line (rendered with the response color).
|
||||
func (g *Game) LogSystem(text string) {
|
||||
g.appendLog(LogMessage{Text: text, Kind: LogSystem})
|
||||
}
|
||||
|
||||
func (g *Game) appendLog(m LogMessage) {
|
||||
g.messages = append(g.messages, m)
|
||||
if g.MaxLogLines > 0 && len(g.messages) > g.MaxLogLines {
|
||||
g.messages = g.messages[len(g.messages)-g.MaxLogLines:]
|
||||
}
|
||||
}
|
||||
|
||||
// Messages returns the current log buffer (read-only).
|
||||
func (g *Game) Messages() []LogMessage { return g.messages }
|
||||
|
||||
// CharacterInScene reports whether a registered character is listed as
|
||||
// an actor in the current scene. Used by the CharacterPanel widget so
|
||||
// it auto-hides when the character isn't in view.
|
||||
func (g *Game) CharacterInScene(name string) bool {
|
||||
if g.currentScene == "" {
|
||||
return false
|
||||
}
|
||||
s := g.SceneManager.MustGet(g.currentScene)
|
||||
for _, a := range s.Actors {
|
||||
if a.CharacterName == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// DrawText is a thin wrapper that lets widgets accept a Theme-supplied color
|
||||
// today and switch to text/v2 later without changing call sites.
|
||||
func (g *Game) DrawText(dst *ebiten.Image, s string, x, y int, c color.Color) {
|
||||
|
||||
Reference in New Issue
Block a user