From 9b692d072f7323cb182b9b94b92b8a338ffaab5b Mon Sep 17 00:00:00 2001 From: kitswas <90329875+kitswas@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:14:11 +0530 Subject: [PATCH] Added checkbox in the settings for poisebar See [this message on Discord](https://discord.com/channels/449602562165833758/1014778601368997958/1033838446575370351). --- assets/voxygen/i18n/en/hud/settings.ftl | 1 + voxygen/src/hud/settings_window/interface.rs | 32 +++++++++++++++++++- voxygen/src/hud/skillbar.rs | 5 +-- voxygen/src/session/settings_change.rs | 4 +++ voxygen/src/settings/interface.rs | 2 ++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/assets/voxygen/i18n/en/hud/settings.ftl b/assets/voxygen/i18n/en/hud/settings.ftl index 847e428fc9..e60754abd1 100644 --- a/assets/voxygen/i18n/en/hud/settings.ftl +++ b/assets/voxygen/i18n/en/hud/settings.ftl @@ -29,6 +29,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-enable_poise_bar = Enable Poise bar hud-settings-experience_numbers = Experience Numbers hud-settings-accumulate_experience = Accumulate Experience Numbers hud-settings-values = Values diff --git a/voxygen/src/hud/settings_window/interface.rs b/voxygen/src/hud/settings_window/interface.rs index 8dab3486ff..2995fbbe6f 100644 --- a/voxygen/src/hud/settings_window/interface.rs +++ b/voxygen/src/hud/settings_window/interface.rs @@ -66,6 +66,8 @@ widget_ids! { show_bar_numbers_percentage_text, always_show_bars_button, always_show_bars_label, + enable_poise_bar_button, + enable_poise_bar_label, // show_shortcuts_button, show_shortcuts_text, @@ -1153,13 +1155,41 @@ impl<'a> Widget for Interface<'a> { .color(TEXT_COLOR) .set(state.ids.always_show_bars_label, ui); + // Enable poise bar + let enable_poise_bar = ToggleButton::new( + self.global_state.settings.interface.enable_poise_bar, + self.imgs.checkbox, + self.imgs.checkbox_checked, + ) + .w_h(18.0, 18.0) + .down_from(state.ids.always_show_bars_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.enable_poise_bar_button, ui); + + if enable_poise_bar != self.global_state.settings.interface.enable_poise_bar { + events.push(TogglePoiseBar(enable_poise_bar)); + } + + Text::new( + &self + .localized_strings + .get_msg("hud-settings-enable_poise_bar"), + ) + .right_from(state.ids.enable_poise_bar_button, 10.0) + .font_size(self.fonts.cyri.scale(14)) + .font_id(self.fonts.cyri.conrod_id) + .graphics_for(state.ids.enable_poise_bar_button) + .color(TEXT_COLOR) + .set(state.ids.enable_poise_bar_label, ui); + // Experience Numbers Text::new( &self .localized_strings .get_msg("hud-settings-experience_numbers"), ) - .down_from(state.ids.always_show_bars_button, 20.0) + .down_from(state.ids.enable_poise_bar_button, 20.0) .font_size(self.fonts.cyri.scale(18)) .font_id(self.fonts.cyri.conrod_id) .color(TEXT_COLOR) diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 263687fa3c..ac389f8d0b 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -399,8 +399,9 @@ impl<'a> Skillbar<'a> { || (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()).abs() > Energy::ENERGY_EPSILON; - let show_poise = self.global_state.settings.interface.always_show_bars - || (self.poise.current() - self.poise.maximum()).abs() > Poise::POISE_EPSILON; + let show_poise = self.global_state.settings.interface.enable_poise_bar + && (self.global_state.settings.interface.always_show_bars + || (self.poise.current() - self.poise.maximum()).abs() > Poise::POISE_EPSILON); 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 { diff --git a/voxygen/src/session/settings_change.rs b/voxygen/src/session/settings_change.rs index 4767b34939..7c3afcde43 100644 --- a/voxygen/src/session/settings_change.rs +++ b/voxygen/src/session/settings_change.rs @@ -122,6 +122,7 @@ pub enum Interface { ToggleXpBar(XpBar), ToggleBarNumbers(BarNumbers), ToggleAlwaysShowBars(bool), + TogglePoiseBar(bool), ToggleShortcutNumbers(ShortcutNumbers), BuffPosition(BuffPosition), @@ -571,6 +572,9 @@ impl SettingsChange { Interface::ToggleAlwaysShowBars(always_show_bars) => { settings.interface.always_show_bars = always_show_bars; }, + Interface::TogglePoiseBar(enable_poise_bar) => { + settings.interface.enable_poise_bar = enable_poise_bar; + }, Interface::ToggleShortcutNumbers(shortcut_numbers) => { settings.interface.shortcut_numbers = shortcut_numbers; }, diff --git a/voxygen/src/settings/interface.rs b/voxygen/src/settings/interface.rs index 66558e4ab8..518f462edb 100644 --- a/voxygen/src/settings/interface.rs +++ b/voxygen/src/settings/interface.rs @@ -30,6 +30,7 @@ pub struct InterfaceSettings { pub buff_position: BuffPosition, pub bar_numbers: BarNumbers, pub always_show_bars: bool, + pub enable_poise_bar: bool, pub ui_scale: ScaleMode, pub map_zoom: f64, pub map_show_topo_map: bool, @@ -73,6 +74,7 @@ impl Default for InterfaceSettings { buff_position: BuffPosition::Bar, bar_numbers: BarNumbers::Values, always_show_bars: false, + enable_poise_bar: false, ui_scale: ScaleMode::RelativeToWindow([1920.0, 1080.0].into()), map_zoom: 10.0, map_show_topo_map: true,