2019-08-18 18:07:21 +00:00
|
|
|
use super::{
|
2020-04-12 01:20:48 +00:00
|
|
|
hotbar,
|
|
|
|
img_ids::{Imgs, ImgsRot},
|
|
|
|
item_imgs::ItemImgs,
|
2022-07-06 09:20:18 +00:00
|
|
|
slots, util, BarNumbers, HudInfo, ShortcutNumbers, BLACK, CRITICAL_HP_COLOR, HP_COLOR,
|
2022-09-02 05:26:41 +00:00
|
|
|
LOW_HP_COLOR, POISEBAR_TICK_COLOR, POISE_COLOR, QUALITY_EPIC, STAMINA_COLOR, TEXT_COLOR,
|
|
|
|
UI_HIGHLIGHT_0,
|
2019-08-18 18:07:21 +00:00
|
|
|
};
|
2020-02-01 20:39:39 +00:00
|
|
|
use crate::{
|
2021-07-21 11:23:45 +00:00
|
|
|
game_input::GameInput,
|
2021-07-22 19:57:04 +00:00
|
|
|
hud::{ComboFloater, Position, PositionSpecifier},
|
2020-04-11 06:33:06 +00:00
|
|
|
ui::{
|
2020-05-25 18:11:39 +00:00
|
|
|
fonts::Fonts,
|
2020-04-11 06:33:06 +00:00
|
|
|
slot::{ContentSize, SlotMaker},
|
2021-03-16 12:19:31 +00:00
|
|
|
ImageFrame, ItemTooltip, ItemTooltipManager, ItemTooltipable, Tooltip, TooltipManager,
|
|
|
|
Tooltipable,
|
2020-04-11 06:33:06 +00:00
|
|
|
},
|
2020-02-01 20:39:39 +00:00
|
|
|
GlobalState,
|
|
|
|
};
|
2021-07-29 18:47:45 +00:00
|
|
|
use i18n::Localization;
|
2022-08-06 17:47:45 +00:00
|
|
|
use std::borrow::Cow;
|
2021-03-24 21:02:01 +00:00
|
|
|
|
|
|
|
use client::{self, Client};
|
2021-03-04 20:43:58 +00:00
|
|
|
use common::comp::{
|
|
|
|
self,
|
2021-11-11 22:55:14 +00:00
|
|
|
ability::AbilityInput,
|
2021-11-10 22:25:37 +00:00
|
|
|
item::{ItemDesc, MaterialStatManifest},
|
2022-09-01 09:39:08 +00:00
|
|
|
Ability, ActiveAbilities, Body, Energy, Health, Inventory, Poise, SkillSet,
|
2020-01-18 01:10:12 +00:00
|
|
|
};
|
2019-05-04 06:07:23 +00:00
|
|
|
use conrod_core::{
|
2019-08-18 18:07:21 +00:00
|
|
|
color,
|
|
|
|
widget::{self, Button, Image, Rectangle, Text},
|
2021-07-20 20:28:41 +00:00
|
|
|
widget_ids, Color, Colorable, Positionable, Sizeable, UiCell, Widget, WidgetCommon,
|
2019-05-04 06:07:23 +00:00
|
|
|
};
|
2020-04-11 06:33:06 +00:00
|
|
|
use vek::*;
|
2019-05-04 06:07:23 +00:00
|
|
|
|
|
|
|
widget_ids! {
|
|
|
|
struct Ids {
|
2020-10-11 21:52:16 +00:00
|
|
|
// Death message
|
2019-08-18 18:07:21 +00:00
|
|
|
death_message_1,
|
|
|
|
death_message_2,
|
2019-09-05 17:28:33 +00:00
|
|
|
death_message_1_bg,
|
|
|
|
death_message_2_bg,
|
2020-10-11 21:52:16 +00:00
|
|
|
death_bg,
|
|
|
|
// Level up message
|
|
|
|
level_up,
|
|
|
|
level_down,
|
|
|
|
level_align,
|
|
|
|
level_message,
|
|
|
|
level_message_bg,
|
|
|
|
// Hurt BG
|
|
|
|
hurt_bg,
|
|
|
|
// Skillbar
|
|
|
|
alignment,
|
|
|
|
bg,
|
|
|
|
frame,
|
2020-12-31 02:59:55 +00:00
|
|
|
bg_health,
|
|
|
|
frame_health,
|
2021-07-31 05:03:12 +00:00
|
|
|
bg_energy,
|
|
|
|
frame_energy,
|
2022-09-01 09:39:08 +00:00
|
|
|
bg_poise,
|
|
|
|
frame_poise,
|
2020-10-11 21:52:16 +00:00
|
|
|
m1_ico,
|
|
|
|
m2_ico,
|
|
|
|
// Level
|
|
|
|
level_bg,
|
|
|
|
level,
|
|
|
|
// Exp-Bar
|
|
|
|
exp_alignment,
|
|
|
|
exp_filling,
|
|
|
|
// HP-Bar
|
|
|
|
hp_alignment,
|
|
|
|
hp_filling,
|
2021-03-24 19:36:36 +00:00
|
|
|
hp_decayed,
|
2020-10-11 21:52:16 +00:00
|
|
|
hp_txt_alignment,
|
|
|
|
hp_txt_bg,
|
|
|
|
hp_txt,
|
2021-03-25 18:43:48 +00:00
|
|
|
decay_overlay,
|
2021-07-31 05:03:12 +00:00
|
|
|
// Energy-Bar
|
|
|
|
energy_alignment,
|
|
|
|
energy_filling,
|
|
|
|
energy_txt_alignment,
|
|
|
|
energy_txt_bg,
|
|
|
|
energy_txt,
|
2022-09-01 09:39:08 +00:00
|
|
|
// Poise-Bar
|
|
|
|
poise_alignment,
|
|
|
|
poise_filling,
|
2022-09-02 05:26:41 +00:00
|
|
|
poise_tick_1, // TODO: Use a list instead
|
|
|
|
poise_tick_2,
|
|
|
|
poise_tick_3,
|
|
|
|
poise_tick_4,
|
2022-09-01 09:39:08 +00:00
|
|
|
poise_txt_alignment,
|
|
|
|
poise_txt_bg,
|
|
|
|
poise_txt,
|
2021-03-04 01:24:54 +00:00
|
|
|
// Combo Counter
|
|
|
|
combo_align,
|
|
|
|
combo_bg,
|
|
|
|
combo,
|
2020-10-11 21:52:16 +00:00
|
|
|
// Slots
|
2019-08-18 18:07:21 +00:00
|
|
|
m1_slot,
|
|
|
|
m1_slot_bg,
|
|
|
|
m1_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
m1_text_bg,
|
2020-01-17 22:00:00 +00:00
|
|
|
m1_slot_act,
|
2019-08-18 18:07:21 +00:00
|
|
|
m1_content,
|
|
|
|
m2_slot,
|
|
|
|
m2_slot_bg,
|
|
|
|
m2_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
m2_text_bg,
|
2020-01-17 22:00:00 +00:00
|
|
|
m2_slot_act,
|
2019-08-18 18:07:21 +00:00
|
|
|
m2_content,
|
|
|
|
slot1,
|
|
|
|
slot1_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot1_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot2,
|
|
|
|
slot2_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot2_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot3,
|
|
|
|
slot3_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot3_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot4,
|
|
|
|
slot4_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot4_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot5,
|
|
|
|
slot5_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot5_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot6,
|
|
|
|
slot6_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot6_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot7,
|
|
|
|
slot7_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot7_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot8,
|
|
|
|
slot8_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot8_text_bg,
|
2019-08-18 18:07:21 +00:00
|
|
|
slot9,
|
|
|
|
slot9_text,
|
2020-04-09 19:42:05 +00:00
|
|
|
slot9_text_bg,
|
|
|
|
slot10,
|
|
|
|
slot10_text,
|
|
|
|
slot10_text_bg,
|
2019-05-04 06:07:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-19 17:52:12 +00:00
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
struct SlotEntry {
|
|
|
|
slot: hotbar::Slot,
|
|
|
|
widget_id: widget::Id,
|
|
|
|
position: PositionSpecifier,
|
|
|
|
game_input: GameInput,
|
|
|
|
shortcut_position: PositionSpecifier,
|
|
|
|
shortcut_position_bg: PositionSpecifier,
|
|
|
|
shortcut_widget_ids: (widget::Id, widget::Id),
|
|
|
|
}
|
|
|
|
|
2021-07-20 17:58:31 +00:00
|
|
|
fn slot_entries(state: &State, slot_offset: f64) -> [SlotEntry; 10] {
|
2021-07-19 17:52:12 +00:00
|
|
|
use PositionSpecifier::*;
|
|
|
|
|
|
|
|
[
|
|
|
|
// 1th - 5th slots
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::One,
|
|
|
|
widget_id: state.ids.slot1,
|
|
|
|
position: BottomLeftWithMarginsOn(state.ids.frame, 0.0, 0.0),
|
|
|
|
game_input: GameInput::Slot1,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot1_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot1, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot1_text, state.ids.slot1_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Two,
|
|
|
|
widget_id: state.ids.slot2,
|
|
|
|
position: RightFrom(state.ids.slot1, slot_offset),
|
|
|
|
game_input: GameInput::Slot2,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot2_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot2, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot2_text, state.ids.slot2_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Three,
|
|
|
|
widget_id: state.ids.slot3,
|
|
|
|
position: RightFrom(state.ids.slot2, slot_offset),
|
|
|
|
game_input: GameInput::Slot3,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot3_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot3, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot3_text, state.ids.slot3_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Four,
|
|
|
|
widget_id: state.ids.slot4,
|
|
|
|
position: RightFrom(state.ids.slot3, slot_offset),
|
|
|
|
game_input: GameInput::Slot4,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot4_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot4, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot4_text, state.ids.slot4_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Five,
|
|
|
|
widget_id: state.ids.slot5,
|
|
|
|
position: RightFrom(state.ids.slot4, slot_offset),
|
|
|
|
game_input: GameInput::Slot5,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot5_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot5, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot5_text, state.ids.slot5_text_bg),
|
|
|
|
},
|
|
|
|
// 6th - 10th slots
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Six,
|
|
|
|
widget_id: state.ids.slot6,
|
|
|
|
position: RightFrom(state.ids.m2_slot_bg, slot_offset),
|
|
|
|
game_input: GameInput::Slot6,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot6_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot6, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot6_text, state.ids.slot6_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Seven,
|
|
|
|
widget_id: state.ids.slot7,
|
|
|
|
position: RightFrom(state.ids.slot6, slot_offset),
|
|
|
|
game_input: GameInput::Slot7,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot7_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot7, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot7_text, state.ids.slot7_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Eight,
|
|
|
|
widget_id: state.ids.slot8,
|
|
|
|
position: RightFrom(state.ids.slot7, slot_offset),
|
|
|
|
game_input: GameInput::Slot8,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot8_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot8, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot8_text, state.ids.slot8_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Nine,
|
|
|
|
widget_id: state.ids.slot9,
|
|
|
|
position: RightFrom(state.ids.slot8, slot_offset),
|
|
|
|
game_input: GameInput::Slot9,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot9_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot9, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot9_text, state.ids.slot9_text_bg),
|
|
|
|
},
|
|
|
|
SlotEntry {
|
|
|
|
slot: hotbar::Slot::Ten,
|
|
|
|
widget_id: state.ids.slot10,
|
|
|
|
position: RightFrom(state.ids.slot9, slot_offset),
|
|
|
|
game_input: GameInput::Slot10,
|
|
|
|
shortcut_position: BottomLeftWithMarginsOn(state.ids.slot10_text_bg, 1.0, 1.0),
|
|
|
|
shortcut_position_bg: TopRightWithMarginsOn(state.ids.slot10, 3.0, 5.0),
|
|
|
|
shortcut_widget_ids: (state.ids.slot10_text, state.ids.slot10_text_bg),
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2019-05-04 06:07:23 +00:00
|
|
|
#[derive(WidgetCommon)]
|
|
|
|
pub struct Skillbar<'a> {
|
2021-03-24 21:02:01 +00:00
|
|
|
client: &'a Client,
|
2022-07-06 09:20:18 +00:00
|
|
|
info: &'a HudInfo,
|
2019-08-18 18:07:21 +00:00
|
|
|
global_state: &'a GlobalState,
|
2019-05-04 06:07:23 +00:00
|
|
|
imgs: &'a Imgs,
|
2020-04-11 06:33:06 +00:00
|
|
|
item_imgs: &'a ItemImgs,
|
2020-05-25 18:11:39 +00:00
|
|
|
fonts: &'a Fonts,
|
2020-04-12 01:20:48 +00:00
|
|
|
rot_imgs: &'a ImgsRot,
|
2020-10-31 22:34:08 +00:00
|
|
|
health: &'a Health,
|
2021-01-08 19:12:09 +00:00
|
|
|
inventory: &'a Inventory,
|
2020-01-12 16:43:25 +00:00
|
|
|
energy: &'a Energy,
|
2022-09-01 09:39:08 +00:00
|
|
|
poise: &'a Poise,
|
2021-04-23 06:56:11 +00:00
|
|
|
skillset: &'a SkillSet,
|
2022-01-20 20:26:35 +00:00
|
|
|
active_abilities: Option<&'a ActiveAbilities>,
|
2021-11-10 02:20:41 +00:00
|
|
|
body: &'a Body,
|
2020-10-12 21:45:51 +00:00
|
|
|
// character_state: &'a CharacterState,
|
|
|
|
// controller: &'a ControllerInputs,
|
2020-04-11 06:33:06 +00:00
|
|
|
hotbar: &'a hotbar::State,
|
2020-04-12 01:20:48 +00:00
|
|
|
tooltip_manager: &'a mut TooltipManager,
|
2021-03-02 00:45:02 +00:00
|
|
|
item_tooltip_manager: &'a mut ItemTooltipManager,
|
2020-04-11 06:33:06 +00:00
|
|
|
slot_manager: &'a mut slots::SlotManager,
|
2020-05-25 18:11:39 +00:00
|
|
|
localized_strings: &'a Localization,
|
2019-12-30 12:16:35 +00:00
|
|
|
pulse: f32,
|
2019-05-04 06:07:23 +00:00
|
|
|
#[conrod(common_builder)]
|
2020-10-12 21:45:51 +00:00
|
|
|
common: widget::CommonBuilder,
|
2021-02-23 20:29:27 +00:00
|
|
|
msm: &'a MaterialStatManifest,
|
2021-03-04 20:43:58 +00:00
|
|
|
combo: Option<ComboFloater>,
|
2019-05-04 06:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Skillbar<'a> {
|
2021-12-07 23:33:46 +00:00
|
|
|
#[allow(clippy::too_many_arguments)]
|
2019-08-18 18:07:21 +00:00
|
|
|
pub fn new(
|
2021-03-24 21:02:01 +00:00
|
|
|
client: &'a Client,
|
2022-07-06 09:20:18 +00:00
|
|
|
info: &'a HudInfo,
|
2019-08-18 18:07:21 +00:00
|
|
|
global_state: &'a GlobalState,
|
|
|
|
imgs: &'a Imgs,
|
2020-04-11 06:33:06 +00:00
|
|
|
item_imgs: &'a ItemImgs,
|
2020-05-25 18:11:39 +00:00
|
|
|
fonts: &'a Fonts,
|
2020-04-12 01:20:48 +00:00
|
|
|
rot_imgs: &'a ImgsRot,
|
2020-10-31 22:34:08 +00:00
|
|
|
health: &'a Health,
|
2021-01-08 19:12:09 +00:00
|
|
|
inventory: &'a Inventory,
|
2020-01-12 16:43:25 +00:00
|
|
|
energy: &'a Energy,
|
2022-09-01 09:39:08 +00:00
|
|
|
poise: &'a Poise,
|
2021-04-23 06:56:11 +00:00
|
|
|
skillset: &'a SkillSet,
|
2022-01-20 20:26:35 +00:00
|
|
|
active_abilities: Option<&'a ActiveAbilities>,
|
2021-11-10 02:20:41 +00:00
|
|
|
body: &'a Body,
|
2020-10-12 21:45:51 +00:00
|
|
|
// character_state: &'a CharacterState,
|
2019-12-30 12:16:35 +00:00
|
|
|
pulse: f32,
|
2020-10-12 21:45:51 +00:00
|
|
|
// controller: &'a ControllerInputs,
|
2020-04-11 06:33:06 +00:00
|
|
|
hotbar: &'a hotbar::State,
|
2020-04-12 01:20:48 +00:00
|
|
|
tooltip_manager: &'a mut TooltipManager,
|
2021-03-02 00:45:02 +00:00
|
|
|
item_tooltip_manager: &'a mut ItemTooltipManager,
|
2020-04-11 06:33:06 +00:00
|
|
|
slot_manager: &'a mut slots::SlotManager,
|
2020-05-25 18:11:39 +00:00
|
|
|
localized_strings: &'a Localization,
|
2021-02-23 20:29:27 +00:00
|
|
|
msm: &'a MaterialStatManifest,
|
2021-03-04 20:43:58 +00:00
|
|
|
combo: Option<ComboFloater>,
|
2019-08-18 18:07:21 +00:00
|
|
|
) -> Self {
|
2019-08-29 00:32:19 +00:00
|
|
|
Self {
|
2021-03-24 21:02:01 +00:00
|
|
|
client,
|
2022-07-06 09:20:18 +00:00
|
|
|
info,
|
2019-12-30 13:56:42 +00:00
|
|
|
global_state,
|
2019-05-04 06:07:23 +00:00
|
|
|
imgs,
|
2020-04-11 06:33:06 +00:00
|
|
|
item_imgs,
|
2019-12-30 13:56:42 +00:00
|
|
|
fonts,
|
2020-04-12 01:20:48 +00:00
|
|
|
rot_imgs,
|
2020-10-31 22:34:08 +00:00
|
|
|
health,
|
2021-01-08 19:12:09 +00:00
|
|
|
inventory,
|
2020-10-12 21:45:51 +00:00
|
|
|
energy,
|
2022-09-01 09:39:08 +00:00
|
|
|
poise,
|
2021-04-23 06:56:11 +00:00
|
|
|
skillset,
|
2021-11-12 03:37:37 +00:00
|
|
|
active_abilities,
|
2021-11-10 02:20:41 +00:00
|
|
|
body,
|
2019-05-04 06:07:23 +00:00
|
|
|
common: widget::CommonBuilder::default(),
|
2020-10-12 21:45:51 +00:00
|
|
|
// character_state,
|
2019-12-30 12:16:35 +00:00
|
|
|
pulse,
|
2020-10-12 21:45:51 +00:00
|
|
|
// controller,
|
2020-04-11 06:33:06 +00:00
|
|
|
hotbar,
|
2020-04-12 01:20:48 +00:00
|
|
|
tooltip_manager,
|
2021-03-02 00:45:02 +00:00
|
|
|
item_tooltip_manager,
|
2020-04-11 06:33:06 +00:00
|
|
|
slot_manager,
|
2020-04-12 01:20:48 +00:00
|
|
|
localized_strings,
|
2021-02-23 20:29:27 +00:00
|
|
|
msm,
|
2021-03-03 20:34:42 +00:00
|
|
|
combo,
|
2019-05-04 06:07:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 19:57:04 +00:00
|
|
|
fn show_death_message(&self, state: &State, ui: &mut UiCell) {
|
|
|
|
let localized_strings = self.localized_strings;
|
|
|
|
let key_layout = &self.global_state.window.key_layout;
|
2019-05-04 06:07:23 +00:00
|
|
|
|
2021-07-22 19:57:04 +00:00
|
|
|
if let Some(key) = self
|
|
|
|
.global_state
|
|
|
|
.settings
|
|
|
|
.controls
|
|
|
|
.get_binding(GameInput::Respawn)
|
|
|
|
{
|
2022-08-23 11:14:29 +00:00
|
|
|
Text::new(&localized_strings.get_msg("hud-you_died"))
|
2021-07-22 19:57:04 +00:00
|
|
|
.middle_of(ui.window)
|
|
|
|
.font_size(self.fonts.cyri.scale(50))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
|
|
|
|
.set(state.ids.death_message_1_bg, ui);
|
2022-08-06 17:47:45 +00:00
|
|
|
let respawn_msg =
|
|
|
|
localized_strings.get_msg_ctx("hud-press_key_to_respawn", &i18n::fluent_args! {
|
|
|
|
"key" => key.display_string(key_layout)
|
|
|
|
});
|
|
|
|
Text::new(&respawn_msg)
|
|
|
|
.mid_bottom_with_margin_on(state.ids.death_message_1_bg, -120.0)
|
|
|
|
.font_size(self.fonts.cyri.scale(30))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
|
|
|
|
.set(state.ids.death_message_2_bg, ui);
|
2022-08-23 11:14:29 +00:00
|
|
|
Text::new(&localized_strings.get_msg("hud-you_died"))
|
2021-07-22 19:57:04 +00:00
|
|
|
.bottom_left_with_margins_on(state.ids.death_message_1_bg, 2.0, 2.0)
|
|
|
|
.font_size(self.fonts.cyri.scale(50))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(CRITICAL_HP_COLOR)
|
|
|
|
.set(state.ids.death_message_1, ui);
|
2022-08-06 17:47:45 +00:00
|
|
|
Text::new(&respawn_msg)
|
|
|
|
.bottom_left_with_margins_on(state.ids.death_message_2_bg, 2.0, 2.0)
|
|
|
|
.font_size(self.fonts.cyri.scale(30))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(CRITICAL_HP_COLOR)
|
|
|
|
.set(state.ids.death_message_2, ui);
|
2019-05-04 06:07:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-22 19:57:04 +00:00
|
|
|
fn show_stat_bars(&self, state: &State, ui: &mut UiCell) {
|
2022-09-01 09:39:08 +00:00
|
|
|
let (hp_percentage, energy_percentage, poise_percentage): (f64, f64, f64) =
|
|
|
|
if self.health.is_dead {
|
|
|
|
(0.0, 0.0, 0.0)
|
|
|
|
} else {
|
|
|
|
let max_hp = f64::from(self.health.base_max().max(self.health.maximum()));
|
|
|
|
let current_hp = f64::from(self.health.current());
|
|
|
|
(
|
|
|
|
current_hp / max_hp * 100.0,
|
|
|
|
f64::from(self.energy.fraction() * 100.0),
|
|
|
|
f64::from(self.poise.fraction() * 100.0),
|
|
|
|
)
|
|
|
|
};
|
2019-08-18 18:07:21 +00:00
|
|
|
|
2021-07-20 19:28:16 +00:00
|
|
|
// Animation timer
|
|
|
|
let hp_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8;
|
2019-12-30 12:16:35 +00:00
|
|
|
let crit_hp_color: Color = Color::Rgba(0.79, 0.19, 0.17, hp_ani);
|
2021-07-22 19:57:04 +00:00
|
|
|
let bar_values = self.global_state.settings.interface.bar_numbers;
|
2021-09-15 12:04:44 +00:00
|
|
|
let show_health = self.global_state.settings.interface.always_show_bars
|
|
|
|
|| (self.health.current() - self.health.maximum()).abs() > Health::HEALTH_EPSILON;
|
|
|
|
let show_energy = self.global_state.settings.interface.always_show_bars
|
2021-09-14 02:16:01 +00:00
|
|
|
|| (self.energy.current() - self.energy.maximum()).abs() > Energy::ENERGY_EPSILON;
|
2022-09-01 09:39:08 +00:00
|
|
|
let show_poise = self.global_state.settings.interface.always_show_bars
|
|
|
|
|| (self.poise.current() - self.poise.maximum()).abs() > Poise::POISE_EPSILON;
|
2021-03-25 18:43:48 +00:00
|
|
|
let decayed_health = 1.0 - self.health.maximum() as f64 / self.health.base_max() as f64;
|
2020-12-31 02:59:55 +00:00
|
|
|
|
2021-03-25 18:43:48 +00:00
|
|
|
if show_health && !self.health.is_dead || decayed_health > 0.0 {
|
2021-01-16 17:01:57 +00:00
|
|
|
let offset = 1.0;
|
2020-12-31 02:59:55 +00:00
|
|
|
Image::new(self.imgs.health_bg)
|
|
|
|
.w_h(484.0, 24.0)
|
|
|
|
.mid_top_with_margin_on(state.ids.frame, -offset)
|
|
|
|
.set(state.ids.bg_health, ui);
|
|
|
|
Rectangle::fill_with([480.0, 18.0], color::TRANSPARENT)
|
|
|
|
.top_left_with_margins_on(state.ids.bg_health, 2.0, 2.0)
|
|
|
|
.set(state.ids.hp_alignment, ui);
|
|
|
|
let health_col = match hp_percentage as u8 {
|
|
|
|
0..=20 => crit_hp_color,
|
|
|
|
21..=40 => LOW_HP_COLOR,
|
|
|
|
_ => HP_COLOR,
|
|
|
|
};
|
|
|
|
Image::new(self.imgs.bar_content)
|
|
|
|
.w_h(480.0 * hp_percentage / 100.0, 18.0)
|
|
|
|
.color(Some(health_col))
|
|
|
|
.top_left_with_margins_on(state.ids.hp_alignment, 0.0, 0.0)
|
|
|
|
.set(state.ids.hp_filling, ui);
|
2021-03-25 01:12:15 +00:00
|
|
|
|
2021-03-24 19:36:36 +00:00
|
|
|
if decayed_health > 0.0 {
|
2021-03-28 00:05:05 +00:00
|
|
|
let decay_bar_len = 480.0 * decayed_health;
|
2021-03-24 19:36:36 +00:00
|
|
|
Image::new(self.imgs.bar_content)
|
2021-03-25 01:12:15 +00:00
|
|
|
.w_h(decay_bar_len, 18.0)
|
|
|
|
.color(Some(QUALITY_EPIC))
|
2021-03-24 19:36:36 +00:00
|
|
|
.top_right_with_margins_on(state.ids.hp_alignment, 0.0, 0.0)
|
2021-03-25 01:12:15 +00:00
|
|
|
.crop_kids()
|
2021-03-25 18:43:48 +00:00
|
|
|
.set(state.ids.hp_decayed, ui);
|
2021-03-25 01:12:15 +00:00
|
|
|
|
2021-03-25 18:43:48 +00:00
|
|
|
Image::new(self.imgs.decayed_bg)
|
|
|
|
.w_h(480.0, 18.0)
|
|
|
|
.color(Some(Color::Rgba(0.58, 0.29, 0.93, (hp_ani + 0.6).min(1.0))))
|
|
|
|
.top_left_with_margins_on(state.ids.hp_alignment, 0.0, 0.0)
|
|
|
|
.parent(state.ids.hp_decayed)
|
|
|
|
.set(state.ids.decay_overlay, ui);
|
2021-03-24 19:36:36 +00:00
|
|
|
}
|
2020-12-31 02:59:55 +00:00
|
|
|
Image::new(self.imgs.health_frame)
|
|
|
|
.w_h(484.0, 24.0)
|
|
|
|
.color(Some(UI_HIGHLIGHT_0))
|
|
|
|
.middle_of(state.ids.bg_health)
|
|
|
|
.set(state.ids.frame_health, ui);
|
|
|
|
}
|
2021-07-31 05:03:12 +00:00
|
|
|
if show_energy && !self.health.is_dead {
|
2021-03-25 18:43:48 +00:00
|
|
|
let offset = if show_health || decayed_health > 0.0 {
|
|
|
|
34.0
|
|
|
|
} else {
|
|
|
|
1.0
|
|
|
|
};
|
2021-07-31 05:03:12 +00:00
|
|
|
Image::new(self.imgs.energy_bg)
|
2020-12-31 02:59:55 +00:00
|
|
|
.w_h(323.0, 16.0)
|
|
|
|
.mid_top_with_margin_on(state.ids.frame, -offset)
|
2021-07-31 05:03:12 +00:00
|
|
|
.set(state.ids.bg_energy, ui);
|
2020-12-31 02:59:55 +00:00
|
|
|
Rectangle::fill_with([319.0, 10.0], color::TRANSPARENT)
|
2021-07-31 05:03:12 +00:00
|
|
|
.top_left_with_margins_on(state.ids.bg_energy, 2.0, 2.0)
|
|
|
|
.set(state.ids.energy_alignment, ui);
|
2020-12-31 02:59:55 +00:00
|
|
|
Image::new(self.imgs.bar_content)
|
|
|
|
.w_h(319.0 * energy_percentage / 100.0, 10.0)
|
|
|
|
.color(Some(STAMINA_COLOR))
|
2021-07-31 05:03:12 +00:00
|
|
|
.top_left_with_margins_on(state.ids.energy_alignment, 0.0, 0.0)
|
|
|
|
.set(state.ids.energy_filling, ui);
|
|
|
|
Image::new(self.imgs.energy_frame)
|
2020-12-31 02:59:55 +00:00
|
|
|
.w_h(323.0, 16.0)
|
|
|
|
.color(Some(UI_HIGHLIGHT_0))
|
2021-07-31 05:03:12 +00:00
|
|
|
.middle_of(state.ids.bg_energy)
|
|
|
|
.set(state.ids.frame_energy, ui);
|
2020-12-31 02:59:55 +00:00
|
|
|
}
|
2022-09-01 09:39:08 +00:00
|
|
|
if show_poise && !self.health.is_dead {
|
2022-09-01 05:16:56 +00:00
|
|
|
let offset = 17.0;
|
2022-09-02 05:26:41 +00:00
|
|
|
|
|
|
|
let poise_ticks = [
|
|
|
|
state.ids.poise_tick_1,
|
|
|
|
state.ids.poise_tick_2,
|
|
|
|
state.ids.poise_tick_3,
|
|
|
|
state.ids.poise_tick_4,
|
|
|
|
];
|
|
|
|
|
2022-09-01 09:39:08 +00:00
|
|
|
Image::new(self.imgs.poise_bg)
|
|
|
|
.w_h(323.0, 14.0)
|
|
|
|
.mid_top_with_margin_on(state.ids.frame, -offset)
|
|
|
|
.set(state.ids.bg_poise, ui);
|
|
|
|
Rectangle::fill_with([319.0, 10.0], color::TRANSPARENT)
|
|
|
|
.top_left_with_margins_on(state.ids.bg_poise, 2.0, 2.0)
|
|
|
|
.set(state.ids.poise_alignment, ui);
|
|
|
|
Image::new(self.imgs.bar_content)
|
|
|
|
.w_h(319.0 * poise_percentage / 100.0, 10.0)
|
|
|
|
.color(Some(POISE_COLOR))
|
|
|
|
.top_left_with_margins_on(state.ids.poise_alignment, 0.0, 0.0)
|
|
|
|
.set(state.ids.poise_filling, ui);
|
2022-09-02 05:26:41 +00:00
|
|
|
for (i, threshold) in self::Poise::POISE_THRESHOLDS.iter().enumerate() {
|
|
|
|
Image::new(self.imgs.poise_tick)
|
|
|
|
.w_h(3.0, 10.0)
|
|
|
|
.color(Some(POISEBAR_TICK_COLOR))
|
|
|
|
.top_left_with_margins_on(
|
|
|
|
state.ids.poise_alignment,
|
|
|
|
0.0,
|
|
|
|
319.0f64 * (*threshold / self.poise.maximum()) as f64,
|
|
|
|
)
|
|
|
|
.set(poise_ticks[i], ui);
|
|
|
|
}
|
2022-09-01 09:39:08 +00:00
|
|
|
Image::new(self.imgs.poise_frame)
|
|
|
|
.w_h(323.0, 16.0)
|
|
|
|
.color(Some(UI_HIGHLIGHT_0))
|
|
|
|
.middle_of(state.ids.bg_poise)
|
|
|
|
.set(state.ids.frame_poise, ui);
|
|
|
|
}
|
2020-10-11 21:52:16 +00:00
|
|
|
// Bar Text
|
2021-07-20 19:28:16 +00:00
|
|
|
let bar_text = if self.health.is_dead {
|
|
|
|
Some((
|
2022-08-23 17:18:18 +00:00
|
|
|
self.localized_strings
|
|
|
|
.get_msg("hud-group-dead")
|
|
|
|
.into_owned(),
|
|
|
|
self.localized_strings
|
|
|
|
.get_msg("hud-group-dead")
|
|
|
|
.into_owned(),
|
2022-09-01 09:39:08 +00:00
|
|
|
self.localized_strings
|
|
|
|
.get_msg("hud-group-dead")
|
|
|
|
.into_owned(),
|
2021-07-20 19:28:16 +00:00
|
|
|
))
|
|
|
|
} else if let BarNumbers::Values = bar_values {
|
|
|
|
Some((
|
|
|
|
format!(
|
|
|
|
"{}/{}",
|
2021-09-09 04:07:17 +00:00
|
|
|
self.health.current().round().max(1.0) as u32, /* Don't show 0 health for
|
|
|
|
* living players */
|
|
|
|
self.health.maximum().round() as u32
|
2021-07-20 19:28:16 +00:00
|
|
|
),
|
|
|
|
format!(
|
|
|
|
"{}/{}",
|
2021-09-14 02:16:01 +00:00
|
|
|
self.energy.current().round() as u32,
|
|
|
|
self.energy.maximum().round() as u32
|
2021-07-20 19:28:16 +00:00
|
|
|
),
|
2022-09-02 05:26:41 +00:00
|
|
|
String::new(), // Don't obscure the tick mark
|
2021-07-20 19:28:16 +00:00
|
|
|
))
|
|
|
|
} else if let BarNumbers::Percent = bar_values {
|
|
|
|
Some((
|
|
|
|
format!("{}%", hp_percentage as u32),
|
|
|
|
format!("{}%", energy_percentage as u32),
|
2022-09-02 05:26:41 +00:00
|
|
|
String::new(), // Don't obscure the tick mark
|
2021-07-20 19:28:16 +00:00
|
|
|
))
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
2022-09-01 09:39:08 +00:00
|
|
|
if let Some((hp_txt, energy_txt, poise_txt)) = bar_text {
|
2021-07-22 19:57:04 +00:00
|
|
|
Text::new(&hp_txt)
|
|
|
|
.middle_of(state.ids.frame_health)
|
|
|
|
.font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
|
|
|
|
.set(state.ids.hp_txt_bg, ui);
|
|
|
|
Text::new(&hp_txt)
|
|
|
|
.bottom_left_with_margins_on(state.ids.hp_txt_bg, 2.0, 2.0)
|
|
|
|
.font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.ids.hp_txt, ui);
|
|
|
|
|
|
|
|
Text::new(&energy_txt)
|
2021-07-31 05:03:12 +00:00
|
|
|
.middle_of(state.ids.frame_energy)
|
2021-07-22 19:57:04 +00:00
|
|
|
.font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
|
2021-07-31 05:03:12 +00:00
|
|
|
.set(state.ids.energy_txt_bg, ui);
|
2021-07-22 19:57:04 +00:00
|
|
|
Text::new(&energy_txt)
|
2021-07-31 05:03:12 +00:00
|
|
|
.bottom_left_with_margins_on(state.ids.energy_txt_bg, 2.0, 2.0)
|
2021-07-22 19:57:04 +00:00
|
|
|
.font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(TEXT_COLOR)
|
2021-07-31 05:03:12 +00:00
|
|
|
.set(state.ids.energy_txt, ui);
|
2022-09-01 09:39:08 +00:00
|
|
|
|
|
|
|
Text::new(&poise_txt)
|
|
|
|
.middle_of(state.ids.frame_poise)
|
|
|
|
.font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
|
|
|
|
.set(state.ids.poise_txt_bg, ui);
|
|
|
|
Text::new(&poise_txt)
|
|
|
|
.bottom_left_with_margins_on(state.ids.poise_txt_bg, 2.0, 2.0)
|
|
|
|
.font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.ids.poise_txt, ui);
|
2020-10-11 21:52:16 +00:00
|
|
|
}
|
2021-07-22 19:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn show_slotbar(&mut self, state: &State, ui: &mut UiCell, slot_offset: f64) {
|
|
|
|
let shortcuts = self.global_state.settings.interface.shortcut_numbers;
|
|
|
|
let key_layout = &self.global_state.window.key_layout;
|
2021-07-20 19:28:16 +00:00
|
|
|
|
2021-07-20 17:58:31 +00:00
|
|
|
// TODO: avoid this
|
2021-11-10 02:20:41 +00:00
|
|
|
let content_source = (
|
|
|
|
self.hotbar,
|
|
|
|
self.inventory,
|
|
|
|
self.energy,
|
|
|
|
self.skillset,
|
2021-11-12 03:37:37 +00:00
|
|
|
self.active_abilities,
|
2021-11-10 02:20:41 +00:00
|
|
|
self.body,
|
|
|
|
);
|
2021-07-22 19:57:04 +00:00
|
|
|
|
2020-10-11 21:52:16 +00:00
|
|
|
let image_source = (self.item_imgs, self.imgs);
|
|
|
|
let mut slot_maker = SlotMaker {
|
|
|
|
// TODO: is a separate image needed for the frame?
|
2020-12-31 02:59:55 +00:00
|
|
|
empty_slot: self.imgs.skillbar_slot,
|
|
|
|
filled_slot: self.imgs.skillbar_slot,
|
2020-10-11 21:52:16 +00:00
|
|
|
selected_slot: self.imgs.inv_slot_sel,
|
|
|
|
background_color: None,
|
|
|
|
content_size: ContentSize {
|
|
|
|
width_height_ratio: 1.0,
|
|
|
|
max_fraction: 0.8, /* Changes the item image size by setting a maximum fraction
|
|
|
|
* of either the width or height */
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2020-10-11 21:52:16 +00:00
|
|
|
selected_content_scale: 1.0,
|
|
|
|
amount_font: self.fonts.cyri.conrod_id,
|
|
|
|
amount_margins: Vec2::new(1.0, 1.0),
|
|
|
|
amount_font_size: self.fonts.cyri.scale(12),
|
|
|
|
amount_text_color: TEXT_COLOR,
|
|
|
|
content_source: &content_source,
|
|
|
|
image_source: &image_source,
|
|
|
|
slot_manager: Some(self.slot_manager),
|
2021-02-16 01:05:54 +00:00
|
|
|
pulse: self.pulse,
|
2020-10-11 21:52:16 +00:00
|
|
|
};
|
2021-03-24 22:17:25 +00:00
|
|
|
|
|
|
|
// Tooltips
|
|
|
|
let tooltip = Tooltip::new({
|
2020-10-11 21:52:16 +00:00
|
|
|
// Edge images [t, b, r, l]
|
|
|
|
// Corner images [tr, tl, br, bl]
|
|
|
|
let edge = &self.rot_imgs.tt_side;
|
|
|
|
let corner = &self.rot_imgs.tt_corner;
|
|
|
|
ImageFrame::new(
|
|
|
|
[edge.cw180, edge.none, edge.cw270, edge.cw90],
|
|
|
|
[corner.none, corner.cw270, corner.cw90, corner.cw180],
|
|
|
|
Color::Rgba(0.08, 0.07, 0.04, 1.0),
|
|
|
|
5.0,
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.title_font_size(self.fonts.cyri.scale(15))
|
|
|
|
.parent(ui.window)
|
|
|
|
.desc_font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.desc_text_color(TEXT_COLOR);
|
2021-03-02 00:45:02 +00:00
|
|
|
|
2021-03-24 22:17:25 +00:00
|
|
|
let item_tooltip = ItemTooltip::new(
|
2021-03-24 21:02:01 +00:00
|
|
|
{
|
|
|
|
// Edge images [t, b, r, l]
|
|
|
|
// Corner images [tr, tl, br, bl]
|
|
|
|
let edge = &self.rot_imgs.tt_side;
|
|
|
|
let corner = &self.rot_imgs.tt_corner;
|
|
|
|
ImageFrame::new(
|
|
|
|
[edge.cw180, edge.none, edge.cw270, edge.cw90],
|
|
|
|
[corner.none, corner.cw270, corner.cw90, corner.cw180],
|
|
|
|
Color::Rgba(0.08, 0.07, 0.04, 1.0),
|
|
|
|
5.0,
|
|
|
|
)
|
|
|
|
},
|
|
|
|
self.client,
|
2022-07-06 09:20:18 +00:00
|
|
|
self.info,
|
2021-03-24 21:02:01 +00:00
|
|
|
self.imgs,
|
|
|
|
self.item_imgs,
|
|
|
|
self.pulse,
|
|
|
|
self.msm,
|
|
|
|
self.localized_strings,
|
|
|
|
)
|
|
|
|
.title_font_size(self.fonts.cyri.scale(20))
|
|
|
|
.parent(ui.window)
|
|
|
|
.desc_font_size(self.fonts.cyri.scale(12))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.desc_text_color(TEXT_COLOR);
|
|
|
|
|
|
|
|
let slot_content = |slot| {
|
2021-07-20 17:58:31 +00:00
|
|
|
let (hotbar, inventory, ..) = content_source;
|
|
|
|
hotbar.get(slot).and_then(|content| match content {
|
2021-12-16 18:37:15 +00:00
|
|
|
hotbar::SlotContents::Inventory(i, _) => inventory.get_by_hash(i),
|
2021-07-20 17:58:31 +00:00
|
|
|
_ => None,
|
|
|
|
})
|
2021-03-24 21:02:01 +00:00
|
|
|
};
|
|
|
|
|
2020-10-11 21:52:16 +00:00
|
|
|
// Helper
|
|
|
|
let tooltip_text = |slot| {
|
2021-11-28 04:32:24 +00:00
|
|
|
let (hotbar, inventory, _, skill_set, active_abilities, _) = content_source;
|
2021-07-20 17:58:31 +00:00
|
|
|
hotbar.get(slot).and_then(|content| match content {
|
2021-12-16 18:37:15 +00:00
|
|
|
hotbar::SlotContents::Inventory(i, _) => inventory
|
|
|
|
.get_by_hash(i)
|
2022-08-06 17:47:45 +00:00
|
|
|
.map(|item| (item.name(), Cow::Borrowed(item.description()))),
|
2021-11-12 03:37:37 +00:00
|
|
|
hotbar::SlotContents::Ability(i) => active_abilities
|
2022-01-20 20:26:35 +00:00
|
|
|
.and_then(|a| {
|
|
|
|
a.auxiliary_set(Some(inventory), Some(skill_set))
|
|
|
|
.get(i)
|
|
|
|
.and_then(|a| Ability::from(*a).ability_id(Some(inventory)))
|
|
|
|
})
|
2022-06-25 11:23:06 +00:00
|
|
|
.map(|id| util::ability_description(id, self.localized_strings)),
|
2021-07-20 17:58:31 +00:00
|
|
|
})
|
2020-10-11 21:52:16 +00:00
|
|
|
};
|
2021-07-19 17:52:12 +00:00
|
|
|
|
2020-12-31 02:59:55 +00:00
|
|
|
slot_maker.empty_slot = self.imgs.skillbar_slot;
|
|
|
|
slot_maker.selected_slot = self.imgs.skillbar_slot;
|
2021-07-22 19:57:04 +00:00
|
|
|
|
2021-07-20 17:58:31 +00:00
|
|
|
let slots = slot_entries(state, slot_offset);
|
2021-07-19 17:52:12 +00:00
|
|
|
for entry in slots {
|
|
|
|
let slot = slot_maker
|
|
|
|
.fabricate(entry.slot, [40.0; 2])
|
|
|
|
.filled_slot(self.imgs.skillbar_slot)
|
|
|
|
.position(entry.position);
|
|
|
|
// if there is an item attached, show item tooltip
|
|
|
|
if let Some(item) = slot_content(entry.slot) {
|
2021-10-14 02:54:59 +00:00
|
|
|
slot.with_item_tooltip(
|
|
|
|
self.item_tooltip_manager,
|
|
|
|
core::iter::once(item as &dyn ItemDesc),
|
|
|
|
&None,
|
|
|
|
&item_tooltip,
|
|
|
|
)
|
|
|
|
.set(entry.widget_id, ui);
|
2021-07-19 17:52:12 +00:00
|
|
|
// if we can gather some text to display, show it
|
|
|
|
} else if let Some((title, desc)) = tooltip_text(entry.slot) {
|
2022-08-06 17:47:45 +00:00
|
|
|
slot.with_tooltip(self.tooltip_manager, &title, &desc, &tooltip, TEXT_COLOR)
|
2021-07-19 17:52:12 +00:00
|
|
|
.set(entry.widget_id, ui);
|
|
|
|
// if not, just set slot
|
|
|
|
} else {
|
|
|
|
slot.set(entry.widget_id, ui);
|
|
|
|
}
|
|
|
|
|
|
|
|
// shortcuts
|
|
|
|
if let ShortcutNumbers::On = shortcuts {
|
|
|
|
if let Some(key) = &self
|
|
|
|
.global_state
|
|
|
|
.settings
|
|
|
|
.controls
|
|
|
|
.get_binding(entry.game_input)
|
|
|
|
{
|
|
|
|
let position = entry.shortcut_position;
|
|
|
|
let position_bg = entry.shortcut_position_bg;
|
|
|
|
let (id, id_bg) = entry.shortcut_widget_ids;
|
|
|
|
|
2022-06-25 21:27:20 +00:00
|
|
|
let key_desc = key.display_shortest(key_layout);
|
2021-07-19 17:52:12 +00:00
|
|
|
// shortcut text
|
|
|
|
Text::new(&key_desc)
|
|
|
|
.position(position)
|
|
|
|
.font_size(self.fonts.cyri.scale(8))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(id, ui);
|
|
|
|
// shortcut background
|
|
|
|
Text::new(&key_desc)
|
|
|
|
.position(position_bg)
|
|
|
|
.font_size(self.fonts.cyri.scale(8))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(BLACK)
|
|
|
|
.set(id_bg, ui);
|
|
|
|
}
|
|
|
|
}
|
2020-10-11 21:52:16 +00:00
|
|
|
}
|
|
|
|
// Slot M1
|
2020-12-31 02:59:55 +00:00
|
|
|
Image::new(self.imgs.skillbar_slot)
|
2020-10-11 21:52:16 +00:00
|
|
|
.w_h(40.0, 40.0)
|
2020-12-31 02:59:55 +00:00
|
|
|
.right_from(state.ids.slot5, slot_offset)
|
2020-10-12 21:45:51 +00:00
|
|
|
.set(state.ids.m1_slot_bg, ui);
|
2021-03-24 02:04:21 +00:00
|
|
|
|
2022-01-20 20:26:35 +00:00
|
|
|
let primary_ability_id = self
|
|
|
|
.active_abilities
|
|
|
|
.and_then(|a| Ability::from(a.primary).ability_id(Some(self.inventory)));
|
2021-03-24 02:04:21 +00:00
|
|
|
|
2021-11-10 22:25:37 +00:00
|
|
|
Button::image(
|
|
|
|
primary_ability_id.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)),
|
|
|
|
)
|
2020-10-11 21:52:16 +00:00
|
|
|
.w_h(36.0, 36.0)
|
2019-08-29 00:32:19 +00:00
|
|
|
.middle_of(state.ids.m1_slot_bg)
|
|
|
|
.set(state.ids.m1_content, ui);
|
2020-10-12 21:45:51 +00:00
|
|
|
// Slot M2
|
2020-12-31 02:59:55 +00:00
|
|
|
Image::new(self.imgs.skillbar_slot)
|
2020-10-12 21:45:51 +00:00
|
|
|
.w_h(40.0, 40.0)
|
2020-12-31 02:59:55 +00:00
|
|
|
.right_from(state.ids.m1_slot_bg, slot_offset)
|
2021-01-18 19:08:13 +00:00
|
|
|
.set(state.ids.m2_slot_bg, ui);
|
2020-01-17 22:00:00 +00:00
|
|
|
|
2022-01-20 20:26:35 +00:00
|
|
|
let secondary_ability_id = self
|
|
|
|
.active_abilities
|
|
|
|
.and_then(|a| Ability::from(a.secondary).ability_id(Some(self.inventory)));
|
2020-07-01 09:51:06 +00:00
|
|
|
|
2021-11-10 22:25:37 +00:00
|
|
|
Button::image(
|
|
|
|
secondary_ability_id.map_or(self.imgs.nothing, |id| util::ability_image(self.imgs, id)),
|
|
|
|
)
|
2020-10-11 21:52:16 +00:00
|
|
|
.w_h(36.0, 36.0)
|
2019-08-29 00:32:19 +00:00
|
|
|
.middle_of(state.ids.m2_slot_bg)
|
2021-11-10 22:25:37 +00:00
|
|
|
.image_color(
|
2020-11-27 16:27:09 +00:00
|
|
|
if self.energy.current()
|
2021-11-10 22:25:37 +00:00
|
|
|
>= self
|
2021-11-12 03:37:37 +00:00
|
|
|
.active_abilities
|
2022-01-20 20:26:35 +00:00
|
|
|
.and_then(|a| {
|
|
|
|
a.activate_ability(
|
|
|
|
AbilityInput::Secondary,
|
|
|
|
Some(self.inventory),
|
|
|
|
self.skillset,
|
|
|
|
Some(self.body),
|
|
|
|
)
|
|
|
|
})
|
2021-11-10 22:25:37 +00:00
|
|
|
.map_or(0.0, |(a, _)| a.get_energy_cost())
|
2020-11-27 16:27:09 +00:00
|
|
|
{
|
|
|
|
Color::Rgba(1.0, 1.0, 1.0, 1.0)
|
|
|
|
} else {
|
|
|
|
Color::Rgba(0.3, 0.3, 0.3, 0.8)
|
2021-11-10 22:25:37 +00:00
|
|
|
},
|
|
|
|
)
|
2019-08-29 00:32:19 +00:00
|
|
|
.set(state.ids.m2_content, ui);
|
2021-07-19 17:52:12 +00:00
|
|
|
|
2020-10-11 21:52:16 +00:00
|
|
|
// M1 and M2 icons
|
|
|
|
Image::new(self.imgs.m1_ico)
|
2020-10-12 21:45:51 +00:00
|
|
|
.w_h(16.0, 18.0)
|
2020-10-19 03:00:35 +00:00
|
|
|
.mid_bottom_with_margin_on(state.ids.m1_content, -11.0)
|
2020-10-11 21:52:16 +00:00
|
|
|
.set(state.ids.m1_ico, ui);
|
|
|
|
Image::new(self.imgs.m2_ico)
|
|
|
|
.w_h(16.0, 18.0)
|
2020-10-19 03:00:35 +00:00
|
|
|
.mid_bottom_with_margin_on(state.ids.m2_content, -11.0)
|
2020-10-11 21:52:16 +00:00
|
|
|
.set(state.ids.m2_ico, ui);
|
2021-07-22 19:57:04 +00:00
|
|
|
}
|
2021-03-04 01:24:54 +00:00
|
|
|
|
2021-07-22 19:57:04 +00:00
|
|
|
fn show_combo_counter(&self, combo: ComboFloater, state: &State, ui: &mut UiCell) {
|
|
|
|
if combo.combo > 0 {
|
|
|
|
let combo_txt = format!("{} Combo", combo.combo);
|
|
|
|
let combo_cnt = combo.combo as f32;
|
|
|
|
let time_since_last_update = comp::combo::COMBO_DECAY_START - combo.timer;
|
|
|
|
let alpha = (1.0 - time_since_last_update * 0.2).min(1.0) as f32;
|
|
|
|
let fnt_col = Color::Rgba(
|
|
|
|
// White -> Yellow -> Red text color gradient depending on count
|
|
|
|
(1.0 - combo_cnt / (combo_cnt + 20.0)).max(0.79),
|
|
|
|
(1.0 - combo_cnt / (combo_cnt + 80.0)).max(0.19),
|
|
|
|
(1.0 - combo_cnt / (combo_cnt + 5.0)).max(0.17),
|
|
|
|
alpha,
|
|
|
|
);
|
|
|
|
// Increase size for higher counts,
|
|
|
|
// "flash" on update by increasing the font size by 2.
|
|
|
|
let fnt_size = ((14.0 + combo.timer as f32 * 0.8).min(30.0)) as u32
|
|
|
|
+ if (time_since_last_update) < 0.1 { 2 } else { 0 };
|
|
|
|
|
|
|
|
Rectangle::fill_with([10.0, 10.0], color::TRANSPARENT)
|
|
|
|
.middle_of(ui.window)
|
|
|
|
.set(state.ids.combo_align, ui);
|
|
|
|
|
|
|
|
Text::new(combo_txt.as_str())
|
|
|
|
.mid_bottom_with_margin_on(
|
2021-07-19 17:52:12 +00:00
|
|
|
state.ids.combo_align,
|
|
|
|
-350.0 + time_since_last_update * -8.0,
|
2021-07-22 19:57:04 +00:00
|
|
|
)
|
|
|
|
.font_size(self.fonts.cyri.scale(fnt_size))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(Color::Rgba(0.0, 0.0, 0.0, alpha))
|
|
|
|
.set(state.ids.combo_bg, ui);
|
|
|
|
Text::new(combo_txt.as_str())
|
|
|
|
.bottom_right_with_margins_on(state.ids.combo_bg, 1.0, 1.0)
|
|
|
|
.font_size(self.fonts.cyri.scale(fnt_size))
|
|
|
|
.font_id(self.fonts.cyri.conrod_id)
|
|
|
|
.color(fnt_col)
|
|
|
|
.set(state.ids.combo, ui);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct State {
|
|
|
|
ids: Ids,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Widget for Skillbar<'a> {
|
|
|
|
type Event = ();
|
|
|
|
type State = State;
|
|
|
|
type Style = ();
|
|
|
|
|
|
|
|
fn init_state(&self, id_gen: widget::id::Generator) -> Self::State {
|
|
|
|
State {
|
|
|
|
ids: Ids::new(id_gen),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn style(&self) -> Self::Style {}
|
|
|
|
|
|
|
|
fn update(mut self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
|
|
|
common_base::prof_span!("Skillbar::update");
|
|
|
|
let widget::UpdateArgs { state, ui, .. } = args;
|
|
|
|
|
|
|
|
let slot_offset = 3.0;
|
|
|
|
|
|
|
|
// Death message
|
|
|
|
if self.health.is_dead {
|
|
|
|
self.show_death_message(state, ui);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Skillbar
|
|
|
|
// 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);
|
|
|
|
|
2021-07-31 05:03:12 +00:00
|
|
|
// Health and Energy bar
|
2021-07-22 19:57:04 +00:00
|
|
|
self.show_stat_bars(state, ui);
|
|
|
|
|
|
|
|
// Slots
|
|
|
|
self.show_slotbar(state, ui, slot_offset);
|
|
|
|
|
|
|
|
// Combo Counter
|
|
|
|
if let Some(combo) = self.combo {
|
|
|
|
self.show_combo_counter(combo, state, ui);
|
2021-03-04 01:24:54 +00:00
|
|
|
}
|
2020-10-11 21:52:16 +00:00
|
|
|
}
|
2019-05-04 06:07:23 +00:00
|
|
|
}
|