-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a3b4c6
commit 3ed2fdd
Showing
7 changed files
with
63 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
target/ | ||
.idea | ||
.idea | ||
exporter/data.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Invoke-Expression -Command "cargo build --release" | ||
|
||
if (Test-Path -Path ".\exporter.exe") { | ||
Remove-Item -Path ".\exporter.exe" | ||
} | ||
|
||
if (Test-Path -Path ".\target\release\exporter.exe") { | ||
Move-Item -Path ".\target\release\exporter.exe" -Destination ".\" | ||
} |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,33 @@ | ||
use std::fs::{DirEntry, File}; | ||
use std::io::{BufReader}; | ||
use serde_derive::Deserialize; | ||
use xml::EventReader; | ||
use xml::reader::XmlEvent; | ||
use crate::{Model, MODEL_DATA}; | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[allow(non_snake_case, non_camel_case_types)] | ||
struct CVehicleModelInfo__InitDataList { | ||
InitDatas: InitDatas | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[allow(non_snake_case, non_camel_case_types)] | ||
struct InitDatas { | ||
Item: Vec<Item> | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[allow(non_snake_case, non_camel_case_types)] | ||
struct Item { | ||
modelName: String, | ||
gameName: String | ||
} | ||
|
||
pub(crate) fn handle_vehicles(dir: &DirEntry) { | ||
let file = File::open(dir.path()).unwrap(); | ||
let file_buf = BufReader::new(file); | ||
let file = BufReader::new(file); | ||
let parser = EventReader::new(file); | ||
|
||
let parser = EventReader::new(file_buf); | ||
|
||
let mut data: String = String::new(); | ||
let mut model_name = String::new(); | ||
let mut game_name = String::new(); | ||
let mut data = String::new(); | ||
let mut model = Model::new(); | ||
for e in parser { | ||
match e { | ||
Ok(XmlEvent::StartElement { name, .. }) => { | ||
data = name.to_string(); | ||
} | ||
Ok(XmlEvent::StartElement { name, .. }) => { data = name.to_string() } | ||
Ok(XmlEvent::Characters(chars)) => { | ||
if data == "modelName" { | ||
data = String::new(); | ||
model_name = chars; | ||
} else if data == "gameName" { | ||
game_name = chars; | ||
match data.as_str() { | ||
"modelName" => { model.model_name = Some(chars) } | ||
"gameName" => { model.game_name = Some(chars) } | ||
_ => {} | ||
} | ||
data.clear(); | ||
} | ||
Err(e) => { | ||
println!("Error: {} {}", dir.path().display(), e); | ||
} | ||
Err(e) => { println!("Error: {} {}", dir.path().display(), e) } | ||
_ => {} | ||
} | ||
let str_new = String::new(); | ||
if model_name != str_new && game_name != str_new { | ||
MODEL_DATA.lock().unwrap().push(Model{ | ||
model_name: model_name.clone(), | ||
game_name: game_name.clone() | ||
}); | ||
model_name.clear(); | ||
game_name.clear(); | ||
if model.model_name.is_some() && model.game_name.is_some() { | ||
MODEL_DATA.lock().unwrap().push(model.clone()); | ||
model.clear(); | ||
} | ||
} | ||
|
||
} | ||
} |