mirror of
https://github.com/Theaninova/mhlib.git
synced 2026-01-20 17:03:37 +00:00
ui
This commit is contained in:
@@ -5,6 +5,8 @@ use crate::formats::sprites::Sprites;
|
||||
use crate::formats::txt::{decrypt_txt, DecryptError};
|
||||
use crate::formats::ui_xml::UiTag;
|
||||
use binrw::BinRead;
|
||||
use itertools::Itertools;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt::Debug;
|
||||
use std::io::{Cursor, Read, Seek, SeekFrom};
|
||||
@@ -26,6 +28,7 @@ pub enum DatafileFile {
|
||||
Vorbis(Vec<u8>),
|
||||
TileCollision(String),
|
||||
Ui(UiTag),
|
||||
Translations(HashMap<String, Vec<String>>),
|
||||
}
|
||||
|
||||
pub enum Error {
|
||||
@@ -90,26 +93,20 @@ where
|
||||
Ok(DatafileFile::Txt(decr))
|
||||
}
|
||||
}
|
||||
/*Some("rle") => {
|
||||
let image: RleImage = RleImage::read(&mut Cursor::new(data)).unwrap();
|
||||
let path = Path::new(dat_path).with_file_name("res.gif");
|
||||
println!("{:?}", path);
|
||||
let mut encoder = GifEncoder::new(
|
||||
OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.open(path)
|
||||
.unwrap(),
|
||||
);
|
||||
encoder.set_repeat(Repeat::Infinite).unwrap();
|
||||
encoder.try_encode_frames(image.into_frames()).unwrap();
|
||||
}
|
||||
Some("dat") => {
|
||||
let image = level_tile_data_to_image(&data).unwrap();
|
||||
let path = Path::new(dat_path).with_file_name("res.png");
|
||||
println!("{:?}", path);
|
||||
image.save_with_format(path, ImageFormat::Png).unwrap();
|
||||
}*/
|
||||
"csv" => Ok(DatafileFile::Translations(
|
||||
String::from_utf8(data)
|
||||
.unwrap()
|
||||
.split('\n')
|
||||
.map(|l| l.trim())
|
||||
.filter(|l| !l.is_empty())
|
||||
.map(|l| {
|
||||
l.splitn(2, ';')
|
||||
.map(|s| s.to_string())
|
||||
.collect_tuple::<(String, String)>()
|
||||
.expect("Invalid csv")
|
||||
})
|
||||
.into_group_map(),
|
||||
)),
|
||||
ext => Err(Error::UnknownFormat(ext.to_string())),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ pub struct UiMenu {
|
||||
pub selected: String,
|
||||
#[serde(rename = "OnBack")]
|
||||
pub on_back: Option<String>,
|
||||
#[serde(rename = "$value")]
|
||||
#[serde(rename = "$value", default)]
|
||||
pub children: Vec<UiTag>,
|
||||
}
|
||||
|
||||
@@ -45,13 +45,14 @@ pub struct UiTextButton {
|
||||
pub on_select: String,
|
||||
}
|
||||
|
||||
/// This sometimes appears completely empty
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct UiTextArea {
|
||||
#[serde(deserialize_with = "deserialize_vec2")]
|
||||
#[serde(deserialize_with = "deserialize_vec2", default)]
|
||||
pub position: [i32; 2],
|
||||
#[serde(deserialize_with = "deserialize_vec2")]
|
||||
#[serde(deserialize_with = "deserialize_vec2", default)]
|
||||
pub size: [i32; 2],
|
||||
#[serde(rename = "$value")]
|
||||
#[serde(rename = "$value", default)]
|
||||
pub children: Vec<UiTag>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user