mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add reset button to graphics settings
This commit is contained in:
parent
8c1ac78ce3
commit
16b66f9cd6
@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Procedural trees (currently only oaks and pines are procedural)
|
||||
- Cliffs on steep slopes
|
||||
- Giant tree sites
|
||||
- Reset button for graphics settings
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -85,6 +85,7 @@
|
||||
"hud.settings.shadow_rendering_mode.map.resolution": "Resolution",
|
||||
"hud.settings.lod_detail": "LoD Detail",
|
||||
"hud.settings.save_window_size": "Save window size",
|
||||
"hud.settings.reset_graphics": "Reset to Defaults",
|
||||
|
||||
|
||||
"hud.settings.music_volume": "Music Volume",
|
||||
|
@ -408,6 +408,7 @@ pub enum Event {
|
||||
ChangeLanguage(Box<LanguageMetadata>),
|
||||
ChangeBinding(GameInput),
|
||||
ResetBindings,
|
||||
ResetGraphics,
|
||||
ChangeFreeLookBehavior(PressBehavior),
|
||||
ChangeRenderMode(Box<RenderMode>),
|
||||
ChangeAutoWalkBehavior(PressBehavior),
|
||||
@ -2527,6 +2528,9 @@ impl Hud {
|
||||
settings_window::Event::ChangeStopAutoWalkOnInput(state) => {
|
||||
events.push(Event::ChangeStopAutoWalkOnInput(state));
|
||||
},
|
||||
settings_window::Event::ResetGraphics => {
|
||||
events.push(Event::ResetGraphics);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ widget_ids! {
|
||||
controls_texts[],
|
||||
controls_buttons[],
|
||||
reset_controls_button,
|
||||
reset_graphics_button,
|
||||
controls_alignment_rectangle,
|
||||
button_help,
|
||||
button_help2,
|
||||
@ -329,6 +330,7 @@ pub enum Event {
|
||||
ChangeLanguage(Box<LanguageMetadata>),
|
||||
ChangeBinding(GameInput),
|
||||
ResetBindings,
|
||||
ResetGraphics,
|
||||
ChangeFreeLookBehavior(PressBehavior),
|
||||
ChangeAutoWalkBehavior(PressBehavior),
|
||||
ChangeStopAutoWalkOnInput(bool),
|
||||
@ -2709,6 +2711,23 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.into_array(),
|
||||
));
|
||||
}
|
||||
|
||||
// Save current screen size
|
||||
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.save_window_size_button, 12.0)
|
||||
.label(&self.localized_strings.get("hud.settings.reset_graphics"))
|
||||
.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_graphics_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(Event::ResetGraphics);
|
||||
}
|
||||
}
|
||||
|
||||
// 5) Sound Tab -----------------------------------
|
||||
|
@ -38,7 +38,7 @@ use crate::{
|
||||
menu::char_selection::CharSelectionState,
|
||||
render::Renderer,
|
||||
scene::{camera, CameraMode, Scene, SceneData},
|
||||
settings::{ControlSettings, Settings},
|
||||
settings::{ControlSettings, GraphicsSettings, Settings},
|
||||
window::{AnalogGameInput, Event, GameInput},
|
||||
Direction, Error, GlobalState, PlayState, PlayStateResult,
|
||||
};
|
||||
@ -1362,6 +1362,32 @@ impl PlayState for SessionState {
|
||||
global_state.settings.gameplay.minimap_face_north = state;
|
||||
global_state.settings.save_to_file_warn();
|
||||
},
|
||||
HudEvent::ResetGraphics => {
|
||||
global_state.settings.graphics = GraphicsSettings::default();
|
||||
global_state.settings.save_to_file_warn();
|
||||
let graphics = &global_state.settings.graphics;
|
||||
// View distance
|
||||
self.client
|
||||
.borrow_mut()
|
||||
.set_view_distance(graphics.view_distance);
|
||||
// FOV
|
||||
self.scene.camera_mut().set_fov_deg(graphics.fov);
|
||||
self.scene
|
||||
.camera_mut()
|
||||
.compute_dependents(&*self.client.borrow().state().terrain());
|
||||
// LoD
|
||||
self.scene.lod.set_detail(graphics.lod_detail);
|
||||
// Render mode
|
||||
global_state
|
||||
.window
|
||||
.renderer_mut()
|
||||
.set_render_mode(graphics.render_mode.clone())
|
||||
.unwrap();
|
||||
// Fullscreen mode
|
||||
global_state.window.set_fullscreen_mode(graphics.fullscreen);
|
||||
// Window size
|
||||
global_state.window.set_size(graphics.window_size.into());
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user