diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-07-02 21:04:27 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-16 19:19:39 +0100 |
commit | 4d83f7151b4bbf1cfe93e39a04900a362c091737 (patch) | |
tree | 2c2be4d4a77891ed1dd80b868404579377a39391 | |
parent | 350570d87d9b322ba1f265bc08defa162f8ebed5 (diff) | |
download | crusader-rex-4d83f7151b4bbf1cfe93e39a04900a362c091737.tar.gz |
crusader: Nuke wide map format.
-rw-r--r-- | play.html | 55 | ||||
-rw-r--r-- | ui.js | 85 |
2 files changed, 16 insertions, 124 deletions
@@ -28,31 +28,16 @@ .map #timeline { position: absolute; -} - -.map.tall #timeline { width: 88px; height: 35px; top: 2410px; background-image: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0.3), rgba(255,255,255,0.8)); } -.map.wide #timeline { - width: 35px; height: 88px; left: 2410px; - background-image: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.3), rgba(255,255,255,0.8)); -} - -.map.tall #timeline.year_1187 { left: 702px; } -.map.tall #timeline.year_1188 { left: 793px; width: 89px; } -.map.tall #timeline.year_1189 { left: 885px; } -.map.tall #timeline.year_1190 { left: 976px; width: 89px; } -.map.tall #timeline.year_1191 { left: 1068px; } -.map.tall #timeline.year_1192 { left: 1160px; width: 85px; } - -.map.wide #timeline.year_1187 { top: 30px; height: 86px; } -.map.wide #timeline.year_1188 { top: 119px; } -.map.wide #timeline.year_1189 { top: 211px; } -.map.wide #timeline.year_1190 { top: 304px; } -.map.wide #timeline.year_1191 { top: 393px; height: 89px; } -.map.wide #timeline.year_1192 { top: 485px; } +.map #timeline.year_1187 { left: 702px; } +.map #timeline.year_1188 { left: 793px; width: 89px; } +.map #timeline.year_1189 { left: 885px; } +.map #timeline.year_1190 { left: 976px; width: 89px; } +.map #timeline.year_1191 { left: 1068px; } +.map #timeline.year_1192 { left: 1160px; width: 85px; } #turn { padding: 8px 0px 8px 8px; @@ -99,33 +84,12 @@ .map { position: relative; - background-repeat: no-repeat; -} - -.map.tall { width: 1275px; height: 2475px; + background-repeat: no-repeat; background-color: #224467; } -.map.wide { - width: 2475px; - height: 1275px; - background-image: url("map-h.jpg"); -} - -.map.crop.tall { - width: 1215px; - height: 2378px; - background-position: -30px -30px; -} - -.map.crop.wide { - width: 2378px; - height: 1215px; - background-position: -30px -30px; -} - .map.hide_blocks div.blocks { visibility: hidden; } @@ -412,9 +376,6 @@ X#FR { background-image: linear-gradient(182deg, tan 30%, olivedrab 35%); } <div class="menu_popup"> <div class="menu_item" onclick="toggle_fullscreen()">Fullscreen</div> <div class="menu_separator"></div> - <div class="menu_item" onclick="tall_map()">Tall Map</div> - <div class="menu_item" onclick="wide_map()">Wide Map</div> - <div class="menu_separator"></div> <div class="menu_item" onclick="set_spread_layout()">Spread blocks</div> <div class="menu_item" onclick="set_stack_layout()">Stack blocks</div> <div class="menu_separator"></div> @@ -487,7 +448,7 @@ X#FR { background-image: linear-gradient(182deg, tan 30%, olivedrab 35%); } <div class="mapwrap" id="mapwrap"> <div class="map" id="map"> <svg id="svgmap" width="1275px" height="2475px" viewBox="0 0 1275 2475"> -<image href="map-v.jpg" x="0" y="0" width="1275" height="2475" /> +<image href="map.jpg" x="0" y="0" width="1275" height="2475" /> <g transform="translate(0.000000,2475.000000) scale(1.000000,-1.000000)"> <path id="sea" d="M29 1275 l0 -1171 3 0 c1 1 4 2 5 4 2 1 4 2 5 2 2 0 5 1 7 2 3 2 7 4 @@ -41,28 +41,6 @@ function toggle_blocks() { document.getElementById("map").classList.toggle("hide_blocks"); } -let map_orientation = window.localStorage['crusader-rex/map-orientation'] || 'tall'; - -function tall_map() { - map_orientation = 'tall'; - document.querySelector(".map").classList.remove("wide"); - document.querySelector(".map").classList.add("tall"); - window.localStorage['crusader-rex/map-orientation'] = map_orientation; - update_map_layout(); - update_map(); - zoom_map(); -} - -function wide_map() { - map_orientation = 'wide'; - document.querySelector(".map").classList.add("wide"); - document.querySelector(".map").classList.remove("tall"); - window.localStorage['crusader-rex/map-orientation'] = map_orientation; - update_map_layout(); - update_map(); - zoom_map(); -} - let ui = { cards: {}, towns: {}, @@ -312,34 +290,6 @@ function build_map_block(b, block) { return element; } -function town_x(t) { - if (map_orientation == 'tall') - return TOWNS[t].x; - else - return TOWNS[t].y; -} - -function town_y(t) { - if (map_orientation == 'tall') - return TOWNS[t].y; - else - return 1275 - TOWNS[t].x; -} - -function flip_x(x, y) { - if (map_orientation == 'tall') - return x; - else - return y; -} - -function flip_y(x, y) { - if (map_orientation == 'tall') - return y; - else - return 1275 - x; -} - function build_town(t, town) { let element = document.createElement("div"); element.town = t; @@ -351,16 +301,6 @@ function build_town(t, town) { return element; } -function update_map_layout() { - for (let t in TOWNS) { - let element = ui.towns[t]; - let xo = Math.round(element.offsetWidth/2) - let yo = Math.round(element.offsetHeight/2) - element.style.left = (town_x(t) - xo) + "px"; - element.style.top = (town_y(t) - yo) + "px"; - } -} - function build_map() { let element; @@ -420,8 +360,6 @@ function layout_blocks(location, secret, known) { layout_blocks_stacked(location, secret, known); } -// function position_block(town, row, n_rows, col, n_cols, element) { - function layout_blocks_spread(town, north, south) { let wrap = TOWNS[town].wrap; let rows = []; @@ -515,8 +453,8 @@ function position_block(town, row, n_rows, col, n_cols, element) { x += row * offset; } - element.style.left = ((flip_x(x,y) - block_size/2)|0)+"px"; - element.style.top = ((flip_y(x,y) - block_size/2)|0)+"px"; + element.style.left = ((x - block_size/2)|0)+"px"; + element.style.top = ((y - block_size/2)|0)+"px"; } function layout_blocks_stacked(location, secret, known) { @@ -534,16 +472,10 @@ function layout_blocks_stacked(location, secret, known) { function position_block_stacked(location, i, c, k, element) { let space = TOWNS[location]; let block_size = 60+6; - let x, y; - if (map_orientation == 'tall') { - x = space.x + (i - c) * 16 + k * 12; - y = space.y + (i - c) * 16 - k * 12; - } else { - x = space.x - (i - c) * 16 + k * 12; - y = space.y + (i - c) * 16 + k * 12; - } - element.style.left = ((flip_x(x,y) - block_size/2)|0)+"px"; - element.style.top = ((flip_y(x,y) - block_size/2)|0)+"px"; + let x = space.x + (i - c) * 16 + k * 12; + let y = space.y + (i - c) * 16 - k * 12; + element.style.left = ((x - block_size/2)|0)+"px"; + element.style.top = ((y - block_size/2)|0)+"px"; } function show_block(element) { @@ -572,6 +504,8 @@ function is_known_block(info, who) { let town = game.location[who]; if (town == ENGLAND || town == FRANCE || town == GERMANIA) return true; + if (town == DEAD) + return true; return false; } @@ -598,7 +532,6 @@ function update_map() { let info = BLOCKS[b]; let element = ui.blocks[b]; let town = game.location[b]; - if (town in TOWNS) { let moved = game.moved[b] ? " moved" : ""; if (town == DEAD) @@ -873,8 +806,6 @@ function on_update() { build_map(); -document.querySelector(".map").classList.add(map_orientation); - drag_element_with_mouse(".battle", ".battle_header"); scroll_with_middle_mouse(".grid_center", 3); init_map_zoom(); |