Skip to content

Commit

Permalink
pass a path as an argument to bff-gui for it to load on startup :)
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzart committed Jan 13, 2024
1 parent 09be75b commit 8d4a668
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bff-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const WINDOW_SIZE: egui::Vec2 = egui::vec2(800.0, 600.0);

#[cfg(not(target_arch = "wasm32"))]
fn main() -> Result<(), eframe::Error> {
use std::env;

let rt = tokio::runtime::Runtime::new().expect("Unable to create Runtime");

let _enter = rt.enter();
Expand All @@ -43,7 +45,7 @@ fn main() -> Result<(), eframe::Error> {
initial_window_size: Some(WINDOW_SIZE),
..Default::default()
};
eframe::run_native(TITLE, options, Box::new(|cc| Box::new(Gui::new(cc))))
eframe::run_native(TITLE, options, Box::new(|cc| Box::new(Gui::new(cc, env::args().collect()))))
}

#[cfg(target_arch = "wasm32")]
Expand Down Expand Up @@ -103,18 +105,26 @@ struct Gui {
}

impl Gui {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
fn new(cc: &eframe::CreationContext<'_>, args: Vec<String>) -> Self {
cc.egui_ctx.set_pixels_per_point(1.25);
egui_extras::install_image_loaders(&cc.egui_ctx);
setup_custom_font(&cc.egui_ctx);
let (tx, rx) = std::sync::mpsc::channel();
let bf_loading = match args.get(1) {
Some(path) => {
let p = PathBuf::from(path);
load_bf(cc.egui_ctx.clone(), p.clone(), tx.clone());
true
},
None => false,
};
Self {
open_window: GuiWindow::default(),
tx,
rx,
bigfile: None,
bigfile_path: None,
bigfile_loading: false,
bigfile_loading: bf_loading,
resource_name: None,
nicknames: HashMap::new(),
nickname_editing: (Name::default(), String::new()),
Expand Down

0 comments on commit 8d4a668

Please sign in to comment.