mirror of
https://github.com/doukutsu-rs/doukutsu-rs.git
synced 2026-08-24 13:02:49 -07:00
Exit the rebind menu on click
This commit is contained in:
@@ -189,7 +189,8 @@
|
||||
},
|
||||
"rebind_confirm_menu": {
|
||||
"title": "Press button for \"{control}\"",
|
||||
"cancel": "(Esc to cancel)"
|
||||
"cancel": "(Esc to cancel)",
|
||||
"cancel_touch": "(Esc or touch the screen to cancel)"
|
||||
},
|
||||
"rumble": "Rumble:",
|
||||
"reset_confirm": "Reset...",
|
||||
|
||||
@@ -188,7 +188,8 @@
|
||||
},
|
||||
"rebind_confirm_menu": {
|
||||
"title": "新しい「ジャンプ」ボタンを押す",
|
||||
"cancel": "(Escキーを押してキャンセル)"
|
||||
"cancel": "(Escキーを押してキャンセル)",
|
||||
"cancel_touch": "(Escキーを押すか画面をタッチしてキャンセル)"
|
||||
},
|
||||
"rumble": "ランブル",
|
||||
"reset_confirm": "リセット",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::common::Rect;
|
||||
use crate::framework::context::Context;
|
||||
use crate::framework::error::GameResult;
|
||||
use crate::framework::gamepad::{self, Axis, AxisDirection, Button, PlayerControllerInputType};
|
||||
@@ -410,7 +411,13 @@ impl ControlsMenu {
|
||||
|
||||
self.select_controller.push_entry(
|
||||
SelectControllerMenuEntry::Keyboard,
|
||||
MenuEntry::Active(state.loc.t(if state.settings.touch_controls { "menus.controls_menu.controller.touch_controls" } else { "menus.controls_menu.controller.keyboard" }).to_owned()),
|
||||
MenuEntry::Active(state.loc.t(
|
||||
if state.settings.touch_controls {
|
||||
"menus.controls_menu.controller.touch_controls_or_keyboard"
|
||||
} else {
|
||||
"menus.controls_menu.controller.keyboard"
|
||||
}
|
||||
).to_owned()),
|
||||
);
|
||||
|
||||
let gamepads = gamepad::get_gamepads(ctx);
|
||||
@@ -487,7 +494,13 @@ impl ControlsMenu {
|
||||
);
|
||||
self.confirm_rebind.push_entry(
|
||||
1,
|
||||
MenuEntry::Disabled(state.loc.t("menus.controls_menu.rebind_confirm_menu.cancel").to_owned()),
|
||||
MenuEntry::Disabled(state.loc.t(
|
||||
if state.settings.touch_controls {
|
||||
"menus.controls_menu.rebind_confirm_menu.cancel_touch"
|
||||
} else {
|
||||
"menus.controls_menu.rebind_confirm_menu.cancel"
|
||||
}
|
||||
).to_owned()),
|
||||
);
|
||||
}
|
||||
None => {}
|
||||
@@ -1052,8 +1065,15 @@ impl ControlsMenu {
|
||||
},
|
||||
CurrentMenu::ConfirmRebindMenu => match self.confirm_rebind.tick(controller, state) {
|
||||
_ => {
|
||||
let entry_bounds = Rect::new_size(0, 0, ctx.screen_size.0 as isize, ctx.screen_size.1 as isize);
|
||||
let pressed_keys: Vec<_> = ctx.keyboard_context.pressed_keys().into_iter().collect();
|
||||
|
||||
if state.touch_controls.consume_click_in(entry_bounds) {
|
||||
state.sound_manager.play_sfx(5);
|
||||
self.current = CurrentMenu::RebindMenu;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for key in pressed_keys.clone() {
|
||||
if *key == ScanCode::Escape {
|
||||
state.sound_manager.play_sfx(5);
|
||||
|
||||
Reference in New Issue
Block a user