Files
AeroMc-Launcher/streamdeck-plugin/com.aeromc.launcher.sdPlugin/ui/instanz.html
T
2026-10-30 05:54:28 +00:00

73 lines
3.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>AeroMC-Instanz</title>
<style>
body { font-family: "Segoe UI", sans-serif; font-size: 13px; color: #d8d8d8; background: #2d2d2d; margin: 0; padding: 12px; }
label { display: block; margin-bottom: 4px; color: #a8a8a8; }
select { width: 100%; padding: 6px; background: #3d3d3d; color: #fff; border: 1px solid #555; border-radius: 4px; }
.hint { margin-top: 10px; color: #8a8a8a; font-size: 12px; }
</style>
</head>
<body>
<label for="instanz">Instanz</label>
<select id="instanz"><option value="">Lade …</option></select>
<p class="hint" id="hinweis"></p>
<script>
// bei diesen Tasten darf die Instanz leer bleiben (= alle Instanzen)
const OPTIONAL = ['com.aeromc.launcher.spielzeit', 'com.aeromc.launcher.ordner', 'com.aeromc.launcher.logs', 'com.aeromc.launcher.absturz'];
const OPTIONAL_TEXT = { 'com.aeromc.launcher.logs': 'Laufende / zuletzt gespielte', 'com.aeromc.launcher.absturz': 'Laufende / zuletzt gespielte' };
let ws, uuid, aktion, einstellungen = {}, wiederholung = null;
function frageInstanzen() {
if (ws.readyState === 1) ws.send(JSON.stringify({ event: 'sendToPlugin', action: aktion, context: uuid, payload: { frage: 'instanzen' } }));
}
function fuelle(p) {
// solange AeroMC nicht erreichbar ist, alle 2 s neu fragen - ein Neuauswählen der Taste ist dann nicht nötig
if (p.erreichbar) { clearInterval(wiederholung); wiederholung = null; }
else if (!wiederholung) wiederholung = setInterval(frageInstanzen, 2000);
const sel = document.getElementById('instanz');
const hinweis = document.getElementById('hinweis');
sel.innerHTML = '';
if (!p.erreichbar) {
sel.innerHTML = '<option value="">AeroMC nicht erreichbar</option>';
hinweis.textContent = 'AeroMC starten und unter Optionen → Allgemein „Stream Deck erlauben“ einschalten. Dieses Fenster aktualisiert sich dann selbst.';
return;
}
hinweis.textContent = '';
const leer = document.createElement('option');
leer.value = ''; leer.textContent = OPTIONAL.includes(aktion) ? (OPTIONAL_TEXT[aktion] || 'Alle Instanzen') : '– bitte wählen –';
sel.appendChild(leer);
for (const i of p.instanzen) {
const o = document.createElement('option');
o.value = i.id; o.textContent = i.name;
sel.appendChild(o);
}
sel.value = einstellungen.instanceId || '';
}
function connectElgatoStreamDeckSocket(port, inUUID, registerEvent, info, actionInfo) {
uuid = inUUID;
const a = JSON.parse(actionInfo);
aktion = a.action;
einstellungen = (a.payload && a.payload.settings) || {};
ws = new WebSocket('ws://127.0.0.1:' + port);
ws.onopen = () => {
ws.send(JSON.stringify({ event: registerEvent, uuid }));
frageInstanzen();
};
ws.onmessage = (e) => {
const m = JSON.parse(e.data);
if (m.event === 'sendToPropertyInspector') fuelle(m.payload || {});
};
document.getElementById('instanz').addEventListener('change', (ev) => {
einstellungen.instanceId = ev.target.value;
ws.send(JSON.stringify({ event: 'setSettings', context: uuid, payload: einstellungen }));
});
}
</script>
</body>
</html>