[feat] template works but cannot edit value by clicking

This commit is contained in:
Purp1e
2025-03-27 16:11:42 +08:00
parent 63172f12bc
commit a10cf8eddf
3 changed files with 31 additions and 39 deletions

View File

@@ -228,7 +228,7 @@ pub fn parse_local_users(steam_dir: &str) -> Result<Vec<LocalUser>> {
let kv: HashMap<String, Value> = serde_json::from_str(&json_data)?;
// 剥离顶层 UserLocalConfigStore
let kv = kv.get("UserLocalConfigStore").and_then(|v| v.as_object()).unwrap();
// let kv = kv.get("UserLocalConfigStore").and_then(|v| v.as_object()).unwrap();
// 获取 friends 节点
let friends = kv.get("friends").and_then(|v| v.as_object());

View File

@@ -47,25 +47,25 @@ const VideoSetting = () => {
2: "2X MSAA",
4: "4X MSAA",
8: "8X MSAA",
}[parseInt(video.msaa_samples)] || "无",
}[parseInt(video.msaa_samples, 10)] || "无",
options: ["无", "2X MSAA", "4X MSAA", "8X MSAA"],
},
{
type: "videocfg_shadow_quality",
title: "全局阴影效果",
value: ["低", "中", "高", "非常高"][parseInt(video.videocfg_shadow_quality)] || "低",
value: ["低", "中", "高", "非常高"][parseInt(video.videocfg_shadow_quality, 10)] || "低",
options: ["低", "中", "高", "非常高"],
},
{
type: "videocfg_dynamic_shadows",
title: "动态阴影",
value: ["仅限日光", "全部"][parseInt(video.videocfg_dynamic_shadows)] || "仅限日光",
value: ["仅限日光", "全部"][parseInt(video.videocfg_dynamic_shadows, 10)] || "仅限日光",
options: ["仅限日光", "全部"],
},
{
type: "videocfg_texture_detail",
title: "模型/贴图细节",
value: ["低", "中", "高"][parseInt(video.videocfg_texture_detail)] || "低",
value: ["低", "中", "高"][parseInt(video.videocfg_texture_detail, 10)] || "低",
options: ["低", "中", "高"],
},
{
@@ -73,33 +73,33 @@ const VideoSetting = () => {
title: "贴图过滤模式",
value:
["双线性", "三线性", "异向 2X", "异向 4X", "异向 8X", "异向 16X"][
parseInt(video.r_texturefilteringquality)
parseInt(video.r_texturefilteringquality, 10)
] || "双线性",
options: ["双线性", "三线性", "异向 2X", "异向 4X", "异向 8X", "异向 16X"],
},
{
type: "videocfg_hdr_detail",
title: "光影细节",
value: ["低", "高"][parseInt(video.shaderquality)] || "低",
value: ["低", "高"][parseInt(video.shaderquality, 10)] || "低",
options: ["低", "高"],
},
{
type: "videocfg_particle_detail",
title: "粒子细节",
value: ["低", "中", "高", "非常高"][parseInt(video.videocfg_particle_detail)] || "低",
value: ["低", "中", "高", "非常高"][parseInt(video.videocfg_particle_detail, 10)] || "低",
options: ["低", "中", "高", "非常高"],
},
{
type: "videocfg_ao_detail",
title: "环境光遮蔽",
value: ["已禁用", "中", "高"][parseInt(video.videocfg_ao_detail)] || "已禁用",
value: ["已禁用", "中", "高"][parseInt(video.videocfg_ao_detail, 10)] || "已禁用",
options: ["已禁用", "中", "高"],
},
{
type: "videocfg_fsr_detail",
title: "Fidelity FX 超级分辨率",
value:
["已禁用", "超高品质", "品质", "均衡", "性能"][parseInt(video.videocfg_fsr_detail)] ||
["已禁用", "超高品质", "品质", "均衡", "性能"][parseInt(video.videocfg_fsr_detail, 10)] ||
"性能",
options: ["性能", "均衡", "品质", "超高品质", "已禁用"],
},
@@ -108,6 +108,11 @@ const VideoSetting = () => {
const [vconfig, setVconfig] = useState<VideoConfig>(tool.state.videoSetting)
useEffect(() => {
console.log("讀取設置")
void tool.getVideoConfig(steam.state.steamDir, steam.currentUser()?.steam_id32 || 0)
}, [])
return (
<Card>
<CardHeader>
@@ -134,7 +139,9 @@ const VideoSetting = () => {
steam.currentUser()?.steam_id32 || 0,
vconfig
)
addToast({ title: "测试中 功能完成后可应用设置到游戏" })
await tool.getVideoConfig(steam.state.steamDir, steam.currentUser()?.steam_id32 || 0)
setEdit(false)
addToast({ title: "应用设置成功" })
}}
>
<Plus />
@@ -142,8 +149,8 @@ const VideoSetting = () => {
</ToolButton>
</>
)}
<Tooltip content="功能测试中,尚未实装" showArrow={true} delay={300}>
<ToolButton onClick={() => {
<ToolButton onClick={async() => {
await tool.getVideoConfig(steam.state.steamDir, steam.currentUser()?.steam_id32 || 0)
setVconfig(tool.state.videoSetting)
setEdit(!edit)
}}>
@@ -159,7 +166,6 @@ const VideoSetting = () => {
</>
)}
</ToolButton>
</Tooltip>
<ToolButton
onClick={() =>

View File

@@ -49,12 +49,9 @@ export interface VideoSetting {
// TODO: 校准
export const VideoSettingTemplate = {
veryhigh: {
cpu_level: "3",
gpu_mem_level: "3",
gpu_level: "3",
shaderquality: "0",
shaderquality: "1",
r_texturefilteringquality: "3",
msaa_samples: "2",
msaa_samples: "8",
r_csgo_cmaa_enable: "0",
videocfg_shadow_quality: "0",
videocfg_dynamic_shadows: "1",
@@ -64,12 +61,9 @@ export const VideoSettingTemplate = {
videocfg_hdr_detail: "3",
},
high: {
cpu_level: "3",
gpu_mem_level: "3",
gpu_level: "3",
shaderquality: "0",
r_texturefilteringquality: "3",
msaa_samples: "2",
r_texturefilteringquality: "2",
msaa_samples: "4",
r_csgo_cmaa_enable: "0",
videocfg_shadow_quality: "0",
videocfg_dynamic_shadows: "1",
@@ -77,13 +71,11 @@ export const VideoSettingTemplate = {
videocfg_particle_detail: "0",
videocfg_ao_detail: "0",
videocfg_hdr_detail: "3",
videocfg_fsr_detail: "0",
},
middle: {
cpu_level: "3",
gpu_mem_level: "3",
gpu_level: "3",
shaderquality: "0",
r_texturefilteringquality: "3",
r_texturefilteringquality: "2",
msaa_samples: "2",
r_csgo_cmaa_enable: "0",
videocfg_shadow_quality: "0",
@@ -91,27 +83,21 @@ export const VideoSettingTemplate = {
videocfg_texture_detail: "1",
videocfg_particle_detail: "0",
videocfg_ao_detail: "0",
videocfg_hdr_detail: "3",
videocfg_fsr_detail: "1",
},
low: {
cpu_level: "3",
gpu_mem_level: "3",
gpu_level: "3",
shaderquality: "0",
r_texturefilteringquality: "3",
msaa_samples: "2",
r_texturefilteringquality: "0",
msaa_samples: "0",
r_csgo_cmaa_enable: "0",
videocfg_shadow_quality: "0",
videocfg_dynamic_shadows: "1",
videocfg_texture_detail: "1",
videocfg_particle_detail: "0",
videocfg_ao_detail: "0",
videocfg_hdr_detail: "3",
videocfg_fsr_detail: "2",
},
recommend: {
cpu_level: "3",
gpu_mem_level: "3",
gpu_level: "3",
shaderquality: "0",
r_texturefilteringquality: "3",
msaa_samples: "2",
@@ -121,7 +107,7 @@ export const VideoSettingTemplate = {
videocfg_texture_detail: "1",
videocfg_particle_detail: "0",
videocfg_ao_detail: "0",
videocfg_hdr_detail: "3",
videocfg_fsr_detail: "0",
},
}