Refined the options a bit.

This commit is contained in:
PeekabooSteam
2023-09-14 20:56:34 +01:00
parent 7f75905d5d
commit 01b30ccf12
3 changed files with 88 additions and 19 deletions

View File

@@ -20,14 +20,14 @@
column-gap: 8px; column-gap: 8px;
display:flex; display:flex;
justify-items: right; justify-items: right;
opacity: .85; opacity: .9;
padding:5px; padding:5px;
width:fit-content; width:fit-content;
} }
#control-tips-panel > * > .key { #control-tips-panel > * > .key {
background-color: white; background-color: var( --background-grey );
border-radius: var( --border-radius-sm ); border-radius: var( --border-radius-sm );
color: var( --background-steel ); color: white;
padding:1px 4px; padding:1px 4px;
} }

View File

@@ -66,6 +66,12 @@ export class Airbase extends CustomMarker {
img.onload = () => SVGInjector(img); img.onload = () => SVGInjector(img);
el.appendChild(img); el.appendChild(img);
this.getElement()?.appendChild(el); this.getElement()?.appendChild(el);
el.addEventListener( "mouseover", ( ev ) => {
document.dispatchEvent( new CustomEvent( "airbaseMouseover", { detail: this }));
});
el.addEventListener( "mouseout", ( ev ) => {
document.dispatchEvent( new CustomEvent( "airbaseMouseout", { detail: this }));
});
el.dataset.coalition = this.#coalition; el.dataset.coalition = this.#coalition;
} }

View File

@@ -7,6 +7,7 @@ export class ControlTips {
#element:HTMLElement; #element:HTMLElement;
#cursorIsHoveringOverUnit:boolean = false; #cursorIsHoveringOverUnit:boolean = false;
#cursorIsHoveringOverAirbase:boolean = false;
#olympusApp:OlympusApp; #olympusApp:OlympusApp;
#shortcutManager:ShortcutManager; #shortcutManager:ShortcutManager;
@@ -26,6 +27,16 @@ export class ControlTips {
this.#updateTips() this.#updateTips()
}); });
document.addEventListener( "airbaseMouseover", ( ev:CustomEventInit ) => {
this.#cursorIsHoveringOverAirbase = true;
this.#updateTips();
});
document.addEventListener( "airbaseMouseout", ( ev:CustomEventInit ) => {
this.#cursorIsHoveringOverAirbase = false;
this.#updateTips();
});
document.addEventListener( "unitDeselection", ( ev:CustomEvent ) => { document.addEventListener( "unitDeselection", ( ev:CustomEvent ) => {
this.#updateTips(); this.#updateTips();
}); });
@@ -67,14 +78,11 @@ export class ControlTips {
{ {
"keys": [], "keys": [],
"tips": [ "tips": [
{
"key": `W/A/S/D`,
"action": `Pan map`,
"showIfUnitSelected": false
},
{ {
"key": `SHIFT`, "key": `SHIFT`,
"action": `Box select`, "action": `Box select`,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": false,
"showIfUnitSelected": false "showIfUnitSelected": false
}, },
{ {
@@ -85,27 +93,73 @@ export class ControlTips {
{ {
"key": `Mouse1+drag`, "key": `Mouse1+drag`,
"action": `Move map`, "action": `Move map`,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": false,
"showIfUnitSelected": false "showIfUnitSelected": false
}, },
{ {
"key": `Mouse2`, "key": `Mouse2`,
"action": `Spawn menu`, "action": `Spawn menu`,
"showIfUnitSelected": false "showIfUnitSelected": false,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": false
},
{
"key": `Mouse2`,
"action": `Quick options`,
"showIfUnitSelected": false,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": true
},
{
"key": `Mouse2`,
"action": `Airbase menu`,
"showIfUnitSelected": false,
"showIfHoveringOverAirbase": true,
"showIfHoveringOverUnit": false
}, },
{ {
"key": `Mouse2`, "key": `Mouse2`,
"action": `Set first waypoint`, "action": `Set first waypoint`,
"showIfHoveringOverAirbase": false,
"showIfUnitSelected": true, "showIfUnitSelected": true,
"unitsMustBeControlled": true "unitsMustBeControlled": true
}, },
{
"key": "CTRL+Mouse2",
"action": "Add waypoint",
"showIfUnitSelected": true,
"showIfHoveringOverAirbase": false,
"unitsMustBeControlled": true
},
{
"key": `Mouse2 (hold)`,
"action": `Point operations`,
"showIfUnitSelected": true,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": false,
"unitsMustBeControlled": true
},
{
"key": "CTRL",
"action": " Pin tool",
"showIfUnitSelected": false,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": false,
"unitsMustBeControlled": true
},
{
"key": "CTRL+Mouse2",
"action": " Airbase menu",
"showIfUnitSelected": true,
"showIfHoveringOverAirbase": true,
"unitsMustBeControlled": true
},
{ {
"key": `Delete`, "key": `Delete`,
"action": `Delete unit`, "action": `Delete unit`,
"showIfHoveringOverAirbase": false,
"showIfUnitSelected": true "showIfUnitSelected": true
},
{
"key": "CTRL",
"action": " (more...)"
} }
] ]
}, },
@@ -116,18 +170,22 @@ export class ControlTips {
"key": `Mouse1`, "key": `Mouse1`,
"action": "Toggle pin", "action": "Toggle pin",
"showIfUnitSelected": false, "showIfUnitSelected": false,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": false "showIfHoveringOverUnit": false
}, },
{ {
"key": `Mouse1`, "key": `Mouse1`,
"action": "Toggle selection", "action": "Toggle selection",
"showIfUnitSelected": true, "showIfUnitSelected": true,
"showIfHoveringOverAirbase": false,
"showIfHoveringOverUnit": true "showIfHoveringOverUnit": true
}, },
{ {
"key": `Mouse2`, "key": `Mouse2`,
"action": `Add waypoint`, "action": `Add waypoint`,
"showIfUnitSelected": true "showIfHoveringOverAirbase": false,
"showIfUnitSelected": true,
"unitsMustBeControlled": true
} }
] ]
}, },
@@ -176,17 +234,22 @@ export class ControlTips {
return; return;
} }
// console.log( tip.action, "state:", this.#cursorIsHoveringOverUnit, "typeof", typeof tip.showIfHoveringOverUnit, "logic", tip.showIfHoveringOverUnit !== this.#cursorIsHoveringOverUnit ); if ( typeof tip.showIfHoveringOverAirbase === "boolean" ) {
if ( tip.showIfHoveringOverAirbase !== this.#cursorIsHoveringOverAirbase ) {
return;
}
}
if ( typeof tip.showIfHoveringOverUnit === "boolean" && tip.showIfHoveringOverUnit !== this.#cursorIsHoveringOverUnit ) { if ( typeof tip.showIfHoveringOverUnit === "boolean" ) {
return; if ( tip.showIfHoveringOverUnit !== this.#cursorIsHoveringOverUnit ) {
return;
}
} }
element.innerHTML += `<div><span class="key">${tip.key}</span><span class="action">${tip.action}</span></div>` element.innerHTML += `<div><span class="key">${tip.key}</span><span class="action">${tip.action}</span></div>`
}); });
// console.log( "----" );
} }