mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-22 13:42:47 +00:00
render = as white circle (closes #110)
This commit is contained in:
parent
6f95e6109c
commit
0415f917f8
|
@ -267,7 +267,11 @@ impl BMFontRenderer {
|
|||
for chr in iter {
|
||||
if let Some(glyph) = self.font.chars.get(&chr) {
|
||||
if let Some(rect) = rect_map.get(&chr) {
|
||||
sprite_rects.push((offset_x, self.line_height(constants) - rect.height() as f32 / 2.0, rect));
|
||||
sprite_rects.push((
|
||||
offset_x,
|
||||
y + self.line_height(constants) / 2.0 - rect.height() as f32 / 2.0,
|
||||
rect,
|
||||
));
|
||||
offset_x += rect.width() as f32;
|
||||
} else {
|
||||
batch.add_rect_scaled_tinted(
|
||||
|
@ -308,7 +312,11 @@ impl BMFontRenderer {
|
|||
|
||||
for (chr, glyph) in chars.iter() {
|
||||
if let Some(rect) = rect_map.get(&chr) {
|
||||
sprite_rects.push((offset_x, self.line_height(constants) - rect.height() as f32 / 2.0, rect));
|
||||
sprite_rects.push((
|
||||
offset_x,
|
||||
y + self.line_height(constants) / 2.0 - rect.height() as f32 / 2.0,
|
||||
rect,
|
||||
));
|
||||
offset_x += rect.width() as f32;
|
||||
} else {
|
||||
if glyph.page == page {
|
||||
|
|
|
@ -225,21 +225,25 @@ impl GameEntity<()> for TextBoxes {
|
|||
for (idx, line) in lines.iter().enumerate() {
|
||||
if !line.is_empty() {
|
||||
if state.constants.textscript.text_shadow {
|
||||
state.font.draw_text_with_shadow(
|
||||
state.font.draw_text_with_shadow_and_rects(
|
||||
line.iter().copied(),
|
||||
left_pos + text_offset + 14.0,
|
||||
top_pos + 10.0 + idx as f32 * 16.0 - y_offset,
|
||||
&state.constants,
|
||||
&mut state.texture_set,
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
Some("TextBox".into()),
|
||||
ctx,
|
||||
)?;
|
||||
} else {
|
||||
state.font.draw_text(
|
||||
state.font.draw_text_with_rects(
|
||||
line.iter().copied(),
|
||||
left_pos + text_offset + 14.0,
|
||||
top_pos + 10.0 + idx as f32 * 16.0 - y_offset,
|
||||
&state.constants,
|
||||
&mut state.texture_set,
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
Some("TextBox".into()),
|
||||
ctx,
|
||||
)?;
|
||||
}
|
||||
|
@ -251,15 +255,27 @@ impl GameEntity<()> for TextBoxes {
|
|||
if tick > 10 {
|
||||
let (mut x, y) = match state.textscript_vm.current_line {
|
||||
TextScriptLine::Line1 => (
|
||||
state.font.text_width(state.textscript_vm.line_1.iter().copied(), &state.constants),
|
||||
state.font.text_width_with_rects(
|
||||
state.textscript_vm.line_1.iter().copied(),
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
&state.constants,
|
||||
),
|
||||
top_pos + 10.0,
|
||||
),
|
||||
TextScriptLine::Line2 => (
|
||||
state.font.text_width(state.textscript_vm.line_2.iter().copied(), &state.constants),
|
||||
state.font.text_width_with_rects(
|
||||
state.textscript_vm.line_2.iter().copied(),
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
&state.constants,
|
||||
),
|
||||
top_pos + 10.0 + 16.0,
|
||||
),
|
||||
TextScriptLine::Line3 => (
|
||||
state.font.text_width(state.textscript_vm.line_3.iter().copied(), &state.constants),
|
||||
state.font.text_width_with_rects(
|
||||
state.textscript_vm.line_3.iter().copied(),
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
&state.constants,
|
||||
),
|
||||
top_pos + 10.0 + 32.0,
|
||||
),
|
||||
};
|
||||
|
|
|
@ -222,6 +222,7 @@ pub struct TextScriptConsts {
|
|||
pub textbox_rect_bottom: Rect<u16>,
|
||||
pub textbox_rect_yes_no: Rect<u16>,
|
||||
pub textbox_rect_cursor: Rect<u16>,
|
||||
pub textbox_item_marker_rect: Rect<u16>,
|
||||
pub inventory_rect_top: Rect<u16>,
|
||||
pub inventory_rect_middle: Rect<u16>,
|
||||
pub inventory_rect_bottom: Rect<u16>,
|
||||
|
@ -1486,6 +1487,7 @@ 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 },
|
||||
textbox_item_marker_rect: Rect { left: 64, top: 48, right: 70, bottom: 54 },
|
||||
inventory_rect_top: Rect { left: 0, top: 0, right: 244, bottom: 8 },
|
||||
inventory_rect_middle: Rect { left: 0, top: 8, right: 244, bottom: 16 },
|
||||
inventory_rect_bottom: Rect { left: 0, top: 16, right: 244, bottom: 24 },
|
||||
|
|
|
@ -133,6 +133,7 @@ pub struct TextScriptVM {
|
|||
pub current_illustration: Option<String>,
|
||||
pub illustration_state: IllustrationState,
|
||||
prev_char: char,
|
||||
pub substitution_rect_map: HashMap<char, Rect<u16>>,
|
||||
}
|
||||
|
||||
pub struct Scripts {
|
||||
|
@ -199,6 +200,7 @@ impl TextScriptVM {
|
|||
current_illustration: None,
|
||||
illustration_state: IllustrationState::Hidden,
|
||||
prev_char: '\x00',
|
||||
substitution_rect_map: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,6 +236,10 @@ impl TextScriptVM {
|
|||
scripts.stage_select_script = script;
|
||||
}
|
||||
|
||||
pub fn set_substitution_rect_map(&mut self, rect_map: HashMap<char, Rect<u16>>) {
|
||||
self.substitution_rect_map = rect_map;
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
self.state = TextScriptExecutionState::Ended;
|
||||
self.flags.0 = 0;
|
||||
|
@ -347,8 +353,11 @@ impl TextScriptVM {
|
|||
state.textscript_vm.prev_char = chr;
|
||||
state.textscript_vm.line_1.push(chr);
|
||||
|
||||
let text_len =
|
||||
state.font.text_width(state.textscript_vm.line_1.iter().copied(), &state.constants);
|
||||
let text_len = state.font.text_width_with_rects(
|
||||
state.textscript_vm.line_1.iter().copied(),
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
&state.constants,
|
||||
);
|
||||
if text_len >= 284.0 {
|
||||
state.textscript_vm.current_line = TextScriptLine::Line2;
|
||||
}
|
||||
|
@ -357,8 +366,11 @@ impl TextScriptVM {
|
|||
state.textscript_vm.prev_char = chr;
|
||||
state.textscript_vm.line_2.push(chr);
|
||||
|
||||
let text_len =
|
||||
state.font.text_width(state.textscript_vm.line_2.iter().copied(), &state.constants);
|
||||
let text_len = state.font.text_width_with_rects(
|
||||
state.textscript_vm.line_2.iter().copied(),
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
&state.constants,
|
||||
);
|
||||
if text_len >= 284.0 {
|
||||
state.textscript_vm.current_line = TextScriptLine::Line3;
|
||||
}
|
||||
|
@ -367,8 +379,11 @@ impl TextScriptVM {
|
|||
state.textscript_vm.prev_char = chr;
|
||||
state.textscript_vm.line_3.push(chr);
|
||||
|
||||
let text_len =
|
||||
state.font.text_width(state.textscript_vm.line_3.iter().copied(), &state.constants);
|
||||
let text_len = state.font.text_width_with_rects(
|
||||
state.textscript_vm.line_3.iter().copied(),
|
||||
&state.textscript_vm.substitution_rect_map,
|
||||
&state.constants,
|
||||
);
|
||||
if text_len >= 284.0 {
|
||||
new_line = true;
|
||||
}
|
||||
|
|
|
@ -522,6 +522,9 @@ impl SharedGameState {
|
|||
let stage_select_script = TextScript::load_from(stage_select_tsc, &self.constants)?;
|
||||
self.textscript_vm.set_stage_select_script(stage_select_script);
|
||||
|
||||
let substitution_rect_map = HashMap::from([('=', self.constants.textscript.textbox_item_marker_rect)]);
|
||||
self.textscript_vm.set_substitution_rect_map(substitution_rect_map);
|
||||
|
||||
let credit_tsc = filesystem::open_find(ctx, &self.constants.base_paths, "Credit.tsc")?;
|
||||
let credit_script = CreditScript::load_from(credit_tsc, &self.constants)?;
|
||||
self.creditscript_vm.set_script(credit_script);
|
||||
|
|
Loading…
Reference in a new issue