2021-04-14 00:43:11 +00:00
|
|
|
use super::SessionState;
|
|
|
|
use crate::{
|
|
|
|
controller::ControllerSettings,
|
2021-07-21 11:23:45 +00:00
|
|
|
game_input::GameInput,
|
2021-04-14 00:43:11 +00:00
|
|
|
hud::{
|
2023-02-21 01:55:49 +00:00
|
|
|
AutoPressBehavior, BarNumbers, BuffPosition, ChatTab, CrosshairType, Intro, PressBehavior,
|
|
|
|
ScaleChange, ShortcutNumbers, XpBar,
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
|
|
|
render::RenderMode,
|
|
|
|
settings::{
|
2022-05-09 01:11:34 +00:00
|
|
|
audio::AudioVolume, AudioSettings, ChatSettings, ControlSettings, Fps, GamepadSettings,
|
|
|
|
GameplaySettings, GraphicsSettings, InterfaceSettings,
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
2023-01-10 01:57:44 +00:00
|
|
|
window::{FullScreenSettings, Window},
|
2021-04-14 00:43:11 +00:00
|
|
|
GlobalState,
|
|
|
|
};
|
2021-07-29 18:47:45 +00:00
|
|
|
use i18n::{LanguageMetadata, LocalizationHandle};
|
2022-10-26 22:15:07 +00:00
|
|
|
use std::rc::Rc;
|
2021-04-14 00:43:11 +00:00
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Audio {
|
2021-04-18 19:52:35 +00:00
|
|
|
AdjustMasterVolume(f32),
|
2022-05-09 01:11:34 +00:00
|
|
|
MuteMasterVolume(bool),
|
2021-04-18 19:52:35 +00:00
|
|
|
AdjustInactiveMasterVolume(f32),
|
2022-05-09 01:11:34 +00:00
|
|
|
MuteInactiveMasterVolume(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
AdjustMusicVolume(f32),
|
2022-05-09 01:11:34 +00:00
|
|
|
MuteMusicVolume(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
AdjustSfxVolume(f32),
|
2022-05-09 01:11:34 +00:00
|
|
|
MuteSfxVolume(bool),
|
2022-03-23 06:50:38 +00:00
|
|
|
AdjustAmbienceVolume(f32),
|
2022-05-09 01:11:34 +00:00
|
|
|
MuteAmbienceVolume(bool),
|
2022-08-14 01:57:58 +00:00
|
|
|
AdjustMusicSpacing(f32),
|
2023-07-30 08:10:36 +00:00
|
|
|
ToggleCombatMusic(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
//ChangeAudioDevice(String),
|
|
|
|
ResetAudioSettings,
|
|
|
|
}
|
|
|
|
#[derive(Clone)]
|
2021-05-14 12:27:15 +00:00
|
|
|
pub enum Chat {
|
|
|
|
Transp(f32),
|
|
|
|
CharName(bool),
|
|
|
|
ChangeChatTab(Option<usize>),
|
|
|
|
ChatTabUpdate(usize, ChatTab),
|
|
|
|
ChatTabInsert(usize, ChatTab),
|
|
|
|
ChatTabMove(usize, usize), //(i, j) move item from position i, and insert into position j
|
|
|
|
ChatTabRemove(usize),
|
|
|
|
ResetChatSettings,
|
|
|
|
}
|
|
|
|
#[derive(Clone)]
|
2021-04-14 00:43:11 +00:00
|
|
|
pub enum Control {
|
|
|
|
ChangeBinding(GameInput),
|
2022-01-07 20:30:30 +00:00
|
|
|
RemoveBinding(GameInput),
|
|
|
|
ToggleKeybindingMode,
|
2021-04-14 00:43:11 +00:00
|
|
|
ResetKeyBindings,
|
|
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Gamepad {}
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Gameplay {
|
|
|
|
AdjustMousePan(u32),
|
|
|
|
AdjustMouseZoom(u32),
|
|
|
|
AdjustCameraClamp(u32),
|
2023-10-13 19:28:56 +00:00
|
|
|
AdjustWalkingSpeed(f32),
|
2021-04-14 00:43:11 +00:00
|
|
|
|
|
|
|
ToggleControllerYInvert(bool),
|
|
|
|
ToggleMouseYInvert(bool),
|
|
|
|
ToggleZoomInvert(bool),
|
|
|
|
|
|
|
|
ToggleSmoothPan(bool),
|
|
|
|
|
|
|
|
ChangeFreeLookBehavior(PressBehavior),
|
|
|
|
ChangeAutoWalkBehavior(PressBehavior),
|
2023-10-13 19:28:56 +00:00
|
|
|
ChangeWalkingSpeedBehavior(PressBehavior),
|
2021-04-14 00:43:11 +00:00
|
|
|
ChangeCameraClampBehavior(PressBehavior),
|
2023-02-21 01:55:49 +00:00
|
|
|
ChangeZoomLockBehavior(AutoPressBehavior),
|
2021-04-14 00:43:11 +00:00
|
|
|
ChangeStopAutoWalkOnInput(bool),
|
|
|
|
ChangeAutoCamera(bool),
|
2022-05-23 23:09:47 +00:00
|
|
|
ChangeBowZoom(bool),
|
2023-02-21 01:55:49 +00:00
|
|
|
ChangeZoomLock(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
|
|
|
|
ResetGameplaySettings,
|
|
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Graphics {
|
2022-08-22 03:21:39 +00:00
|
|
|
AdjustTerrainViewDistance(u32),
|
|
|
|
AdjustEntityViewDistance(u32),
|
2022-05-10 11:36:44 +00:00
|
|
|
AdjustLodDistance(u32),
|
2021-04-14 00:43:11 +00:00
|
|
|
AdjustLodDetail(u32),
|
|
|
|
AdjustSpriteRenderDistance(u32),
|
|
|
|
AdjustFigureLoDRenderDistance(u32),
|
|
|
|
|
|
|
|
ChangeMaxFPS(Fps),
|
2021-10-10 15:33:31 +00:00
|
|
|
ChangeMaxBackgroundFPS(Fps),
|
2021-04-14 00:43:11 +00:00
|
|
|
ChangeFOV(u16),
|
|
|
|
|
|
|
|
ChangeGamma(f32),
|
|
|
|
ChangeExposure(f32),
|
|
|
|
ChangeAmbiance(f32),
|
|
|
|
|
|
|
|
ChangeRenderMode(Box<RenderMode>),
|
|
|
|
|
|
|
|
ChangeFullscreenMode(FullScreenSettings),
|
|
|
|
ToggleParticlesEnabled(bool),
|
2022-01-28 05:06:11 +00:00
|
|
|
ToggleWeaponTrailsEnabled(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
AdjustWindowSize([u16; 2]),
|
|
|
|
|
|
|
|
ResetGraphicsSettings,
|
2022-10-26 22:15:07 +00:00
|
|
|
ChangeGraphicsSettings(Rc<dyn Fn(GraphicsSettings) -> GraphicsSettings>),
|
2021-04-14 00:43:11 +00:00
|
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Interface {
|
|
|
|
Sct(bool),
|
2022-04-18 14:41:49 +00:00
|
|
|
SctRoundDamage(bool),
|
2022-04-19 16:37:28 +00:00
|
|
|
SctDamageAccumDuration(f32),
|
2022-06-14 21:11:58 +00:00
|
|
|
SctIncomingDamage(bool),
|
2022-04-19 16:37:28 +00:00
|
|
|
SctIncomingDamageAccumDuration(f32),
|
2021-12-31 21:42:01 +00:00
|
|
|
SpeechBubbleSelf(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
SpeechBubbleDarkMode(bool),
|
|
|
|
SpeechBubbleIcon(bool),
|
|
|
|
ToggleHelp(bool),
|
|
|
|
ToggleDebug(bool),
|
2021-05-04 20:12:26 +00:00
|
|
|
ToggleHitboxes(bool),
|
2021-06-21 19:16:03 +00:00
|
|
|
ToggleChat(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
ToggleTips(bool),
|
2021-09-24 16:03:05 +00:00
|
|
|
ToggleHotkeyHints(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
|
|
|
|
CrosshairTransp(f32),
|
|
|
|
CrosshairType(CrosshairType),
|
|
|
|
Intro(Intro),
|
|
|
|
ToggleXpBar(XpBar),
|
|
|
|
ToggleBarNumbers(BarNumbers),
|
2021-09-15 12:04:44 +00:00
|
|
|
ToggleAlwaysShowBars(bool),
|
2022-10-24 11:44:11 +00:00
|
|
|
TogglePoiseBar(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
ToggleShortcutNumbers(ShortcutNumbers),
|
|
|
|
BuffPosition(BuffPosition),
|
|
|
|
|
|
|
|
UiScale(ScaleChange),
|
2021-04-14 13:29:22 +00:00
|
|
|
//Minimap
|
|
|
|
MinimapShow(bool),
|
|
|
|
MinimapFaceNorth(bool),
|
2021-04-19 18:51:53 +00:00
|
|
|
MinimapZoom(f64),
|
2021-04-14 00:43:11 +00:00
|
|
|
//Map settings
|
|
|
|
MapZoom(f64),
|
|
|
|
MapShowTopoMap(bool),
|
|
|
|
MapShowDifficulty(bool),
|
|
|
|
MapShowTowns(bool),
|
|
|
|
MapShowDungeons(bool),
|
|
|
|
MapShowCastles(bool),
|
2022-09-26 14:46:30 +00:00
|
|
|
MapShowBridges(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
MapShowCaves(bool),
|
|
|
|
MapShowTrees(bool),
|
2021-05-03 02:00:23 +00:00
|
|
|
MapShowPeaks(bool),
|
2022-01-17 22:45:51 +00:00
|
|
|
MapShowBiomes(bool),
|
2021-05-14 00:46:17 +00:00
|
|
|
MapShowVoxelMap(bool),
|
2022-06-14 21:11:58 +00:00
|
|
|
AccumExperience(bool),
|
2023-08-17 15:24:05 +00:00
|
|
|
//Slots
|
|
|
|
SlotsUsePrefixes(bool),
|
|
|
|
SlotsPrefixSwitchPoint(u32),
|
2021-04-14 00:43:11 +00:00
|
|
|
|
|
|
|
ResetInterfaceSettings,
|
|
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Language {
|
|
|
|
ChangeLanguage(Box<LanguageMetadata>),
|
2021-04-24 14:39:35 +00:00
|
|
|
ToggleEnglishFallback(bool),
|
2021-04-14 00:43:11 +00:00
|
|
|
}
|
|
|
|
#[derive(Clone)]
|
2022-08-15 15:58:37 +00:00
|
|
|
pub enum Networking {
|
2022-08-22 03:21:39 +00:00
|
|
|
AdjustTerrainViewDistance(u32),
|
|
|
|
AdjustEntityViewDistance(u32),
|
2022-08-15 15:58:37 +00:00
|
|
|
ChangePlayerPhysicsBehavior {
|
|
|
|
server_authoritative: bool,
|
|
|
|
},
|
|
|
|
ToggleLossyTerrainCompression(bool),
|
|
|
|
|
|
|
|
#[cfg(feature = "discord")]
|
|
|
|
ToggleDiscordIntegration(bool),
|
2022-08-22 03:21:39 +00:00
|
|
|
// TODO: reset option (ensure it handles the entity/terrain vd the same as graphics reset
|
|
|
|
// option)
|
2022-08-15 15:58:37 +00:00
|
|
|
}
|
2021-04-14 00:43:11 +00:00
|
|
|
|
2023-04-25 20:01:18 +00:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum Accessibility {
|
|
|
|
ChangeRenderMode(Box<RenderMode>),
|
2023-04-26 14:20:56 +00:00
|
|
|
SetSubtitles(bool),
|
2023-04-25 20:01:18 +00:00
|
|
|
}
|
|
|
|
|
2021-04-14 00:43:11 +00:00
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum SettingsChange {
|
|
|
|
Audio(Audio),
|
2021-05-14 12:27:15 +00:00
|
|
|
Chat(Chat),
|
2021-04-14 00:43:11 +00:00
|
|
|
Control(Control),
|
|
|
|
Gamepad(Gamepad),
|
|
|
|
Gameplay(Gameplay),
|
|
|
|
Graphics(Graphics),
|
|
|
|
Interface(Interface),
|
|
|
|
Language(Language),
|
|
|
|
Networking(Networking),
|
2023-04-25 20:01:18 +00:00
|
|
|
Accessibility(Accessibility),
|
2021-04-14 00:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! settings_change_from {
|
|
|
|
($i: ident) => {
|
|
|
|
impl From<$i> for SettingsChange {
|
|
|
|
fn from(change: $i) -> Self { SettingsChange::$i(change) }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
settings_change_from!(Audio);
|
2021-05-14 12:27:15 +00:00
|
|
|
settings_change_from!(Chat);
|
2021-04-14 00:43:11 +00:00
|
|
|
settings_change_from!(Control);
|
|
|
|
settings_change_from!(Gamepad);
|
|
|
|
settings_change_from!(Gameplay);
|
|
|
|
settings_change_from!(Graphics);
|
|
|
|
settings_change_from!(Interface);
|
|
|
|
settings_change_from!(Language);
|
|
|
|
settings_change_from!(Networking);
|
2023-04-25 20:01:18 +00:00
|
|
|
settings_change_from!(Accessibility);
|
2021-04-14 00:43:11 +00:00
|
|
|
|
|
|
|
impl SettingsChange {
|
|
|
|
pub fn process(self, global_state: &mut GlobalState, session_state: &mut SessionState) {
|
2023-09-28 14:51:32 +00:00
|
|
|
let settings = &mut global_state.settings;
|
2022-05-09 01:11:34 +00:00
|
|
|
|
2021-04-14 00:43:11 +00:00
|
|
|
match self {
|
2021-04-14 00:55:52 +00:00
|
|
|
SettingsChange::Audio(audio_change) => {
|
2022-05-09 01:11:34 +00:00
|
|
|
fn update_volume(audio: &mut AudioVolume, volume: f32) -> f32 {
|
|
|
|
audio.volume = volume;
|
|
|
|
audio.get_checked()
|
|
|
|
}
|
|
|
|
fn update_muted(audio: &mut AudioVolume, muted: bool) -> f32 {
|
|
|
|
audio.muted = muted;
|
|
|
|
audio.get_checked()
|
|
|
|
}
|
|
|
|
|
2021-04-14 00:55:52 +00:00
|
|
|
match audio_change {
|
2021-04-18 19:52:35 +00:00
|
|
|
Audio::AdjustMasterVolume(master_volume) => {
|
2022-05-09 01:11:34 +00:00
|
|
|
let volume_checked =
|
|
|
|
update_volume(&mut settings.audio.master_volume, master_volume);
|
2021-04-18 19:52:35 +00:00
|
|
|
|
2022-05-09 01:11:34 +00:00
|
|
|
global_state.audio.set_master_volume(volume_checked);
|
|
|
|
},
|
|
|
|
Audio::MuteMasterVolume(master_muted) => {
|
|
|
|
let volume_checked =
|
|
|
|
update_muted(&mut settings.audio.master_volume, master_muted);
|
|
|
|
|
|
|
|
global_state.audio.set_master_volume(volume_checked);
|
2021-04-18 19:52:35 +00:00
|
|
|
},
|
2021-05-09 09:51:41 +00:00
|
|
|
Audio::AdjustInactiveMasterVolume(inactive_master_volume_perc) => {
|
2022-05-09 01:11:34 +00:00
|
|
|
settings.audio.inactive_master_volume_perc.volume =
|
|
|
|
inactive_master_volume_perc;
|
|
|
|
},
|
|
|
|
Audio::MuteInactiveMasterVolume(inactive_master_volume_muted) => {
|
|
|
|
settings.audio.inactive_master_volume_perc.muted =
|
|
|
|
inactive_master_volume_muted;
|
2021-04-18 19:52:35 +00:00
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Audio::AdjustMusicVolume(music_volume) => {
|
2022-05-09 01:11:34 +00:00
|
|
|
let volume_checked =
|
|
|
|
update_volume(&mut settings.audio.music_volume, music_volume);
|
2021-04-14 00:43:11 +00:00
|
|
|
|
2022-05-09 01:11:34 +00:00
|
|
|
global_state.audio.set_music_volume(volume_checked);
|
|
|
|
},
|
|
|
|
Audio::MuteMusicVolume(music_muted) => {
|
|
|
|
let volume_checked =
|
|
|
|
update_muted(&mut settings.audio.music_volume, music_muted);
|
|
|
|
|
|
|
|
global_state.audio.set_music_volume(volume_checked);
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
|
|
|
Audio::AdjustSfxVolume(sfx_volume) => {
|
2022-05-09 01:11:34 +00:00
|
|
|
let volume_checked =
|
|
|
|
update_volume(&mut settings.audio.sfx_volume, sfx_volume);
|
|
|
|
|
|
|
|
global_state.audio.set_sfx_volume(volume_checked);
|
|
|
|
},
|
|
|
|
Audio::MuteSfxVolume(sfx_muted) => {
|
|
|
|
let volume_checked =
|
|
|
|
update_muted(&mut settings.audio.sfx_volume, sfx_muted);
|
2021-04-14 00:43:11 +00:00
|
|
|
|
2022-05-09 01:11:34 +00:00
|
|
|
global_state.audio.set_sfx_volume(volume_checked);
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
2022-03-23 06:50:38 +00:00
|
|
|
Audio::AdjustAmbienceVolume(ambience_volume) => {
|
|
|
|
global_state.audio.set_ambience_volume(ambience_volume);
|
|
|
|
|
2022-05-09 01:11:34 +00:00
|
|
|
settings.audio.ambience_volume.volume = ambience_volume;
|
|
|
|
},
|
|
|
|
Audio::MuteAmbienceVolume(ambience_muted) => {
|
|
|
|
let volume_checked =
|
|
|
|
update_muted(&mut settings.audio.ambience_volume, ambience_muted);
|
|
|
|
|
|
|
|
global_state.audio.set_ambience_volume(volume_checked);
|
2022-03-23 06:50:38 +00:00
|
|
|
},
|
2022-08-14 01:57:58 +00:00
|
|
|
Audio::AdjustMusicSpacing(multiplier) => {
|
2022-08-11 02:56:40 +00:00
|
|
|
global_state.audio.set_music_spacing(multiplier);
|
2022-08-01 17:41:44 +00:00
|
|
|
|
2022-08-11 02:56:40 +00:00
|
|
|
settings.audio.music_spacing = multiplier;
|
2022-08-01 17:41:44 +00:00
|
|
|
},
|
2023-07-30 08:10:36 +00:00
|
|
|
Audio::ToggleCombatMusic(combat_music_enabled) => {
|
|
|
|
global_state.audio.combat_music_enabled = combat_music_enabled
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
//Audio::ChangeAudioDevice(name) => {
|
|
|
|
// global_state.audio.set_device(name.clone());
|
2021-04-14 00:43:11 +00:00
|
|
|
|
2021-04-14 00:55:52 +00:00
|
|
|
// settings.audio.output = AudioOutput::Device(name);
|
|
|
|
//},
|
|
|
|
Audio::ResetAudioSettings => {
|
|
|
|
settings.audio = AudioSettings::default();
|
2022-05-09 01:11:34 +00:00
|
|
|
|
|
|
|
let audio = &mut global_state.audio;
|
|
|
|
|
|
|
|
// TODO: check if updating the master volume is necessary
|
|
|
|
// (it wasn't done before)
|
|
|
|
audio.set_master_volume(settings.audio.master_volume.get_checked());
|
|
|
|
audio.set_music_volume(settings.audio.music_volume.get_checked());
|
|
|
|
audio.set_sfx_volume(settings.audio.sfx_volume.get_checked());
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
|
|
|
}
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
2021-05-14 12:27:15 +00:00
|
|
|
SettingsChange::Chat(chat_change) => {
|
|
|
|
let chat_tabs = &mut settings.chat.chat_tabs;
|
|
|
|
match chat_change {
|
2021-08-01 19:40:06 +00:00
|
|
|
Chat::Transp(chat_opacity) => {
|
|
|
|
settings.chat.chat_opacity = chat_opacity;
|
2021-05-14 12:27:15 +00:00
|
|
|
},
|
|
|
|
Chat::CharName(chat_char_name) => {
|
|
|
|
settings.chat.chat_character_name = chat_char_name;
|
|
|
|
},
|
|
|
|
Chat::ChangeChatTab(chat_tab_index) => {
|
|
|
|
settings.chat.chat_tab_index =
|
|
|
|
chat_tab_index.filter(|i| *i < chat_tabs.len());
|
|
|
|
},
|
|
|
|
Chat::ChatTabUpdate(i, chat_tab) => {
|
|
|
|
if i < chat_tabs.len() {
|
|
|
|
chat_tabs[i] = chat_tab;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Chat::ChatTabInsert(i, chat_tab) => {
|
|
|
|
if i <= chat_tabs.len() {
|
|
|
|
settings.chat.chat_tabs.insert(i, chat_tab);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Chat::ChatTabMove(i, j) => {
|
|
|
|
if i < chat_tabs.len() && j < chat_tabs.len() {
|
|
|
|
let chat_tab = settings.chat.chat_tabs.remove(i);
|
|
|
|
settings.chat.chat_tabs.insert(j, chat_tab);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Chat::ChatTabRemove(i) => {
|
|
|
|
if i < chat_tabs.len() {
|
|
|
|
settings.chat.chat_tabs.remove(i);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Chat::ResetChatSettings => {
|
|
|
|
settings.chat = ChatSettings::default();
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2021-04-14 00:43:11 +00:00
|
|
|
SettingsChange::Control(control_change) => match control_change {
|
|
|
|
Control::ChangeBinding(game_input) => {
|
|
|
|
global_state.window.set_keybinding_mode(game_input);
|
|
|
|
},
|
2022-01-07 20:30:30 +00:00
|
|
|
Control::RemoveBinding(game_input) => {
|
|
|
|
settings.controls.remove_binding(game_input);
|
|
|
|
},
|
|
|
|
Control::ToggleKeybindingMode => {
|
|
|
|
global_state.window.toggle_keybinding_mode();
|
|
|
|
},
|
2021-04-14 00:43:11 +00:00
|
|
|
Control::ResetKeyBindings => {
|
2021-04-14 00:55:52 +00:00
|
|
|
settings.controls = ControlSettings::default();
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
SettingsChange::Gamepad(gamepad_change) => match gamepad_change {},
|
2021-04-14 00:55:52 +00:00
|
|
|
SettingsChange::Gameplay(gameplay_change) => {
|
2023-09-28 14:51:32 +00:00
|
|
|
let window = &mut global_state.window;
|
2021-04-14 00:55:52 +00:00
|
|
|
match gameplay_change {
|
|
|
|
Gameplay::AdjustMousePan(sensitivity) => {
|
|
|
|
window.pan_sensitivity = sensitivity;
|
|
|
|
settings.gameplay.pan_sensitivity = sensitivity;
|
|
|
|
},
|
|
|
|
Gameplay::AdjustMouseZoom(sensitivity) => {
|
|
|
|
window.zoom_sensitivity = sensitivity;
|
|
|
|
settings.gameplay.zoom_sensitivity = sensitivity;
|
|
|
|
},
|
|
|
|
Gameplay::AdjustCameraClamp(angle) => {
|
|
|
|
settings.gameplay.camera_clamp_angle = angle;
|
|
|
|
},
|
2023-10-13 19:28:56 +00:00
|
|
|
Gameplay::AdjustWalkingSpeed(speed) => {
|
|
|
|
settings.gameplay.walking_speed = speed;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Gameplay::ToggleControllerYInvert(controller_y_inverted) => {
|
|
|
|
window.controller_settings.pan_invert_y = controller_y_inverted;
|
|
|
|
settings.controller.pan_invert_y = controller_y_inverted;
|
|
|
|
},
|
|
|
|
Gameplay::ToggleMouseYInvert(mouse_y_inverted) => {
|
|
|
|
window.mouse_y_inversion = mouse_y_inverted;
|
|
|
|
settings.gameplay.mouse_y_inversion = mouse_y_inverted;
|
|
|
|
},
|
|
|
|
Gameplay::ToggleZoomInvert(zoom_inverted) => {
|
|
|
|
window.zoom_inversion = zoom_inverted;
|
|
|
|
settings.gameplay.zoom_inversion = zoom_inverted;
|
|
|
|
},
|
|
|
|
Gameplay::ToggleSmoothPan(smooth_pan_enabled) => {
|
|
|
|
settings.gameplay.smooth_pan_enable = smooth_pan_enabled;
|
|
|
|
},
|
|
|
|
Gameplay::ChangeFreeLookBehavior(behavior) => {
|
|
|
|
settings.gameplay.free_look_behavior = behavior;
|
|
|
|
},
|
|
|
|
Gameplay::ChangeAutoWalkBehavior(behavior) => {
|
|
|
|
settings.gameplay.auto_walk_behavior = behavior;
|
|
|
|
},
|
2023-10-13 19:28:56 +00:00
|
|
|
Gameplay::ChangeWalkingSpeedBehavior(behavior) => {
|
|
|
|
settings.gameplay.walking_speed_behavior = behavior;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Gameplay::ChangeCameraClampBehavior(behavior) => {
|
|
|
|
settings.gameplay.camera_clamp_behavior = behavior;
|
|
|
|
},
|
2023-02-21 01:55:49 +00:00
|
|
|
Gameplay::ChangeZoomLockBehavior(state) => {
|
|
|
|
settings.gameplay.zoom_lock_behavior = state;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Gameplay::ChangeStopAutoWalkOnInput(state) => {
|
|
|
|
settings.gameplay.stop_auto_walk_on_input = state;
|
|
|
|
},
|
|
|
|
Gameplay::ChangeAutoCamera(state) => {
|
|
|
|
settings.gameplay.auto_camera = state;
|
|
|
|
},
|
2022-05-23 23:09:47 +00:00
|
|
|
Gameplay::ChangeBowZoom(state) => {
|
|
|
|
settings.gameplay.bow_zoom = state;
|
|
|
|
},
|
2023-02-21 01:55:49 +00:00
|
|
|
Gameplay::ChangeZoomLock(state) => {
|
|
|
|
settings.gameplay.zoom_lock = state;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Gameplay::ResetGameplaySettings => {
|
|
|
|
// Reset Gameplay Settings
|
|
|
|
settings.gameplay = GameplaySettings::default();
|
|
|
|
// Reset Gamepad and Controller Settings
|
|
|
|
settings.controller = GamepadSettings::default();
|
|
|
|
window.controller_settings = ControllerSettings::from(&settings.controller);
|
|
|
|
// Pan Sensitivity
|
|
|
|
window.pan_sensitivity = settings.gameplay.pan_sensitivity;
|
|
|
|
// Zoom Sensitivity
|
|
|
|
window.zoom_sensitivity = settings.gameplay.zoom_sensitivity;
|
|
|
|
// Invert Scroll Zoom
|
|
|
|
window.zoom_inversion = settings.gameplay.zoom_inversion;
|
|
|
|
// Invert Mouse Y Axis
|
|
|
|
window.mouse_y_inversion = settings.gameplay.mouse_y_inversion;
|
|
|
|
},
|
|
|
|
}
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
SettingsChange::Graphics(graphics_change) => {
|
2022-10-27 12:31:32 +00:00
|
|
|
let mut change_preset = false;
|
2022-10-26 22:15:07 +00:00
|
|
|
|
2021-04-14 00:55:52 +00:00
|
|
|
match graphics_change {
|
2022-08-22 03:21:39 +00:00
|
|
|
Graphics::AdjustTerrainViewDistance(terrain_vd) => {
|
|
|
|
adjust_terrain_view_distance(terrain_vd, settings, session_state)
|
|
|
|
},
|
|
|
|
Graphics::AdjustEntityViewDistance(entity_vd) => {
|
|
|
|
adjust_entity_view_distance(entity_vd, settings, session_state)
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
2022-05-10 11:36:44 +00:00
|
|
|
Graphics::AdjustLodDistance(lod_distance) => {
|
|
|
|
session_state
|
|
|
|
.client
|
|
|
|
.borrow_mut()
|
|
|
|
.set_lod_distance(lod_distance);
|
|
|
|
|
|
|
|
settings.graphics.lod_distance = lod_distance;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Graphics::AdjustLodDetail(lod_detail) => {
|
|
|
|
session_state.scene.lod.set_detail(lod_detail);
|
2021-04-14 00:43:11 +00:00
|
|
|
|
2021-04-14 00:55:52 +00:00
|
|
|
settings.graphics.lod_detail = lod_detail;
|
|
|
|
},
|
|
|
|
Graphics::AdjustSpriteRenderDistance(sprite_render_distance) => {
|
|
|
|
settings.graphics.sprite_render_distance = sprite_render_distance;
|
|
|
|
},
|
|
|
|
Graphics::AdjustFigureLoDRenderDistance(figure_lod_render_distance) => {
|
|
|
|
settings.graphics.figure_lod_render_distance = figure_lod_render_distance;
|
|
|
|
},
|
|
|
|
Graphics::ChangeMaxFPS(fps) => {
|
|
|
|
settings.graphics.max_fps = fps;
|
|
|
|
},
|
2021-10-10 15:33:31 +00:00
|
|
|
Graphics::ChangeMaxBackgroundFPS(fps) => {
|
|
|
|
settings.graphics.max_background_fps = fps;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Graphics::ChangeFOV(new_fov) => {
|
|
|
|
settings.graphics.fov = new_fov;
|
|
|
|
session_state.scene.camera_mut().set_fov_deg(new_fov);
|
|
|
|
session_state
|
|
|
|
.scene
|
|
|
|
.camera_mut()
|
2022-09-08 19:51:02 +00:00
|
|
|
.compute_dependents(&session_state.client.borrow().state().terrain());
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
|
|
|
Graphics::ChangeGamma(new_gamma) => {
|
|
|
|
settings.graphics.gamma = new_gamma;
|
|
|
|
},
|
|
|
|
Graphics::ChangeExposure(new_exposure) => {
|
|
|
|
settings.graphics.exposure = new_exposure;
|
|
|
|
},
|
|
|
|
Graphics::ChangeAmbiance(new_ambiance) => {
|
|
|
|
settings.graphics.ambiance = new_ambiance;
|
|
|
|
},
|
|
|
|
Graphics::ChangeRenderMode(new_render_mode) => {
|
2023-01-10 01:57:44 +00:00
|
|
|
change_render_mode(*new_render_mode, &mut global_state.window, settings);
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
|
|
|
Graphics::ChangeFullscreenMode(new_fullscreen_settings) => {
|
|
|
|
global_state
|
|
|
|
.window
|
|
|
|
.set_fullscreen_mode(new_fullscreen_settings);
|
|
|
|
settings.graphics.fullscreen = new_fullscreen_settings;
|
|
|
|
},
|
|
|
|
Graphics::ToggleParticlesEnabled(particles_enabled) => {
|
|
|
|
settings.graphics.particles_enabled = particles_enabled;
|
|
|
|
},
|
2022-01-28 05:06:11 +00:00
|
|
|
Graphics::ToggleWeaponTrailsEnabled(weapon_trails_enabled) => {
|
|
|
|
settings.graphics.weapon_trails_enabled = weapon_trails_enabled;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Graphics::AdjustWindowSize(new_size) => {
|
|
|
|
global_state.window.set_size(new_size.into());
|
|
|
|
settings.graphics.window_size = new_size;
|
|
|
|
},
|
|
|
|
Graphics::ResetGraphicsSettings => {
|
|
|
|
settings.graphics = GraphicsSettings::default();
|
2022-10-27 12:31:32 +00:00
|
|
|
change_preset = true;
|
|
|
|
// Fullscreen mode
|
|
|
|
global_state
|
|
|
|
.window
|
|
|
|
.set_fullscreen_mode(settings.graphics.fullscreen);
|
|
|
|
// Window size
|
|
|
|
global_state
|
|
|
|
.window
|
|
|
|
.set_size(settings.graphics.window_size.into());
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
2022-10-26 22:15:07 +00:00
|
|
|
Graphics::ChangeGraphicsSettings(f) => {
|
|
|
|
settings.graphics = f(settings.graphics.clone());
|
2022-10-27 12:31:32 +00:00
|
|
|
change_preset = true;
|
2022-10-26 22:15:07 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-10-27 12:31:32 +00:00
|
|
|
if change_preset {
|
2022-10-26 22:15:07 +00:00
|
|
|
let graphics = &settings.graphics;
|
|
|
|
// View distance
|
|
|
|
client_set_view_distance(settings, session_state);
|
|
|
|
// FOV
|
|
|
|
session_state.scene.camera_mut().set_fov_deg(graphics.fov);
|
|
|
|
session_state
|
|
|
|
.scene
|
|
|
|
.camera_mut()
|
|
|
|
.compute_dependents(&session_state.client.borrow().state().terrain());
|
|
|
|
// LoD
|
|
|
|
session_state.scene.lod.set_detail(graphics.lod_detail);
|
|
|
|
// LoD distance
|
|
|
|
session_state
|
|
|
|
.client
|
|
|
|
.borrow_mut()
|
|
|
|
.set_lod_distance(graphics.lod_distance);
|
|
|
|
// Render mode
|
|
|
|
global_state
|
|
|
|
.window
|
|
|
|
.renderer_mut()
|
|
|
|
.set_render_mode(graphics.render_mode.clone())
|
|
|
|
.unwrap();
|
2021-04-14 00:55:52 +00:00
|
|
|
}
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
SettingsChange::Interface(interface_change) => {
|
|
|
|
match interface_change {
|
|
|
|
Interface::Sct(sct) => {
|
|
|
|
settings.interface.sct = sct;
|
|
|
|
},
|
2022-04-18 14:41:49 +00:00
|
|
|
Interface::SctRoundDamage(sct_round_damage) => {
|
|
|
|
settings.interface.sct_damage_rounding = sct_round_damage;
|
|
|
|
},
|
2022-04-19 16:37:28 +00:00
|
|
|
Interface::SctDamageAccumDuration(sct_dmg_accum_duration) => {
|
|
|
|
settings.interface.sct_dmg_accum_duration = sct_dmg_accum_duration;
|
|
|
|
},
|
2022-06-16 16:31:57 +00:00
|
|
|
Interface::SctIncomingDamage(sct_inc_dmg) => {
|
|
|
|
settings.interface.sct_inc_dmg = sct_inc_dmg;
|
2022-06-14 21:11:58 +00:00
|
|
|
},
|
2022-04-19 16:37:28 +00:00
|
|
|
Interface::SctIncomingDamageAccumDuration(sct_inc_dmg_accum_duration) => {
|
|
|
|
settings.interface.sct_inc_dmg_accum_duration = sct_inc_dmg_accum_duration;
|
|
|
|
},
|
2021-12-31 21:42:01 +00:00
|
|
|
Interface::SpeechBubbleSelf(sbdm) => {
|
|
|
|
settings.interface.speech_bubble_self = sbdm;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Interface::SpeechBubbleDarkMode(sbdm) => {
|
|
|
|
settings.interface.speech_bubble_dark_mode = sbdm;
|
|
|
|
},
|
|
|
|
Interface::SpeechBubbleIcon(sbi) => {
|
|
|
|
settings.interface.speech_bubble_icon = sbi;
|
|
|
|
},
|
|
|
|
Interface::ToggleHelp(_) => {
|
|
|
|
// implemented in hud
|
|
|
|
},
|
|
|
|
Interface::ToggleDebug(toggle_debug) => {
|
|
|
|
settings.interface.toggle_debug = toggle_debug;
|
|
|
|
},
|
2021-05-04 20:12:26 +00:00
|
|
|
Interface::ToggleHitboxes(toggle_hitboxes) => {
|
|
|
|
settings.interface.toggle_hitboxes = toggle_hitboxes;
|
|
|
|
},
|
2021-06-21 19:16:03 +00:00
|
|
|
Interface::ToggleChat(toggle_chat) => {
|
|
|
|
settings.interface.toggle_chat = toggle_chat;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Interface::ToggleTips(loading_tips) => {
|
|
|
|
settings.interface.loading_tips = loading_tips;
|
|
|
|
},
|
2021-09-24 16:03:05 +00:00
|
|
|
Interface::ToggleHotkeyHints(toggle_hotkey_hints) => {
|
|
|
|
settings.interface.toggle_hotkey_hints = toggle_hotkey_hints;
|
|
|
|
},
|
2021-08-01 19:40:06 +00:00
|
|
|
Interface::CrosshairTransp(crosshair_opacity) => {
|
|
|
|
settings.interface.crosshair_opacity = crosshair_opacity;
|
2021-04-14 00:55:52 +00:00
|
|
|
},
|
|
|
|
Interface::CrosshairType(crosshair_type) => {
|
|
|
|
settings.interface.crosshair_type = crosshair_type;
|
|
|
|
},
|
|
|
|
Interface::Intro(intro_show) => {
|
|
|
|
settings.interface.intro_show = intro_show;
|
|
|
|
},
|
|
|
|
Interface::ToggleXpBar(xp_bar) => {
|
|
|
|
settings.interface.xp_bar = xp_bar;
|
|
|
|
},
|
|
|
|
Interface::ToggleBarNumbers(bar_numbers) => {
|
|
|
|
settings.interface.bar_numbers = bar_numbers;
|
|
|
|
},
|
2021-09-15 12:04:44 +00:00
|
|
|
Interface::ToggleAlwaysShowBars(always_show_bars) => {
|
|
|
|
settings.interface.always_show_bars = always_show_bars;
|
|
|
|
},
|
2022-10-24 11:44:11 +00:00
|
|
|
Interface::TogglePoiseBar(enable_poise_bar) => {
|
|
|
|
settings.interface.enable_poise_bar = enable_poise_bar;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Interface::ToggleShortcutNumbers(shortcut_numbers) => {
|
|
|
|
settings.interface.shortcut_numbers = shortcut_numbers;
|
|
|
|
},
|
|
|
|
Interface::BuffPosition(buff_position) => {
|
|
|
|
settings.interface.buff_position = buff_position;
|
|
|
|
},
|
|
|
|
Interface::UiScale(scale_change) => {
|
|
|
|
settings.interface.ui_scale = session_state.hud.scale_change(scale_change);
|
|
|
|
},
|
2021-04-14 13:29:22 +00:00
|
|
|
Interface::MinimapShow(state) => {
|
|
|
|
settings.interface.minimap_show = state;
|
|
|
|
},
|
|
|
|
Interface::MinimapFaceNorth(state) => {
|
|
|
|
settings.interface.minimap_face_north = state;
|
|
|
|
},
|
2021-04-19 18:51:53 +00:00
|
|
|
Interface::MinimapZoom(minimap_zoom) => {
|
|
|
|
settings.interface.minimap_zoom = minimap_zoom;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Interface::MapZoom(map_zoom) => {
|
|
|
|
settings.interface.map_zoom = map_zoom;
|
|
|
|
},
|
|
|
|
Interface::MapShowTopoMap(map_show_topo_map) => {
|
|
|
|
settings.interface.map_show_topo_map = map_show_topo_map;
|
|
|
|
},
|
|
|
|
Interface::MapShowDifficulty(map_show_difficulty) => {
|
|
|
|
settings.interface.map_show_difficulty = map_show_difficulty;
|
|
|
|
},
|
|
|
|
Interface::MapShowTowns(map_show_towns) => {
|
|
|
|
settings.interface.map_show_towns = map_show_towns;
|
|
|
|
},
|
|
|
|
Interface::MapShowDungeons(map_show_dungeons) => {
|
|
|
|
settings.interface.map_show_dungeons = map_show_dungeons;
|
|
|
|
},
|
|
|
|
Interface::MapShowCastles(map_show_castles) => {
|
|
|
|
settings.interface.map_show_castles = map_show_castles;
|
|
|
|
},
|
2022-09-26 14:46:30 +00:00
|
|
|
Interface::MapShowBridges(map_show_bridges) => {
|
|
|
|
settings.interface.map_show_bridges = map_show_bridges;
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Interface::MapShowCaves(map_show_caves) => {
|
|
|
|
settings.interface.map_show_caves = map_show_caves;
|
|
|
|
},
|
|
|
|
Interface::MapShowTrees(map_show_trees) => {
|
|
|
|
settings.interface.map_show_trees = map_show_trees;
|
|
|
|
},
|
2021-05-03 02:00:23 +00:00
|
|
|
Interface::MapShowPeaks(map_show_peaks) => {
|
|
|
|
settings.interface.map_show_peaks = map_show_peaks;
|
|
|
|
},
|
2022-01-17 22:45:51 +00:00
|
|
|
Interface::MapShowBiomes(map_show_biomes) => {
|
|
|
|
settings.interface.map_show_biomes = map_show_biomes;
|
|
|
|
},
|
2021-05-14 00:46:17 +00:00
|
|
|
Interface::MapShowVoxelMap(map_show_voxel_map) => {
|
|
|
|
settings.interface.map_show_voxel_map = map_show_voxel_map;
|
|
|
|
},
|
2022-06-14 21:11:58 +00:00
|
|
|
Interface::AccumExperience(accum_experience) => {
|
|
|
|
settings.interface.accum_experience = accum_experience;
|
|
|
|
},
|
2023-08-17 15:24:05 +00:00
|
|
|
Interface::SlotsUsePrefixes(slots_use_prefixes) => {
|
|
|
|
settings.interface.slots_use_prefixes = slots_use_prefixes;
|
|
|
|
session_state.hud.set_slots_use_prefixes(slots_use_prefixes);
|
|
|
|
},
|
|
|
|
Interface::SlotsPrefixSwitchPoint(slots_prefix_switch_point) => {
|
|
|
|
settings.interface.slots_prefix_switch_point = slots_prefix_switch_point;
|
|
|
|
session_state
|
|
|
|
.hud
|
|
|
|
.set_slots_prefix_switch_point(slots_prefix_switch_point);
|
|
|
|
},
|
2021-04-14 00:55:52 +00:00
|
|
|
Interface::ResetInterfaceSettings => {
|
|
|
|
// Reset Interface Settings
|
|
|
|
let tmp = settings.interface.intro_show;
|
|
|
|
settings.interface = InterfaceSettings::default();
|
|
|
|
settings.interface.intro_show = tmp;
|
|
|
|
// Update Current Scaling Mode
|
|
|
|
session_state
|
|
|
|
.hud
|
|
|
|
.set_scaling_mode(settings.interface.ui_scale);
|
|
|
|
},
|
|
|
|
}
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
|
|
|
SettingsChange::Language(language_change) => match language_change {
|
|
|
|
Language::ChangeLanguage(new_language) => {
|
2021-04-14 00:55:52 +00:00
|
|
|
settings.language.selected_language = new_language.language_identifier;
|
2021-05-07 11:24:37 +00:00
|
|
|
global_state.i18n =
|
|
|
|
LocalizationHandle::load_expect(&settings.language.selected_language);
|
2021-04-24 14:39:35 +00:00
|
|
|
global_state
|
|
|
|
.i18n
|
|
|
|
.set_english_fallback(settings.language.use_english_fallback);
|
2021-04-14 00:43:11 +00:00
|
|
|
session_state.hud.update_fonts(&global_state.i18n.read());
|
|
|
|
},
|
2021-04-24 14:39:35 +00:00
|
|
|
Language::ToggleEnglishFallback(toggle_fallback) => {
|
|
|
|
settings.language.use_english_fallback = toggle_fallback;
|
|
|
|
global_state
|
|
|
|
.i18n
|
|
|
|
.set_english_fallback(settings.language.use_english_fallback);
|
|
|
|
},
|
2021-04-14 00:43:11 +00:00
|
|
|
},
|
2022-08-15 15:58:37 +00:00
|
|
|
SettingsChange::Networking(networking_change) => match networking_change {
|
2022-08-22 03:21:39 +00:00
|
|
|
Networking::AdjustTerrainViewDistance(terrain_vd) => {
|
|
|
|
adjust_terrain_view_distance(terrain_vd, settings, session_state)
|
|
|
|
},
|
|
|
|
Networking::AdjustEntityViewDistance(entity_vd) => {
|
|
|
|
adjust_entity_view_distance(entity_vd, settings, session_state)
|
2022-08-15 15:58:37 +00:00
|
|
|
},
|
|
|
|
Networking::ChangePlayerPhysicsBehavior {
|
|
|
|
server_authoritative,
|
|
|
|
} => {
|
|
|
|
settings.networking.player_physics_behavior = server_authoritative;
|
|
|
|
session_state
|
|
|
|
.client
|
|
|
|
.borrow_mut()
|
|
|
|
.request_player_physics(server_authoritative);
|
|
|
|
},
|
|
|
|
Networking::ToggleLossyTerrainCompression(lossy_terrain_compression) => {
|
|
|
|
settings.networking.lossy_terrain_compression = lossy_terrain_compression;
|
|
|
|
session_state
|
|
|
|
.client
|
|
|
|
.borrow_mut()
|
|
|
|
.request_lossy_terrain_compression(lossy_terrain_compression);
|
|
|
|
},
|
|
|
|
#[cfg(feature = "discord")]
|
|
|
|
Networking::ToggleDiscordIntegration(enabled) => {
|
|
|
|
use crate::discord::Discord;
|
|
|
|
|
|
|
|
settings.networking.enable_discord_integration = enabled;
|
|
|
|
if enabled {
|
|
|
|
global_state.discord = Discord::start(&global_state.tokio_runtime);
|
|
|
|
|
|
|
|
#[cfg(feature = "singleplayer")]
|
2023-09-17 17:11:19 +00:00
|
|
|
let singleplayer = global_state.singleplayer.is_running();
|
2022-08-15 15:58:37 +00:00
|
|
|
#[cfg(not(feature = "singleplayer"))]
|
|
|
|
let singleplayer = false;
|
|
|
|
|
|
|
|
if singleplayer {
|
|
|
|
global_state.discord.join_singleplayer();
|
|
|
|
} else {
|
|
|
|
global_state.discord.join_server(
|
|
|
|
session_state.client.borrow().server_info().name.clone(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
global_state.discord.clear_activity();
|
|
|
|
global_state.discord = Discord::Inactive;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2023-04-25 20:01:18 +00:00
|
|
|
SettingsChange::Accessibility(accessibility_change) => match accessibility_change {
|
|
|
|
Accessibility::ChangeRenderMode(new_render_mode) => {
|
|
|
|
change_render_mode(*new_render_mode, &mut global_state.window, settings);
|
2023-04-26 14:20:56 +00:00
|
|
|
},
|
|
|
|
Accessibility::SetSubtitles(enabled) => {
|
|
|
|
global_state.settings.audio.subtitles = enabled;
|
|
|
|
global_state.audio.set_subtitles(enabled);
|
|
|
|
},
|
2023-04-25 20:01:18 +00:00
|
|
|
},
|
2021-04-14 00:43:11 +00:00
|
|
|
}
|
2022-08-21 06:16:12 +00:00
|
|
|
global_state
|
|
|
|
.settings
|
|
|
|
.save_to_file_warn(&global_state.config_dir);
|
2021-04-14 00:43:11 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-21 06:16:12 +00:00
|
|
|
|
2022-08-22 03:21:39 +00:00
|
|
|
use crate::settings::Settings;
|
|
|
|
|
2023-01-10 01:57:44 +00:00
|
|
|
pub fn change_render_mode(
|
|
|
|
new_render_mode: RenderMode,
|
|
|
|
window: &mut Window,
|
|
|
|
settings: &mut Settings,
|
|
|
|
) {
|
|
|
|
// Do this first so if it crashes the setting isn't saved :)
|
|
|
|
window
|
|
|
|
.renderer_mut()
|
|
|
|
.set_render_mode(new_render_mode.clone())
|
|
|
|
.unwrap();
|
|
|
|
settings.graphics.render_mode = new_render_mode;
|
|
|
|
}
|
|
|
|
|
2022-08-22 03:21:39 +00:00
|
|
|
fn adjust_terrain_view_distance(
|
|
|
|
terrain_vd: u32,
|
|
|
|
settings: &mut Settings,
|
2023-10-05 17:35:11 +00:00
|
|
|
session_state: &mut SessionState,
|
2022-08-22 03:21:39 +00:00
|
|
|
) {
|
|
|
|
settings.graphics.terrain_view_distance = terrain_vd;
|
|
|
|
client_set_view_distance(settings, session_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn adjust_entity_view_distance(
|
|
|
|
entity_vd: u32,
|
|
|
|
settings: &mut Settings,
|
2023-10-05 17:35:11 +00:00
|
|
|
session_state: &mut SessionState,
|
2022-08-21 06:16:12 +00:00
|
|
|
) {
|
2022-08-22 03:21:39 +00:00
|
|
|
settings.graphics.entity_view_distance = entity_vd;
|
|
|
|
client_set_view_distance(settings, session_state);
|
|
|
|
}
|
|
|
|
|
2023-10-05 17:35:11 +00:00
|
|
|
fn client_set_view_distance(settings: &Settings, session_state: &mut SessionState) {
|
2022-08-22 03:21:39 +00:00
|
|
|
let view_distances = common::ViewDistances {
|
|
|
|
terrain: settings.graphics.terrain_view_distance,
|
|
|
|
entity: settings.graphics.entity_view_distance,
|
|
|
|
};
|
2022-08-21 06:16:12 +00:00
|
|
|
session_state
|
|
|
|
.client
|
|
|
|
.borrow_mut()
|
2022-08-22 03:21:39 +00:00
|
|
|
.set_view_distances(view_distances);
|
2022-08-21 06:16:12 +00:00
|
|
|
}
|