From d590e5f2e5107084f35aefdf40b383aa564d3d62 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 1 Oct 2021 13:57:42 +0200 Subject: 300: Always show undo button. Help muscle memory by always showing the undo button in the same place. --- play.html | 2 +- rules.js | 1 + ui.js | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/play.html b/play.html index fe3cb5e..8180fd1 100644 --- a/play.html +++ b/play.html @@ -293,8 +293,8 @@ - +
diff --git a/rules.js b/rules.js index e1218e1..c209f00 100644 --- a/rules.js +++ b/rules.js @@ -9,6 +9,7 @@ // Diary: 2021-05-03 - Monday Night - Clean up reaction event game states. // Diary: 2021-05-04 - Tuesday Night - Event code cleanup. // Diary: 2021-05-08 - Saturday Afternoon - Polish game log messages. +// Diary: 2021-10-01 - Friday Afternoon - Fix bugs. // Acropolis on Fire -- if sudden death of the great king, does greece get 6 or 5 talents for the next campaign? // leonidas + miltiades -- forbid combination? diff --git a/ui.js b/ui.js index 5c95765..d37adf6 100644 --- a/ui.js +++ b/ui.js @@ -267,6 +267,26 @@ function show_marker(id, class_name, show = 1, enabled = 0) { elt.className = class_name; } +function show_undo_button(sel, action, use_label = false) { + let button = document.querySelector(sel); + if (game.actions) { + button.classList.remove("hide"); + if (game.actions && action in game.actions) { + if (game.actions[action]) { + if (use_label) + button.textContent = game.actions[action]; + button.disabled = false; + } else { + button.disabled = true; + } + } else { + button.disabled = true; + } + } else { + button.classList.add("hide"); + } +} + function on_update() { document.getElementById("greek_info").textContent = greek_info(); document.getElementById("persian_info").textContent = persian_info(); @@ -285,7 +305,7 @@ function on_update() { show_action_button("#button_draw", "draw"); show_action_button("#button_next", "next"); show_action_button("#button_pass", "pass"); - show_action_button("#button_undo", "undo"); + show_undo_button("#button_undo", "undo"); if (game.actions && game.actions.destroy) document.getElementById("bridge").className = "show destroy"; -- cgit v1.2.3