diff --git a/script/viewer.tsx b/script/viewer.tsx index 1c74dba..f92d3bf 100644 --- a/script/viewer.tsx +++ b/script/viewer.tsx @@ -4,8 +4,10 @@ import {download} from "./download"; import {AsyncParser} from "./viewer/Analyse/Data/AsyncParser"; import {render} from "solid-js/web"; import {Analyser} from "./viewer/Analyse/Analyser"; +import {loadMapData} from "./viewer/Analyse/MapBoundries"; ready(async () => { + let mapPromise = loadMapData(); document.querySelectorAll('.onlyscript').forEach(e => e.classList.remove('onlyscript')); const fileInput: HTMLInputElement | null = document.querySelector(`.dropzone input[type="file"]`); const urlInput: HTMLInputElement | null = document.querySelector(`.viewer-page input[name="url"]`); @@ -22,6 +24,7 @@ ready(async () => { if (header.type === "HL2DEMO" && header.game === "tf") { drop_text.textContent = "Parsing..."; + await mapPromise; parse(data, parseProgress, false); } else { drop_text.textContent = "Malformed demo or not a TF2 demo"; @@ -31,6 +34,7 @@ ready(async () => { const url = urlInput.value; console.log(url); const data = await download(url, (progress) => downloadProgress.value = progress); + await mapPromise; parse(data, parseProgress, true); } }) @@ -44,4 +48,4 @@ const parse = async (data: ArrayBuffer, parseProgress: HTMLProgressElement, stor const page = document.querySelector('.viewer-page'); render(() => , page); -} \ No newline at end of file +} diff --git a/script/viewer/Analyse/MapBoundries.ts b/script/viewer/Analyse/MapBoundries.ts index 5c10ef3..6f6f30c 100644 --- a/script/viewer/Analyse/MapBoundries.ts +++ b/script/viewer/Analyse/MapBoundries.ts @@ -1,7 +1,18 @@ -import {mapBoundaries} from './boundaries'; +let mapBoundaries = {}; -mapBoundaries['koth_viaduct'] = mapBoundaries['koth_product_rc8']; -mapBoundaries['cp_prolands'] = mapBoundaries['cp_badlands']; + +export const loadMapData = async () => { + if (Object.keys(mapBoundaries).length > 0) { + return; + } + const map_root = document.querySelector('[data-maps]').getAttribute('data-maps'); + const res = await fetch(`${map_root}boundaries.json`); + + mapBoundaries = await res.json(); + + mapBoundaries['koth_viaduct'] = mapBoundaries['koth_product_rc8']; + mapBoundaries['cp_prolands'] = mapBoundaries['cp_badlands']; +} const mapAliases = new Map([ ['cp_prolands', 'cp_badlands'] diff --git a/script/viewer/Analyse/boundaries.ts b/script/viewer/Analyse/boundaries.ts deleted file mode 100644 index 8d07f53..0000000 --- a/script/viewer/Analyse/boundaries.ts +++ /dev/null @@ -1,462 +0,0 @@ -export const mapBoundaries = { - "pl_badwater_pro_v9": { - "boundary_min": { - "x": -2427, - "y": -3340 - }, - "boundary_max": { - "x": 3785, - "y": 2922 - } - }, - "cp_gullywash_final1": { - "boundary_min": { - "x": -4050, - "y": -2950 - }, - "boundary_max": { - "x": 5432, - "y": 2260 - } - }, - "cp_gullywash_f6": { - "boundary_min": { - "x": -4717, - "y": -2643 - }, - "boundary_max": { - "x": 4765, - "y": 2567 - } - }, - "cp_process_final": { - "boundary_min": { - "x": -5222, - "y": -3146 - }, - "boundary_max": { - "x": 5216, - "y": 3128 - } - }, - "cp_badlands": { - "boundary_min": { - "x": -4285, - "y": -4898 - }, - "boundary_max": { - "x": 2577, - "y": 4858 - } - }, - "pl_upward": { - "boundary_min": { - "x": -2653, - "y": -4344 - }, - "boundary_max": { - "x": 3097, - "y": 2180 - } - }, - "koth_product_rc8": { - "boundary_min": { - "x": -2859, - "y": -3668 - }, - "boundary_max": { - "x": -171, - "y": 3776 - } - }, - "cp_snakewater_final1": { - "boundary_min": { - "x": -5671, - "y": -2649 - }, - "boundary_max": { - "x": 6687, - "y": 2961 - } - }, - "ultiduo_baloo_v2": { - "boundary_min": { - "x": -1678, - "y": -1964 - }, - "boundary_max": { - "x": 1678, - "y": 1964 - } - }, - "cp_sunshine": { - "boundary_min": { - "x": -8798, - "y": 173 - }, - "boundary_max": { - "x": -2502, - "y": 10279 - } - }, - "cp_metalworks_rc7": { - "boundary_min": { - "x": -3034, - "y": -6699 - }, - "boundary_max": { - "x": 3374, - "y": 4939 - } - }, - "cp_steel": { - "boundary_min": { - "x": -2406, - "y": -3422 - }, - "boundary_max": { - "x": 2924, - "y": 2684 - } - }, - "koth_lakeside_final": { - "boundary_min": { - "x": -4617, - "y": -2160 - }, - "boundary_max": { - "x": 4491, - "y": 1114 - } - }, - "cp_granary_pro_b10": { - "boundary_min": { - "x": -3069, - "y": -6539 - }, - "boundary_max": { - "x": 7, - "y": 6263 - } - }, - "koth_ashville_rc1": { - "boundary_min": { - "x": -1423, - "y": -3920 - }, - "boundary_max": { - "x": 1501, - "y": 3890 - } - }, - "cp_reckoner_b3a": { - "boundary_min": { - "x": -3800, - "y": -4921 - }, - "boundary_max": { - "x": 3794, - "y": 4879 - } - }, - "pl_borneo": { - "boundary_min": { - "x": -3470, - "y": -8160 - }, - "boundary_max": { - "x": 3168, - "y": 3786 - } - }, - "pl_swiftwater_final1": { - "boundary_min": { - "x": 408, - "y": -6128 - }, - "boundary_max": { - "x": 6296, - "y": 2624 - } - }, - "ultiduo_grove_b2": { - "boundary_min": { - "x": -2099, - "y": -1793 - }, - "boundary_max": { - "x": 2099, - "y": 1793 - } - }, - "pl_vigil_b2": { - "boundary_min": { - "x": -1019, - "y": -2070 - }, - "boundary_max": { - "x": 4875, - "y": 4784 - } - }, - "koth_bagel_rc4": { - "boundary_min": { - "x": -4286, - "y": -1234 - }, - "boundary_max": { - "x": 4196, - "y": 1150 - } - }, - "ctf_ballin_sky": { - "boundary_min": { - "x": -1024, - "y": -1504 - }, - "boundary_max": { - "x": 1024, - "y": 1504 - } - }, - "koth_ultiduo_r_b7": { - "boundary_min": { - "x": -1337, - "y": -1313 - }, - "boundary_max": { - "x": 1337, - "y": 1313 - } - }, - "koth_warmtic_rc4": { - "boundary_min": { - "x": -1337, - "y": -4437 - }, - "boundary_max": { - "x": 2099, - "y": 4547 - } - }, - "cp_alloy_rc2a": { - "boundary_min": { - "x": -4271, - "y": -3262 - }, - "boundary_max": { - "x": 1801, - "y": 5492 - } - }, - "pl_millstone_ugc_7": { - "boundary_min": { - "x": -3349, - "y": -1776 - }, - "boundary_max": { - "x": 2709, - "y": 4840 - } - }, - "cp_vanguard": { - "boundary_min": { - "x": -5585, - "y": -1896 - }, - "boundary_max": { - "x": 5585, - "y": 1896 - } - }, - "koth_cascade_b6": { - "boundary_min": { - "x": -1682, - "y": -3807 - }, - "boundary_max": { - "x": 1714, - "y": 3735 - } - }, - "koth_coalplant_b8": { - "boundary_min": { - "x": -1513, - "y": -4089 - }, - "boundary_max": { - "x": 1527, - "y": 4083 - } - }, - "koth_ramjam_rc1": { - "boundary_min": { - "x": -3464, - "y": -1865 - }, - "boundary_max": { - "x": 3464, - "y": 1851 - } - }, - "dm_airfusion_final": { - "boundary_min": { - "x": -855, - "y": -2533 - }, - "boundary_max": { - "x": 2315, - "y": 337 - } - }, - "dm_biohazard_cal": { - "boundary_min": { - "x": 422, - "y": 366 - }, - "boundary_max": { - "x": 2486, - "y": 1942 - } - }, - "dm_caverns_r1": { - "boundary_min": { - "x": -1979, - "y": -1476 - }, - "boundary_max": { - "x": 1091, - "y": 1884 - } - }, - "dm_ethic": { - "boundary_min": { - "x": -1549, - "y": -1537 - }, - "boundary_max": { - "x": 273, - "y": -19 - } - }, - "dm_killbox_kbh_2p": { - "boundary_min": { - "x": -1510, - "y": -1017 - }, - "boundary_max": { - "x": 1010, - "y": 1017 - } - }, - "dm_lockdown_r6": { - "boundary_min": { - "x": -4670, - "y": 1257 - }, - "boundary_max": { - "x": -2382, - "y": 6343 - } - }, - "dm_lostarena": { - "boundary_min": { - "x": -867, - "y": -1421 - }, - "boundary_max": { - "x": 1277, - "y": 1041 - } - }, - "dm_lostvillage_v3": { - "boundary_min": { - "x": -513, - "y": -1830 - }, - "boundary_max": { - "x": 2163, - "y": 2000 - } - }, - "dm_tigcrik_r2": { - "boundary_min": { - "x": -1608, - "y": -402 - }, - "boundary_max": { - "x": 264, - "y": 1268 - } - }, - "cp_kalinka": { - "boundary_min": { - "x": -4117, - "y": -5036 - }, - "boundary_max": { - "x": 4117, - "y": 4740 - } - }, - "cp_cardinal": { - "boundary_min": { - "x": -6716, - "y": -1782 - }, - "boundary_max": { - "x": 6716, - "y": 1782 - } - }, - "koth_airfield": { - "boundary_min": { - "x": -3102, - "y": -2094 - }, - "boundary_max": { - "x": 3102, - "y": 2094 - } - }, - "koth_clearcut": { - "boundary_min": { - "x": -4432, - "y": -1283 - }, - "boundary_max": { - "x": 4438, - "y": 1255 - } - }, - "cp_villa": { - "boundary_min": { - "x": -5988, - "y": -2466 - }, - "boundary_max": { - "x": 5988, - "y": 2466 - } - }, - "cp_gravelpit": { - "boundary_min": { - "x": -5359, - "y": -328 - }, - "boundary_max": { - "x": 1795, - "y": 5610 - } - }, - "koth_proplant": { - "boundary_min": { - "x": -1530, - "y": -4109 - }, - "boundary_max": { - "x": 1530, - "y": 4071 - } - } -}