diff --git a/backend/model/functions.go b/backend/model/functions.go
index 2b42b7e..200608d 100644
--- a/backend/model/functions.go
+++ b/backend/model/functions.go
@@ -86,7 +86,10 @@ var AddMapSite = func(w *DfWorld, id int) template.HTML {
if e, ok := w.Entities[site.Owner]; ok {
c = e.Color()
}
- return template.HTML(fmt.Sprintf(``, site.Name(), x1/16.0, y1/16.0-1, x2/16.0, y2/16.0-1, c))
+ if site.Ruin {
+ c = "#aaa"
+ }
+ return template.HTML(fmt.Sprintf(``, site.Id_, x1/16.0, y1/16.0-1, x2/16.0, y2/16.0-1, c))
} else {
return ""
}
@@ -97,7 +100,7 @@ var AddMapMountain = func(w *DfWorld, id int) template.HTML {
c1 := strings.Split(m.Coords, ",")
x, _ := strconv.Atoi(c1[0])
y, _ := strconv.Atoi(c1[1])
- return template.HTML(fmt.Sprintf(``, m.Name_, x, y))
+ return template.HTML(fmt.Sprintf(``, m.Id_, x, y))
}
return ""
}
@@ -113,7 +116,7 @@ var AddMapWorldConstruction = func(w *DfWorld, id int) template.HTML {
r += "var polyline = L.polyline(["
r += strings.Join(util.Map(x.Line(), func(c Coord) string { return fmt.Sprintf(`coord(%d+0.5,%d-0.5)`, c.X, c.Y) }), ",")
r += "], {color: '" + color + "', opacity: 1, weight: 3}).addTo(constructionsLayer);\n"
- r += "attachTooltip(polyline, '" + x.Name_ + "');\n"
+ r += fmt.Sprintf(`attachTooltip(polyline, urlToolTip('worldconstruction', %d));`, x.Id_)
r += "polyline.on('mouseover', function (e) { this.setStyle({weight: 10}); });\n"
r += "polyline.on('mouseout', function (e) { this.setStyle({ weight: 3}); });\n"
r += ""
diff --git a/backend/model/process.go b/backend/model/process.go
index 67b9367..01d1c4d 100644
--- a/backend/model/process.go
+++ b/backend/model/process.go
@@ -76,7 +76,7 @@ func (w *DfWorld) processEvents() {
w.addEntitySite(d.CivId, d.SiteId)
w.addEntitySite(d.SiteCivId, d.SiteId)
w.Sites[d.SiteId].Ruin = false
- w.Sites[d.SiteId].Owner = d.SiteCivId
+ w.Sites[d.SiteId].Owner = d.CivId
case *HistoricalEventDestroyedSite:
w.addEntitySite(d.DefenderCivId, d.SiteId)
w.addEntitySite(d.SiteCivId, d.SiteId)
@@ -87,7 +87,7 @@ func (w *DfWorld) processEvents() {
w.addEntitySite(d.DefenderCivId, d.SiteId)
w.addEntitySite(d.NewSiteCivId, d.SiteId)
w.Sites[d.SiteId].Ruin = false
- w.Sites[d.SiteId].Owner = d.NewSiteCivId
+ w.Sites[d.SiteId].Owner = d.AttackerCivId
case *HistoricalEventHfDestroyedSite:
w.addEntitySite(d.SiteCivId, d.SiteId)
w.addEntitySite(d.DefenderCivId, d.SiteId)
@@ -96,7 +96,7 @@ func (w *DfWorld) processEvents() {
w.addEntitySite(d.SiteCivId, d.SiteId)
w.addEntitySite(d.SiteCivId, d.SiteId)
w.Sites[d.SiteId].Ruin = false
- w.Sites[d.SiteId].Owner = d.SiteCivId
+ w.Sites[d.SiteId].Owner = d.CivId
case *HistoricalEventAddHfEntityLink:
if d.Link == HistoricalEventAddHfEntityLinkLink_Position {
if hf, ok := w.HistoricalFigures[d.Hfid]; ok {
diff --git a/backend/server/server.go b/backend/server/server.go
index f987bcf..fcfe179 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -61,8 +61,13 @@ func StartServer(config *Config, world *model.DfWorld, static embed.FS) error {
}
})
srv.RegisterWorldResourcePage("/landmass/{id}", "landmass.html", func(id int) any { return srv.context.world.Landmasses[id] })
+ srv.RegisterWorldResourcePage("/popover/landmass/{id}", "popoverLandmass.html", func(id int) any { return srv.context.world.Landmasses[id] })
+
srv.RegisterWorldResourcePage("/mountain/{id}", "mountain.html", func(id int) any { return srv.context.world.MountainPeaks[id] })
+ srv.RegisterWorldResourcePage("/popover/mountain/{id}", "popoverMountain.html", func(id int) any { return srv.context.world.MountainPeaks[id] })
+
srv.RegisterWorldResourcePage("/river/{id}", "river.html", func(id int) any { return srv.context.world.Rivers[id] })
+ srv.RegisterWorldResourcePage("/popover/river/{id}", "popoverRiver.html", func(id int) any { return srv.context.world.Rivers[id] })
srv.RegisterWorldPage("/regions", "regions.html", func(p Parms) any { return groupByType(srv.context.world.Regions) })
srv.RegisterWorldResourcePage("/region/{id}", "region.html", func(id int) any { return srv.context.world.Regions[id] })
diff --git a/backend/static/js/map.js b/backend/static/js/map.js
index 15a547b..999e44e 100644
--- a/backend/static/js/map.js
+++ b/backend/static/js/map.js
@@ -105,7 +105,18 @@ function attachTooltip(layer, tip) {
layer.bindTooltip(tip, { direction: 'top' }).bindPopup(tip);
}
-function addSite(name, y1, x1, y2, x2, color, glyph) {
+function urlToolTip(type, id) {
+ return function (layer) {
+ return $.ajax({
+ url: "/popover/" + type + "/" + id,
+ async: false
+ }).responseText;
+ }
+}
+
+var myIcon = L.divIcon({ className: 'fa-solid fa-mountain fa-xl' });
+
+function addSite(id, y1, x1, y2, x2, color, glyph) {
/* resize tiny sites like lairs */
var MIN_SIZE = .3;
if (y2 - y1 < MIN_SIZE) {
@@ -116,7 +127,6 @@ function addSite(name, y1, x1, y2, x2, color, glyph) {
x1 = (x1 + x2) / 2 - MIN_SIZE / 2;
x2 = x1 + MIN_SIZE;
}
- /* TODO: use glyph of the site instead of a polygon? */
var polygon = L.polygon(
[coord(y1, x1), coord(y2, x1), coord(y2, x2), coord(y1, x2)], {
color: color,
@@ -124,17 +134,21 @@ function addSite(name, y1, x1, y2, x2, color, glyph) {
weight: 3
}).addTo(sitesLayer);
- attachTooltip(polygon, name);
+ /* TODO: use glyph of the site instead of a polygon? */
+ // var marker = L.marker(coord(y1, x1), { icon: myIcon }).addTo(sitesLayer);
+ // attachTooltip(marker, urlToolTip("site", id));
+
+ attachTooltip(polygon, urlToolTip("site", id));
}
-function addWc(name, y, x, color) {
+function addWc(id, y, x, color) {
var polygon = L.polygon(square(y, x, structureOffset), {
color: color,
opacity: 1, fillOpacity: 0.7,
weight: 3
}).addTo(constructionsLayer);
- attachTooltip(polygon, name);
+ attachTooltip(polygon, urlToolTip("worldconstruction", id));
}
function addRegion(name, y1, x1, y2, x2, color) {
@@ -149,7 +163,7 @@ function addRegion(name, y1, x1, y2, x2, color) {
attachTooltip(polygon, name);
}
-function addMountain(name, y, x, color) {
+function addMountain(id, y, x, color) {
x = worldWidth - x - 1;
var polygon = L.polygon(
[[x + mountainOffset / 2, y + mountainOffset], [x + mountainOffset / 2, y + 1 - mountainOffset], [x + 1 - mountainOffset, y + 0.5]], {
@@ -158,7 +172,7 @@ function addMountain(name, y, x, color) {
weight: 3
}).addTo(mountainsLayer);
- attachTooltip(polygon, name);
+ attachTooltip(polygon, urlToolTip("mountain", id));
minx = Math.min(x, minx);
miny = Math.min(y, miny);
diff --git a/backend/templates/popoverArtifact.html b/backend/templates/popoverArtifact.html
index 1f45493..6127cb9 100644
--- a/backend/templates/popoverArtifact.html
+++ b/backend/templates/popoverArtifact.html
@@ -1,3 +1,4 @@
+{{ artifact .Id }}
{{- if or (ne .ItemType "") (ne .ItemSubtype "")}}
{{.Mat}} {{if ne .ItemSubtype ""}}{{.ItemSubtype}}{{else}}{{.ItemType}}{{end}}
{{- end}}
diff --git a/backend/templates/popoverEntity.html b/backend/templates/popoverEntity.html
index 9a4e04a..09bc953 100644
--- a/backend/templates/popoverEntity.html
+++ b/backend/templates/popoverEntity.html
@@ -1,3 +1,4 @@
+{{ entity .Id }}
{{ .Race }}{{ if .Necromancer}} necromancer{{end}} {{ .Type }}
{{- if .Profession }}
of {{ .Profession }}s
diff --git a/backend/templates/popoverHf.html b/backend/templates/popoverHf.html
index bb06a64..14c20d1 100644
--- a/backend/templates/popoverHf.html
+++ b/backend/templates/popoverHf.html
@@ -1,3 +1,4 @@
+{{ hf .Id }}
{{if .Female }}
{{else}}
@@ -12,7 +13,6 @@
{{ if not (or .Deity .Force)}}
(*{{ .BirthYear }}{{ if ge .DeathYear 0 }} †{{ .DeathYear }}{{ end }})
{{ end }}
-
{{- if or (ne 0 (len .EntityFormerPositionLink)) (ne 0 (len .EntityPositionLink)) }}