1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-21 12:17:45 +00:00
physis/src/common.rs
Joshua Goins d17f860f07 Allow naive repairing of version files
Currently, we not handle repairing version files well, so I
sought to seek a solution to the problem. This is one of part of the
puzzle, by implementing a simple "game repair". This is not
IndexedZiPatch support, but simply checking if we can restore version
files if possible, or otherwise wipe the directory.
2022-10-25 11:03:05 -04:00

52 lines
1.3 KiB
Rust
Executable file

use std::fs;
use std::path::Path;
use binrw::binrw;
#[binrw]
#[brw(repr(u8))]
#[repr(u8)]
/// The language the game data is written for.
pub enum Language {
/// Used for data that is language-agnostic, such as item data.
None,
/// Japanese language.
Japanese,
/// English language.
English,
/// German language.
German,
/// French language.
French,
/// Chinese (Simplified) language.
ChineseSimplified,
/// Chinese (Traditional) language.
ChineseTraditional,
/// Korean language.
Korean,
}
/// Returns the shorthand language code for `language`. For example, English becomes "en".
pub fn get_language_code(lang: &Language) -> &'static str {
match &lang {
Language::None => "",
Language::Japanese => "ja",
Language::English => "en",
Language::German => "de",
Language::French => "fr",
Language::ChineseSimplified => "chs",
Language::ChineseTraditional => "cht",
Language::Korean => "ko",
}
}
#[binrw]
#[brw(repr = i16)]
#[derive(Debug, PartialEq, Eq)]
pub enum Region {
Global = -1, // TODO: find patch codes for other regions :-)
}
/// Reads a version file.
pub fn read_version(p: &Path) -> Option<String> {
fs::read_to_string(p).ok()
}