1rust_i18n::i18n!("locales");
3
4include!(concat!(env!("OUT_DIR"), "/icon_meta.rs"));
5
6pub mod app;
7pub mod menu;
8pub mod panels;
9pub mod preferences;
10pub mod state;
11pub mod theme;
12pub mod toolbar;
13pub mod updater;
15pub mod widgets;
17pub mod worker;
19
20use std::path::PathBuf;
21
22use eframe::egui;
23use rust_i18n::t;
24
25pub fn run(project_path: Option<PathBuf>) -> anyhow::Result<()> {
29 let mut app = app::FastPackApp::default();
30 rust_i18n::set_locale(app.prefs.language.code());
31 if let Some(path) = project_path {
32 match std::fs::read_to_string(&path) {
33 Ok(text) => match toml::from_str(&text) {
34 Ok(project) => {
35 app.state.project = project;
36 app.state.project_path = Some(path);
37 }
38 Err(e) => app
39 .state
40 .log_error(t!("log.parse_failed", err = e.to_string())),
41 },
42 Err(e) => app
43 .state
44 .log_error(t!("log.read_failed", err = e.to_string())),
45 }
46 }
47 let options = eframe::NativeOptions {
48 viewport: egui::ViewportBuilder::default()
49 .with_inner_size([1280.0, 800.0])
50 .with_icon(load_icon()),
51 ..Default::default()
52 };
53 eframe::run_native(
54 "FastPack",
55 options,
56 Box::new(|cc| {
57 let mut fonts = egui::FontDefinitions::default();
58 egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular);
59 cc.egui_ctx.set_fonts(fonts);
60 theme::apply(&cc.egui_ctx, app.state.dark_mode);
61 let native_ppp = cc.egui_ctx.pixels_per_point();
62 app.native_pixels_per_point = native_ppp;
63 cc.egui_ctx
64 .set_pixels_per_point(native_ppp * app.prefs.ui_scale);
65 Ok(Box::new(app))
66 }),
67 )
68 .map_err(|e| anyhow::anyhow!("eframe error: {e}"))
69}
70
71fn load_icon() -> egui::IconData {
72 let rgba = include_bytes!(concat!(env!("OUT_DIR"), "/icon.rgba")).to_vec();
73 egui::IconData {
74 rgba,
75 width: ICON_WIDTH,
76 height: ICON_HEIGHT,
77 }
78}