支持货币数据获取

This commit is contained in:
BTMuli
2025-12-28 15:19:34 +08:00
parent 002fb63df3
commit 5ecb46f1da
4 changed files with 95 additions and 18 deletions

View File

@@ -10,6 +10,7 @@ use inject::{call_yaemain, create_named_pipe, find_module_base, inject_dll, spaw
use pt_ac::parse_achi_list;
use pt_store::parse_store_list;
use serde_json::Value;
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, Read, Write};
use std::os::windows::io::{FromRawHandle, RawHandle};
@@ -116,7 +117,8 @@ pub fn call_yae_dll(
move || {
let mut file = file.try_clone().expect("Failed to clone pipe file");
let mut cmd = [0u8; 1];
// 处理Prop
let mut prop_map: HashMap<u32, f64> = HashMap::new();
loop {
match file.read_exact(&mut cmd) {
// 输出命令字节
@@ -124,6 +126,7 @@ pub fn call_yae_dll(
println!("收到命令: {}", cmd[0]);
match cmd[0] {
0x01 => {
println!("AchievementNotify");
match read_u32_le(&mut file) {
Ok(len) => {
// 再读数据
@@ -175,7 +178,9 @@ pub fn call_yae_dll(
// 读取剩余数据
match read_u32_le(&mut file) {
Ok(prop_type) => match read_f64_le(&mut file) {
Ok(value) => println!("Prop 类型: {}, 值: {}", prop_type, value),
Ok(value) => {
prop_map.insert(prop_type, value);
}
Err(e) => println!("读取值失败: {:?}", e),
},
Err(e) => println!("读取类型失败: {:?}", e),
@@ -202,6 +207,34 @@ pub fn call_yae_dll(
}
}
0xFF => {
println!("处理 Prop 列表,长度: {}", prop_map.len());
let mut new_data: HashMap<u32, f64> = HashMap::new();
// 201 = 10015 - 10022 原石
let v1 = prop_map.get(&10015).copied().unwrap_or(0.0);
let v2 = prop_map.get(&10022).copied().unwrap_or(0.0);
new_data.insert(201, v1 - v2);
// 202 = 10016 - 10023 摩拉
let v3 = prop_map.get(&10016).copied().unwrap_or(0.0);
let v4 = prop_map.get(&10023).copied().unwrap_or(0.0);
new_data.insert(202, v3 - v4);
// 203 = 10025 - 10026 创世结晶
let v5 = prop_map.get(&10025).copied().unwrap_or(0.0);
let v6 = prop_map.get(&10026).copied().unwrap_or(0.0);
new_data.insert(203, v5 - v6);
// 204 = 10042 - 10043 洞天宝钱
let v7 = prop_map.get(&10042).copied().unwrap_or(0.0);
let v8 = prop_map.get(&10043).copied().unwrap_or(0.0);
new_data.insert(204, v7 - v8);
// 206 = 10053
// let v9 = prop_map.get(&10053).copied().unwrap_or(0.0);
// new_data.insert(206, v9);
// 207 = 10058
// let va = prop_map.get(&10058).copied().unwrap_or(0.0);
// new_data.insert(207, va);
// 转成 JSON 输出
let json = serde_json::to_string_pretty(&new_data).unwrap();
let payload = serde_json::json!({ "type": "prop", "data": json, "uid": uid });
let _ = app_handle.emit("yae_read", payload);
let _ = file.write_all(&[1]);
break;
}