feat: custom plugin config support
This commit is contained in:
1 parent
e1497acef4
commit
96ebe74d12
2 files changed
+14
-8
No files matched your search
+4
-3
@@ -18,10 +18,11 @@ use self::{
|
|||||||
command::PluginCommander, dirs::PluginDirs, fs::PluginFileSystem, log::PluginLogger,
|
command::PluginCommander, dirs::PluginDirs, fs::PluginFileSystem, log::PluginLogger,
|
||||||
network::PluginNetwork, os::PluginOS, path::PluginPath,
|
network::PluginNetwork, os::PluginOS, path::PluginPath,
|
||||||
},
|
},
|
||||||
|
types::PluginConfig,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod types;
|
|
||||||
pub mod interface;
|
pub mod interface;
|
||||||
|
mod types;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref LUA: Mutex<Lua> = Mutex::new(Lua::new());
|
static ref LUA: Mutex<Lua> = Mutex::new(Lua::new());
|
||||||
@@ -50,8 +51,8 @@ impl PluginManager {
|
|||||||
lua.globals()
|
lua.globals()
|
||||||
.set("library_dir", plugin_dir.to_str().unwrap())
|
.set("library_dir", plugin_dir.to_str().unwrap())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// lua.globals()
|
let config = PluginConfig::from_toml_value(config);
|
||||||
// .set("config_info", );
|
lua.globals().set("config_info", config)?;
|
||||||
|
|
||||||
let mut index: u32 = 1;
|
let mut index: u32 = 1;
|
||||||
let mut init_list: Vec<(u32, PathBuf, PluginInfo)> = Vec::new();
|
let mut init_list: Vec<(u32, PathBuf, PluginInfo)> = Vec::new();
|
||||||
|
|||||||
+10
-5
@@ -2,8 +2,6 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use mlua::ToLua;
|
use mlua::ToLua;
|
||||||
|
|
||||||
use super::LUA;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct PluginConfig {
|
pub struct PluginConfig {
|
||||||
available: bool,
|
available: bool,
|
||||||
@@ -38,9 +36,15 @@ impl PluginConfig {
|
|||||||
|
|
||||||
let mut config_info = HashMap::new();
|
let mut config_info = HashMap::new();
|
||||||
|
|
||||||
let lua = LUA.lock().unwrap();
|
for (name, value) in tab {
|
||||||
|
if let toml::Value::Table(value) = value {
|
||||||
for (name, value) in tab {}
|
let mut map = HashMap::new();
|
||||||
|
for (item, info) in value {
|
||||||
|
map.insert(item, Value::from_toml(info));
|
||||||
|
}
|
||||||
|
config_info.insert(name, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
available,
|
available,
|
||||||
@@ -55,6 +59,7 @@ impl PluginConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Value {
|
pub enum Value {
|
||||||
String(String),
|
String(String),
|
||||||
|
|||||||
Reference in new issue
Block a user