mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Merge pull request #93 from Pax1601/81-demo-loadout-data-still-present
Fixed issue
This commit is contained in:
commit
d87139b619
@ -19,7 +19,20 @@ const DEMO_UNIT_DATA = {
|
||||
missionData: {
|
||||
fuel: 50,
|
||||
flags: {human: false},
|
||||
ammo: [],
|
||||
ammo: [
|
||||
{
|
||||
count: 4,
|
||||
desc: {
|
||||
displayName: "AIM-120"
|
||||
}
|
||||
},
|
||||
{
|
||||
count: 2,
|
||||
desc: {
|
||||
displayName: "AIM-7"
|
||||
}
|
||||
}
|
||||
],
|
||||
targets: [],
|
||||
hasTask: true,
|
||||
coalition: "blue"
|
||||
|
||||
@ -56,5 +56,5 @@
|
||||
}
|
||||
|
||||
#unit-info-panel #loadout-container .loadout-item::before {
|
||||
content: attr( data-loadout-item ) ' \d7 ' attr( data-loadout-qty );
|
||||
content: attr( data-loadout-qty )'\d7 ' attr( data-loadout-item ) ;
|
||||
}
|
||||
@ -58,26 +58,18 @@ export class UnitInfoPanel extends Panel {
|
||||
this.#task.classList.toggle("neutral", unit.getMissionData().coalition === "neutral");
|
||||
|
||||
/* Add the loadout elements */
|
||||
var els = this.getElement().getElementsByClassName("js-loadout-element");
|
||||
while (els.length > 0)
|
||||
this.#loadoutContainer.removeChild(els[0]);
|
||||
|
||||
for (let index in unit.getMissionData().ammo)
|
||||
this.#addLoadoutElement(unit, index);
|
||||
this.#loadoutContainer.replaceChildren(...unit.getMissionData().ammo.map(
|
||||
(ammo: any) => {
|
||||
var el = document.createElement("div");
|
||||
el.classList.add("pill", "loadout-item");
|
||||
el.dataset.loadoutQty = ammo.count;
|
||||
el.dataset.loadoutItem = ammo.desc.displayName;
|
||||
return el;
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#addLoadoutElement(unit: Unit, index: string)
|
||||
{
|
||||
var ammo = unit.getMissionData().ammo[index];
|
||||
var displayName = ammo.desc.displayName;
|
||||
var amount = ammo.count;
|
||||
var el = document.createElement("div")
|
||||
el.classList.add("js-loadout-element", "ol-rectangular-container-dark")
|
||||
el.innerText = amount + "x" + displayName;
|
||||
this.#loadoutContainer.appendChild(el);
|
||||
}
|
||||
|
||||
#onUnitsSelection(units: Unit[]){
|
||||
if (units.length == 1)
|
||||
this.show();
|
||||
|
||||
@ -22,10 +22,7 @@
|
||||
</dl>
|
||||
|
||||
<div id="loadout-container" class="ol-group wrap">
|
||||
<div class="pill loadout-item" data-loadout-qty="4" data-loadout-item="AIM-120"></div>
|
||||
<div class="pill loadout-item" data-loadout-qty="4" data-loadout-item="AIM-54"></div>
|
||||
<div class="pill loadout-item" data-loadout-qty="2" data-loadout-item="AIM-9P"></div>
|
||||
<div class="pill loadout-item" data-loadout-qty="895" data-loadout-item="bullets"></div>
|
||||
<!-- Here the loadout elements will be shown -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user