voxelcore/src/settings.hpp
alexei-zebra ab7f542d61
Add display settings for the wayland window frame
The frame the native wayland backend draws gets three switches in the
display tab: a narrow 24px bar instead of the 48px one, the shadow with
the outer resize area, and redrawing the content while the window is
resized (off keeps the previous behaviour of stretching the last frame).

The settings are applied at runtime: the bar geometry is rebuilt and the
surface is resized together with the toplevel geometry, no restart needed.
The narrow bar drops the insets and the gap of its controls, so that they
sit flush against the window edge.

The switches are hidden outside of the wayland backend, which reports its
name through Window::getBackendName().
2026-10-10 12:23:42 +03:00

153 lines
5.4 KiB
C++

#pragma once
#include <string>
#include <unordered_map>
#include "data/setting.hpp"
#include "constants.hpp"
#include "typedefs.hpp"
struct AudioSettings {
/// @brief try to initialize AL backend
FlagSetting enabled {true};
FlagSetting recordingEnabled {false};
NumberSetting volumeMaster {1.0f, 0.0f, 1.0f, setting_format::percent};
NumberSetting volumeRegular {1.0f, 0.0f, 1.0f, setting_format::percent};
NumberSetting volumeUI {1.0f, 0.0f, 1.0f, setting_format::percent};
NumberSetting volumeAmbient {1.0f, 0.0f, 1.0f, setting_format::percent};
NumberSetting volumeMusic {1.0f, 0.0f, 1.0f, setting_format::percent};
StringSetting inputDevice {""};
FlagSetting acousticEffects {true};
};
struct DisplaySettings {
/// @brief Window mode (windowed/fullscreen/borderless)
IntegerSetting windowMode {0, 0, 2};
/// @brief Window width (pixels)
IntegerSetting width {1280};
/// @brief Window height (pixels)
IntegerSetting height {720};
/// @brief Anti-aliasing samples
IntegerSetting samples {0};
/// @brief Framerate limit
IntegerSetting framerate {-1, -1, 120};
/// @brief Limit framerate when window is iconified
FlagSetting limitFpsIconified {false};
/// @brief Adaptive framerate in menu (experimental)
FlagSetting adaptiveFpsInMenu {false};
/// @brief Draw the narrow (24px) window bar instead of the 48px one
FlagSetting compactWindowBar {false};
/// @brief Draw the window shadow and keep the outer area for resizing
FlagSetting windowShadow {true};
/// @brief Render the window content every frame while it is resized
FlagSetting liveResize {true};
};
struct ChunksSettings {
/// @brief Max milliseconds that engine uses for chunks loading only
IntegerSetting loadSpeed {4, 1, 32};
/// @brief Radius of chunks loading zone (chunk is unit)
IntegerSetting loadDistance {22, 3, 80};
/// @brief Buffer zone where chunks are not unloading (chunk is unit)
IntegerSetting padding {2, 1, 8};
};
struct CameraSettings {
/// @brief Camera dynamic field of view effects
FlagSetting fovEffects {true};
/// @brief Camera movement shake
FlagSetting shaking {true};
/// @brief Camera movement inertia effect
FlagSetting inertia {true};
/// @brief Camera field of view
NumberSetting fov {90.0f, 10, 120};
/// @brief Camera sensitivity
NumberSetting sensitivity {2.0f, 0.1f, 10.0f};
};
struct GraphicsSettings {
/// @brief Enable fog
FlagSetting enableFog {true};
/// @brief Fog opacity is calculated as `pow(depth*k, fogCurve)` where k depends on chunksLoadDistance.
/// 1.0 is linear, 2.0 is quadratic
NumberSetting fogCurve {1.0f, 1.0f, 6.0f};
/// @brief Lighting gamma
NumberSetting gamma {1.0f, 0.4f, 1.0f};
/// @brief Enable blocks backlight to prevent complete darkness
FlagSetting backlight {true};
/// @brief Disable culling with 'optional' mode
FlagSetting denseRender {true};
/// @brief Enable chunks frustum culling
FlagSetting frustumCulling {true};
/// @brief Skybox texture face resolution
IntegerSetting skyboxResolution {64 + 32, 64, 128};
/// @brief Chunk renderer vertices buffer capacity
IntegerSetting chunkMaxVertices {200'000, 0, 4'000'000};
/// @brief Chunk renderer vertices buffer capacity in dense render mode
IntegerSetting chunkMaxVerticesDense {800'000, 0, 8'000'000};
/// @brief Limit of chunk renderers count
IntegerSetting chunkMaxRenderers {6, -4, 32};
/// @brief Particles renderer vertices buffer capacity
IntegerSetting particlesBatchVertices {4'096, 0, 1'000'000};
/// @brief Advanced render pipeline
FlagSetting advancedRender {true};
/// @brief Screen space ambient occlusion quality
IntegerSetting ssao {1, 0, 2};
/// @brief Shadows quality
IntegerSetting shadowsQuality {0, 0, 3};
/// @brief Dense render distance
IntegerSetting denseRenderDistance {56, 0, 10'000};
/// @brief Soft lighting for blocks
FlagSetting softLighting {true};
/// @brief Clouds quality level
IntegerSetting cloudsQuality {2, 0, 2};
};
struct PathfindingSettings {
/// @brief Max visited blocks by an agent per async tick
IntegerSetting stepsPerAsyncAgent {128, 1, 2048};
};
struct DebugSettings {
/// @brief Turns off chunks saving/loading
FlagSetting generatorTestMode {false};
/// @brief Write lights cache
FlagSetting doWriteLights {true};
/// @brief Write preprocessed shaders code to user:export
FlagSetting doTraceShaders {false};
/// @brief Enable experimental optimizations and features
FlagSetting enableExperimental {false};
};
struct UiSettings {
StringSetting language {"auto"};
IntegerSetting worldPreviewSize {64, 1, 512};
};
struct NetworkSettings {
};
struct SystemSettings {
/// @brief Max background assets loaders
IntegerSetting maxBgAssetLoaders {3, -4, 16};
/// @brief Preserve assets during current frame from being destroyed
FlagSetting preserveAssetsDuringFrame {true};
/// @brief Allow luajit cdata objects direct data access optimizations
FlagSetting directScriptingDataAccess {true};
};
struct EngineSettings {
AudioSettings audio;
DisplaySettings display;
ChunksSettings chunks;
CameraSettings camera;
GraphicsSettings graphics;
DebugSettings debug;
UiSettings ui;
NetworkSettings network;
PathfindingSettings pathfinding;
SystemSettings system;
};