presence module & update_status
This commit is contained in:
@@ -7,7 +7,7 @@ use crate::{
|
||||
active_app::init_foreground_app_change_listener,
|
||||
auth::get_session_token,
|
||||
cursor::init_cursor_tracking,
|
||||
modules::init_modules,
|
||||
presence_modules::init_modules,
|
||||
scene::{close_splash_window, open_splash_window},
|
||||
welcome::open_welcome_window,
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ pub mod doll_editor;
|
||||
pub mod health_manager;
|
||||
pub mod health_monitor;
|
||||
pub mod interaction;
|
||||
pub mod modules;
|
||||
pub mod presence_modules;
|
||||
pub mod scene;
|
||||
pub mod sprite_recolor;
|
||||
pub mod welcome;
|
||||
|
||||
@@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json;
|
||||
use std::fs;
|
||||
|
||||
pub mod models;
|
||||
pub mod runtime;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
11
src-tauri/src/services/presence_modules/models.rs
Normal file
11
src-tauri/src/services/presence_modules/models.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export)]
|
||||
pub struct PresenceStatus {
|
||||
pub title: Option<String>,
|
||||
pub subtitle: Option<String>,
|
||||
pub graphics_b64: Option<String>,
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
use mlua::{Lua, UserData, UserDataMethods};
|
||||
use mlua::{Lua, LuaSerdeExt, UserData, UserDataMethods, Value};
|
||||
use std::{path::Path, thread, time::Duration};
|
||||
use tracing::{error, info};
|
||||
|
||||
use super::models::PresenceStatus;
|
||||
|
||||
pub struct Engine;
|
||||
|
||||
impl UserData for Engine {
|
||||
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||
fn add_methods<M: UserDataMethods<Self>>(methods: &mut M) {
|
||||
methods.add_method("log", |_, _, message: String| {
|
||||
info!("{}", message);
|
||||
Ok(())
|
||||
@@ -14,6 +16,11 @@ impl UserData for Engine {
|
||||
thread::sleep(Duration::from_secs(seconds));
|
||||
Ok(())
|
||||
});
|
||||
methods.add_method("update_status", |lua, _, value: Value| {
|
||||
let status: PresenceStatus = lua.from_value(value)?;
|
||||
dbg!(status);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user