51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
use eframe::{NativeOptions, run_native, App};
|
|
use log::info;
|
|
use tokio::runtime::Runtime;
|
|
use std::sync::Arc;
|
|
use eframe::IconData;
|
|
|
|
mod app;
|
|
mod ui;
|
|
mod installer;
|
|
//mod util;
|
|
|
|
fn main() {
|
|
env_logger::init();
|
|
info!("Starting Sinfar NWN Custom Content Installer");
|
|
|
|
let rt = Runtime::new().expect("Failed to create Tokio runtime");
|
|
let rt = Arc::new(rt);
|
|
|
|
let options = NativeOptions {
|
|
initial_window_size: Some(eframe::egui::vec2(600.0, 400.0)),
|
|
resizable: false,
|
|
icon_data: load_icon(),
|
|
..Default::default()
|
|
};
|
|
|
|
let app_rt = rt.clone();
|
|
run_native(
|
|
"Sinfar NWN Custom Content Installer",
|
|
options,
|
|
Box::new(move |cc| Box::new(app::SinfarInstallerApp::new(cc, app_rt.clone()))),
|
|
).expect("Failed to start application");
|
|
}
|
|
|
|
fn load_icon() -> Option<eframe::IconData> {
|
|
#[cfg(feature = "embed_icon")]
|
|
{
|
|
let icon_bytes = include_bytes!("../assets/installerico.ico");
|
|
// Convert ico to rgba data
|
|
match image::load_from_memory(icon_bytes) {
|
|
Ok(image) => {
|
|
let image_rgba = image.to_rgba8();
|
|
let (width, height) = image_rgba.dimensions();
|
|
let rgba = image_rgba.into_raw();
|
|
Some(eframe::IconData { rgba, width, height })
|
|
},
|
|
Err(_) => None,
|
|
}
|
|
}
|
|
#[cfg(not(feature = "embed_icon"))]
|
|
None
|
|
} |