aboutsummaryrefslogtreecommitdiff
path: root/scripts/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/main.js')
-rw-r--r--scripts/main.js26
1 files changed, 18 insertions, 8 deletions
diff --git a/scripts/main.js b/scripts/main.js
index 5483adf..8df176b 100644
--- a/scripts/main.js
+++ b/scripts/main.js
@@ -37,18 +37,23 @@ function genGrid(x_count, y_count, cell_size)
37 37
38function AssetView({asset_index, on_drag_begin, on_drag_end}) 38function AssetView({asset_index, on_drag_begin, on_drag_end})
39{ 39{
40 let bg = ASSET_WHITE_BG;
41 if(TILES[asset_index].bg === null)
42 {
43 bg = null;
44 }
40 return h("div", {"class": "Asset", "draggable": true, 45 return h("div", {"class": "Asset", "draggable": true,
41 "data-asset-index": asset_index, 46 "data-asset-index": asset_index,
42 "ondragstart": on_drag_begin, 47 "ondragstart": on_drag_begin,
43 "ondragend": on_drag_end,}, 48 "ondragend": on_drag_end,
44 h("svg", ASSET_SVG_PROPS, ASSET_WHITE_BG, 49 "title": TILES[asset_index].name,},
45 TILES[asset_index].inner_svg)); 50 h("svg", ASSET_SVG_PROPS, bg, TILES[asset_index].inner_svg));
46} 51}
47 52
48function AssetsView({on_drag_begin, on_drag_end}) 53function AssetsView({on_drag_begin, on_drag_end})
49{ 54{
50 let views = TILES.slice(1).map((t, i) => 55 let views = TILES.map((t, i) =>
51 h(AssetView, {asset_index: i + 1, on_drag_begin: on_drag_begin, 56 h(AssetView, {asset_index: i, on_drag_begin: on_drag_begin,
52 on_drag_end: on_drag_end})); 57 on_drag_end: on_drag_end}));
53 return h("div", {}, views); 58 return h("div", {}, views);
54} 59}
@@ -91,8 +96,13 @@ function PlanGridView({content, mouse_state})
91 if(idx == 0) return null; 96 if(idx == 0) return null;
92 let cell_x = i % GRID_SIZE_X; 97 let cell_x = i % GRID_SIZE_X;
93 let cell_y = Math.floor(i / GRID_SIZE_Y); 98 let cell_y = Math.floor(i / GRID_SIZE_Y);
99 let bg = ASSET_WHITE_BG;
100 if(TILES[idx].bg === null)
101 {
102 bg = null;
103 }
94 return h("g", {"transform": `translate(${cell_x * (CELL_SIZE + 1) + 1} \ 104 return h("g", {"transform": `translate(${cell_x * (CELL_SIZE + 1) + 1} \
95${cell_y * (CELL_SIZE + 1) + 1})`}, ASSET_WHITE_BG, TILES[idx].inner_svg); 105${cell_y * (CELL_SIZE + 1) + 1})`}, bg, TILES[idx].inner_svg);
96 }); 106 });
97 107
98 let img_width = GRID_SIZE_X * (CELL_SIZE + 1) + 1; 108 let img_width = GRID_SIZE_X * (CELL_SIZE + 1) + 1;
@@ -101,7 +111,7 @@ ${cell_y * (CELL_SIZE + 1) + 1})`}, ASSET_WHITE_BG, TILES[idx].inner_svg);
101 "version": "1.1", "ondragover": onDragOver, 111 "version": "1.1", "ondragover": onDragOver,
102 "id": "Grid", "ondragleave": onDragLeave,}, 112 "id": "Grid", "ondragleave": onDragLeave,},
103 h("rect", {x: 0, y: 0, width: img_width, height: img_height, 113 h("rect", {x: 0, y: 0, width: img_width, height: img_height,
104 fill: "#a4b0be", "stroke-width": 0}), 114 fill: "#c0c0c0", "stroke-width": 0}),
105 grid_content, genGrid(GRID_SIZE_X, GRID_SIZE_Y, CELL_SIZE + 1), 115 grid_content, genGrid(GRID_SIZE_X, GRID_SIZE_Y, CELL_SIZE + 1),
106 hilight_box); 116 hilight_box);
107} 117}
@@ -116,7 +126,7 @@ function PlanView({plan, mouse_state})
116// on_floor_change takes one argument, which is the 0-based floor number. 126// on_floor_change takes one argument, which is the 0-based floor number.
117function FloorSelector({floor, on_floor_change}) 127function FloorSelector({floor, on_floor_change})
118{ 128{
119 return h("div", {"id": "FloorSelectorWrapper", "class": "ButtonRow"}, 129 return h("div", {"id": "FloorSelectorWrapper", "class": "ButtonRowLeft"},
120 h("label", {}, "Floor"), 130 h("label", {}, "Floor"),
121 h("input", {"id": "InputFloor", "type": "number", "step": 1, "min": 1, 131 h("input", {"id": "InputFloor", "type": "number", "step": 1, "min": 1,
122 "max": 15, "value": floor, 132 "max": 15, "value": floor,