Compare commits

...

2 Commits

Author SHA1 Message Date
David Holland d541ce90e9 Add RON support and make it the preferred file format 2023-06-11 13:09:45 +02:00
David Holland 5c27435e87 Bump version numbers 2023-06-11 13:02:14 +02:00
4 changed files with 167 additions and 99 deletions

211
Cargo.lock generated
View File

@ -360,9 +360,9 @@ dependencies = [
[[package]]
name = "atk-sys"
version = "0.15.1"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6"
checksum = "11ad703eb64dc058024f0e57ccfa069e15a413b98dbd50a1a950e743b7f11148"
dependencies = [
"glib-sys",
"gobject-sys",
@ -535,9 +535,9 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
[[package]]
name = "cairo-sys-rs"
version = "0.15.1"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8"
checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421"
dependencies = [
"libc",
"system-deps",
@ -1327,6 +1327,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c"
[[package]]
name = "fast-srgb8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1"
[[package]]
name = "fastrand"
version = "1.9.0"
@ -1357,15 +1363,6 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "find-crate"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59a98bbaacea1c0eb6a0876280051b892eb73594fd90cf3b20e9c817029c57d2"
dependencies = [
"toml 0.5.11",
]
[[package]]
name = "flate2"
version = "1.0.26"
@ -1481,9 +1478,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533"
dependencies = [
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
@ -1491,9 +1490,9 @@ dependencies = [
[[package]]
name = "gdk-pixbuf-sys"
version = "0.15.10"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7"
checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016"
dependencies = [
"gio-sys",
"glib-sys",
@ -1504,9 +1503,9 @@ dependencies = [
[[package]]
name = "gdk-sys"
version = "0.15.1"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88"
checksum = "d76354f97a913e55b984759a997b693aa7dc71068c9e98bcce51aa167a0a5c5a"
dependencies = [
"cairo-sys-rs",
"gdk-pixbuf-sys",
@ -1554,9 +1553,9 @@ dependencies = [
[[package]]
name = "gio-sys"
version = "0.15.10"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d"
checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229"
dependencies = [
"glib-sys",
"gobject-sys",
@ -1578,9 +1577,9 @@ dependencies = [
[[package]]
name = "glib-sys"
version = "0.15.10"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4"
checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65"
dependencies = [
"libc",
"system-deps",
@ -1689,9 +1688,9 @@ dependencies = [
[[package]]
name = "gobject-sys"
version = "0.15.10"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a"
checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1"
dependencies = [
"glib-sys",
"libc",
@ -1700,9 +1699,9 @@ dependencies = [
[[package]]
name = "gtk-sys"
version = "0.15.3"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84"
checksum = "89b5f8946685d5fe44497007786600c2f368ff6b1e61a16251c89f72a97520a3"
dependencies = [
"atk-sys",
"cairo-sys-rs",
@ -2051,9 +2050,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.18"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
[[package]]
name = "longest-increasing-subsequence"
@ -2236,6 +2235,16 @@ dependencies = [
"windows-sys 0.45.0",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num-integer"
version = "0.1.45"
@ -2376,6 +2385,12 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "owned_ttf_parser"
version = "0.19.0"
@ -2387,33 +2402,32 @@ dependencies = [
[[package]]
name = "palette"
version = "0.6.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f9cd68f7112581033f157e56c77ac4a5538ec5836a2e39284e65bd7d7275e49"
checksum = "e1641aee47803391405d0a1250e837d2336fdddd18b27f3ddb8c1d80ce8d7f43"
dependencies = [
"approx",
"num-traits",
"fast-srgb8",
"palette_derive",
"phf",
]
[[package]]
name = "palette_derive"
version = "0.6.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05eedf46a8e7c27f74af0c9cfcdb004ceca158cb1b918c6f68f8d7a549b3e427"
checksum = "3c02bfa6b3ba8af5434fa0531bf5701f750d983d4260acd6867faca51cdc4484"
dependencies = [
"find-crate",
"proc-macro2",
"quote",
"syn 1.0.109",
"syn 2.0.18",
]
[[package]]
name = "pango-sys"
version = "0.15.10"
version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa"
checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f"
dependencies = [
"glib-sys",
"gobject-sys",
@ -2558,9 +2572,9 @@ dependencies = [
[[package]]
name = "png"
version = "0.17.8"
version = "0.17.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaeebc51f9e7d2c150d3f3bfeb667f2aa985db5ef1e3d212847bdedb488beeaa"
checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11"
dependencies = [
"bitflags",
"crc32fast",
@ -2703,17 +2717,18 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
[[package]]
name = "rfd"
version = "0.10.0"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0149778bd99b6959285b0933288206090c50e2327f47a9c463bfdbf45c8823ea"
checksum = "4fe664af397d2b6a13a8ba1d172a2b5c87c6c5149039edbf8fa122b98c9ed96f"
dependencies = [
"async-io",
"block",
"dispatch",
"futures-util",
"glib-sys",
"gobject-sys",
"gtk-sys",
"js-sys",
"lazy_static",
"log",
"objc",
"objc-foundation",
@ -2722,7 +2737,18 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"windows 0.37.0",
"windows 0.44.0",
]
[[package]]
name = "ron"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300a51053b1cb55c80b7a9fde4120726ddf25ca241a1cbb926626f62fb136bff"
dependencies = [
"base64",
"bitflags",
"serde",
]
[[package]]
@ -2768,9 +2794,13 @@ dependencies = [
"palette",
"plotly",
"rfd",
"ron",
"serde",
"serde_json",
"toml 0.5.11",
"toml 0.7.4",
"tracing-subscriber",
"tracing-wasm",
"wasm-bindgen-futures",
]
[[package]]
@ -2930,6 +2960,15 @@ dependencies = [
"digest",
]
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]]
name = "simd-adler32"
version = "0.3.5"
@ -3317,6 +3356,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77"
dependencies = [
"nu-ansi-term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
]
[[package]]
name = "tracing-wasm"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07"
dependencies = [
"tracing",
"tracing-subscriber",
"wasm-bindgen",
]
[[package]]
@ -3394,6 +3470,12 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2cb3ff47e36907a6267572c1e398ff32ef78ac5131de8aa272e53846592c207e"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vec_map"
version = "0.8.2"
@ -3658,19 +3740,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647"
dependencies = [
"windows_aarch64_msvc 0.37.0",
"windows_i686_gnu 0.37.0",
"windows_i686_msvc 0.37.0",
"windows_x86_64_gnu 0.37.0",
"windows_x86_64_msvc 0.37.0",
]
[[package]]
name = "windows"
version = "0.44.0"
@ -3773,12 +3842,6 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
@ -3791,12 +3854,6 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3"
[[package]]
name = "windows_i686_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
@ -3809,12 +3866,6 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241"
[[package]]
name = "windows_i686_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
@ -3827,12 +3878,6 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00"
[[package]]
name = "windows_x86_64_gnu"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
@ -3857,12 +3902,6 @@ version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953"
[[package]]
name = "windows_x86_64_msvc"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"

View File

@ -10,17 +10,29 @@ edition = "2021"
chrono = { version = "0.4.23", features = ["wasmbind"] }
console_error_panic_hook = "0.1.7"
fast-float = "0.2.0"
palette = "0.6.1"
palette = "0.7.2"
plotly = { version = "0.8.1", features = ["wasm"] }
rfd = "0.11.4"
ron = "0.8.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.5.9"
rfd = "0.10.0"
toml = "0.7.4"
dioxus = "0.3.2"
dioxus-web = "0.3.2"
egui = { git = "https://github.com/emilk/egui", branch = "master" }
eframe = { git = "https://github.com/emilk/egui", branch = "master" }
dioxus = "0.3.2"
dioxus-web = "0.3.2"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tracing-subscriber = "0.3"
# web:
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.6"
tracing-wasm = "0.2"
wasm-bindgen-futures = "0.4"
[profile.release]
opt-level = 2 # fast and small wasm

View File

@ -1,9 +1,9 @@
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fs;
#[derive(Deserialize, Debug, Default)]
#[derive(Deserialize, Debug, Default, Serialize)]
pub struct Shot {
pub filename: Option<String>,
pub json: Option<String>,
@ -12,7 +12,7 @@ pub struct Shot {
pub disable: Option<bool>,
}
#[derive(Deserialize, Debug, Default)]
#[derive(Deserialize, Debug, Default, Serialize)]
pub struct Chart {
pub title: String,
pub shots: Vec<u64>,
@ -22,7 +22,7 @@ pub struct Chart {
pub max_flow: u64,
}
#[derive(Deserialize, Debug, Default)]
#[derive(Deserialize, Debug, Default, Serialize)]
pub struct Config {
pub shots: HashMap<String, Shot>,
pub charts: HashMap<String, Chart>,
@ -38,8 +38,19 @@ pub struct Config {
}
impl Config {
pub fn from_file(path: &str) -> Self {
pub fn from_toml(path: &str) -> Self {
let config_file = fs::read_to_string(&path).expect("Can't read config.toml");
toml::from_str(&config_file).expect("Can't deserialize config.toml")
}
pub fn from_ron(path: &str) -> Self {
let config_file = fs::read_to_string(&path).expect("Can't read config.ron");
let ron: Self = ron::from_str(&config_file).expect("Can't deserialize config.ron");
println!("{}", ron::to_string(&ron).unwrap());
ron
}
pub fn from_default() -> Self {
Self::from_ron("config.ron")
}
}

View File

@ -6,6 +6,7 @@ use egui::{
plot::{Legend, Line, Plot},
Align, Layout, ProgressBar,
};
use plotly::layout::Center;
// use rfd::FileDialog;
@ -101,7 +102,7 @@ impl eframe::App for Ui {
ctx.request_repaint();
}
self.allowed_to_close = true;
// self.allowed_to_close = true;
egui::TopBottomPanel::bottom("status_bar").show(ctx, |ui| {
ui.columns(2, |_columns| {});
});
@ -342,7 +343,7 @@ impl eframe::App for Ui {
let mut loading_data = LoadingData::default();
loading_data.config = Config::from_file(&picked_path_owned);
loading_data.config = Config::from_ron(&picked_path_owned);
loading_data.database =
Database::from_config(&loading_data.config);
@ -426,13 +427,14 @@ impl eframe::App for Ui {
// if ui.button("Open file").clicked() {
// if let Some(path) = FileDialog::new()
// .add_filter("ron", &["ron"])
// .add_filter("toml", &["toml"])
// .set_directory(
// match &env::current_dir() {
// Ok(path) => path.to_str(),
// Err(_) => None,
// }
// .unwrap_or_default(),
// .unwrap_or_default(),
// )
// .pick_file()
// {
@ -440,6 +442,10 @@ impl eframe::App for Ui {
// }
// }
if ui.button("Open default config.ron").clicked() {
self.picked_path = Some(String::from("config.ron"));
}
if ui.button("Open default config.toml").clicked() {
self.picked_path = Some(String::from("config.toml"));
}