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