mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'PersianKnight/Reset_to_Defaults_Buttons' into 'master'
Add Reset to Default Buttons for Interface, Gameplay and Sound Settings See merge request veloren/veloren!1877
This commit is contained in:
commit
a9bcaf0a37
@ -36,6 +36,7 @@
|
||||
"hud.settings.background_transparency": "Background Transparency",
|
||||
"hud.settings.chat_character_name": "Character Names in chat",
|
||||
"hud.settings.loading_tips": "Loading Screen Tips",
|
||||
"hud.settings.reset_interface": "Reset to Defaults",
|
||||
|
||||
"hud.settings.pan_sensitivity": "Pan Sensitivity",
|
||||
"hud.settings.zoom_sensitivity": "Zoom Sensitivity",
|
||||
@ -46,6 +47,7 @@
|
||||
"hud.settings.free_look_behavior": "Free look behavior",
|
||||
"hud.settings.auto_walk_behavior": "Auto walk behavior",
|
||||
"hud.settings.stop_auto_walk_on_input": "Stop auto walk on movement",
|
||||
"hud.settings.reset_gameplay": "Reset to Defaults",
|
||||
|
||||
"hud.settings.view_distance": "View Distance",
|
||||
"hud.settings.sprites_view_distance": "Sprites View Distance",
|
||||
@ -91,6 +93,7 @@
|
||||
"hud.settings.music_volume": "Music Volume",
|
||||
"hud.settings.sound_effect_volume": "Sound Effects Volume",
|
||||
"hud.settings.audio_device": "Audio Device",
|
||||
"hud.settings.reset_sound": "Reset to Defaults",
|
||||
|
||||
"hud.settings.awaitingkey": "Press a key...",
|
||||
"hud.settings.unbound": "None",
|
||||
|
@ -413,8 +413,11 @@ pub enum Event {
|
||||
Quit,
|
||||
ChangeLanguage(Box<LanguageMetadata>),
|
||||
ChangeBinding(GameInput),
|
||||
ResetBindings,
|
||||
ResetGraphics,
|
||||
ResetInterfaceSettings,
|
||||
ResetGameplaySettings,
|
||||
ResetKeyBindings,
|
||||
ResetGraphicsSettings,
|
||||
ResetAudioSettings,
|
||||
ChangeFreeLookBehavior(PressBehavior),
|
||||
ChangeRenderMode(Box<RenderMode>),
|
||||
ChangeAutoWalkBehavior(PressBehavior),
|
||||
@ -2538,9 +2541,6 @@ impl Hud {
|
||||
settings_window::Event::ChangeBinding(game_input) => {
|
||||
events.push(Event::ChangeBinding(game_input));
|
||||
},
|
||||
settings_window::Event::ResetBindings => {
|
||||
events.push(Event::ResetBindings);
|
||||
},
|
||||
settings_window::Event::ChangeFreeLookBehavior(behavior) => {
|
||||
events.push(Event::ChangeFreeLookBehavior(behavior));
|
||||
},
|
||||
@ -2550,8 +2550,22 @@ impl Hud {
|
||||
settings_window::Event::ChangeStopAutoWalkOnInput(state) => {
|
||||
events.push(Event::ChangeStopAutoWalkOnInput(state));
|
||||
},
|
||||
settings_window::Event::ResetGraphics => {
|
||||
events.push(Event::ResetGraphics);
|
||||
settings_window::Event::ResetInterfaceSettings => {
|
||||
self.show.help = true;
|
||||
self.show.debug = false;
|
||||
events.push(Event::ResetInterfaceSettings);
|
||||
},
|
||||
settings_window::Event::ResetGameplaySettings => {
|
||||
events.push(Event::ResetGameplaySettings);
|
||||
},
|
||||
settings_window::Event::ResetKeyBindings => {
|
||||
events.push(Event::ResetKeyBindings);
|
||||
},
|
||||
settings_window::Event::ResetGraphicsSettings => {
|
||||
events.push(Event::ResetGraphicsSettings);
|
||||
},
|
||||
settings_window::Event::ResetAudioSettings => {
|
||||
events.push(Event::ResetAudioSettings);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -2915,6 +2929,10 @@ impl Hud {
|
||||
|
||||
pub fn new_notification(&mut self, msg: Notification) { self.new_notifications.push_back(msg); }
|
||||
|
||||
pub fn set_scaling_mode(&mut self, scale_mode: ScaleMode) {
|
||||
self.ui.set_scaling_mode(scale_mode);
|
||||
}
|
||||
|
||||
pub fn scale_change(&mut self, scale_change: ScaleChange) -> ScaleMode {
|
||||
let scale_mode = match scale_change {
|
||||
ScaleChange::Adjust(scale) => ScaleMode::Absolute(scale),
|
||||
|
@ -59,8 +59,11 @@ widget_ids! {
|
||||
settings_scrollbar,
|
||||
controls_texts[],
|
||||
controls_buttons[],
|
||||
reset_interface_button,
|
||||
reset_gameplay_button,
|
||||
reset_controls_button,
|
||||
reset_graphics_button,
|
||||
reset_sound_button,
|
||||
controls_alignment_rectangle,
|
||||
button_help,
|
||||
button_help2,
|
||||
@ -329,8 +332,11 @@ pub enum Event {
|
||||
SpeechBubbleIcon(bool),
|
||||
ChangeLanguage(Box<LanguageMetadata>),
|
||||
ChangeBinding(GameInput),
|
||||
ResetBindings,
|
||||
ResetGraphics,
|
||||
ResetInterfaceSettings,
|
||||
ResetGameplaySettings,
|
||||
ResetKeyBindings,
|
||||
ResetGraphicsSettings,
|
||||
ResetAudioSettings,
|
||||
ChangeFreeLookBehavior(PressBehavior),
|
||||
ChangeAutoWalkBehavior(PressBehavior),
|
||||
ChangeStopAutoWalkOnInput(bool),
|
||||
@ -1308,6 +1314,23 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.set(state.ids.chat_char_name_text, ui);
|
||||
|
||||
// TODO Show account name in chat
|
||||
|
||||
// Reset the interface settings to the default settings
|
||||
if Button::image(self.imgs.button)
|
||||
.w_h(31.0 * 5.0, 12.0 * 2.0)
|
||||
.hover_image(self.imgs.button_hover)
|
||||
.press_image(self.imgs.button_press)
|
||||
.down_from(state.ids.buff_pos_map_button, 12.0)
|
||||
.label(&self.localized_strings.get("hud.settings.reset_interface"))
|
||||
.label_font_size(self.fonts.cyri.scale(14))
|
||||
.label_color(TEXT_COLOR)
|
||||
.label_font_id(self.fonts.cyri.conrod_id)
|
||||
.label_y(Relative::Scalar(2.0))
|
||||
.set(state.ids.reset_interface_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(Event::ResetInterfaceSettings);
|
||||
}
|
||||
}
|
||||
|
||||
// 2) Gameplay Tab --------------------------------
|
||||
@ -1621,6 +1644,23 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.graphics_for(state.ids.stop_auto_walk_on_input_button)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.stop_auto_walk_on_input_label, ui);
|
||||
|
||||
// Reset the gameplay settings to the default settings
|
||||
if Button::image(self.imgs.button)
|
||||
.w_h(31.0 * 5.0, 12.0 * 2.0)
|
||||
.hover_image(self.imgs.button_hover)
|
||||
.press_image(self.imgs.button_press)
|
||||
.down_from(state.ids.free_look_behavior_list, 12.0)
|
||||
.label(&self.localized_strings.get("hud.settings.reset_gameplay"))
|
||||
.label_font_size(self.fonts.cyri.scale(14))
|
||||
.label_color(TEXT_COLOR)
|
||||
.label_font_id(self.fonts.cyri.conrod_id)
|
||||
.label_y(Relative::Scalar(2.0))
|
||||
.set(state.ids.reset_gameplay_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(Event::ResetGameplaySettings);
|
||||
}
|
||||
}
|
||||
|
||||
// 3) Controls Tab --------------------------------
|
||||
@ -1729,6 +1769,8 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
// Set the previous id to the current one for the next cycle
|
||||
previous_element_id = Some(text_id);
|
||||
}
|
||||
|
||||
// Reset the KeyBindings settings to the default settings
|
||||
if let Some(prev_id) = previous_element_id {
|
||||
let key_string = self.localized_strings.get("hud.settings.reset_keybinds");
|
||||
let button_widget = Button::new()
|
||||
@ -1743,7 +1785,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.label_y(Relative::Scalar(3.0))
|
||||
.set(state.ids.reset_controls_button, ui);
|
||||
if button_widget.was_clicked() {
|
||||
events.push(Event::ResetBindings);
|
||||
events.push(Event::ResetKeyBindings);
|
||||
}
|
||||
previous_element_id = Some(state.ids.reset_controls_button)
|
||||
}
|
||||
@ -2712,7 +2754,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
));
|
||||
}
|
||||
|
||||
// Save current screen size
|
||||
// Reset the graphics settings to the default settings
|
||||
if Button::image(self.imgs.button)
|
||||
.w_h(31.0 * 5.0, 12.0 * 2.0)
|
||||
.hover_image(self.imgs.button_hover)
|
||||
@ -2726,7 +2768,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.set(state.ids.reset_graphics_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(Event::ResetGraphics);
|
||||
events.push(Event::ResetGraphicsSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2833,6 +2875,23 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
// let new_val = device_list[clicked].clone();
|
||||
// events.push(Event::ChangeAudioDevice(new_val));
|
||||
//}
|
||||
|
||||
// Reset the sound settings to the default settings
|
||||
if Button::image(self.imgs.button)
|
||||
.w_h(31.0 * 5.0, 12.0 * 2.0)
|
||||
.hover_image(self.imgs.button_hover)
|
||||
.press_image(self.imgs.button_press)
|
||||
.down_from(state.ids.sfx_volume_slider, 12.0)
|
||||
.label(&self.localized_strings.get("hud.settings.reset_sound"))
|
||||
.label_font_size(self.fonts.cyri.scale(14))
|
||||
.label_color(TEXT_COLOR)
|
||||
.label_font_id(self.fonts.cyri.conrod_id)
|
||||
.label_y(Relative::Scalar(2.0))
|
||||
.set(state.ids.reset_sound_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(Event::ResetAudioSettings);
|
||||
}
|
||||
}
|
||||
|
||||
// 5) Languages Tab -----------------------------------
|
||||
|
@ -38,7 +38,10 @@ use crate::{
|
||||
menu::char_selection::CharSelectionState,
|
||||
render::Renderer,
|
||||
scene::{camera, CameraMode, Scene, SceneData},
|
||||
settings::{ControlSettings, GraphicsSettings, Settings},
|
||||
settings::{
|
||||
AudioSettings, ControlSettings, GamepadSettings, GameplaySettings, GraphicsSettings,
|
||||
Settings,
|
||||
},
|
||||
window::{AnalogGameInput, Event, GameInput},
|
||||
Direction, Error, GlobalState, PlayState, PlayStateResult,
|
||||
};
|
||||
@ -1320,10 +1323,6 @@ impl PlayState for SessionState {
|
||||
HudEvent::ChangeBinding(game_input) => {
|
||||
global_state.window.set_keybinding_mode(game_input);
|
||||
},
|
||||
HudEvent::ResetBindings => {
|
||||
global_state.settings.controls = ControlSettings::default();
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ChangeFreeLookBehavior(behavior) => {
|
||||
global_state.settings.gameplay.free_look_behavior = behavior;
|
||||
},
|
||||
@ -1362,7 +1361,97 @@ impl PlayState for SessionState {
|
||||
global_state.settings.gameplay.minimap_face_north = state;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ResetGraphics => {
|
||||
HudEvent::ResetInterfaceSettings => {
|
||||
// Load Defaults
|
||||
let default = GameplaySettings::default();
|
||||
// General
|
||||
//global_state.settings.gameplay.intro_show = default.intro_show;
|
||||
global_state.settings.gameplay.loading_tips = default.loading_tips;
|
||||
global_state.settings.gameplay.toggle_debug = default.toggle_debug;
|
||||
// UI-Scale
|
||||
global_state.settings.gameplay.ui_scale = default.ui_scale;
|
||||
self.hud.set_scaling_mode(default.ui_scale);
|
||||
// Crosshair
|
||||
global_state.settings.gameplay.crosshair_type = default.crosshair_type;
|
||||
global_state.settings.gameplay.crosshair_transp = default.crosshair_transp;
|
||||
//Energybar Numbers
|
||||
global_state.settings.gameplay.bar_numbers = default.bar_numbers;
|
||||
// Hotbar
|
||||
global_state.settings.gameplay.xp_bar = default.xp_bar;
|
||||
global_state.settings.gameplay.shortcut_numbers = default.shortcut_numbers;
|
||||
global_state.settings.gameplay.buff_position = default.buff_position;
|
||||
// Scrolling Combat Text
|
||||
global_state.settings.gameplay.sct = default.sct;
|
||||
global_state.settings.gameplay.sct_player_batch = default.sct_player_batch;
|
||||
global_state.settings.gameplay.sct_damage_batch = default.sct_damage_batch;
|
||||
//Speech Bubble
|
||||
global_state.settings.gameplay.speech_bubble_dark_mode =
|
||||
default.speech_bubble_dark_mode;
|
||||
global_state.settings.gameplay.speech_bubble_icon =
|
||||
default.speech_bubble_icon;
|
||||
// Chat
|
||||
global_state.settings.gameplay.chat_transp = default.chat_transp;
|
||||
global_state.settings.gameplay.chat_character_name =
|
||||
default.chat_character_name;
|
||||
// Map
|
||||
global_state.settings.gameplay.map_zoom = default.map_zoom;
|
||||
global_state.settings.gameplay.map_drag = default.map_drag;
|
||||
global_state.settings.gameplay.map_show_difficulty =
|
||||
default.map_show_difficulty;
|
||||
global_state.settings.gameplay.map_show_towns = default.map_show_towns;
|
||||
global_state.settings.gameplay.map_show_dungeons =
|
||||
default.map_show_dungeons;
|
||||
global_state.settings.gameplay.map_show_castles = default.map_show_castles;
|
||||
global_state.settings.gameplay.map_show_caves = default.map_show_caves;
|
||||
global_state.settings.gameplay.map_show_trees = default.map_show_trees;
|
||||
global_state.settings.gameplay.minimap_show = default.minimap_show;
|
||||
global_state.settings.gameplay.minimap_face_north =
|
||||
default.minimap_face_north;
|
||||
// Save to File
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ResetGameplaySettings => {
|
||||
// Load Defaults
|
||||
let default = GameplaySettings::default();
|
||||
// Pan Sensitivity
|
||||
global_state.window.pan_sensitivity = default.pan_sensitivity;
|
||||
global_state.settings.gameplay.pan_sensitivity = default.pan_sensitivity;
|
||||
// Zoom Sensitivity
|
||||
global_state.window.zoom_sensitivity = default.zoom_sensitivity;
|
||||
global_state.settings.gameplay.zoom_sensitivity = default.zoom_sensitivity;
|
||||
// Invert Scroll Zoom
|
||||
global_state.window.zoom_inversion = default.zoom_inversion;
|
||||
global_state.settings.gameplay.zoom_inversion = default.zoom_inversion;
|
||||
// Invert Mouse Y Axis
|
||||
global_state.window.mouse_y_inversion = default.mouse_y_inversion;
|
||||
global_state.settings.gameplay.mouse_y_inversion =
|
||||
default.mouse_y_inversion;
|
||||
// Invert Controller Y Axis
|
||||
let default_gamepad = GamepadSettings::default();
|
||||
global_state.window.controller_settings.pan_invert_y =
|
||||
default_gamepad.pan_invert_y;
|
||||
global_state.settings.controller.pan_invert_y =
|
||||
default_gamepad.pan_invert_y;
|
||||
// Camera Smoothing
|
||||
global_state.settings.gameplay.smooth_pan_enable =
|
||||
default.smooth_pan_enable;
|
||||
// Free Look Behavior
|
||||
global_state.settings.gameplay.free_look_behavior =
|
||||
default.free_look_behavior;
|
||||
// Auto Walk Behavior
|
||||
global_state.settings.gameplay.auto_walk_behavior =
|
||||
default.auto_walk_behavior;
|
||||
// Stop Auto Walk on Movement
|
||||
global_state.settings.gameplay.stop_auto_walk_on_input =
|
||||
default.stop_auto_walk_on_input;
|
||||
// Save to File
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ResetKeyBindings => {
|
||||
global_state.settings.controls = ControlSettings::default();
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ResetGraphicsSettings => {
|
||||
global_state.settings.graphics = GraphicsSettings::default();
|
||||
global_state.settings.save_to_file_warn();
|
||||
let graphics = &global_state.settings.graphics;
|
||||
@ -1388,6 +1477,13 @@ impl PlayState for SessionState {
|
||||
// Window size
|
||||
global_state.window.set_size(graphics.window_size.into());
|
||||
},
|
||||
HudEvent::ResetAudioSettings => {
|
||||
global_state.settings.audio = AudioSettings::default();
|
||||
global_state.settings.save_to_file_warn();
|
||||
let audio = &global_state.settings.audio;
|
||||
global_state.audio.set_music_volume(audio.music_volume);
|
||||
global_state.audio.set_sfx_volume(audio.sfx_volume);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user