1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Renamed CCursorHandler -> CursorHandler

This commit is contained in:
Ivan Savenko
2023-01-05 19:34:37 +02:00
parent d44e809369
commit 0e8ee929df
22 changed files with 49 additions and 49 deletions

View File

@@ -38,7 +38,7 @@ VCMI_LIB_NAMESPACE_END
class CMapHandler; class CMapHandler;
class CSoundHandler; class CSoundHandler;
class CMusicHandler; class CMusicHandler;
class CCursorHandler; class CursorHandler;
class IMainVideoPlayer; class IMainVideoPlayer;
class CServerHandler; class CServerHandler;
@@ -49,7 +49,7 @@ public:
CSoundHandler * soundh; CSoundHandler * soundh;
CMusicHandler * musich; CMusicHandler * musich;
CConsoleHandler * consoleh; CConsoleHandler * consoleh;
CCursorHandler * curh; CursorHandler * curh;
IMainVideoPlayer * videoh; IMainVideoPlayer * videoh;
}; };
extern CClientState * CCS; extern CClientState * CCS;

View File

@@ -25,7 +25,7 @@
#include "lobby/CSelectionBase.h" #include "lobby/CSelectionBase.h"
#include "windows/CCastleInterface.h" #include "windows/CCastleInterface.h"
#include "../lib/CConsoleHandler.h" #include "../lib/CConsoleHandler.h"
#include "gui/CCursorHandler.h" #include "gui/CursorHandler.h"
#include "../lib/CGameState.h" #include "../lib/CGameState.h"
#include "../CCallback.h" #include "../CCallback.h"
#include "CPlayerInterface.h" #include "CPlayerInterface.h"
@@ -470,7 +470,7 @@ int main(int argc, char * argv[])
pomtime.getDiff(); pomtime.getDiff();
graphics = new Graphics(); // should be before curh graphics = new Graphics(); // should be before curh
CCS->curh = new CCursorHandler(); CCS->curh = new CursorHandler();
logGlobal->info("Screen handler: %d ms", pomtime.getDiff()); logGlobal->info("Screen handler: %d ms", pomtime.getDiff());
pomtime.getDiff(); pomtime.getDiff();

View File

