1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2025-03-24 19:09:22 +00:00

Added Android cutscene skip

This commit is contained in:
dawnDus 2022-05-02 18:54:57 -04:00
parent af39130fed
commit 02a9cac305
No known key found for this signature in database
GPG key ID: 972AABDE81848F21
3 changed files with 83 additions and 42 deletions

View file

@ -79,12 +79,26 @@ impl TouchControls {
texture_set: &mut TextureSet, texture_set: &mut TextureSet,
ctx: &mut Context, ctx: &mut Context,
) -> GameResult { ) -> GameResult {
if self.control_type == TouchControlType::Controls {
let batch = texture_set.get_or_load_batch(ctx, constants, "builtin/touch")?; let batch = texture_set.get_or_load_batch(ctx, constants, "builtin/touch")?;
let color = (255, 255, 255, 160); 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);
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),
);
batch.draw(ctx)?;
}
TouchControlType::Controls => {
// Movement
for x in 0..3 { for x in 0..3 {
for y in 0..3 { for y in 0..3 {
let mut icon_x = x; let mut icon_x = x;
@ -103,6 +117,7 @@ impl TouchControls {
} }
} }
// Jump
batch.add_rect_tinted( batch.add_rect_tinted(
canvas_size.0 - (4.0 + 48.0) + 8.0 - right, canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
canvas_size.1 - (4.0 + 48.0) + 8.0 - bottom, canvas_size.1 - (4.0 + 48.0) + 8.0 - bottom,
@ -110,6 +125,7 @@ impl TouchControls {
&Rect::new_size(3 * 32, 32, 32, 32), &Rect::new_size(3 * 32, 32, 32, 32),
); );
// Shoot
batch.add_rect_tinted( batch.add_rect_tinted(
canvas_size.0 - (4.0 + 48.0) + 8.0 - right, canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
canvas_size.1 - (4.0 + 48.0) * 2.0 + 8.0 - bottom, canvas_size.1 - (4.0 + 48.0) * 2.0 + 8.0 - bottom,
@ -117,6 +133,7 @@ impl TouchControls {
&Rect::new_size(3 * 32, 0, 32, 32), &Rect::new_size(3 * 32, 0, 32, 32),
); );
// Inventory
batch.add_rect_tinted( batch.add_rect_tinted(
canvas_size.0 - (4.0 + 48.0) + 8.0 - right, canvas_size.0 - (4.0 + 48.0) + 8.0 - right,
4.0 + 8.0 + top, 4.0 + 8.0 + top,
@ -124,10 +141,12 @@ impl TouchControls {
&Rect::new_size(0, 3 * 32, 32, 32), &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.add_rect_tinted(4.0, 4.0, color, &Rect::new_size(32, 3 * 32, 32, 32));
batch.draw(ctx)?; batch.draw(ctx)?;
} }
}
Ok(()) Ok(())
} }

View file

@ -49,7 +49,12 @@ impl PlayerController for TouchPlayerController {
self.state.set_jump( self.state.set_jump(
state state
.touch_controls .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(), .is_some(),
); );
@ -57,6 +62,18 @@ impl PlayerController for TouchPlayerController {
self.prev_touch_len = state.touch_controls.points.len(); self.prev_touch_len = state.touch_controls.points.len();
self.old_state.set_jump(false); 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 => { TouchControlType::Controls => {
let (left, _top, right, bottom) = screen_insets_scaled(ctx, state.scale); 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.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(),
); );
} }
} }

View file

@ -1743,6 +1743,7 @@ impl Scene for GameScene {
| TextScriptExecutionState::FallingIsland(_, _, _, _, _, _) | TextScriptExecutionState::FallingIsland(_, _, _, _, _, _)
if !state.control_flags.control_enabled() && !state.textscript_vm.flags.cutscene_skip() => if !state.control_flags.control_enabled() && !state.textscript_vm.flags.cutscene_skip() =>
{ {
state.touch_controls.control_type = TouchControlType::Dialog;
if self.player1.controller.inventory() { if self.player1.controller.inventory() {
self.skip_counter += 1; self.skip_counter += 1;
if self.skip_counter >= CUTSCENE_SKIP_WAIT { if self.skip_counter >= CUTSCENE_SKIP_WAIT {
@ -2041,7 +2042,11 @@ impl Scene for GameScene {
if self.skip_counter > 1 || state.tutorial_counter > 0 { if self.skip_counter > 1 || state.tutorial_counter > 0 {
let text = state.tt( let text = state.tt(
"game.cutscene_skip", "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 width = state.font.text_width(text.chars(), &state.constants);
let pos_x = state.canvas_size.0 - width - 20.0; let pos_x = state.canvas_size.0 - width - 20.0;