Merge branch 'PersianKnight/ImprovedSettings' into 'master'

Persian knight/improved settings

See merge request veloren/veloren!1893
This commit is contained in:
Imbris 2021-03-13 19:45:36 +00:00
commit bc75a8b769
3 changed files with 28 additions and 20 deletions

View File

@ -2431,7 +2431,10 @@ impl Hud {
events.push(Event::SctDamageBatch(sct_damage_batch)); events.push(Event::SctDamageBatch(sct_damage_batch));
}, },
settings_window::Event::ToggleHelp => self.show.help = !self.show.help, settings_window::Event::ToggleHelp => self.show.help = !self.show.help,
settings_window::Event::ToggleDebug => self.show.debug = !self.show.debug, settings_window::Event::ToggleDebug => {
self.show.debug = !self.show.debug;
events.push(Event::ToggleDebug(self.show.debug));
},
settings_window::Event::ToggleTips(loading_tips) => { settings_window::Event::ToggleTips(loading_tips) => {
events.push(Event::ToggleTips(loading_tips)); events.push(Event::ToggleTips(loading_tips));
}, },
@ -2551,7 +2554,7 @@ impl Hud {
events.push(Event::ChangeStopAutoWalkOnInput(state)); events.push(Event::ChangeStopAutoWalkOnInput(state));
}, },
settings_window::Event::ResetInterfaceSettings => { settings_window::Event::ResetInterfaceSettings => {
self.show.help = true; self.show.help = false;
self.show.debug = false; self.show.debug = false;
events.push(Event::ResetInterfaceSettings); events.push(Event::ResetInterfaceSettings);
}, },

View File

@ -241,6 +241,9 @@ widget_ids! {
} }
} }
const RESET_BUTTONS_HEIGHT: f64 = 34.0;
const RESET_BUTTONS_WIDTH: f64 = 155.0;
pub enum SettingsTab { pub enum SettingsTab {
Interface, Interface,
Video, Video,
@ -1323,7 +1326,7 @@ impl<'a> Widget for SettingsWindow<'a> {
// Reset the interface settings to the default settings // Reset the interface settings to the default settings
if Button::image(self.imgs.button) if Button::image(self.imgs.button)
.w_h(31.0 * 5.0, 12.0 * 2.0) .w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
.hover_image(self.imgs.button_hover) .hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press) .press_image(self.imgs.button_press)
.down_from(state.ids.buff_pos_map_button, 12.0) .down_from(state.ids.buff_pos_map_button, 12.0)
@ -1653,7 +1656,7 @@ impl<'a> Widget for SettingsWindow<'a> {
// Reset the gameplay settings to the default settings // Reset the gameplay settings to the default settings
if Button::image(self.imgs.button) if Button::image(self.imgs.button)
.w_h(31.0 * 5.0, 12.0 * 2.0) .w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
.hover_image(self.imgs.button_hover) .hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press) .press_image(self.imgs.button_press)
.down_from(state.ids.free_look_behavior_list, 12.0) .down_from(state.ids.free_look_behavior_list, 12.0)
@ -1778,23 +1781,24 @@ impl<'a> Widget for SettingsWindow<'a> {
// Reset the KeyBindings settings to the default settings // Reset the KeyBindings settings to the default settings
if let Some(prev_id) = previous_element_id { if let Some(prev_id) = previous_element_id {
let key_string = self.localized_strings.get("hud.settings.reset_keybinds"); if Button::image(self.imgs.button)
let button_widget = Button::new() .w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
.label(&key_string) .hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.down_from(prev_id, 20.0)
.label(&self.localized_strings.get("hud.settings.reset_keybinds"))
.label_font_size(self.fonts.cyri.scale(14))
.label_color(TEXT_COLOR) .label_color(TEXT_COLOR)
.label_font_id(self.fonts.cyri.conrod_id) .label_font_id(self.fonts.cyri.conrod_id)
.label_font_size(self.fonts.cyri.scale(18)) .label_y(Relative::Scalar(2.0))
.down_from(prev_id, 20.0) .set(state.ids.reset_controls_button, ui)
.w(200.0) .was_clicked()
.rgba(0.0, 0.0, 0.0, 0.0) {
.border_rgba(0.0, 0.0, 0.0, 255.0)
.label_y(Relative::Scalar(3.0))
.set(state.ids.reset_controls_button, ui);
if button_widget.was_clicked() {
events.push(Event::ResetKeyBindings); events.push(Event::ResetKeyBindings);
} }
previous_element_id = Some(state.ids.reset_controls_button) previous_element_id = Some(state.ids.reset_controls_button)
} }
// Add an empty text widget to simulate some bottom margin, because conrod sucks // Add an empty text widget to simulate some bottom margin, because conrod sucks
if let Some(prev_id) = previous_element_id { if let Some(prev_id) = previous_element_id {
Rectangle::fill_with([1.0, 1.0], color::TRANSPARENT) Rectangle::fill_with([1.0, 1.0], color::TRANSPARENT)
@ -2739,7 +2743,7 @@ impl<'a> Widget for SettingsWindow<'a> {
// Save current screen size // Save current screen size
if Button::image(self.imgs.button) if Button::image(self.imgs.button)
.w_h(31.0 * 5.0, 12.0 * 2.0) .w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
.hover_image(self.imgs.button_hover) .hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press) .press_image(self.imgs.button_press)
.down_from(state.ids.fullscreen_mode_list, 12.0) .down_from(state.ids.fullscreen_mode_list, 12.0)
@ -2762,10 +2766,11 @@ impl<'a> Widget for SettingsWindow<'a> {
// Reset the graphics settings to the default settings // Reset the graphics settings to the default settings
if Button::image(self.imgs.button) if Button::image(self.imgs.button)
.w_h(31.0 * 5.0, 12.0 * 2.0) .w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
.hover_image(self.imgs.button_hover) .hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press) .press_image(self.imgs.button_press)
.down_from(state.ids.save_window_size_button, 12.0) .down_from(state.ids.fullscreen_mode_list, 12.0)
.right_from(state.ids.save_window_size_button, 12.0)
.label(&self.localized_strings.get("hud.settings.reset_graphics")) .label(&self.localized_strings.get("hud.settings.reset_graphics"))
.label_font_size(self.fonts.cyri.scale(14)) .label_font_size(self.fonts.cyri.scale(14))
.label_color(TEXT_COLOR) .label_color(TEXT_COLOR)
@ -2884,7 +2889,7 @@ impl<'a> Widget for SettingsWindow<'a> {
// Reset the sound settings to the default settings // Reset the sound settings to the default settings
if Button::image(self.imgs.button) if Button::image(self.imgs.button)
.w_h(31.0 * 5.0, 12.0 * 2.0) .w_h(RESET_BUTTONS_WIDTH, RESET_BUTTONS_HEIGHT)
.hover_image(self.imgs.button_hover) .hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press) .press_image(self.imgs.button_press)
.down_from(state.ids.sfx_volume_slider, 12.0) .down_from(state.ids.sfx_volume_slider, 12.0)

View File

@ -636,7 +636,7 @@ impl Default for GraphicsSettings {
exposure: 1.0, exposure: 1.0,
ambiance: 10.0, ambiance: 10.0,
render_mode: RenderMode::default(), render_mode: RenderMode::default(),
window_size: [1920, 1080], window_size: [1280, 720],
fullscreen: FullScreenSettings::default(), fullscreen: FullScreenSettings::default(),
lod_detail: 250, lod_detail: 250,
} }