tangled
alpha
login
or
join now
j0.lol
/
vee
0
fork
atom
Mii rendering and parsing library
0
fork
atom
overview
issues
pulls
pipelines
add vfl-cli
j0.lol
10 months ago
43b035d9
68296dc5
+77
-13
1 changed file
expand all
collapse all
unified
split
crates
vfl-cli
src
main.rs
+77
-13
crates/vfl-cli/src/main.rs
reviewed
···
3
3
use std::io::BufReader;
4
4
use std::path::PathBuf;
5
5
use vfl::charinfo::nx::BinRead;
6
6
+
use vfl::res::tex::nx::{ResourceTexture, TextureElement};
6
7
7
8
// TODO: use real names
8
9
// https://github.com/ariankordi/ffl/blob/97eecdf3688f92c4c95cecf5d6ab3e84c0ee42c0/tools/FFLResource.py#L448
···
41
42
index: usize,
42
43
output: PathBuf,
43
44
},
45
45
+
46
46
+
/// Show existant textures
47
47
+
TextureExists {
48
48
+
#[arg(short, long)]
49
49
+
resource_file: PathBuf,
50
50
+
#[arg(value_enum, short, long)]
51
51
+
texture_type: TextureType,
52
52
+
},
44
53
}
45
54
46
55
// This is kind of `clap`-slop. I just need a quick debug tool.
···
62
71
let res_file = std::fs::read(resource_file).unwrap();
63
72
64
73
// *YandereDev Voice* If only there was a better way...
65
65
-
let texture_element = match texture_type {
66
66
-
TextureType::Hat => res_tex.hat[index],
67
67
-
TextureType::Eye => res_tex.eye[index],
68
68
-
TextureType::Eyebrow => res_tex.eyebrow[index],
69
69
-
TextureType::Beard => res_tex.beard[index],
70
70
-
TextureType::Wrinkle => res_tex.wrinkle[index],
71
71
-
TextureType::Makeup => res_tex.makeup[index],
72
72
-
TextureType::Glass => res_tex.glass[index],
73
73
-
TextureType::Mole => res_tex.mole[index],
74
74
-
TextureType::Mouth => res_tex.mouth[index],
75
75
-
TextureType::Mustache => res_tex.mustache[index],
76
76
-
TextureType::NoseLine => res_tex.noseline[index],
77
77
-
};
74
74
+
let texture_element = lookup_texture_type(texture_type, index, res_tex).unwrap();
78
75
let el = texture_element.get_image(&res_file).unwrap().unwrap();
79
76
el.save(output).unwrap();
80
77
}
78
78
+
Subcommands::TextureExists {
79
79
+
resource_file,
80
80
+
texture_type,
81
81
+
} => {
82
82
+
let res_tex = ResourceTexture::read(&mut BufReader::new(
83
83
+
File::open(resource_file.clone()).unwrap(),
84
84
+
))
85
85
+
.unwrap();
86
86
+
let res_file = std::fs::read(resource_file).unwrap();
87
87
+
88
88
+
let mut exists = vec![];
89
89
+
for index in 0..match texture_type {
90
90
+
TextureType::Hat => res_tex.hat.len(),
91
91
+
TextureType::Eye => res_tex.eye.len(),
92
92
+
TextureType::Eyebrow => res_tex.eyebrow.len(),
93
93
+
TextureType::Beard => res_tex.beard.len(),
94
94
+
TextureType::Wrinkle => res_tex.wrinkle.len(),
95
95
+
TextureType::Makeup => res_tex.makeup.len(),
96
96
+
TextureType::Glass => res_tex.glass.len(),
97
97
+
TextureType::Mole => res_tex.mole.len(),
98
98
+
TextureType::Mouth => res_tex.mouth.len(),
99
99
+
TextureType::Mustache => res_tex.mustache.len(),
100
100
+
TextureType::NoseLine => res_tex.noseline.len(),
101
101
+
} {
102
102
+
let texture_element = lookup_texture_type(texture_type, index, res_tex).unwrap();
103
103
+
if (texture_element.texture.width == 0 && texture_element.texture.height == 0)
104
104
+
|| (texture_element.texture.width == 8 && texture_element.texture.height == 8)
105
105
+
{
106
106
+
exists.push(false);
107
107
+
continue;
108
108
+
}
109
109
+
let texture = texture_element.get_image(&res_file).unwrap();
110
110
+
111
111
+
let valid = texture.is_some();
112
112
+
113
113
+
exists.push(valid);
114
114
+
}
115
115
+
116
116
+
println!(
117
117
+
"{:#?}",
118
118
+
exists
119
119
+
.iter()
120
120
+
.enumerate()
121
121
+
.filter_map(|(num, bool)| if *bool { Some(num) } else { None })
122
122
+
.collect::<Vec<_>>()
123
123
+
)
124
124
+
}
125
125
+
}
126
126
+
}
127
127
+
128
128
+
fn lookup_texture_type(
129
129
+
texture_type: TextureType,
130
130
+
index: usize,
131
131
+
res_tex: ResourceTexture,
132
132
+
) -> Option<TextureElement> {
133
133
+
match texture_type {
134
134
+
TextureType::Hat => res_tex.hat.get(index).copied(),
135
135
+
TextureType::Eye => res_tex.eye.get(index).copied(),
136
136
+
TextureType::Eyebrow => res_tex.eyebrow.get(index).copied(),
137
137
+
TextureType::Beard => res_tex.beard.get(index).copied(),
138
138
+
TextureType::Wrinkle => res_tex.wrinkle.get(index).copied(),
139
139
+
TextureType::Makeup => res_tex.makeup.get(index).copied(),
140
140
+
TextureType::Glass => res_tex.glass.get(index).copied(),
141
141
+
TextureType::Mole => res_tex.mole.get(index).copied(),
142
142
+
TextureType::Mouth => res_tex.mouth.get(index).copied(),
143
143
+
TextureType::Mustache => res_tex.mustache.get(index).copied(),
144
144
+
TextureType::NoseLine => res_tex.noseline.get(index).copied(),
81
145
}
82
146
}