- 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;
|
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(){
|
void Game::load(){
|
||||||
originalDisplayMsgCallback = NetworkInterface::getDisplayMessageFunction();
|
originalDisplayMsgCallback = NetworkInterface::getDisplayMessageFunction();
|
||||||
NetworkInterface::setDisplayMessageFunction(ErrorDisplayMessage);
|
NetworkInterface::setDisplayMessageFunction(ErrorDisplayMessage);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] gameSettings = [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->gameSettings.toString().c_str());
|
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();
|
Logger &logger= Logger::getInstance();
|
||||||
|
Game::findFactionLogoFile(&gameSettings, &logger);
|
||||||
|
|
||||||
string mapName= gameSettings.getMap();
|
string mapName= gameSettings.getMap();
|
||||||
string tilesetName= gameSettings.getTileset();
|
string tilesetName= gameSettings.getTileset();
|
||||||
string techName= gameSettings.getTech();
|
string techName= gameSettings.getTech();
|
||||||
string scenarioName= gameSettings.getScenario();
|
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;
|
bool loadingImageUsed=false;
|
||||||
|
|
||||||
logger.setState(Lang::getInstance().get("Loading"));
|
logger.setState(Lang::getInstance().get("Loading"));
|
||||||
|
@ -276,7 +427,7 @@ void Game::load(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
//throw runtime_error("Test!");
|
//throw runtime_error("Test!");
|
||||||
|
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
|
@ -143,6 +143,8 @@ public:
|
||||||
void endPerformanceTimer();
|
void endPerformanceTimer();
|
||||||
Vec2i getPerformanceTimerResults();
|
Vec2i getPerformanceTimerResults();
|
||||||
|
|
||||||
|
static string findFactionLogoFile(const GameSettings *settings, Logger *logger);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//render
|
//render
|
||||||
void render3d();
|
void render3d();
|
||||||
|
|
|
@ -50,6 +50,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||||
{
|
{
|
||||||
switchSetupRequestFlagType |= ssrft_NetworkPlayerName;
|
switchSetupRequestFlagType |= ssrft_NetworkPlayerName;
|
||||||
updateDataSynchDetailText = false;
|
updateDataSynchDetailText = false;
|
||||||
|
|
||||||
|
currentFactionLogo = "";
|
||||||
|
factionTexture=NULL;
|
||||||
|
|
||||||
activeInputLabel = NULL;
|
activeInputLabel = NULL;
|
||||||
lastNetworkSendPing = 0;
|
lastNetworkSendPing = 0;
|
||||||
pingCount = 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__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//list boxes
|
//list boxes
|
||||||
xoffset=120;
|
xoffset=60;
|
||||||
int rowHeight=27;
|
int rowHeight=27;
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||||
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
|
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
|
||||||
|
@ -253,6 +257,10 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
||||||
chatManager.init(&console, -1,true);
|
chatManager.init(&console, -1,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuStateConnectedGame::~MenuStateConnectedGame() {
|
||||||
|
cleanupFactionTexture();
|
||||||
|
}
|
||||||
|
|
||||||
void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
CoreData &coreData= CoreData::getInstance();
|
CoreData &coreData= CoreData::getInstance();
|
||||||
|
@ -397,7 +405,6 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateConnectedGame::render() {
|
void MenuStateConnectedGame::render() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//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__);
|
||||||
|
|
||||||
|
@ -407,6 +414,10 @@ void MenuStateConnectedGame::render(){
|
||||||
|
|
||||||
Renderer &renderer= Renderer::getInstance();
|
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__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -784,6 +795,16 @@ void MenuStateConnectedGame::update() {
|
||||||
mustSwitchPlayerName = true;
|
mustSwitchPlayerName = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( clientInterface != NULL && clientInterface->isConnected() &&
|
||||||
|
gameSettings != NULL) {
|
||||||
|
|
||||||
|
string factionLogo = Game::findFactionLogoFile(gameSettings, NULL);
|
||||||
|
if(currentFactionLogo != factionLogo) {
|
||||||
|
currentFactionLogo = factionLogo;
|
||||||
|
loadFactionTexture(currentFactionLogo);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//update lobby
|
//update lobby
|
||||||
|
@ -834,6 +855,7 @@ void MenuStateConnectedGame::update() {
|
||||||
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__);
|
||||||
|
|
||||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||||
|
return;
|
||||||
|
|
||||||
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__);
|
||||||
}
|
}
|
||||||
|
@ -1092,4 +1114,51 @@ string MenuStateConnectedGame::getHumanPlayerName() {
|
||||||
return result;
|
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
|
}}//end namespace
|
||||||
|
|
|
@ -109,8 +109,12 @@ private:
|
||||||
int8 switchSetupRequestFlagType;
|
int8 switchSetupRequestFlagType;
|
||||||
string defaultPlayerName;
|
string defaultPlayerName;
|
||||||
|
|
||||||
|
string currentFactionLogo;
|
||||||
|
Texture2D *factionTexture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
||||||
|
~MenuStateConnectedGame();
|
||||||
|
|
||||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
|
@ -131,6 +135,10 @@ private:
|
||||||
void returnToJoinMenu();
|
void returnToJoinMenu();
|
||||||
string getHumanPlayerName();
|
string getHumanPlayerName();
|
||||||
void setActiveInputLabel(GraphicLabel *newLable);
|
void setActiveInputLabel(GraphicLabel *newLable);
|
||||||
|
|
||||||
|
void cleanupFactionTexture();
|
||||||
|
void loadFactionTexture(string filepath);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -53,6 +53,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
activeInputLabel=NULL;
|
activeInputLabel=NULL;
|
||||||
showGeneralError = false;
|
showGeneralError = false;
|
||||||
generalErrorToShow = "---";
|
generalErrorToShow = "---";
|
||||||
|
currentFactionLogo = "";
|
||||||
|
factionTexture=NULL;
|
||||||
|
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
@ -231,9 +233,9 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
|
|
||||||
|
|
||||||
// Advanced Options
|
// Advanced Options
|
||||||
labelAdvanced.init(790, 80, 80);
|
labelAdvanced.init(xoffset+650, 150, 80);
|
||||||
labelAdvanced.setText(lang.get("AdvancedGameOptions"));
|
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("Yes"));
|
||||||
listBoxAdvanced.pushBackItem(lang.get("No"));
|
listBoxAdvanced.pushBackItem(lang.get("No"));
|
||||||
listBoxAdvanced.setSelectedItemIndex(0);
|
listBoxAdvanced.setSelectedItemIndex(0);
|
||||||
|
@ -296,16 +298,16 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
listBoxEnableServerControlledAI.setSelectedItemIndex(0);
|
||||||
|
|
||||||
//list boxes
|
//list boxes
|
||||||
xoffset=120;
|
xoffset=60;
|
||||||
int rowHeight=27;
|
int rowHeight=27;
|
||||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||||
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
|
labelPlayers[i].init(xoffset+50, setupPos-30-i*rowHeight);
|
||||||
labelPlayerNames[i].init(xoffset+100,setupPos-30-i*rowHeight);
|
labelPlayerNames[i].init(xoffset+100,setupPos-30-i*rowHeight);
|
||||||
|
|
||||||
listBoxControls[i].init(xoffset+200, setupPos-30-i*rowHeight);
|
listBoxControls[i].init(xoffset+175, setupPos-30-i*rowHeight);
|
||||||
listBoxFactions[i].init(xoffset+350, setupPos-30-i*rowHeight, 150);
|
listBoxFactions[i].init(xoffset+320, setupPos-30-i*rowHeight, 150);
|
||||||
listBoxTeams[i].init(xoffset+520, setupPos-30-i*rowHeight, 60);
|
listBoxTeams[i].init(xoffset+495, setupPos-30-i*rowHeight, 60);
|
||||||
labelNetStatus[i].init(xoffset+600, 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);
|
labelControl.init(xoffset+200, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||||
|
@ -425,6 +427,10 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
|
cleanupFactionTexture();
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::returnToParentMenu(){
|
void MenuStateCustomGame::returnToParentMenu(){
|
||||||
|
@ -507,9 +513,35 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
// Send the game settings to each client if we have at least one networked client
|
// Send the game settings to each client if we have at least one networked client
|
||||||
safeMutex.Lock();
|
safeMutex.Lock();
|
||||||
|
|
||||||
|
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__);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if( hasNetworkGameSettings() == true &&
|
if( hasNetworkGameSettings() == true &&
|
||||||
needToSetChangedGameSettings == true)
|
needToSetChangedGameSettings == true) {
|
||||||
{
|
|
||||||
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__);
|
||||||
serverInterface->setGameSettings(&gameSettings,true);
|
serverInterface->setGameSettings(&gameSettings,true);
|
||||||
|
|
||||||
|
@ -520,6 +552,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
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__);
|
||||||
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
||||||
if(bOkToStart == true) {
|
if(bOkToStart == true) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if( listBoxPublishServer.getEditable() &&
|
if( listBoxPublishServer.getEditable() &&
|
||||||
listBoxPublishServer.getSelectedItemIndex() == 0) {
|
listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
|
|
||||||
|
@ -543,10 +577,12 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
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__);
|
||||||
program->setState(new Game(program, &gameSettings));
|
program->setState(new Game(program, &gameSettings));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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__);
|
||||||
}
|
}
|
||||||
|
@ -828,6 +864,10 @@ void MenuStateCustomGame::render(){
|
||||||
try {
|
try {
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
|
||||||
|
if(factionTexture != NULL) {
|
||||||
|
renderer.renderTextureQuad(60+575+40,365,200,225,factionTexture,1);
|
||||||
|
}
|
||||||
|
|
||||||
if(mainMessageBox.getEnabled()){
|
if(mainMessageBox.getEnabled()){
|
||||||
renderer.renderMessageBox(&mainMessageBox);
|
renderer.renderMessageBox(&mainMessageBox);
|
||||||
}
|
}
|
||||||
|
@ -1057,7 +1097,9 @@ void MenuStateCustomGame::update() {
|
||||||
currentConnectionCount++;
|
currentConnectionCount++;
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] B - ctNetwork\n",__FILE__,__FUNCTION__);
|
//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 &&
|
if(connectionSlot != NULL &&
|
||||||
connectionSlot->getAllowDownloadDataSynch() == true &&
|
connectionSlot->getAllowDownloadDataSynch() == true &&
|
||||||
connectionSlot->getAllowGameDataSynchCheck() == true)
|
connectionSlot->getAllowGameDataSynchCheck() == true)
|
||||||
|
@ -1184,11 +1226,11 @@ void MenuStateCustomGame::update() {
|
||||||
needToSetChangedGameSettings == true &&
|
needToSetChangedGameSettings == true &&
|
||||||
difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
||||||
|
|
||||||
// Send the game settings to each client if we have at least one networked client
|
|
||||||
if(checkDataSynch == true)
|
|
||||||
{
|
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
|
|
||||||
|
// Send the game settings to each client if we have at least one networked client
|
||||||
|
if(checkDataSynch == true) {
|
||||||
serverInterface->setGameSettings(&gameSettings,false);
|
serverInterface->setGameSettings(&gameSettings,false);
|
||||||
needToSetChangedGameSettings = false;
|
needToSetChangedGameSettings = false;
|
||||||
}
|
}
|
||||||
|
@ -1251,6 +1293,12 @@ void MenuStateCustomGame::update() {
|
||||||
}
|
}
|
||||||
soundConnectionCount = currentConnectionCount;
|
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__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
catch(const std::exception &ex) {
|
catch(const std::exception &ex) {
|
||||||
|
@ -2066,4 +2114,51 @@ string MenuStateCustomGame::getHumanPlayerName(int index) {
|
||||||
return result;
|
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
|
}}//end namespace
|
||||||
|
|
|
@ -118,6 +118,9 @@ private:
|
||||||
string defaultPlayerName;
|
string defaultPlayerName;
|
||||||
int8 switchSetupRequestFlagType;
|
int8 switchSetupRequestFlagType;
|
||||||
|
|
||||||
|
string currentFactionLogo;
|
||||||
|
Texture2D *factionTexture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false);
|
MenuStateCustomGame(Program *program, MainMenu *mainMenu ,bool openNetworkSlots= false, bool parentMenuIsMasterserver=false);
|
||||||
~MenuStateCustomGame();
|
~MenuStateCustomGame();
|
||||||
|
@ -154,6 +157,9 @@ private:
|
||||||
GameSettings loadGameSettingsFromFile(std::string fileName);
|
GameSettings loadGameSettingsFromFile(std::string fileName);
|
||||||
void setActiveInputLabel(GraphicLabel *newLable);
|
void setActiveInputLabel(GraphicLabel *newLable);
|
||||||
string getHumanPlayerName(int index=-1);
|
string getHumanPlayerName(int index=-1);
|
||||||
|
|
||||||
|
void cleanupFactionTexture();
|
||||||
|
void loadFactionTexture(string filepath);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
Loading…
Reference in New Issue
Block a user