* looks for 'gbm' (1-4 player) maps & 'mgm' (5-8 player) maps
This commit is contained in:
parent
b4ffb67c03
commit
06012e4804
|
@ -44,20 +44,28 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||||
needToSetChangedGameSettings = false;
|
needToSetChangedGameSettings = false;
|
||||||
lastSetChangedGameSettings = time(NULL);;
|
lastSetChangedGameSettings = time(NULL);;
|
||||||
|
|
||||||
vector<string> results, teamItems, controlItems;
|
vector<string> glestMaps, megaMaps, teamItems, controlItems;
|
||||||
|
|
||||||
//create
|
//create
|
||||||
buttonReturn.init(350, 140, 125);
|
buttonReturn.init(350, 140, 125);
|
||||||
buttonPlayNow.init(525, 140, 125);
|
buttonPlayNow.init(525, 140, 125);
|
||||||
|
|
||||||
//map listBox
|
//map listBox
|
||||||
findAll("maps/*.gbm", results, true);
|
findAll("maps/*.gbm", glestMaps, true);
|
||||||
if(results.size()==0){
|
findAll("maps/*.mgm", megaMaps, true);
|
||||||
throw runtime_error("There is no maps");
|
mapFiles.resize(glestMaps.size() + megaMaps.size());
|
||||||
|
if (!glestMaps.empty()) {
|
||||||
|
copy(glestMaps.begin(), glestMaps.end(), mapFiles.begin());
|
||||||
}
|
}
|
||||||
mapFiles= results;
|
if (!megaMaps.empty()) {
|
||||||
for(int i= 0; i<results.size(); ++i){
|
copy(megaMaps.begin(), megaMaps.end(), mapFiles.begin() + glestMaps.size());
|
||||||
results[i]= formatString(results[i]);
|
}
|
||||||
|
if(mapFiles.size()==0){
|
||||||
|
throw runtime_error("There are no maps");
|
||||||
|
}
|
||||||
|
vector<string> results;
|
||||||
|
for(int i= 0; i < mapFiles.size(); ++i){
|
||||||
|
results.push_back(formatString(mapFiles[i]));
|
||||||
}
|
}
|
||||||
listBoxMap.init(200, 260, 150);
|
listBoxMap.init(200, 260, 150);
|
||||||
listBoxMap.setItems(results);
|
listBoxMap.setItems(results);
|
||||||
|
@ -205,6 +213,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxMap.mouseClick(x, y)){
|
else if(listBoxMap.mouseClick(x, y)){
|
||||||
|
printf("%s\n", mapFiles[listBoxMap.getSelectedItemIndex()].c_str());
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo);
|
loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo);
|
||||||
labelMapInfo.setText(mapInfo.desc);
|
labelMapInfo.setText(mapInfo.desc);
|
||||||
updateControlers();
|
updateControlers();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "tech_tree.h"
|
#include "tech_tree.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
using namespace Shared::Util;
|
using namespace Shared::Util;
|
||||||
|
@ -612,6 +613,19 @@ void Map::computeCellColors(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
string Map::getMapPath(const string &mapName) {
|
||||||
|
string mega = "maps/" + mapName + ".mgm";
|
||||||
|
string glest = "maps/" + mapName + ".gbm";
|
||||||
|
if (fileExists(mega)) {
|
||||||
|
return mega;
|
||||||
|
} else if (fileExists(glest)) {
|
||||||
|
return glest;
|
||||||
|
} else {
|
||||||
|
throw runtime_error("Map " + mapName + " not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class PosCircularIterator
|
// class PosCircularIterator
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
|
@ -223,7 +223,7 @@ public:
|
||||||
//static
|
//static
|
||||||
static Vec2i toSurfCoords(Vec2i unitPos) {return unitPos/cellScale;}
|
static Vec2i toSurfCoords(Vec2i unitPos) {return unitPos/cellScale;}
|
||||||
static Vec2i toUnitCoords(Vec2i surfPos) {return surfPos*cellScale;}
|
static Vec2i toUnitCoords(Vec2i surfPos) {return surfPos*cellScale;}
|
||||||
static string getMapPath(const string &mapName) {return "maps/"+mapName+".gbm";}
|
static string getMapPath(const string &mapName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//compute
|
//compute
|
||||||
|
|
Loading…
Reference in New Issue
Block a user