-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmissing_methods.rs
More file actions
52 lines (47 loc) · 2.35 KB
/
missing_methods.rs
File metadata and controls
52 lines (47 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Missing method implementations that were referenced but not defined
pub fn save_theme_settings(&mut self) {
let theme_data = serde_json::json!({
"current_theme": self.current_theme,
"custom_colors": self.custom_theme_colors,
"brightness": self.brightness,
"contrast": self.contrast,
"font_size": self.font_size,
});
if let Ok(json) = serde_json::to_string_pretty(&theme_data) {
let config_dir = dirs::config_dir().unwrap_or_else(|| std::path::PathBuf::from("."));
let theme_file = config_dir.join("wgsl-shader-studio").join("theme.json");
if let Some(parent) = theme_file.parent() {
let _ = std::fs::create_dir_all(parent);
}
match std::fs::write(&theme_file, json) {
Ok(_) => println!("✓ Theme settings saved"),
Err(e) => eprintln!("✗ Failed to save theme settings: {}", e),
}
}
}
pub fn load_theme_settings(&mut self) {
let config_dir = dirs::config_dir().unwrap_or_else(|| std::path::PathBuf::from("."));
let theme_file = config_dir.join("wgsl-shader-studio").join("theme.json");
if theme_file.exists() {
match std::fs::read_to_string(&theme_file) {
Ok(json) => {
if let Ok(theme_data) = serde_json::from_str::<serde_json::Value>(&json) {
if let Some(theme) = theme_data["current_theme"].as_str() {
self.current_theme = theme.to_string();
}
if let Some(brightness) = theme_data["brightness"].as_f64() {
self.brightness = brightness as f32;
}
if let Some(contrast) = theme_data["contrast"].as_f64() {
self.contrast = contrast as f32;
}
if let Some(font_size) = theme_data["font_size"].as_f64() {
self.font_size = font_size as f32;
}
println!("✓ Theme settings loaded");
}
}
Err(e) => eprintln!("✗ Failed to load theme settings: {}", e),
}
}
}