@@ -18,7 +18,7 @@ set(client_SRCS
gui/CAnimation.cpp gui/CAnimation.cpp
gui/Canvas.cpp gui/Canvas.cpp
gui/CCursorHandler.cpp gui/CursorHandler.cpp
gui/CGuiHandler.cpp gui/CGuiHandler.cpp
gui/CIntObject.cpp gui/CIntObject.cpp
gui/ColorFilter.cpp gui/ColorFilter.cpp
@@ -104,7 +104,7 @@ set(client_HEADERS
gui/CAnimation.h gui/CAnimation.h
gui/Canvas.h gui/Canvas.h
gui/CCursorHandler.h gui/CursorHandler.h
gui/CGuiHandler.h gui/CGuiHandler.h
gui/ColorFilter.h gui/ColorFilter.h
gui/CIntObject.h gui/CIntObject.h

View File

@@ -19,7 +19,7 @@
#include "battle/BattleWindow.h" #include "battle/BattleWindow.h"
#include "../CCallback.h" #include "../CCallback.h"
#include "windows/CCastleInterface.h" #include "windows/CCastleInterface.h"
#include "gui/CCursorHandler.h" #include "gui/CursorHandler.h"
#include "windows/CKingdomInterface.h" #include "windows/CKingdomInterface.h"
#include "CGameInfo.h" #include "CGameInfo.h"
#include "windows/CHeroWindow.h" #include "windows/CHeroWindow.h"

View File

@@ -19,7 +19,7 @@
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CIntObject.h" #include "../gui/CIntObject.h"
#include "../windows/CCreatureWindow.h" #include "../windows/CCreatureWindow.h"

View File

@@ -22,7 +22,7 @@
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CMusicHandler.h" #include "../CMusicHandler.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../../CCallback.h" #include "../../CCallback.h"

View File

@@ -26,7 +26,7 @@
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../gui/Canvas.h" #include "../gui/Canvas.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../../CCallback.h" #include "../../CCallback.h"
#include "../../lib/BattleFieldHandler.h" #include "../../lib/BattleFieldHandler.h"

View File

@@ -28,7 +28,7 @@
#include "../CMusicHandler.h" #include "../CMusicHandler.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../gui/Canvas.h" #include "../gui/Canvas.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../windows/CAdvmapInterface.h" #include "../windows/CAdvmapInterface.h"

View File

@@ -26,7 +26,7 @@
#include "../Graphics.h" #include "../Graphics.h"
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../gui/Canvas.h" #include "../gui/Canvas.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../widgets/AdventureMapClasses.h" #include "../widgets/AdventureMapClasses.h"
#include "../widgets/Buttons.h" #include "../widgets/Buttons.h"

View File

@@ -21,7 +21,7 @@
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../CMusicHandler.h" #include "../CMusicHandler.h"
#include "../gui/Canvas.h" #include "../gui/Canvas.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../windows/CSpellWindow.h" #include "../windows/CSpellWindow.h"

View File

@@ -14,7 +14,7 @@
#include <SDL.h> #include <SDL.h>
#include "CIntObject.h" #include "CIntObject.h"
#include "CCursorHandler.h" #include "CursorHandler.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../../lib/CThreadHelper.h" #include "../../lib/CThreadHelper.h"

View File

@@ -8,7 +8,7 @@
* *
*/ */
#include "StdInc.h" #include "StdInc.h"
#include "CCursorHandler.h" #include "CursorHandler.h"
#include <SDL.h> #include <SDL.h>
@@ -18,13 +18,13 @@
#include "../CMT.h" #include "../CMT.h"
void CCursorHandler::clearBuffer() void CursorHandler::clearBuffer()
{ {
Uint32 fillColor = SDL_MapRGBA(buffer->format, 0, 0, 0, 0); Uint32 fillColor = SDL_MapRGBA(buffer->format, 0, 0, 0, 0);
CSDL_Ext::fillRect(buffer, nullptr, fillColor); CSDL_Ext::fillRect(buffer, nullptr, fillColor);
} }
void CCursorHandler::updateBuffer(CIntObject * payload) void CursorHandler::updateBuffer(CIntObject * payload)
{ {
payload->moveTo(Point(0,0)); payload->moveTo(Point(0,0));
payload->showAll(buffer); payload->showAll(buffer);
@@ -32,13 +32,13 @@ void CCursorHandler::updateBuffer(CIntObject * payload)
needUpdate = true; needUpdate = true;
} }
void CCursorHandler::replaceBuffer(CIntObject * payload) void CursorHandler::replaceBuffer(CIntObject * payload)
{ {
clearBuffer(); clearBuffer();
updateBuffer(payload); updateBuffer(payload);
} }
CCursorHandler::CCursorHandler() CursorHandler::CursorHandler()
: needUpdate(true) : needUpdate(true)
, buffer(nullptr) , buffer(nullptr)
, cursorLayer(nullptr) , cursorLayer(nullptr)
@@ -70,12 +70,12 @@ CCursorHandler::CCursorHandler()
set(Cursor::Map::POINTER); set(Cursor::Map::POINTER);
} }
Point CCursorHandler::position() const Point CursorHandler::position() const
{ {
return pos; return pos;
} }
void CCursorHandler::changeGraphic(Cursor::Type type, size_t index) void CursorHandler::changeGraphic(Cursor::Type type, size_t index)
{ {
assert(dndObject == nullptr); assert(dndObject == nullptr);
@@ -95,28 +95,28 @@ void CCursorHandler::changeGraphic(Cursor::Type type, size_t index)
replaceBuffer(currentCursor); replaceBuffer(currentCursor);
} }
void CCursorHandler::set(Cursor::Default index) void CursorHandler::set(Cursor::Default index)
{ {
changeGraphic(Cursor::Type::DEFAULT, static_cast<size_t>(index)); changeGraphic(Cursor::Type::DEFAULT, static_cast<size_t>(index));
} }
void CCursorHandler::set(Cursor::Map index) void CursorHandler::set(Cursor::Map index)
{ {
changeGraphic(Cursor::Type::ADVENTURE, static_cast<size_t>(index)); changeGraphic(Cursor::Type::ADVENTURE, static_cast<size_t>(index));
} }
void CCursorHandler::set(Cursor::Combat index) void CursorHandler::set(Cursor::Combat index)
{ {
changeGraphic(Cursor::Type::COMBAT, static_cast<size_t>(index)); changeGraphic(Cursor::Type::COMBAT, static_cast<size_t>(index));
} }
void CCursorHandler::set(Cursor::Spellcast index) void CursorHandler::set(Cursor::Spellcast index)
{ {
//Note: this is animated cursor, ignore specified frame and only change type //Note: this is animated cursor, ignore specified frame and only change type
changeGraphic(Cursor::Type::SPELLBOOK, frame); changeGraphic(Cursor::Type::SPELLBOOK, frame);
} }
void CCursorHandler::dragAndDropCursor(std::unique_ptr<CAnimImage> object) void CursorHandler::dragAndDropCursor(std::unique_ptr<CAnimImage> object)
{ {
dndObject = std::move(object); dndObject = std::move(object);
if(dndObject) if(dndObject)
@@ -125,18 +125,18 @@ void CCursorHandler::dragAndDropCursor(std::unique_ptr<CAnimImage> object)
replaceBuffer(currentCursor); replaceBuffer(currentCursor);
} }
void CCursorHandler::cursorMove(const int & x, const int & y) void CursorHandler::cursorMove(const int & x, const int & y)
{ {
pos.x = x; pos.x = x;
pos.y = y; pos.y = y;
} }
Point CCursorHandler::getPivotOffsetDefault(size_t index) Point CursorHandler::getPivotOffsetDefault(size_t index)
{ {
return {0, 0}; return {0, 0};
} }
Point CCursorHandler::getPivotOffsetMap(size_t index) Point CursorHandler::getPivotOffsetMap(size_t index)
{ {
static const std::array<Point, 43> offsets = {{ static const std::array<Point, 43> offsets = {{
{ 0, 0}, // POINTER = 0, { 0, 0}, // POINTER = 0,
@@ -196,7 +196,7 @@ Point CCursorHandler::getPivotOffsetMap(size_t index)
return offsets[index]; return offsets[index];
} }
Point CCursorHandler::getPivotOffsetCombat(size_t index) Point CursorHandler::getPivotOffsetCombat(size_t index)
{ {
static const std::array<Point, 20> offsets = {{ static const std::array<Point, 20> offsets = {{
{ 12, 12 }, // BLOCKED = 0, { 12, 12 }, // BLOCKED = 0,
@@ -226,12 +226,12 @@ Point CCursorHandler::getPivotOffsetCombat(size_t index)
return offsets[index]; return offsets[index];
} }
Point CCursorHandler::getPivotOffsetSpellcast() Point CursorHandler::getPivotOffsetSpellcast()
{ {
return { 18, 28}; return { 18, 28};
} }
Point CCursorHandler::getPivotOffset() Point CursorHandler::getPivotOffset()
{ {
switch (type) { switch (type) {
case Cursor::Type::ADVENTURE: return getPivotOffsetMap(frame); case Cursor::Type::ADVENTURE: return getPivotOffsetMap(frame);
@@ -244,7 +244,7 @@ Point CCursorHandler::getPivotOffset()
return {0, 0}; return {0, 0};
} }
void CCursorHandler::centerCursor() void CursorHandler::centerCursor()
{ {
pos.x = static_cast<int>((screen->w / 2.) - (currentCursor->pos.w / 2.)); pos.x = static_cast<int>((screen->w / 2.) - (currentCursor->pos.w / 2.));
pos.y = static_cast<int>((screen->h / 2.) - (currentCursor->pos.h / 2.)); pos.y = static_cast<int>((screen->h / 2.) - (currentCursor->pos.h / 2.));
@@ -253,7 +253,7 @@ void CCursorHandler::centerCursor()
SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE); SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
} }
void CCursorHandler::updateSpellcastCursor() void CursorHandler::updateSpellcastCursor()
{ {
static const float frameDisplayDuration = 0.1f; static const float frameDisplayDuration = 0.1f;
@@ -274,7 +274,7 @@ void CCursorHandler::updateSpellcastCursor()
changeGraphic(Cursor::Type::SPELLBOOK, newFrame); changeGraphic(Cursor::Type::SPELLBOOK, newFrame);
} }
void CCursorHandler::render() void CursorHandler::render()
{ {
if(!showing) if(!showing)
return; return;
@@ -302,7 +302,7 @@ void CCursorHandler::render()
SDL_RenderCopy(mainRenderer, cursorLayer, nullptr, &destRect); SDL_RenderCopy(mainRenderer, cursorLayer, nullptr, &destRect);
} }
void CCursorHandler::updateTexture() void CursorHandler::updateTexture()
{ {
if(needUpdate) if(needUpdate)
{ {
@@ -311,7 +311,7 @@ void CCursorHandler::updateTexture()
} }
} }
CCursorHandler::~CCursorHandler() CursorHandler::~CursorHandler()
{ {
if(buffer) if(buffer)
SDL_FreeSurface(buffer); SDL_FreeSurface(buffer);

View File

@@ -112,7 +112,7 @@ namespace Cursor
} }
/// handles mouse cursor /// handles mouse cursor
class CCursorHandler final class CursorHandler final
{ {
bool needUpdate; bool needUpdate;
SDL_Texture * cursorLayer; SDL_Texture * cursorLayer;
@@ -150,8 +150,8 @@ class CCursorHandler final
void updateSpellcastCursor(); void updateSpellcastCursor();
public: public:
CCursorHandler(); CursorHandler();
~CCursorHandler(); ~CursorHandler();
/** /**
* Replaces the cursor with a custom image. * Replaces the cursor with a custom image.

View File

@@ -21,7 +21,7 @@
#include "../../lib/filesystem/CCompressedStream.h" #include "../../lib/filesystem/CCompressedStream.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../../lib/CGeneralTextHandler.h" #include "../../lib/CGeneralTextHandler.h"

View File

@@ -11,7 +11,7 @@
#include "CArtifactHolder.h" #include "CArtifactHolder.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "Buttons.h" #include "Buttons.h"
#include "CComponent.h" #include "CComponent.h"

View File

@@ -17,7 +17,7 @@
#include <vcmi/spells/Spell.h> #include <vcmi/spells/Spell.h>
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../CMessage.h" #include "../CMessage.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"

View File

@@ -13,7 +13,7 @@
#include "CComponent.h" #include "CComponent.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../CMessage.h" #include "../CMessage.h"

View File

@@ -32,7 +32,7 @@
#include "../mapHandler.h" #include "../mapHandler.h"
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../widgets/MiscWidgets.h" #include "../widgets/MiscWidgets.h"

View File

@@ -13,7 +13,7 @@
#include "CAdvmapInterface.h" #include "CAdvmapInterface.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../widgets/Images.h" #include "../widgets/Images.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"

View File

@@ -18,7 +18,7 @@
#include "../gui/SDL_Pixels.h" #include "../gui/SDL_Pixels.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../battle/BattleInterface.h" #include "../battle/BattleInterface.h"
#include "../battle/BattleInterfaceClasses.h" #include "../battle/BattleInterfaceClasses.h"

View File

@@ -32,7 +32,7 @@
#include "../gui/CAnimation.h" #include "../gui/CAnimation.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../widgets/CComponent.h" #include "../widgets/CComponent.h"
#include "../widgets/MiscWidgets.h" #include "../widgets/MiscWidgets.h"

View File

@@ -24,7 +24,7 @@
#include "../gui/SDL_Pixels.h" #include "../gui/SDL_Pixels.h"
#include "../gui/SDL_Extensions.h" #include "../gui/SDL_Extensions.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../gui/CCursorHandler.h" #include "../gui/CursorHandler.h"
#include "../battle/BattleInterface.h" #include "../battle/BattleInterface.h"
#include "../battle/BattleInterfaceClasses.h" #include "../battle/BattleInterfaceClasses.h"