mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added keybinding shortcut in loading tips
This commit is contained in:
parent
8e8d1a6624
commit
047cda179f
@ -85,9 +85,10 @@ https://veloren.net/account/."#,
|
|||||||
|
|
||||||
|
|
||||||
vector_map: {
|
vector_map: {
|
||||||
|
// The keybinding names can be found in voxygen/src/game_input.rs in the GameInput enum
|
||||||
"loading.tips": [
|
"loading.tips": [
|
||||||
"Press 'G' to light your lantern.",
|
"Press '{gameinput.togglelantern}' to light your lantern.",
|
||||||
"Press 'F1' to see all default keybindings.",
|
"Press '{gameinput.help}' to see all default keybindings.",
|
||||||
"You can type /say or /s to only chat with players directly around you.",
|
"You can type /say or /s to only chat with players directly around you.",
|
||||||
"You can type /region or /r to only chat with players a couple of hundred blocks around you.",
|
"You can type /region or /r to only chat with players a couple of hundred blocks around you.",
|
||||||
"Admins can use the /build command to enter build mode.",
|
"Admins can use the /build command to enter build mode.",
|
||||||
@ -96,16 +97,18 @@ https://veloren.net/account/."#,
|
|||||||
"Keep an eye out for food, chests and other loot spread all around the world!",
|
"Keep an eye out for food, chests and other loot spread all around the world!",
|
||||||
"Inventory filled with food? Try crafting better food from it!",
|
"Inventory filled with food? Try crafting better food from it!",
|
||||||
"Wondering what there is to do? Try out one of the dungeons marked on the map!",
|
"Wondering what there is to do? Try out one of the dungeons marked on the map!",
|
||||||
"Don't forget to adjust the graphics for your system. Press 'N' to open the settings.",
|
"Don't forget to adjust the graphics for your system.",
|
||||||
"Playing with others is fun! Press 'O' to see who is online.",
|
"Playing with others is fun! Press '{gameinput.social}' to see who is online.",
|
||||||
"Press 'J' to dance. Party!",
|
"Press '{gameinput.dance}' to dance. Party!",
|
||||||
"Press 'L-Shift' to open your Glider and conquer the skies.",
|
"Press '{gameinput.glide}' to open your Glider and conquer the skies.",
|
||||||
"Veloren is still in Pre-Alpha. We do our best to improve it every day!",
|
"Veloren is still in Pre-Alpha. We do our best to improve it every day!",
|
||||||
"If you want to join the dev team or just have a chat with us, join our Discord server.",
|
"If you want to join the dev team or just have a chat with us, join our Discord server.",
|
||||||
"You can toggle showing your amount of health on the healthbar in the settings.",
|
"You can toggle showing your amount of health on the healthbar in the settings.",
|
||||||
"Sit near a campfire (with the 'K' key) to slowly recover from your injuries.",
|
"Sit near a campfire (with the '{gameinput.sit}' key) to slowly recover from your injuries.",
|
||||||
"Need more bags or better armor to continue your journey? Press 'C' to open the crafting menu!",
|
"Need more bags or better armor to continue your journey? Press '{gameinput.crafting}' to open the crafting menu!",
|
||||||
"Try jumping when rolling through creatures.",
|
"Press '{gameinput.roll}' to roll. Rolling can be used to move faster and dodge enemy attacks.",
|
||||||
|
"Wondering what an item is used for? Search 'input:<item name>' in crafting to see what recipes it's used in.",
|
||||||
|
"Find something cool? Take a screenshot of it with '{gameinput.screenshot}'."
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::convert::AsRef;
|
use std::convert::AsRef;
|
||||||
use strum::{AsRefStr, EnumIter};
|
use strum::{AsRefStr, EnumIter, EnumString};
|
||||||
|
|
||||||
/// Represents a key that the game recognises after input mapping.
|
/// Represents a key that the game recognises after input mapping.
|
||||||
#[derive(
|
#[derive(
|
||||||
@ -16,6 +16,7 @@ use strum::{AsRefStr, EnumIter};
|
|||||||
Serialize,
|
Serialize,
|
||||||
AsRefStr,
|
AsRefStr,
|
||||||
EnumIter,
|
EnumIter,
|
||||||
|
EnumString,
|
||||||
)]
|
)]
|
||||||
pub enum GameInput {
|
pub enum GameInput {
|
||||||
#[strum(serialize = "gameinput.primary")]
|
#[strum(serialize = "gameinput.primary")]
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use super::{ConnectionState, Imgs, Message};
|
use super::{ConnectionState, Imgs, Message};
|
||||||
|
|
||||||
use crate::ui::{
|
use crate::{
|
||||||
fonts::IcedFonts as Fonts,
|
game_input::GameInput,
|
||||||
ice::{component::neat_button, style, widget::Image, Element, IcedUi as Ui, Id},
|
settings::ControlSettings,
|
||||||
Graphic,
|
ui::{
|
||||||
|
fonts::IcedFonts as Fonts,
|
||||||
|
ice::{component::neat_button, style, widget::Image, Element, IcedUi as Ui, Id},
|
||||||
|
Graphic,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use common::assets::{self, AssetExt};
|
use common::assets::{self, AssetExt};
|
||||||
use i18n::Localization;
|
use i18n::Localization;
|
||||||
@ -84,6 +90,7 @@ impl Screen {
|
|||||||
i18n: &Localization,
|
i18n: &Localization,
|
||||||
button_style: style::button::Style,
|
button_style: style::button::Style,
|
||||||
show_tip: bool,
|
show_tip: bool,
|
||||||
|
controls: &ControlSettings,
|
||||||
) -> Element<Message> {
|
) -> Element<Message> {
|
||||||
// TODO: add built in support for animated images
|
// TODO: add built in support for animated images
|
||||||
let frame_index = (time * self.loading_animation.speed_factor as f64)
|
let frame_index = (time * self.loading_animation.speed_factor as f64)
|
||||||
@ -93,11 +100,35 @@ impl Screen {
|
|||||||
let children = match connection_state {
|
let children = match connection_state {
|
||||||
ConnectionState::InProgress => {
|
ConnectionState::InProgress => {
|
||||||
let tip = if show_tip {
|
let tip = if show_tip {
|
||||||
let tip = format!(
|
let tip = &i18n.get_variation("loading.tips", self.tip_number);
|
||||||
"{} {}",
|
let mut new_tip = String::with_capacity(tip.len());
|
||||||
&i18n.get("main.tip"),
|
let mut last_index = 0;
|
||||||
&i18n.get_variation("loading.tips", self.tip_number)
|
|
||||||
);
|
// This could be done with regex instead, but adding new dependencies is
|
||||||
|
// scary...
|
||||||
|
tip.match_indices("{gameinput.").for_each(|(start, s)| {
|
||||||
|
println!("start {}", start);
|
||||||
|
if let Some(end) = tip[start + s.len()..].find('}') {
|
||||||
|
let end = start + s.len() + end;
|
||||||
|
println!("end {}", end);
|
||||||
|
if let Ok(game_input) = GameInput::from_str(&tip[start + 1..end]) {
|
||||||
|
println!("input {:?}", game_input);
|
||||||
|
new_tip.push_str(&tip[last_index..start]);
|
||||||
|
new_tip.push_str(
|
||||||
|
controls.keybindings[&game_input]
|
||||||
|
.display_string(&None)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
|
last_index = end + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// If there is any text left over append it
|
||||||
|
if last_index < tip.len() {
|
||||||
|
new_tip.push_str(&tip[last_index..]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let tip = format!("{} {}", i18n.get("main.tip"), new_tip.as_str());
|
||||||
Container::new(Text::new(tip).size(fonts.cyri.scale(25)))
|
Container::new(Text::new(tip).size(fonts.cyri.scale(25)))
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
|
@ -308,6 +308,7 @@ impl Controls {
|
|||||||
&self.i18n.read(),
|
&self.i18n.read(),
|
||||||
button_style,
|
button_style,
|
||||||
settings.interface.loading_tips,
|
settings.interface.loading_tips,
|
||||||
|
&settings.controls,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user