mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'vfoulon80/loading-animations' into 'master'
Add new random loading animations See merge request veloren/veloren!1931
This commit is contained in:
commit
9c95e971f2
@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Overhauled the sceptre
|
||||
- Make the /time command relative to the current day
|
||||
- Spatial partitioning via a grid for entity versus entity collisions was added which can more than halve the total tick time at higher entity counts (> ~1000)
|
||||
- The loading screen will now display random animations
|
||||
|
||||
### Removed
|
||||
|
||||
|
BIN
assets/voxygen/element/animation/loaders/cauldron1.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cauldron1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cauldron2.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cauldron2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cauldron3.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cauldron3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cauldron4.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cauldron4.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cauldron5.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cauldron5.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cheese1.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cheese1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cheese2.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cheese2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cheese3.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cheese3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cheese4.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cheese4.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/cheese5.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/cheese5.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/coins1.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/coins1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/coins2.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/coins2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/coins3.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/coins3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/coins4.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/coins4.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/coins5.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/coins5.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/house1.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/house1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/house2.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/house2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/house3.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/house3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/house4.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/house4.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/house5.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/house5.png
(Stored with Git LFS)
Normal file
Binary file not shown.
37
assets/voxygen/element/animation/loaders/manifest.ron
Normal file
37
assets/voxygen/element/animation/loaders/manifest.ron
Normal file
@ -0,0 +1,37 @@
|
||||
([
|
||||
(8.0, [
|
||||
"voxygen.element.animation.loaders.cauldron1",
|
||||
"voxygen.element.animation.loaders.cauldron2",
|
||||
"voxygen.element.animation.loaders.cauldron3",
|
||||
"voxygen.element.animation.loaders.cauldron4",
|
||||
"voxygen.element.animation.loaders.cauldron5",
|
||||
]),
|
||||
(6.0, [
|
||||
"voxygen.element.animation.loaders.cheese1",
|
||||
"voxygen.element.animation.loaders.cheese2",
|
||||
"voxygen.element.animation.loaders.cheese3",
|
||||
"voxygen.element.animation.loaders.cheese4",
|
||||
"voxygen.element.animation.loaders.cheese5",
|
||||
]),
|
||||
(6.0, [
|
||||
"voxygen.element.animation.loaders.coins1",
|
||||
"voxygen.element.animation.loaders.coins2",
|
||||
"voxygen.element.animation.loaders.coins3",
|
||||
"voxygen.element.animation.loaders.coins4",
|
||||
"voxygen.element.animation.loaders.coins5",
|
||||
]),
|
||||
(1.0, [
|
||||
"voxygen.element.animation.loaders.house1",
|
||||
"voxygen.element.animation.loaders.house2",
|
||||
"voxygen.element.animation.loaders.house3",
|
||||
"voxygen.element.animation.loaders.house4",
|
||||
"voxygen.element.animation.loaders.house5",
|
||||
]),
|
||||
(1.0, [
|
||||
"voxygen.element.animation.loaders.ship1",
|
||||
"voxygen.element.animation.loaders.ship2",
|
||||
"voxygen.element.animation.loaders.ship3",
|
||||
"voxygen.element.animation.loaders.ship4",
|
||||
"voxygen.element.animation.loaders.ship5",
|
||||
]),
|
||||
])
|
BIN
assets/voxygen/element/animation/loaders/ship1.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/ship1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/ship2.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/ship2.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/ship3.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/ship3.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/ship4.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/ship4.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/element/animation/loaders/ship5.png
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/element/animation/loaders/ship5.png
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -3,25 +3,65 @@ use crate::{
|
||||
i18n::Localization,
|
||||
ui::{
|
||||
fonts::IcedFonts as Fonts,
|
||||
ice::{component::neat_button, style, widget::Image, Element},
|
||||
ice::{component::neat_button, style, widget::Image, Element, IcedUi as Ui, Id},
|
||||
Graphic,
|
||||
},
|
||||
};
|
||||
use common::assets::{self, AssetExt};
|
||||
use iced::{button, Align, Column, Container, Length, Row, Space, Text};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
struct LoadingAnimation {
|
||||
speed_factor: f32,
|
||||
frames: Vec<Id>,
|
||||
}
|
||||
impl LoadingAnimation {
|
||||
fn new(raw: &(f32, Vec<String>), ui: &mut Ui) -> Self {
|
||||
let mut frames = vec![];
|
||||
for frame_path in raw.1.iter() {
|
||||
frames.push(ui.add_graphic(Graphic::Image(
|
||||
assets::Image::load(frame_path).unwrap().read().to_image(),
|
||||
None,
|
||||
)));
|
||||
}
|
||||
Self {
|
||||
speed_factor: raw.0,
|
||||
frames,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
struct LoadingAnimationManifest(Vec<(f32, Vec<String>)>);
|
||||
impl assets::Asset for LoadingAnimationManifest {
|
||||
type Loader = assets::RonLoader;
|
||||
|
||||
const EXTENSION: &'static str = "ron";
|
||||
}
|
||||
|
||||
const GEAR_ANIMATION_SPEED_FACTOR: f64 = 10.0;
|
||||
/// Connecting screen for the main menu
|
||||
pub struct Screen {
|
||||
cancel_button: button::State,
|
||||
add_button: button::State,
|
||||
tip_number: u16,
|
||||
loading_animation: LoadingAnimation,
|
||||
}
|
||||
|
||||
impl Screen {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(ui: &mut Ui) -> Self {
|
||||
let animations =
|
||||
LoadingAnimationManifest::load("voxygen.element.animation.loaders.manifest")
|
||||
.unwrap()
|
||||
.cloned()
|
||||
.0;
|
||||
Self {
|
||||
cancel_button: Default::default(),
|
||||
add_button: Default::default(),
|
||||
tip_number: rand::random(),
|
||||
loading_animation: LoadingAnimation::new(
|
||||
&animations[rand::random::<usize>() % animations.len()],
|
||||
ui,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,15 +75,10 @@ impl Screen {
|
||||
button_style: style::button::Style,
|
||||
show_tip: bool,
|
||||
) -> Element<Message> {
|
||||
let gear_anim_time = time * GEAR_ANIMATION_SPEED_FACTOR;
|
||||
// TODO: add built in support for animated images
|
||||
let gear_anim_image = match (gear_anim_time % 5.0).trunc() as u8 {
|
||||
0 => imgs.f1,
|
||||
1 => imgs.f2,
|
||||
2 => imgs.f3,
|
||||
3 => imgs.f4,
|
||||
_ => imgs.f5,
|
||||
};
|
||||
let frame_index = (time * self.loading_animation.speed_factor as f64)
|
||||
% self.loading_animation.frames.len() as f64;
|
||||
let frame_id = self.loading_animation.frames[frame_index as usize];
|
||||
|
||||
let children = match connection_state {
|
||||
ConnectionState::InProgress => {
|
||||
@ -82,9 +117,9 @@ impl Screen {
|
||||
.padding(5);
|
||||
|
||||
let gear = Container::new(
|
||||
Image::new(gear_anim_image)
|
||||
.width(Length::Units(74))
|
||||
.height(Length::Units(62)),
|
||||
Image::new(frame_id)
|
||||
.width(Length::Units(64))
|
||||
.height(Length::Units(64)),
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.padding(10)
|
||||
|
@ -51,13 +51,6 @@ image_ids_ice! {
|
||||
selection: "voxygen.element.frames.selection",
|
||||
selection_hover: "voxygen.element.frames.selection_hover",
|
||||
selection_press: "voxygen.element.frames.selection_press",
|
||||
|
||||
// Animation
|
||||
f1: "voxygen.element.animation.gears.1",
|
||||
f2: "voxygen.element.animation.gears.2",
|
||||
f3: "voxygen.element.animation.gears.3",
|
||||
f4: "voxygen.element.animation.gears.4",
|
||||
f5: "voxygen.element.animation.gears.5",
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +312,13 @@ impl Controls {
|
||||
.into()
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Message, events: &mut Vec<Event>, settings: &Settings) {
|
||||
fn update(
|
||||
&mut self,
|
||||
message: Message,
|
||||
events: &mut Vec<Event>,
|
||||
settings: &Settings,
|
||||
ui: &mut Ui,
|
||||
) {
|
||||
let servers = &settings.networking.servers;
|
||||
let mut language_metadatas = crate::i18n::list_localizations();
|
||||
|
||||
@ -343,14 +342,14 @@ impl Controls {
|
||||
#[cfg(feature = "singleplayer")]
|
||||
Message::Singleplayer => {
|
||||
self.screen = Screen::Connecting {
|
||||
screen: connecting::Screen::new(),
|
||||
screen: connecting::Screen::new(ui),
|
||||
connection_state: ConnectionState::InProgress,
|
||||
};
|
||||
events.push(Event::StartSingleplayer);
|
||||
},
|
||||
Message::Multiplayer => {
|
||||
self.screen = Screen::Connecting {
|
||||
screen: connecting::Screen::new(),
|
||||
screen: connecting::Screen::new(ui),
|
||||
connection_state: ConnectionState::InProgress,
|
||||
};
|
||||
|
||||
@ -577,7 +576,7 @@ impl<'a> MainMenuUi {
|
||||
|
||||
messages.into_iter().for_each(|message| {
|
||||
self.controls
|
||||
.update(message, &mut events, &global_state.settings)
|
||||
.update(message, &mut events, &global_state.settings, &mut self.ui)
|
||||
});
|
||||
|
||||
events
|
||||
|
Loading…
Reference in New Issue
Block a user