From e521e6687a51301186c93f74af6f30f8d8362f63 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Thu, 3 Jul 2014 15:10:01 +0400 Subject: [PATCH] centralize cursor drawing --- client/CPlayerInterface.cpp | 4 +--- client/CPreGame.cpp | 4 +--- client/gui/CCursorHandler.cpp | 8 ++++++++ client/gui/CCursorHandler.h | 16 +++++++++------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 9404e689b..62fc56dd6 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1582,9 +1582,7 @@ void CPlayerInterface::update() GH.drawFPSCounter(); // draw the mouse cursor and update the screen - CCS->curh->drawWithScreenRestore(); - CSDL_Ext::update(screen); - CCS->curh->drawRestored(); + CCS->curh->render(); } int CPlayerInterface::getLastIndex( std::string namePrefix) diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 8da4c12f8..434908e7f 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -543,9 +543,7 @@ void CGPreGame::update() GH.drawFPSCounter(); // draw the mouse cursor and update the screen - CCS->curh->drawWithScreenRestore(); - CSDL_Ext::update(screen); - CCS->curh->drawRestored(); + CCS->curh->render(); } void CGPreGame::openCampaignScreen(std::string name) diff --git a/client/gui/CCursorHandler.cpp b/client/gui/CCursorHandler.cpp index 6a53cbb3b..c8b4e6d82 100644 --- a/client/gui/CCursorHandler.cpp +++ b/client/gui/CCursorHandler.cpp @@ -223,6 +223,14 @@ void CCursorHandler::centerCursor() SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE); } +void CCursorHandler::render() +{ + drawWithScreenRestore(); + CSDL_Ext::update(screen); + drawRestored(); +} + + CCursorHandler::~CCursorHandler() { if(help) diff --git a/client/gui/CCursorHandler.h b/client/gui/CCursorHandler.h index ab5afb4ad..907071eeb 100644 --- a/client/gui/CCursorHandler.h +++ b/client/gui/CCursorHandler.h @@ -32,6 +32,13 @@ class CCursorHandler CAnimImage * dndObject; //if set, overrides currentCursor bool showing; + /// Draw cursor preserving original image below cursor + void drawWithScreenRestore(); + /// Restore original image below cursor + void drawRestored(); + /// Simple draw cursor + void draw(SDL_Surface *to); + public: /// position of cursor int xpos, ypos; @@ -53,13 +60,8 @@ public: * cursor. CursorHandler takes ownership of object */ void dragAndDropCursor (CAnimImage * image); - - /// Draw cursor preserving original image below cursor - void drawWithScreenRestore(); - /// Restore original image below cursor - void drawRestored(); - /// Simple draw cursor - void draw(SDL_Surface *to); + + void render(); void shiftPos( int &x, int &y ); void hide() { showing=0; };