Skip to content

Commit 49fd1e1

Browse files
committed
Use hitman-commons
1 parent 010765c commit 49fd1e1

File tree

9 files changed

+302
-3065
lines changed

9 files changed

+302
-3065
lines changed

Cargo.lock

Lines changed: 132 additions & 2247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license = "LGPL-3.0-only"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
clap = { version = "4.2.4", features = ["derive"] }
10+
clap = { version = "4.2.4", features = ["derive"], optional = true }
1111
itertools = "0.10.3"
1212
md5 = "0.7.0"
1313
rayon = "1.8.0"
@@ -17,27 +17,27 @@ serde_json = { version = "1.0.81", features = [
1717
"preserve_order",
1818
] }
1919
serde_with = "2.0.1"
20-
egui = "0.19.0"
21-
egui_extras = { version = "0.19.0", features = ["image"] }
22-
image = { version = "0.24", features = ["png"] }
23-
eframe = "0.19.0"
24-
rfd = "0.10.0"
2520
similar = "2.2.1"
2621
anyhow = "1.0.70"
2722
tryvial = "0.2.0"
2823
fn-error-context = "0.2.1"
2924
auto_context = { path = "auto_context" }
3025
indexmap = { version = "2.1.0", features = ["serde", "rayon"] }
3126
serde_path_to_error = "0.1.14"
32-
env_logger = "0.10.1"
33-
tracing = "0.1.40"
27+
env_logger = { version = "0.10.1", optional = true }
3428
log = "0.4.20"
3529
specta = { version = "=2.0.0-rc.7", features = ["indexmap", "serde_json"] }
30+
hitman-commons = { git = "https://github.com/atampy25/hitman-commons", features = [
31+
"resourcelib",
32+
"serde",
33+
"specta",
34+
] }
3635

37-
[[bin]]
38-
name = "quickentity-rs"
39-
path = "src/main.rs"
36+
[features]
37+
default = ["cli"]
38+
cli = ["dep:env_logger", "dep:clap"]
4039

4140
[[bin]]
42-
name = "quickentity-gui"
43-
path = "src/gui.rs"
41+
name = "quickentity_rs"
42+
path = "src/main.rs"
43+
required-features = ["cli"]

src/gui.rs

Lines changed: 0 additions & 216 deletions
This file was deleted.

src/io_utils.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use hitman_commons::resourcelib::{EntityBlueprint, EntityBlueprintLegacy, EntityFactory, EntityFactoryLegacy};
2+
use hitman_commons::rpkg_tool::RpkgResourceMeta;
13
use quickentity_rs::patch_structs::Patch;
24
use quickentity_rs::qn_structs::Entity;
3-
use quickentity_rs::rpkg_structs::ResourceMeta;
4-
use quickentity_rs::rt_structs::{RTBlueprint, RTFactory};
5-
use quickentity_rs::{convert_2016_blueprint_to_modern, convert_2016_factory_to_modern};
65

76
use serde::Serialize;
87
use serde_json::ser::Formatter;
@@ -22,29 +21,37 @@ pub fn read_as_entity(path: &str) -> Entity {
2221
.expect("Failed to parse file")
2322
}
2423

25-
pub fn read_as_rtfactory(path: &str) -> RTFactory {
24+
pub fn read_as_rtfactory(path: &str) -> EntityFactory {
2625
let x = fs::read(path).expect("Failed to read file");
27-
let val: Value = serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x)).expect("Failed to parse file");
26+
let val: Value =
27+
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x)).expect("Failed to parse file");
2828

2929
if val.get("entityTemplates").is_some() {
30-
convert_2016_factory_to_modern(&from_value(val).expect("Failed to read file as RT struct"))
30+
from_value::<EntityFactoryLegacy>(val)
31+
.expect("Failed to read file as RT struct")
32+
.into_modern()
3133
} else {
32-
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x)).expect("Failed to read file as RT struct")
34+
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x))
35+
.expect("Failed to read file as RT struct")
3336
}
3437
}
3538

36-
pub fn read_as_rtblueprint(path: &str) -> RTBlueprint {
39+
pub fn read_as_rtblueprint(path: &str) -> EntityBlueprint {
3740
let x = fs::read(path).expect("Failed to read file");
38-
let val: Value = serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x)).expect("Failed to parse file");
41+
let val: Value =
42+
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x)).expect("Failed to parse file");
3943

4044
if val.get("entityTemplates").is_some() {
41-
convert_2016_blueprint_to_modern(&from_value(val).expect("Failed to read file as RT struct"))
45+
from_value::<EntityBlueprintLegacy>(val)
46+
.expect("Failed to read file as RT struct")
47+
.into_modern()
4248
} else {
43-
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x)).expect("Failed to read file as RT struct")
49+
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&x))
50+
.expect("Failed to read file as RT struct")
4451
}
4552
}
4653

47-
pub fn read_as_meta(path: &str) -> ResourceMeta {
54+
pub fn read_as_meta(path: &str) -> RpkgResourceMeta {
4855
serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&{
4956
let mut vec = Vec::new();
5057
fs::File::open(path)

0 commit comments

Comments
 (0)