- added code to rename duplicate maps and show a warning at game start
This commit is contained in:
parent
25da3ea34a
commit
b8075eaf01
|
@ -67,6 +67,9 @@ Intro::Intro(Program *program):
|
||||||
int w= metrics.getVirtualW();
|
int w= metrics.getVirtualW();
|
||||||
int h= metrics.getVirtualH();
|
int h= metrics.getVirtualH();
|
||||||
timer=0;
|
timer=0;
|
||||||
|
mouseX = 0;
|
||||||
|
mouseY = 0;
|
||||||
|
mouse2d = 0;
|
||||||
|
|
||||||
texts.push_back(Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), 4000));
|
texts.push_back(Text(coreData.getLogoTexture(), Vec2i(w/2-128, h/2-64), Vec2i(256, 128), 4000));
|
||||||
texts.push_back(Text(glestVersionString, Vec2i(w/2+45, h/2-45), 4000, coreData.getMenuFontNormal()));
|
texts.push_back(Text(glestVersionString, Vec2i(w/2+45, h/2-45), 4000, coreData.getMenuFontNormal()));
|
||||||
|
@ -97,6 +100,8 @@ void Intro::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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouse2d= (mouse2d+1) % Renderer::maxMouse2dAnim;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Intro::render(){
|
void Intro::render(){
|
||||||
|
@ -136,6 +141,8 @@ void Intro::render(){
|
||||||
|
|
||||||
if(program != NULL) program->renderProgramMsgBox();
|
if(program != NULL) program->renderProgramMsgBox();
|
||||||
|
|
||||||
|
if(this->forceMouseRender == true) renderer.renderMouse2d(mouseX, mouseY, mouse2d, 0.f);
|
||||||
|
|
||||||
renderer.swapBuffers();
|
renderer.swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,4 +167,9 @@ void Intro::mouseUpLeft(int x, int y){
|
||||||
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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Intro::mouseMove(int x, int y, const MouseState *ms) {
|
||||||
|
mouseX = x;
|
||||||
|
mouseY = y;
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -71,6 +71,9 @@ private:
|
||||||
private:
|
private:
|
||||||
vector<Text> texts;
|
vector<Text> texts;
|
||||||
int timer;
|
int timer;
|
||||||
|
int mouseX;
|
||||||
|
int mouseY;
|
||||||
|
int mouse2d;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Intro(Program *program);
|
Intro(Program *program);
|
||||||
|
@ -78,6 +81,7 @@ public:
|
||||||
virtual void render();
|
virtual void render();
|
||||||
virtual void keyDown(char key);
|
virtual void keyDown(char key);
|
||||||
virtual void mouseUpLeft(int x, int y);
|
virtual void mouseUpLeft(int x, int y);
|
||||||
|
void mouseMove(int x, int y, const MouseState *ms);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -1314,6 +1314,7 @@ void CheckForDuplicateData() {
|
||||||
throw runtime_error("No maps were found!");
|
throw runtime_error("No maps were found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<string> duplicateMapsToRename;
|
||||||
for(int i = 0; i < maps.size(); ++i) {
|
for(int i = 0; i < maps.size(); ++i) {
|
||||||
string map1 = maps[i];
|
string map1 = maps[i];
|
||||||
for(int j = 0; j < maps.size(); ++j) {
|
for(int j = 0; j < maps.size(); ++j) {
|
||||||
|
@ -1323,12 +1324,40 @@ void CheckForDuplicateData() {
|
||||||
//printf("i = %d map1 [%s] j = %d map2 [%s]\n",i,map1.c_str(),j,map2.c_str());
|
//printf("i = %d map1 [%s] j = %d map2 [%s]\n",i,map1.c_str(),j,map2.c_str());
|
||||||
|
|
||||||
if(map1 == map2) {
|
if(map1 == map2) {
|
||||||
|
if(std::find(duplicateMapsToRename.begin(),duplicateMapsToRename.end(),map1) == duplicateMapsToRename.end()) {
|
||||||
|
duplicateMapsToRename.push_back(map1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(duplicateMapsToRename.size() > 0) {
|
||||||
|
string errorMsg = "Warning duplicate maps were detected and renamed:\n";
|
||||||
|
for(int i = 0; i < duplicateMapsToRename.size(); ++i) {
|
||||||
|
string oldFile = mapPaths[1] + "/" + duplicateMapsToRename[i];
|
||||||
|
string newFile = mapPaths[1] + "/" + duplicateMapsToRename[i];
|
||||||
|
string ext = extractExtension(newFile);
|
||||||
|
newFile = newFile.substr( 0, newFile.length()-ext.length()-1);
|
||||||
|
newFile = newFile + "_custom." + ext;
|
||||||
|
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"You have duplicate maps for map [%s] in [%s] and [%s]",map1.c_str(),mapPaths[0].c_str(),mapPaths[1].c_str());
|
int result = rename(oldFile.c_str(),newFile.c_str());
|
||||||
|
if(result != 0) {
|
||||||
|
char *errmsg = strerror(errno);
|
||||||
|
sprintf(szBuf,"Error [%s]\nCould not rename [%s] to [%s]!",errmsg,oldFile.c_str(),newFile.c_str());
|
||||||
throw runtime_error(szBuf);
|
throw runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sprintf(szBuf,"map [%s] in [%s]\nwas renamed to [%s]",duplicateMapsToRename[i].c_str(),oldFile.c_str(),newFile.c_str());
|
||||||
}
|
}
|
||||||
|
errorMsg += szBuf;
|
||||||
}
|
}
|
||||||
|
//throw runtime_error(szBuf);
|
||||||
|
Program *program = Program::getInstance();
|
||||||
|
if(program) {
|
||||||
|
program->getState()->setForceMouseRender(true);
|
||||||
|
}
|
||||||
|
ExceptionHandler::DisplayMessage(errorMsg.c_str(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//tilesets
|
//tilesets
|
||||||
|
|
|
@ -49,9 +49,13 @@ protected:
|
||||||
|
|
||||||
int startX;
|
int startX;
|
||||||
int startY;
|
int startY;
|
||||||
|
bool forceMouseRender;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProgramState(Program *program) {this->program= program;}
|
ProgramState(Program *program) {
|
||||||
|
this->program= program;
|
||||||
|
this->forceMouseRender = false;
|
||||||
|
}
|
||||||
virtual ~ProgramState(){};
|
virtual ~ProgramState(){};
|
||||||
|
|
||||||
virtual void render()=0;
|
virtual void render()=0;
|
||||||
|
@ -81,6 +85,7 @@ public:
|
||||||
virtual bool quitTriggered() { return false; }
|
virtual bool quitTriggered() { return false; }
|
||||||
virtual Stats quitAndToggleState() { return Stats(); };
|
virtual Stats quitAndToggleState() { return Stats(); };
|
||||||
virtual Program * getProgram() { return program; }
|
virtual Program * getProgram() { return program; }
|
||||||
|
virtual void setForceMouseRender(bool value) { forceMouseRender=value;}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===============================
|
// ===============================
|
||||||
|
|
Loading…
Reference in New Issue
Block a user