Added chat toggle

This commit is contained in:
Joshua Barretto 2021-06-21 20:16:03 +01:00
parent 8ab222bf80
commit b84708ca75
6 changed files with 74 additions and 38 deletions

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added debug line info to release builds, enhancing the usefulness of panic backtraces - Added debug line info to release builds, enhancing the usefulness of panic backtraces
- NPCs and animals can now make sounds in response to certain events - NPCs and animals can now make sounds in response to certain events
- Players can press H to greet others - Players can press H to greet others
- Ability to toggle chat visibility
### Changed ### Changed
- Entity-entity pushback is no longer applied in forced movement states like rolling and leaping. - Entity-entity pushback is no longer applied in forced movement states like rolling and leaping.

View File

@ -11,6 +11,7 @@
"hud.settings.help_window": "Help Window", "hud.settings.help_window": "Help Window",
"hud.settings.debug_info": "Debug Info", "hud.settings.debug_info": "Debug Info",
"hud.settings.show_hitboxes": "Show hitboxes", "hud.settings.show_hitboxes": "Show hitboxes",
"hud.settings.show_chat": "Show chat",
"hud.settings.tips_on_startup": "Tips-On-Startup", "hud.settings.tips_on_startup": "Tips-On-Startup",
"hud.settings.ui_scale": "UI-Scale", "hud.settings.ui_scale": "UI-Scale",
"hud.settings.relative_scaling": "Relative Scaling", "hud.settings.relative_scaling": "Relative Scaling",

View File

@ -2706,6 +2706,7 @@ impl Hud {
.retain(|m| !matches!(m.chat_type, comp::ChatType::Npc(_, _))); .retain(|m| !matches!(m.chat_type, comp::ChatType::Npc(_, _)));
// Chat box // Chat box
if global_state.settings.interface.toggle_chat {
for event in Chat::new( for event in Chat::new(
&mut self.new_messages, &mut self.new_messages,
&client, &client,
@ -2745,6 +2746,7 @@ impl Hud {
}, },
} }
} }
}
self.new_messages = VecDeque::new(); self.new_messages = VecDeque::new();
self.new_notifications = VecDeque::new(); self.new_notifications = VecDeque::new();

View File

@ -38,6 +38,8 @@ widget_ids! {
debug_button_label, debug_button_label,
hitboxes_button, hitboxes_button,
hitboxes_button_label, hitboxes_button_label,
chat_button,
chat_button_label,
ch_title, ch_title,
ch_transp_slider, ch_transp_slider,
ch_transp_value, ch_transp_value,
@ -266,9 +268,33 @@ impl<'a> Widget for Interface<'a> {
.color(TEXT_COLOR) .color(TEXT_COLOR)
.set(state.ids.hitboxes_button_label, ui); .set(state.ids.hitboxes_button_label, ui);
// Chat
let show_chat = ToggleButton::new(
self.global_state.settings.interface.toggle_chat,
self.imgs.checkbox,
self.imgs.checkbox_checked,
)
.w_h(18.0, 18.0)
.down_from(state.ids.hitboxes_button, 8.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.chat_button, ui);
if self.global_state.settings.interface.toggle_chat != show_chat {
events.push(ToggleChat(show_chat));
}
Text::new(&self.localized_strings.get("hud.settings.show_chat"))
.right_from(state.ids.chat_button, 10.0)
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.graphics_for(state.ids.chat_button)
.color(TEXT_COLOR)
.set(state.ids.chat_button_label, ui);
// Ui Scale // Ui Scale
Text::new(&self.localized_strings.get("hud.settings.ui_scale")) Text::new(&self.localized_strings.get("hud.settings.ui_scale"))
.down_from(state.ids.hitboxes_button, 20.0) .down_from(state.ids.chat_button, 20.0)
.font_size(self.fonts.cyri.scale(18)) .font_size(self.fonts.cyri.scale(18))
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.color(TEXT_COLOR) .color(TEXT_COLOR)

View File

@ -97,6 +97,7 @@ pub enum Interface {
ToggleHelp(bool), ToggleHelp(bool),
ToggleDebug(bool), ToggleDebug(bool),
ToggleHitboxes(bool), ToggleHitboxes(bool),
ToggleChat(bool),
ToggleTips(bool), ToggleTips(bool),
CrosshairTransp(f32), CrosshairTransp(f32),
@ -450,6 +451,9 @@ impl SettingsChange {
Interface::ToggleHitboxes(toggle_hitboxes) => { Interface::ToggleHitboxes(toggle_hitboxes) => {
settings.interface.toggle_hitboxes = toggle_hitboxes; settings.interface.toggle_hitboxes = toggle_hitboxes;
}, },
Interface::ToggleChat(toggle_chat) => {
settings.interface.toggle_chat = toggle_chat;
},
Interface::ToggleTips(loading_tips) => { Interface::ToggleTips(loading_tips) => {
settings.interface.loading_tips = loading_tips; settings.interface.loading_tips = loading_tips;
}, },

View File

@ -11,6 +11,7 @@ use vek::*;
pub struct InterfaceSettings { pub struct InterfaceSettings {
pub toggle_debug: bool, pub toggle_debug: bool,
pub toggle_hitboxes: bool, pub toggle_hitboxes: bool,
pub toggle_chat: bool,
pub sct: bool, pub sct: bool,
pub sct_player_batch: bool, pub sct_player_batch: bool,
pub sct_damage_batch: bool, pub sct_damage_batch: bool,
@ -46,6 +47,7 @@ impl Default for InterfaceSettings {
Self { Self {
toggle_debug: false, toggle_debug: false,
toggle_hitboxes: false, toggle_hitboxes: false,
toggle_chat: true,
sct: true, sct: true,
sct_player_batch: false, sct_player_batch: false,
sct_damage_batch: false, sct_damage_batch: false,