- added new messagebox prompt on server when data synch check enabled and data is different we stop the server from launching the game.
- added faction preview texture when users change their faction selection
This commit is contained in:
parent
135a03e95a
commit
6ce69a1e0b
|
@ -153,17 +153,168 @@ int Game::ErrorDisplayMessage(const char *msg, bool exitApp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger) {
|
||||
string result = "";
|
||||
if(settings == NULL) {
|
||||
result = "";
|
||||
}
|
||||
//Logger &logger= Logger::getInstance();
|
||||
string mapName= settings->getMap();
|
||||
string tilesetName= settings->getTileset();
|
||||
string techName= settings->getTech();
|
||||
string scenarioName= settings->getScenario();
|
||||
bool loadingImageUsed=false;
|
||||
|
||||
if(logger != NULL) {
|
||||
logger->setState(Lang::getInstance().get("Loading"));
|
||||
|
||||
if(scenarioName.empty()){
|
||||
logger->setSubtitle(formatString(mapName)+" - "+formatString(tilesetName)+" - "+formatString(techName));
|
||||
}
|
||||
else{
|
||||
logger->setSubtitle(formatString(scenarioName));
|
||||
}
|
||||
}
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
//good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//bool skipCustomLoadScreen = true;
|
||||
bool skipCustomLoadScreen = false;
|
||||
|
||||
string scenarioDir = "";
|
||||
if(skipCustomLoadScreen == false && settings->getScenarioDir() != "") {
|
||||
scenarioDir = settings->getScenarioDir();
|
||||
if(EndsWith(scenarioDir, ".xml") == true) {
|
||||
scenarioDir = scenarioDir.erase(scenarioDir.size() - 4, 4);
|
||||
scenarioDir = scenarioDir.erase(scenarioDir.size() - settings->getScenario().size(), settings->getScenario().size() + 1);
|
||||
}
|
||||
// use a scenario based loading screen
|
||||
vector<string> loadScreenList;
|
||||
findAll(scenarioDir + "loading_screen.*", loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
//string senarioLogo = scenarioDir + "/" + "loading_screen.jpg";
|
||||
string senarioLogo = scenarioDir + loadScreenList[0];
|
||||
if(fileExists(senarioLogo) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found scenario loading screen '%s'\n",__FILE__,__FUNCTION__,senarioLogo.c_str());
|
||||
|
||||
result = senarioLogo;
|
||||
if(logger != NULL) {
|
||||
logger->loadLoadingScreen(result);
|
||||
}
|
||||
loadingImageUsed=true;
|
||||
}
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings.getScenarioDir() = [%s] gameSettings.getScenario() = [%s] scenarioDir = [%s]\n",__FILE__,__FUNCTION__,__LINE__,settings->getScenarioDir().c_str(),settings->getScenario().c_str(),scenarioDir.c_str());
|
||||
}
|
||||
|
||||
// give CPU time to update other things to avoid apperance of hanging
|
||||
//sleep(0);
|
||||
//SDL_PumpEvents();
|
||||
|
||||
if(skipCustomLoadScreen == false && loadingImageUsed == false){
|
||||
// try to use a faction related loading screen
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Searching for faction loading screen\n",__FILE__,__FUNCTION__);
|
||||
for ( int i=0; i < settings->getFactionCount(); ++i ) {
|
||||
if( settings->getFactionControl(i) == ctHuman ||
|
||||
(settings->getFactionControl(i) == ctNetwork && settings->getThisFactionIndex() == i)){
|
||||
vector<string> pathList=config.getPathListForType(ptTechs,scenarioDir);
|
||||
for(int idx = 0; idx < pathList.size(); idx++) {
|
||||
const string path = pathList[idx]+ "/" +techName+ "/"+ "factions"+ "/"+ settings->getFactionTypeName(i);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] possible loading screen dir '%s'\n",__FILE__,__FUNCTION__,path.c_str());
|
||||
if(isdir(path.c_str()) == true) {
|
||||
vector<string> loadScreenList;
|
||||
findAll(path + "/" + "loading_screen.*", loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
//string factionLogo = path + "/" + "loading_screen.jpg";
|
||||
string factionLogo = path + "/" + loadScreenList[0];
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str());
|
||||
|
||||
if(fileExists(factionLogo) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str());
|
||||
|
||||
result = factionLogo;
|
||||
if(logger != NULL) {
|
||||
logger->loadLoadingScreen(result);
|
||||
}
|
||||
loadingImageUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(loadingImageUsed == true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(skipCustomLoadScreen == false && loadingImageUsed == false){
|
||||
// try to use a tech related loading screen
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Searching for tech loading screen\n",__FILE__,__FUNCTION__);
|
||||
|
||||
vector<string> pathList=config.getPathListForType(ptTechs,scenarioDir);
|
||||
for(int idx = 0; idx < pathList.size(); idx++) {
|
||||
const string path = pathList[idx]+ "/" +techName;
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] possible loading screen dir '%s'\n",__FILE__,__FUNCTION__,path.c_str());
|
||||
if(isdir(path.c_str()) == true) {
|
||||
vector<string> loadScreenList;
|
||||
findAll(path + "/" + "loading_screen.*", loadScreenList, false, false);
|
||||
if(loadScreenList.size() > 0) {
|
||||
//string factionLogo = path + "/" + "loading_screen.jpg";
|
||||
string factionLogo = path + "/" + loadScreenList[0];
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] looking for loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str());
|
||||
|
||||
if(fileExists(factionLogo) == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] found loading screen '%s'\n",__FILE__,__FUNCTION__,factionLogo.c_str());
|
||||
|
||||
result = factionLogo;
|
||||
if(logger != NULL) {
|
||||
logger->loadLoadingScreen(result);
|
||||
}
|
||||
loadingImageUsed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(loadingImageUsed == true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Game::load(){
|
||||
originalDisplayMsgCallback = NetworkInterface::getDisplayMessageFunction();
|
||||
NetworkInterface::setDisplayMessageFunction(ErrorDisplayMessage);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->gameSettings.toString().c_str());
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
Logger &logger= Logger::getInstance();
|
||||
Game::findFactionLogoFile(&gameSettings, &logger);
|
||||
|
||||
string mapName= gameSettings.getMap();
|
||||
string tilesetName= gameSettings.getTileset();
|
||||
string techName= gameSettings.getTech();
|
||||
string scenarioName= gameSettings.getScenario();
|
||||
|
||||
string scenarioDir = "";
|
||||
if(gameSettings.getScenarioDir() != "") {
|
||||
scenarioDir = gameSettings.getScenarioDir();
|
||||
if(EndsWith(scenarioDir, ".xml") == true) {
|
||||
scenarioDir = scenarioDir.erase(scenarioDir.size() - 4, 4);
|
||||
scenarioDir = scenarioDir.erase(scenarioDir.size() - gameSettings.getScenario().size(), gameSettings.getScenario().size() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bool loadingImageUsed=false;
|
||||
|
||||
logger.setState(Lang::getInstance().get("Loading"));
|
||||
|
@ -276,7 +427,7 @@ void Game::load(){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
//throw runtime_error("Test!");
|
||||
|
||||
SDL_PumpEvents();
|
||||
|
|
|
@ -143,6 +143,8 @@ public:
|
|||
void endPerformanceTimer();
|
||||
Vec2i getPerformanceTimerResults();
|
||||
|
||||
static string findFactionLogoFile(const GameSettings *settings, Logger *logger);
|
||||
|
||||
private:
|
||||
//render
|
||||
void render3d();
|
||||
|
|
|
@ -736,7 +736,7 @@ void Renderer::renderMouse3d() {
|
|||
|
||||
}
|
||||
|
||||
void Renderer::renderBackground(const Texture2D *texture){
|
||||
void Renderer::renderBackground(const Texture2D *texture) {
|
||||
|
||||
const Metrics &metrics= Metrics::getInstance();
|
||||
|
||||
|
|
|
@ -50,6 +50,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
{
|
||||
switchSetupRequestFlagType |= ssrft_NetworkPlayerName;
|
||||
updateDataSynchDetailText = false;
|
||||
|
||||
currentFactionLogo = "";
|
||||
factionTexture=NULL;
|
||||
|
||||
activeInputLabel = NULL;
|
||||
lastNetworkSendPing = 0;
|
||||
pingCount = 0;
|
||||
|
@ -183,7 +187,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//list boxes
|
||||
xoffset=120;
|
||||
xoffset=60;
|
||||
int rowHeight=27;
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
|
||||
|
@ -253,6 +257,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
chatManager.init(&console, -1,true);
|
||||
}
|
||||
|
||||
MenuStateConnectedGame::~MenuStateConnectedGame() {
|
||||
cleanupFactionTexture();
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
|
@ -396,8 +404,7 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
|
|||
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::render(){
|
||||
|
||||
void MenuStateConnectedGame::render() {
|
||||
try {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -407,6 +414,10 @@ void MenuStateConnectedGame::render(){
|
|||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
if(factionTexture != NULL) {
|
||||
renderer.renderTextureQuad(60+575+80,365,200,225,factionTexture,1);
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
int i;
|
||||
|
@ -661,7 +672,7 @@ void MenuStateConnectedGame::update() {
|
|||
bool errorOnMissingData = (clientInterface->getAllowGameDataSynchCheck() == false);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
vector<string> maps,tilesets,techtree;
|
||||
const GameSettings *gameSettings=clientInterface->getGameSettings();
|
||||
const GameSettings *gameSettings = clientInterface->getGameSettings();
|
||||
|
||||
if(gameSettings == NULL) {
|
||||
throw runtime_error("gameSettings == NULL");
|
||||
|
@ -784,6 +795,16 @@ void MenuStateConnectedGame::update() {
|
|||
mustSwitchPlayerName = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( clientInterface != NULL && clientInterface->isConnected() &&
|
||||
gameSettings != NULL) {
|
||||
|
||||
string factionLogo = Game::findFactionLogoFile(gameSettings, NULL);
|
||||
if(currentFactionLogo != factionLogo) {
|
||||
currentFactionLogo = factionLogo;
|
||||
loadFactionTexture(currentFactionLogo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update lobby
|
||||
|
@ -834,6 +855,7 @@ void MenuStateConnectedGame::update() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||
return;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
@ -1092,4 +1114,51 @@ string MenuStateConnectedGame::getHumanPlayerName() {
|
|||
return result;
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::loadFactionTexture(string filepath) {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
cleanupFactionTexture();
|
||||
|
||||
if(filepath=="")
|
||||
{
|
||||
factionTexture=NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str());
|
||||
|
||||
factionTexture = GraphicsInterface::getInstance().getFactory()->newTexture2D();
|
||||
//loadingTexture = renderer.newTexture2D(rsGlobal);
|
||||
factionTexture->setMipmap(true);
|
||||
//loadingTexture->getPixmap()->load(filepath);
|
||||
factionTexture->load(filepath);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.initTexture(rsGlobal,factionTexture);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::cleanupFactionTexture() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(factionTexture!=NULL) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
factionTexture->end();
|
||||
delete factionTexture;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//delete loadingTexture;
|
||||
factionTexture=NULL;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -109,8 +109,12 @@ private:
|
|||
int8 switchSetupRequestFlagType;
|
||||
string defaultPlayerName;
|
||||
|
||||
string currentFactionLogo;
|
||||
Texture2D *factionTexture;
|
||||
|
||||
public:
|
||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
||||
~MenuStateConnectedGame();
|
||||
|
||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
|
@ -131,6 +135,10 @@ private:
|
|||
void returnToJoinMenu();
|
||||
string getHumanPlayerName();
|
||||
void setActiveInputLabel(GraphicLabel *newLable);
|
||||
|
||||
void cleanupFactionTexture();
|
||||
void loadFactionTexture(string filepath);
|
||||
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -53,6 +53,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
activeInputLabel=NULL;
|
||||
showGeneralError = false;
|
||||
generalErrorToShow = "---";
|
||||
currentFactionLogo = "";
|
||||
factionTexture=NULL;
|
||||
|
||||
publishToMasterserverThread = NULL;
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -231,9 +233,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
|
||||
|
||||
// Advanced Options
|
||||
labelAdvanced.init(790, 80, 80);
|
||||
labelAdvanced.init(xoffset+650, 150, 80);
|
||||
labelAdvanced.setText(lang.get("AdvancedGameOptions"));
|
||||
listBoxAdvanced.init(810, 80-30, 80);
|
||||
listBoxAdvanced.init(xoffset+650, 150-30, 80);
|
||||
listBoxAdvanced.pushBackItem(lang.get("Yes"));
|
||||
listBoxAdvanced.pushBackItem(lang.get("No"));
|
||||
listBoxAdvanced.setSelectedItemIndex(0);
|
||||
|
@ -296,16 +298,16 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
||||
|
||||
//list boxes
|
||||
xoffset=120;
|
||||
xoffset=60;
|
||||
int rowHeight=27;
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
|
||||
labelPlayerNames[i].init(xoffset+100,setupPos-30-i*rowHeight);
|
||||
|
||||
listBoxControls[i].init(xoffset+200, setupPos-30-i*rowHeight);
|
||||
listBoxFactions[i].init(xoffset+350, setupPos-30-i*rowHeight, 150);
|
||||
listBoxTeams[i].init(xoffset+520, setupPos-30-i*rowHeight, 60);
|
||||
labelNetStatus[i].init(xoffset+600, setupPos-30-i*rowHeight, 60);
|
||||
listBoxControls[i].init(xoffset+175, setupPos-30-i*rowHeight);
|
||||
listBoxFactions[i].init(xoffset+320, setupPos-30-i*rowHeight, 150);
|
||||
listBoxTeams[i].init(xoffset+495, setupPos-30-i*rowHeight, 60);
|
||||
labelNetStatus[i].init(xoffset+575, setupPos-30-i*rowHeight, 60);
|
||||
}
|
||||
|
||||
labelControl.init(xoffset+200, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||
|
@ -425,6 +427,10 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
|||
publishToMasterserverThread = NULL;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
cleanupFactionTexture();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::returnToParentMenu(){
|
||||
|
@ -507,45 +513,75 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
|
||||
// Send the game settings to each client if we have at least one networked client
|
||||
safeMutex.Lock();
|
||||
if( hasNetworkGameSettings() == true &&
|
||||
needToSetChangedGameSettings == true)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
serverInterface->setGameSettings(&gameSettings,true);
|
||||
|
||||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
||||
if(bOkToStart == true) {
|
||||
if( listBoxPublishServer.getEditable() &&
|
||||
listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||
bool dataSynchCheckOk = true;
|
||||
for(int i= 0; i<mapInfo.players; ++i) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
needToRepublishToMasterserver = true;
|
||||
lastMasterserverPublishing = 0;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
ConnectionSlot* connectionSlot= serverInterface->getSlot(i);
|
||||
if(connectionSlot != NULL && connectionSlot->getNetworkGameDataSynchCheckOk() == false) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
dataSynchCheckOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
needToBroadcastServerSettings = false;
|
||||
needToRepublishToMasterserver = false;
|
||||
}
|
||||
|
||||
if(dataSynchCheckOk == false) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
mainMessageBoxState=1;
|
||||
showMessageBox( "You cannot start the game because\none or more clients do not have the same game data!", "Data Mismatch Error", false);
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
assert(program != NULL);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new Game(program, &gameSettings));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
safeMutex.ReleaseLock();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if( hasNetworkGameSettings() == true &&
|
||||
needToSetChangedGameSettings == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
serverInterface->setGameSettings(&gameSettings,true);
|
||||
|
||||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
||||
if(bOkToStart == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if( listBoxPublishServer.getEditable() &&
|
||||
listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
needToRepublishToMasterserver = true;
|
||||
lastMasterserverPublishing = 0;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
needToBroadcastServerSettings = false;
|
||||
needToRepublishToMasterserver = false;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
assert(program != NULL);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new Game(program, &gameSettings));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -824,10 +860,14 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
|||
listBoxAdvanced.mouseMove(x, y);
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::render(){
|
||||
void MenuStateCustomGame::render() {
|
||||
try {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
|
||||
if(factionTexture != NULL) {
|
||||
renderer.renderTextureQuad(60+575+40,365,200,225,factionTexture,1);
|
||||
}
|
||||
|
||||
if(mainMessageBox.getEnabled()){
|
||||
renderer.renderMessageBox(&mainMessageBox);
|
||||
}
|
||||
|
@ -1057,7 +1097,9 @@ void MenuStateCustomGame::update() {
|
|||
currentConnectionCount++;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] B - ctNetwork\n",__FILE__,__FUNCTION__);
|
||||
|
||||
string label = connectionSlot->getName() + ", " + connectionSlot->getVersionString();
|
||||
//string label = connectionSlot->getName() + ", " + connectionSlot->getVersionString();
|
||||
string label = connectionSlot->getVersionString();
|
||||
|
||||
if(connectionSlot != NULL &&
|
||||
connectionSlot->getAllowDownloadDataSynch() == true &&
|
||||
connectionSlot->getAllowGameDataSynchCheck() == true)
|
||||
|
@ -1184,11 +1226,11 @@ void MenuStateCustomGame::update() {
|
|||
needToSetChangedGameSettings == true &&
|
||||
difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
||||
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
|
||||
// Send the game settings to each client if we have at least one networked client
|
||||
if(checkDataSynch == true)
|
||||
{
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
if(checkDataSynch == true) {
|
||||
serverInterface->setGameSettings(&gameSettings,false);
|
||||
needToSetChangedGameSettings = false;
|
||||
}
|
||||
|
@ -1251,6 +1293,12 @@ void MenuStateCustomGame::update() {
|
|||
}
|
||||
soundConnectionCount = currentConnectionCount;
|
||||
|
||||
string factionLogo = Game::findFactionLogoFile(&gameSettings, NULL);
|
||||
if(currentFactionLogo != factionLogo) {
|
||||
currentFactionLogo = factionLogo;
|
||||
loadFactionTexture(currentFactionLogo);
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
|
@ -2066,4 +2114,51 @@ string MenuStateCustomGame::getHumanPlayerName(int index) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::loadFactionTexture(string filepath) {
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
cleanupFactionTexture();
|
||||
|
||||
if(filepath=="")
|
||||
{
|
||||
factionTexture=NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] filepath = [%s]\n",__FILE__,__FUNCTION__,__LINE__,filepath.c_str());
|
||||
|
||||
factionTexture = GraphicsInterface::getInstance().getFactory()->newTexture2D();
|
||||
//loadingTexture = renderer.newTexture2D(rsGlobal);
|
||||
factionTexture->setMipmap(true);
|
||||
//loadingTexture->getPixmap()->load(filepath);
|
||||
factionTexture->load(filepath);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.initTexture(rsGlobal,factionTexture);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::cleanupFactionTexture() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(factionTexture!=NULL) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
factionTexture->end();
|
||||
delete factionTexture;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//delete loadingTexture;
|
||||
factionTexture=NULL;
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -118,6 +118,9 @@ private:
|
|||
string defaultPlayerName;
|
||||
int8 switchSetupRequestFlagType;
|
||||
|
||||
string currentFactionLogo;
|
||||
Texture2D *factionTexture;
|
||||
|
||||
public:
|
||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false);
|
||||
~MenuStateCustomGame();
|
||||
|
@ -154,6 +157,9 @@ private:
|
|||
GameSettings loadGameSettingsFromFile(std::string fileName);
|
||||
void setActiveInputLabel(GraphicLabel *newLable);
|
||||
string getHumanPlayerName(int index=-1);
|
||||
|
||||
void cleanupFactionTexture();
|
||||
void loadFactionTexture(string filepath);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
Loading…
Reference in New Issue