summaryrefslogtreecommitdiff
path: root/ui.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-07-02 21:04:27 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:19:39 +0100
commit4d83f7151b4bbf1cfe93e39a04900a362c091737 (patch)
tree2c2be4d4a77891ed1dd80b868404579377a39391 /ui.js
parent350570d87d9b322ba1f265bc08defa162f8ebed5 (diff)
downloadcrusader-rex-4d83f7151b4bbf1cfe93e39a04900a362c091737.tar.gz
crusader: Nuke wide map format.
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js85
1 files changed, 8 insertions, 77 deletions
diff --git a/ui.js b/ui.js
index 22f9692..f5de84a 100644
--- a/ui.js
+++ b/ui.js
@@ -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();