Crates.io | aoe2-probe |
lib.rs | aoe2-probe |
version | 0.3.2 |
source | src |
created_at | 2022-07-27 12:20:18.146972 |
updated_at | 2024-05-31 08:28:44.780037 |
description | A rust library for editing aoe2scenario files from AoE2 DE. |
homepage | https://github.com/ptazithos/aoe2-probe |
repository | https://github.com/ptazithos/aoe2-probe |
max_upload_size | |
id | 633879 |
size | 183,257 |
This is a rust library for editing aoe2scenario files from AoE2 DE.
Under the directory ./examples/, you can find several simple showcases.
Import and export files:
use aoe2_probe::scenario::{Scenario, ExportFormat};
//Reading scenario content from the .aoe2scenario file
let scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario").unwrap();
//saving content to a new .aoe2scenario file
scenario.to_file("./resources/temp.aoe2scenario", ExportFormat::AoE2Scenario);
//saving content to a new .json file
scenario.to_file("./resources/temp.json", ExportFormat::JSON);
Update attributes:
use aoe2_probe::scenario::Scenario;
//versio's structure definition can be found in the folder /src/prebuilt/ver1_46/versio.rs
let mut scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario").unwrap();
let author = scenario.versio.get_by_path_mut("/file_header/creator_name");
//Update the creator name.
author.try_mut_str32().set_content("Arian");
Customize a structure:
//Define a score record
let mut root = PatchedMap::new();
root.push_back("score", Token::Int16(100));
root.push_back("name", Token::Str32(DynString::with_capacity(12, "anonymous")));
//serialize
root.to_le_vec();
//deserialize
root.from_le_vec();
Serialize/Deserialize to any formats that serde support:
let scenario = Scenario::from_file("./resources/chapter_3.aoe2scenario").unwrap();
let json = serde_json::to_string( & scenario.versio).unwrap();
println!("{}", json);
Run examples with the following command:
cargo run --example read_write
Every member of versio and itself implements fmt::Debug trait. Print them if you want to know more.
let scenario = Scenario::from_file("./resources/chapter_1.aoe2scenario").unwrap();
println!("{:?}", &scenario.versio())
Advanced examples can be found in misc-probe. Detailed information can be found in Docs.
Game version | Supported status |
---|---|
ver.1.46 | Supported |
ver.1.47 | Supported |
ver.1.48 | Supported |
ver.1.49 | Supported |
ver.1.51 | Experimental |
ver.1.53 | Experimental |
Currently, only version 1.46 and newer will be firstly supported.
This library is inspired by AoE2ScenarioParser and Trigger Craft