-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.rs
68 lines (55 loc) · 1.72 KB
/
Main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#![cfg_attr(not(debug_assertions), windows_subsystem="windows")]
#![allow(non_snake_case)]
#![allow(unused_must_use)]
use Broken::*;
BrokenImport!{PocketSolar}
use egui::plot::Line;
use egui::plot::Plot;
use egui::plot::PlotBounds;
use egui::plot::PlotPoints;
use egui::plot::Points;
use egui::Color32;
#[derive(Parser, Debug)]
#[command(author=Broken::Constants::AUTHOR, about=Broken::Constants::About::PocketSolar, version)]
pub struct Args {
#[arg(short, long, help = "Reset to default settings")]
defaultSettings: bool,
}
BrokenStruct! {
pub struct PocketSolarApp {
#[serde(skip)]
solarPanelCurve: Arc<RwLock<SolarCurve::SolarCurve>>,
// Export Window
showExportWindow: bool,
#[default(20)]
exportNOfPoints: i64,
outputCSV: String,
// Other configurations
showConfigurationWindow: bool,
}
}
impl PocketSolarApp {
pub fn new(cc: &eframe::CreationContext<'_>, args: Args) -> PocketSolarApp {
// Restore previous settings if any
let mut app = {
if !args.defaultSettings {
if let Some(storage) = cc.storage {
eframe::get_value(storage, "PocketSolar").unwrap_or_default()
}
}
PocketSolarApp::default()
};
// Spin the SolarCurve thread
app.solarPanelCurve = SolarCurve::SolarCurve::spin_default();
return app;
}
}
fn main() {
Broken::setupLog();
let args = Args::parse();
eframe::run_native("PocketSolar", eframe::NativeOptions::default(), Box::new(|cc| {
let app = Box::new(PocketSolarApp::new(cc, args));
cc.egui_ctx.set_visuals(egui::Visuals::dark());
return app;
}));
}