Die Sendung aus dem Cockpit (Plan 2026-11-06 twitch-sendung): Buehnenbild, Namensschilder, OBS-Szenen als Plan, Chat (Gruss, Moderation nach Entscheid, Pokerfragen), Twitch-Anmeldung, Cockpit-Bereich. - Python: sendung/ (twitch, obs, moderator, chat, einblendung, fragen, gruss, schilder, wsklient), betrieb/ (lehrer, sprecher, sprachmodell, anbieter, rueckblick, umschreiber), sicht/ (sendung_knoepfe, anbieter_knoepfe, aufsicht, sendung_seiten, server, ws). Alle 17 Sendung-Specs + die zwei Knopf-Specs gruen. - Swift: Cockpit-Modelle Anbieter/Sendung, Editoren, SendungSpec. Mac baut, 152 Pruefung-Tests gruen. - Ohne die Engine-niveau-Arbeit (src/*.rs, benchmarks) - die bleibt auf ablage. Offen (Owner): OBS installieren, Twitch-Geraetecode-Anmeldung, Feinmessung der Namensstellen am Streambild. Bekannt (vorbestehend, nicht aus dieser Arbeit): tests/cfr_multi.rs Frozen-Chart-Test rot seit dem Abnahme-Stand - die eingefrorene src/preflop/generated_charts_multi.rs weicht vom Generator ab.
136 lines
6.2 KiB
Swift
136 lines
6.2 KiB
Swift
import Foundation
|
||
import CockpitKern
|
||
import SwiftUI
|
||
|
||
/// Der Bereich "Sendung": Stand von Twitch und Chat, Live/Pause über den Chat, die Moderationsfälle
|
||
/// mit "Zurücknehmen" und die letzten Fragen. Die Daten kommen mit der Rueckmeldung (cockpit.sendung);
|
||
/// die Knöpfe gehen an sicht/sendung_knoepfe.py. OBS-Installation und Twitch-Anmeldung macht der Owner.
|
||
struct SendungEditor: View {
|
||
@Environment(Cockpit.self) private var cockpit
|
||
@State private var clientId = ""
|
||
|
||
private var sendung: Sendung { cockpit.sendung ?? Sendung() }
|
||
|
||
var body: some View {
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
HStack {
|
||
Label("Sendung", systemImage: "dot.radiowaves.left.and.right").font(.callout.weight(.semibold))
|
||
Spacer()
|
||
Button("Fertig") { cockpit.sendungOffen = false }.buttonStyle(.borderedProminent)
|
||
}
|
||
twitch
|
||
chat
|
||
if !sendung.chat.faelle.isEmpty { faelle }
|
||
if !sendung.chat.fragen.isEmpty { fragen }
|
||
}
|
||
.controlSize(.small)
|
||
.padding(10)
|
||
.background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 14))
|
||
}
|
||
|
||
@ViewBuilder private var twitch: some View {
|
||
let t = sendung.twitch
|
||
if t.angemeldet {
|
||
HStack {
|
||
Label("Twitch: \(t.login ?? "angemeldet")", systemImage: "checkmark.seal.fill").foregroundStyle(.green)
|
||
Spacer()
|
||
Button("Abmelden") { cockpit.steuern("twitch_abmelden") }
|
||
}
|
||
} else if let a = t.anmeldung {
|
||
VStack(alignment: .leading, spacing: 2) {
|
||
Text("Anmeldung offen: Code \(a.code ?? "–")").font(.caption.weight(.semibold))
|
||
if let adr = a.adresse { Text(adr).font(.caption2).foregroundStyle(.secondary) }
|
||
}
|
||
} else {
|
||
HStack {
|
||
TextField("Client-ID", text: $clientId).textFieldStyle(.roundedBorder).frame(maxWidth: 220)
|
||
Button("Verbinden") {
|
||
let d = String(data: (try? JSONSerialization.data(withJSONObject: ["client_id": clientId])) ?? Data(), encoding: .utf8)
|
||
cockpit.steuern("twitch_verbinden", daten: d)
|
||
}.disabled(clientId.isEmpty)
|
||
}
|
||
}
|
||
}
|
||
|
||
@ViewBuilder private var chat: some View {
|
||
HStack {
|
||
Label(sendung.chat.an ? "Chat läuft" : "Chat aus", systemImage: sendung.chat.an ? "bubble.left.and.bubble.right.fill" : "bubble.left")
|
||
.foregroundStyle(sendung.chat.an ? .green : .secondary)
|
||
Spacer()
|
||
if sendung.chat.an { Button("Chat aus") { cockpit.steuern("chat_aus") } }
|
||
else { Button("Chat an") { cockpit.steuern("chat_an") } }
|
||
}
|
||
if let h = sendung.chat.hinweis, !h.isEmpty {
|
||
Text(h).font(.caption2).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
|
||
}
|
||
}
|
||
|
||
private var faelle: some View {
|
||
VStack(alignment: .leading, spacing: 4) {
|
||
Text("Moderation").font(.caption.weight(.semibold))
|
||
ForEach(sendung.chat.faelle) { f in
|
||
HStack(spacing: 6) {
|
||
Text(f.strafe == "bann" ? "Bann" : "Stumm").font(.caption2.weight(.bold))
|
||
.foregroundStyle(f.zurueckgenommen ? Color.secondary : (f.strafe == "bann" ? Color.red : Color.orange))
|
||
Text("\(f.nutzer ?? "?") · \(f.grund ?? "")").font(.caption2).lineLimit(1)
|
||
Spacer()
|
||
if f.zurueckgenommen {
|
||
Text("zurückgenommen").font(.caption2).foregroundStyle(.secondary)
|
||
} else {
|
||
Button("Zurücknehmen") {
|
||
let d = String(data: (try? JSONSerialization.data(withJSONObject: ["nummer": f.nummer])) ?? Data(), encoding: .utf8)
|
||
cockpit.steuern("fall_zuruecknehmen", daten: d)
|
||
}.controlSize(.mini)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
private var fragen: some View {
|
||
VStack(alignment: .leading, spacing: 4) {
|
||
Text("Fragen").font(.caption.weight(.semibold))
|
||
ForEach(sendung.chat.fragen) { f in
|
||
VStack(alignment: .leading, spacing: 1) {
|
||
Text("\(f.name ?? "?"): \(f.frage ?? "")").font(.caption2.weight(.medium)).lineLimit(2)
|
||
if let a = f.antwort, !a.isEmpty { Text(a).font(.caption2).foregroundStyle(.secondary).lineLimit(3) }
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// Der Bereich "Stimme & KI": die gespeicherten Anbieter je Art (nie ein Schlüssel). Formular zum
|
||
/// Sichern/Testen bleibt bewusst knapp; der Stand kommt mit der Rueckmeldung (cockpit.anbieter).
|
||
struct StimmeKIEditor: View {
|
||
@Environment(Cockpit.self) private var cockpit
|
||
|
||
private var anbieter: Anbieter { cockpit.anbieter ?? Anbieter() }
|
||
|
||
var body: some View {
|
||
VStack(alignment: .leading, spacing: 10) {
|
||
HStack {
|
||
Label("Stimme & KI", systemImage: "waveform").font(.callout.weight(.semibold))
|
||
Spacer()
|
||
Button("Aktualisieren") { cockpit.steuern("anbieter_lesen") }
|
||
Button("Fertig") { cockpit.stimmeOffen = false }.buttonStyle(.borderedProminent)
|
||
}
|
||
if anbieter.katalog.isEmpty {
|
||
Text("Noch nichts geladen – auf Aktualisieren tippen.").font(.caption).foregroundStyle(.secondary)
|
||
} else {
|
||
ForEach(anbieter.katalog.keys.sorted(), id: \.self) { art in
|
||
let gespeichert = anbieter.gespeichert[art] ?? [:]
|
||
HStack(spacing: 6) {
|
||
Text(art.capitalized).font(.caption.weight(.semibold)).frame(width: 90, alignment: .leading)
|
||
Text(gespeichert.isEmpty ? "keiner gespeichert" : gespeichert.keys.sorted().joined(separator: ", "))
|
||
.font(.caption2).foregroundStyle(.secondary).lineLimit(1)
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.controlSize(.small)
|
||
.padding(10)
|
||
.background(.white.opacity(0.05), in: RoundedRectangle(cornerRadius: 14))
|
||
}
|
||
}
|