mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-01-27 04:46:55 +00:00
Added Android cutscene skip
This commit is contained in:
parent
af39130fed
commit
02a9cac305
|
@ -79,54 +79,73 @@ impl TouchControls {
|
|||
texture_set: &mut TextureSet,
|
||||
ctx: &mut Context,
|
||||
) -> GameResult {
|
||||
if self.control_type == TouchControlType::Controls {
|
||||
let batch = texture_set.get_or_load_batch(ctx, constants, "builtin/touch")?;
|
||||
let color = (255, 255, 255, 160);
|
||||
let batch = texture_set.get_or_load_batch(ctx, constants, "builtin/touch")?;
|
||||
let color = (255, 255, 255, 160);
|
||||
|
||||
let (left, top, right, bottom) = screen_insets_scaled(ctx, scale);
|
||||
let (left, top, right, bottom) = screen_insets_scaled(ctx, scale);
|
||||
|
||||
for x in 0..3 {
|
||||
for y in 0..3 {
|
||||
let mut icon_x = x;
|
||||
let icon_y = y;
|
||||
match self.control_type {
|
||||
TouchControlType::None => {}
|
||||
TouchControlType::Dialog => {
|
||||
// Fast-Forward
|
||||
batch.add_rect_tinted(
|
||||
canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
|
||||
4.0 + 8.0 + top,
|
||||
color,
|
||||
&Rect::new_size(2 * 32, 3 * 32, 32, 32),
|
||||
);
|
||||
|
||||
if self.interact_icon && x == 1 && y == 2 {
|
||||
icon_x = 3;
|
||||
}
|
||||
|
||||
batch.add_rect_tinted(
|
||||
4.0 + 48.0 * x as f32 + 8.0 + left,
|
||||
(canvas_size.1 - 4.0 - 48.0 * 3.0) + 48.0 * y as f32 + 8.0 - bottom,
|
||||
color,
|
||||
&Rect::new_size(icon_x * 32, icon_y * 32, 32, 32),
|
||||
);
|
||||
}
|
||||
batch.draw(ctx)?;
|
||||
}
|
||||
TouchControlType::Controls => {
|
||||
// Movement
|
||||
for x in 0..3 {
|
||||
for y in 0..3 {
|
||||
let mut icon_x = x;
|
||||
let icon_y = y;
|
||||
|
||||
batch.add_rect_tinted(
|
||||
canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
|
||||
canvas_size.1 - (4.0 + 48.0) + 8.0 - bottom,
|
||||
color,
|
||||
&Rect::new_size(3 * 32, 32, 32, 32),
|
||||
);
|
||||
if self.interact_icon && x == 1 && y == 2 {
|
||||
icon_x = 3;
|
||||
}
|
||||
|
||||
batch.add_rect_tinted(
|
||||
canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
|
||||
canvas_size.1 - (4.0 + 48.0) * 2.0 + 8.0 - bottom,
|
||||
color,
|
||||
&Rect::new_size(3 * 32, 0, 32, 32),
|
||||
);
|
||||
batch.add_rect_tinted(
|
||||
4.0 + 48.0 * x as f32 + 8.0 + left,
|
||||
(canvas_size.1 - 4.0 - 48.0 * 3.0) + 48.0 * y as f32 + 8.0 - bottom,
|
||||
color,
|
||||
&Rect::new_size(icon_x * 32, icon_y * 32, 32, 32),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
batch.add_rect_tinted(
|
||||
canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
|
||||
4.0 + 8.0 + top,
|
||||
color,
|
||||
&Rect::new_size(0, 3 * 32, 32, 32),
|
||||
);
|
||||
// Jump
|
||||
batch.add_rect_tinted(
|
||||
canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
|
||||
canvas_size.1 - (4.0 + 48.0) + 8.0 - bottom,
|
||||
color,
|
||||
&Rect::new_size(3 * 32, 32, 32, 32),
|
||||
);
|
||||
|
||||
batch.add_rect_tinted(4.0, 4.0, color, &Rect::new_size(32, 3 * 32, 32, 32));
|
||||
// Shoot
|
||||
batch.add_rect_tinted(
|
||||
canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
|
||||
canvas_size.1 - (4.0 + 48.0) * 2.0 + 8.0 - bottom,
|
||||
color,
|
||||
&Rect::new_size(3 * 32, 0, 32, 32),
|
||||
);
|
||||
|
||||
batch.draw(ctx)?;
|
||||
// Inventory
|
||||
batch.add_rect_tinted(
|
||||
canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
|
||||
4.0 + 8.0 + top,
|
||||
color,
|
||||
&Rect::new_size(0, 3 * 32, 32, 32),
|
||||
);
|
||||
|
||||
// Pause
|
||||
batch.add_rect_tinted(4.0, 4.0, color, &Rect::new_size(32, 3 * 32, 32, 32));
|
||||
|
||||
batch.draw(ctx)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -49,7 +49,12 @@ impl PlayerController for TouchPlayerController {
|
|||
self.state.set_jump(
|
||||
state
|
||||
.touch_controls
|
||||
.point_in(Rect::new_size(0, 0, state.canvas_size.0 as isize, state.canvas_size.1 as isize))
|
||||
.point_in(Rect::new_size(
|
||||
0,
|
||||
state.canvas_size.1 as isize / 2,
|
||||
state.canvas_size.0 as isize,
|
||||
state.canvas_size.1 as isize / 2,
|
||||
))
|
||||
.is_some(),
|
||||
);
|
||||
|
||||
|
@ -57,6 +62,18 @@ impl PlayerController for TouchPlayerController {
|
|||
self.prev_touch_len = state.touch_controls.points.len();
|
||||
self.old_state.set_jump(false);
|
||||
}
|
||||
|
||||
let (_, top, right, _) = screen_insets_scaled(ctx, state.scale);
|
||||
|
||||
let top = 4 + top as isize;
|
||||
let right = 4 + right as isize;
|
||||
|
||||
self.state.set_inventory(
|
||||
state
|
||||
.touch_controls
|
||||
.point_in(Rect::new_size(state.canvas_size.0 as isize - 48 - right, top, 48, 48))
|
||||
.is_some(),
|
||||
);
|
||||
}
|
||||
TouchControlType::Controls => {
|
||||
let (left, _top, right, bottom) = screen_insets_scaled(ctx, state.scale);
|
||||
|
@ -218,7 +235,7 @@ impl PlayerController for TouchPlayerController {
|
|||
);
|
||||
|
||||
self.state.set_pause(
|
||||
self.state.pause() || state.touch_controls.point_in(Rect::new_size(0, 0, 20, 20)).is_some(),
|
||||
self.state.pause() || state.touch_controls.point_in(Rect::new_size(0, 0, 40, 40)).is_some(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1743,6 +1743,7 @@ impl Scene for GameScene {
|
|||
| TextScriptExecutionState::FallingIsland(_, _, _, _, _, _)
|
||||
if !state.control_flags.control_enabled() && !state.textscript_vm.flags.cutscene_skip() =>
|
||||
{
|
||||
state.touch_controls.control_type = TouchControlType::Dialog;
|
||||
if self.player1.controller.inventory() {
|
||||
self.skip_counter += 1;
|
||||
if self.skip_counter >= CUTSCENE_SKIP_WAIT {
|
||||
|
@ -2041,7 +2042,11 @@ impl Scene for GameScene {
|
|||
if self.skip_counter > 1 || state.tutorial_counter > 0 {
|
||||
let text = state.tt(
|
||||
"game.cutscene_skip",
|
||||
HashMap::from([("key".to_owned(), format!("{:?}", state.settings.player1_key_map.inventory))]),
|
||||
HashMap::from(if !state.settings.touch_controls {
|
||||
[("key".to_owned(), format!("{:?}", state.settings.player1_key_map.inventory))]
|
||||
} else {
|
||||
[("key".to_owned(), ">>".to_owned())]
|
||||
}),
|
||||
);
|
||||
let width = state.font.text_width(text.chars(), &state.constants);
|
||||
let pos_x = state.canvas_size.0 - width - 20.0;
|
||||
|
|
Loading…
Reference in a new issue