mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added tick mark for the upcoming threshold
This commit is contained in:
@ -55,6 +55,8 @@ pub struct Poise {
|
|||||||
pub regen_rate: f32,
|
pub regen_rate: f32,
|
||||||
/// Time that entity was last in a poise state
|
/// Time that entity was last in a poise state
|
||||||
last_stun_time: Option<Time>,
|
last_stun_time: Option<Time>,
|
||||||
|
/// Next threshold for the poise change
|
||||||
|
next_threshold: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// States to define effects of a poise change
|
/// States to define effects of a poise change
|
||||||
@ -160,6 +162,9 @@ impl Poise {
|
|||||||
/// Returns the current value of poise casted to a float
|
/// Returns the current value of poise casted to a float
|
||||||
pub fn current(&self) -> f32 { self.current as f32 / Self::SCALING_FACTOR_FLOAT }
|
pub fn current(&self) -> f32 { self.current as f32 / Self::SCALING_FACTOR_FLOAT }
|
||||||
|
|
||||||
|
/// Returns the next threshold of poise
|
||||||
|
pub fn next_threshold(&self) -> f32 { self.next_threshold }
|
||||||
|
|
||||||
/// Returns the base maximum value of poise casted to a float
|
/// Returns the base maximum value of poise casted to a float
|
||||||
pub fn base_max(&self) -> f32 { self.base_max as f32 / Self::SCALING_FACTOR_FLOAT }
|
pub fn base_max(&self) -> f32 { self.base_max as f32 / Self::SCALING_FACTOR_FLOAT }
|
||||||
|
|
||||||
@ -189,6 +194,7 @@ impl Poise {
|
|||||||
last_change: Dir::default(),
|
last_change: Dir::default(),
|
||||||
regen_rate: 0.0,
|
regen_rate: 0.0,
|
||||||
last_stun_time: None,
|
last_stun_time: None,
|
||||||
|
next_threshold: self::Poise::POISE_THRESHOLDS[0],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +207,10 @@ impl Poise {
|
|||||||
* Self::SCALING_FACTOR_FLOAT) as u32)
|
* Self::SCALING_FACTOR_FLOAT) as u32)
|
||||||
.min(self.maximum);
|
.min(self.maximum);
|
||||||
self.last_change = Dir::from_unnormalized(change.impulse).unwrap_or_default();
|
self.last_change = Dir::from_unnormalized(change.impulse).unwrap_or_default();
|
||||||
|
self.next_threshold = *self::Poise::POISE_THRESHOLDS
|
||||||
|
.iter()
|
||||||
|
.find(|&&threshold| self.current() > threshold)
|
||||||
|
.unwrap_or(&self::Poise::POISE_THRESHOLDS[0]);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,6 +341,7 @@ image_ids! {
|
|||||||
energy_frame: "voxygen.element.ui.skillbar.energy_frame",
|
energy_frame: "voxygen.element.ui.skillbar.energy_frame",
|
||||||
poise_bg: "voxygen.element.ui.skillbar.poise_bg",
|
poise_bg: "voxygen.element.ui.skillbar.poise_bg",
|
||||||
poise_frame: "voxygen.element.ui.skillbar.poise_frame",
|
poise_frame: "voxygen.element.ui.skillbar.poise_frame",
|
||||||
|
poise_tick: "voxygen.element.ui.skillbar.bar_content",
|
||||||
m1_ico: "voxygen.element.ui.generic.icons.m1",
|
m1_ico: "voxygen.element.ui.generic.icons.m1",
|
||||||
m2_ico: "voxygen.element.ui.generic.icons.m2",
|
m2_ico: "voxygen.element.ui.generic.icons.m2",
|
||||||
m_scroll_ico: "voxygen.element.ui.generic.icons.m_scroll",
|
m_scroll_ico: "voxygen.element.ui.generic.icons.m_scroll",
|
||||||
|
@ -16,6 +16,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
GlobalState,
|
GlobalState,
|
||||||
};
|
};
|
||||||
|
use conrod_core::widget::Line;
|
||||||
use i18n::Localization;
|
use i18n::Localization;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
@ -84,6 +85,7 @@ widget_ids! {
|
|||||||
// Poise-Bar
|
// Poise-Bar
|
||||||
poise_alignment,
|
poise_alignment,
|
||||||
poise_filling,
|
poise_filling,
|
||||||
|
poise_tick,
|
||||||
poise_txt_alignment,
|
poise_txt_alignment,
|
||||||
poise_txt_bg,
|
poise_txt_bg,
|
||||||
poise_txt,
|
poise_txt,
|
||||||
@ -481,6 +483,15 @@ impl<'a> Skillbar<'a> {
|
|||||||
.color(Some(POISE_COLOR))
|
.color(Some(POISE_COLOR))
|
||||||
.top_left_with_margins_on(state.ids.poise_alignment, 0.0, 0.0)
|
.top_left_with_margins_on(state.ids.poise_alignment, 0.0, 0.0)
|
||||||
.set(state.ids.poise_filling, ui);
|
.set(state.ids.poise_filling, ui);
|
||||||
|
Image::new(self.imgs.poise_tick)
|
||||||
|
.w_h(3.0, 10.0)
|
||||||
|
.color(Some(Color::Rgba(0.70, 0.90, 0.0, 1.0)))
|
||||||
|
.top_left_with_margins_on(
|
||||||
|
state.ids.poise_alignment,
|
||||||
|
0.0,
|
||||||
|
319.0f64 * (self.poise.next_threshold() / self.poise.maximum()) as f64,
|
||||||
|
)
|
||||||
|
.set(state.ids.poise_tick, ui);
|
||||||
Image::new(self.imgs.poise_frame)
|
Image::new(self.imgs.poise_frame)
|
||||||
.w_h(323.0, 16.0)
|
.w_h(323.0, 16.0)
|
||||||
.color(Some(UI_HIGHLIGHT_0))
|
.color(Some(UI_HIGHLIGHT_0))
|
||||||
|
Reference in New Issue
Block a user