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 }} +
+
+
+{{initMap}} +{{ addCollection .Id }} +{{- end }} +

{{ html (capitalize (string (collection .Id))) }}

{{- if eq .Type "occasion" }}{{- with getOccasion .Details.CivId .Details.OccasionId }}{{- if ne .Event -1 }} diff --git a/backend/templates/collections.html b/backend/templates/collections.html index 924ae71..bd8932f 100644 --- a/backend/templates/collections.html +++ b/backend/templates/collections.html @@ -8,8 +8,8 @@ diff --git a/backend/templates/entities.html b/backend/templates/entities.html index 347332d..a58dcd5 100644 --- a/backend/templates/entities.html +++ b/backend/templates/entities.html @@ -8,8 +8,8 @@ diff --git a/backend/templates/entity.html b/backend/templates/entity.html index 930f5c1..b7fb607 100644 --- a/backend/templates/entity.html +++ b/backend/templates/entity.html @@ -32,22 +32,19 @@ diff --git a/backend/templates/geography.html b/backend/templates/geography.html index 16f5b6d..2e684b4 100644 --- a/backend/templates/geography.html +++ b/backend/templates/geography.html @@ -9,20 +9,20 @@ diff --git a/backend/templates/layout.html b/backend/templates/layout.html index 9a24346..37bde3b 100644 --- a/backend/templates/layout.html +++ b/backend/templates/layout.html @@ -89,12 +89,13 @@ var hash = document.location.hash; if (hash && hash.startsWith("#nav-")) { var hashPieces = hash.split('?'); - activeTab = $('.nav-link[data-bs-target="' + hashPieces[0] + '"]'); - console.log(hashPieces[0], activeTab); - activeTab && activeTab.click() + + var someTabTriggerEl = document.querySelector('.nav-link[data-bs-target="' + hashPieces[0] + '"]') + var tab = new bootstrap.Tab(someTabTriggerEl) + tab.show() } - $('.nav-tabs button').on('click', function (e) { + $('.nav-tabs button,.nav-tabs a').on('click', function (e) { window.location.hash = $(this).data("bs-target") }); diff --git a/backend/templates/regions.html b/backend/templates/regions.html index fafeba1..7240536 100644 --- a/backend/templates/regions.html +++ b/backend/templates/regions.html @@ -8,8 +8,8 @@ diff --git a/backend/templates/site.html b/backend/templates/site.html index c2d1951..be20844 100644 --- a/backend/templates/site.html +++ b/backend/templates/site.html @@ -8,19 +8,21 @@

{{ title .Name }}

{{ .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 }}

{{ title .Name }}

diff --git a/backend/templates/worldconstructions.html b/backend/templates/worldconstructions.html index b50d094..c2716de 100644 --- a/backend/templates/worldconstructions.html +++ b/backend/templates/worldconstructions.html @@ -8,8 +8,8 @@ diff --git a/backend/templates/writtencontents.html b/backend/templates/writtencontents.html index 905e7ce..9707d23 100644 --- a/backend/templates/writtencontents.html +++ b/backend/templates/writtencontents.html @@ -8,8 +8,8 @@