mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better naming for shortened key functions
* Old display_shortened that returned Option is now called try_shortened * What was called try_shortened is now just display_shortest, because if shortened version isn't available, it means that regular version is already shortened.
This commit is contained in:
parent
3d1b2735a2
commit
3e73fba165
@ -425,7 +425,7 @@ impl<'a> Buttons<'a> {
|
||||
text: widget::Id,
|
||||
) {
|
||||
let key_layout = &self.global_state.window.key_layout;
|
||||
let key_desc = key_mouse.try_shortened(key_layout);
|
||||
let key_desc = key_mouse.display_shortest(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.try_shortened(key_layout))
|
||||
.map(|key| key.display_shortest(key_layout))
|
||||
.unwrap_or_default();
|
||||
|
||||
Text::new(&ability_key)
|
||||
|
@ -1425,7 +1425,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.zoom_txt, ui);
|
||||
|
||||
Text::new(&location_marker_binding.try_shortened(key_layout))
|
||||
Text::new(&location_marker_binding.display_shortest(key_layout))
|
||||
.right_from(state.ids.zoom_txt, 15.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
|
@ -134,7 +134,7 @@ impl<'a> Widget for Controls<'a> {
|
||||
format!(
|
||||
"{} {}",
|
||||
key.display_string(key_layout),
|
||||
key.display_shortened(key_layout)
|
||||
key.try_shortened(key_layout)
|
||||
.map_or("".to_owned(), |short| format!("({})", short))
|
||||
),
|
||||
if controls.has_conflicting_bindings(key) {
|
||||
|
@ -655,7 +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.try_shortened(key_layout);
|
||||
let key_desc = key.display_shortest(key_layout);
|
||||
// shortcut text
|
||||
Text::new(&key_desc)
|
||||
.position(position)
|
||||
|
@ -344,10 +344,9 @@ impl KeyMouse {
|
||||
key_string.to_owned()
|
||||
}
|
||||
|
||||
/// Returns shortened key name (e.g. Left Click -> LMB)
|
||||
///
|
||||
/// Use it in case if space does really matter.
|
||||
pub fn display_shortened(&self, _key_layout: &Option<KeyLayout>) -> Option<String> {
|
||||
/// If it exists, returns the shortened version of a key name
|
||||
/// (e.g. Left Click -> M1)
|
||||
pub fn try_shortened(&self, _key_layout: &Option<KeyLayout>) -> Option<String> {
|
||||
use self::KeyMouse::*;
|
||||
use winit::event::{MouseButton, VirtualKeyCode::*};
|
||||
let key_string = match self {
|
||||
@ -367,8 +366,12 @@ impl KeyMouse {
|
||||
Some(key_string.to_owned())
|
||||
}
|
||||
|
||||
pub fn try_shortened(&self, key_layout: &Option<KeyLayout>) -> String {
|
||||
self.display_shortened(key_layout)
|
||||
/// Returns shortest name of key (e.g. Left Click - M1)
|
||||
/// If key doesn't have shorter version, use regular one.
|
||||
///
|
||||
/// Use it in case if space does really matter.
|
||||
pub fn display_shortest(&self, key_layout: &Option<KeyLayout>) -> String {
|
||||
self.try_shortened(key_layout)
|
||||
.unwrap_or_else(|| self.display_string(key_layout))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user