-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.rs
105 lines (92 loc) · 3.1 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release mode
#[macro_use]
extern crate lazy_static;
pub mod autosplitters;
pub mod config;
pub mod hotkey;
pub mod livesplit_renderer;
pub mod routes;
pub mod usb2snes;
pub mod utils;
pub mod widget;
use autosplitters::supermetroid::Settings;
use clap::Parser;
use eframe::egui;
use livesplit_core::layout::{ComponentSettings, LayoutSettings};
use livesplit_core::{Layout, Run, Segment, Timer};
use parking_lot::RwLock;
use std::error::Error;
use std::sync::Arc;
use config::app_config::*;
use livesplit_renderer::*;
#[allow(dead_code)]
fn customize_layout(layout: &mut LayoutSettings) {
layout.components.iter_mut().for_each(customize_component);
}
#[allow(dead_code)]
fn customize_component(component: &mut ComponentSettings) {
match component {
ComponentSettings::Splits(splits) => customize_splits(splits),
ComponentSettings::Timer(timer) => customize_timer(timer),
_ => (),
}
}
#[allow(dead_code)]
fn customize_splits(splits: &mut livesplit_core::component::splits::Settings) {
use livesplit_core::timing::formatter::Accuracy;
splits.visual_split_count = 5;
splits.split_preview_count = 2;
splits.split_time_accuracy = Accuracy::Tenths;
splits.segment_time_accuracy = Accuracy::Tenths;
splits.always_show_last_split = true;
splits.delta_drop_decimals = true;
}
#[allow(dead_code)]
fn customize_timer(timer: &mut livesplit_core::component::timer::Settings) {
use livesplit_core::timing::formatter::Accuracy;
timer.accuracy = Accuracy::Tenths;
}
fn main() -> std::result::Result<(), Box<dyn Error>> {
let cli_config = AppConfig::parse();
let settings = Settings::new();
let settings = Arc::new(RwLock::new(settings));
let mut run = Run::default();
run.push_segment(Segment::new(""));
let timer = Timer::new(run)
.expect("Run with at least one segment provided")
.into_shared();
let options = eframe::NativeOptions {
renderer: eframe::Renderer::Glow,
viewport: egui::viewport::ViewportBuilder {
..Default::default()
},
..eframe::NativeOptions::default()
};
let layout_settings = Layout::default_layout().settings();
//customize_layout(&mut layout_settings);
let layout = Layout::from_settings(layout_settings);
use std::sync::mpsc::sync_channel;
let (sync_sender, sync_receiver) = sync_channel(1);
let project_dirs = directories::ProjectDirs::from("", "", "annelid")
.ok_or("Unable to computer configuration directory")?;
println!("project_dirs = {:#?}", project_dirs);
let preference_dir = project_dirs.preference_dir();
std::fs::create_dir_all(preference_dir)?;
let mut app = LiveSplitCoreRenderer::new(
timer,
layout,
settings,
sync_sender,
project_dirs,
cli_config,
);
eframe::run_native(
"Annelid",
options,
Box::new(move |cc| {
livesplit_renderer::app_init(&mut app, sync_receiver, cc);
Box::new(app)
}),
)?;
Ok(())
}