mapFilter
This commit is contained in:
parent
f16bb3f28b
commit
13173788da
|
@ -40,6 +40,7 @@ private:
|
||||||
int factionCount;
|
int factionCount;
|
||||||
int teams[GameConstants::maxPlayers];
|
int teams[GameConstants::maxPlayers];
|
||||||
int startLocationIndex[GameConstants::maxPlayers];
|
int startLocationIndex[GameConstants::maxPlayers];
|
||||||
|
int mapFilterIndex;
|
||||||
|
|
||||||
|
|
||||||
bool defaultUnits;
|
bool defaultUnits;
|
||||||
|
@ -101,6 +102,7 @@ public:
|
||||||
int getFactionCount() const {return factionCount;}
|
int getFactionCount() const {return factionCount;}
|
||||||
int getTeam(int factionIndex) const {return teams[factionIndex];}
|
int getTeam(int factionIndex) const {return teams[factionIndex];}
|
||||||
int getStartLocationIndex(int factionIndex) const {return startLocationIndex[factionIndex];}
|
int getStartLocationIndex(int factionIndex) const {return startLocationIndex[factionIndex];}
|
||||||
|
int getMapFilterIndex() const {return mapFilterIndex;}
|
||||||
|
|
||||||
bool getDefaultUnits() const {return defaultUnits;}
|
bool getDefaultUnits() const {return defaultUnits;}
|
||||||
bool getDefaultResources() const {return defaultResources;}
|
bool getDefaultResources() const {return defaultResources;}
|
||||||
|
@ -128,6 +130,7 @@ public:
|
||||||
void setFactionCount(int factionCount) {this->factionCount= factionCount;}
|
void setFactionCount(int factionCount) {this->factionCount= factionCount;}
|
||||||
void setTeam(int factionIndex, int team) {this->teams[factionIndex]= team;}
|
void setTeam(int factionIndex, int team) {this->teams[factionIndex]= team;}
|
||||||
void setStartLocationIndex(int factionIndex, int startLocationIndex) {this->startLocationIndex[factionIndex]= startLocationIndex;}
|
void setStartLocationIndex(int factionIndex, int startLocationIndex) {this->startLocationIndex[factionIndex]= startLocationIndex;}
|
||||||
|
void setMapFilterIndex(int mapFilterIndex) {this->mapFilterIndex=mapFilterIndex;}
|
||||||
|
|
||||||
void setDefaultUnits(bool defaultUnits) {this->defaultUnits= defaultUnits;}
|
void setDefaultUnits(bool defaultUnits) {this->defaultUnits= defaultUnits;}
|
||||||
void setDefaultResources(bool defaultResources) {this->defaultResources= defaultResources;}
|
void setDefaultResources(bool defaultResources) {this->defaultResources= defaultResources;}
|
||||||
|
@ -144,6 +147,7 @@ public:
|
||||||
string result = "";
|
string result = "";
|
||||||
|
|
||||||
result += "description = " + description + "\n";
|
result += "description = " + description + "\n";
|
||||||
|
result += "mapFilterIndex = " + intToStr(mapFilterIndex) + "\n";
|
||||||
result += "map = " + map + "\n";
|
result += "map = " + map + "\n";
|
||||||
result += "tileset = " + tileset + "\n";
|
result += "tileset = " + tileset + "\n";
|
||||||
result += "tech = " + tech + "\n";
|
result += "tech = " + tech + "\n";
|
||||||
|
|
|
@ -132,7 +132,17 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
}
|
}
|
||||||
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
|
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
|
||||||
mapFiles = results;
|
mapFiles = results;
|
||||||
std::for_each(results.begin(), results.end(), FormatString());
|
|
||||||
|
copy(mapFiles.begin(), mapFiles.end(), std::back_inserter(playerSortedMaps[0]));
|
||||||
|
copy(playerSortedMaps[0].begin(), playerSortedMaps[0].end(), std::back_inserter(formattedPlayerSortedMaps[0]));
|
||||||
|
std::for_each(formattedPlayerSortedMaps[0].begin(), formattedPlayerSortedMaps[0].end(), FormatString());
|
||||||
|
|
||||||
|
for ( int i = 0 ; i<mapFiles.size(); i++ )
|
||||||
|
{// fetch info and put map in right list
|
||||||
|
loadMapInfo(Map::getMapPath(mapFiles.at(i)), &mapInfo);
|
||||||
|
playerSortedMaps[mapInfo.players].push_back(mapFiles.at(i));
|
||||||
|
formattedPlayerSortedMaps[mapInfo.players].push_back(formatString(mapFiles.at(i)));
|
||||||
|
}
|
||||||
|
|
||||||
labelLocalIP.init(410, networkHeadPos+30);
|
labelLocalIP.init(410, networkHeadPos+30);
|
||||||
|
|
||||||
|
@ -155,7 +165,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
labelMap.init(xoffset+100, mapHeadPos);
|
labelMap.init(xoffset+100, mapHeadPos);
|
||||||
labelMap.setText(lang.get("Map")+":");
|
labelMap.setText(lang.get("Map")+":");
|
||||||
listBoxMap.init(xoffset+100, mapPos, 200);
|
listBoxMap.init(xoffset+100, mapPos, 200);
|
||||||
listBoxMap.setItems(results);
|
listBoxMap.setItems(formattedPlayerSortedMaps[0]);
|
||||||
labelMapInfo.init(xoffset+100, mapPos-30, 200, 40);
|
labelMapInfo.init(xoffset+100, mapPos-30, 200, 40);
|
||||||
|
|
||||||
// MapFilter
|
// MapFilter
|
||||||
|
@ -163,15 +173,10 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
labelMapFilter.setText(lang.get("MapFilter")+":");
|
labelMapFilter.setText(lang.get("MapFilter")+":");
|
||||||
listBoxMapFilter.init(xoffset+310, mapPos, 80);
|
listBoxMapFilter.init(xoffset+310, mapPos, 80);
|
||||||
listBoxMapFilter.pushBackItem(lang.get("all"));
|
listBoxMapFilter.pushBackItem(lang.get("all"));
|
||||||
listBoxMapFilter.pushBackItem("1");
|
for(int i=1; i<GameConstants::maxPlayers+1; ++i){
|
||||||
listBoxMapFilter.pushBackItem("2");
|
listBoxMapFilter.pushBackItem(intToStr(i));
|
||||||
listBoxMapFilter.pushBackItem("3");
|
}
|
||||||
listBoxMapFilter.pushBackItem("4");
|
listBoxMapFilter.setSelectedItemIndex(0);
|
||||||
listBoxMapFilter.pushBackItem("5");
|
|
||||||
listBoxMapFilter.pushBackItem("6");
|
|
||||||
listBoxMapFilter.pushBackItem("7");
|
|
||||||
listBoxMapFilter.pushBackItem("8");
|
|
||||||
listBoxMapFilter.setSelectedItemIndex(4);
|
|
||||||
|
|
||||||
//tileset listBox
|
//tileset listBox
|
||||||
findDirs(config.getPathListForType(ptTilesets), results);
|
findDirs(config.getPathListForType(ptTilesets), results);
|
||||||
|
@ -366,7 +371,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
labelEnableObserverMode.setText(lang.get("EnableObserverMode"));
|
labelEnableObserverMode.setText(lang.get("EnableObserverMode"));
|
||||||
|
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo);
|
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo);
|
||||||
|
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
|
|
||||||
|
@ -451,6 +456,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
CoreData &coreData= CoreData::getInstance();
|
CoreData &coreData= CoreData::getInstance();
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
|
int oldListBoxMapfilterIndex=listBoxMapFilter.getSelectedItemIndex();
|
||||||
|
|
||||||
if(mainMessageBox.getEnabled()){
|
if(mainMessageBox.getEnabled()){
|
||||||
int button= 1;
|
int button= 1;
|
||||||
|
@ -566,11 +572,11 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxMap.mouseClick(x, y)){
|
else if(listBoxMap.mouseClick(x, y)){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", mapFiles[listBoxMap.getSelectedItemIndex()].c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", getCurrentMapFile().c_str());
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo);
|
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo);
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
updateControlers();
|
updateControlers();
|
||||||
updateNetworkSlots();
|
updateNetworkSlots();
|
||||||
|
@ -638,6 +644,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
else if(listBoxMapFilter.mouseClick(x, y)){
|
else if(listBoxMapFilter.mouseClick(x, y)){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
|
switchToNextMapGroup(listBoxMapFilter.getSelectedItemIndex()-oldListBoxMapfilterIndex);
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
|
|
||||||
if(hasNetworkGameSettings() == true)
|
if(hasNetworkGameSettings() == true)
|
||||||
|
@ -1422,8 +1429,9 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
gameSettings->setDescription(formatString(mapFiles[listBoxMap.getSelectedItemIndex()]));
|
gameSettings->setMapFilterIndex(listBoxMapFilter.getSelectedItemIndex());
|
||||||
gameSettings->setMap(mapFiles[listBoxMap.getSelectedItemIndex()]);
|
gameSettings->setDescription(formatString(getCurrentMapFile()));
|
||||||
|
gameSettings->setMap(getCurrentMapFile());
|
||||||
gameSettings->setTileset(tilesetFiles[listBoxTileset.getSelectedItemIndex()]);
|
gameSettings->setTileset(tilesetFiles[listBoxTileset.getSelectedItemIndex()]);
|
||||||
gameSettings->setTech(techTreeFiles[listBoxTechTree.getSelectedItemIndex()]);
|
gameSettings->setTech(techTreeFiles[listBoxTechTree.getSelectedItemIndex()]);
|
||||||
gameSettings->setDefaultUnits(true);
|
gameSettings->setDefaultUnits(true);
|
||||||
|
@ -1530,7 +1538,8 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
||||||
//ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
//ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
|
||||||
saveGameFile << "Description=" << gameSettings.getDescription() << std::endl;
|
saveGameFile << "Description=" << gameSettings.getDescription() << std::endl;
|
||||||
|
|
||||||
|
saveGameFile << "MapFilterIndex=" << gameSettings.getMapFilterIndex() << std::endl;
|
||||||
saveGameFile << "Map=" << gameSettings.getMap() << std::endl;
|
saveGameFile << "Map=" << gameSettings.getMap() << std::endl;
|
||||||
saveGameFile << "Tileset=" << gameSettings.getTileset() << std::endl;
|
saveGameFile << "Tileset=" << gameSettings.getTileset() << std::endl;
|
||||||
saveGameFile << "TechTree=" << gameSettings.getTech() << std::endl;
|
saveGameFile << "TechTree=" << gameSettings.getTech() << std::endl;
|
||||||
|
@ -1583,6 +1592,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
||||||
properties.load(fileName);
|
properties.load(fileName);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
|
||||||
|
|
||||||
|
gameSettings.setMapFilterIndex(properties.getInt("MapFilterIndex"));
|
||||||
gameSettings.setDescription(properties.getString("Description"));
|
gameSettings.setDescription(properties.getString("Description"));
|
||||||
gameSettings.setMap(properties.getString("Map"));
|
gameSettings.setMap(properties.getString("Map"));
|
||||||
gameSettings.setTileset(properties.getString("Tileset"));
|
gameSettings.setTileset(properties.getString("Tileset"));
|
||||||
|
@ -1611,11 +1621,14 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
|
listBoxMapFilter.setSelectedItemIndex(gameSettings.getMapFilterIndex());
|
||||||
|
listBoxMap.setItems(formattedPlayerSortedMaps[gameSettings.getMapFilterIndex()]);
|
||||||
|
|
||||||
string mapFile = gameSettings.getMap();
|
string mapFile = gameSettings.getMap();
|
||||||
mapFile = formatString(mapFile);
|
mapFile = formatString(mapFile);
|
||||||
listBoxMap.setSelectedItem(mapFile);
|
listBoxMap.setSelectedItem(mapFile);
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo);
|
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo);
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
|
|
||||||
string tilesetFile = gameSettings.getTileset();
|
string tilesetFile = gameSettings.getTileset();
|
||||||
|
@ -1970,6 +1983,28 @@ void MenuStateCustomGame::showMessageBox(const string &text, const string &heade
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuStateCustomGame::switchToNextMapGroup(const int direction){
|
||||||
|
int i=listBoxMapFilter.getSelectedItemIndex();
|
||||||
|
// if there are no maps for the current selection we switch to next selection
|
||||||
|
while(formattedPlayerSortedMaps[i].empty()){
|
||||||
|
i=i+direction;
|
||||||
|
if(i>GameConstants::maxPlayers){
|
||||||
|
i=0;
|
||||||
|
}
|
||||||
|
if(i<0){
|
||||||
|
i=GameConstants::maxPlayers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
listBoxMapFilter.setSelectedItemIndex(i);
|
||||||
|
listBoxMap.setItems(formattedPlayerSortedMaps[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
string MenuStateCustomGame::getCurrentMapFile(){
|
||||||
|
int i=listBoxMapFilter.getSelectedItemIndex();
|
||||||
|
int mapIndex=listBoxMap.getSelectedItemIndex();
|
||||||
|
return playerSortedMaps[i].at(mapIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
void MenuStateCustomGame::setActiveInputLabel(GraphicLabel *newLable) {
|
||||||
if(newLable!=NULL) {
|
if(newLable!=NULL) {
|
||||||
string text= newLable->getText();
|
string text= newLable->getText();
|
||||||
|
|
|
@ -47,6 +47,8 @@ private:
|
||||||
GraphicListBox listBoxEnableServerControlledAI;
|
GraphicListBox listBoxEnableServerControlledAI;
|
||||||
|
|
||||||
vector<string> mapFiles;
|
vector<string> mapFiles;
|
||||||
|
vector<string> playerSortedMaps[GameConstants::maxPlayers+1];
|
||||||
|
vector<string> formattedPlayerSortedMaps[GameConstants::maxPlayers+1];
|
||||||
vector<string> techTreeFiles;
|
vector<string> techTreeFiles;
|
||||||
vector<string> tilesetFiles;
|
vector<string> tilesetFiles;
|
||||||
vector<string> factionFiles;
|
vector<string> factionFiles;
|
||||||
|
@ -147,6 +149,8 @@ private:
|
||||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||||
|
|
||||||
void saveGameSettingsToFile(std::string fileName);
|
void saveGameSettingsToFile(std::string fileName);
|
||||||
|
void switchToNextMapGroup(const int direction);
|
||||||
|
string getCurrentMapFile();
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user