Updated settings, added reset to default settings option, tried to fix -1 map bug
This commit is contained in:
@@ -41,6 +41,8 @@ else()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -O2 -std=c++23 -Wall -Wextra -pedantic -fmax-errors=1)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -DDEBUG -g)
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE m)
|
||||
endif()
|
||||
|
@@ -301,7 +301,6 @@ void main()
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
#define SHADER_UNIFORM_COLOR "u_color"
|
||||
#define SHADER_UNIFORM_TRANSFORM "u_transform"
|
||||
#define SHADER_UNIFORM_TINT "u_tint"
|
||||
|
32
src/anm2.cpp
32
src/anm2.cpp
@@ -657,8 +657,7 @@ void anm2_layer_add(Anm2* self)
|
||||
|
||||
void anm2_layer_remove(Anm2* self, s32 id)
|
||||
{
|
||||
if (!self->layers.contains(id))
|
||||
return;
|
||||
if (!self->layers.contains(id)) return;
|
||||
|
||||
self->layers.erase(id);
|
||||
|
||||
@@ -752,18 +751,12 @@ void anm2_new(Anm2* self)
|
||||
|
||||
Anm2Animation* anm2_animation_from_reference(Anm2* self, Anm2Reference* reference)
|
||||
{
|
||||
if (reference->animationID == ID_NONE) return nullptr;
|
||||
|
||||
if (!self->animations.contains(reference->animationID))
|
||||
return nullptr;
|
||||
|
||||
return &self->animations[reference->animationID];
|
||||
return map_find(self->animations, reference->animationID);
|
||||
}
|
||||
|
||||
Anm2Item* anm2_item_from_reference(Anm2* self, Anm2Reference* reference)
|
||||
{
|
||||
if (reference->itemType == ANM2_NONE)
|
||||
return nullptr;
|
||||
if (reference->itemType == ANM2_NONE) return nullptr;
|
||||
|
||||
Anm2Animation* animation = anm2_animation_from_reference(self, reference);
|
||||
|
||||
@@ -771,22 +764,13 @@ Anm2Item* anm2_item_from_reference(Anm2* self, Anm2Reference* reference)
|
||||
|
||||
switch (reference->itemType)
|
||||
{
|
||||
case ANM2_ROOT:
|
||||
return &animation->rootAnimation;
|
||||
case ANM2_LAYER:
|
||||
if (!animation->layerAnimations.contains(reference->itemID)) return nullptr;
|
||||
return &animation->layerAnimations[reference->itemID];
|
||||
case ANM2_NULL:
|
||||
if (!animation->nullAnimations.contains(reference->itemID)) return nullptr;
|
||||
return &animation->nullAnimations[reference->itemID];
|
||||
case ANM2_TRIGGERS:
|
||||
return &animation->triggers;
|
||||
default:
|
||||
return nullptr;
|
||||
case ANM2_ROOT: return &animation->rootAnimation;
|
||||
case ANM2_LAYER: return map_find(animation->layerAnimations, reference->itemID);
|
||||
case ANM2_NULL: return map_find(animation->nullAnimations, reference->itemID);
|
||||
case ANM2_TRIGGERS: return &animation->triggers;
|
||||
default: return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Anm2Frame* anm2_frame_from_reference(Anm2* self, Anm2Reference* reference)
|
||||
{
|
||||
Anm2Item* item = anm2_item_from_reference(self, reference);
|
||||
|
@@ -1647,6 +1647,7 @@ static void _imgui_taskbar(Imgui* self)
|
||||
if (imgui_begin_popup(IMGUI_SETTINGS.popup, self, IMGUI_SETTINGS.popupSize))
|
||||
{
|
||||
if (_imgui_checkbox_selectable(IMGUI_VSYNC, self, self->settings->isVsync)) window_vsync_set(self->settings->isVsync);
|
||||
if (_imgui_selectable(IMGUI_DEFAULT_SETTINGS, self)) *self->settings = Settings();
|
||||
imgui_end_popup(self);
|
||||
}
|
||||
|
||||
|
@@ -1014,6 +1014,12 @@ IMGUI_ITEM(IMGUI_VSYNC,
|
||||
self.isSizeToText = true
|
||||
);
|
||||
|
||||
IMGUI_ITEM(IMGUI_DEFAULT_SETTINGS,
|
||||
self.label = "&Reset to Default Settings",
|
||||
self.tooltip = "Reset the program's settings to their default state.",
|
||||
self.isSizeToText = true
|
||||
);
|
||||
|
||||
IMGUI_ITEM(IMGUI_ANIMATIONS,
|
||||
self.label = "Animations",
|
||||
self.flags = ImGuiWindowFlags_NoScrollbar |
|
||||
|
@@ -45,14 +45,14 @@ static void _settings_setting_load(Settings* self, const std::string& line)
|
||||
if (entry.type == TYPE_VEC2)
|
||||
{
|
||||
vec2* v = (vec2*)target;
|
||||
if ((value = match_key(key + "X"))) { v->x = std::atof(value); return; }
|
||||
if ((value = match_key(key + "Y"))) { v->y = std::atof(value); return; }
|
||||
if ((value = match_key(key + (entry.isWidthHeight ? "W" : "X")))) { v->x = std::atof(value); return; }
|
||||
if ((value = match_key(key + (entry.isWidthHeight ? "H" : "Y")))) { v->y = std::atof(value); return; }
|
||||
}
|
||||
else if (entry.type == TYPE_IVEC2)
|
||||
{
|
||||
ivec2* v = (ivec2*)target;
|
||||
if ((value = match_key(key + "X"))) { v->x = std::atoi(value); return; }
|
||||
if ((value = match_key(key + "Y"))) { v->y = std::atoi(value); return; }
|
||||
if ((value = match_key(key + (entry.isWidthHeight ? "W" : "X")))) { v->x = std::atoi(value); return; }
|
||||
if ((value = match_key(key + (entry.isWidthHeight ? "H" : "Y")))) { v->y = std::atoi(value); return; }
|
||||
}
|
||||
else if (entry.type == TYPE_VEC3)
|
||||
{
|
||||
@@ -107,15 +107,15 @@ static void _settings_setting_write(Settings* self, std::ostream& out, SettingsE
|
||||
case TYPE_IVEC2:
|
||||
{
|
||||
ivec2* data = (ivec2*)(selfPointer + entry.offset);
|
||||
out << entry.key << "X=" << data->x << "\n";
|
||||
out << entry.key << "Y=" << data->y << "\n";
|
||||
out << entry.key << (entry.isWidthHeight ? "W=" : "X=") << data->x << "\n";
|
||||
out << entry.key << (entry.isWidthHeight ? "H=" : "Y=") << data->y << "\n";
|
||||
break;
|
||||
}
|
||||
case TYPE_VEC2:
|
||||
{
|
||||
vec2* data = (vec2*)(selfPointer + entry.offset);
|
||||
out << entry.key << "X=" << std::format(SETTINGS_FLOAT_FORMAT, data->x) << "\n";
|
||||
out << entry.key << "Y=" << std::format(SETTINGS_FLOAT_FORMAT, data->y) << "\n";
|
||||
out << entry.key << (entry.isWidthHeight ? "W=" : "X=") << std::format(SETTINGS_FLOAT_FORMAT, data->x) << "\n";
|
||||
out << entry.key << (entry.isWidthHeight ? "H=" : "Y=") << std::format(SETTINGS_FLOAT_FORMAT, data->y) << "\n";
|
||||
break;
|
||||
}
|
||||
case TYPE_VEC3:
|
||||
|
@@ -27,11 +27,12 @@ struct SettingsEntry
|
||||
std::string key;
|
||||
DataType type;
|
||||
s32 offset;
|
||||
bool isWidthHeight = false;
|
||||
};
|
||||
|
||||
struct Settings
|
||||
{
|
||||
ivec2 windowSize = {1080, 720};
|
||||
ivec2 windowSize = {1600, 900};
|
||||
bool isVsync = true;
|
||||
bool playbackIsLoop = true;
|
||||
bool playbackIsClampPlayhead = true;
|
||||
@@ -70,7 +71,7 @@ struct Settings
|
||||
f32 previewOverlayTransparency = 255.0f;
|
||||
f32 previewZoom = 200.0;
|
||||
vec2 previewPan = {0.0, 0.0};
|
||||
ivec2 previewGridSize = {32, 3};
|
||||
ivec2 previewGridSize = {32, 32};
|
||||
ivec2 previewGridOffset{};
|
||||
vec4 previewGridColor = {1.0, 1.0, 1.0, 0.125};
|
||||
vec4 previewAxesColor = {1.0, 1.0, 1.0, 0.125};
|
||||
@@ -106,7 +107,7 @@ struct Settings
|
||||
|
||||
const SettingsEntry SETTINGS_ENTRIES[] =
|
||||
{
|
||||
{"window", TYPE_IVEC2, offsetof(Settings, windowSize)},
|
||||
{"window", TYPE_IVEC2, offsetof(Settings, windowSize), true},
|
||||
{"isVsync", TYPE_BOOL, offsetof(Settings, isVsync)},
|
||||
{"playbackIsLoop", TYPE_BOOL, offsetof(Settings, playbackIsLoop)},
|
||||
{"playbackIsClampPlayhead", TYPE_BOOL, offsetof(Settings, playbackIsClampPlayhead)},
|
||||
@@ -182,8 +183,8 @@ constexpr s32 SETTINGS_COUNT = (s32)std::size(SETTINGS_ENTRIES);
|
||||
|
||||
const std::string SETTINGS_DEFAULT = R"(
|
||||
[Settings]
|
||||
windowX=1600
|
||||
windowY=900
|
||||
windowW=1600
|
||||
windowH=900
|
||||
isVsync=true
|
||||
playbackIsLoop=true
|
||||
playbackIsClampPlayhead=false
|
||||
|
Reference in New Issue
Block a user