diff --git a/backend/model/functions.go b/backend/model/functions.go index fd31096..94bce94 100644 --- a/backend/model/functions.go +++ b/backend/model/functions.go @@ -127,6 +127,45 @@ var AddMapRiver = func(w *DfWorld, id int) template.HTML { return "" } +func AddMapCollection(w *DfWorld, id int) template.HTML { + if x, ok := w.HistoricalEventCollections[id]; ok { + r := "" + switch d := x.Details.(type) { + case *HistoricalEventCollectionBeastAttack: + r += string(AddMapSite(w, d.SiteId, false)) + case *HistoricalEventCollectionDuel: + c1 := strings.Split(d.Coords, ",") + x, _ := strconv.Atoi(c1[0]) + y, _ := strconv.Atoi(c1[1]) + r += fmt.Sprintf(``, id, x, y) + case *HistoricalEventCollectionSiteConquered: + r += string(AddMapSite(w, d.SiteId, false)) + case *HistoricalEventCollectionBattle: + if d.SiteId != -1 { + r += string(AddMapSite(w, d.SiteId, false)) + } + + for _, s := range d.AttackingSquadSite { + r += string(AddMapSite(w, s, true)) + } + for _, s := range d.DefendingSquadSite { + r += string(AddMapSite(w, s, true)) + } + + c1 := strings.Split(d.Coords, ",") + x, _ := strconv.Atoi(c1[0]) + y, _ := strconv.Atoi(c1[1]) + r += fmt.Sprintf(``, id, x, y) + case *HistoricalEventCollectionWar: + for _, y := range x.Eventcol { + r += string(AddMapCollection(w, y)) + } + } + return template.HTML(r) + } + return "" +} + var AndList = func(s []string) template.HTML { return template.HTML(andList(s)) } func andList(list []string) string { diff --git a/backend/server/templates.go b/backend/server/templates.go index a2e3380..1b7b501 100644 --- a/backend/server/templates.go +++ b/backend/server/templates.go @@ -69,6 +69,7 @@ func (srv *DfServer) LoadTemplates() { "addMountain": func(id int, color bool) template.HTML { return model.AddMapMountain(srv.context.world, id, color) }, "addWorldConstruction": func(id int) template.HTML { return model.AddMapWorldConstruction(srv.context.world, id) }, "addRiver": func(id int) template.HTML { return model.AddMapRiver(srv.context.world, id) }, + "addCollection": func(id int) template.HTML { return model.AddMapCollection(srv.context.world, id) }, "events": func(obj any) *model.EventList { return model.NewEventList(srv.context.world, obj) diff --git a/backend/static/css/legends.css b/backend/static/css/legends.css index f46f33f..91e7db3 100644 --- a/backend/static/css/legends.css +++ b/backend/static/css/legends.css @@ -28,6 +28,12 @@ a { margin-bottom: 16px; } +.page-tabs .tab-content { + overflow-y: auto; + max-height: 300px; + margin-bottom: 16px; +} + .popover { max-width: fit-content; } diff --git a/backend/static/js/map.js b/backend/static/js/map.js index c3af428..8d5addb 100644 --- a/backend/static/js/map.js +++ b/backend/static/js/map.js @@ -189,7 +189,7 @@ function coord(y, x) { return [x, y]; } -function addBattle(name, y, x) { +function addBattle(id, y, x) { x = worldWidth - x - 1; var polygon = L.polygon( [[x + 0.5, y + battleOffset], @@ -201,7 +201,7 @@ function addBattle(name, y, x) { weight: 3 }).addTo(map); - attachTooltip(polygon, name); + attachTooltip(polygon, urlToolTip("collection", id)); minx = Math.min(x, minx); miny = Math.min(y, miny); diff --git a/backend/templates/artforms.html b/backend/templates/artforms.html index cfd601d..3fc804d 100644 --- a/backend/templates/artforms.html +++ b/backend/templates/artforms.html @@ -9,16 +9,16 @@
diff --git a/backend/templates/artifacts.html b/backend/templates/artifacts.html index d99b095..1579ae7 100644 --- a/backend/templates/artifacts.html +++ b/backend/templates/artifacts.html @@ -8,8 +8,8 @@ diff --git a/backend/templates/collection.html b/backend/templates/collection.html index d374419..06b2827 100644 --- a/backend/templates/collection.html +++ b/backend/templates/collection.html @@ -4,6 +4,14 @@ {{define "content"}} +{{ if world.MapReady }} +{{ .Type_ }}
+ {{ $history := history .Id }} + {{ $active = ""}}{{- end}} - {{ if world.MapReady }} diff --git a/backend/templates/sites.html b/backend/templates/sites.html index 3c18476..49023ae 100644 --- a/backend/templates/sites.html +++ b/backend/templates/sites.html @@ -8,8 +8,8 @@ diff --git a/backend/templates/structures.html b/backend/templates/structures.html index 0b7c71c..e913104 100644 --- a/backend/templates/structures.html +++ b/backend/templates/structures.html @@ -8,8 +8,8 @@ diff --git a/backend/templates/worldconstruction.html b/backend/templates/worldconstruction.html index 9ff9299..35a54bf 100644 --- a/backend/templates/worldconstruction.html +++ b/backend/templates/worldconstruction.html @@ -10,6 +10,9 @@ {{initMap}} {{ addWorldConstruction .Id }} +{{- range .Parts }} +{{ addWorldConstruction . }} +{{- end }} {{- end }}