summaryrefslogtreecommitdiffstats
path: root/gui/src/main.rs
diff options
context:
space:
mode:
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}