summaryrefslogtreecommitdiff
path: root/src/state/log.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/log.rs')
-rw-r--r--src/state/log.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/state/log.rs b/src/state/log.rs
new file mode 100644
index 0000000..5afa8ca
--- /dev/null
+++ b/src/state/log.rs
@@ -0,0 +1,35 @@
+use mlua::UserData;
+use super::GlobalState;
+
+#[derive(Debug, Default)]
+pub struct LogState {
+ pub visible: bool,
+}
+
+impl LogState {
+ pub const fn new() -> Self {
+ Self { visible: false }
+ }
+}
+
+macro_rules! cfg {
+ () => {
+ GlobalState::instance().log
+ };
+}
+
+macro_rules! cfg_mut {
+ () => {
+ GlobalState::instance_mut().log
+ };
+}
+
+impl UserData for LogState {
+ fn add_fields<'lua, F: mlua::prelude::LuaUserDataFields<'lua, Self>>(fields: &mut F) {
+ fields.add_field_function_get("visible", |_, _| Ok(cfg!().visible));
+ fields.add_field_function_set("visible", |_, _, visible: bool| {
+ cfg_mut!().visible = visible;
+ Ok(())
+ });
+ }
+}