WinUI-Cockpit: Sammeln-Teil auf der Cash-Seite (Knopf, Stufen-Chips mit -/+, Anzeige)
Spiegel des Slint-Teils gegen sicht/steuern.py sammler_*: Sammeln/Stopp, Zeile mit Tischen/Haenden/Haende je h, gesperrt solange ein Laeufer laeuft; aufklappbare Stufenwahl aus der Lobby mit Obergrenze je Stufe und gesamter Obergrenze. Programm.cs: POKERFREAK_COCKPIT_PROBE meldet eine Probe-Instanz unter eigenem Schluessel an (Bildschirmprobe neben dem Cockpit des Owners). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+6
-1
@@ -14,6 +14,11 @@ public static class Programm
|
||||
/// <summary>Der Schluessel, unter dem sich das erste Cockpit anmeldet (je Windows-Sitzung).</summary>
|
||||
public const string Schluessel = "Pokerfreak.Cockpit";
|
||||
|
||||
/// <summary>Nur fuer Proben: POKERFREAK_COCKPIT_PROBE=name meldet unter eigenem Schluessel an, so laeuft
|
||||
/// eine Probe-Instanz (gegen einen Probe-Server, POKERFREAK_ADRESSE) neben dem Cockpit des Owners.</summary>
|
||||
private static string SchluesselJetzt =>
|
||||
Environment.GetEnvironmentVariable("POKERFREAK_COCKPIT_PROBE") is { Length: > 0 } p ? Schluessel + ".Probe." + p : Schluessel;
|
||||
|
||||
[STAThread]
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
@@ -38,7 +43,7 @@ public static class Programm
|
||||
AppInstance erstes;
|
||||
try
|
||||
{
|
||||
erstes = AppInstance.FindOrRegisterForKey(Schluessel);
|
||||
erstes = AppInstance.FindOrRegisterForKey(SchluesselJetzt);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -89,6 +89,7 @@ public sealed class CashSeite : UserControl, ISeite
|
||||
|
||||
private readonly LiveTeil _live;
|
||||
private readonly LimitTeil _limits;
|
||||
private readonly SammlerTeil _sammler;
|
||||
private readonly ZuschauerTeil _zuschauer;
|
||||
|
||||
public CashSeite(CockpitZustand z)
|
||||
@@ -96,6 +97,7 @@ public sealed class CashSeite : UserControl, ISeite
|
||||
_z = z;
|
||||
_live = new LiveTeil(z);
|
||||
_limits = new LimitTeil(z);
|
||||
_sammler = new SammlerTeil(z);
|
||||
_zuschauer = new ZuschauerTeil(z);
|
||||
|
||||
// ---- Modus: Zuschauer | Übung | Echtgeld als Kapsel ---------------------------------------
|
||||
@@ -274,7 +276,7 @@ public sealed class CashSeite : UserControl, ISeite
|
||||
// ---- Aufbau --------------------------------------------------------------------------------
|
||||
_nurLaeufer = new UIElement[] { kacheln, zahlZeile, formZeile, wasSpielen };
|
||||
var kopf = Ui.Spalte(10, modusKapsel, _cashFrage, kacheln, zahlZeile, formZeile, wasSpielen, _turnierPlan, _anmeldungen,
|
||||
_phase, _statusZeile, _konto, _knoepfe, _notAusBand, _deckelBand, _limits, _portWarnung);
|
||||
_phase, _statusZeile, _konto, _knoepfe, _notAusBand, _deckelBand, _limits, _sammler, _portWarnung);
|
||||
kopf.Padding = new Thickness(12, 6, 12, 10);
|
||||
var rueck = Ui.Spalte(6, _wartet, _meldung);
|
||||
rueck.Padding = new Thickness(12, 0, 12, 0);
|
||||
@@ -523,6 +525,8 @@ public sealed class CashSeite : UserControl, ISeite
|
||||
.Where(t => !string.IsNullOrEmpty(t)));
|
||||
// Verlustlimits einstellen (Owner 17.11.): nur Echtgeld, fertige Stufen statt Zahlen raten
|
||||
_limits.Zeichnen(deckel, cash);
|
||||
// Sammeln (19.11.): fremden Tischen zusehen, Stufen aus der Lobby - gesperrt, solange ein Laeufer laeuft
|
||||
_sammler.Zeichnen(_z.Ansicht.Zuschauer.Obj("sammler"));
|
||||
|
||||
// Rueckmeldungen
|
||||
_wartet.Visibility = Sichtbar(beschaeftigt);
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Pokerfreak.Cockpit.Kern;
|
||||
|
||||
namespace Pokerfreak.Cockpit.Seiten;
|
||||
|
||||
/// <summary>
|
||||
/// Sammeln (betrieb/sammler.py, sicht/steuern.py `sammler_*`, sicht/ansicht.py `sammler_`): fremden Tischen
|
||||
/// der gewaehlten Stufen nur zusehen und ihre Haende sammeln - nie setzen, nie klicken. Oben der Knopf
|
||||
/// Sammeln/Stopp und die Zeile (Tische, Haende, Haende/h); gesperrt, solange ein Laeufer laeuft (Echtgeld hat
|
||||
/// Vorrang, der Server weist den Start dann auch selbst ab). Darunter aufklappbar die Stufenwahl: jede
|
||||
/// Cash-Stufe, die die Lobby anbietet, an/aus mit eigener Obergrenze (−/+), dazu die gesamte. Die Wahl gilt
|
||||
/// beim naechsten Start (Spiegel: cockpit/src/modelle.rs `Sammler::wahl_daten`).
|
||||
/// </summary>
|
||||
public sealed class SammlerTeil : UserControl
|
||||
{
|
||||
private readonly CockpitZustand _z;
|
||||
private readonly TextBlock _zeile = Ui.Text("", 12, umbruch: true, pinsel: Ui.Zweit);
|
||||
private readonly Border _knopf = new() { CornerRadius = new CornerRadius(8), Padding = new Thickness(14, 5, 14, 6), MinWidth = 92 };
|
||||
private readonly TextBlock _knopfText = Ui.Text("Sammeln", 12, fett: true);
|
||||
private readonly Tippflaeche _knopfTipp;
|
||||
private readonly TextBlock _stufenKopf = Ui.Text("", 12, fett: true);
|
||||
private readonly TextBlock _stufenFuss = Ui.Winzig("");
|
||||
private readonly TextBlock _gesamt = Ui.Text("", 12, zahlen: true);
|
||||
private readonly VariableSizedWrapGrid _chips = new()
|
||||
{
|
||||
Orientation = Orientation.Horizontal,
|
||||
ItemWidth = 88,
|
||||
ItemHeight = 54,
|
||||
};
|
||||
private readonly Tippflaeche _gesamtMinus, _gesamtPlus;
|
||||
private string _abdruck = "";
|
||||
private JsonObject? _s;
|
||||
|
||||
public SammlerTeil(CockpitZustand z)
|
||||
{
|
||||
_z = z;
|
||||
_knopfText.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
_knopf.Child = _knopfText;
|
||||
_knopf.VerticalAlignment = VerticalAlignment.Center;
|
||||
_knopfTipp = _knopf.Tippen(Knopf, 8, "Fremden Tischen der gewählten Stufen zusehen und ihre Hände sammeln - setzt sich nie");
|
||||
var titel = Ui.Spalte(2, Ui.Reihe(6, Ui.Zeichen("", 13), Ui.Text("Sammeln", 13, fett: true)), _zeile);
|
||||
var oben = Ui.Zeile(titel, _knopfTipp, 10);
|
||||
|
||||
_gesamtMinus = Klein("", () => Wahl("tische", -1));
|
||||
_gesamtPlus = Klein("", () => Wahl("tische", +1));
|
||||
var gesamt = Ui.Reihe(4, Ui.Winzig("gesamt höchstens"), _gesamtMinus, _gesamt, _gesamtPlus);
|
||||
var inhalt = Ui.Spalte(8, gesamt, _chips,
|
||||
Ui.Winzig("Stufe antippen: an/aus · −/+ die Obergrenze der Stufe (alle = nur die gesamte). Gilt beim nächsten Start.", Ui.Dritt)
|
||||
.Mit(t => t.TextWrapping = TextWrapping.Wrap));
|
||||
var ex = new Expander
|
||||
{
|
||||
Header = Ui.Spalte(1, _stufenKopf, _stufenFuss),
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
HorizontalContentAlignment = HorizontalAlignment.Stretch,
|
||||
Content = inhalt,
|
||||
};
|
||||
Content = Ui.Flaeche(Ui.Spalte(8, oben, ex), 14, 0.06, 10);
|
||||
}
|
||||
|
||||
private static Tippflaeche Klein(string glyph, Action tun)
|
||||
{
|
||||
var z = Ui.Zeichen(glyph, 9);
|
||||
z.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
z.VerticalAlignment = VerticalAlignment.Center;
|
||||
return new Border { Width = 22, Height = 20, Child = z, Background = Ui.Weiss(0.10), CornerRadius = new CornerRadius(5) }.Tippen(tun, 5);
|
||||
}
|
||||
|
||||
private bool Laeuft => _s.Wahr("laeuft");
|
||||
private bool Gesperrt => _s.Wahr("gesperrt") && !Laeuft;
|
||||
|
||||
private void Knopf()
|
||||
{
|
||||
if (_s is null) return;
|
||||
if (Laeuft) _ = _z.Senden(("sammler_stoppen", null));
|
||||
else if (!Gesperrt) _ = _z.Senden(("sammler_starten", null));
|
||||
}
|
||||
|
||||
/// <summary>Was ein Klick an den Server schickt - wie modelle.rs `wahl_daten`; null, wenn er nichts aendert.</summary>
|
||||
public static JsonObject? WahlDaten(JsonObject? s, string was, int index = -1, int schritt = 0)
|
||||
{
|
||||
if (s is null) return null;
|
||||
var stufen = s.Objekte("stufen").ToList();
|
||||
var tische = (int)(s.Zahl("tische") ?? 12);
|
||||
JsonObject? st = index >= 0 && index < stufen.Count ? stufen[index] : null;
|
||||
switch (was)
|
||||
{
|
||||
case "stufe" when st != null:
|
||||
return new JsonObject { ["bb"] = st.Zahl("bb"), ["an"] = !st.Wahr("an") };
|
||||
case "grenze" when st != null && st.Wahr("an"):
|
||||
{
|
||||
var g = (int)(st.Zahl("grenze") ?? 0);
|
||||
var neu = g == 0 && schritt < 0 ? 0 : Math.Clamp(g + schritt, 0, Math.Max(1, tische));
|
||||
if (neu == g) return null;
|
||||
return new JsonObject { ["bb"] = st.Zahl("bb"), ["grenze"] = neu == 0 ? null : neu };
|
||||
}
|
||||
case "tische":
|
||||
{
|
||||
var neu = Math.Clamp(tische + schritt, 1, 48);
|
||||
return neu == tische ? null : new JsonObject { ["tische"] = neu };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Wahl(string was, int schritt, int index = -1)
|
||||
{
|
||||
if (Laeuft) return;
|
||||
if (WahlDaten(_s, was, index, schritt) is JsonObject d) _ = _z.Senden(("sammler_wahl_setzen", d));
|
||||
}
|
||||
|
||||
/// <summary>`s`: zuschauer.sammler vom Server; fehlt er (aelterer Server), bleibt der Teil unsichtbar.</summary>
|
||||
public void Zeichnen(JsonObject? s)
|
||||
{
|
||||
_s = s;
|
||||
Visibility = s is null ? Visibility.Collapsed : Visibility.Visible;
|
||||
if (s is null) return;
|
||||
var abdruck = s.Abdruck();
|
||||
if (abdruck == _abdruck) return;
|
||||
_abdruck = abdruck;
|
||||
|
||||
var laeuft = Laeuft;
|
||||
var gesperrt = Gesperrt;
|
||||
_zeile.Text = s.T("text");
|
||||
_zeile.Foreground = gesperrt ? Ui.Pinsel("orange") : laeuft ? Ui.Pinsel("gruen") : Ui.Zweit;
|
||||
_knopfText.Text = laeuft ? "Stopp" : "Sammeln";
|
||||
_knopf.Background = laeuft ? Ui.Pinsel("rot", 0.28) : Ui.Pinsel("blau", 0.28);
|
||||
_knopf.BorderBrush = laeuft ? Ui.Pinsel("rot", 0.7) : Ui.Pinsel("blau", 0.7);
|
||||
_knopf.BorderThickness = new Thickness(1);
|
||||
_knopfTipp.An = laeuft || !gesperrt;
|
||||
|
||||
var stufen = s.Objekte("stufen").ToList();
|
||||
var tische = (int)(s.Zahl("tische") ?? 12);
|
||||
_gesamt.Text = $"{tische} Tische";
|
||||
_gesamtMinus.An = _gesamtPlus.An = !laeuft;
|
||||
var an = stufen.Where(x => x.Wahr("an")).OrderByDescending(x => x.Zahl("bb") ?? 0)
|
||||
.Select(x => x.T("name") + ((int)(x.Zahl("grenze") ?? 0) is int g && g > 0 ? $" bis {g}" : "")).ToList();
|
||||
_stufenKopf.Text = "Stufen · " + (an.Count > 0 ? string.Join(", ", an) : "keine gewählt");
|
||||
_stufenFuss.Text = laeuft ? $"gesamt {tische} Tische · gesperrt, solange er sammelt"
|
||||
: $"gesamt {tische} Tische · {stufen.Count} Stufen in der Lobby";
|
||||
|
||||
_chips.Children.Clear();
|
||||
for (var i = 0; i < stufen.Count; i++) _chips.Children.Add(Chip(stufen[i], i, laeuft));
|
||||
}
|
||||
|
||||
private FrameworkElement Chip(JsonObject st, int i, bool laeuft)
|
||||
{
|
||||
var ein = st.Wahr("an");
|
||||
var g = (int)(st.Zahl("grenze") ?? 0);
|
||||
var kopf = Ui.Zeile(Ui.Text(st.T("name"), 12, fett: true, pinsel: ein ? null : Ui.Zweit),
|
||||
Ui.Winzig(st.T("text").Replace(" Tische", " T."), Ui.Dritt), 4);
|
||||
var kopfTipp = kopf.Tippen(() => Wahl("stufe", 0, i), 6, ein ? "abwählen" : "wählen");
|
||||
kopfTipp.An = !laeuft;
|
||||
var s = Ui.Spalte(3, kopfTipp);
|
||||
if (ein)
|
||||
{
|
||||
var minus = Klein("", () => Wahl("grenze", -1, i));
|
||||
var plus = Klein("", () => Wahl("grenze", +1, i));
|
||||
minus.An = plus.An = !laeuft;
|
||||
var wert = Ui.Text(g > 0 ? $"bis {g}" : "alle", 11, zahlen: true);
|
||||
wert.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
wert.VerticalAlignment = VerticalAlignment.Center;
|
||||
var reihe = new Grid { ColumnSpacing = 2 };
|
||||
reihe.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
reihe.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
reihe.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
reihe.Children.Add(minus);
|
||||
reihe.Children.Add(wert.Spalte(1));
|
||||
reihe.Children.Add(plus.Spalte(2));
|
||||
s.Children.Add(reihe);
|
||||
}
|
||||
return new Border
|
||||
{
|
||||
Margin = new Thickness(0, 0, 4, 4),
|
||||
Padding = new Thickness(6, 4, 6, 4),
|
||||
CornerRadius = new CornerRadius(8),
|
||||
Background = ein ? Ui.Pinsel("blau", 0.20) : Ui.Weiss(0.04),
|
||||
BorderBrush = ein ? Ui.Pinsel("blau", 0.6) : Ui.Weiss(0.10),
|
||||
BorderThickness = new Thickness(1),
|
||||
Child = s,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user