The Update(TM), Part 2
This commit is contained in:
145
src/settings.h
145
src/settings.h
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "COMMON.h"
|
||||
#include "tool.h"
|
||||
|
||||
#define SETTINGS_BUFFER 0xFFFF
|
||||
#define SETTINGS_BUFFER_ITEM 0xFF
|
||||
@@ -8,124 +8,73 @@
|
||||
#define SETTINGS_SECTION_IMGUI "# Dear ImGui"
|
||||
#define SETTINGS_INIT_ERROR "Failed to read settings file! ({})"
|
||||
#define SETTINGS_PATH "settings.ini"
|
||||
|
||||
enum SettingsValueType
|
||||
{
|
||||
SETTINGS_TYPE_INT,
|
||||
SETTINGS_TYPE_FLOAT,
|
||||
SETTINGS_TYPE_BOOL,
|
||||
SETTINGS_TYPE_STRING
|
||||
};
|
||||
#define SETTINGS_FLOAT_FORMAT "{:.3f}"
|
||||
|
||||
struct SettingsEntry
|
||||
{
|
||||
std::string key;
|
||||
SettingsValueType type;
|
||||
DataType type;
|
||||
s32 offset;
|
||||
};
|
||||
|
||||
struct Settings
|
||||
{
|
||||
s32 windowW = 1920;
|
||||
s32 windowH = 1080;
|
||||
ivec2 windowSize = {1080, 720};
|
||||
bool playbackIsLoop = true;
|
||||
bool previewIsAxis = true;
|
||||
bool previewIsGrid = true;
|
||||
bool previewIsRootTransform = false;
|
||||
bool previewIsShowPivot = false;
|
||||
f32 previewPanX = 0.0f;
|
||||
f32 previewPanY = 0.0f;
|
||||
f32 previewZoom = 200.0f;
|
||||
s32 previewGridSizeX = 32;
|
||||
s32 previewGridSizeY = 32;
|
||||
s32 previewGridOffsetX = 0;
|
||||
s32 previewGridOffsetY = 0;
|
||||
f32 previewGridColorR = 1.0f;
|
||||
f32 previewGridColorG = 1.0f;
|
||||
f32 previewGridColorB = 1.0f;
|
||||
f32 previewGridColorA = 0.125f;
|
||||
f32 previewAxisColorR = 1.0f;
|
||||
f32 previewAxisColorG = 1.0f;
|
||||
f32 previewAxisColorB = 1.0f;
|
||||
f32 previewAxisColorA = 0.5f;
|
||||
f32 previewBackgroundColorR = 0.113f;
|
||||
f32 previewBackgroundColorG = 0.184f;
|
||||
f32 previewBackgroundColorB = 0.286f;
|
||||
f32 previewBackgroundColorA = 1.0f;
|
||||
bool previewIsBorder = false;
|
||||
f32 previewOverlayTransparency = 255.0f;
|
||||
f32 previewZoom = 200.0;
|
||||
vec2 previewPan = {0.0, 0.0};
|
||||
ivec2 previewGridSize = {32, 32};
|
||||
ivec2 previewGridOffset{};
|
||||
vec4 previewGridColor = {1.0, 1.0, 1.0, 0.125};
|
||||
vec4 previewAxisColor = {1.0, 1.0, 1.0, 0.125};
|
||||
vec4 previewBackgroundColor = {0.113, 0.184, 0.286, 1.0};
|
||||
bool editorIsGrid = true;
|
||||
bool editorIsGridSnap = true;
|
||||
bool editorIsBorder = true;
|
||||
f32 editorPanX = 0.0f;
|
||||
f32 editorPanY = 0.0f;
|
||||
f32 editorZoom = 200.0f;
|
||||
s32 editorGridSizeX = 32;
|
||||
s32 editorGridSizeY = 32;
|
||||
s32 editorGridOffsetX = 32;
|
||||
s32 editorGridOffsetY = 32;
|
||||
f32 editorGridColorR = 1.0f;
|
||||
f32 editorGridColorG = 1.0f;
|
||||
f32 editorGridColorB = 1.0f;
|
||||
f32 editorGridColorA = 0.125f;
|
||||
f32 editorBackgroundColorR = 0.113f;
|
||||
f32 editorBackgroundColorG = 0.184f;
|
||||
f32 editorBackgroundColorB = 0.286f;
|
||||
f32 editorBackgroundColorA = 1.0f;
|
||||
f32 toolColorR = 1.0f;
|
||||
f32 toolColorG = 1.0f;
|
||||
f32 toolColorB = 1.0f;
|
||||
f32 toolColorA = 1.0f;
|
||||
f32 editorZoom = 200.0;
|
||||
vec2 editorPan = {0.0, 0.0};
|
||||
ivec2 editorGridSize = {32, 32};
|
||||
ivec2 editorGridOffset = {32, 32};
|
||||
vec4 editorGridColor = {1.0, 1.0, 1.0, 0.125};
|
||||
vec4 editorBackgroundColor = {0.113, 0.184, 0.286, 1.0};
|
||||
ToolType tool = TOOL_PAN;
|
||||
vec4 toolColor = {1.0, 1.0, 1.0, 1.0};
|
||||
};
|
||||
|
||||
const SettingsEntry SETTINGS_ENTRIES[] =
|
||||
{
|
||||
{"windowW=", SETTINGS_TYPE_INT, offsetof(Settings, windowW)},
|
||||
{"windowH=", SETTINGS_TYPE_INT, offsetof(Settings, windowH)},
|
||||
{"playbackIsLoop=", SETTINGS_TYPE_BOOL, offsetof(Settings, playbackIsLoop)},
|
||||
{"previewIsAxis=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsAxis)},
|
||||
{"previewIsGrid=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsGrid)},
|
||||
{"previewIsRootTransform=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsRootTransform)},
|
||||
{"previewIsShowPivot=", SETTINGS_TYPE_BOOL, offsetof(Settings, previewIsShowPivot)},
|
||||
{"previewPanX=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewPanX)},
|
||||
{"previewPanY=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewPanY)},
|
||||
{"previewZoom=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewZoom)},
|
||||
{"previewGridSizeX=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridSizeX)},
|
||||
{"previewGridSizeY=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridSizeY)},
|
||||
{"previewGridOffsetX=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridOffsetX)},
|
||||
{"previewGridOffsetY=", SETTINGS_TYPE_INT, offsetof(Settings, previewGridOffsetY)},
|
||||
{"previewGridColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorR)},
|
||||
{"previewGridColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorG)},
|
||||
{"previewGridColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorB)},
|
||||
{"previewGridColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewGridColorA)},
|
||||
{"previewAxisColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorR)},
|
||||
{"previewAxisColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorG)},
|
||||
{"previewAxisColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorB)},
|
||||
{"previewAxisColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewAxisColorA)},
|
||||
{"previewBackgroundColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorR)},
|
||||
{"previewBackgroundColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorG)},
|
||||
{"previewBackgroundColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorB)},
|
||||
{"previewBackgroundColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, previewBackgroundColorA)},
|
||||
{"editorIsGrid=", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsGrid)},
|
||||
{"editorIsGridSnap=", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsGridSnap)},
|
||||
{"editorIsBorder=", SETTINGS_TYPE_BOOL, offsetof(Settings, editorIsBorder)},
|
||||
{"editorPanX=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorPanX)},
|
||||
{"editorPanY=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorPanY)},
|
||||
{"editorZoom=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorZoom)},
|
||||
{"editorGridSizeX=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridSizeX)},
|
||||
{"editorGridSizeY=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridSizeY)},
|
||||
{"editorGridOffsetX=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridOffsetX)},
|
||||
{"editorGridOffsetY=", SETTINGS_TYPE_INT, offsetof(Settings, editorGridOffsetY)},
|
||||
{"editorGridColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorR)},
|
||||
{"editorGridColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorG)},
|
||||
{"editorGridColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorB)},
|
||||
{"editorGridColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorGridColorA)},
|
||||
{"editorBackgroundColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorR)},
|
||||
{"editorBackgroundColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorG)},
|
||||
{"editorBackgroundColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorB)},
|
||||
{"editorBackgroundColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, editorBackgroundColorA)},
|
||||
{"toolColorR=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorR)},
|
||||
{"toolColorG=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorG)},
|
||||
{"toolColorB=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorB)},
|
||||
{"toolColorA=", SETTINGS_TYPE_FLOAT, offsetof(Settings, toolColorA)}
|
||||
{"window", TYPE_IVEC2, offsetof(Settings, windowSize)},
|
||||
{"playbackIsLoop", TYPE_BOOL, offsetof(Settings, playbackIsLoop)},
|
||||
{"previewIsAxis", TYPE_BOOL, offsetof(Settings, previewIsAxis)},
|
||||
{"previewIsGrid", TYPE_BOOL, offsetof(Settings, previewIsGrid)},
|
||||
{"previewIsRootTransform", TYPE_BOOL, offsetof(Settings, previewIsRootTransform)},
|
||||
{"previewIsShowPivot", TYPE_BOOL, offsetof(Settings, previewIsShowPivot)},
|
||||
{"previewIsBorder", TYPE_BOOL, offsetof(Settings, previewIsBorder)},
|
||||
{"previewOverlayTransparency", TYPE_FLOAT, offsetof(Settings, previewOverlayTransparency)},
|
||||
{"previewZoom", TYPE_FLOAT, offsetof(Settings, previewZoom)},
|
||||
{"previewPan", TYPE_VEC2, offsetof(Settings, previewPan)},
|
||||
{"previewGridSize", TYPE_IVEC2, offsetof(Settings, previewGridSize)},
|
||||
{"previewGridOffset", TYPE_IVEC2, offsetof(Settings, previewGridOffset)},
|
||||
{"previewGridColor", TYPE_VEC4, offsetof(Settings, previewGridColor)},
|
||||
{"previewAxisColor", TYPE_VEC4, offsetof(Settings, previewAxisColor)},
|
||||
{"previewBackgroundColor", TYPE_VEC4, offsetof(Settings, previewBackgroundColor)},
|
||||
{"editorIsGrid", TYPE_BOOL, offsetof(Settings, editorIsGrid)},
|
||||
{"editorIsGridSnap", TYPE_BOOL, offsetof(Settings, editorIsGridSnap)},
|
||||
{"editorIsBorder", TYPE_BOOL, offsetof(Settings, editorIsBorder)},
|
||||
{"editorZoom", TYPE_FLOAT, offsetof(Settings, editorZoom)},
|
||||
{"editorPan", TYPE_VEC2, offsetof(Settings, editorPan)},
|
||||
{"editorGridSize", TYPE_IVEC2, offsetof(Settings, editorGridSize)},
|
||||
{"editorGridOffset", TYPE_IVEC2, offsetof(Settings, editorGridOffset)},
|
||||
{"editorGridColor", TYPE_VEC4, offsetof(Settings, editorGridColor)},
|
||||
{"editorBackgroundColor", TYPE_VEC4, offsetof(Settings, editorBackgroundColor)},
|
||||
{"tool", TYPE_INT, offsetof(Settings, tool)},
|
||||
{"toolColor", TYPE_VEC4, offsetof(Settings, toolColor)},
|
||||
};
|
||||
constexpr s32 SETTINGS_COUNT = (s32)std::size(SETTINGS_ENTRIES);
|
||||
|
||||
|
Reference in New Issue
Block a user