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,
|
text: widget::Id,
|
||||||
) {
|
) {
|
||||||
let key_layout = &self.global_state.window.key_layout;
|
let key_layout = &self.global_state.window.key_layout;
|
||||||
let key_desc = key_mouse
|
let key_desc = key_mouse.try_shortened(key_layout);
|
||||||
.display_shortened(key_layout)
|
|
||||||
.unwrap_or_else(|| key_mouse.display_string(key_layout));
|
|
||||||
|
|
||||||
//Create shadow
|
//Create shadow
|
||||||
Text::new(&key_desc)
|
Text::new(&key_desc)
|
||||||
|
@ -878,7 +878,7 @@ impl<'a> Widget for Diary<'a> {
|
|||||||
]
|
]
|
||||||
.get(i)
|
.get(i)
|
||||||
.and_then(|input| keys.get_binding(*input))
|
.and_then(|input| keys.get_binding(*input))
|
||||||
.map(|key| key.display_string(key_layout))
|
.map(|key| key.try_shortened(key_layout))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
Text::new(&ability_key)
|
Text::new(&ability_key)
|
||||||
|
@ -1425,17 +1425,13 @@ impl<'a> Widget for Map<'a> {
|
|||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.zoom_txt, ui);
|
.set(state.ids.zoom_txt, ui);
|
||||||
|
|
||||||
Text::new(
|
Text::new(&location_marker_binding.try_shortened(key_layout))
|
||||||
&location_marker_binding
|
.right_from(state.ids.zoom_txt, 15.0)
|
||||||
.display_shortened(key_layout)
|
.font_size(self.fonts.cyri.scale(14))
|
||||||
.unwrap_or_default(),
|
.font_id(self.fonts.cyri.conrod_id)
|
||||||
)
|
.graphics_for(state.ids.map_layers[0])
|
||||||
.right_from(state.ids.zoom_txt, 15.0)
|
.color(TEXT_COLOR)
|
||||||
.font_size(self.fonts.cyri.scale(14))
|
.set(state.ids.waypoint_binding_txt, ui);
|
||||||
.font_id(self.fonts.cyri.conrod_id)
|
|
||||||
.graphics_for(state.ids.map_layers[0])
|
|
||||||
.color(TEXT_COLOR)
|
|
||||||
.set(state.ids.waypoint_binding_txt, ui);
|
|
||||||
|
|
||||||
Text::new(i18n.get("hud.map.mid_click"))
|
Text::new(i18n.get("hud.map.mid_click"))
|
||||||
.right_from(state.ids.waypoint_binding_txt, 5.0)
|
.right_from(state.ids.waypoint_binding_txt, 5.0)
|
||||||
|
@ -655,9 +655,7 @@ impl<'a> Skillbar<'a> {
|
|||||||
let position_bg = entry.shortcut_position_bg;
|
let position_bg = entry.shortcut_position_bg;
|
||||||
let (id, id_bg) = entry.shortcut_widget_ids;
|
let (id, id_bg) = entry.shortcut_widget_ids;
|
||||||
|
|
||||||
let key_desc = key
|
let key_desc = key.try_shortened(key_layout);
|
||||||
.display_shortened(key_layout)
|
|
||||||
.unwrap_or_else(|| key.display_string(key_layout));
|
|
||||||
// shortcut text
|
// shortcut text
|
||||||
Text::new(&key_desc)
|
Text::new(&key_desc)
|
||||||
.position(position)
|
.position(position)
|
||||||
|
@ -366,6 +366,11 @@ impl KeyMouse {
|
|||||||
|
|
||||||
Some(key_string.to_owned())
|
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 {
|
pub struct Window {
|
||||||
|
Loading…
Reference in New Issue
Block a user