1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-13 01:20:34 +02:00

Added RenderHandler that acts as factory for images and animations

This commit is contained in:
Ivan Savenko
2023-09-04 18:01:44 +03:00
parent 3f921fa771
commit 1d0e696db6
38 changed files with 246 additions and 126 deletions

View File

@ -17,6 +17,7 @@
#include "../renderSDL/CursorHardware.h"
#include "../render/CAnimation.h"
#include "../render/IImage.h"
#include "../render/IRenderHandler.h"
#include "../../lib/CConfigHandler.h"
@ -46,10 +47,10 @@ CursorHandler::CursorHandler()
cursors =
{
std::make_unique<CAnimation>(AnimationPath::builtin("CRADVNTR")),
std::make_unique<CAnimation>(AnimationPath::builtin("CRCOMBAT")),
std::make_unique<CAnimation>(AnimationPath::builtin("CRDEFLT")),
std::make_unique<CAnimation>(AnimationPath::builtin("CRSPELL"))
GH.renderHandler().loadAnimation(AnimationPath::builtin("CRADVNTR")),
GH.renderHandler().loadAnimation(AnimationPath::builtin("CRCOMBAT")),
GH.renderHandler().loadAnimation(AnimationPath::builtin("CRDEFLT")),
GH.renderHandler().loadAnimation(AnimationPath::builtin("CRSPELL"))
};
for (auto & cursor : cursors)
@ -102,9 +103,9 @@ void CursorHandler::dragAndDropCursor(std::shared_ptr<IImage> image)
void CursorHandler::dragAndDropCursor (const AnimationPath & path, size_t index)
{
CAnimation anim(path);
anim.load(index);
dragAndDropCursor(anim.getImage(index));
auto anim = GH.renderHandler().loadAnimation(path);
anim->load(index);
dragAndDropCursor(anim->getImage(index));
}
void CursorHandler::cursorMove(const int & x, const int & y)