mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-30 01:02:51 +00:00
add <GIT item boxes
This commit is contained in:
parent
124f793e4c
commit
a94aef5e58
|
@ -146,6 +146,11 @@ pub struct TextScriptConsts {
|
||||||
pub textbox_rect_bottom: Rect<usize>,
|
pub textbox_rect_bottom: Rect<usize>,
|
||||||
pub textbox_rect_yes_no: Rect<usize>,
|
pub textbox_rect_yes_no: Rect<usize>,
|
||||||
pub textbox_rect_cursor: 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)]
|
#[derive(Debug)]
|
||||||
|
@ -845,6 +850,11 @@ impl EngineConstants {
|
||||||
textbox_rect_bottom: Rect { left: 0, top: 16, right: 244, bottom: 24 },
|
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_yes_no: Rect { left: 152, top: 48, right: 244, bottom: 80 },
|
||||||
textbox_rect_cursor: Rect { left: 112, top: 88, right: 128, bottom: 104 },
|
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_path: str!("builtin/builtin_font.fnt"),
|
||||||
font_scale: 1.0,
|
font_scale: 1.0,
|
||||||
|
|
|
@ -331,6 +331,21 @@ impl GameScene {
|
||||||
batch.add_rect(left_pos, top_pos + 56.0, &state.constants.textscript.textbox_rect_bottom);
|
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 {
|
if let TextScriptExecutionState::WaitConfirmation(_, _, _, wait, selection) = state.textscript_vm.state {
|
||||||
let pos_y = if wait > 14 {
|
let pos_y = if wait > 14 {
|
||||||
state.canvas_size.1 - 96.0 - (wait as f32 - 2.0) * 4.0
|
state.canvas_size.1 - 96.0 - (wait as f32 - 2.0) * 4.0
|
||||||
|
@ -365,6 +380,34 @@ impl GameScene {
|
||||||
batch.draw(ctx)?;
|
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 };
|
let text_offset = if state.textscript_vm.face == 0 { 0.0 } else { 56.0 };
|
||||||
|
|
||||||
// todo: proper text rendering
|
// todo: proper text rendering
|
||||||
|
|
Loading…
Reference in a new issue