summaryrefslogtreecommitdiffstats
path: root/gui/src/main.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-01 21:09:56 +0100
committersalmonik <salmonik@tuta.io>2026-11-01 21:09:56 +0100
commitbf4cf78ab26896faf457273e37d30fc96381c4a4 (patch)
tree71d67c300b6be191016a988ed5338e15c8b1bdd3 /gui/src/main.rs
parentv4.1.1: pointer-first betting and visible payouts in the GUI (diff)
downloadzagan-bet-bf4cf78ab26896faf457273e37d30fc96381c4a4.tar.gz
zagan-bet-bf4cf78ab26896faf457273e37d30fc96381c4a4.zip
v4.2.0: wire the GUI to the core, transport and all four games
Phase 4. The egui frontend now shares ClientCore and the client database with the terminal: one background worker owns TLS, trust answers go through a channel, and a 10 s request deadline mirrors the terminal socket timeout. First contact, a changed key and a version mismatch are explicit screens; login can remember the credential and auto-login signs in before the login form appears. Adds the lobby with an update notice, a full-width scrollable history table, and the four games painted from View: slots with reel animation and win lines that stop at the last matching reel, roulette with the hover lattice and wheel spin, blackjack with vector-drawn suits, and a smooth crash curve. Sidebars pin their action block; leaving a live hand or round asks before forfeiting. The header balance holds the staked amount while the reels or wheel turn and only shows the payout when they stop. Refused spins cancel the animation. Live crash multipliers keep full precision for the chart; the terminal still displays two decimals. Verified live against a 4.2.0 server: register, login, auto-login, trust, all four games settling, history (50 rows), logout, disconnect, forfeit confirmation, and the version-mismatch screen. Release: 8.3 MB Linux, 6.8 MB Windows, 61 ms to window, 131 MB idle RSS.
Diffstat (limited to '')
-rw-r--r--gui/src/main.rs38
1 files changed, 33 insertions, 5 deletions
diff --git a/gui/src/main.rs b/gui/src/main.rs
index cf1c67d..82babb6 100644
--- a/gui/src/main.rs
+++ b/gui/src/main.rs
@@ -1,12 +1,36 @@
1//! Desktop frontend for zagan-bet. 1//! Desktop frontend for zagan-bet.
2//! 2//!
3//! Phase 3 of `docs/GUI-PLAN.md`: the style spike. It owns the window and the 3//! Phase 4: the egui shell over the shared `ClientCore`, with the transport on
4//! roulette reference screen; the shared core and transport are wired in 4//! a worker thread. The same data directory and flags as the terminal client.
5//! Phase 4.
6 5
7use zagan_bet_gui::app::ZaganApp; 6use zagan_bet::client::paths::{default_data_dir, parse_args};
7use zagan_bet_gui::app::{Startup, ZaganApp};
8 8
9fn main() -> eframe::Result { 9fn main() -> eframe::Result {
10 let args = match parse_args(std::env::args().skip(1)) {
11 Ok(args) => args,
12 Err(message) => {
13 eprintln!("{message}");
14 std::process::exit(2);
15 }
16 };
17 if args.help {
18 println!(
19 "usage: zagan-bet-gui [-d <dir>] [--unsafe]
20
21 -d, --data-dir <dir> where to keep client.db (default: XDG data dir)
22 --unsafe skip certificate verification
23 -h, --help show this message"
24 );
25 return Ok(());
26 }
27
28 let data_dir = args.data_dir.unwrap_or_else(default_data_dir);
29 if let Err(error) = std::fs::create_dir_all(&data_dir) {
30 eprintln!("Cannot create {}: {error}", data_dir.display());
31 std::process::exit(1);
32 }
33
10 let options = eframe::NativeOptions { 34 let options = eframe::NativeOptions {
11 viewport: eframe::egui::ViewportBuilder::default() 35 viewport: eframe::egui::ViewportBuilder::default()
12 .with_title("Zagan-Bet") 36 .with_title("Zagan-Bet")
@@ -17,9 +41,13 @@ fn main() -> eframe::Result {
17 ..Default::default() 41 ..Default::default()
18 }; 42 };
19 43
44 let startup = Startup {
45 data_dir,
46 unsafe_mode: args.unsafe_mode,
47 };
20 eframe::run_native( 48 eframe::run_native(
21 "Zagan-Bet", 49 "Zagan-Bet",
22 options, 50 options,
23 Box::new(|cc| Ok(Box::new(ZaganApp::new(cc)))), 51 Box::new(move |cc| Ok(Box::new(ZaganApp::new(cc, startup)))),
24 ) 52 )
25} 53}