reuploading levels

This commit is contained in:
Reid 2023-09-20 18:46:37 -07:00
parent fd88a4e374
commit 4d8a41ba47
Signed by: reidlab
GPG key ID: 6C9EAA3364F962C8
20 changed files with 604 additions and 22 deletions

View file

@ -5,6 +5,8 @@ use base64::{Engine as _, engine::general_purpose};
use flate2::read::GzDecoder;
use roxmltree::Document;
use std::collections::HashMap;
pub static DEFAULT_EXTRA_STRING: LazyLock<String> = LazyLock::new(|| {
@ -13,6 +15,12 @@ pub static DEFAULT_EXTRA_STRING: LazyLock<String> = LazyLock::new(|| {
return string;
});
pub static DEFAULT_LEVEL_INFO: LazyLock<String> = LazyLock::new(|| {
let string = String::from("");
return string;
});
macro_rules! object_prop_bool {
($key:expr, $name:ident) => {
pub fn $name(&self) -> bool {
@ -167,6 +175,21 @@ pub fn parse(raw_level_data: &str) -> Vec<HashMap<String, String>> {
.collect()
}
pub fn gmd_parse(gmd_file: &str) -> HashMap<String, String> {
let doc = Document::parse(gmd_file).expect("failed to parse gmd file");
let root = doc.root_element();
let mut result = Vec::new();
for child in root.children().filter(|node| node.node_type() != roxmltree::NodeType::Text) {
if let Some(child_text) = child.children().next() {
result.push(child_text.text().unwrap_or("").to_string());
}
}
return array_to_hash(result);
}
pub fn decode(level_data: String) -> Vec<HashMap<String, String>> {
let decoded_bytes = general_purpose::URL_SAFE.decode(level_data).expect("couldnt decode b64");