|
@@ -34,10 +34,9 @@ use crate::{
|
|
|
error::Error,
|
|
error::Error,
|
|
|
expr::Op,
|
|
expr::Op,
|
|
|
gfx::{GraphicsEventPublisherPtr, RenderApi, Vertex},
|
|
gfx::{GraphicsEventPublisherPtr, RenderApi, Vertex},
|
|
|
- plugin::{self, PluginObject},
|
|
|
|
|
|
|
+ plugin::{self, PluginObject, PluginSettings},
|
|
|
prop::{
|
|
prop::{
|
|
|
- Property, PropertyAtomicGuard, PropertyBool, PropertyStr, PropertySubType, PropertyType,
|
|
|
|
|
- Role,
|
|
|
|
|
|
|
+ Property, PropertyAtomicGuard, PropertyBool, PropertyStr, PropertySubType, PropertyType, PropertyValue, Role
|
|
|
},
|
|
},
|
|
|
scene::{Pimpl, SceneNode as SceneNode3, SceneNodePtr, SceneNodeType as SceneNodeType3, Slot},
|
|
scene::{Pimpl, SceneNode as SceneNode3, SceneNodePtr, SceneNodeType as SceneNodeType3, Slot},
|
|
|
text::TextShaperPtr,
|
|
text::TextShaperPtr,
|
|
@@ -48,12 +47,13 @@ use crate::{
|
|
|
mod node;
|
|
mod node;
|
|
|
use node::create_darkirc;
|
|
use node::create_darkirc;
|
|
|
mod schema;
|
|
mod schema;
|
|
|
-use schema::{get_window_scale_filename, settings};
|
|
|
|
|
|
|
+use schema::{get_settingsdb_path, get_window_scale_filename, settings};
|
|
|
|
|
|
|
|
macro_rules! d { ($($arg:tt)*) => { debug!(target: "app", $($arg)*); } }
|
|
macro_rules! d { ($($arg:tt)*) => { debug!(target: "app", $($arg)*); } }
|
|
|
macro_rules! t { ($($arg:tt)*) => { trace!(target: "app", $($arg)*); } }
|
|
macro_rules! t { ($($arg:tt)*) => { trace!(target: "app", $($arg)*); } }
|
|
|
macro_rules! i { ($($arg:tt)*) => { info!(target: "app", $($arg)*); } }
|
|
macro_rules! i { ($($arg:tt)*) => { info!(target: "app", $($arg)*); } }
|
|
|
macro_rules! w { ($($arg:tt)*) => { warn!(target: "app", $($arg)*); } }
|
|
macro_rules! w { ($($arg:tt)*) => { warn!(target: "app", $($arg)*); } }
|
|
|
|
|
+macro_rules! e { ($($arg:tt)*) => { error!(target: "app", $($arg)*); } }
|
|
|
|
|
|
|
|
//fn print_type_of<T>(_: &T) {
|
|
//fn print_type_of<T>(_: &T) {
|
|
|
// println!("{}", std::any::type_name::<T>())
|
|
// println!("{}", std::any::type_name::<T>())
|
|
@@ -157,8 +157,18 @@ impl App {
|
|
|
|
|
|
|
|
/// Does not require miniquad to be init. Created the scene graph tree / schema and all
|
|
/// Does not require miniquad to be init. Created the scene graph tree / schema and all
|
|
|
/// the objects.
|
|
/// the objects.
|
|
|
- pub async fn setup(&self) {
|
|
|
|
|
|
|
+ pub async fn setup(&self) -> Result<Option<i32>, Error> {
|
|
|
t!("App::setup()");
|
|
t!("App::setup()");
|
|
|
|
|
+
|
|
|
|
|
+ let db_path = get_settingsdb_path();
|
|
|
|
|
+ let db = match sled::open(&db_path) {
|
|
|
|
|
+ Ok(db) => db,
|
|
|
|
|
+ Err(err) => {
|
|
|
|
|
+ e!("Sled database '{}' failed to open: {err}!", db_path.display());
|
|
|
|
|
+ return Err(Error::SledDbErr);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
let atom = &mut PropertyAtomicGuard::new();
|
|
let atom = &mut PropertyAtomicGuard::new();
|
|
|
|
|
|
|
|
let mut window = SceneNode3::new("window", SceneNodeType3::Window);
|
|
let mut window = SceneNode3::new("window", SceneNodeType3::Window);
|
|
@@ -167,12 +177,21 @@ impl App {
|
|
|
prop.set_array_len(2);
|
|
prop.set_array_len(2);
|
|
|
window.add_property(prop).unwrap();
|
|
window.add_property(prop).unwrap();
|
|
|
|
|
|
|
|
- let mut prop = Property::new("scale", PropertyType::Float32, PropertySubType::Pixel);
|
|
|
|
|
- prop.set_defaults_f32(vec![1.]).unwrap();
|
|
|
|
|
- window.add_property(prop).unwrap();
|
|
|
|
|
|
|
|
|
|
- let window = window.setup(|me| Window::new(me, self.render_api.clone())).await;
|
|
|
|
|
|
|
+ let setting_root = Arc::new(SceneNode3::new("setting", SceneNodeType3::SettingRoot));
|
|
|
|
|
+ let settings_tree = db.open_tree("settings").unwrap();
|
|
|
|
|
+ let settings = PluginSettings {
|
|
|
|
|
+ setting_root: setting_root.clone(),
|
|
|
|
|
+ sled_tree: settings_tree,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ settings.add_setting("scale", PropertyValue::Float32(1.));
|
|
|
|
|
+ settings.load_settings();
|
|
|
|
|
+ let window = window.setup(|me| Window::new(me, self.render_api.clone(), setting_root.clone())).await;
|
|
|
|
|
+
|
|
|
self.sg_root.clone().link(window.clone());
|
|
self.sg_root.clone().link(window.clone());
|
|
|
|
|
+ self.sg_root.clone().link(setting_root.clone());
|
|
|
|
|
+
|
|
|
schema::make(&self, window.clone()).await;
|
|
schema::make(&self, window.clone()).await;
|
|
|
|
|
|
|
|
d!("Schema loaded");
|
|
d!("Schema loaded");
|
|
@@ -186,7 +205,9 @@ impl App {
|
|
|
#[cfg(not(feature = "enable-plugins"))]
|
|
#[cfg(not(feature = "enable-plugins"))]
|
|
|
w!("Plugins are disabled in this build");
|
|
w!("Plugins are disabled in this build");
|
|
|
|
|
|
|
|
- settings::make(&self, window).await;
|
|
|
|
|
|
|
+ settings::make(&self, window, self.ex.clone()).await;
|
|
|
|
|
+
|
|
|
|
|
+ Ok(None)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "enable-plugins")]
|
|
#[cfg(feature = "enable-plugins")]
|
|
@@ -330,12 +351,6 @@ impl App {
|
|
|
prop.clone().set_f32(atom, Role::App, 0, screen_width);
|
|
prop.clone().set_f32(atom, Role::App, 0, screen_width);
|
|
|
prop.clone().set_f32(atom, Role::App, 1, screen_height);
|
|
prop.clone().set_f32(atom, Role::App, 1, screen_height);
|
|
|
|
|
|
|
|
- let mut window_scale = 1.;
|
|
|
|
|
- if let Ok(mut file) = File::open(get_window_scale_filename()) {
|
|
|
|
|
- window_scale = Decodable::decode(&mut file).unwrap();
|
|
|
|
|
- }
|
|
|
|
|
- window_node.set_property_f32(atom, Role::App, "scale", window_scale).unwrap();
|
|
|
|
|
-
|
|
|
|
|
drop(atom);
|
|
drop(atom);
|
|
|
|
|
|
|
|
// Access drawable in window node and call draw()
|
|
// Access drawable in window node and call draw()
|