Added tick mark for the upcoming threshold

This commit is contained in:
kitswas 2022-09-01 15:53:57 +05:30
parent be586aa84f
commit b21764c99f
3 changed files with 22 additions and 0 deletions

View File

@ -55,6 +55,8 @@ pub struct Poise {
pub regen_rate: f32,
/// Time that entity was last in a poise state
last_stun_time: Option<Time>,
/// Next threshold for the poise change
next_threshold: f32,
}
/// States to define effects of a poise change
@ -160,6 +162,9 @@ impl Poise {
/// Returns the current value of poise casted to a 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
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(),
regen_rate: 0.0,
last_stun_time: None,
next_threshold: self::Poise::POISE_THRESHOLDS[0],
}
}
@ -201,6 +207,10 @@ impl Poise {
* Self::SCALING_FACTOR_FLOAT) as u32)
.min(self.maximum);
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]);
},
}
}

View File

@ -341,6 +341,7 @@ image_ids! {
energy_frame: "voxygen.element.ui.skillbar.energy_frame",
poise_bg: "voxygen.element.ui.skillbar.poise_bg",
poise_frame: "voxygen.element.ui.skillbar.poise_frame",
poise_tick: "voxygen.element.ui.skillbar.bar_content",
m1_ico: "voxygen.element.ui.generic.icons.m1",
m2_ico: "voxygen.element.ui.generic.icons.m2",
m_scroll_ico: "voxygen.element.ui.generic.icons.m_scroll",

View File

@ -16,6 +16,7 @@ use crate::{
},
GlobalState,
};
use conrod_core::widget::Line;
use i18n::Localization;
use std::borrow::Cow;
@ -84,6 +85,7 @@ widget_ids! {
// Poise-Bar
poise_alignment,
poise_filling,
poise_tick,
poise_txt_alignment,
poise_txt_bg,
poise_txt,
@ -481,6 +483,15 @@ impl<'a> Skillbar<'a> {
.color(Some(POISE_COLOR))
.top_left_with_margins_on(state.ids.poise_alignment, 0.0, 0.0)
.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)
.w_h(323.0, 16.0)
.color(Some(UI_HIGHLIGHT_0))