Add setting to always show energy bars

This commit is contained in:
Bafon 2021-09-15 12:04:44 +00:00 committed by Monty Marz
parent 350e835d7d
commit b910c1dd9c
7 changed files with 43 additions and 6 deletions

View File

@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added a setting to always show health and energy bars
### Changed
- Made dungeon tiers 3, 4, and 5 more common

View File

@ -32,6 +32,7 @@
"hud.settings.speech_bubble_dark_mode": "Speech Bubble Dark Mode",
"hud.settings.speech_bubble_icon": "Speech Bubble Icon",
"hud.settings.energybar_numbers": "Energybar Numbers",
"hud.settings.always_show_bars": "Always show Energybars",
"hud.settings.values": "Values",
"hud.settings.percentages": "Percentages",
"hud.settings.chat": "Chat",

View File

@ -127,10 +127,11 @@ impl<'a> Widget for BuffsBar<'a> {
.desc_text_color(TEXT_COLOR);
if let BuffPosition::Bar = buff_position {
let decayed_health = 1.0 - self.health.maximum() / self.health.base_max();
let show_health = (self.health.current() - self.health.maximum()).abs()
> Health::HEALTH_EPSILON
let show_health = self.global_state.settings.interface.always_show_bars
|| (self.health.current() - self.health.maximum()).abs() > Health::HEALTH_EPSILON
|| decayed_health > 0.0;
let show_energy = self.energy.current() != self.energy.maximum();
let show_energy = self.global_state.settings.interface.always_show_bars
|| self.energy.current() != self.energy.maximum();
let offset = if show_energy && show_health {
140.0
} else if show_health || show_energy {

View File

@ -62,6 +62,8 @@ widget_ids! {
show_bar_numbers_values_text,
show_bar_numbers_percentage_button,
show_bar_numbers_percentage_text,
always_show_bars_button,
always_show_bars_label,
//
show_shortcuts_button,
show_shortcuts_text,
@ -981,6 +983,30 @@ impl<'a> Widget for Interface<'a> {
.color(TEXT_COLOR)
.set(state.ids.show_bar_numbers_percentage_text, ui);
// Always show energy bars
let always_show_bars = ToggleButton::new(
self.global_state.settings.interface.always_show_bars,
self.imgs.checkbox,
self.imgs.checkbox_checked,
)
.w_h(18.0, 18.0)
.down_from(state.ids.show_bar_numbers_percentage_button, 20.0)
.hover_images(self.imgs.checkbox_mo, self.imgs.checkbox_checked_mo)
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
.set(state.ids.always_show_bars_button, ui);
if always_show_bars != self.global_state.settings.interface.always_show_bars {
events.push(ToggleAlwaysShowBars(always_show_bars));
}
Text::new(self.localized_strings.get("hud.settings.always_show_bars"))
.right_from(state.ids.always_show_bars_button, 10.0)
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.graphics_for(state.ids.always_show_bars_button)
.color(TEXT_COLOR)
.set(state.ids.always_show_bars_label, ui);
// Reset the interface settings to the default settings
if Button::image(self.imgs.button)
.w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)

View File

@ -377,9 +377,10 @@ impl<'a> Skillbar<'a> {
let hp_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8;
let crit_hp_color: Color = Color::Rgba(0.79, 0.19, 0.17, hp_ani);
let bar_values = self.global_state.settings.interface.bar_numbers;
let show_health =
(self.health.current() - self.health.maximum()).abs() > Health::HEALTH_EPSILON;
let show_energy = self.energy.current() != self.energy.maximum();
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
|| self.energy.current() != self.energy.maximum();
let decayed_health = 1.0 - self.health.maximum() as f64 / self.health.base_max() as f64;
if show_health && !self.health.is_dead || decayed_health > 0.0 {

View File

@ -106,6 +106,7 @@ pub enum Interface {
Intro(Intro),
ToggleXpBar(XpBar),
ToggleBarNumbers(BarNumbers),
ToggleAlwaysShowBars(bool),
ToggleShortcutNumbers(ShortcutNumbers),
BuffPosition(BuffPosition),
@ -468,6 +469,9 @@ impl SettingsChange {
Interface::ToggleBarNumbers(bar_numbers) => {
settings.interface.bar_numbers = bar_numbers;
},
Interface::ToggleAlwaysShowBars(always_show_bars) => {
settings.interface.always_show_bars = always_show_bars;
},
Interface::ToggleShortcutNumbers(shortcut_numbers) => {
settings.interface.shortcut_numbers = shortcut_numbers;
},

View File

@ -25,6 +25,7 @@ pub struct InterfaceSettings {
pub shortcut_numbers: ShortcutNumbers,
pub buff_position: BuffPosition,
pub bar_numbers: BarNumbers,
pub always_show_bars: bool,
pub ui_scale: ScaleMode,
pub map_zoom: f64,
pub map_drag: Vec2<f64>,
@ -62,6 +63,7 @@ impl Default for InterfaceSettings {
shortcut_numbers: ShortcutNumbers::On,
buff_position: BuffPosition::Bar,
bar_numbers: BarNumbers::Values,
always_show_bars: false,
ui_scale: ScaleMode::RelativeToWindow([1920.0, 1080.0].into()),
map_zoom: 10.0,
map_drag: Vec2 { x: 0.0, y: 0.0 },