mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 11:19:48 +02:00
- added code so Alt-Enter etc. works during game loading phase
This commit is contained in:
@@ -49,6 +49,7 @@ Game::Game(Program *program, const GameSettings *gameSettings):
|
|||||||
|
|
||||||
this->program = program;
|
this->program = program;
|
||||||
Unit::setGame(this);
|
Unit::setGame(this);
|
||||||
|
gameStarted = false;
|
||||||
|
|
||||||
original_updateFps = GameConstants::updateFps;
|
original_updateFps = GameConstants::updateFps;
|
||||||
original_cameraFps = GameConstants::cameraFps;
|
original_cameraFps = GameConstants::cameraFps;
|
||||||
@@ -368,6 +369,7 @@ void Game::load(LoadGameItem loadTypes) {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
Game::findFactionLogoFile(&gameSettings, &logger);
|
Game::findFactionLogoFile(&gameSettings, &logger);
|
||||||
|
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,6 +395,7 @@ void Game::load(LoadGameItem loadTypes) {
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -430,6 +433,7 @@ void Game::load(LoadGameItem loadTypes) {
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -442,6 +446,7 @@ void Game::load(LoadGameItem loadTypes) {
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -501,6 +506,7 @@ void Game::init(bool initForPreviewOnly)
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,6 +517,7 @@ void Game::init(bool initForPreviewOnly)
|
|||||||
if(initForPreviewOnly == false) {
|
if(initForPreviewOnly == false) {
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
gui.init(this);
|
gui.init(this);
|
||||||
@@ -537,6 +544,7 @@ void Game::init(bool initForPreviewOnly)
|
|||||||
if(initForPreviewOnly == false) {
|
if(initForPreviewOnly == false) {
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
scriptManager.init(&world, &gameCamera);
|
scriptManager.init(&world, &gameCamera);
|
||||||
@@ -570,6 +578,7 @@ void Game::init(bool initForPreviewOnly)
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
//weather particle systems
|
//weather particle systems
|
||||||
@@ -607,6 +616,7 @@ void Game::init(bool initForPreviewOnly)
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -660,6 +670,8 @@ void Game::init(bool initForPreviewOnly)
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"================ STARTING GAME ================\n");
|
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"================ STARTING GAME ================\n");
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"PathFinderType: %s\n", (getGameSettings()->getPathFinderType() ? "RoutePlanner" : "PathFinder"));
|
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"PathFinderType: %s\n", (getGameSettings()->getPathFinderType() ? "RoutePlanner" : "PathFinder"));
|
||||||
|
|
||||||
|
gameStarted = true;
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = %llu\n",__FILE__,__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = %llu\n",__FILE__,__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== START GAME ====\n");
|
SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== START GAME ====\n");
|
||||||
}
|
}
|
||||||
@@ -933,9 +945,12 @@ void Game::tick() {
|
|||||||
|
|
||||||
// ==================== events ====================
|
// ==================== events ====================
|
||||||
|
|
||||||
void Game::mouseDownLeft(int x, int y){
|
void Game::mouseDownLeft(int x, int y) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Map *map= world.getMap();
|
Map *map= world.getMap();
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
@@ -1028,8 +1043,12 @@ void Game::mouseDownLeft(int x, int y){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseDownRight(int x, int y){
|
void Game::mouseDownRight(int x, int y) {
|
||||||
try {
|
try {
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Map *map= world.getMap();
|
Map *map= world.getMap();
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
|
||||||
@@ -1057,13 +1076,25 @@ void Game::mouseDownRight(int x, int y){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseUpCenter(int x, int y){
|
void Game::mouseUpCenter(int x, int y) {
|
||||||
if (!mouseMoved) gameCamera.resetPosition();
|
if(gameStarted == false) {
|
||||||
else mouseMoved = false;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mouseMoved == false) {
|
||||||
|
gameCamera.resetPosition();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mouseMoved = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseUpLeft(int x, int y){
|
void Game::mouseUpLeft(int x, int y) {
|
||||||
try {
|
try {
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gui.mouseUpLeftGraphics(x, y);
|
gui.mouseUpLeftGraphics(x, y);
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
@@ -1077,8 +1108,12 @@ void Game::mouseUpLeft(int x, int y){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseDoubleClickLeft(int x, int y){
|
void Game::mouseDoubleClickLeft(int x, int y) {
|
||||||
try {
|
try {
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
|
||||||
//display panel
|
//display panel
|
||||||
@@ -1104,8 +1139,12 @@ void Game::mouseDoubleClickLeft(int x, int y){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mouseMove(int x, int y, const MouseState *ms){
|
void Game::mouseMove(int x, int y, const MouseState *ms) {
|
||||||
try {
|
try {
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const Metrics &metrics = Metrics::getInstance();
|
const Metrics &metrics = Metrics::getInstance();
|
||||||
|
|
||||||
mouseX = x;
|
mouseX = x;
|
||||||
@@ -1219,7 +1258,10 @@ void Game::eventMouseWheel(int x, int y, int zDelta) {
|
|||||||
|
|
||||||
void Game::keyDown(char key) {
|
void Game::keyDown(char key) {
|
||||||
try {
|
try {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c] [%d] gameStarted [%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key, gameStarted);
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame();
|
||||||
@@ -1388,6 +1430,10 @@ void Game::keyDown(char key) {
|
|||||||
|
|
||||||
void Game::keyUp(char key){
|
void Game::keyUp(char key){
|
||||||
try {
|
try {
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(chatManager.getEditEnabled()) {
|
if(chatManager.getEditEnabled()) {
|
||||||
//send key to the chat manager
|
//send key to the chat manager
|
||||||
chatManager.keyUp(key);
|
chatManager.keyUp(key);
|
||||||
@@ -1428,6 +1474,10 @@ void Game::keyUp(char key){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::keyPress(char c){
|
void Game::keyPress(char c){
|
||||||
|
if(gameStarted == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
chatManager.keyPress(c);
|
chatManager.keyPress(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -112,6 +112,8 @@ private:
|
|||||||
bool photoModeEnabled;
|
bool photoModeEnabled;
|
||||||
Program *program;
|
Program *program;
|
||||||
|
|
||||||
|
bool gameStarted;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(Program *program, const GameSettings *gameSettings);
|
Game(Program *program, const GameSettings *gameSettings);
|
||||||
~Game();
|
~Game();
|
||||||
@@ -168,6 +170,7 @@ public:
|
|||||||
static string findFactionLogoFile(const GameSettings *settings, Logger *logger, string factionLogoFilter="loading_screen.*");
|
static string findFactionLogoFile(const GameSettings *settings, Logger *logger, string factionLogoFilter="loading_screen.*");
|
||||||
|
|
||||||
bool getGameOver() { return gameOver; }
|
bool getGameOver() { return gameOver; }
|
||||||
|
bool hasGameStarted() { return gameStarted;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//render
|
//render
|
||||||
|
@@ -19,11 +19,11 @@
|
|||||||
#include "conversion.h"
|
#include "conversion.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
#include "leak_dumper.h"
|
|
||||||
|
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "window.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Shared::Platform;
|
using namespace Shared::Platform;
|
||||||
@@ -727,6 +727,8 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window::handleEvent();
|
||||||
// sleep a bit
|
// sleep a bit
|
||||||
sleep(waitSleepTime);
|
sleep(waitSleepTime);
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "game_util.h"
|
#include "game_util.h"
|
||||||
#include "miniftpserver.h"
|
#include "miniftpserver.h"
|
||||||
|
#include "window.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -992,6 +993,8 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window::handleEvent();
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s] PART B (telling client we are ready!\n",__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s] PART B (telling client we are ready!\n",__FUNCTION__);
|
||||||
try {
|
try {
|
||||||
|
@@ -19,7 +19,8 @@
|
|||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "xml_parser.h"
|
#include "xml_parser.h"
|
||||||
#include "platform_util.h"
|
#include "platform_util.h"
|
||||||
#include "game_util.h"
|
#include "game_util.h"
|
||||||
|
#include "window.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
using namespace Shared::Util;
|
using namespace Shared::Util;
|
||||||
@@ -62,6 +63,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
for(int i=0; i<filenames.size(); ++i){
|
for(int i=0; i<filenames.size(); ++i){
|
||||||
str=dir+"/resources/"+filenames[i];
|
str=dir+"/resources/"+filenames[i];
|
||||||
resourceTypes[i].load(str, checksum, &checksumValue);
|
resourceTypes[i].load(str, checksum, &checksumValue);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +79,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
//load tech tree xml info
|
//load tech tree xml info
|
||||||
@@ -97,6 +100,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
const XmlNode *attackTypeNode= attackTypesNode->getChild("attack-type", i);
|
const XmlNode *attackTypeNode= attackTypesNode->getChild("attack-type", i);
|
||||||
attackTypes[i].setName(attackTypeNode->getAttribute("name")->getRestrictedValue());
|
attackTypes[i].setName(attackTypeNode->getAttribute("name")->getRestrictedValue());
|
||||||
attackTypes[i].setId(i);
|
attackTypes[i].setId(i);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +115,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
const XmlNode *armorTypeNode= armorTypesNode->getChild("armor-type", i);
|
const XmlNode *armorTypeNode= armorTypesNode->getChild("armor-type", i);
|
||||||
armorTypes[i].setName(armorTypeNode->getAttribute("name")->getRestrictedValue());
|
armorTypes[i].setName(armorTypeNode->getAttribute("name")->getRestrictedValue());
|
||||||
armorTypes[i].setId(i);
|
armorTypes[i].setId(i);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +128,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
const ArmorType *armorType= getArmorType(damageMultiplierNode->getAttribute("armor")->getRestrictedValue());
|
const ArmorType *armorType= getArmorType(damageMultiplierNode->getAttribute("armor")->getRestrictedValue());
|
||||||
float multiplier= damageMultiplierNode->getAttribute("value")->getFloatValue();
|
float multiplier= damageMultiplierNode->getAttribute("value")->getFloatValue();
|
||||||
damageMultiplierTable.setDamageMultiplier(attackType, armorType, multiplier);
|
damageMultiplierTable.setDamageMultiplier(attackType, armorType, multiplier);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,6 +161,7 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user