mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
move flashing lights to accessability settings tab
This commit is contained in:
parent
65098b8066
commit
1c9b502f69
@ -12,6 +12,7 @@ common-video = Graphics
|
||||
common-sound = Sound
|
||||
common-chat = Chat
|
||||
common-networking = Networking
|
||||
common-accessibility = Accessibility
|
||||
common-resume = Resume
|
||||
common-characters = Characters
|
||||
common-close = Close
|
||||
@ -42,6 +43,7 @@ common-sound_settings = Sound Settings
|
||||
common-language_settings = Language Settings
|
||||
common-chat_settings = Chat Settings
|
||||
common-networking_settings = Networking Settings
|
||||
common-accessibility_settings = Accessibility Settings
|
||||
common-connection_lost =
|
||||
Connection lost!
|
||||
Did the server restart?
|
||||
|
134
voxygen/src/hud/settings_window/accessibility.rs
Normal file
134
voxygen/src/hud/settings_window/accessibility.rs
Normal file
@ -0,0 +1,134 @@
|
||||
use crate::{
|
||||
hud::{img_ids::Imgs, TEXT_COLOR},
|
||||
session::settings_change::{Accessibility as AccessibilityChange, Accessibility::*},
|
||||
ui::{fonts::Fonts, ToggleButton},
|
||||
GlobalState, render::RenderMode,
|
||||
};
|
||||
use conrod_core::{
|
||||
color,
|
||||
widget::{self, Rectangle, Text},
|
||||
widget_ids, Colorable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||
};
|
||||
use i18n::Localization;
|
||||
|
||||
widget_ids! {
|
||||
struct Ids {
|
||||
window,
|
||||
window_r,
|
||||
flashing_lights_button,
|
||||
flashing_lights_label,
|
||||
flashing_lights_info_label,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(WidgetCommon)]
|
||||
pub struct Accessibility<'a> {
|
||||
global_state: &'a GlobalState,
|
||||
imgs: &'a Imgs,
|
||||
fonts: &'a Fonts,
|
||||
localized_strings: &'a Localization,
|
||||
#[conrod(common_builder)]
|
||||
common: widget::CommonBuilder,
|
||||
}
|
||||
impl<'a> Accessibility<'a> {
|
||||
pub fn new(
|
||||
global_state: &'a GlobalState,
|
||||
imgs: &'a Imgs,
|
||||
fonts: &'a Fonts,
|
||||
localized_strings: &'a Localization,
|
||||
) -> Self {
|
||||
Self {
|
||||
global_state,
|
||||
imgs,
|
||||
fonts,
|
||||
localized_strings,
|
||||
common: widget::CommonBuilder::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct State {
|
||||
ids: Ids,
|
||||
}
|
||||
|
||||
impl<'a> Widget for Accessibility<'a> {
|
||||
type Event = Vec<AccessibilityChange>;
|
||||
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(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
||||
common_base::prof_span!("Accessibility::update");
|
||||
let widget::UpdateArgs { state, ui, .. } = args;
|
||||
|
||||
let mut events = Vec::new();
|
||||
|
||||
Rectangle::fill_with(args.rect.dim(), color::TRANSPARENT)
|
||||
.xy(args.rect.xy())
|
||||
.graphics_for(args.id)
|
||||
.scroll_kids()
|
||||
.scroll_kids_vertically()
|
||||
.set(state.ids.window, ui);
|
||||
Rectangle::fill_with([args.rect.w() / 2.0, args.rect.h()], color::TRANSPARENT)
|
||||
.top_right()
|
||||
.parent(state.ids.window)
|
||||
.set(state.ids.window_r, ui);
|
||||
|
||||
// Get render mode
|
||||
let render_mode = &self.global_state.settings.graphics.render_mode;
|
||||
|
||||
// Disable flashing lights
|
||||
Text::new(
|
||||
&self
|
||||
.localized_strings
|
||||
.get_msg("hud-settings-flashing_lights"),
|
||||
)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.top_left_with_margins_on(state.ids.window, 10.0, 10.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.flashing_lights_label, ui);
|
||||
|
||||
let flashing_lights_enabled = ToggleButton::new(
|
||||
self.global_state
|
||||
.settings
|
||||
.graphics
|
||||
.render_mode
|
||||
.flashing_lights_enabled,
|
||||
self.imgs.checkbox,
|
||||
self.imgs.checkbox_checked,
|
||||
)
|
||||
.w_h(18.0, 18.0)
|
||||
.right_from(state.ids.flashing_lights_label, 10.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.flashing_lights_button, ui);
|
||||
|
||||
Text::new(
|
||||
&self
|
||||
.localized_strings
|
||||
.get_msg("hud-settings-flashing_lights_info"),
|
||||
)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.right_from(state.ids.flashing_lights_label, 32.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.flashing_lights_info_label, ui);
|
||||
|
||||
if render_mode.flashing_lights_enabled != flashing_lights_enabled {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
flashing_lights_enabled,
|
||||
..render_mode.clone()
|
||||
})));
|
||||
}
|
||||
|
||||
events
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ mod language;
|
||||
mod networking;
|
||||
mod sound;
|
||||
mod video;
|
||||
mod accessibility;
|
||||
|
||||
use crate::{
|
||||
hud::{img_ids::Imgs, Show, TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN},
|
||||
@ -41,6 +42,7 @@ widget_ids! {
|
||||
language,
|
||||
chat,
|
||||
networking,
|
||||
accessibility,
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,6 +59,7 @@ pub enum SettingsTab {
|
||||
Controls,
|
||||
Lang,
|
||||
Networking,
|
||||
Accessibility,
|
||||
}
|
||||
impl SettingsTab {
|
||||
fn name_key(&self) -> &str {
|
||||
@ -69,6 +72,7 @@ impl SettingsTab {
|
||||
SettingsTab::Sound => "common-sound",
|
||||
SettingsTab::Lang => "common-languages",
|
||||
SettingsTab::Networking => "common-networking",
|
||||
SettingsTab::Accessibility => "common-accessibility",
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,6 +86,7 @@ impl SettingsTab {
|
||||
SettingsTab::Sound => "common-sound_settings",
|
||||
SettingsTab::Lang => "common-language_settings",
|
||||
SettingsTab::Networking => "common-networking_settings",
|
||||
SettingsTab::Accessibility => "common-accessibility_settings",
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -350,6 +355,20 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
events.push(Event::SettingsChange(change.into()));
|
||||
}
|
||||
},
|
||||
SettingsTab::Accessibility => {
|
||||
for change in accessibility::Accessibility::new(
|
||||
global_state,
|
||||
imgs,
|
||||
fonts,
|
||||
localized_strings,
|
||||
)
|
||||
.top_left_with_margins_on(state.ids.settings_content_align, 0.0, 0.0)
|
||||
.wh_of(state.ids.settings_content_align)
|
||||
.set(state.ids.accessibility, ui)
|
||||
{
|
||||
events.push(Event::SettingsChange(change.into()));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
events
|
||||
|
@ -172,6 +172,11 @@ pub enum Networking {
|
||||
// option)
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Accessibility {
|
||||
ChangeRenderMode(Box<RenderMode>),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum SettingsChange {
|
||||
Audio(Audio),
|
||||
@ -183,6 +188,7 @@ pub enum SettingsChange {
|
||||
Interface(Interface),
|
||||
Language(Language),
|
||||
Networking(Networking),
|
||||
Accessibility(Accessibility),
|
||||
}
|
||||
|
||||
macro_rules! settings_change_from {
|
||||
@ -201,6 +207,7 @@ settings_change_from!(Graphics);
|
||||
settings_change_from!(Interface);
|
||||
settings_change_from!(Language);
|
||||
settings_change_from!(Networking);
|
||||
settings_change_from!(Accessibility);
|
||||
|
||||
impl SettingsChange {
|
||||
pub fn process(self, global_state: &mut GlobalState, session_state: &mut SessionState) {
|
||||
@ -734,6 +741,11 @@ impl SettingsChange {
|
||||
}
|
||||
},
|
||||
},
|
||||
SettingsChange::Accessibility(accessibility_change) => match accessibility_change {
|
||||
Accessibility::ChangeRenderMode(new_render_mode) => {
|
||||
change_render_mode(*new_render_mode, &mut global_state.window, settings);
|
||||
}
|
||||
},
|
||||
}
|
||||
global_state
|
||||
.settings
|
||||
|
Loading…
Reference in New Issue
Block a user