Add some tsc settings to the Lua API[ci skip]
This commit is contained in:
parent
b3007c10e3
commit
f07228895c
|
@ -56,7 +56,12 @@ __doukutsu_rs_runtime_dont_touch._known_settings = {
|
|||
["doukutsu-rs.new_game.event_id"] = 0x1003,
|
||||
["doukutsu-rs.new_game.stage_id"] = 0x1004,
|
||||
["doukutsu-rs.new_game.pos"] = 0x1005,
|
||||
["doukutsu-rs.window.height"] = 0x1100,
|
||||
["doukutsu-rs.window.width"] = 0x1101,
|
||||
["doukutsu-rs.window.title"] = 0x1102,
|
||||
["doukutsu-rs.font_scale"] = 0x2000,
|
||||
["doukutsu-rs.tsc.encoding"] = 0x3000,
|
||||
["doukutsu-rs.tsc.encrypted"] = 0x3001,
|
||||
}
|
||||
|
||||
__doukutsu_rs_runtime_dont_touch._requires = {}
|
||||
|
|
|
@ -8,6 +8,7 @@ use lua_ffi::lua_method;
|
|||
use crate::common::{Direction, Rect};
|
||||
use crate::framework::filesystem;
|
||||
use crate::game::scripting::lua::{check_status, DRS_RUNTIME_GLOBAL, LuaScriptingState};
|
||||
use crate::game::scripting::tsc::text_script::TextScriptEncoding;
|
||||
use crate::scene::game_scene::LightingMode;
|
||||
use crate::util::rng::RNG;
|
||||
|
||||
|
@ -156,6 +157,18 @@ impl Doukutsu {
|
|||
game_state.constants.game.new_game_player_pos = (ng_x as i16, ng_y as i16);
|
||||
}
|
||||
}
|
||||
0x1100 => {
|
||||
// window height
|
||||
//TODO
|
||||
}
|
||||
0x1101 => {
|
||||
// window width
|
||||
//TODO
|
||||
}
|
||||
0x1102 => {
|
||||
// window title
|
||||
//TODO
|
||||
}
|
||||
0x2000 => {
|
||||
// font scale
|
||||
if let Some(font_scale) = state.to_float(3) {
|
||||
|
@ -164,6 +177,25 @@ impl Doukutsu {
|
|||
}
|
||||
}
|
||||
}
|
||||
0x3000 => {
|
||||
// tsc encoding
|
||||
if let Some(encoding) = state.to_str(3) {
|
||||
let enc = TextScriptEncoding::from(encoding.clone());
|
||||
|
||||
if TextScriptEncoding::invalid_encoding(enc, &game_state) {
|
||||
log::warn!("{} encoding is invalid", encoding.clone());
|
||||
} else {
|
||||
game_state.constants.textscript.encoding = enc;
|
||||
log::debug!("{} encoding is set", encoding.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
0x3001 => {
|
||||
// tsc encrypted
|
||||
if let Some(encrypted) = state.to_bool(3) {
|
||||
game_state.constants.textscript.encrypted = encrypted;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,27 @@ pub enum TextScriptEncoding {
|
|||
ShiftJIS,
|
||||
}
|
||||
|
||||
impl From<&str> for TextScriptEncoding {
|
||||
fn from(s: &str) -> Self {
|
||||
match s {
|
||||
"utf-8" => Self::UTF8,
|
||||
_ => Self::ShiftJIS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TextScriptEncoding {
|
||||
pub fn invalid_encoding(encoding: TextScriptEncoding, state: &SharedGameState) -> bool {
|
||||
let required_encoding = if (state.loc.code == "jp" || state.loc.code == "en") && state.constants.is_base() {
|
||||
TextScriptEncoding::ShiftJIS
|
||||
} else {
|
||||
TextScriptEncoding::UTF8
|
||||
};
|
||||
|
||||
encoding != required_encoding
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
#[repr(u8)]
|
||||
pub enum TextScriptLine {
|
||||
|
|
Loading…
Reference in New Issue