From ce57fd472b5ebcd04349ab0f0593d740a2b8536b Mon Sep 17 00:00:00 2001 From: Robert Janetzko Date: Fri, 6 May 2022 13:16:16 +0000 Subject: [PATCH] civ colors --- analyze/overwrites.json | 4 +++ backend/model/context.go | 23 ++++++++++++-- backend/model/model.go | 7 ++++- backend/model/process.go | 6 ++++ backend/static/css/legends.css | 5 ++++ backend/templates/artforms.html | 33 ++++++++++---------- backend/templates/entity.html | 45 +++++++++++++++------------- backend/templates/geography.html | 43 +++++++++++++------------- backend/templates/popoverEntity.html | 5 +++- backend/templates/site.html | 20 ++++++++----- 10 files changed, 122 insertions(+), 69 deletions(-) diff --git a/analyze/overwrites.json b/analyze/overwrites.json index 7278bc1..e83ea45 100644 --- a/analyze/overwrites.json +++ b/analyze/overwrites.json @@ -87,6 +87,10 @@ } ], "Entity": [ + { + "Name": "Parent", + "Type": "int" + }, { "Name": "Necromancer", "Type": "bool" diff --git a/backend/model/context.go b/backend/model/context.go index d1071cc..594ca0b 100644 --- a/backend/model/context.go +++ b/backend/model/context.go @@ -94,10 +94,13 @@ func hfIcon(x *HistoricalFigure) string { case x.Necromancer: return ` ` case x.Werebeast: - return ` ` + return ` ` case x.Vampire: return ` ` } + if len(x.SiteLink) > 0 && x.SiteLink[0].LinkType == SiteLinkLinkType_Lair { + return ` ` + } return "" } @@ -138,7 +141,23 @@ func (c *Context) artifact(id int) string { func (c *Context) entity(id int) string { if x, ok := c.World.Entities[id]; ok { - return fmt.Sprintf(` %s`, x.Id(), x.Icon(), util.Title(x.Name())) + c := "" + switch x.Race { + case "dwarf": + c = ` style="color:#FFCC33"` + case "elf": + c = ` style="color:#99FF00"` + case "human": + c = ` style="color:#0000CC"` + case "kobold": + c = ` style="color:#333"` + case "goblin": + c = ` style="color:#CC0000"` + } + if x.Necromancer { + c = ` style="color:#A0A"` + } + return fmt.Sprintf(` %s`, x.Id(), x.Icon(), c, util.Title(x.Name())) } return "UNKNOWN ENTITY" } diff --git a/backend/model/model.go b/backend/model/model.go index 04ec7c3..7e8402d 100644 --- a/backend/model/model.go +++ b/backend/model/model.go @@ -1992,13 +1992,15 @@ type Entity struct { WorshipId []int `json:"worshipId" legend:"plus" related:""` // worship_id Leaders []*EntityLeader `json:"leaders" legend:"add" related:""` // Leaders Necromancer bool `json:"necromancer" legend:"add" related:""` // Necromancer + Parent int `json:"parent" legend:"add" related:""` // Parent Sites []int `json:"sites" legend:"add" related:""` // Sites Wars []*HistoricalEventCollection `json:"wars" legend:"add" related:""` // Wars } func NewEntity() *Entity { return &Entity{ - Id_: -1, + Id_: -1, + Parent: -1, } } func (x *Entity) Id() int { return x.Id_ } @@ -2033,6 +2035,9 @@ func (x *Entity) MarshalJSON() ([]byte, error) { d["worshipId"] = x.WorshipId d["leaders"] = x.Leaders d["necromancer"] = x.Necromancer + if x.Parent != -1 { + d["parent"] = x.Parent + } d["sites"] = x.Sites d["wars"] = x.Wars return json.Marshal(d) diff --git a/backend/model/process.go b/backend/model/process.go index 17e5403..43b40fc 100644 --- a/backend/model/process.go +++ b/backend/model/process.go @@ -32,6 +32,12 @@ func (w *DfWorld) process() { } } + for _, l := range e.EntityLink { + if l.Type_ == EntityEntityLinkType_PARENT { + e.Parent = l.Target + } + } + idx := slices.Index(e.Child, e.Id_) if idx != -1 { e.Child = append(e.Child[:idx], e.Child[idx+1:]...) diff --git a/backend/static/css/legends.css b/backend/static/css/legends.css index 6868ec7..47068c8 100644 --- a/backend/static/css/legends.css +++ b/backend/static/css/legends.css @@ -86,6 +86,11 @@ td.object { @media (prefers-color-scheme: dark) { + .bg-light { + --bs-bg-opacity: 1; + background-color: rgba(var(--bs-dark-rgb), var(--bs-bg-opacity)) !important; + } + a { color: #337ab7; } diff --git a/backend/templates/artforms.html b/backend/templates/artforms.html index 002087f..cfd601d 100644 --- a/backend/templates/artforms.html +++ b/backend/templates/artforms.html @@ -7,24 +7,25 @@