Add a dark mode to speech bubbles; consistantly use 'speech bubble' instead of 'chat bubble'

This commit is contained in:
CapsizeGlimmer 2020-05-24 21:29:47 -04:00 committed by Pfauenauge90
parent c65967ccdb
commit 3c07d02218
18 changed files with 227 additions and 92 deletions

BIN
assets/voxygen/element/frames/bubble_dark/bottom.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/bottom_left.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/bottom_right.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/left.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/mid.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/right.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/tail.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/top.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/top_left.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/frames/bubble_dark/top_right.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -238,6 +238,7 @@ Enjoy your stay in the World of Veloren."#,
"hud.settings.cumulated_damage": "Cumulated Damage",
"hud.settings.incoming_damage": "Incoming Damage",
"hud.settings.cumulated_incoming_damage": "Cumulated Incoming Damage",
"hud.settings.speech_bubble_dark_mode": "Speech Bubble Dark Mode",
"hud.settings.energybar_numbers": "Energybar Numbers",
"hud.settings.values": "Values",
"hud.settings.percentages": "Percentages",

View File

@ -86,7 +86,7 @@ impl Default for Activity {
fn default() -> Self { Activity::Idle(Vec2::zero()) }
}
/// Default duration in seconds of chat bubbles
/// Default duration in seconds of speech bubbles
pub const SPEECH_BUBBLE_DURATION: f64 = 5.0;
/// Adds a speech bubble to the entity

View File

