summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-07-27 19:29:18 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:26 +0100
commitdd5314b7a0c4fced7909f90a3b5d6a7aa30db215 (patch)
tree1264d875cffd1a716630b8fdc1251e8f85b59294 /play.js
parent736097bab6ce3d9b59f791b8dad0d7cd98c9d584 (diff)
downloadrommel-in-the-desert-dd5314b7a0c4fced7909f90a3b5d6a7aa30db215.tar.gz
Keep expanded stack on screen.
Diffstat (limited to 'play.js')
-rw-r--r--play.js30
1 files changed, 20 insertions, 10 deletions
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
}