Переглянути джерело

Fix usage of fillRect.
* proper fix for slider drawing

AlexVinS 11 роки тому
батько
коміт
0edd10078f

+ 1 - 1
client/CPreGame.cpp

@@ -4194,7 +4194,7 @@ CPrologEpilogVideo::CPrologEpilogVideo( CCampaignScenario::SScenarioPrologEpilog
 
 void CPrologEpilogVideo::show( SDL_Surface * to )
 {
-	CSDL_Ext::fillRect(to, &pos, 0); // fill screen with black
+	CSDL_Ext::fillRectBlack(to, &pos);
 	//BUG: some videos are 800x600 in size while some are 800x400
 	//VCMI should center them in the middle of the screen. Possible but needs modification
 	//of video player API which I'd like to avoid until we'll get rid of Windows-specific player

+ 1 - 13
client/gui/CIntObjectClasses.cpp

@@ -850,22 +850,10 @@ void CSlider::setAmount( int to )
 
 void CSlider::showAll(SDL_Surface * to)
 {
-	CSDL_Ext::fillRect(to, &pos, 0);
+	CSDL_Ext::fillRectBlack(to, &pos);
 	CIntObject::showAll(to);
 }
 
-void CSlider::show(SDL_Surface * to)
-{
-	//todo: find better solution for background glitches.
-	#ifdef VCMI_SDL1	
-	CIntObject::show(to);	
-	#else
-	CSDL_Ext::fillRect(to, &pos, 0);
-	CIntObject::showAll(to);	
-	#endif // VCMI_SDL1
-}
-
-
 void CSlider::wheelScrolled(bool down, bool in)
 {
 	moveTo(value + 3 * (down ? +scrollStep : -scrollStep));

+ 0 - 1
client/gui/CIntObjectClasses.h

@@ -218,7 +218,6 @@ public:
 	void clickLeft(tribool down, bool previousState);
 	void mouseMoved (const SDL_MouseMotionEvent & sEvent);
 	void showAll(SDL_Surface * to);	
-	void show(SDL_Surface * to) override;
 
 	CSlider(int x, int y, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, 
 		int Value=0, bool Horizontal=true, int style = 0); //style 0 - brown, 1 - blue

+ 6 - 0
client/gui/SDL_Extensions.cpp

@@ -955,6 +955,12 @@ void CSDL_Ext::fillRect( SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color )
 	SDL_FillRect(dst, &newRect, color);
 }
 
+void CSDL_Ext::fillRectBlack( SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	const Uint32 black = SDL_MapRGB(dst->format,0,0,0);
+	fillRect(dst,dstrect,black);
+}
+
 void CSDL_Ext::fillTexture(SDL_Surface *dst, SDL_Surface * src)
 {
 	SDL_Rect srcRect;

+ 1 - 0
client/gui/SDL_Extensions.h

@@ -208,6 +208,7 @@ namespace CSDL_Ext
 
 	void blitSurface(SDL_Surface * src, SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect);
 	void fillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
+	void fillRectBlack(SDL_Surface * dst, SDL_Rect * dstrect);
 	//fill dest image with source texture.
 	void fillTexture(SDL_Surface *dst, SDL_Surface * sourceTexture);