1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Video in Tavern Window. Minor improvements.

This commit is contained in:
Michał W. Urbańczyk 2009-06-24 09:17:33 +00:00
parent 60f7048662
commit f0dea8d708
5 changed files with 68 additions and 18 deletions

View File

@ -892,7 +892,7 @@ void CPlayerInterface::handleMouseMotion(SDL_Event *sEvent)
}
//adventure map scrolling with mouse
if(!SDL_GetKeyState(NULL)[SDLK_LCTRL])
if(!SDL_GetKeyState(NULL)[SDLK_LCTRL] && adventureInt->active)
{
if(sEvent->motion.x<15)
{

View File

@ -2055,7 +2055,6 @@ StartInfo CPreGame::runLoop()
#ifdef _WIN32
CGI->videoh->open("ACREDIT.SMK");
CGI->videoh->show(8, 105, screen, false);
#endif
while(run)
@ -2336,7 +2335,9 @@ StartInfo CPreGame::runLoop()
SDL_Delay(20); //give time for other apps
}
ret.mode = (fromMenu==newGame) ? 0 : 1;
#ifdef _WIN32
CGI->videoh->close();
#endif
return ret;
}

View File

@ -39,6 +39,7 @@
#include "../lib/NetPacks.h"
#include "CSpellWindow.h"
#include "CHeroWindow.h"
#include "../hch/CVideoHandler.h"
/*
* GUIClasses.cpp, part of VCMI engine
@ -2788,6 +2789,10 @@ CTavernWindow::CTavernWindow(const CGHeroInstance *H1, const CGHeroInstance *H2,
if(!H1)
recruit->block(1);
}
#ifdef _WIN32
CGI->videoh->open("TAVERN.BIK");
#endif
}
void CTavernWindow::recruitb()
@ -2799,6 +2804,9 @@ void CTavernWindow::recruitb()
CTavernWindow::~CTavernWindow()
{
#ifdef _WIN32
CGI->videoh->close();
#endif
SDL_FreeSurface(bg);
delete cancel;
delete thiefGuild;
@ -2837,6 +2845,9 @@ void CTavernWindow::close()
void CTavernWindow::show(SDL_Surface * to)
{
blitAt(bg,pos.x,pos.y,to);
#ifdef _WIN32
CGI->videoh->update(pos.x+70, pos.y+56, to, true, false);
#endif
if(h1.h)
h1.show(to);
if(h2.h)

View File

@ -181,6 +181,14 @@ int CBIKHandler::frameCount() const
return hBink->frameCount;
}
void CBIKHandler::redraw( int x, int y, SDL_Surface *dst, bool update )
{
int w = hBink->width, h = hBink->height;
blitBuffer(buffer, x, y, w, h, dst);
if(update)
SDL_UpdateRect(dst, x, y, w, h);
}
void CSmackPlayer::nextFrame()
{
ptrSmackNextFrame(data);
@ -241,8 +249,22 @@ void CSmackPlayer::show( int x, int y, SDL_Surface *dst, bool update)
//put frame to the buffer
ptrSmackToBuffer(data, 0, 0, stripe, w, buf, 0x80000000);
ptrSmackDoFrame(data);
redraw(x, y, dst, update);
}
int CSmackPlayer::curFrame() const
{
return data->currentFrame;
}
int CSmackPlayer::frameCount() const
{
return data->frameCount;
}
void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
{
int w = data->width, h = data->height;
/* Lock the screen for direct access to the pixels */
if ( SDL_MUSTLOCK(dst) )
{
@ -279,16 +301,6 @@ void CSmackPlayer::show( int x, int y, SDL_Surface *dst, bool update)
SDL_UpdateRect(dst, x, y, w, h);
}
int CSmackPlayer::curFrame() const
{
return data->currentFrame;
}
int CSmackPlayer::frameCount() const
{
return data->frameCount;
}
CVideoPlayer::CVideoPlayer()
{
vidh = new CVidHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "VIDEO.VID"));
@ -308,6 +320,7 @@ void CVideoPlayer::open(std::string name)
current = &smkPlayer;
fname = name;
first = true;
//extract video from video.vid so we can play it
vidh->extract(name, name);
@ -365,15 +378,35 @@ bool CVideoPlayer::openAndPlayVideo(std::string name, int x, int y, SDL_Surface
return ret;
}
void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool redraw, bool update )
void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, bool update )
{
bool w = wait(); //check if should keep current frame
bool w = false;
if(!first)
{
w = wait(); //check if should keep current frame
if(!w)
nextFrame();
}
else
{
first = false;
}
if(!w)
nextFrame();
if(!w || redraw) //redraw if changed frame or we was told to
if(!w)
{
show(x,y,dst,update);
}
else if (forceRedraw)
{
redraw(x, y, dst, update);
}
}
void CVideoPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
{
current->redraw(x, y, dst, update);
}
//reads events and throws on key down

View File

@ -65,6 +65,7 @@ public:
virtual void close()=0;
virtual void nextFrame()=0;
virtual void show(int x, int y, SDL_Surface *dst, bool update = true)=0;
virtual void redraw(int x, int y, SDL_Surface *dst, bool update = true)=0; //reblits buffer
virtual bool wait()=0;
virtual int curFrame() const =0;
virtual int frameCount() const =0;
@ -90,6 +91,7 @@ public:
void close();
void nextFrame();
void show(int x, int y, SDL_Surface *dst, bool update = true);
void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer
bool wait();
int curFrame() const;
int frameCount() const;
@ -143,6 +145,7 @@ public:
void close();
void nextFrame();
void show(int x, int y, SDL_Surface *dst, bool update = true);
void redraw(int x, int y, SDL_Surface *dst, bool update = true); //reblits buffer
bool wait();
int curFrame() const;
int frameCount() const;
@ -160,6 +163,7 @@ private:
IVideoPlayer *current; //points to bik or smk player, appropriate to type of currently played video
std::string fname; //name of current video file (empty if idle)
bool first; //are we about to display the first frame (blocks update)
public:
CVideoPlayer(); //c-tor
~CVideoPlayer(); //d-tor
@ -169,7 +173,8 @@ public:
void close();
void nextFrame(); //move animation to the next frame
void show(int x, int y, SDL_Surface *dst, bool update = true); //blit current frame
void update(int x, int y, SDL_Surface *dst, bool redraw, bool update = true); //moves to next frame if appropriate, and blits it or blits only if redraw paremeter is set true
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 paremeter is set true
bool wait(); //true if we should wait before displaying next frame (for keeping FPS)
int curFrame() const; //current frame number <1, framecount>
int frameCount() const;