index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-30 17:14:52 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-30 17:14:52 -0700 |
commit | 56c8411920744939aff26b3d874f6560b95f6ba7 (patch) | |
tree | d53391fd00da9748f54dbd9eeaaddc98de0e18f3 | |
parent | d2286b5fdb56462b018cc2b3f0537a54941aab4b (diff) |
Make scenarios list in modal dynamic
-rw-r--r-- | src/modules/map_select_dialog.js | 21 | ||||
-rw-r--r-- | src/modules/scenarios.js | 9 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/modules/map_select_dialog.js b/src/modules/map_select_dialog.js index bbc2374..24215f6 100644 --- a/src/modules/map_select_dialog.js +++ b/src/modules/map_select_dialog.js @@ -1,6 +1,4 @@ -import sideShow from './assets/images/scenario-side_show.svg'; -import dragonHunting from './assets/images/scenario-dragon_hunting.svg'; -// import raceAgainstTime from './assets/images/scenario-race_against_time.svg'; +import { scenarios } from './scenarios.js'; export function init() { const showButton = document.getElementById('show-dialog'), @@ -8,15 +6,12 @@ export function init() { selectEl = mapDialog.querySelector('select'), confirmBtn = mapDialog.querySelector('#confirm-btn'); - let option = document.createElement('option'); - option.setAttribute('value', sideShow); - option.textContent = 'BattleTroops Scenario 1: Side Show'; - selectEl.appendChild(option); - - option = document.createElement('option'); - option.setAttribute('value', dragonHunting); - option.textContent = 'BattleTroops Scenario 2: Dragon Hunting'; - selectEl.appendChild(option); + Object.keys(scenarios).forEach(scenario => { + const option = document.createElement('option'); + option.setAttribute('value', scenario); + option.textContent = scenarios[scenario]; + selectEl.appendChild(option); + }); return { selectCurrentOptionOnPageLoad() { @@ -56,4 +51,4 @@ export function init() { }; } -export const defaultMap = sideShow; +export const defaultMap = scenarios.sideShow; diff --git a/src/modules/scenarios.js b/src/modules/scenarios.js new file mode 100644 index 0000000..afe375f --- /dev/null +++ b/src/modules/scenarios.js @@ -0,0 +1,9 @@ +import sideShow from './assets/images/scenario-side_show.svg'; +import dragonHunting from './assets/images/scenario-dragon_hunting.svg'; +import raceAgainstTime from './assets/images/scenario-race_against_time.svg'; + +export const scenarios = { + [sideShow]: 'BattleTroops Scenario 1: Side Show', + [dragonHunting]: 'BattleTroops Scenario 2: Dragon Hunting', + [raceAgainstTime]: 'BattleTroops Scenario 3: Race Against Time', +} |