- Echtgeld bankroll = conservative N-buy-in reserve per table (configurable,
default 20), replacing the aggressive 1/5 rule; threaded through table
selection (auswahl) and the sit gate (sitzen) end to end.
- Table shape selectable (Multiway/Heads-Up/Both); heads-up detected from the
seat count AND the room name ('NL HU'); an opened wrong-shape table is closed.
- Bomb Pot playable in both modes (PLO5, engine capable); only K-Poker stays
off (bet menu unmeasured). Drop the 'gambling' framing for an honest
capability gate (nicht_bespielbar / NICHT_BESPIELBAR).
- Stakes band (min/max BB) added to the money model; 'Echtgeld' mode rename;
native Preferences window; budget tile shows the reserve, not a percent.
- Fix runner import path so the client auto-config thread finds lobby_adapter.
135 lines
6.2 KiB
Swift
135 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) {
|
||
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 {
|
||
let twitchDa = sendung.twitch.angemeldet
|
||
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") }.disabled(!twitchDa) }
|
||
}
|
||
// Der Chat läuft über Twitch: ohne Verbindung bleibt der Knopf grau, und der Hinweis steht
|
||
// DIREKT hier (Twitch-Zeile ist gleich darüber) - nicht als lose Meldung woanders (Owner 7.11.).
|
||
if !twitchDa {
|
||
Label("Chat braucht Twitch – erst oben verbinden.", systemImage: "arrow.up")
|
||
.font(.caption2).foregroundStyle(.orange).fixedSize(horizontal: false, vertical: true)
|
||
} else 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 {
|
||
Spacer()
|
||
Button("Aktualisieren") { cockpit.steuern("anbieter_lesen") }
|
||
}
|
||
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))
|
||
}
|
||
}
|