Quellcode durchsuchen

centralize cursor drawing

AlexVinS vor 11 Jahren
Ursprung
Commit
e521e6687a
4 geänderte Dateien mit 19 neuen und 13 gelöschten Zeilen
  1. 1 3
      client/CPlayerInterface.cpp
  2. 1 3
      client/CPreGame.cpp
  3. 8 0
      client/gui/CCursorHandler.cpp
  4. 9 7
      client/gui/CCursorHandler.h

+ 1 - 3
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)

+ 1 - 3
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)

+ 8 - 0
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)

+ 9 - 7
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; };