More resiliant settings, better key defaults

This commit is contained in:
Joshua Barretto 2020-11-11 17:37:26 +00:00
parent d8ce666a9e
commit 7bce8b9615
7 changed files with 56 additions and 28 deletions

View File

@ -68,6 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Significantly improved terrain generation performance - Significantly improved terrain generation performance
- Significantly stabilized the game clock, to produce more "constant" TPS - Significantly stabilized the game clock, to produce more "constant" TPS
- Transitioned main menu and character selection screen to a using iced for the ui (fixes paste keybinding on macos, removes password field limits, adds tabbing between input fields in the main menu, adds language selection in the main menu) - Transitioned main menu and character selection screen to a using iced for the ui (fixes paste keybinding on macos, removes password field limits, adds tabbing between input fields in the main menu, adds language selection in the main menu)
- Made settings less likely to reset when the format changes
- Adjusted some keybindings
### Removed ### Removed

View File

@ -7,7 +7,8 @@ use hashbrown::HashMap;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
/// Contains all controller related settings and keymaps /// Contains all controller related settings and keymaps
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize, Default)]
#[serde(default)]
pub struct ControllerSettings { pub struct ControllerSettings {
pub game_button_map: HashMap<Button, Vec<GameInput>>, pub game_button_map: HashMap<Button, Vec<GameInput>>,
pub menu_button_map: HashMap<Button, Vec<MenuInput>>, pub menu_button_map: HashMap<Button, Vec<MenuInput>>,
@ -285,6 +286,10 @@ pub enum Button {
EventCode(u32), EventCode(u32),
} }
impl Default for Button {
fn default() -> Self { Button::Simple(GilButton::Unknown) }
}
/// AnalogButton::Simple(GilButton::Unknown) is invalid and equal to mapping an /// AnalogButton::Simple(GilButton::Unknown) is invalid and equal to mapping an
/// action to nothing /// action to nothing
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
@ -293,6 +298,10 @@ pub enum AnalogButton {
EventCode(u32), EventCode(u32),
} }
impl Default for AnalogButton {
fn default() -> Self { AnalogButton::Simple(GilButton::Unknown) }
}
/// Axis::Simple(GilAxis::Unknown) is invalid and equal to mapping an action to /// Axis::Simple(GilAxis::Unknown) is invalid and equal to mapping an action to
/// nothing /// nothing
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
@ -301,6 +310,10 @@ pub enum Axis {
EventCode(u32), EventCode(u32),
} }
impl Default for Axis {
fn default() -> Self { Axis::Simple(GilAxis::Unknown) }
}
impl From<(GilAxis, GilCode)> for Axis { impl From<(GilAxis, GilCode)> for Axis {
fn from((axis, code): (GilAxis, GilCode)) -> Self { fn from((axis, code): (GilAxis, GilCode)) -> Self {
match axis { match axis {

View File

@ -381,43 +381,50 @@ pub enum Windows {
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum CrosshairType { pub enum CrosshairType {
Round,
RoundEdges, RoundEdges,
Edges, Edges,
#[serde(other)]
Round,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum Intro { pub enum Intro {
Show,
Never, Never,
#[serde(other)]
Show,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum XpBar { pub enum XpBar {
Always,
OnGain, OnGain,
#[serde(other)]
Always,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum BarNumbers { pub enum BarNumbers {
Values,
Percent, Percent,
Off, Off,
#[serde(other)]
Values,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum ShortcutNumbers { pub enum ShortcutNumbers {
On,
Off, Off,
#[serde(other)]
On,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum BuffPosition { pub enum BuffPosition {
Bar,
Map, Map,
#[serde(other)]
Bar,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum PressBehavior { pub enum PressBehavior {
Toggle = 0,
Hold = 1, Hold = 1,
#[serde(other)]
Toggle = 0,
} }
pub struct Show { pub struct Show {

View File

@ -67,7 +67,6 @@ use serde::{Deserialize, Serialize};
/// Anti-aliasing modes /// Anti-aliasing modes
#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] #[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)]
pub enum AaMode { pub enum AaMode {
None,
/// Fast approximate antialiasing. /// Fast approximate antialiasing.
/// ///
/// This is a screen-space technique, and therefore works fine with greedy /// This is a screen-space technique, and therefore works fine with greedy
@ -99,6 +98,8 @@ pub enum AaMode {
/// meshing that (without significantly more work) invalidate the /// meshing that (without significantly more work) invalidate the
/// GPU's assumptions about importance sampling. /// GPU's assumptions about importance sampling.
SsaaX4, SsaaX4,
#[serde(other)]
None,
} }
impl Default for AaMode { impl Default for AaMode {
@ -140,8 +141,9 @@ pub enum CloudMode {
/// future that player better with the GPU. /// future that player better with the GPU.
Minimal, Minimal,
Low, Low,
Medium,
High, High,
#[serde(other)]
Medium,
} }
impl Default for CloudMode { impl Default for CloudMode {
@ -171,6 +173,7 @@ pub enum FluidMode {
/// Another issue is that we don't always know whether light is *blocked*, /// Another issue is that we don't always know whether light is *blocked*,
/// which causes attenuation to be computed incorrectly; this can be /// which causes attenuation to be computed incorrectly; this can be
/// addressed by using shadow maps (at least for terrain). /// addressed by using shadow maps (at least for terrain).
#[serde(other)]
Shiny, Shiny,
} }
@ -187,15 +190,16 @@ pub enum LightingMode {
/// This model may not work as well with purely directional lighting, and is /// This model may not work as well with purely directional lighting, and is
/// more expensive than the other models. /// more expensive than the other models.
Ashikhmin, Ashikhmin,
/// Standard Blinn-Phong shading, combing Lambertian diffuse reflections and
/// specular highlights.
BlinnPhong,
/// Standard Lambertian lighting model, with only diffuse reflections. The /// Standard Lambertian lighting model, with only diffuse reflections. The
/// cheapest lighting model by a decent margin, but the performance /// cheapest lighting model by a decent margin, but the performance
/// difference between it and Blinn-Phong will probably only be /// difference between it and Blinn-Phong will probably only be
/// significant on low-end machines that are bottlenecked on fragment /// significant on low-end machines that are bottlenecked on fragment
/// shading. /// shading.
Lambertian, Lambertian,
/// Standard Blinn-Phong shading, combing Lambertian diffuse reflections and
/// specular highlights.
#[serde(other)]
BlinnPhong,
} }
impl Default for LightingMode { impl Default for LightingMode {
@ -220,15 +224,16 @@ impl Default for ShadowMapMode {
pub enum ShadowMode { pub enum ShadowMode {
/// No shadows at all. By far the cheapest option. /// No shadows at all. By far the cheapest option.
None, None,
/// Shadow map (render the scene from each light source, and also renders
/// LOD shadows using horizon maps).
Map(ShadowMapMode),
/// Point shadows (draw circles under figures, up to a configured maximum; /// Point shadows (draw circles under figures, up to a configured maximum;
/// also render LOD shadows using horizon maps). Can be expensive on /// also render LOD shadows using horizon maps). Can be expensive on
/// some machines, probably mostly due to horizon mapping; the point /// some machines, probably mostly due to horizon mapping; the point
/// shadows are not rendered too efficiently, but that can probably /// shadows are not rendered too efficiently, but that can probably
/// be addressed later. /// be addressed later.
#[serde(other)] // Would normally be on `Map`, but only allowed on unit variants
Cheap, Cheap,
/// Shadow map (render the scene from each light source, and also renders
/// LOD shadows using horizon maps).
Map(ShadowMapMode),
} }
impl Default for ShadowMode { impl Default for ShadowMode {
@ -254,15 +259,11 @@ impl ShadowMode {
/// Render modes /// Render modes
#[derive(PartialEq, Clone, Debug, Default, Serialize, Deserialize)] #[derive(PartialEq, Clone, Debug, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct RenderMode { pub struct RenderMode {
#[serde(default)]
pub aa: AaMode, pub aa: AaMode,
#[serde(default)]
pub cloud: CloudMode, pub cloud: CloudMode,
#[serde(default)]
pub fluid: FluidMode, pub fluid: FluidMode,
#[serde(default)]
pub lighting: LightingMode, pub lighting: LightingMode,
#[serde(default)]
pub shadow: ShadowMode, pub shadow: ShadowMode,
} }

View File

@ -120,7 +120,7 @@ impl ControlSettings {
match game_input { match game_input {
GameInput::Primary => KeyMouse::Mouse(MouseButton::Left), GameInput::Primary => KeyMouse::Mouse(MouseButton::Left),
GameInput::Secondary => KeyMouse::Mouse(MouseButton::Right), GameInput::Secondary => KeyMouse::Mouse(MouseButton::Right),
GameInput::ToggleCursor => KeyMouse::Key(VirtualKeyCode::Tab), GameInput::ToggleCursor => KeyMouse::Key(VirtualKeyCode::Caret),
GameInput::Escape => KeyMouse::Key(VirtualKeyCode::Escape), GameInput::Escape => KeyMouse::Key(VirtualKeyCode::Escape),
GameInput::Chat => KeyMouse::Key(VirtualKeyCode::Return), GameInput::Chat => KeyMouse::Key(VirtualKeyCode::Return),
GameInput::Command => KeyMouse::Key(VirtualKeyCode::Slash), GameInput::Command => KeyMouse::Key(VirtualKeyCode::Slash),
@ -136,7 +136,7 @@ impl ControlSettings {
GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl), GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl),
GameInput::SwimUp => KeyMouse::Key(VirtualKeyCode::Space), GameInput::SwimUp => KeyMouse::Key(VirtualKeyCode::Space),
GameInput::SwimDown => KeyMouse::Key(VirtualKeyCode::LShift), GameInput::SwimDown => KeyMouse::Key(VirtualKeyCode::LShift),
GameInput::Fly => KeyMouse::Key(VirtualKeyCode::F), GameInput::Fly => KeyMouse::Key(VirtualKeyCode::H),
GameInput::Sneak => KeyMouse::Key(VirtualKeyCode::LControl), GameInput::Sneak => KeyMouse::Key(VirtualKeyCode::LControl),
//GameInput::WallLeap => MIDDLE_CLICK_KEY, //GameInput::WallLeap => MIDDLE_CLICK_KEY,
GameInput::ToggleLantern => KeyMouse::Key(VirtualKeyCode::G), GameInput::ToggleLantern => KeyMouse::Key(VirtualKeyCode::G),
@ -171,7 +171,7 @@ impl ControlSettings {
GameInput::Slot8 => KeyMouse::Key(VirtualKeyCode::Key8), GameInput::Slot8 => KeyMouse::Key(VirtualKeyCode::Key8),
GameInput::Slot9 => KeyMouse::Key(VirtualKeyCode::Key9), GameInput::Slot9 => KeyMouse::Key(VirtualKeyCode::Key9),
GameInput::Slot10 => KeyMouse::Key(VirtualKeyCode::Q), GameInput::Slot10 => KeyMouse::Key(VirtualKeyCode::Q),
GameInput::SwapLoadout => KeyMouse::Key(VirtualKeyCode::LAlt), GameInput::SwapLoadout => KeyMouse::Key(VirtualKeyCode::Tab),
GameInput::Select => KeyMouse::Key(VirtualKeyCode::Y), GameInput::Select => KeyMouse::Key(VirtualKeyCode::Y),
GameInput::AcceptGroupInvite => KeyMouse::Key(VirtualKeyCode::U), GameInput::AcceptGroupInvite => KeyMouse::Key(VirtualKeyCode::U),
GameInput::DeclineGroupInvite => KeyMouse::Key(VirtualKeyCode::I), GameInput::DeclineGroupInvite => KeyMouse::Key(VirtualKeyCode::I),
@ -540,7 +540,7 @@ impl Default for GameplaySettings {
intro_show: Intro::Show, intro_show: Intro::Show,
xp_bar: XpBar::Always, xp_bar: XpBar::Always,
shortcut_numbers: ShortcutNumbers::On, shortcut_numbers: ShortcutNumbers::On,
buff_position: BuffPosition::Map, buff_position: BuffPosition::Bar,
bar_numbers: BarNumbers::Values, bar_numbers: BarNumbers::Values,
ui_scale: ScaleMode::RelativeToWindow([1920.0, 1080.0].into()), ui_scale: ScaleMode::RelativeToWindow([1920.0, 1080.0].into()),
free_look_behavior: PressBehavior::Toggle, free_look_behavior: PressBehavior::Toggle,
@ -654,8 +654,9 @@ pub enum AudioOutput {
// If this option is disabled, functions in the rodio // If this option is disabled, functions in the rodio
// library MUST NOT be called. // library MUST NOT be called.
Off, Off,
Automatic,
Device(String), Device(String),
#[serde(other)]
Automatic,
} }
impl AudioOutput { impl AudioOutput {

View File

@ -7,12 +7,14 @@ use vek::*;
pub enum ScaleMode { pub enum ScaleMode {
// Scale against physical size. // Scale against physical size.
Absolute(f64), Absolute(f64),
// Use the dpi factor provided by the windowing system (i.e. use logical size).
DpiFactor,
// Scale based on the window's physical size, but maintain aspect ratio of widgets. // Scale based on the window's physical size, but maintain aspect ratio of widgets.
// Contains width and height of the "default" window size (ie where there should be no // Contains width and height of the "default" window size (ie where there should be no
// scaling). // scaling).
RelativeToWindow(Vec2<f64>), RelativeToWindow(Vec2<f64>),
// Use the dpi factor provided by the windowing system (i.e. use logical size).
#[serde(other)]
// Would be `RelativeToWindow([1920.0, 1080.0].into())`, but only supported on unit variants
DpiFactor,
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy)]

View File

@ -1388,6 +1388,7 @@ impl Window {
#[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)] #[derive(Copy, Clone, Hash, Eq, PartialEq, Debug, Serialize, Deserialize)]
pub enum FullscreenMode { pub enum FullscreenMode {
Exclusive, Exclusive,
#[serde(other)]
Borderless, Borderless,
} }
@ -1395,6 +1396,7 @@ impl Default for FullscreenMode {
fn default() -> Self { FullscreenMode::Borderless } fn default() -> Self { FullscreenMode::Borderless }
} }
#[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)] #[derive(PartialEq, Clone, Copy, Debug, Serialize, Deserialize)]
#[serde(default)]
pub struct FullScreenSettings { pub struct FullScreenSettings {
pub enabled: bool, pub enabled: bool,
pub mode: FullscreenMode, pub mode: FullscreenMode,