aboutsummaryrefslogtreecommitdiff
path: root/internal/game/render_color.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-08-03 17:15:50 -0400
committerhistoria <[not public]>2026-08-03 17:15:50 -0400
commita2cbc04f86508708daa09affa5e9d73cc689b2ba (patch)
tree0d0c6c7fbf4a775faaf5e9dd700157b883882638 /internal/game/render_color.go
parentadda27dba5bf7bf1dee62159f0cbc0bd90734751 (diff)
downloadthehouseoficarus-a2cbc04f86508708daa09affa5e9d73cc689b2ba.tar.gz
feat: new color 'command', color tag system implemented
Diffstat (limited to 'internal/game/render_color.go')
-rw-r--r--internal/game/render_color.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/internal/game/render_color.go b/internal/game/render_color.go
index 958b671..ab3692e 100644
--- a/internal/game/render_color.go
+++ b/internal/game/render_color.go
@@ -107,3 +107,58 @@ func (g *Game) itemColorize(sess *net.Session, itemDef *item.ItemDef, text strin
}
return g.colorize(sess, "item", text)
}
+
+// namedColorSpecs maps every color category name to its resolved ColorSpec
+// for the session, letting inline tags like {command} bind to a color
+// category. All player-overridable categories, server defaults, and constant
+// colors are included so any color can be tagged in data content.
+func (g *Game) namedColorSpecs(sess *net.Session) map[string]color.ColorSpec {
+ names := make(map[string]color.ColorSpec)
+ for name := range config.DefaultColors() {
+ if spec := g.resolveColor(sess, name); !spec.Empty() {
+ names[name] = spec
+ }
+ }
+ if g.ColorConfig != nil {
+ for name := range *g.ColorConfig {
+ if _, ok := names[name]; ok {
+ continue
+ }
+ if spec := g.resolveColor(sess, name); !spec.Empty() {
+ names[name] = spec
+ }
+ }
+ }
+ for name := range config.DefaultConstantColors() {
+ if spec := g.resolveConstant(sess, name); !spec.Empty() {
+ names[name] = spec
+ }
+ }
+ if g.ConstantColorConfig != nil {
+ for name := range *g.ConstantColorConfig {
+ if _, ok := names[name]; ok {
+ continue
+ }
+ if spec := g.resolveConstant(sess, name); !spec.Empty() {
+ names[name] = spec
+ }
+ }
+ }
+ return names
+}
+
+// expandTags expands inline {spec}text{/} tags, including named color
+// categories such as {command}, using the session's resolved colors.
+func (g *Game) expandTags(sess *net.Session, text string) string {
+ return color.ExpandTagsNamed(g.colorMode(sess), g.namedColorSpecs(sess), text)
+}
+
+// expandTagsDefault is expandTags with a default spec applied to untagged text.
+func (g *Game) expandTagsDefault(sess *net.Session, def color.ColorSpec, text string) string {
+ return color.ExpandTagsDefaultNamed(g.colorMode(sess), def, g.namedColorSpecs(sess), text)
+}
+
+// expandDialogTags expands dialog text (quoted speech) with named color tags.
+func (g *Game) expandDialogTags(sess *net.Session, dialogSpec color.ColorSpec, text string) string {
+ return color.ExpandDialogTagsNamed(g.colorMode(sess), dialogSpec, g.namedColorSpecs(sess), text)
+}