- fixed TOM's game loading screen mouse click problem

This commit is contained in:
Mark Vejvoda
2010-06-25 05:05:52 +00:00
parent 96858fcd31
commit 848d953bd7
4 changed files with 53 additions and 17 deletions

View File

@@ -242,6 +242,8 @@ void Game::load(){
//throw runtime_error("Test!");
SDL_PumpEvents();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//tileset
@@ -249,7 +251,7 @@ void Game::load(){
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -265,7 +267,7 @@ void Game::load(){
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -274,7 +276,7 @@ void Game::load(){
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -286,7 +288,7 @@ void Game::load(){
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
@@ -315,13 +317,13 @@ void Game::init()
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
world.init(this, gameSettings.getDefaultUnits());
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
gui.init(this);
@@ -338,7 +340,7 @@ void Game::init()
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
scriptManager.init(&world, &gameCamera);
@@ -361,7 +363,7 @@ void Game::init()
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
//wheather particle systems
if(world.getTileset()->getWeather() == wRainy){
@@ -389,7 +391,7 @@ void Game::init()
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
//sounds
SoundRenderer &soundRenderer= SoundRenderer::getInstance();

View File

@@ -264,18 +264,36 @@ void Program::resize(SizeState sizeState){
// ==================== misc ====================
//Your filter function should look something like:
int SDLEventFilter(const SDL_Event* filterEvent) {
if(filterEvent->type == SDL_KEYDOWN || /**< Keys pressed */
filterEvent->type == SDL_KEYUP || /**< Keys released */
filterEvent->type == SDL_MOUSEMOTION || /**< Mouse moved */
filterEvent->type == SDL_MOUSEBUTTONDOWN || /**< Mouse button pressed */
filterEvent->type == SDL_MOUSEBUTTONUP) /**< Mouse button released */
{
return 0;
}
return 1;
}
void Program::setState(ProgramState *programState, bool cleanupOldState)
{
try {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
int X = 0;
int Y = 0;
SDL_GetMouseState(&X,&Y);
programState->setStartXY(X,Y);
if(dynamic_cast<Game *>(programState) != NULL) {
int X = 0;
int Y = 0;
SDL_GetMouseState(&X,&Y);
programState->setStartXY(X,Y);
showCursor(true);
sleep(0);
SDL_PumpEvents();
showCursor(true);
SDL_PumpEvents();
sleep(0);
}
if(cleanupOldState == true) {
if(this->programState != programState) {

View File

@@ -51,6 +51,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
for(int i=0; i<unitTypes.size(); ++i){
string str= dir + "/units/" + unitFilenames[i];
unitTypes[i].preLoad(str);
SDL_PumpEvents();
}
// a2) preload upgrades
@@ -61,6 +63,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
for(int i=0; i<upgradeTypes.size(); ++i){
string str= dir + "/upgrades/" + upgradeFilenames[i];
upgradeTypes[i].preLoad(str);
SDL_PumpEvents();
}
// b1) load units
@@ -68,6 +72,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
for(int i=0; i<unitTypes.size(); ++i){
string str= dir + "/units/" + unitTypes[i].getName();
unitTypes[i].load(i, str, techTree, this, checksum);
SDL_PumpEvents();
}
}
catch(const exception &e){
@@ -79,6 +85,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
for(int i=0; i<upgradeTypes.size(); ++i){
string str= dir + "/upgrades/" + upgradeTypes[i].getName();
upgradeTypes[i].load(str, techTree, this, checksum);
SDL_PumpEvents();
}
}
catch(const exception &e){
@@ -102,6 +110,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
string name= resourceNode->getAttribute("name")->getRestrictedValue();
int amount= resourceNode->getAttribute("amount")->getIntValue();
startingResources[i].init(techTree->getResourceType(name), amount);
SDL_PumpEvents();
}
//read starting units
@@ -111,6 +121,8 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
string name= unitNode->getAttribute("name")->getRestrictedValue();
int amount= unitNode->getAttribute("amount")->getIntValue();
startingUnits.push_back(PairPUnitTypeInt(getUnitType(name), amount));
SDL_PumpEvents();
}
//read music

View File

@@ -60,6 +60,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
for(int i=0; i<filenames.size(); ++i){
str=dir+"/resources/"+filenames[i];
resourceTypes[i].load(str, checksum);
SDL_PumpEvents();
}
}
catch(const exception &e){
@@ -68,7 +69,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
//load tech tree xml info
try{
@@ -87,6 +88,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
const XmlNode *attackTypeNode= attackTypesNode->getChild("attack-type", i);
attackTypes[i].setName(attackTypeNode->getAttribute("name")->getRestrictedValue());
attackTypes[i].setId(i);
SDL_PumpEvents();
}
// give CPU time to update other things to avoid apperance of hanging
@@ -100,6 +102,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
const XmlNode *armorTypeNode= armorTypesNode->getChild("armor-type", i);
armorTypes[i].setName(armorTypeNode->getAttribute("name")->getRestrictedValue());
armorTypes[i].setId(i);
SDL_PumpEvents();
}
//damage multipliers
@@ -111,6 +114,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
const ArmorType *armorType= getArmorType(damageMultiplierNode->getAttribute("armor")->getRestrictedValue());
float multiplier= damageMultiplierNode->getAttribute("value")->getFloatValue();
damageMultiplierTable.setDamageMultiplier(attackType, armorType, multiplier);
SDL_PumpEvents();
}
}
catch(const exception &e){
@@ -139,7 +143,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
// give CPU time to update other things to avoid apperance of hanging
sleep(0);
//SDL_PumpEvents();
SDL_PumpEvents();
}
}