mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'tygyh/buttons-refactoring' into 'master'
Tygyh/buttons refactoring See merge request veloren/veloren!2718
This commit is contained in:
commit
35902d45b4
3
voxygen/src/hud/animation.rs
Normal file
3
voxygen/src/hud/animation.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn animation_timer(pulse: f32) -> f32 {
|
||||
(pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8 //y=0.5cos(4x)+0.8
|
||||
}
|
@ -3,7 +3,7 @@ use super::{
|
||||
BUFF_COLOR, DEBUFF_COLOR, TEXT_COLOR,
|
||||
};
|
||||
use crate::{
|
||||
hud::{self, BuffPosition},
|
||||
hud::{self, animation::animation_timer, BuffPosition},
|
||||
ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
|
||||
GlobalState,
|
||||
};
|
||||
@ -104,7 +104,7 @@ impl<'a> Widget for BuffsBar<'a> {
|
||||
let mut event = Vec::new();
|
||||
let localized_strings = self.localized_strings;
|
||||
let buffs = self.buffs;
|
||||
let buff_ani = ((self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8) + 0.5; //Animation timer
|
||||
let buff_ani = animation_timer(self.pulse) + 0.5; //Animation timer
|
||||
let pulsating_col = Color::Rgba(1.0, 1.0, 1.0, buff_ani);
|
||||
let norm_col = Color::Rgba(1.0, 1.0, 1.0, 1.0);
|
||||
let buff_position = self.global_state.settings.interface.buff_position;
|
||||
|
@ -4,6 +4,7 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
game_input::GameInput,
|
||||
hud::animation::animation_timer,
|
||||
ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
|
||||
window::KeyMouse,
|
||||
GlobalState,
|
||||
@ -11,7 +12,7 @@ use crate::{
|
||||
use client::Client;
|
||||
use common::comp::{SkillSet, Stats};
|
||||
use conrod_core::{
|
||||
widget::{self, Button, Image, Text},
|
||||
widget::{self, Button, Image, Text, UpdateArgs},
|
||||
widget_ids, Color, Colorable, Positionable, Sizeable, UiCell, Widget, WidgetCommon,
|
||||
};
|
||||
use i18n::Localization;
|
||||
@ -123,16 +124,10 @@ impl<'a> Widget for Buttons<'a> {
|
||||
|
||||
fn style(&self) -> Self::Style {}
|
||||
|
||||
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
||||
fn update(self, args: UpdateArgs<Self>) -> Self::Event {
|
||||
common_base::prof_span!("Buttons::update");
|
||||
let widget::UpdateArgs { state, ui, .. } = args;
|
||||
let invs = self.client.inventories();
|
||||
let inventory = match invs.get(self.client.entity()) {
|
||||
Some(inv) => inv,
|
||||
None => return None,
|
||||
};
|
||||
let UpdateArgs { state, ui, .. } = args;
|
||||
let localized_strings = self.localized_strings;
|
||||
let arrow_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8; //Animation timer
|
||||
|
||||
let button_tooltip = Tooltip::new({
|
||||
// Edge images [t, b, r, l]
|
||||
@ -197,6 +192,11 @@ impl<'a> Widget for Buttons<'a> {
|
||||
state.ids.bag_text,
|
||||
);
|
||||
}
|
||||
let invs = self.client.inventories();
|
||||
let inventory = match invs.get(self.client.entity()) {
|
||||
Some(inv) => inv,
|
||||
None => return None,
|
||||
};
|
||||
if !self.show_bag {
|
||||
let space_used = inventory.populated_slots();
|
||||
let space_max = inventory.slots().count();
|
||||
@ -357,6 +357,7 @@ impl<'a> Widget for Buttons<'a> {
|
||||
}
|
||||
// Unspent SP indicator
|
||||
if unspent_sp {
|
||||
let arrow_ani = animation_timer(self.pulse); //Animation timer
|
||||
Image::new(self.imgs.sp_indicator_arrow)
|
||||
.w_h(20.0, 11.0)
|
||||
.graphics_for(state.ids.spellbook_button)
|
||||
|
@ -1,3 +1,4 @@
|
||||
mod animation;
|
||||
mod bag;
|
||||
mod buffs;
|
||||
mod buttons;
|
||||
|
Loading…
Reference in New Issue
Block a user