Rebased and implemented a TODO

Converted individual poise bar tick values to a list.

Co-authored-by: Samuel Keiffer <samuelkeiffer@gmail.com>
This commit is contained in:
kitswas 2022-10-19 19:44:13 +05:30
parent c83ec87d6a
commit e472632426

View File

@ -3,8 +3,7 @@ use super::{
img_ids::{Imgs, ImgsRot},
item_imgs::ItemImgs,
slots, util, BarNumbers, HudInfo, ShortcutNumbers, BLACK, CRITICAL_HP_COLOR, HP_COLOR,
LOW_HP_COLOR, POISEBAR_TICK_COLOR, POISE_COLOR, QUALITY_EPIC, STAMINA_COLOR, TEXT_COLOR,
UI_HIGHLIGHT_0,
LOW_HP_COLOR, POISE_COLOR, QUALITY_EPIC, STAMINA_COLOR, TEXT_COLOR, UI_HIGHLIGHT_0,
};
use crate::{
game_input::GameInput,
@ -85,10 +84,7 @@ widget_ids! {
// Poise-Bar
poise_alignment,
poise_filling,
poise_tick_1, // TODO: Use a list instead
poise_tick_2,
poise_tick_3,
poise_tick_4,
poise_ticks[],
poise_txt_alignment,
poise_txt_bg,
poise_txt,
@ -475,13 +471,6 @@ impl<'a> Skillbar<'a> {
if show_poise && !self.health.is_dead {
let offset = 17.0;
let poise_ticks = [
state.ids.poise_tick_1,
state.ids.poise_tick_2,
state.ids.poise_tick_3,
state.ids.poise_tick_4,
];
let poise_colour = match self.poise.previous_state {
self::PoiseState::KnockedDown => BLACK,
self::PoiseState::Dazed => Color::Rgba(0.25, 0.0, 0.15, 1.0),
@ -502,16 +491,16 @@ impl<'a> Skillbar<'a> {
.color(Some(poise_colour))
.top_left_with_margins_on(state.ids.poise_alignment, 0.0, 0.0)
.set(state.ids.poise_filling, ui);
for (i, threshold) in self::Poise::POISE_THRESHOLDS.iter().enumerate() {
for i in 0..state.ids.poise_ticks.len() {
Image::new(self.imgs.poise_tick)
.w_h(3.0, 10.0)
.color(Some(POISEBAR_TICK_COLOR))
.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 * (*threshold / self.poise.maximum()) as f64,
319.0f64 * (self::Poise::POISE_THRESHOLDS[i] / self.poise.maximum()) as f64,
)
.set(poise_ticks[i], ui);
.set(state.ids.poise_ticks[i], ui);
}
Image::new(self.imgs.poise_frame)
.w_h(323.0, 16.0)
@ -896,13 +885,22 @@ impl<'a> Widget for Skillbar<'a> {
}
// Skillbar
// Poise bar ticks
state.update(|s| {
s.ids.poise_ticks.resize(
self::Poise::POISE_THRESHOLDS.len(),
&mut ui.widget_id_generator(),
)
});
// Alignment and BG
let alignment_size = 40.0 * 12.0 + slot_offset * 11.0;
Rectangle::fill_with([alignment_size, 80.0], color::TRANSPARENT)
.mid_bottom_with_margin_on(ui.window, 10.0)
.set(state.ids.frame, ui);
// Health and Energy bar
// Health, Energy and Poise bars
self.show_stat_bars(state, ui);
// Slots