326 lines
8.9 KiB
Rust
326 lines
8.9 KiB
Rust
|
#![allow(unused)]
|
||
|
|
||
|
use assetpath::AssetPath;
|
||
|
use engine::prelude::*;
|
||
|
use std::{collections::HashMap, env::var, marker::PhantomData};
|
||
|
|
||
|
use crate::game::game::MapInformation;
|
||
|
|
||
|
#[cfg(target_os = "windows")]
|
||
|
pub fn settings_file_dir() -> String {
|
||
|
let b = var("LOCALAPPDATA").expect("couldn't get local appdata variable");
|
||
|
|
||
|
format!("{}\\gavania\\", b)
|
||
|
}
|
||
|
|
||
|
#[cfg(target_os = "linux")]
|
||
|
pub fn settings_file_dir() -> String {
|
||
|
let b = var("HOME").expect("couldn't get HOME variable");
|
||
|
|
||
|
format!("{}/.local/share/gavania/", b)
|
||
|
}
|
||
|
|
||
|
#[cfg(target_os = "macos")]
|
||
|
pub fn settings_file_dir() -> String {
|
||
|
compile_error!("settings directory not set!");
|
||
|
}
|
||
|
|
||
|
create_settings_section!(
|
||
|
LuaScripts,
|
||
|
"Scripts",
|
||
|
{
|
||
|
change_map: AssetPath,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
VulkanSection,
|
||
|
"Vulkan",
|
||
|
{
|
||
|
debugging: bool,
|
||
|
steam_layer: bool,
|
||
|
verbose: bool,
|
||
|
renderdoc: bool,
|
||
|
util: bool,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
WindowSection,
|
||
|
"Window",
|
||
|
{
|
||
|
window_title: String,
|
||
|
width: u32,
|
||
|
height: u32,
|
||
|
fullscreen: bool,
|
||
|
preferred_display: String,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
InputSection,
|
||
|
"Input",
|
||
|
{
|
||
|
keyboard_enabled: bool,
|
||
|
mouse_enabled: bool,
|
||
|
controller_enabled: bool,
|
||
|
axis_enable_deadzone: f32,
|
||
|
axis_disable_deadzone: f32,
|
||
|
trigger_enable_deadzone: f32,
|
||
|
trigger_disable_deadzone: f32,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
GuiSection,
|
||
|
"Gui",
|
||
|
{
|
||
|
font: AssetPath,
|
||
|
default_button: AssetPath,
|
||
|
default_selected_button: AssetPath,
|
||
|
default_click_sound: AssetPath,
|
||
|
default_hover_sound: AssetPath,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
GraphicsSection,
|
||
|
"Graphics",
|
||
|
{
|
||
|
renderer_type: SceneType,
|
||
|
render_scale: f32,
|
||
|
sample_count: u32,
|
||
|
vsync: bool,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
RaytracingSection,
|
||
|
"Raytracing",
|
||
|
{
|
||
|
tris_per_as: u32,
|
||
|
max_samplers: u32,
|
||
|
acceleration_count: u32,
|
||
|
stack_size: u32,
|
||
|
max_lights: u32,
|
||
|
recursion_depth: u32,
|
||
|
use_default_pipeline: bool,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
RasterizerSection,
|
||
|
"Rasterizing",
|
||
|
{
|
||
|
shadow_image_size: u32,
|
||
|
enable_lighting: bool,
|
||
|
use_deferred: bool,
|
||
|
use_shadow_maps: bool,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
EngineSection,
|
||
|
"Engine",
|
||
|
{
|
||
|
tile_directory: AssetPath,
|
||
|
entity_directory: AssetPath,
|
||
|
gltf_directory: AssetPath,
|
||
|
xbox_controller_directory: AssetPath,
|
||
|
steam_controller_directory: AssetPath,
|
||
|
ps4_controller_directory: AssetPath,
|
||
|
light_key: AssetPath,
|
||
|
dark_key: AssetPath,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
AudioSection,
|
||
|
"Audio",
|
||
|
{
|
||
|
master: f32,
|
||
|
music: f32,
|
||
|
gui: f32,
|
||
|
sfx: f32,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
TweakSection,
|
||
|
"Tweaks",
|
||
|
{
|
||
|
enable_gamemode: bool,
|
||
|
enable_backtrace: bool,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
GameSection,
|
||
|
"Game",
|
||
|
{
|
||
|
sounds_directory: AssetPath,
|
||
|
music_directory: AssetPath,
|
||
|
|
||
|
ability_icon_directory: AssetPath,
|
||
|
ability_directory: AssetPath,
|
||
|
slides_directory: AssetPath,
|
||
|
particle_directory: AssetPath,
|
||
|
npc_directory: AssetPath,
|
||
|
|
||
|
camera_distance: f32,
|
||
|
camera_angle: f32,
|
||
|
loot_action_radius: f32,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_section!(
|
||
|
MapInfos,
|
||
|
"Map Infos",
|
||
|
{
|
||
|
directory: AssetPath,
|
||
|
start: String,
|
||
|
[black_list: String],
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_container!(
|
||
|
CoreSettings,
|
||
|
{
|
||
|
vulkan: VulkanSection,
|
||
|
gui: GuiSection,
|
||
|
engine: EngineSection,
|
||
|
game: GameSection,
|
||
|
map_infos: MapInfos,
|
||
|
lua_scripts: LuaScripts,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
create_settings_container!(
|
||
|
UserSettings,
|
||
|
{
|
||
|
window: WindowSection,
|
||
|
input: InputSection,
|
||
|
graphics: GraphicsSection,
|
||
|
ray_tracing: RaytracingSection,
|
||
|
rasterizer: RasterizerSection,
|
||
|
audio: AudioSection,
|
||
|
tweaks: TweakSection,
|
||
|
}
|
||
|
);
|
||
|
|
||
|
impl CoreSettings {
|
||
|
pub fn map_info(&self) -> MapInformation {
|
||
|
MapInformation {
|
||
|
map_directories: vec![self.map_infos.directory.clone()],
|
||
|
start_map: if self.map_infos.start.is_empty() {
|
||
|
None
|
||
|
} else {
|
||
|
Some(self.map_infos.start.clone())
|
||
|
},
|
||
|
black_list: self.map_infos.black_list.clone(),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn into_engine_info<'a>(
|
||
|
core_settings: CoreSettings,
|
||
|
user_settings: UserSettings,
|
||
|
) -> EngineCreateInfo<'a> {
|
||
|
EngineCreateInfo {
|
||
|
app_info: ApplicationInfo::default(),
|
||
|
|
||
|
window_info: WindowCreateInfo {
|
||
|
title: user_settings.window.window_title,
|
||
|
width: user_settings.window.width,
|
||
|
height: user_settings.window.height,
|
||
|
fullscreen: user_settings.window.fullscreen,
|
||
|
requested_display: if user_settings.window.preferred_display.is_empty() {
|
||
|
None
|
||
|
} else {
|
||
|
Some(user_settings.window.preferred_display)
|
||
|
},
|
||
|
},
|
||
|
|
||
|
os_specific_config: OsSpecificConfig {
|
||
|
enable_game_mode: user_settings.tweaks.enable_gamemode,
|
||
|
},
|
||
|
|
||
|
vulkan_debug_info: VulkanDebugInfo {
|
||
|
debugging: core_settings.vulkan.debugging,
|
||
|
steam_layer: core_settings.vulkan.steam_layer,
|
||
|
verbose: core_settings.vulkan.verbose,
|
||
|
renderdoc: core_settings.vulkan.renderdoc,
|
||
|
},
|
||
|
volume_info: {
|
||
|
let mut audio = HashMap::new();
|
||
|
|
||
|
audio.insert("master".to_string(), user_settings.audio.master);
|
||
|
audio.insert("music".to_string(), user_settings.audio.music);
|
||
|
audio.insert("gui".to_string(), user_settings.audio.gui);
|
||
|
audio.insert("sfx".to_string(), user_settings.audio.sfx);
|
||
|
|
||
|
audio
|
||
|
},
|
||
|
|
||
|
gui_info: GuiHandlerCreateInfo {
|
||
|
menu_button: core_settings.gui.default_button,
|
||
|
menu_button_selected: core_settings.gui.default_selected_button,
|
||
|
font: Font::Path(core_settings.gui.font),
|
||
|
click_sound: core_settings.gui.default_click_sound,
|
||
|
hover_sound: core_settings.gui.default_hover_sound,
|
||
|
resource_directory: AssetPath::default(),
|
||
|
},
|
||
|
|
||
|
enable_backtrace: user_settings.tweaks.enable_backtrace,
|
||
|
enable_mouse: user_settings.input.mouse_enabled,
|
||
|
enable_keyboard: user_settings.input.keyboard_enabled,
|
||
|
enable_controller: user_settings.input.controller_enabled,
|
||
|
|
||
|
resource_base_path: String::new(),
|
||
|
|
||
|
controller_deadzones: ControllerDeadzones {
|
||
|
axis_enable_deadzone: user_settings.input.axis_enable_deadzone,
|
||
|
axis_disable_deadzone: user_settings.input.axis_disable_deadzone,
|
||
|
trigger_enable_deadzone: user_settings.input.trigger_enable_deadzone,
|
||
|
trigger_disable_deadzone: user_settings.input.trigger_disable_deadzone,
|
||
|
},
|
||
|
|
||
|
controller_directories: ControllerPictureDirectories {
|
||
|
xbox_path: core_settings.engine.xbox_controller_directory,
|
||
|
steam_path: core_settings.engine.steam_controller_directory,
|
||
|
ps4_path: core_settings.engine.ps4_controller_directory,
|
||
|
},
|
||
|
asset_directories: AssetDirectories {
|
||
|
entity_file_directory: core_settings.engine.entity_directory,
|
||
|
gltf_file_directory: core_settings.engine.gltf_directory,
|
||
|
tile_file_directory: core_settings.engine.tile_directory,
|
||
|
},
|
||
|
|
||
|
graphics_info: GraphicsInfo {
|
||
|
sample_count: VkSampleCountFlags::from(user_settings.graphics.sample_count),
|
||
|
render_type: user_settings.graphics.renderer_type,
|
||
|
render_scale: user_settings.graphics.render_scale,
|
||
|
vsync: user_settings.graphics.vsync,
|
||
|
},
|
||
|
raytracing_info: RaytracingInfo {
|
||
|
triangles_per_as: user_settings.ray_tracing.tris_per_as,
|
||
|
accelerate_buffer_size: user_settings.ray_tracing.acceleration_count,
|
||
|
stack_size: user_settings.ray_tracing.stack_size,
|
||
|
max_lights: user_settings.ray_tracing.max_lights,
|
||
|
recursion_depth: user_settings.ray_tracing.recursion_depth,
|
||
|
use_default_pipeline: user_settings.ray_tracing.use_default_pipeline,
|
||
|
max_samplers: user_settings.ray_tracing.max_samplers,
|
||
|
},
|
||
|
rasterizer_info: RasterizerInfo {
|
||
|
shadow_image_size: user_settings.rasterizer.shadow_image_size,
|
||
|
enable_lighting: user_settings.rasterizer.enable_lighting,
|
||
|
use_deferred: user_settings.rasterizer.use_deferred,
|
||
|
use_shadow_maps: user_settings.rasterizer.use_shadow_maps,
|
||
|
},
|
||
|
key_backgrounds: ButtonBackgrounds {
|
||
|
light: core_settings.engine.light_key,
|
||
|
dark: core_settings.engine.dark_key,
|
||
|
},
|
||
|
}
|
||
|
}
|