Forráskód Böngészése

Make scale a parameter of "open" methods

AlexVinS 11 éve
szülő
commit
679dd64ff9
4 módosított fájl, 28 hozzáadás és 47 törlés
  1. 2 4
      client/CMT.cpp
  2. 0 7
      client/CSpellWindow.cpp
  3. 5 7
      client/CVideoHandler.cpp
  4. 21 29
      client/CVideoHandler.h

+ 2 - 4
client/CMT.cpp

@@ -779,12 +779,10 @@ void processCommand(const std::string &message)
 //plays intro, ends when intro is over or button has been pressed (handles events)
 void playIntro()
 {
-	CCS->videoh->setScaling(true);
-	if(CCS->videoh->openAndPlayVideo("3DOLOGO.SMK", 60, 40, screen, true))
+	if(CCS->videoh->openAndPlayVideo("3DOLOGO.SMK", 60, 40, screen, true, true))
 	{
-		CCS->videoh->openAndPlayVideo("AZVS.SMK", 60, 80, screen, true);
+		CCS->videoh->openAndPlayVideo("AZVS.SMK", 60, 80, screen, true, true);
 	}
-	CCS->videoh->setScaling(false);
 }
 
 void dispose()

+ 0 - 7
client/CSpellWindow.cpp

@@ -516,20 +516,13 @@ void CSpellWindow::deactivate()
 void CSpellWindow::turnPageLeft()
 {
 	if (settings["video"]["spellbookAnimation"].Bool())
-	{
-		CCS->videoh->setScaling(false);
 		CCS->videoh->openAndPlayVideo("PGTRNLFT.SMK", pos.x+13, pos.y+15, screen);
-	}
-		
 }
 
 void CSpellWindow::turnPageRight()
 {
 	if (settings["video"]["spellbookAnimation"].Bool())
-	{
-		CCS->videoh->setScaling(false);
 		CCS->videoh->openAndPlayVideo("PGTRNRGH.SMK", pos.x+13, pos.y+15, screen);
-	}		
 }
 
 void CSpellWindow::keyPressed(const SDL_KeyboardEvent & key)

+ 5 - 7
client/CVideoHandler.cpp

@@ -71,18 +71,16 @@ CVideoPlayer::CVideoPlayer()
 	// combination of av_register_input_format() /
 	// av_register_output_format() / av_register_protocol() instead.
 	av_register_all();
-	
-	doScale = false;
 }
 
-bool CVideoPlayer::open(std::string fname)
+bool CVideoPlayer::open(std::string fname, bool scale/* = false*/)
 {
 	return open(fname, true, false);
 }
 
 // loop = to loop through the video
 // useOverlay = directly write to the screen.
-bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
+bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scale /*= false*/)
 {
 	close();
 
@@ -167,7 +165,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 	
 	//setup scaling
 	
-	if(doScale)
+	if(scale)
 	{
 		pos.w = screen->w;		
 		pos.h = screen->h;
@@ -480,9 +478,9 @@ bool CVideoPlayer::playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey)
 	return true;
 }
 
-bool CVideoPlayer::openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey)
+bool CVideoPlayer::openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey, bool scale/* = false*/)
 {
-	open(name, false, true);
+	open(name, false, true, scale);
 	bool ret = playVideo(x, y, dst, stopOnKey);
 	close();
 	return ret;

+ 21 - 29
client/CVideoHandler.h

@@ -6,7 +6,7 @@ struct SDL_Surface;
 class IVideoPlayer
 {
 public:
-	virtual bool open(std::string name)=0; //true - succes
+	virtual bool open(std::string name, bool scale = false)=0; //true - succes
 	virtual void close()=0;
 	virtual bool nextFrame()=0;
 	virtual void show(int x, int y, SDL_Surface *dst, bool update = true)=0;
@@ -14,9 +14,6 @@ public:
 	virtual bool wait()=0;
 	virtual int curFrame() const =0;
 	virtual int frameCount() const =0;
-	
-	virtual void setScaling(bool enabled) =0;
-
 };
 
 class IMainVideoPlayer : public IVideoPlayer
@@ -25,7 +22,7 @@ public:
 	std::string fname;  //name of current video file (empty if idle)
 
 	virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true){}
-	virtual bool openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey = false) 
+	virtual bool openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey = false, bool scale = false)
 	{
 		return false;
 	}
@@ -34,15 +31,14 @@ public:
 class CEmptyVideoPlayer : public IMainVideoPlayer
 {
 public:
-	virtual int curFrame() const {return -1;};
-	virtual int frameCount() const {return -1;};
-	virtual void redraw( int x, int y, SDL_Surface *dst, bool update = true ) {};
-	virtual void show( int x, int y, SDL_Surface *dst, bool update = true ) {};
-	virtual bool nextFrame() {return false;};
-	virtual void close() {};
-	virtual bool wait() {return false;};
-	virtual bool open( std::string name ) {return false;};
-	void setScaling(bool enabled) override {};
+	int curFrame() const override {return -1;};
+	int frameCount() const override {return -1;};
+	void redraw(int x, int y, SDL_Surface *dst, bool update = true) override {};
+	void show(int x, int y, SDL_Surface *dst, bool update = true) override{};
+	bool nextFrame() override {return false;};
+	void close() override {};
+	bool wait() override {return false;};
+	bool open(std::string name, bool scale = false) override {return false;};
 };
 
 
@@ -86,34 +82,30 @@ class CVideoPlayer : public IMainVideoPlayer
 	int refreshWait; // Wait several refresh before updating the image
 	int refreshCount;
 	bool doLoop;				// loop through video
-	
-	bool doScale;
 
 	bool playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey);
-	bool open(std::string fname, bool loop, bool useOverlay = false);
+	bool open(std::string fname, bool loop, bool useOverlay = false, bool scale = false);
 
 public:
 	CVideoPlayer();
 	~CVideoPlayer();
 
 	bool init();
-	bool open(std::string fname);
-	void close();
-	bool nextFrame();			// display next frame
+	bool open(std::string fname, bool scale = false) override;
+	void close() override;
+	bool nextFrame() override;			// display next frame
 
-	void show(int x, int y, SDL_Surface *dst, bool update = true); //blit current frame
-	void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer
-	void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true); //moves to next frame if appropriate, and blits it or blits only if redraw parameter is set true
+	void show(int x, int y, SDL_Surface *dst, bool update = true) override; //blit current frame
+	void redraw(int x, int y, SDL_Surface *dst, bool update = true) override; //reblits buffer
+	void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true) override; //moves to next frame if appropriate, and blits it or blits only if redraw parameter is set true
 	
 	// Opens video, calls playVideo, closes video; returns playVideo result (if whole video has been played)
-	bool openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey = false);
+	bool openAndPlayVideo(std::string name, int x, int y, SDL_Surface *dst, bool stopOnKey = false, bool scale = false) override;
 
 	//TODO:
-	bool wait(){return false;};
-	int curFrame() const {return -1;};
-	int frameCount() const {return -1;};
-
-	void setScaling(bool enabled) override {doScale = enabled;};
+	bool wait() override {return false;};
+	int curFrame() const override {return -1;};
+	int frameCount() const override {return -1;};
 
 	// public to allow access from ffmpeg IO functions
 	std::unique_ptr<CInputStream> data;