summaryrefslogtreecommitdiff
path: root/src/state/log.rs
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-08-02 11:38:19 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2024-08-02 11:38:19 +0200
commit04a5a938994ddb95cfaa9a74b180e457d3a2b5d0 (patch)
tree31ce9525ed3f3423678397323b65c910d63eadb1 /src/state/log.rs
parentfe0938b1de0c46fc2afcaa3dcd6a0f4ec870d21a (diff)
implement new lua interface
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(())
+ });
+ }
+}