consider key layout

This commit is contained in:
IsseW 2021-10-26 00:42:30 +02:00
parent 6a85e231b4
commit 3368f43a22
2 changed files with 7 additions and 3 deletions

View File

@ -14,6 +14,7 @@ use crate::{
use common::assets::{self, AssetExt};
use i18n::Localization;
use iced::{button, Align, Column, Container, Length, Row, Space, Text};
use keyboard_keynames::key_layout::KeyLayout;
use serde::{Deserialize, Serialize};
struct LoadingAnimation {
@ -91,6 +92,7 @@ impl Screen {
button_style: style::button::Style,
show_tip: bool,
controls: &ControlSettings,
key_layout: &Option<KeyLayout>,
) -> Element<Message> {
// TODO: add built in support for animated images
let frame_index = (time * self.loading_animation.speed_factor as f64)
@ -116,7 +118,7 @@ impl Screen {
new_tip.push_str(&tip[last_index..start]);
new_tip.push_str(
controls.keybindings[&game_input]
.display_string(&None)
.display_string(key_layout)
.as_str(),
);
last_index = end + 1;

View File

@ -19,6 +19,7 @@ use crate::{
};
use i18n::{LanguageMetadata, LocalizationHandle};
use iced::{text_input, Column, Container, HorizontalAlignment, Length, Row, Space};
use keyboard_keynames::key_layout::KeyLayout;
//ImageFrame, Tooltip,
use crate::settings::Settings;
use common::assets::{self, AssetExt};
@ -229,7 +230,7 @@ impl Controls {
}
}
fn view(&mut self, settings: &Settings, dt: f32) -> Element<Message> {
fn view(&mut self, settings: &Settings, key_layout: &Option<KeyLayout>, dt: f32) -> Element<Message> {
self.time += dt as f64;
// TODO: consider setting this as the default in the renderer
@ -309,6 +310,7 @@ impl Controls {
button_style,
settings.interface.loading_tips,
&settings.controls,
key_layout,
),
};
@ -588,7 +590,7 @@ impl MainMenuUi {
let mut events = Vec::new();
let (messages, _) = self.ui.maintain(
self.controls.view(&global_state.settings, dt.as_secs_f32()),
self.controls.view(&global_state.settings, &global_state.window.key_layout, dt.as_secs_f32()),
global_state.window.renderer_mut(),
None,
&mut global_state.clipboard,