detail maps

This commit is contained in:
Robert Janetzko 2022-05-08 07:35:57 +00:00
parent 15bec5967e
commit 41d54dd5f3
12 changed files with 60 additions and 12 deletions

View File

@ -61,7 +61,7 @@ var AddMapRegion = func(w *DfWorld, id int) template.HTML {
return ""
}
var AddMapSite = func(w *DfWorld, id int) template.HTML {
var AddMapSite = func(w *DfWorld, id int, color bool) template.HTML {
if site, ok := w.Sites[id]; ok {
coords := strings.Split(site.Rectangle, ":")
c1 := strings.Split(coords[0], ",")
@ -77,18 +77,25 @@ var AddMapSite = func(w *DfWorld, id int) template.HTML {
if site.Ruin {
c = "#aaa"
}
if !color {
c = "#fff"
}
return template.HTML(fmt.Sprintf(`<script>addSite(%d, %f, %f, %f, %f, "%s", "")</script>`, site.Id_, x1/16.0, y1/16.0-1, x2/16.0, y2/16.0-1, c))
} else {
return ""
}
}
var AddMapMountain = func(w *DfWorld, id int) template.HTML {
var AddMapMountain = func(w *DfWorld, id int, color bool) template.HTML {
if m, ok := w.MountainPeaks[id]; ok {
c1 := strings.Split(m.Coords, ",")
x, _ := strconv.Atoi(c1[0])
y, _ := strconv.Atoi(c1[1])
return template.HTML(fmt.Sprintf(`<script>addMountain(%d, %d, %d, '#666')</script>`, m.Id_, x, y))
c := "#666"
if !color {
c = "#fff"
}
return template.HTML(fmt.Sprintf(`<script>addMountain(%d, %d, %d, '%s')</script>`, m.Id_, x, y, c))
}
return ""
}

View File

@ -64,8 +64,8 @@ func (srv *DfServer) LoadTemplates() {
"addLandmass": func(id int) template.HTML { return model.AddMapLandmass(srv.context.world, id) },
"addRegion": func(id int) template.HTML { return model.AddMapRegion(srv.context.world, id) },
"addSite": func(id int) template.HTML { return model.AddMapSite(srv.context.world, id) },
"addMountain": func(id int) template.HTML { return model.AddMapMountain(srv.context.world, id) },
"addSite": func(id int, color bool) template.HTML { return model.AddMapSite(srv.context.world, id, color) },
"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) },

View File

@ -62,8 +62,6 @@ var overlayMaps = {
"Evilness": evilnessLayer,
};
L.control.layers(null, overlayMaps).addTo(map);
var imageLayer = L.imageOverlay(imageUrl, imageBounds, { opacity: 0.5 });
imageLayer.addTo(map);

View File

@ -25,6 +25,17 @@
{{- end }}
</p>
{{- if gt (len .Sites) 0 }}
<div class="object-map">
<div id="map" style="width: 300px; height: 300px"></div>
<!-- <img class="site-map" src="$suburi/sitemap/$site.id" width="300" /> -->
</div>
{{initMap}}
{{- range .Sites }}
{{ addSite . false }}
{{- end }}
{{- end }}
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
{{ $active := " active"}}

View File

@ -21,7 +21,7 @@
{{- range $race, $civs := .Civilizations }}
{{- range $civs }}
{{- range .Sites }}
{{ addSite . }}
{{ addSite . true }}
{{- end }}
{{- end }}
{{- end }}

View File

@ -6,5 +6,12 @@
<h1>{{ title .Name }}</h1>
<p>landmass</p>
<div class="object-map">
<div id="map" style="width: 300px; height: 300px"></div>
</div>
{{initMap}}
{{ addLandmass .Id }}
<script>map.addLayer(landmassesLayer);</script>
<p>{{ json . }}</p>
{{- end }}

View File

@ -6,6 +6,12 @@
<h3>{{ title .Name }}</h3>
<p>{{ if .IsVolcano }}volcano{{else}}mountain{{end}}</p>
<div class="object-map">
<div id="map" style="width: 300px; height: 300px"></div>
</div>
{{initMap}}
{{ addMountain .Id false }}
<dl class="row">
<dt class="col-2 col-lg-1">Height</dt>
<dd class="col-10 col-lg-11">{{ .Height }}</dd>

View File

@ -6,6 +6,13 @@
<h3>{{ title .Name }}</h3>
<p>{{ .Type }}</p>
<div class="object-map">
<div id="map" style="width: 300px; height: 300px"></div>
</div>
{{initMap}}
{{ addRegion .Id }}
<script>map.addLayer(regionsLayer);</script>
{{- if ne .ForceId -1 -}}
<dl class="row">
<dt class="col-2 col-lg-1">Force</dt>

View File

@ -11,7 +11,7 @@
<!-- <img class="site-map" src="$suburi/sitemap/$site.id" width="300" /> -->
</div>
{{initMap}}
{{ addSite .Id }}
{{ addSite .Id false }}
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">

View File

@ -6,6 +6,12 @@
<h3>{{ title .Name }}</h3>
{{ .Type_ }} in {{ site .SiteId }}
<div class="object-map">
<div id="map" style="width: 300px; height: 300px"></div>
</div>
{{initMap}}
{{ addSite .SiteId false }}
<h5 class="mt-3">Events</h5>
{{ template "events.html" events . }}

View File

@ -6,7 +6,7 @@
<div id="map" style="width: 100%; height: 1000px"></div>
{{initMap}}
<script>L.control.layers(null, overlayMaps).addTo(map);</script>
{{- range .Landmasses }}
{{ addLandmass .Id }}
{{- end }}
@ -16,11 +16,11 @@
{{- end }}
{{- range .Sites }}
{{ addSite .Id }}
{{ addSite .Id true }}
{{- end }}
{{- range .MountainPeaks }}
{{ addMountain .Id }}
{{ addMountain .Id true }}
{{- end }}
{{- range .WorldConstructions }}

View File

@ -6,6 +6,12 @@
<h3>{{ title .Name }}</h3>
<p>{{ .Type }}</p>
<div class="object-map">
<div id="map" style="width: 300px; height: 300px"></div>
</div>
{{initMap}}
{{ addWorldConstruction .Id }}
{{- if gt (len .Parts) 0 }}
<h5>Parts</h5>
<ul>