Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-05-30 12:37:29 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-05-30 12:37:29 -0700
commit981cc566f05a2c517aef8657bad605477d519b48 (patch)
treec62ad253b23b6437a198833e4bf8324867529014 /src
parent51974436fff22bcd2c37471351165179bb5daa23 (diff)
WIP: put all svg refs in scenario file at build time
Diffstat (limited to 'src')
-rw-r--r--src/index.js4
-rw-r--r--src/modules/map_select_dialog.js19
2 files changed, 21 insertions, 2 deletions
diff --git a/src/index.js b/src/index.js
index 9ed2d90..d677b01 100644
--- a/src/index.js
+++ b/src/index.js
@@ -3,6 +3,7 @@ import * as gameboard from './modules/gameboard.js';
import * as recordSheet from './modules/record_sheet.js';
import * as mapSelectDialog from './modules/map_select_dialog.js';
import { Observable } from './modules/observable.js';
+import sideShow from './assets/images/scenario-side_show.svg';
globalThis.svgns = 'http://www.w3.org/2000/svg';
@@ -12,7 +13,8 @@ const mapPlaceholder = document.querySelector('.map-placeholder'),
contentVisToggleEl = document.querySelector('#content input[type="checkbox"].visible'),
// fileName = localStorage.getItem('map') || (env === 'test' ? 'test_map' : 'map1'),
fileName = localStorage.getItem('map') || 'scenario-side_show',
- map = `assets/images/${fileName}.svg`,
+ // map = `assets/images/${fileName}.svg`,
+ map = sideShow,
fileInputEl = document.querySelector('input[type="file"]'),
dice = document.querySelectorAll('.die'),
diff --git a/src/modules/map_select_dialog.js b/src/modules/map_select_dialog.js
index 2a4622a..bbc2374 100644
--- a/src/modules/map_select_dialog.js
+++ b/src/modules/map_select_dialog.js
@@ -1,9 +1,23 @@
+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 function init() {
const showButton = document.getElementById('show-dialog'),
mapDialog = document.getElementById('map-dialog'),
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);
+
return {
selectCurrentOptionOnPageLoad() {
mapDialog.querySelectorAll('option').forEach(option =>
@@ -34,9 +48,12 @@ export function init() {
e.preventDefault();
localStorage.removeItem('pan-zoom');
localStorage.setItem('map', selectEl.value);
- loadFn(`assets/images/${selectEl.value}.svg`);
+ // loadFn(`assets/images/${selectEl.value}.svg`);
+ loadFn(selectEl.value);
mapDialog.close();
});
}
};
}
+
+export const defaultMap = sideShow;