1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Moved framerate keeper from CPlayerInterface to CGuiHandler, thing should be running smoother.

This commit is contained in:
Michał W. Urbańczyk 2011-04-03 10:45:39 +00:00
parent 6d52bb5842
commit b5a546349b
4 changed files with 13 additions and 14 deletions

View File

@ -10,8 +10,6 @@
#include "CPlayerInterface.h"
//#include "SDL_Extensions.h"
#include "SDL_Extensions.h"
//#include "SDL_framerate.h"
#include "SDL_framerate.h"
#include "CConfigHandler.h"
#include "CCreatureAnimation.h"
@ -108,9 +106,6 @@ CPlayerInterface::CPlayerInterface(int Player)
showingDialog = new CondSh<bool>(false);
sysOpts = GDefaultOptions;
//initializing framerate keeper
mainFPSmng = new FPSmanager;
SDL_initFramerate(mainFPSmng);
SDL_setFramerate(mainFPSmng, 48);
//framerate keeper initialized
cingconsole = new CInGameConsole;
terminate_cond.set(false);
@ -123,7 +118,6 @@ CPlayerInterface::~CPlayerInterface()
//delete pim;
//delNull(pim);
delete showingDialog;
delete mainFPSmng;
if(adventureInt)
{
if(adventureInt->active & CIntObject::KEYBOARD)
@ -289,7 +283,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
initMovement(details, ho, hp);
//first initializing done
SDL_framerateDelay(mainFPSmng); // after first move
SDL_framerateDelay(GH.mainFPSmng); // after first move
//main moving
for(int i=1; i<32; i+=2*sysOpts.heroMoveSpeed)
@ -298,7 +292,7 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
adventureInt->updateScreen = true;
adventureInt->show(screen);
CSDL_Ext::update(screen);
SDL_framerateDelay(mainFPSmng); //for animation purposes
SDL_framerateDelay(GH.mainFPSmng); //for animation purposes
} //for(int i=1; i<32; i+=4)
//main moving done
@ -1349,8 +1343,6 @@ void CPlayerInterface::update()
CCS->curh->draw2();
pim->unlock();
SDL_framerateDelay(mainFPSmng);
}
int CPlayerInterface::getLastIndex( std::string namePrefix)

View File

@ -3,7 +3,6 @@
#include "../global.h"
#include "../CGameInterface.h"
#include "../lib/CondSh.h"
#include "SDL_framerate.h"
#include <map>
#include <list>
#include <algorithm>
@ -130,7 +129,6 @@ public:
CCastleInterface * castleInt; //NULL if castle window isn't opened
static CBattleInterface * battleInt; //NULL if no battle
FPSmanager * mainFPSmng; //to keep const framerate
CInGameConsole * cingconsole;
CCallback * cb; //to communicate with engine

View File

@ -9,6 +9,7 @@
#include "CBitmapHandler.h"
#include "Graphics.h"
#include "../CThreadHelper.h"
/*
* GUIBase.cpp, part of VCMI engine
*
@ -342,11 +343,14 @@ void CGuiHandler::run()
setThreadName(-1, "CGuiHandler::run");
try
{
SDL_initFramerate(mainFPSmng);
while(!terminate)
{
if(curInt)
curInt->update();
SDL_Delay(20); //give time for other apps
SDL_framerateDelay(mainFPSmng);
//SDL_Delay(20); //give time for other apps
}
} HANDLE_EXCEPTION
}
@ -358,11 +362,14 @@ CGuiHandler::CGuiHandler()
current = NULL;
terminate = false;
statusbar = NULL;
mainFPSmng = new FPSmanager;
SDL_setFramerate(mainFPSmng, 48);
}
CGuiHandler::~CGuiHandler()
{
delete mainFPSmng;
}
void CGuiHandler::breakEventHandling()

View File

@ -7,6 +7,7 @@
#include <list>
#include "../timeHandler.h"
#include "FontBase.h"
#include "SDL_framerate.h"
#ifdef max
#undef max
@ -511,6 +512,7 @@ public:
class CGuiHandler
{
public:
FPSmanager * mainFPSmng; //to keep const framerate
timeHandler th;
std::list<IShowActivable *> listInt; //list of interfaces - front=foreground; back = background (includes adventure map, window interfaces, all kind of active dialogs, and so on)
IStatusBar * statusbar;