@ -272,17 +272,28 @@ image_ids! {
progress_frame: "voxygen.element.frames.progress_bar",
progress: "voxygen.element.misc_bg.progress",
// Chat bubbles
chat_bubble_top_left: "voxygen.element.frames.bubble.top_left",
chat_bubble_top: "voxygen.element.frames.bubble.top",
chat_bubble_top_right: "voxygen.element.frames.bubble.top_right",
chat_bubble_left: "voxygen.element.frames.bubble.left",
chat_bubble_mid: "voxygen.element.frames.bubble.mid",
chat_bubble_right: "voxygen.element.frames.bubble.right",
chat_bubble_bottom_left: "voxygen.element.frames.bubble.bottom_left",
chat_bubble_bottom: "voxygen.element.frames.bubble.bottom",
chat_bubble_bottom_right: "voxygen.element.frames.bubble.bottom_right",
chat_bubble_tail: "voxygen.element.frames.bubble.tail",
// Speech bubbles
speech_bubble_top_left: "voxygen.element.frames.bubble.top_left",
speech_bubble_top: "voxygen.element.frames.bubble.top",
speech_bubble_top_right: "voxygen.element.frames.bubble.top_right",
speech_bubble_left: "voxygen.element.frames.bubble.left",
speech_bubble_mid: "voxygen.element.frames.bubble.mid",
speech_bubble_right: "voxygen.element.frames.bubble.right",
speech_bubble_bottom_left: "voxygen.element.frames.bubble.bottom_left",
speech_bubble_bottom: "voxygen.element.frames.bubble.bottom",
speech_bubble_bottom_right: "voxygen.element.frames.bubble.bottom_right",
speech_bubble_tail: "voxygen.element.frames.bubble.tail",
dark_bubble_top_left: "voxygen.element.frames.bubble_dark.top_left",
dark_bubble_top: "voxygen.element.frames.bubble_dark.top",
dark_bubble_top_right: "voxygen.element.frames.bubble_dark.top_right",
dark_bubble_left: "voxygen.element.frames.bubble_dark.left",
dark_bubble_mid: "voxygen.element.frames.bubble_dark.mid",
dark_bubble_right: "voxygen.element.frames.bubble_dark.right",
dark_bubble_bottom_left: "voxygen.element.frames.bubble_dark.bottom_left",
dark_bubble_bottom: "voxygen.element.frames.bubble_dark.bottom",
dark_bubble_bottom_right: "voxygen.element.frames.bubble_dark.bottom_right",
dark_bubble_tail: "voxygen.element.frames.bubble_dark.tail",
<BlankGraphic>
nothing: (),

View File

@ -235,6 +235,7 @@ pub enum Event {
Sct(bool),
SctPlayerBatch(bool),
SctDamageBatch(bool),
SpeechBubbleDarkMode(bool),
ToggleDebug(bool),
UiScale(ScaleChange),
CharacterSelection,
@ -944,13 +945,14 @@ impl Hud {
);
let ingame_pos = pos + Vec3::unit_z() * height_offset;
// Chat bubble, name, level, and hp bars
// Speech bubble, name, level, and hp bars
overhead::Overhead::new(
&name,
bubble,
stats,
energy,
own_level,
&global_state.settings.gameplay,
self.pulse,
&self.imgs,
&self.fonts,
@ -1626,6 +1628,9 @@ impl Hud {
.set(self.ids.settings_window, ui_widgets)
{
match event {
settings_window::Event::SpeechBubbleDarkMode(sbdm) => {
events.push(Event::SpeechBubbleDarkMode(sbdm));
},
settings_window::Event::Sct(sct) => {
events.push(Event::Sct(sct));
},

View File

@ -1,5 +1,8 @@
use super::{img_ids::Imgs, HP_COLOR, LOW_HP_COLOR, MANA_COLOR};
use crate::ui::{fonts::ConrodVoxygenFonts, Ingameable};
use crate::{
settings::GameplaySettings,
ui::{fonts::ConrodVoxygenFonts, Ingameable},
};
use common::comp::{Energy, SpeechBubble, Stats};
use conrod_core::{
position::Align,
@ -9,19 +12,19 @@ use conrod_core::{
widget_ids! {
struct Ids {
// Chat bubble
chat_bubble_text,
chat_bubble_text2,
chat_bubble_top_left,
chat_bubble_top,
chat_bubble_top_right,
chat_bubble_left,
chat_bubble_mid,
chat_bubble_right,
chat_bubble_bottom_left,
chat_bubble_bottom,
chat_bubble_bottom_right,
chat_bubble_tail,
// Speech bubble
speech_bubble_text,
speech_bubble_text2,
speech_bubble_top_left,
speech_bubble_top,
speech_bubble_top_right,
speech_bubble_left,
speech_bubble_mid,
speech_bubble_right,
speech_bubble_bottom_left,
speech_bubble_bottom,
speech_bubble_bottom_right,
speech_bubble_tail,
// Name
name_bg,
@ -46,6 +49,7 @@ pub struct Overhead<'a> {
stats: &'a Stats,
energy: &'a Energy,
own_level: u32,
settings: &'a GameplaySettings,
pulse: f32,
imgs: &'a Imgs,
fonts: &'a ConrodVoxygenFonts,
@ -60,6 +64,7 @@ impl<'a> Overhead<'a> {
stats: &'a Stats,
energy: &'a Energy,
own_level: u32,
settings: &'a GameplaySettings,
pulse: f32,
imgs: &'a Imgs,
fonts: &'a ConrodVoxygenFonts,
@ -70,6 +75,7 @@ impl<'a> Overhead<'a> {
stats,
energy,
own_level,
settings,
pulse,
imgs,
fonts,
@ -130,77 +136,122 @@ impl<'a> Widget for Overhead<'a> {
.x_y(0.0, MANA_BAR_Y + 50.0)
.set(state.ids.name, ui);
// Speech bubble
if let Some(bubble) = self.bubble {
// Speech bubble
let dark_mode = self.settings.speech_bubble_dark_mode;
let mut text = Text::new(&bubble.message)
.font_id(self.fonts.cyri.conrod_id)
.font_size(18)
.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
.up_from(state.ids.name, 10.0)
.x_align_to(state.ids.name, Align::Middle)
.parent(id);
text = if dark_mode {
text.color(Color::Rgba(1.0, 1.0, 1.0, 1.0))
} else {
text.color(Color::Rgba(0.0, 0.0, 0.0, 1.0))
};
if let Some(w) = text.get_w(ui) {
if w > 250.0 {
text = text.w(250.0);
}
}
Image::new(self.imgs.chat_bubble_top_left)
.w_h(10.0, 10.0)
.top_left_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_top_left, ui);
Image::new(self.imgs.chat_bubble_top)
.h(10.0)
.w_of(state.ids.chat_bubble_text)
.mid_top_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_top, ui);
Image::new(self.imgs.chat_bubble_top_right)
.w_h(10.0, 10.0)
.top_right_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_top_right, ui);
Image::new(self.imgs.chat_bubble_left)
.w(10.0)
.h_of(state.ids.chat_bubble_text)
.mid_left_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_left, ui);
Image::new(self.imgs.chat_bubble_mid)
.wh_of(state.ids.chat_bubble_text)
.top_left_of(state.ids.chat_bubble_text)
.parent(id)
.set(state.ids.chat_bubble_mid, ui);
Image::new(self.imgs.chat_bubble_right)
.w(10.0)
.h_of(state.ids.chat_bubble_text)
.mid_right_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_right, ui);
Image::new(self.imgs.chat_bubble_bottom_left)
.w_h(10.0, 10.0)
.bottom_left_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_bottom_left, ui);
Image::new(self.imgs.chat_bubble_bottom)
.h(10.0)
.w_of(state.ids.chat_bubble_text)
.mid_bottom_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_bottom, ui);
Image::new(self.imgs.chat_bubble_bottom_right)
.w_h(10.0, 10.0)
.bottom_right_with_margin_on(state.ids.chat_bubble_text, -10.0)
.parent(id)
.set(state.ids.chat_bubble_bottom_right, ui);
let tail = Image::new(self.imgs.chat_bubble_tail)
.w_h(11.0, 16.0)
.mid_bottom_with_margin_on(state.ids.chat_bubble_text, -16.0)
.parent(id);
Image::new(if dark_mode {
self.imgs.dark_bubble_top_left
} else {
self.imgs.speech_bubble_top_left
})
.w_h(10.0, 10.0)
.top_left_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_top_left, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_top
} else {
self.imgs.speech_bubble_top
})
.h(10.0)
.w_of(state.ids.speech_bubble_text)
.mid_top_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_top, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_top_right
} else {
self.imgs.speech_bubble_top_right
})
.w_h(10.0, 10.0)
.top_right_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_top_right, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_left
} else {
self.imgs.speech_bubble_left
})
.w(10.0)
.h_of(state.ids.speech_bubble_text)
.mid_left_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_left, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_mid
} else {
self.imgs.speech_bubble_mid
})
.wh_of(state.ids.speech_bubble_text)
.top_left_of(state.ids.speech_bubble_text)
.parent(id)
.set(state.ids.speech_bubble_mid, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_right
} else {
self.imgs.speech_bubble_right
})
.w(10.0)
.h_of(state.ids.speech_bubble_text)
.mid_right_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_right, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_bottom_left
} else {
self.imgs.speech_bubble_bottom_left
})
.w_h(10.0, 10.0)
.bottom_left_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_bottom_left, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_bottom
} else {
self.imgs.speech_bubble_bottom
})
.h(10.0)
.w_of(state.ids.speech_bubble_text)
.mid_bottom_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_bottom, ui);
Image::new(if dark_mode {
self.imgs.dark_bubble_bottom_right
} else {
self.imgs.speech_bubble_bottom_right
})
.w_h(10.0, 10.0)
.bottom_right_with_margin_on(state.ids.speech_bubble_text, -10.0)
.parent(id)
.set(state.ids.speech_bubble_bottom_right, ui);
let tail = Image::new(if dark_mode {
self.imgs.dark_bubble_tail
} else {
self.imgs.speech_bubble_tail
})
.w_h(11.0, 16.0)
.mid_bottom_with_margin_on(state.ids.speech_bubble_text, -16.0)
.parent(id);
// Move text to front (conrod depth is lowest first; not a z-index)
tail.set(state.ids.chat_bubble_tail, ui);
tail.set(state.ids.speech_bubble_tail, ui);
text.depth(tail.get_depth() - 1.0)
.set(state.ids.chat_bubble_text, ui);
.set(state.ids.speech_bubble_text, ui);
}
let hp_percentage =

