Make scenarios list in modal dynamic
This commit is contained in:
parent
d2286b5fdb
commit
56c8411920
@ -1,6 +1,4 @@
|
|||||||
import sideShow from './assets/images/scenario-side_show.svg';
|
import { scenarios } from './scenarios.js';
|
||||||
import dragonHunting from './assets/images/scenario-dragon_hunting.svg';
|
|
||||||
// import raceAgainstTime from './assets/images/scenario-race_against_time.svg';
|
|
||||||
|
|
||||||
export function init() {
|
export function init() {
|
||||||
const showButton = document.getElementById('show-dialog'),
|
const showButton = document.getElementById('show-dialog'),
|
||||||
@ -8,15 +6,12 @@ export function init() {
|
|||||||
selectEl = mapDialog.querySelector('select'),
|
selectEl = mapDialog.querySelector('select'),
|
||||||
confirmBtn = mapDialog.querySelector('#confirm-btn');
|
confirmBtn = mapDialog.querySelector('#confirm-btn');
|
||||||
|
|
||||||
let option = document.createElement('option');
|
Object.keys(scenarios).forEach(scenario => {
|
||||||
option.setAttribute('value', sideShow);
|
const option = document.createElement('option');
|
||||||
option.textContent = 'BattleTroops Scenario 1: Side Show';
|
option.setAttribute('value', scenario);
|
||||||
selectEl.appendChild(option);
|
option.textContent = scenarios[scenario];
|
||||||
|
|
||||||
option = document.createElement('option');
|
|
||||||
option.setAttribute('value', dragonHunting);
|
|
||||||
option.textContent = 'BattleTroops Scenario 2: Dragon Hunting';
|
|
||||||
selectEl.appendChild(option);
|
selectEl.appendChild(option);
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectCurrentOptionOnPageLoad() {
|
selectCurrentOptionOnPageLoad() {
|
||||||
@ -56,4 +51,4 @@ export function init() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultMap = sideShow;
|
export const defaultMap = scenarios.sideShow;
|
||||||
|
9
src/modules/scenarios.js
Normal file
9
src/modules/scenarios.js
Normal file
@ -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',
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user