From dd5314b7a0c4fced7909f90a3b5d6a7aa30db215 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 27 Jul 2022 19:29:18 +0200 Subject: Keep expanded stack on screen. --- play.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'play.js') diff --git a/play.js b/play.js index c2a49da..e5b8e02 100644 --- a/play.js +++ b/play.js @@ -485,29 +485,39 @@ function update_map() { } } + for (let hex = 0; hex < stack.length; ++hex) { + let start_x = ui.hex_x[hex] + let start_y = ui.hex_y[hex] + + if (stack[hex] === ui.focus) { + let height = stack[hex].length * 56 + if (start_y + height + 25 > 960) + start_y = 960 - height + 25 + } + for (let i = 0; i < stack[hex].length; ++i) { let u = stack[hex][i] let e = ui.units[u] let x, y, z if (stack[hex] === ui.focus) { - x = ui.hex_x[hex] - 25 - y = ui.hex_y[hex] - 25 + i * 56 + x = start_x - 25 + y = start_y - 25 + i * 56 z = 100 } else { if (stack[hex].length <= 1) { - x = ui.hex_x[hex] - 25 + i * 11 - y = ui.hex_y[hex] - 25 + i * 14 + x = start_x - 25 + i * 11 + y = start_y - 25 + i * 14 } else if (stack[hex].length <= 4) { - x = ui.hex_x[hex] - 30 + i * 11 - y = ui.hex_y[hex] - 30 + i * 14 + x = start_x - 30 + i * 11 + y = start_y - 30 + i * 14 } else if (stack[hex].length <= 8) { - x = ui.hex_x[hex] - 30 + i * 4 - y = ui.hex_y[hex] - 30 + i * 4 + x = start_x - 30 + i * 4 + y = start_y - 30 + i * 4 } else { - x = ui.hex_x[hex] - 35 + i * 3 - y = ui.hex_y[hex] - 35 + i * 3 + x = start_x - 35 + i * 3 + y = start_y - 35 + i * 3 } z = 1 + i } -- cgit v1.2.3