View File

@ -153,6 +153,8 @@ widget_ids! {
sct_num_dur_text,
sct_num_dur_slider,
sct_num_dur_value,
speech_bubble_dark_mode_text,
speech_bubble_dark_mode_button,
free_look_behavior_text,
free_look_behavior_list
}
@ -235,6 +237,7 @@ pub enum Event {
Sct(bool),
SctPlayerBatch(bool),
SctDamageBatch(bool),
SpeechBubbleDarkMode(bool),
ChangeLanguage(LanguageMetadata),
ChangeBinding(GameInput),
ChangeFreeLookBehavior(PressBehavior),
@ -943,17 +946,45 @@ impl<'a> Widget for SettingsWindow<'a> {
.set(state.ids.sct_batch_inc_text, ui);
}
// Speech bubble dark mode
let speech_bubble_dark_mode = ToggleButton::new(
self.global_state.settings.gameplay.speech_bubble_dark_mode,
self.imgs.checkbox,
self.imgs.checkbox_checked,
)
.down_from(
if self.global_state.settings.gameplay.sct {
state.ids.sct_batch_inc_radio
} else {
state.ids.sct_show_radio
},
20.0,
)
.x(0.0)
.w_h(18.0, 18.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.speech_bubble_dark_mode_button, ui);
if self.global_state.settings.gameplay.speech_bubble_dark_mode
!= speech_bubble_dark_mode
{
events.push(Event::SpeechBubbleDarkMode(speech_bubble_dark_mode));
}
Text::new(
&self
.localized_strings
.get("hud.settings.speech_bubble_dark_mode"),
)
.right_from(state.ids.speech_bubble_dark_mode_button, 10.0)
.font_size(self.fonts.cyri.scale(18))
.font_id(self.fonts.cyri.conrod_id)
.color(TEXT_COLOR)
.set(state.ids.speech_bubble_dark_mode_text, ui);
// Energybars Numbers
// Hotbar text
Text::new(&self.localized_strings.get("hud.settings.energybar_numbers"))
.down_from(
if self.global_state.settings.gameplay.sct {
state.ids.sct_batch_inc_radio
} else {
state.ids.sct_show_radio
},
20.0,
)
.down_from(state.ids.speech_bubble_dark_mode_button, 20.0)
.font_size(self.fonts.cyri.scale(18))
.font_id(self.fonts.cyri.conrod_id)
.color(TEXT_COLOR)

View File

@ -594,6 +594,10 @@ impl PlayState for SessionState {
global_state.settings.gameplay.sct_damage_batch = sct_damage_batch;
global_state.settings.save_to_file_warn();
},
HudEvent::SpeechBubbleDarkMode(sbdm) => {
global_state.settings.gameplay.speech_bubble_dark_mode = sbdm;
global_state.settings.save_to_file_warn();
},
HudEvent::ToggleDebug(toggle_debug) => {
global_state.settings.gameplay.toggle_debug = toggle_debug;
global_state.settings.save_to_file_warn();

View File

@ -455,6 +455,7 @@ pub struct GameplaySettings {
pub sct: bool,
pub sct_player_batch: bool,
pub sct_damage_batch: bool,
pub speech_bubble_dark_mode: bool,
pub mouse_y_inversion: bool,
pub smooth_pan_enable: bool,
pub crosshair_transp: f32,
@ -480,6 +481,7 @@ impl Default for GameplaySettings {
sct: true,
sct_player_batch: true,
sct_damage_batch: false,
speech_bubble_dark_mode: false,
crosshair_transp: 0.6,
chat_transp: 0.4,
crosshair_type: CrosshairType::Round,