mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Try to display shortened version of key in diary
* Make try_shortened method that tries shortened version of key or regular version if shortened one isn't available * Use it in most places where display_shortened + display_string were used * Use it for diary skilbar
This commit is contained in:
parent
8c837da561
commit
9d928261cb
@ -425,9 +425,7 @@ impl<'a> Buttons<'a> {
|
||||
text: widget::Id,
|
||||
) {
|
||||
let key_layout = &self.global_state.window.key_layout;
|
||||
let key_desc = key_mouse
|
||||
.display_shortened(key_layout)
|
||||
.unwrap_or_else(|| key_mouse.display_string(key_layout));
|
||||
let key_desc = key_mouse.try_shortened(key_layout);
|
||||
|
||||
//Create shadow
|
||||
Text::new(&key_desc)
|
||||
|
@ -878,7 +878,7 @@ impl<'a> Widget for Diary<'a> {
|
||||
]
|
||||
.get(i)
|
||||
.and_then(|input| keys.get_binding(*input))
|
||||
.map(|key| key.display_string(key_layout))
|
||||
.map(|key| key.try_shortened(key_layout))
|
||||
.unwrap_or_default();
|
||||
|
||||
Text::new(&ability_key)
|
||||
|
@ -1425,11 +1425,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.zoom_txt, ui);
|
||||
|
||||
Text::new(
|
||||
&location_marker_binding
|
||||
.display_shortened(key_layout)
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
Text::new(&location_marker_binding.try_shortened(key_layout))
|
||||
.right_from(state.ids.zoom_txt, 15.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
|
@ -655,9 +655,7 @@ impl<'a> Skillbar<'a> {
|
||||
let position_bg = entry.shortcut_position_bg;
|
||||
let (id, id_bg) = entry.shortcut_widget_ids;
|
||||
|
||||
let key_desc = key
|
||||
.display_shortened(key_layout)
|
||||
.unwrap_or_else(|| key.display_string(key_layout));
|
||||
let key_desc = key.try_shortened(key_layout);
|
||||
// shortcut text
|
||||
Text::new(&key_desc)
|
||||
.position(position)
|
||||
|
@ -366,6 +366,11 @@ impl KeyMouse {
|
||||
|
||||
Some(key_string.to_owned())
|
||||
}
|
||||
|
||||
pub fn try_shortened(&self, key_layout: &Option<KeyLayout>) -> String {
|
||||
self.display_shortened(key_layout)
|
||||
.unwrap_or_else(|| self.display_string(key_layout))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Window {
|
||||
|
Loading…
Reference in New Issue
Block a user