1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-26 15:23:38 +00:00

add <GIT item boxes

This commit is contained in:
Alula 2020-09-10 14:34:42 +02:00
parent 124f793e4c
commit a94aef5e58
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA
3 changed files with 54 additions and 1 deletions

View file

@ -146,6 +146,11 @@ pub struct TextScriptConsts {
pub textbox_rect_bottom: Rect<usize>,
pub textbox_rect_yes_no: Rect<usize>,
pub textbox_rect_cursor: Rect<usize>,
pub get_item_top_left: Rect<usize>,
pub get_item_bottom_left: Rect<usize>,
pub get_item_top_right: Rect<usize>,
pub get_item_right: Rect<usize>,
pub get_item_bottom_right: Rect<usize>,
}
#[derive(Debug)]
@ -845,6 +850,11 @@ impl EngineConstants {
textbox_rect_bottom: Rect { left: 0, top: 16, right: 244, bottom: 24 },
textbox_rect_yes_no: Rect { left: 152, top: 48, right: 244, bottom: 80 },
textbox_rect_cursor: Rect { left: 112, top: 88, right: 128, bottom: 104 },
get_item_top_left: Rect { left: 0, top: 0, right: 72, bottom: 16 },
get_item_bottom_left: Rect { left: 0, top: 8, right: 72, bottom: 24 },
get_item_top_right: Rect { left: 240, top: 0, right: 244, bottom: 8 },
get_item_right: Rect { left: 240, top: 8, right: 244, bottom: 16 },
get_item_bottom_right: Rect { left: 240, top: 16, right: 244, bottom: 24 },
},
font_path: str!("builtin/builtin_font.fnt"),
font_scale: 1.0,

View file

@ -331,6 +331,21 @@ impl GameScene {
batch.add_rect(left_pos, top_pos + 56.0, &state.constants.textscript.textbox_rect_bottom);
}
if state.textscript_vm.item != 0 {
batch.add_rect((state.canvas_size.0 / 2.0 - 40.0).floor(), state.canvas_size.1 - 112.0,
&state.constants.textscript.get_item_top_left);
batch.add_rect((state.canvas_size.0 / 2.0 - 40.0).floor(), state.canvas_size.1 - 96.0,
&state.constants.textscript.get_item_bottom_left);
batch.add_rect((state.canvas_size.0 / 2.0 + 32.0).floor(), state.canvas_size.1 - 112.0,
&state.constants.textscript.get_item_top_right);
batch.add_rect((state.canvas_size.0 / 2.0 + 32.0).floor(), state.canvas_size.1 - 104.0,
&state.constants.textscript.get_item_right);
batch.add_rect((state.canvas_size.0 / 2.0 + 32.0).floor(), state.canvas_size.1 - 96.0,
&state.constants.textscript.get_item_right);
batch.add_rect((state.canvas_size.0 / 2.0 + 32.0).floor(), state.canvas_size.1 - 88.0,
&state.constants.textscript.get_item_bottom_right);
}
if let TextScriptExecutionState::WaitConfirmation(_, _, _, wait, selection) = state.textscript_vm.state {
let pos_y = if wait > 14 {
state.canvas_size.1 - 96.0 - (wait as f32 - 2.0) * 4.0
@ -365,6 +380,34 @@ impl GameScene {
batch.draw(ctx)?;
}
if state.textscript_vm.item != 0 {
let mut rect = Rect::<usize>::new(0, 0, 0, 0);
if state.textscript_vm.item < 1000 {
let item_id = state.textscript_vm.item as usize;
rect.left = (item_id % 16) * 16;
rect.right = rect.left + 16;
rect.top = (item_id / 16) * 16;
rect.bottom = rect.top + 16;
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, "ArmsImage")?;
batch.add_rect((state.canvas_size.0 / 2.0 - 12.0).floor(), state.canvas_size.1 - 104.0, &rect);
batch.draw(ctx)?;
} else {
let item_id = state.textscript_vm.item as usize - 1000;
rect.left = (item_id % 8) * 32;
rect.right = rect.left + 32;
rect.top = (item_id / 8) * 16;
rect.bottom = rect.top + 16;
let batch = state.texture_set.get_or_load_batch(ctx, &state.constants, "ItemImage")?;
batch.add_rect((state.canvas_size.0 / 2.0 - 20.0).floor(), state.canvas_size.1 - 104.0, &rect);
batch.draw(ctx)?;
}
}
let text_offset = if state.textscript_vm.face == 0 { 0.0 } else { 56.0 };
// todo: proper text rendering

View file

@ -29,7 +29,7 @@ impl Scene for LoadingScene {
state.npc_table = npc_table;
let head_script = TextScript::load_from(filesystem::open(ctx, [&state.base_path, "/Head.tsc"].join(""))?)?;
state.textscript_vm.set_global_script(head_script);
let mut next_scene = GameScene::new(state, ctx, 13)?;
next_scene.player.x = 10 * 16 * 0x200;
next_scene.player.y = 8 * 16 * 0x200;