mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix cursor scaling
This commit is contained in:
parent
5c11a10667
commit
095f5b5e60
@ -12,7 +12,7 @@
|
||||
#include "CursorHardware.h"
|
||||
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../renderSDL/ScreenHandler.h"
|
||||
#include "../render/IScreenHandler.h"
|
||||
#include "../render/Colors.h"
|
||||
#include "../render/IImage.h"
|
||||
#include "SDL_Extensions.h"
|
||||
@ -45,7 +45,7 @@ void CursorHardware::setVisible(bool on)
|
||||
|
||||
void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivotOffset)
|
||||
{
|
||||
auto cursorSurface = CSDL_Ext::newSurface(image->dimensions());
|
||||
auto cursorSurface = CSDL_Ext::newSurface(image->dimensions() * GH.screenHandler().getScalingFactor());
|
||||
|
||||
CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY));
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "StdInc.h"
|
||||
#include "CursorSoftware.h"
|
||||
|
||||
#include "../gui/CGuiHandler.h"
|
||||
#include "../render/IScreenHandler.h"
|
||||
#include "../render/Colors.h"
|
||||
#include "../render/IImage.h"
|
||||
#include "../CMT.h"
|
||||
@ -30,8 +32,8 @@ void CursorSoftware::render()
|
||||
SDL_Rect destRect;
|
||||
destRect.x = renderPos.x;
|
||||
destRect.y = renderPos.y;
|
||||
destRect.w = 40;
|
||||
destRect.h = 40;
|
||||
destRect.w = cursorSurface->w;
|
||||
destRect.h = cursorSurface->h;
|
||||
|
||||
SDL_RenderCopy(mainRenderer, cursorTexture, nullptr, &destRect);
|
||||
}
|
||||
@ -53,8 +55,13 @@ void CursorSoftware::createTexture(const Point & dimensions)
|
||||
|
||||
void CursorSoftware::updateTexture()
|
||||
{
|
||||
if (!cursorSurface || Point(cursorSurface->w, cursorSurface->h) != cursorImage->dimensions())
|
||||
createTexture(cursorImage->dimensions());
|
||||
if (!cursorSurface)
|
||||
createTexture(cursorImage->dimensions() * GH.screenHandler().getScalingFactor());
|
||||
|
||||
Point currentSize = Point(cursorSurface->w, cursorSurface->h);
|
||||
|
||||
if (currentSize != cursorImage->dimensions() * GH.screenHandler().getScalingFactor())
|
||||
createTexture(cursorImage->dimensions() * GH.screenHandler().getScalingFactor());
|
||||
|
||||
CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user