Center worldmap on screen.

This commit is contained in:
Oskar Wiksten
2012-10-14 13:41:59 +02:00
parent 584a34f7c4
commit 67303c3907
2 changed files with 26 additions and 9 deletions

View File

@@ -6,22 +6,28 @@
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<title></title>
<style type=\"text/css\">
#playerPosition { position: absolute; z-index: 3; font-size: 19pt; color: red; text-shadow: rgba(0, 0, 0, 1) 2px 2px 2px; }
img { z-index: 1; position: absolute; }
.namedarea { position: absolute; z-index: 2; font-size: 16pt; text-shadow: black 0.1em 0.1em 0.2em; text-align: center; }
.namedarea span { display: inline-block; vertical-align: middle; line-height: 1em; }
.settlement { color: white; }
.other { color: #cccccc; }
html, body { height:100%%; padding:0; margin:0; }
div#table { height:100%%; width:100%%; display:table; }
div#cell { display:table-cell; vertical-align:middle; text-align:center;}
div#maps { width:{{sizex}}px; height:{{sizey}}px; position:relative; display:inline-block; }
div#playerPosition { position:absolute; z-index:3; font-size:19pt; color:red; text-shadow:rgba(0, 0, 0, 1) 2px 2px 2px; }
img { z-index:1; position:absolute; }
.namedarea { position: absolute; z-index:2; font-size:16pt; text-shadow:black 0.1em 0.1em 0.2em; text-align:center; }
.namedarea span { display:inline-block; vertical-align:middle; line-height:1em; }
.settlement { color:white; }
.other { color:#cccccc; }
</style>
</head>
<body>
<div id=\"table\">
<div id=\"cell\">
<div id=\"maps\">
{{maps}}
{{areas}}
<div id=\"playerPosition\">x</div>
<div id=\"playerPosition\">x</div>
</div>
</div>
</div>
<script type=\"text/javascript\">

View File

@@ -176,6 +176,8 @@ public final class WorldMapController {
offsetWorldmapTo.y = Math.min(offsetWorldmapTo.y, map.worldPosition.y);
}
Coord bottomRight = new Coord(0, 0);
StringBuffer mapsAsHtml = new StringBuffer();
for (WorldMapSegmentMap segmentMap : segment.maps.values()) {
File f = WorldMapController.getFileForMap(segmentMap.mapName);
@@ -197,7 +199,14 @@ public final class WorldMapController {
.append((segmentMap.worldPosition.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE)
.append("px;\" />");
if (AndorsTrailApplication.DEVELOPMENT_DEBUGMESSAGES) mapsAsHtml.append("\n");
bottomRight.x = Math.max(bottomRight.x, segmentMap.worldPosition.x + size.width);
bottomRight.y = Math.max(bottomRight.y, segmentMap.worldPosition.y + size.height);
}
Size worldmapSegmentSize = new Size(
(bottomRight.x - offsetWorldmapTo.x) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
,(bottomRight.y - offsetWorldmapTo.y) * WorldMapController.WORLDMAP_DISPLAY_TILESIZE
);
StringBuffer namedAreasAsHtml = new StringBuffer();
for (NamedWorldMapArea area : segment.namedAreas.values()) {
@@ -223,6 +232,8 @@ public final class WorldMapController {
return res.getString(R.string.worldmap_template)
.replace("{{maps}}", mapsAsHtml.toString())
.replace("{{areas}}", namedAreasAsHtml.toString())
.replace("{{sizex}}", Integer.toString(worldmapSegmentSize.width))
.replace("{{sizey}}", Integer.toString(worldmapSegmentSize.height))
.replace("{{offsetx}}", Integer.toString(offsetWorldmapTo.x * WorldMapController.WORLDMAP_DISPLAY_TILESIZE))
.replace("{{offsety}}", Integer.toString(offsetWorldmapTo.y * WorldMapController.WORLDMAP_DISPLAY_TILESIZE));
}