mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix cursor scaling
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
#include "CursorHardware.h"
|
#include "CursorHardware.h"
|
||||||
|
|
||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../renderSDL/ScreenHandler.h"
|
#include "../render/IScreenHandler.h"
|
||||||
#include "../render/Colors.h"
|
#include "../render/Colors.h"
|
||||||
#include "../render/IImage.h"
|
#include "../render/IImage.h"
|
||||||
#include "SDL_Extensions.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)
|
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));
|
CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY));
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "CursorSoftware.h"
|
#include "CursorSoftware.h"
|
||||||
|
|
||||||
|
#include "../gui/CGuiHandler.h"
|
||||||
|
#include "../render/IScreenHandler.h"
|
||||||
#include "../render/Colors.h"
|
#include "../render/Colors.h"
|
||||||
#include "../render/IImage.h"
|
#include "../render/IImage.h"
|
||||||
#include "../CMT.h"
|
#include "../CMT.h"
|
||||||
@@ -30,8 +32,8 @@ void CursorSoftware::render()
|
|||||||
SDL_Rect destRect;
|
SDL_Rect destRect;
|
||||||
destRect.x = renderPos.x;
|
destRect.x = renderPos.x;
|
||||||
destRect.y = renderPos.y;
|
destRect.y = renderPos.y;
|
||||||
destRect.w = 40;
|
destRect.w = cursorSurface->w;
|
||||||
destRect.h = 40;
|
destRect.h = cursorSurface->h;
|
||||||
|
|
||||||
SDL_RenderCopy(mainRenderer, cursorTexture, nullptr, &destRect);
|
SDL_RenderCopy(mainRenderer, cursorTexture, nullptr, &destRect);
|
||||||
}
|
}
|
||||||
@@ -53,8 +55,13 @@ void CursorSoftware::createTexture(const Point & dimensions)
|
|||||||
|
|
||||||
void CursorSoftware::updateTexture()
|
void CursorSoftware::updateTexture()
|
||||||
{
|
{
|
||||||
if (!cursorSurface || Point(cursorSurface->w, cursorSurface->h) != cursorImage->dimensions())
|
if (!cursorSurface)
|
||||||
createTexture(cursorImage->dimensions());
|
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));
|
CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user