mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-03-25 03:19:27 +00:00
Add display touch controls option[ci skip]
This commit is contained in:
parent
f6caffd624
commit
425a26b3a0
|
@ -113,6 +113,9 @@
|
|||
"soundtrack": "Soundtrack: {soundtrack}"
|
||||
},
|
||||
"controls": "Controls...",
|
||||
"controls_menu": {
|
||||
"display_touch_controls": "Display touch controls:"
|
||||
},
|
||||
"language": "Language...",
|
||||
"behavior": "Behavior...",
|
||||
"behavior_menu": {
|
||||
|
|
|
@ -190,7 +190,7 @@ impl Game {
|
|||
|
||||
if let Some(scene) = &mut self.scene {
|
||||
scene.draw(state_ref, ctx)?;
|
||||
if state_ref.settings.touch_controls {
|
||||
if state_ref.settings.touch_controls && state_ref.settings.display_touch_controls {
|
||||
state_ref.touch_controls.draw(
|
||||
state_ref.canvas_size,
|
||||
state_ref.scale,
|
||||
|
|
|
@ -28,6 +28,8 @@ pub struct Settings {
|
|||
#[serde(default = "default_true")]
|
||||
pub motion_interpolation: bool,
|
||||
pub touch_controls: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub display_touch_controls: bool,
|
||||
pub soundtrack: String,
|
||||
#[serde(default = "default_vol")]
|
||||
pub bgm_volume: f32,
|
||||
|
@ -91,7 +93,7 @@ fn default_true() -> bool {
|
|||
|
||||
#[inline(always)]
|
||||
fn current_version() -> u32 {
|
||||
22
|
||||
23
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -334,6 +336,11 @@ impl Settings {
|
|||
self.discord_rpc = true;
|
||||
}
|
||||
|
||||
if self.version == 22 {
|
||||
self.version = 23;
|
||||
self.display_touch_controls = true;
|
||||
}
|
||||
|
||||
if self.version != initial_version {
|
||||
log::info!("Upgraded configuration file from version {} to {}.", initial_version, self.version);
|
||||
}
|
||||
|
@ -410,6 +417,7 @@ impl Default for Settings {
|
|||
subpixel_coords: true,
|
||||
motion_interpolation: true,
|
||||
touch_controls: cfg!(target_os = "android"),
|
||||
display_touch_controls: true,
|
||||
soundtrack: "Organya".to_string(),
|
||||
bgm_volume: 1.0,
|
||||
sfx_volume: 1.0,
|
||||
|
|
|
@ -42,12 +42,18 @@ enum MainMenuEntry {
|
|||
Controller,
|
||||
Rebind,
|
||||
Rumble,
|
||||
#[cfg(target_os = "android")]
|
||||
DisplayTouchControls,
|
||||
Back,
|
||||
}
|
||||
|
||||
impl Default for MainMenuEntry {
|
||||
fn default() -> Self {
|
||||
MainMenuEntry::SelectedPlayer
|
||||
#[cfg(target_os = "android")]
|
||||
return MainMenuEntry::DisplayTouchControls;
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
return MainMenuEntry::SelectedPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,25 +201,37 @@ impl ControlsMenu {
|
|||
}
|
||||
|
||||
pub fn init(&mut self, state: &mut SharedGameState, ctx: &mut Context) -> GameResult {
|
||||
#[cfg(not(target_os = "android"))]
|
||||
{
|
||||
self.main.push_entry(
|
||||
MainMenuEntry::SelectedPlayer,
|
||||
MenuEntry::Options(
|
||||
state.loc.t("menus.controls_menu.select_player.entry").to_owned(),
|
||||
self.selected_player as usize,
|
||||
vec![
|
||||
state.loc.t("menus.controls_menu.select_player.player_1").to_owned(),
|
||||
state.loc.t("menus.controls_menu.select_player.player_2").to_owned(),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
self.main.push_entry(
|
||||
MainMenuEntry::Controller,
|
||||
MenuEntry::Active(state.loc.t("menus.controls_menu.controller.entry").to_owned()),
|
||||
);
|
||||
self.main
|
||||
.push_entry(MainMenuEntry::Rebind, MenuEntry::Active(state.loc.t("menus.controls_menu.rebind").to_owned()));
|
||||
self.main.push_entry(MainMenuEntry::Rumble, MenuEntry::Hidden);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
self.main.push_entry(
|
||||
MainMenuEntry::SelectedPlayer,
|
||||
MenuEntry::Options(
|
||||
state.loc.t("menus.controls_menu.select_player.entry").to_owned(),
|
||||
self.selected_player as usize,
|
||||
vec![
|
||||
state.loc.t("menus.controls_menu.select_player.player_1").to_owned(),
|
||||
state.loc.t("menus.controls_menu.select_player.player_2").to_owned(),
|
||||
],
|
||||
MainMenuEntry::DisplayTouchControls,
|
||||
MenuEntry::Toggle(
|
||||
state.loc.t("menus.options_menu.controls_menu.display_touch_controls").to_owned(),
|
||||
state.settings.display_touch_controls,
|
||||
),
|
||||
);
|
||||
|
||||
self.main.push_entry(
|
||||
MainMenuEntry::Controller,
|
||||
MenuEntry::Active(state.loc.t("menus.controls_menu.controller.entry").to_owned()),
|
||||
);
|
||||
self.main
|
||||
.push_entry(MainMenuEntry::Rebind, MenuEntry::Active(state.loc.t("menus.controls_menu.rebind").to_owned()));
|
||||
self.main.push_entry(MainMenuEntry::Rumble, MenuEntry::Hidden);
|
||||
self.main.push_entry(MainMenuEntry::Back, MenuEntry::Active(state.loc.t("common.back").to_owned()));
|
||||
|
||||
self.confirm_reset.push_entry(
|
||||
|
@ -954,6 +972,15 @@ impl ControlsMenu {
|
|||
state.settings.save(ctx)?;
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
MenuSelectionResult::Selected(MainMenuEntry::DisplayTouchControls, toggle) => {
|
||||
if let MenuEntry::Toggle(_, value) = toggle {
|
||||
state.settings.display_touch_controls = !state.settings.display_touch_controls;
|
||||
let _ = state.settings.save(ctx);
|
||||
|
||||
*value = state.settings.display_touch_controls;
|
||||
}
|
||||
}
|
||||
MenuSelectionResult::Selected(MainMenuEntry::Back, _) | MenuSelectionResult::Canceled => exit_action(),
|
||||
_ => {}
|
||||
},
|
||||
|
|
|
@ -345,7 +345,6 @@ impl SettingsMenu {
|
|||
self.main
|
||||
.push_entry(MainMenuEntry::Sound, MenuEntry::Active(state.loc.t("menus.options_menu.sound").to_owned()));
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
self.main.push_entry(
|
||||
MainMenuEntry::Controls,
|
||||
MenuEntry::Active(state.loc.t("menus.options_menu.controls").to_owned()),
|
||||
|
|
Loading…
Reference in a new issue