diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index f34da994..5b88da41 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -50,7 +50,7 @@ wxString ToUnicode(const string& str) { // =============================================== const string g3dviewerVersionString= "v1.3.6"; -const string MainWindow::winHeader= "G3D viewer " + g3dviewerVersionString + " - Built: " + __DATE__; +const string MainWindow::winHeader= "G3D viewer " + g3dviewerVersionString; MainWindow::MainWindow(const string &modelPath) : wxFrame(NULL, -1, ToUnicode(winHeader),wxPoint(Renderer::windowX, Renderer::windowY), @@ -66,7 +66,8 @@ MainWindow::MainWindow(const string &modelPath) speed= 0.025f; - glCanvas = new GlCanvas(this); + int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER }; // to prevent flicker + glCanvas = new GlCanvas(this, args); //getGlPlatformExtensions(); @@ -110,7 +111,7 @@ MainWindow::MainWindow(const string &modelPath) menuCustomColor->AppendCheckItem(miColorWhite, wxT("&White\t4")); menuCustomColor->AppendCheckItem(miColorCyan, wxT("&Cyan\t5")); menuCustomColor->AppendCheckItem(miColorOrange, wxT("&Orange\t6")); - menuCustomColor->AppendCheckItem(miColorMagenta, wxT("&Magenta\t7")); + menuCustomColor->AppendCheckItem(miColorMagenta, wxT("&Pink\t7")); // it is called Pink everywhere else so... menu->Append(menuCustomColor, wxT("&Custom Color")); menuMode->Check(miModeGrid, true); @@ -123,19 +124,19 @@ MainWindow::MainWindow(const string &modelPath) rotX= 0.0f; rotY= 0.0f; zoom= 1.0f; + backBrightness= 0.3f; + gridBrightness= 1.0f; + lightBrightness= 0.3f; lastX= 0; lastY= 0; anim= 0.0f; CreateStatusBar(); - //std::cout << "A" << std::endl; wxInitAllImageHandlers(); #ifdef WIN32 - //std::cout << "B" << std::endl; wxIcon icon("IDI_ICON1"); #else - //std::cout << "B" << std::endl; wxIcon icon; std::ifstream testFile("g3dviewer.ico"); if(testFile.good()) { @@ -143,7 +144,6 @@ MainWindow::MainWindow(const string &modelPath) icon.LoadFile(wxT("g3dviewer.ico"),wxBITMAP_TYPE_ICO); } #endif - //std::cout << "C" << std::endl; SetIcon(icon); timer = new wxTimer(this); @@ -165,8 +165,6 @@ void MainWindow::init(){ renderer->init(); loadModel(""); - - //SetTitle(ToUnicode(winHeader + "; " + modelPath)); } void MainWindow::onPaint(wxPaintEvent &event){ @@ -201,7 +199,7 @@ void MainWindow::onClose(wxCloseEvent &event){ unitParticleSystems.clear(); unitParticleSystemTypes.clear(); - + projectileParticleSystems.clear(); projectileParticleSystemTypes.clear(); splashParticleSystems.clear(); // as above @@ -213,7 +211,7 @@ void MainWindow::onClose(wxCloseEvent &event){ delete this; } -// for the mouseweel +// for the mousewheel void MainWindow::onMouseWheelDown(wxMouseEvent &event) { wxPaintEvent paintEvent; zoom*= 1.1f; @@ -260,6 +258,7 @@ void MainWindow::onMenuFileLoad(wxCommandEvent &event){ modelPathList.clear(); loadModel((const char*)wxFNCONV(fileDialog.GetPath().c_str())); } + isControlKeyPressed = false; } void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){ @@ -278,6 +277,7 @@ void MainWindow::onMenuFileLoadParticleXML(wxCommandEvent &event){ string path = (const char*)wxFNCONV(fileDialog.GetPath().c_str()); loadParticle(path); } + isControlKeyPressed = false; } void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){ @@ -296,6 +296,7 @@ void MainWindow::onMenuFileLoadProjectileParticleXML(wxCommandEvent &event){ string path = (const char*)wxFNCONV(fileDialog.GetPath().c_str()); loadProjectileParticle(path); } + isControlKeyPressed = false; } void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){ @@ -314,7 +315,8 @@ void MainWindow::onMenuFileLoadSplashParticleXML(wxCommandEvent &event){ string path = (const char*)wxFNCONV(fileDialog.GetPath().c_str()); loadSplashParticle(path); } -} // is it possible to join loadParticle(), loadProjectileParticle() and loadSplashParticle() to one method? + isControlKeyPressed = false; +} // is it possible to join loadParticle(), loadProjectileParticle() and loadSplashParticle() to one method? void MainWindow::onMenuFileClearAll(wxCommandEvent &event){ @@ -328,7 +330,7 @@ void MainWindow::onMenuFileClearAll(wxCommandEvent &event){ unitParticleSystems.clear(); unitParticleSystemTypes.clear(); - + projectileParticleSystems.clear(); projectileParticleSystemTypes.clear(); splashParticleSystems.clear(); // as above @@ -344,6 +346,7 @@ void MainWindow::onMenuFileClearAll(wxCommandEvent &event){ GetStatusBar()->SetStatusText(ToUnicode("")); timer->Start(100); + isControlKeyPressed = false; } void MainWindow::onMenuFileExit(wxCommandEvent &event) { @@ -355,6 +358,7 @@ void MainWindow::loadModel(string path) { this->modelPathList.push_back(path); } + string titlestring=winHeader; for(unsigned int idx =0; idx < this->modelPathList.size(); idx++) { string modelPath = this->modelPathList[idx]; @@ -365,7 +369,9 @@ void MainWindow::loadModel(string path) { model= tmpModel; GetStatusBar()->SetStatusText(ToUnicode(getModelInfo().c_str())); timer->Start(100); + titlestring = extractFileFromDirectoryPath(modelPath) + " - "+ titlestring; } + SetTitle(ToUnicode(titlestring)); } void MainWindow::loadParticle(string path) { @@ -376,11 +382,11 @@ void MainWindow::loadParticle(string path) { unitParticleSystemTypes.clear(); if(isControlKeyPressed == true) { - std::cout << "Adding to list..." << std::endl; + // std::cout << "Adding to list..." << std::endl; this->particlePathList.push_back(path); } else { - std::cout << "Clearing list..." << std::endl; + // std::cout << "Clearing list..." << std::endl; this->particlePathList.clear(); this->particlePathList.push_back(path); } @@ -388,6 +394,7 @@ void MainWindow::loadParticle(string path) { try{ if(this->particlePathList.size() > 0) { + string titlestring=winHeader; for(unsigned int idx = 0; idx < this->particlePathList.size(); idx++) { string particlePath = this->particlePathList[idx]; string dir= extractDirectoryPathFromFile(particlePath); @@ -398,6 +405,7 @@ void MainWindow::loadParticle(string path) { } particlePath= extractFileFromDirectoryPath(particlePath); + titlestring = particlePath + " - "+ titlestring; std::string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath(dir) + ".xml"; @@ -415,7 +423,7 @@ void MainWindow::loadParticle(string path) { height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); } - std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; + // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; UnitParticleSystemType *unitParticleSystemType= new UnitParticleSystemType(); unitParticleSystemType->load(dir, dir + folderDelimiter + particlePath, renderer); @@ -442,9 +450,10 @@ void MainWindow::loadParticle(string path) { renderer->initTextureManager(); } } + SetTitle(ToUnicode(titlestring)); } } - catch(std::runtime_error e) { + catch(std::runtime_error e) { std::cout << e.what() << std::endl; wxMessageBox( ToUnicode(e.what()), wxT("Not a Mega-Glest particle XML file, or broken"), wxICON_ERROR); } @@ -459,11 +468,11 @@ void MainWindow::loadProjectileParticle(string path) { projectileParticleSystemTypes.clear(); if(isControlKeyPressed == true) { - std::cout << "Adding to list..." << std::endl; + // std::cout << "Adding to list..." << std::endl; this->particleProjectilePathList.push_back(path); } else { - std::cout << "Clearing list..." << std::endl; + // std::cout << "Clearing list..." << std::endl; this->particleProjectilePathList.clear(); this->particleProjectilePathList.push_back(path); } @@ -471,7 +480,7 @@ void MainWindow::loadProjectileParticle(string path) { try { if(this->particleProjectilePathList.size() > 0) { - + string titlestring=winHeader; for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) { string particlePath = this->particleProjectilePathList[idx]; string dir= extractDirectoryPathFromFile(particlePath); @@ -482,6 +491,7 @@ void MainWindow::loadProjectileParticle(string path) { } particlePath= extractFileFromDirectoryPath(particlePath); + titlestring = particlePath + " - "+ titlestring; std::string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath(dir) + ".xml"; @@ -499,18 +509,18 @@ void MainWindow::loadProjectileParticle(string path) { height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); } - std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; + // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; XmlTree xmlTree; xmlTree.load(dir + folderDelimiter + particlePath); const XmlNode *particleSystemNode= xmlTree.getRootNode(); - std::cout << "Loaded successfully, loading values..." << std::endl; + // std::cout << "Loaded successfully, loading values..." << std::endl; ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile(); projectileParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer); - std::cout << "Values loaded, about to read..." << std::endl; + // std::cout << "Values loaded, about to read..." << std::endl; projectileParticleSystemTypes.push_back(projectileParticleSystemType); @@ -541,6 +551,7 @@ void MainWindow::loadProjectileParticle(string path) { //renderer.manageParticleSystem(psProj, rsGame); } } + SetTitle(ToUnicode(titlestring)); if(path != "" && fileExists(path) == true) { renderer->initModelManager(); @@ -548,7 +559,7 @@ void MainWindow::loadProjectileParticle(string path) { } } } - catch(std::runtime_error e) { + catch(std::runtime_error e) { std::cout << e.what() << std::endl; wxMessageBox( ToUnicode(e.what()), wxT("Not a Mega-Glest projectile particle XML file, or broken"), wxICON_ERROR); } @@ -560,14 +571,14 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp if(path != "" && fileExists(path) == true) { renderer->end(); splashParticleSystems.clear(); - splashParticleSystemTypes.clear(); + splashParticleSystemTypes.clear(); if(isControlKeyPressed == true) { - std::cout << "Adding to list..." << std::endl; + // std::cout << "Adding to list..." << std::endl; this->particleSplashPathList.push_back(path); } else { - std::cout << "Clearing list..." << std::endl; + // std::cout << "Clearing list..." << std::endl; this->particleSplashPathList.clear(); this->particleSplashPathList.push_back(path); } @@ -575,7 +586,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp try { if(this->particleSplashPathList.size() > 0) { - + string titlestring=winHeader; for(unsigned int idx = 0; idx < this->particleSplashPathList.size(); idx++) { string particlePath = this->particleSplashPathList[idx]; string dir= extractDirectoryPathFromFile(particlePath); @@ -586,6 +597,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp } particlePath= extractFileFromDirectoryPath(particlePath); + titlestring = particlePath + " - "+ titlestring; std::string unitXML = dir + folderDelimiter + extractFileFromDirectoryPath(dir) + ".xml"; @@ -603,18 +615,18 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); } - std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; + // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; XmlTree xmlTree; xmlTree.load(dir + folderDelimiter + particlePath); const XmlNode *particleSystemNode= xmlTree.getRootNode(); - std::cout << "Loaded successfully, loading values..." << std::endl; + // std::cout << "Loaded successfully, loading values..." << std::endl; - ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash(); + ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash(); splashParticleSystemType->load(dir, dir + folderDelimiter + particlePath,renderer); // <---- only that must be splash... - std::cout << "Values loaded, about to read..." << std::endl; + // std::cout << "Values loaded, about to read..." << std::endl; splashParticleSystemTypes.push_back(splashParticleSystemType); @@ -638,6 +650,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp renderer->manageParticleSystem(ps); } } + SetTitle(ToUnicode(titlestring)); if(path != "" && fileExists(path) == true) { renderer->initModelManager(); @@ -645,7 +658,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp } } } - catch(std::runtime_error e) { + catch(std::runtime_error e) { std::cout << e.what() << std::endl; wxMessageBox( ToUnicode(e.what()), wxT("Not a Mega-Glest splash particle XML file, or broken"), wxICON_ERROR); } @@ -798,8 +811,9 @@ string MainWindow::getModelInfo(){ void MainWindow::onKeyDown(wxKeyEvent &e) { - std::cout << "e.ControlDown() = " << e.ControlDown() << " e.GetKeyCode() = " << e.GetKeyCode() << " isCtrl = " << (e.GetKeyCode() == WXK_CONTROL) << std::endl; + // std::cout << "e.ControlDown() = " << e.ControlDown() << " e.GetKeyCode() = " << e.GetKeyCode() << " isCtrl = " << (e.GetKeyCode() == WXK_CONTROL) << std::endl; + // Note: This ctrl-key handling is buggy since it never resests when ctrl is released later, so I reset it at end of loadcommands for now. if(e.ControlDown() == true || e.GetKeyCode() == WXK_CONTROL) { isControlKeyPressed = true; } @@ -807,16 +821,48 @@ void MainWindow::onKeyDown(wxKeyEvent &e) { isControlKeyPressed = false; } - std::cout << "isControlKeyPressed = " << isControlKeyPressed << std::endl; + // std::cout << "isControlKeyPressed = " << isControlKeyPressed << std::endl; - // here also becuase + and - hotkeys don't work for numpad automaticly + // here also because + and - hotkeys don't work for numpad automaticly if (e.GetKeyCode() == 388) speed*= 1.5f; //numpad+ else if (e.GetKeyCode() == 390) speed/= 1.5f; //numpad- + else if (e.GetKeyCode() == 87) { + glClearColor(0.6f, 0.6f, 0.6f, 1.0f); //w key //backgroundcolor constant 0.3 -> 0.6 + + } + + // some posibility to adjust brightness: + /* + else if (e.GetKeyCode() == 322) { // Ins - Grid + gridBrightness += 0.1f; if (gridBrightness >1.0) gridBrightness =1.0; + } + else if (e.GetKeyCode() == 127) { // Del + gridBrightness -= 0.1f; if (gridBrightness <0) gridBrightness =0; + } + */ + else if (e.GetKeyCode() == 313) { // Home - Background + backBrightness += 0.1f; if (backBrightness >1.0) backBrightness=1.0; + glClearColor(backBrightness, backBrightness, backBrightness, 1.0f); + } + else if (e.GetKeyCode() == 312) { // End + backBrightness -= 0.1f; if (backBrightness<0) backBrightness=0; + glClearColor(backBrightness, backBrightness, backBrightness, 1.0f); + } + else if (e.GetKeyCode() == 366) { // PgUp - Lightning of model + lightBrightness += 0.1f; if (lightBrightness >1.0) lightBrightness =1.0; + Vec4f ambientNEW= Vec4f(lightBrightness, lightBrightness, lightBrightness, 1.0f); + glLightfv(GL_LIGHT0,GL_AMBIENT, ambientNEW.ptr()); + } + else if (e.GetKeyCode() == 367) { // pgDn + lightBrightness -= 0.1f; if (lightBrightness <0) lightBrightness =0; + Vec4f ambientNEW= Vec4f(lightBrightness, lightBrightness, lightBrightness, 1.0f); + glLightfv(GL_LIGHT0,GL_AMBIENT, ambientNEW.ptr()); + } } void MainWindow::onMenuRestart(wxCommandEvent &event){ - std::cout << "pressed R (restart particle animation)" << std::endl; + // std::cout << "pressed R (restart particle animation)" << std::endl; renderer->end(); unitParticleSystems.clear(); @@ -882,6 +928,12 @@ GlCanvas::GlCanvas(MainWindow * mainWindow): this->mainWindow = mainWindow; } +// to prevent flicker +GlCanvas::GlCanvas(MainWindow * mainWindow, int *args) + : wxGLCanvas(mainWindow, -1, wxDefaultPosition, wxDefaultSize, 0, wxT("GLCanvas"), args) { + this->mainWindow = mainWindow; +} + // for the mousewheel void GlCanvas::onMouseWheel(wxMouseEvent &event) { if(event.GetWheelRotation()>0) mainWindow->onMouseWheelDown(event); @@ -918,10 +970,10 @@ bool App::OnInit(){ std::string modelPath; if(argc==2){ if(argv[1][0]=='-') { // any flag gives help and exits program. - std::cout << "G3D viewer " << g3dviewerVersionString << std::endl << std::endl; - std::cout << "glest_g3dviewer [G3D 3D-MODEL FILE]" << std::endl << std::endl; + std::cout << "G3D viewer " << g3dviewerVersionString << std::endl << std::endl; + std::cout << "glest_g3dviewer [G3D 3D-MODEL FILE]" << std::endl << std::endl; std::cout << "Displays glest 3D-models and unit/projectile/splash particle systems." << std::endl; - std::cout << "rotate with left mouse button, zoom with right mouse button or mousewheel." << std::endl; + std::cout << "rotate with left mouse button, zoom with right mouse button or mousewheel." << std::endl; std::cout << "Use ctrl to load more than one particle system. Press R to restart particles." << std::endl << std::endl; exit (0); } diff --git a/source/g3d_viewer/main.h b/source/g3d_viewer/main.h index 1051f0ca..6f9ce811 100644 --- a/source/g3d_viewer/main.h +++ b/source/g3d_viewer/main.h @@ -73,7 +73,8 @@ private: float speed; float anim; - float rotX, rotY, zoom; + float rotX, rotY, zoom; + float backBrightness, gridBrightness, lightBrightness; int lastX, lastY; Renderer::PlayerColor playerColor; @@ -139,8 +140,8 @@ private: DECLARE_EVENT_TABLE() public: - GlCanvas(MainWindow *mainWindow); - + GlCanvas(MainWindow *mainWindow); + GlCanvas(MainWindow *mainWindow, int *args); void onMouseWheel(wxMouseEvent &event); void onMouseMove(wxMouseEvent &event); diff --git a/source/g3d_viewer/renderer.cpp b/source/g3d_viewer/renderer.cpp index bb76255b..983fef05 100644 --- a/source/g3d_viewer/renderer.cpp +++ b/source/g3d_viewer/renderer.cpp @@ -186,7 +186,7 @@ void Renderer::init(){ customTextureYellow->getPixmap()->init(1, 1, 3); customTextureYellow->getPixmap()->setPixel(0, 0, Vec3f(1.f, 1.f, 0.f)); - //white tex + //white tex customTextureWhite= textureManager->newTexture2D(); customTextureWhite->getPixmap()->init(1, 1, 3); customTextureWhite->getPixmap()->setPixel(0, 0, Vec3f(1.f, 1.f, 1.f)); @@ -206,7 +206,7 @@ void Renderer::init(){ customTextureMagenta->getPixmap()->init(1, 1, 3); customTextureMagenta->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.5f, 1.f)); - glClearColor(0.3f, 0.3f, 0.3f, 1.0f); + glClearColor(0.3f, 0.3f, 0.3f, 1.0f); //backgroundcolor constant 0.3 glEnable(GL_TEXTURE_2D); glFrontFace(GL_CW); glEnable(GL_CULL_FACE); @@ -301,7 +301,7 @@ void Renderer::renderGrid(){ glDisable(GL_LIGHTING); glBegin(GL_LINES); - glColor3f(1.0f, 1.0f, 1.0f); + glColor3f(1.0f, 1.0f, 1.0f); // gridcolor constant for(i=-10.0f; i<=10.0f; i+=1.0f){ glVertex3f(i, 0.0f, 10.0f); glVertex3f(i, 0.0f, -10.0f); @@ -347,7 +347,7 @@ void Renderer::renderTheModel(Model *model, float f){ glPushAttrib(GL_ENABLE_BIT); glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); - glColor3f(1.0f, 1.0f, 1.0f); + glColor3f(1.0f, 1.0f, 1.0f); //normalscolor constant modelRenderer->renderNormalsOnly(model); glPopAttrib(); } diff --git a/source/glest_map_editor/icons/brush_players_player.xpm b/source/glest_map_editor/icons/brush_players_player.xpm index 2c3f5fa9..91c95971 100644 --- a/source/glest_map_editor/icons/brush_players_player.xpm +++ b/source/glest_map_editor/icons/brush_players_player.xpm @@ -1,9 +1,10 @@ /* XPM */ static const char *brush_players_player[] = { /* columns rows colors chars-per-pixel */ -"16 16 3 1", +"16 16 4 1", " c #FFFF00", ". c #008080", +"@ c #000000", "X c None", /* pixels */ "XXXXX......XXXXX", @@ -18,8 +19,8 @@ static const char *brush_players_player[] = { "...... ........", "...... ........", "X..... .......X", -"X.... ......X", -"XX............XX", -"XXX..........XXX", -"XXXXX......XXXXX" +"X.... @@@@@@@", +"XX........@@@@@X", +"XXX........@@@XX", +"XXXXX......X@XXX" }; diff --git a/source/glest_map_editor/icons/brush_surface_custom.xpm b/source/glest_map_editor/icons/brush_surface_custom.xpm index a7e5a81d..c99daf00 100644 --- a/source/glest_map_editor/icons/brush_surface_custom.xpm +++ b/source/glest_map_editor/icons/brush_surface_custom.xpm @@ -1,25 +1,26 @@ /* XPM */ static const char *brush_surface_custom[] = { /* columns rows colors chars-per-pixel */ -"16 16 3 1", -" c #000000", +"16 16 4 1", +" c #2D2013", ". c #7c4645", +"@ c #C48C54", "X c None", /* pixels */ "XXXXXXXXXXXXXXXX", -" ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", +"@@@@@@@@@@@@@@@.", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", " ", "XXXXXXXXXXXXXXXX" }; diff --git a/source/glest_map_editor/icons/brush_surface_grass1.xpm b/source/glest_map_editor/icons/brush_surface_grass1.xpm index 45749f15..d679e7ef 100644 --- a/source/glest_map_editor/icons/brush_surface_grass1.xpm +++ b/source/glest_map_editor/icons/brush_surface_grass1.xpm @@ -1,25 +1,26 @@ /* XPM */ static const char *brush_surface_grass1[] = { /* columns rows colors chars-per-pixel */ -"16 16 3 1", -" c #000000", +"16 16 4 1", +" c #003300", ". c #00a000", +"@ c #00E000", "X c None", /* pixels */ "XXXXXXXXXXXXXXXX", -" ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", +"@@@@@@@@@@@@@@@.", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", " ", "XXXXXXXXXXXXXXXX" }; diff --git a/source/glest_map_editor/icons/brush_surface_grass2.xpm b/source/glest_map_editor/icons/brush_surface_grass2.xpm index c0f97597..0ac1c6fd 100644 --- a/source/glest_map_editor/icons/brush_surface_grass2.xpm +++ b/source/glest_map_editor/icons/brush_surface_grass2.xpm @@ -1,25 +1,26 @@ /* XPM */ static const char *brush_surface_grass2[] = { /* columns rows colors chars-per-pixel */ -"16 16 3 1", -" c #000000", +"16 16 4 1", +" c #192600", ". c #536e0b", +"@ c #70A800", "X c None", /* pixels */ "XXXXXXXXXXXXXXXX", -" ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", +"@@@@@@@@@@@@@@@.", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", " ", "XXXXXXXXXXXXXXXX" }; diff --git a/source/glest_map_editor/icons/brush_surface_road.xpm b/source/glest_map_editor/icons/brush_surface_road.xpm index 2183c3a7..d9bcb32d 100644 --- a/source/glest_map_editor/icons/brush_surface_road.xpm +++ b/source/glest_map_editor/icons/brush_surface_road.xpm @@ -1,25 +1,26 @@ /* XPM */ static const char *brush_surface_road[] = { /* columns rows colors chars-per-pixel */ -"16 16 3 1", -" c #000000", +"16 16 4 1", +" c #261300", ". c #800000", +"@ c #A85400", "X c None", /* pixels */ "XXXXXXXXXXXXXXXX", -" ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", +"@@@@@@@@@@@@@@@.", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", " ", "XXXXXXXXXXXXXXXX" }; diff --git a/source/glest_map_editor/icons/brush_surface_stone.xpm b/source/glest_map_editor/icons/brush_surface_stone.xpm index 41688818..5b106363 100644 --- a/source/glest_map_editor/icons/brush_surface_stone.xpm +++ b/source/glest_map_editor/icons/brush_surface_stone.xpm @@ -1,25 +1,26 @@ /* XPM */ static const char *brush_surface_stone[] = { /* columns rows colors chars-per-pixel */ -"16 16 3 1", -" c #000000", +"16 16 4 1", +" c #2D2D2D", ". c #808080", +"@ c #C4C4C4", "X c None", /* pixels */ "XXXXXXXXXXXXXXXX", -" ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", -" .............. ", +"@@@@@@@@@@@@@@@.", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", +"@.............. ", " ", "XXXXXXXXXXXXXXXX" }; diff --git a/source/glest_map_editor/icons/edit_switch-surfaces.xpm b/source/glest_map_editor/icons/edit_switch-surfaces.xpm index 1eac08b3..458293e5 100644 --- a/source/glest_map_editor/icons/edit_switch-surfaces.xpm +++ b/source/glest_map_editor/icons/edit_switch-surfaces.xpm @@ -9,16 +9,16 @@ static const char *edit_switch_surfaces[] = { "........ ", "........ ", "........ ", -"........ ", "..... .. . ", ".... .. .. ", -"... ..... ", -"... ..... ", +"... .. ... ", +".. ...... ", +".. ...... ", +"... .. ... ", ".... .. .. ", "..... .. . ", "........ ", "........ ", "........ ", -"........ ", "........ " }; diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index 28f2c0a6..531d9eca 100755 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -22,8 +22,10 @@ using namespace std; namespace MapEditor { -const string MainWindow::versionString = "v1.5.0"; -const string MainWindow::winHeader = "Glest Map Editor " + versionString + " - Built: " + __DATE__; + + +const string mapeditorVersionString = "v1.5.1"; +const string MainWindow::winHeader = "Glest Map Editor " + mapeditorVersionString; // =============================================== // class Global functions @@ -69,6 +71,7 @@ MainWindow::MainWindow() //file menuFile = new wxMenu(); + menuFile->Append(wxID_NEW); menuFile->Append(wxID_OPEN); menuFile->AppendSeparator(); menuFile->Append(wxID_SAVE); @@ -81,115 +84,133 @@ MainWindow::MainWindow() menuEdit = new wxMenu(); menuEdit->Append(miEditUndo, wxT("&Undo\tCTRL+Z")); menuEdit->Append(miEditRedo, wxT("&Redo\tCTRL+Y")); - menuEdit->Append(miEditReset, wxT("Rese&t")); - menuEdit->Append(miEditResetPlayers, wxT("Reset &Players")); - menuEdit->Append(miEditResize, wxT("Re&size")); + menuEdit->AppendSeparator(); +// menuEdit->Append(miEditReset, wxT("Rese&t...")); + menuEdit->Append(miEditResetPlayers, wxT("Reset &Players...")); + menuEdit->Append(miEditResize, wxT("Re&size...")); menuEdit->Append(miEditFlipX, wxT("Flip &X")); menuEdit->Append(miEditFlipY, wxT("Flip &Y")); + + // Mirror submenu------------------------------------------- + menuEditMirror = new wxMenu(); + menuEditMirror->Append(miEditMirrorX, wxT("Copy &Left to Right")); + menuEditMirror->Append(miEditMirrorY, wxT("Copy &Top to Bottom")); + menuEditMirror->Append(miEditMirrorXY, wxT("Copy &BottomLeft to TopRight")); + menuEditMirror->AppendSeparator(); + menuEditMirror->Append(miEditRotatecopyX, wxT("&Rotate Left to Right")); + menuEditMirror->Append(miEditRotatecopyY, wxT("Rotate T&op to Bottom")); + menuEditMirror->Append(miEditRotatecopyXY, wxT("Rotate Botto&mLeft to TopRight")); + menuEditMirror->Append(miEditRotatecopyCorner, wxT("Rotate TopLeft &corner to TopRight")); + menuEdit->Append(miEditMirror, wxT("&Mirror"), menuEditMirror); + // --------------------------------------------------------- + menuEdit->Append(miEditRandomizeHeights, wxT("Randomize &Heights")); - menuEdit->Append(miEditRandomize, wxT("Randomi&ze")); - menuEdit->Append(miEditSwitchSurfaces, wxT("Switch Su&rfaces")); - menuEdit->Append(miEditInfo, wxT("&Info")); - menuEdit->Append(miEditAdvanced, wxT("&Advanced")); + menuEdit->Append(miEditRandomize, wxT("Randomi&ze Heights/Players")); + menuEdit->Append(miEditSwitchSurfaces, wxT("Switch Sur&faces...")); + menuEdit->Append(miEditInfo, wxT("&Info...")); + menuEdit->Append(miEditAdvanced, wxT("&Advanced...")); menuBar->Append(menuEdit, wxT("&Edit")); - //misc - menuMisc = new wxMenu(); - menuMisc->Append(miMiscResetZoomAndPos, wxT("&Reset zoom and pos")); - menuMisc->Append(miMiscAbout, wxT("&About")); - menuMisc->Append(miMiscHelp, wxT("&Help")); - menuBar->Append(menuMisc, wxT("&Misc")); + //view + menuView = new wxMenu(); + menuView->Append(miViewResetZoomAndPos, wxT("&Reset zoom and pos")); + menuView->AppendSeparator(); + menuView->Append(miViewHelp, wxT("&Help...")); + menuView->Append(miViewAbout, wxT("&About...")); + menuBar->Append(menuView, wxT("&View")); //brush - menuBrush = new wxMenu(); + // menuBrush = new wxMenu(); - // Glest height brush - menuBrushHeight = new wxMenu(); - for (int i = 0; i < heightCount; ++i) { - menuBrushHeight->AppendCheckItem(miBrushHeight + i + 1, ToUnicode(intToStr(i - heightCount / 2))); - } - menuBrushHeight->Check(miBrushHeight + (heightCount + 1) / 2, true); - menuBrush->Append(miBrushHeight, wxT("&Height"), menuBrushHeight); + //surface + menuBrushSurface = new wxMenu(); + menuBrushSurface->AppendCheckItem(miBrushSurface + 1, wxT("&Grass")); + menuBrushSurface->AppendCheckItem(miBrushSurface + 2, wxT("S&econdary grass")); + menuBrushSurface->AppendCheckItem(miBrushSurface + 3, wxT("&Road")); + menuBrushSurface->AppendCheckItem(miBrushSurface + 4, wxT("&Stone")); + menuBrushSurface->AppendCheckItem(miBrushSurface + 5, wxT("Gr&ound")); + menuBar->Append(menuBrushSurface, wxT("&Surface")); - enabledGroup = ctHeight; + //resources + menuBrushResource = new wxMenu(); + //menuBrushResource->AppendCheckItem(miBrushResource + 1, wxT("&0 - None")); + menuBrushResource->AppendCheckItem(miBrushResource+2, wxT("&Gold (unwalkable)")); + menuBrushResource->AppendCheckItem(miBrushResource+3, wxT("&Stone (unwalkable)")); + menuBrushResource->AppendCheckItem(miBrushResource+4, wxT("&3 - custom")); + menuBrushResource->AppendCheckItem(miBrushResource+5, wxT("&4 - custom")); + menuBrushResource->AppendCheckItem(miBrushResource+6, wxT("&5 - custom")); + menuBar->Append(menuBrushResource, wxT("&Resource")); + + //objects + menuBrushObject = new wxMenu(); + menuBrushObject->AppendCheckItem(miBrushObject+1, wxT("&None (erase)\tALT+0")); + menuBrushObject->AppendSeparator(); + menuBrushObject->AppendCheckItem(miBrushObject+2, wxT("&Tree (harvestable)")); + menuBrushObject->AppendCheckItem(miBrushObject+3, wxT("&Dead tree/Cactuses/Thornbush")); + menuBrushObject->AppendCheckItem(miBrushObject+4, wxT("&Stone")); + menuBrushObject->AppendCheckItem(miBrushObject+5, wxT("&Bush/Grass/Fern (walkable)")); + menuBrushObject->AppendCheckItem(miBrushObject+6, wxT("&Water object/Reed/Papyrus (walkable)")); + menuBrushObject->AppendCheckItem(miBrushObject+7, wxT("Big tree/&Old palm")); + menuBrushObject->AppendCheckItem(miBrushObject+8, wxT("&Hanged/Impaled ")); + menuBrushObject->AppendCheckItem(miBrushObject+9, wxT("St&atues")); + menuBrushObject->AppendCheckItem(miBrushObject+10, wxT("&Mountain")); + menuBrushObject->AppendCheckItem(miBrushObject+11, wxT("&Invisible blocking object")); + menuBar->Append(menuBrushObject, wxT("&Object")); // ZombiePirate height brush menuBrushGradient = new wxMenu(); for (int i = 0; i < heightCount; ++i) { - menuBrushGradient->AppendCheckItem(miBrushGradient + i + 1, ToUnicode(intToStr(i - heightCount / 2))); + menuBrushGradient->AppendCheckItem(miBrushGradient + i + 1, ToUnicode((i>4?"&":"") +intToStr(i - heightCount / 2))); } - menuBrush->Append(miBrushGradient, wxT("&Gradient"), menuBrushGradient); + menuBar->Append(menuBrushGradient, wxT("&Gradient")); - //surface - menuBrushSurface = new wxMenu(); - menuBrushSurface->AppendCheckItem(miBrushSurface + 1, wxT("&1 - Grass")); - menuBrushSurface->AppendCheckItem(miBrushSurface + 2, wxT("&2 - Secondary Grass")); - menuBrushSurface->AppendCheckItem(miBrushSurface + 3, wxT("&3 - Road")); - menuBrushSurface->AppendCheckItem(miBrushSurface + 4, wxT("&4 - Stone")); - menuBrushSurface->AppendCheckItem(miBrushSurface + 5, wxT("&5 - Ground")); - menuBrush->Append(miBrushSurface, wxT("&Surface"), menuBrushSurface); + // Glest height brush + menuBrushHeight = new wxMenu(); + for (int i = 0; i < heightCount; ++i) { + menuBrushHeight->AppendCheckItem(miBrushHeight + i + 1, ToUnicode((i>4?"&":"") +intToStr(i - heightCount / 2))); + } + menuBrushHeight->Check(miBrushHeight + (heightCount + 1) / 2, true); + menuBar->Append(menuBrushHeight, wxT("&Height")); - //objects - menuBrushObject = new wxMenu(); - menuBrushObject->AppendCheckItem(miBrushObject + 1, wxT("&0 - None (erase)")); - menuBrushObject->AppendCheckItem(miBrushObject+2, wxT("&1 - Tree (unwalkable/harvestable)")); - menuBrushObject->AppendCheckItem(miBrushObject+3, wxT("&2 - DeadTree/Cactuses/Thornbush (unwalkable)")); - menuBrushObject->AppendCheckItem(miBrushObject+4, wxT("&3 - Stone (unwalkable)")); - menuBrushObject->AppendCheckItem(miBrushObject+5, wxT("&4 - Bush/Grass/Fern (walkable)")); - menuBrushObject->AppendCheckItem(miBrushObject+6, wxT("&5 - Water Object/Reed/Papyrus (walkable)")); - menuBrushObject->AppendCheckItem(miBrushObject+7, wxT("&6 - C1 BigTree/DeadTree/OldPalm (unwalkable/not harvestable)")); - menuBrushObject->AppendCheckItem(miBrushObject+8, wxT("&7 - C2 Hanged/Impaled (unwalkable)")); - menuBrushObject->AppendCheckItem(miBrushObject+9, wxT("&8 - C3 Statues (unwalkable)")); - menuBrushObject->AppendCheckItem(miBrushObject+10, wxT("&9 - C4 Big Rock (Mountain) (unwalkable)")); - menuBrushObject->AppendCheckItem(miBrushObject+11, wxT("10 &- C5 Invisible Blocking Object (unwalkable)")); - menuBrush->Append(miBrushObject, wxT("&Object"), menuBrushObject); - - //resources - menuBrushResource = new wxMenu(); - menuBrushResource->AppendCheckItem(miBrushResource + 1, wxT("&0 - None")); - menuBrushResource->AppendCheckItem(miBrushResource+2, wxT("&1 - gold (unwalkable)")); - menuBrushResource->AppendCheckItem(miBrushResource+3, wxT("&2 - stone (unwalkable)")); - menuBrushResource->AppendCheckItem(miBrushResource+4, wxT("&3 - custom")); - menuBrushResource->AppendCheckItem(miBrushResource+5, wxT("&4 - custom")); - menuBrushResource->AppendCheckItem(miBrushResource+6, wxT("&5 - custom")); - menuBrush->Append(miBrushResource, wxT("&Resource"), menuBrushResource); - - //players - menuBrushStartLocation = new wxMenu(); - wxMenuItem *pmi1 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 1, wxT("&1 - Player 1")); - pmi1->SetBitmap(wxBitmap(brush_players_red)); - menuBrushStartLocation->Append(pmi1); - wxMenuItem *pmi2 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 2, wxT("&2 - Player 2")); - pmi2->SetBitmap(wxBitmap(brush_players_blue)); - menuBrushStartLocation->Append(pmi2); - wxMenuItem *pmi3 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 3, wxT("&3 - Player 3")); - pmi3->SetBitmap(wxBitmap(brush_players_green)); - menuBrushStartLocation->Append(pmi3); - wxMenuItem *pmi4 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 4, wxT("&4 - Player 4")); - pmi4->SetBitmap(wxBitmap(brush_players_yellow)); - menuBrushStartLocation->Append(pmi4); - wxMenuItem *pmi5 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 5, wxT("&5 - Player 5")); - pmi5->SetBitmap(wxBitmap(brush_players_white)); - menuBrushStartLocation->Append(pmi5); - wxMenuItem *pmi6 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 6, wxT("&6 - Player 6")); - pmi6->SetBitmap(wxBitmap(brush_players_cyan)); - menuBrushStartLocation->Append(pmi6); - wxMenuItem *pmi7 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 7, wxT("&7 - Player 7")); - pmi7->SetBitmap(wxBitmap(brush_players_orange)); - menuBrushStartLocation->Append(pmi7); - wxMenuItem *pmi8 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 8, wxT("&8 - Player 8")); - pmi8->SetBitmap(wxBitmap(brush_players_pink)); - menuBrushStartLocation->Append(pmi8); - menuBrush->Append(miBrushStartLocation, wxT("&Player"), menuBrushStartLocation); - menuBar->Append(menuBrush, wxT("&Brush")); + enabledGroup = ctHeight; //radius menuRadius = new wxMenu(); for (int i = 1; i <= radiusCount; ++i) { - menuRadius->AppendCheckItem(miRadius + i, ToUnicode("&" + intToStr(i) + "\tALT+" + intToStr(i))); + menuRadius->AppendCheckItem(miRadius + i, ToUnicode("&" + intToStr(i) + " (diameter "+intToStr(i*2-1)+ ")"+ "\tALT+" + intToStr(i))); } menuRadius->Check(miRadius + 1, true); - menuBar->Append(menuRadius, wxT("&Radius")); + menuBar->Append(menuRadius, wxT("R&adius")); + + //players + menuBrushStartLocation = new wxMenu(); + wxMenuItem *pmi1 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 1, wxT("Player &1 Red")); + pmi1->SetBitmap(wxBitmap(brush_players_red)); + menuBrushStartLocation->Append(pmi1); + wxMenuItem *pmi2 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 2, wxT("Player &2 Blue")); + pmi2->SetBitmap(wxBitmap(brush_players_blue)); + menuBrushStartLocation->Append(pmi2); + wxMenuItem *pmi3 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 3, wxT("Player &3 Green")); + pmi3->SetBitmap(wxBitmap(brush_players_green)); + menuBrushStartLocation->Append(pmi3); + wxMenuItem *pmi4 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 4, wxT("Player &4 Yellow")); + pmi4->SetBitmap(wxBitmap(brush_players_yellow)); + menuBrushStartLocation->Append(pmi4); + wxMenuItem *pmi5 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 5, wxT("Player &5 White")); + pmi5->SetBitmap(wxBitmap(brush_players_white)); + menuBrushStartLocation->Append(pmi5); + wxMenuItem *pmi6 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 6, wxT("Player &6 Cyan")); + pmi6->SetBitmap(wxBitmap(brush_players_cyan)); + menuBrushStartLocation->Append(pmi6); + wxMenuItem *pmi7 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 7, wxT("Player &7 Orange")); + pmi7->SetBitmap(wxBitmap(brush_players_orange)); + menuBrushStartLocation->Append(pmi7); + wxMenuItem *pmi8 = new wxMenuItem(menuBrushStartLocation, miBrushStartLocation + 8, wxT("Player &8 Pink")); // = Light Magenta :-) + pmi8->SetBitmap(wxBitmap(brush_players_pink)); + menuBrushStartLocation->Append(pmi8); + menuBar->Append(menuBrushStartLocation, wxT("&Player")); + //menuBar->Append(menuBrush, wxT("&Brush")); + SetMenuBar(menuBar); @@ -217,34 +238,34 @@ MainWindow::MainWindow() toolbar->AddTool(miEditUndo, _("undo"), wxBitmap(edit_undo), _("Undo")); toolbar->AddTool(miEditRedo, _("redo"), wxBitmap(edit_redo), _("Redo")); toolbar->AddTool(miEditRandomizeHeights, _("randomizeHeights"), wxBitmap(edit_randomize_heights), _("Randomize Heights")); - toolbar->AddTool(miEditRandomize, _("randomize"), wxBitmap(edit_randomize), _("Randomize")); +// toolbar->AddTool(miEditRandomize, _("randomize"), wxBitmap(edit_randomize), _("Randomize")); toolbar->AddTool(miEditSwitchSurfaces, _("switch"), wxBitmap(edit_switch_surfaces), _("Switch Surfaces")); toolbar->AddSeparator(); toolbar->AddTool(miBrushSurface + 1, _("brush_grass1"), wxBitmap(brush_surface_grass1), _("Grass")); - toolbar->AddTool(miBrushSurface + 2, _("brush_grass2"), wxBitmap(brush_surface_grass2), _("Secondary Grass")); + toolbar->AddTool(miBrushSurface + 2, _("brush_grass2"), wxBitmap(brush_surface_grass2), _("Secondary grass")); toolbar->AddTool(miBrushSurface + 3, _("brush_road"), wxBitmap(brush_surface_road), _("Road")); toolbar->AddTool(miBrushSurface + 4, _("brush_stone"), wxBitmap(brush_surface_stone), _("Stone")); toolbar->AddTool(miBrushSurface + 5, _("brush_custom"), wxBitmap(brush_surface_custom), _("Ground")); toolbar->AddSeparator(); toolbar->AddTool(miBrushResource + 2, _("resource1"), wxBitmap(brush_resource_1_gold), _("gold (unwalkable)")); toolbar->AddTool(miBrushResource + 3, _("resource2"), wxBitmap(brush_resource_2_stone), _("stone (unwalkable)")); - toolbar->AddTool(miBrushResource + 4, _("resource3"), wxBitmap(brush_resource_3), _("custom")); - toolbar->AddTool(miBrushResource + 5, _("resource4"), wxBitmap(brush_resource_4), _("custom")); - toolbar->AddTool(miBrushResource + 6, _("resource5"), wxBitmap(brush_resource_5), _("custom")); + toolbar->AddTool(miBrushResource + 4, _("resource3"), wxBitmap(brush_resource_3), _("custom3")); + toolbar->AddTool(miBrushResource + 5, _("resource4"), wxBitmap(brush_resource_4), _("custom4")); + toolbar->AddTool(miBrushResource + 6, _("resource5"), wxBitmap(brush_resource_5), _("custom5")); toolbar->AddSeparator(); toolbar->AddTool(miBrushObject + 1, _("brush_none"), wxBitmap(brush_none), _("None (erase)")); toolbar->AddTool(miBrushObject + 2, _("brush_tree"), wxBitmap(brush_object_tree), _("Tree (unwalkable/harvestable)")); - toolbar->AddTool(miBrushObject + 3, _("brush_dead_tree"), wxBitmap(brush_object_dead_tree), _("DeadTree/Cactuses/Thornbush (unwalkable)")); - toolbar->AddTool(miBrushObject + 4, _("brush_stone"), wxBitmap(brush_object_stone), _("Stone (unwalkable)")); + toolbar->AddTool(miBrushObject + 3, _("brush_dead_tree"), wxBitmap(brush_object_dead_tree), _("Dead tree/Cactuses/Thornbush (unwalkable)")); + toolbar->AddTool(miBrushObject + 4, _("brush_stone"), wxBitmap(brush_object_stone), _("Stone (unwalkable/not harvestable)")); toolbar->AddTool(miBrushObject + 5, _("brush_bush"), wxBitmap(brush_object_bush), _("Bush/Grass/Fern (walkable)")); - toolbar->AddTool(miBrushObject + 6, _("brush_water"), wxBitmap(brush_object_water_object), _("Water Object/Reed/Papyrus (walkable)")); - toolbar->AddTool(miBrushObject + 7, _("brush_c1_bigtree"), wxBitmap(brush_object_c1_bigtree), _("C1 BigTree/DeadTree/OldPalm (unwalkable/not harvestable)")); - toolbar->AddTool(miBrushObject + 8, _("brush_c2_hanged"), wxBitmap(brush_object_c2_hanged), _("C2 Hanged/Impaled (unwalkable)")); - toolbar->AddTool(miBrushObject + 9, _("brush_c3_statue"), wxBitmap(brush_object_c3_statue), _("C3, Statues (unwalkable))")); - toolbar->AddTool(miBrushObject +10, _("brush_c4_bigrock"), wxBitmap(brush_object_c4_bigrock), _("Big Rock (Mountain) (unwalkable)")); - toolbar->AddTool(miBrushObject +11, _("brush_c5_blocking"), wxBitmap(brush_object_c5_blocking), _("Invisible Blocking Object (unwalkable)")); + toolbar->AddTool(miBrushObject + 6, _("brush_water"), wxBitmap(brush_object_water_object), _("Water object/Reed/Papyrus (walkable)")); + toolbar->AddTool(miBrushObject + 7, _("brush_c1_bigtree"), wxBitmap(brush_object_c1_bigtree), _("Big tree/Old palm (unwalkable/not harvestable)")); + toolbar->AddTool(miBrushObject + 8, _("brush_c2_hanged"), wxBitmap(brush_object_c2_hanged), _("Hanged/Impaled (unwalkable)")); + toolbar->AddTool(miBrushObject + 9, _("brush_c3_statue"), wxBitmap(brush_object_c3_statue), _("Statues (unwalkable)")); + toolbar->AddTool(miBrushObject +10, _("brush_c4_bigrock"), wxBitmap(brush_object_c4_bigrock), _("Mountain (unwalkable)")); + toolbar->AddTool(miBrushObject +11, _("brush_c5_blocking"), wxBitmap(brush_object_c5_blocking), _("Invisible blocking object (unwalkable)")); toolbar->AddSeparator(); - toolbar->AddTool(toolPlayer, _("brush_player"), wxBitmap(brush_players_player)); + toolbar->AddTool(toolPlayer, _("brush_player"), wxBitmap(brush_players_player), _("Player start position")); toolbar->Realize(); wxToolBar *toolbar2 = new wxToolBar(this->panel, wxID_ANY); @@ -282,12 +303,12 @@ MainWindow::MainWindow() toolbar2->AddTool(miRadius + 8, _("radius8"), wxBitmap(radius_8)); toolbar2->AddTool(miRadius + 9, _("radius9"), wxBitmap(radius_9)); toolbar2->Realize(); - + wxBoxSizer *boxsizer = new wxBoxSizer(wxVERTICAL); boxsizer->Add(toolbar, 0, wxEXPAND); boxsizer->Add(toolbar2, 0, wxEXPAND); boxsizer->Add(glCanvas, 1, wxEXPAND); - + this->panel->SetSizer(boxsizer); this->Layout(); @@ -328,7 +349,7 @@ void MainWindow::init(string fname) { currentFile = fname; fileName = cutLastExt(extractFileFromDirectoryPath(fname.c_str())); } - SetTitle(ToUnicode(winHeader + "; " + currentFile)); + SetTitle(ToUnicode(currentFile + " - " + winHeader)); setDirty(false); setExtension(); } @@ -390,6 +411,19 @@ void MainWindow::onMouseDown(wxMouseEvent &event, int x, int y) { event.Skip(); } +// for the mousewheel +void MainWindow::onMouseWheelDown(wxMouseEvent &event) { + wxPaintEvent ev; + program->incCellSize(1); + onPaint(ev); +} + +void MainWindow::onMouseWheelUp(wxMouseEvent &event) { + wxPaintEvent ev; + program->incCellSize(-1); + onPaint(ev); +} + void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) { bool repaint = false; int dif; @@ -415,7 +449,7 @@ void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) { int currObject = program->getObject(x, y); SetStatusText(wxT("Object: ") + ToUnicode(object_descs[currObject]), siCURR_OBJECT); resourceUnderMouse = 0; - objectUnderMouse = currObject; + objectUnderMouse = currObject; } } lastX = x; @@ -433,6 +467,11 @@ void MainWindow::onPaint(wxPaintEvent &event) { sleep(1); return; } + + wxPaintDC dc(this); // "In a paint event handler must always create a wxPaintDC object even if you do not use it. (?) + // Otherwise, under MS Windows, refreshing for this and other windows will go wrong" + // http://docs.wxwidgets.org/2.6/wx_wxpaintevent.html + lastPaintEvent.start(); if(panel) panel->Update(); @@ -445,7 +484,7 @@ void MainWindow::onPaint(wxPaintEvent &event) { void MainWindow::onMenuFileLoad(wxCommandEvent &event) { wxFileDialog fileDialog(this); - fileDialog.SetWildcard(wxT("Glest Map (*.gbm)|*.gbm|Mega Map (*.mgm)|*.mgm")); + fileDialog.SetWildcard(wxT("Glest&Mega Map (*.gbm *.mgm)|*.gbm;*.mgm|Glest Map (*.gbm)|*.gbm|Mega Map (*.mgm)|*.mgm")); if (fileDialog.ShowModal() == wxID_OK) { currentFile = fileDialog.GetPath().ToAscii(); program->loadMap(currentFile); @@ -485,7 +524,7 @@ void MainWindow::onMenuFileExit(wxCommandEvent &event) { } void MainWindow::onMenuEditUndo(wxCommandEvent &event) { - std::cout << "Undo Pressed" << std::endl; + // std::cout << "Undo Pressed" << std::endl; if (program->undo()) { wxPaintEvent e; onPaint(e); @@ -494,7 +533,7 @@ void MainWindow::onMenuEditUndo(wxCommandEvent &event) { } void MainWindow::onMenuEditRedo(wxCommandEvent &event) { - std::cout << "Redo Pressed" << std::endl; + // std::cout << "Redo Pressed" << std::endl; if (program->redo()) { wxPaintEvent e; onPaint(e); @@ -505,11 +544,12 @@ void MainWindow::onMenuEditRedo(wxCommandEvent &event) { void MainWindow::onMenuEditReset(wxCommandEvent &event) { program->setUndoPoint(ctAll); SimpleDialog simpleDialog; - simpleDialog.addValue("Altitude", "10"); - simpleDialog.addValue("Surface", "1"); - simpleDialog.addValue("Width", "128"); - simpleDialog.addValue("Height", "128"); - simpleDialog.show(); + simpleDialog.addValue("Width", "128","(must be 16,32,64,128,256,512...)"); // must be an exponent of two + simpleDialog.addValue("Height", "128","(must be 16,32,64,128,256,512...)"); + simpleDialog.addValue("Surface", "1","(Default surface material)"); + simpleDialog.addValue("Altitude", "10","(Default surface height)"); + simpleDialog.addValue("Number of players", "8"); + if (!simpleDialog.show()) return; try { program->reset( @@ -517,7 +557,8 @@ void MainWindow::onMenuEditReset(wxCommandEvent &event) { strToInt(simpleDialog.getValue("Height")), strToInt(simpleDialog.getValue("Altitude")), strToInt(simpleDialog.getValue("Surface"))); - } + program->resetFactions(strToInt(simpleDialog.getValue("Number of players"))); + } catch (const exception &e) { MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal(); } @@ -527,12 +568,12 @@ void MainWindow::onMenuEditReset(wxCommandEvent &event) { void MainWindow::onMenuEditResetPlayers(wxCommandEvent &event) { SimpleDialog simpleDialog; - simpleDialog.addValue("Factions", intToStr(program->getMap()->getMaxFactions())); - simpleDialog.show(); + simpleDialog.addValue("Number of players", intToStr(program->getMap()->getMaxFactions())); + if (!simpleDialog.show("Reset players")) return; try { - program->resetFactions(strToInt(simpleDialog.getValue("Factions"))); - } + program->resetFactions(strToInt(simpleDialog.getValue("Number of players"))); + } catch (const exception &e) { MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal(); } @@ -542,19 +583,19 @@ void MainWindow::onMenuEditResetPlayers(wxCommandEvent &event) { void MainWindow::onMenuEditResize(wxCommandEvent &event) { SimpleDialog simpleDialog; - simpleDialog.addValue("Altitude", "10"); - simpleDialog.addValue("Surface", "1"); - simpleDialog.addValue("Height", "128"); - simpleDialog.addValue("Width", "128"); - simpleDialog.show(); + simpleDialog.addValue("Width", intToStr(program->getMap()->getW()),"(must be 16,32,64,128,256,512...)"); + simpleDialog.addValue("Height", intToStr(program->getMap()->getH()),"(must be 16,32,64,128,256,512...)"); + simpleDialog.addValue("Surface", "1","(surface material for new area around map)"); + simpleDialog.addValue("Altitude", "10","(surface height for new area around map)"); + if (!simpleDialog.show("Resze - expand around, shrink to topleft")) return; try { program->resize( - strToInt(simpleDialog.getValue("Height")), strToInt(simpleDialog.getValue("Width")), + strToInt(simpleDialog.getValue("Height")), strToInt(simpleDialog.getValue("Altitude")), strToInt(simpleDialog.getValue("Surface"))); - } + } catch (const exception &e) { MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal(); } @@ -562,36 +603,84 @@ void MainWindow::onMenuEditResize(wxCommandEvent &event) { } void MainWindow::onMenuEditFlipX(wxCommandEvent &event) { + program->setUndoPoint(ctAll); program->flipX(); setDirty(); } void MainWindow::onMenuEditFlipY(wxCommandEvent &event) { + program->setUndoPoint(ctAll); program->flipY(); setDirty(); } +void MainWindow::onMenuEditMirrorX(wxCommandEvent &event) { // copy left to right + program->setUndoPoint(ctAll); + program->mirrorX(); + setDirty(); +} + +void MainWindow::onMenuEditMirrorY(wxCommandEvent &event) { // copy top to bottom + program->setUndoPoint(ctAll); + program->mirrorY(); + setDirty(); +} + +void MainWindow::onMenuEditMirrorXY(wxCommandEvent &event) { // copy bottomleft tp topright + program->setUndoPoint(ctAll); + program->mirrorXY(); + setDirty(); +} + +void MainWindow::onMenuEditRotatecopyX(wxCommandEvent &event) { // copy left to right, rotated + program->setUndoPoint(ctAll); + program->rotatecopyX(); + setDirty(); +} + +void MainWindow::onMenuEditRotatecopyY(wxCommandEvent &event) { // copy top to bottom, rotated + program->setUndoPoint(ctAll); + program->rotatecopyY(); + setDirty(); +} + +void MainWindow::onMenuEditRotatecopyXY(wxCommandEvent &event) { // copy bottomleft to topright, rotated + program->setUndoPoint(ctAll); + program->rotatecopyXY(); + setDirty(); +} + +void MainWindow::onMenuEditRotatecopyCorner(wxCommandEvent &event) { // copy top left 1/4 to top right 1/4, rotated + program->setUndoPoint(ctAll); + program->rotatecopyCorner(); + setDirty(); +} + + void MainWindow::onMenuEditRandomizeHeights(wxCommandEvent &event) { + program->setUndoPoint(ctAll); program->randomizeMapHeights(); setDirty(); } void MainWindow::onMenuEditRandomize(wxCommandEvent &event) { + program->setUndoPoint(ctAll); program->randomizeMap(); setDirty(); } void MainWindow::onMenuEditSwitchSurfaces(wxCommandEvent &event) { SimpleDialog simpleDialog; - simpleDialog.addValue("Surface1", "1"); - simpleDialog.addValue("Surface2", "2"); - simpleDialog.show(); + simpleDialog.addValue("Surface1", "1","replace this surface with..."); + simpleDialog.addValue("Surface2", "2","...this and vice versa"); + if (!simpleDialog.show("Switch surfaces")) return; try { + program->setUndoPoint(ctSurface); program->switchMapSurfaces( strToInt(simpleDialog.getValue("Surface1")), strToInt(simpleDialog.getValue("Surface2"))); - } + } catch (const exception &e) { MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal(); } @@ -601,54 +690,59 @@ void MainWindow::onMenuEditSwitchSurfaces(wxCommandEvent &event) { void MainWindow::onMenuEditInfo(wxCommandEvent &event) { SimpleDialog simpleDialog; simpleDialog.addValue("Title", program->getMap()->getTitle()); - simpleDialog.addValue("Desc", program->getMap()->getDesc()); + simpleDialog.addValue("Description", program->getMap()->getDesc()); simpleDialog.addValue("Author", program->getMap()->getAuthor()); + if (!simpleDialog.show("Info",true)) return; - simpleDialog.show(); - - if (program->setMapTitle(simpleDialog.getValue("Title")) - || program->setMapDesc(simpleDialog.getValue("Desc")) - || program->setMapAuthor(simpleDialog.getValue("Author"))) { + bool ischanged = false; + ischanged = program->setMapTitle(simpleDialog.getValue("Title")); + ischanged = (program->setMapDesc(simpleDialog.getValue("Description")) || ischanged); + ischanged = (program->setMapAuthor(simpleDialog.getValue("Author")) || ischanged); + if (ischanged) if (!isDirty()) { setDirty(true); } - } + } void MainWindow::onMenuEditAdvanced(wxCommandEvent &event) { SimpleDialog simpleDialog; - simpleDialog.addValue("Height Factor", intToStr(program->getMap()->getHeightFactor())); - simpleDialog.addValue("Water Level", intToStr(program->getMap()->getWaterLevel())); - - simpleDialog.show(); + simpleDialog.addValue("Height Factor", intToStr(program->getMap()->getHeightFactor()),"(lower means map is more more zoomed in)"); + simpleDialog.addValue("Water Level", intToStr(program->getMap()->getWaterLevel()),"(which level water is visible but still walkable)"); + if (!simpleDialog.show("Advanced")) return; try { program->setMapAdvanced( strToInt(simpleDialog.getValue("Height Factor")), strToInt(simpleDialog.getValue("Water Level"))); - } + } catch (const exception &e) { MsgDialog(this, ToUnicode(e.what()), wxT("Exception"), wxOK | wxICON_ERROR).ShowModal(); } setDirty(); } -void MainWindow::onMenuMiscResetZoomAndPos(wxCommandEvent &event) { +void MainWindow::onMenuViewResetZoomAndPos(wxCommandEvent &event) { program->resetOfset(); + wxPaintEvent e; + onPaint(e); } -void MainWindow::onMenuMiscAbout(wxCommandEvent &event) { +void MainWindow::onMenuViewAbout(wxCommandEvent &event) { MsgDialog( this, wxT("Glest Map Editor - Copyright 2004 The Glest Team\n(with improvements by others, 2010)."), wxT("About")).ShowModal(); } -void MainWindow::onMenuMiscHelp(wxCommandEvent &event) { - MsgDialog( - this, - wxT("Left mouse click: draw\nRight mouse drag: move\nCenter mouse drag: zoom"), +void MainWindow::onMenuViewHelp(wxCommandEvent &event) { + MsgDialog(this, + wxT("Draw with left mouse\nMove viewport with right mouse drag\nZoom with center mouse drag, or mousewheel\n\ +You can change brush in the same category with key 1-9\n\ +A good idea is to put some stone, gold and tree near starting position\n\ +Starting position needs an open area for the tower and at starting units\n"), wxT("Help")).ShowModal(); + /* 5 away and 10x10 empty area? */ } void MainWindow::onMenuBrushHeight(wxCommandEvent &e) { @@ -837,7 +931,7 @@ void MainWindow::uncheckRadius() { if (e.GetKeyCode() == 'H') { wxCommandEvent evt(wxEVT_NULL, miBrushHeight + height + heightCount / 2 + 1); onMenuBrushHeight(evt); - } else if (e.GetKeyCode() == ' ') { + } else if (e.GetKeyCode() == ' ') { if (resourceUnderMouse != 0) { wxCommandEvent evt(wxEVT_NULL, miBrushResource + resourceUnderMouse + 1); onMenuBrushResource(evt); @@ -869,11 +963,12 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame) EVT_CLOSE(MainWindow::onClose) - // these are 'handled' by GlCanvas and funneled to these handlers + // these are 'handled' by GlCanvas and funneled to these handlers. See BEGIN_EVENT_TABLE(GlCanvas, wxGLCanvas) below. //EVT_LEFT_DOWN(MainWindow::onMouseDown) //EVT_MOTION(MainWindow::onMouseMove) //EVT_KEY_DOWN(MainWindow::onKeyDown) + EVT_MENU(wxID_NEW, MainWindow::onMenuEditReset) EVT_MENU(wxID_OPEN, MainWindow::onMenuFileLoad) EVT_MENU(wxID_SAVE, MainWindow::onMenuFileSave) EVT_MENU(wxID_SAVEAS, MainWindow::onMenuFileSaveAs) @@ -881,20 +976,28 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame) EVT_MENU(miEditUndo, MainWindow::onMenuEditUndo) EVT_MENU(miEditRedo, MainWindow::onMenuEditRedo) - EVT_MENU(miEditReset, MainWindow::onMenuEditReset) EVT_MENU(miEditResetPlayers, MainWindow::onMenuEditResetPlayers) EVT_MENU(miEditResize, MainWindow::onMenuEditResize) EVT_MENU(miEditFlipX, MainWindow::onMenuEditFlipX) EVT_MENU(miEditFlipY, MainWindow::onMenuEditFlipY) + + EVT_MENU(miEditMirrorX, MainWindow::onMenuEditMirrorX) + EVT_MENU(miEditMirrorY, MainWindow::onMenuEditMirrorY) + EVT_MENU(miEditMirrorXY, MainWindow::onMenuEditMirrorXY) + EVT_MENU(miEditRotatecopyX, MainWindow::onMenuEditRotatecopyX) + EVT_MENU(miEditRotatecopyY, MainWindow::onMenuEditRotatecopyY) + EVT_MENU(miEditRotatecopyXY, MainWindow::onMenuEditRotatecopyXY) + EVT_MENU(miEditRotatecopyCorner, MainWindow::onMenuEditRotatecopyCorner) + EVT_MENU(miEditRandomizeHeights, MainWindow::onMenuEditRandomizeHeights) EVT_MENU(miEditRandomize, MainWindow::onMenuEditRandomize) EVT_MENU(miEditSwitchSurfaces, MainWindow::onMenuEditSwitchSurfaces) EVT_MENU(miEditInfo, MainWindow::onMenuEditInfo) EVT_MENU(miEditAdvanced, MainWindow::onMenuEditAdvanced) - EVT_MENU(miMiscResetZoomAndPos, MainWindow::onMenuMiscResetZoomAndPos) - EVT_MENU(miMiscAbout, MainWindow::onMenuMiscAbout) - EVT_MENU(miMiscHelp, MainWindow::onMenuMiscHelp) + EVT_MENU(miViewResetZoomAndPos, MainWindow::onMenuViewResetZoomAndPos) + EVT_MENU(miViewAbout, MainWindow::onMenuViewAbout) + EVT_MENU(miViewHelp, MainWindow::onMenuViewHelp) EVT_MENU_RANGE(miBrushHeight + 1, miBrushHeight + heightCount, MainWindow::onMenuBrushHeight) EVT_MENU_RANGE(miBrushGradient + 1, miBrushGradient + heightCount, MainWindow::onMenuBrushGradient) @@ -903,9 +1006,9 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame) EVT_MENU_RANGE(miBrushResource + 1, miBrushResource + resourceCount, MainWindow::onMenuBrushResource) EVT_MENU_RANGE(miBrushStartLocation + 1, miBrushStartLocation + startLocationCount, MainWindow::onMenuBrushStartLocation) EVT_MENU_RANGE(miRadius, miRadius + radiusCount, MainWindow::onMenuRadius) - + EVT_PAINT(MainWindow::onPaint) - + EVT_TOOL(toolPlayer, MainWindow::onToolPlayer) END_EVENT_TABLE() @@ -929,6 +1032,12 @@ void translateCoords(wxWindow *wnd, int &x, int &y) { */ } +// for the mousewheel +void GlCanvas::onMouseWheel(wxMouseEvent &event) { + if(event.GetWheelRotation()>0) mainWindow->onMouseWheelDown(event); + else mainWindow->onMouseWheelUp(event); +} + void GlCanvas::onMouseDown(wxMouseEvent &event) { int x, y; event.GetPosition(&x, &y); @@ -950,20 +1059,28 @@ void GlCanvas::onKeyDown(wxKeyEvent &event) { mainWindow->onKeyDown(event); } +void GlCanvas::onPaint(wxPaintEvent &event) { +// wxPaintDC dc(this); //N "In a paint event handler must always create a wxPaintDC object even if you do not use it. (?) +// mainWindow->program->renderMap(GetClientSize().x, GetClientSize().y); +// SwapBuffers(); +// event.Skip(); + mainWindow->onPaint(event); +} BEGIN_EVENT_TABLE(GlCanvas, wxGLCanvas) EVT_KEY_DOWN(GlCanvas::onKeyDown) - + EVT_MOUSEWHEEL(GlCanvas::onMouseWheel) EVT_LEFT_DOWN(GlCanvas::onMouseDown) EVT_MOTION(GlCanvas::onMouseMove) + EVT_PAINT(GlCanvas::onPaint) // Because the drawing area needs to be repainted too. END_EVENT_TABLE() // =============================================== // class SimpleDialog // =============================================== -void SimpleDialog::addValue(const string &key, const string &value) { - values.push_back(pair(key, value)); +void SimpleDialog::addValue(const string &key, const string &value, const string &help) { + values.push_back(pair(key, value+"|"+help)); // I guess I need map<,> instead but I don't know how to do it } string SimpleDialog::getValue(const string &key) { @@ -975,27 +1092,32 @@ string SimpleDialog::getValue(const string &key) { return ""; } -void SimpleDialog::show() { - - Create(NULL, -1, wxT("Edit Values")); - - wxSizer *sizer = new wxFlexGridSizer(2); +bool SimpleDialog::show(const string &title, bool wide) { + Create(NULL, -1, ToUnicode(title)); + wxSizer *sizer2 = new wxBoxSizer(wxVERTICAL); + wxSizer *sizer = new wxFlexGridSizer(3); vector texts; - for (Values::iterator it = values.begin(); it != values.end(); ++it) { + int helptextpos = it->second.find_first_of('|'); sizer->Add(new wxStaticText(this, -1, ToUnicode(it->first)), 0, wxALL, 5); - wxTextCtrl *text = new wxTextCtrl(this, -1, ToUnicode(it->second)); + wxTextCtrl *text = new wxTextCtrl(this, -1, ToUnicode(it->second.substr(0,helptextpos))); + if(wide) text->SetMinSize( wxSize((text->GetSize().GetWidth())*4, text->GetSize().GetHeight())); // 4 time as wide as default sizer->Add(text, 0, wxALL, 5); texts.push_back(text); + sizer->Add(new wxStaticText(this, -1, ToUnicode(it->second.substr(helptextpos+1))), 0, wxALL, 5); } - SetSizerAndFit(sizer); + sizer2->Add(sizer); + sizer2->Add(CreateButtonSizer(wxOK|wxCANCEL),0,wxALIGN_RIGHT); // enable Cancel button + SetSizerAndFit(sizer2); ShowModal(); + if(m_returnCode==wxID_CANCEL) return false; // don't change values if canceled for (unsigned int i = 0; i < texts.size(); ++i) { values[i].second = texts[i]->GetValue().ToAscii(); } + return true; } @@ -1006,6 +1128,17 @@ void SimpleDialog::show() { bool App::OnInit() { string fileparam; if(argc==2){ + if(argv[1][0]=='-') { // any flag gives help and exits program. + std::cout << "Glest map editor " << mapeditorVersionString << std::endl << std::endl; + std::cout << "glest_map_editor [GBM OR MGM FILE]" << std::endl << std::endl; + std::cout << "Creates or edits glest/megaglest maps." << std::endl; + std::cout << "Draw with left mouse button (select what and how large area in menu or toolbar)" << std::endl; + std::cout << "Pan trough the map with right mouse button" << std::endl; + std::cout << "Zoom with middle mouse button or mousewheel" << std::endl; +// std::cout << " ~ more helps should be written here ~" << std::endl; + std::cout << std::endl; + exit (0); + } fileparam = wxFNCONV(argv[1]); } @@ -1013,7 +1146,7 @@ bool App::OnInit() { mainWindow->Show(); mainWindow->init(fileparam); mainWindow->Update(); - + #ifdef WIN32 wxPoint pos = mainWindow->GetScreenPosition(); wxSize size = mainWindow->GetSize(); @@ -1028,7 +1161,7 @@ int App::MainLoop() { try { //throw runtime_error("test"); return wxApp::MainLoop(); - } + } catch (const exception &e) { MsgDialog(NULL, ToUnicode(e.what()), wxT("Exception")).ShowModal(); } @@ -1044,11 +1177,11 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString& caption, long style, const wxPoint& pos) { - + m_sizerText = NULL; // TODO: should we use main frame as parent by default here? if ( !wxDialog::Create(parent, wxID_ANY, caption, - pos, wxDefaultSize, + pos, wxDefaultSize, style) ) { return; } diff --git a/source/glest_map_editor/main.h b/source/glest_map_editor/main.h index 97515a9a..66973ae7 100644 --- a/source/glest_map_editor/main.h +++ b/source/glest_map_editor/main.h @@ -54,24 +54,24 @@ enum StatusItems { const char *object_descs[] = { "None (Erase)", "Tree", - "Dead Tree", - "Stone", + "Dead tree", + "Stone (non harvest)", "Bush", - "Water Object", - "Big/Dead Tree", - "Trophy Corpse", + "Water object", + "Big tree", + "Hanged/Impaled", "Statues", - "Big Rock", - "Invisible Blocking" + "Mountain", + "Invisible blocking" }; const char *resource_descs[] = { - "None (Erase)", "Gold", "Stone", "Custom", "Custom", "Custom" + "None (Erase)", "Gold", "Stone", "Custom 4", "Custom 5", "Custom 6" }; const char *surface_descs[] = { - "Grass", "Alt. Grass", "Road", "Stone", "Ground" + "Grass", "Sec. grass", "Road", "Stone", "Ground" }; // ===================================================== @@ -106,15 +106,25 @@ private: miEditResize, miEditFlipX, miEditFlipY, + + miEditMirrorX, + miEditMirrorY, + miEditMirrorXY, + miEditRotatecopyX, + miEditRotatecopyY, + miEditRotatecopyXY, + miEditRotatecopyCorner, + miEditMirror, + miEditRandomizeHeights, miEditRandomize, miEditSwitchSurfaces, miEditInfo, miEditAdvanced, - miMiscResetZoomAndPos, - miMiscAbout, - miMiscHelp, + miViewResetZoomAndPos, + miViewAbout, + miViewHelp, toolPlayer, @@ -134,11 +144,12 @@ private: int lastX, lastY; wxPanel *panel; - + wxMenuBar *menuBar; wxMenu *menuFile; wxMenu *menuEdit; - wxMenu *menuMisc; + wxMenu *menuEditMirror; + wxMenu *menuView; wxMenu *menuBrush; wxMenu *menuBrushHeight; wxMenu *menuBrushGradient; @@ -160,7 +171,7 @@ private: int startLocation; int resourceUnderMouse; int objectUnderMouse; - + ChangeType enabledGroup; string fileName; @@ -177,6 +188,8 @@ public: void onMouseDown(wxMouseEvent &event, int x, int y); void onMouseMove(wxMouseEvent &event, int x, int y); + void onMouseWheelDown(wxMouseEvent &event); + void onMouseWheelUp(wxMouseEvent &event); void onPaint(wxPaintEvent &event); void onKeyDown(wxKeyEvent &e); @@ -193,15 +206,24 @@ public: void onMenuEditResize(wxCommandEvent &event); void onMenuEditFlipX(wxCommandEvent &event); void onMenuEditFlipY(wxCommandEvent &event); + + void onMenuEditMirrorX(wxCommandEvent &event); // copy left to right + void onMenuEditMirrorY(wxCommandEvent &event); // copy top to bottom + void onMenuEditMirrorXY(wxCommandEvent &event); // copy bottomleft to topright + void onMenuEditRotatecopyX(wxCommandEvent &event); // copy left to right, rotated + void onMenuEditRotatecopyY(wxCommandEvent &event); // copy top to bottom, rotated + void onMenuEditRotatecopyXY(wxCommandEvent &event); // copy bottomleft to topright, rotated + void onMenuEditRotatecopyCorner(wxCommandEvent &event); // copy top left 1/4 to top right 1/4, rotated + void onMenuEditRandomizeHeights(wxCommandEvent &event); void onMenuEditRandomize(wxCommandEvent &event); void onMenuEditSwitchSurfaces(wxCommandEvent &event); void onMenuEditInfo(wxCommandEvent &event); void onMenuEditAdvanced(wxCommandEvent &event); - void onMenuMiscResetZoomAndPos(wxCommandEvent &event); - void onMenuMiscAbout(wxCommandEvent &event); - void onMenuMiscHelp(wxCommandEvent &event); + void onMenuViewResetZoomAndPos(wxCommandEvent &event); + void onMenuViewAbout(wxCommandEvent &event); + void onMenuViewHelp(wxCommandEvent &event); void onMenuBrushHeight(wxCommandEvent &event); void onMenuBrushGradient(wxCommandEvent &event); @@ -210,7 +232,7 @@ public: void onMenuBrushResource(wxCommandEvent &event); void onMenuBrushStartLocation(wxCommandEvent &event); void onMenuRadius(wxCommandEvent &event); - + void onToolPlayer(wxCommandEvent &event); void change(int x, int y); @@ -237,8 +259,9 @@ public: void onMouseDown(wxMouseEvent &event); void onMouseMove(wxMouseEvent &event); + void onMouseWheel(wxMouseEvent &event); void onKeyDown(wxKeyEvent &event); - + void onPaint(wxPaintEvent &event); private: MainWindow *mainWindow; }; @@ -255,10 +278,10 @@ private: Values values; public: - void addValue(const string &key, const string &value); + void addValue(const string &key, const string &value, const string &help=""); string getValue(const string &key); - void show(); + bool show(const string &title="Edit values", bool wide=false); }; // ===================================================== diff --git a/source/glest_map_editor/map.cpp b/source/glest_map_editor/map.cpp index bf32e348..ad74c9f2 100644 --- a/source/glest_map_editor/map.cpp +++ b/source/glest_map_editor/map.cpp @@ -9,6 +9,7 @@ // License, or (at your option) any later version // ============================================================== +// This file is not used anoymore #include "map.h" @@ -192,7 +193,7 @@ void Map::pirateChangeHeight(int x, int y, int height, int radius) { normI[1] = 2; } else if (normIf < 0) { normI[1] = 0; - } else /*(normIf == 0)*/ { + } else { // (normIf == 0) normI[1] = 1; } } else { @@ -217,7 +218,7 @@ void Map::pirateChangeHeight(int x, int y, int height, int radius) { normJ[1] = 2; } else if (normJf < 0) { normJ[1] = 0; - } else /*(normJf == 0)*/ { + } else { // (normJf == 0) normJ[1] = 1; } } else { @@ -316,6 +317,45 @@ void Map::flipY() { delete [] oldCells; } +void Map::mirrorX() { // copy left to right + for (int i = 0; i < w/2; i++) { + for (int j = 0; j < h; j++) { + cells[w-i-1][j].height = cells[i][j].height; + cells[w-i-1][j].object = cells[i][j].object; + cells[w-i-1][j].resource = cells[i][j].resource; + cells[w-i-1][j].surface = cells[i][j].surface; + } + } +} + +void Map::mirrorY() { // copy top to bottom + for (int i = 0; i < w; i++) { + for (int j = 0; j < h/2; j++) { + cells[i][h-j-1].height = cells[i][j].height; + cells[i][h-j-1].object = cells[i][j].object; + cells[i][h-j-1].resource = cells[i][j].resource; + cells[i][h-j-1].surface = cells[i][j].surface; + } + } +} + +void Map::mirrorXY() { // copy leftbottom to topright + for (int i = 0; i < w-1; i++) { + for (int j = i+1; j < h; j++) { + cells[i][j].height = cells[j][i].height; + cells[i][j].object = cells[j][i].object; + cells[i][j].resource = cells[j][i].resource; + cells[i][j].surface = cells[j][i].surface; + } + } +} +/* +void Map::rotatecopyX(); +void Map::rotatecopyY(); +void Map::rotatecopyXY(); +void Map::rotatecopyCorner(); +*/ + void Map::changeSurface(int x, int y, int surface, int radius) { int i, j; int dist; @@ -506,6 +546,7 @@ void Map::resetFactions(int maxPlayers) { throw runtime_error("Max Players must be in the range 1-8"); } + // perhaps we should NOT remove current starting posititons, since the user just want to change number of players.... if (startLocations != NULL) { delete [] startLocations; startLocations = NULL; @@ -762,3 +803,5 @@ void Map::applyNewHeight(float newHeight, int x, int y, int strenght) { } }// end namespace + + diff --git a/source/glest_map_editor/map.h b/source/glest_map_editor/map.h index 3c8926b5..e8ef2397 100644 --- a/source/glest_map_editor/map.h +++ b/source/glest_map_editor/map.h @@ -9,6 +9,8 @@ // License, or (at your option) any later version // ============================================================== +// This file is not used anoymore + #ifndef _MAPEDITOR_MAP_H_ #define _MAPEDITOR_MAP_H_ @@ -112,6 +114,13 @@ public: void flipX(); void flipY(); + void mirrorX(); + void mirrorY(); + void mirrorXY(); + void rotatecopyX(); + void rotatecopyY(); + void rotatecopyXY(); + void rotatecopyCorner(); void reset(int w, int h, float alt, int surf); void resize(int w, int h, float alt, int surf); void resetFactions(int maxFactions); diff --git a/source/glest_map_editor/program.cpp b/source/glest_map_editor/program.cpp index c3969b14..96e7d6af 100644 --- a/source/glest_map_editor/program.cpp +++ b/source/glest_map_editor/program.cpp @@ -14,6 +14,7 @@ #include "util.h" +#include using namespace Shared::Util; namespace MapEditor { @@ -24,7 +25,7 @@ namespace MapEditor { int UndoPoint::w = 0; int UndoPoint::h = 0; -UndoPoint::UndoPoint() +UndoPoint::UndoPoint() : change(ctNone) , surface(0) , object(0) @@ -252,6 +253,124 @@ void Program::flipY() { map->flipY(); } +void Program::mirrorX() { // copy left to right + int w=map->getW(); + int h=map->getH(); + for (int i = 0; i < w/2; i++) { + for (int j = 0; j < h; j++) { + map->copyXY(w-i-1,j , i,j); + } + } +} + +void Program::mirrorY() { // copy top to bottom + int w=map->getW(); + int h=map->getH(); + for (int i = 0; i < w; i++) { + for (int j = 0; j < h/2; j++) { + map->copyXY(i,h-j-1 , i,j); + } + } +} + +void Program::mirrorXY() { // copy leftbottom to topright, can handle non-sqaure maps + int w=map->getW(); + int h=map->getH(); + if (h==w) { + for (int i = 0; i < w-1; i++) { + for (int j = i+1; j < h; j++) { + map->copyXY(j,i , i,j); + } + } + } + // Non-sqaure maps: + else if (h < w) { // copy horizontal strips + int s=w/h; // 2 if twice as wide as heigh + for (int i = 0; i < w/s-1; i++) { + for (int j = i+1; j < h; j++) { + for (int p = 0; p < s; p++) map->copyXY(j*s+p,i , i*s+p,j); + } + } + } + else { // copy vertical strips + int s=h/w; // 2 if twice as heigh as wide + for (int i = 0; i < w-1; i++) { + for (int j = i+1; j < h/s; j++) { + for (int p = 0; p < s; p++) map->copyXY(j,i*s+p , i,j*s+p); + } + } + } +} + +void Program::rotatecopyX() { + int w=map->getW(); + int h=map->getH(); + for (int i = 0; i < w/2; i++) { + for (int j = 0; j < h; j++) { + map->copyXY(w-i-1,h-j-1 , i,j); + } + } +} + +void Program::rotatecopyY() { + int w=map->getW(); + int h=map->getH(); + for (int i = 0; i < w; i++) { + for (int j = 0; j < h/2; j++) { + map->copyXY(w-i-1,h-j-1 , i,j); + } + } +} + +void Program::rotatecopyXY() { + int w=map->getW(); + int h=map->getH(); + int sw=w/h; if(sw<1) sw=1; // x-squares per y + int sh=h/w; if(sh<1) sh=1; // y-squares per x + if (sh==1) + for (int j = 0; j < h-1; j++) { // row by row! + for (int i = j*sw; i < w; i++) { + map->copyXY(i,j , w-i-1,h-j-1); + } + } + else + for (int i = 0; i = 0; j--) { + map->copyXY(w-i-1,j , i,h-j-1); + } + } +} + +void Program::rotatecopyCorner() { // rotate top left 1/4 to top right 1/4 + int w=map->getW(); + int h=map->getH(); + if (h==w) { + for (int i = 0; i < w/2; i++) { + for (int j = 0; j < h/2; j++) { + map->copyXY(w-j-1,i , i,j); + } + } + } + // Non-sqaure maps: + else if (h < w) { // copy horizontal strips + int s=w/h; // 2 if twice as wide as heigh + for (int i = 0; i < w/s/2; i++) { + for (int j = 0; j < h/2; j++) { + for (int p = 0; p < s; p++) map->copyXY(w-j*s-1-p,i , i*s+p,j); + } + } + } + else { // copy vertical strips + int s=h/w; // 2 if twice as heigh as wide + for (int i = 0; i < w/2; i++) { + for (int j = 0; j < h/s/2; j++) { + for (int p = 0; p < s; p++) map->copyXY(w-j-1,i*s+p , i,j*s+p); + } + } + } +} + + void Program::randomizeMapHeights() { map->randomizeHeights(); } diff --git a/source/glest_map_editor/program.h b/source/glest_map_editor/program.h index 2e7b5dfc..4cfc78a0 100644 --- a/source/glest_map_editor/program.h +++ b/source/glest_map_editor/program.h @@ -125,6 +125,15 @@ public: void setRefAlt(int x, int y); void flipX(); void flipY(); + void mirrorX(); + void mirrorY(); + void mirrorXY(); + void rotatecopyX(); + void rotatecopyY(); + void rotatecopyXY(); + void rotatecopyCorner(); + + void randomizeMapHeights(); void randomizeMap(); void switchMapSurfaces(int surf1, int surf2); diff --git a/source/shared_lib/include/map/map_preview.h b/source/shared_lib/include/map/map_preview.h index aa201119..115cf6ce 100644 --- a/source/shared_lib/include/map/map_preview.h +++ b/source/shared_lib/include/map/map_preview.h @@ -150,6 +150,7 @@ public: void flipX(); void flipY(); + void copyXY(int x, int y, int sx, int sy); // destination x,y = source sx,sy void reset(int w, int h, float alt, MapSurfaceType surf); void resize(int w, int h, float alt, MapSurfaceType surf); void resetFactions(int maxFactions); diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index 2044be19..d8342f18 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -344,6 +344,14 @@ void MapPreview::flipY() { //delete [] oldCells; } +// Copy a cell in the map from one cell to another, used by MirrorXY etc +void MapPreview::copyXY(int x, int y, int sx, int sy) { + cells[x][y].height = cells[sx][sy].height; + cells[x][y].object = cells[sx][sy].object; + cells[x][y].resource = cells[sx][sy].resource; + cells[x][y].surface = cells[sx][sy].surface; +} + void MapPreview::changeSurface(int x, int y, MapSurfaceType surface, int radius) { int i, j; int dist;