Skip to content

Commit 473b6bc

Browse files
committed
Fix compilation with newer versions of ImGui
- Fix a crash when saving a spritesheet with fractional canvas resize (#7) - Update copyright dates to 2024
1 parent 0b5ef87 commit 473b6bc

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
set(NCPROJECT_NAME "SpookyGhost")
22
set(NCPROJECT_EXE_NAME "spookyghost")
33
set(NCPROJECT_VENDOR "Angelo Theodorou")
4-
set(NCPROJECT_COPYRIGHT "Copyright ©2020-2022 ${NCPROJECT_VENDOR}")
4+
set(NCPROJECT_COPYRIGHT "Copyright ©2020-2024 ${NCPROJECT_VENDOR}")
55
set(NCPROJECT_DESCRIPTION "A procedural sprite animation tool")
66
set(NCPROJECT_HOMEPAGE "https://encelo.itch.io/spookyghost")
77
set(NCPROJECT_REVERSE_DNS "io.itch.encelo.spookyghost")

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020-2022 Angelo Theodorou
1+
Copyright (c) 2020-2024 Angelo Theodorou
22

33
Permission is hereby granted, free of charge, to any person obtaining a
44
copy of this software and associated documentation files (the "Software"),

src/gui/RenderGuiWindow.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,15 @@ void RenderGuiWindow::create()
304304
saveAnimStatus_.filename.format("%s.png", nc::fs::joinPath(directory, filename).data(), saveAnimStatus_.numSavedFrames);
305305
shouldSaveSpritesheet_ = true;
306306
saveAnimStatus_.sheetDestPos.set(0, 0);
307-
theResizedCanvas->resizeTexture(theCanvas->size() * saveAnimStatus_.canvasResize);
307+
// Immediately-invoked function expression for const initialization
308+
const nc::Vector2i resizeCanvasSize = [&] {
309+
nc::Vector2i size(theCanvas->texWidth() * saveAnimStatus_.canvasResize,
310+
theCanvas->texHeight() * saveAnimStatus_.canvasResize);
311+
size.x = (size.x < 2) ? 2 : size.x;
312+
size.y = (size.y < 2) ? 2 : size.y;
313+
return size;
314+
}();
315+
theResizedCanvas->resizeTexture(resizeCanvasSize);
308316
theSpritesheet->resizeTexture(spritesheetSize);
309317
// Disabling V-Sync for faster render times
310318
nc::theApplication().gfxDevice().setSwapInterval(0);

src/gui/UserInterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,9 +1398,9 @@ void UserInterface::createSpritesWindow()
13981398
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
13991399
enableKeyboardNav = false;
14001400

1401-
if (enableMoveUpButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_UpArrow)))
1401+
if (enableMoveUpButton && ImGui::IsKeyReleased(ImGuiKey_UpArrow))
14021402
moveSpriteEntry(*selectedSpriteEntry_, indexInParent, true);
1403-
if (enableMoveDownButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_DownArrow)))
1403+
if (enableMoveDownButton && ImGui::IsKeyReleased(ImGuiKey_DownArrow))
14041404
moveSpriteEntry(*selectedSpriteEntry_, indexInParent, false);
14051405
}
14061406

@@ -1997,9 +1997,9 @@ void UserInterface::createAnimationsWindow()
19971997
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
19981998
enableKeyboardNav = false;
19991999

2000-
if (enableMoveUpButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_UpArrow)))
2000+
if (enableMoveUpButton && ImGui::IsKeyReleased(ImGuiKey_UpArrow))
20012001
nctl::swap(selectedAnimation_->parent()->anims()[selectedIndex], selectedAnimation_->parent()->anims()[selectedIndex - 1]);
2002-
if (enableMoveDownButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_DownArrow)))
2002+
if (enableMoveDownButton && ImGui::IsKeyReleased(ImGuiKey_DownArrow))
20032003
nctl::swap(selectedAnimation_->parent()->anims()[selectedIndex], selectedAnimation_->parent()->anims()[selectedIndex + 1]);
20042004
}
20052005

@@ -3413,9 +3413,9 @@ void UserInterface::createTipsWindow()
34133413
ImGui::GetIO().ConfigFlags &= ~(ImGuiConfigFlags_NavEnableKeyboard);
34143414
enableKeyboardNav = false;
34153415

3416-
if (enablePrevButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_LeftArrow)))
3416+
if (enablePrevButton && ImGui::IsKeyReleased(ImGuiKey_LeftArrow))
34173417
currentTipIndex--;
3418-
if (enableNextButton && ImGui::IsKeyReleased(ImGui::GetKeyIndex(ImGuiKey_RightArrow)))
3418+
if (enableNextButton && ImGui::IsKeyReleased(ImGuiKey_RightArrow))
34193419
currentTipIndex++;
34203420
}
34213421

0 commit comments

Comments
 (0)