- fix map editor in wx 3.0.2
This commit is contained in:
parent
d6dbb187cc
commit
236b95fc0d
|
@ -115,11 +115,6 @@ MainWindow::MainWindow(string appPath)
|
||||||
Properties::setApplicationPath(executable_path(appPath));
|
Properties::setApplicationPath(executable_path(appPath));
|
||||||
|
|
||||||
this->panel = new wxPanel(this, wxID_ANY);
|
this->panel = new wxPanel(this, wxID_ANY);
|
||||||
|
|
||||||
//gl canvas
|
|
||||||
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 };
|
|
||||||
glCanvas = new GlCanvas(this, this->panel, args);
|
|
||||||
glCanvas->SetFocus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onToolPlayer(wxCommandEvent& event){
|
void MainWindow::onToolPlayer(wxCommandEvent& event){
|
||||||
|
@ -440,10 +435,10 @@ void MainWindow::init(string fname) {
|
||||||
boxsizer = new wxBoxSizer(wxVERTICAL);
|
boxsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
boxsizer->Add(toolbar, 0, wxEXPAND);
|
boxsizer->Add(toolbar, 0, wxEXPAND);
|
||||||
boxsizer->Add(toolbar2, 0, wxEXPAND);
|
boxsizer->Add(toolbar2, 0, wxEXPAND);
|
||||||
boxsizer->Add(glCanvas, 1, wxEXPAND);
|
//boxsizer->Add(glCanvas, 1, wxEXPAND);
|
||||||
|
|
||||||
this->panel->SetSizer(boxsizer);
|
this->panel->SetSizer(boxsizer);
|
||||||
this->Layout();
|
//this->Layout();
|
||||||
|
|
||||||
//program = new Program(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y);
|
//program = new Program(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y);
|
||||||
|
|
||||||
|
@ -488,6 +483,20 @@ void MainWindow::onClose(wxCloseEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupStartupSettings() {
|
void MainWindow::setupStartupSettings() {
|
||||||
|
|
||||||
|
//gl canvas
|
||||||
|
if(glCanvas == NULL) {
|
||||||
|
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 };
|
||||||
|
glCanvas = new GlCanvas(this, this->panel, args);
|
||||||
|
|
||||||
|
boxsizer->Add(glCanvas, 1, wxEXPAND);
|
||||||
|
|
||||||
|
this->panel->SetSizer(boxsizer);
|
||||||
|
this->Layout();
|
||||||
|
}
|
||||||
|
glCanvas->setCurrentGLContext();
|
||||||
|
glCanvas->SetFocus();
|
||||||
|
|
||||||
string playerName = Config::getInstance().getString("NetPlayerName","");
|
string playerName = Config::getInstance().getString("NetPlayerName","");
|
||||||
program = new Program(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y, playerName);
|
program = new Program(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y, playerName);
|
||||||
fileName = "New (unsaved) Map";
|
fileName = "New (unsaved) Map";
|
||||||
|
@ -635,7 +644,11 @@ void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onPaint(wxPaintEvent &event) {
|
void MainWindow::onPaint(wxPaintEvent &event) {
|
||||||
|
//printf("onPaint map\n");
|
||||||
|
|
||||||
if(!IsShown()) {
|
if(!IsShown()) {
|
||||||
|
//printf("onPaint skip map\n");
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -652,11 +665,14 @@ void MainWindow::onPaint(wxPaintEvent &event) {
|
||||||
glCanvas->setCurrentGLContext();
|
glCanvas->setCurrentGLContext();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
//printf("lastPaintEvent.getMillis() map\n");
|
||||||
if(lastPaintEvent.getMillis() < 30) {
|
if(lastPaintEvent.getMillis() < 30) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
event.Skip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("wxPaintDC dc map\n");
|
||||||
wxPaintDC dc(this); // "In a paint event handler must always create a wxPaintDC object even if you do not use it. (?)
|
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"
|
// Otherwise, under MS Windows, refreshing for this and other windows will go wrong"
|
||||||
// http://docs.wxwidgets.org/2.6/wx_wxpaintevent.html
|
// http://docs.wxwidgets.org/2.6/wx_wxpaintevent.html
|
||||||
|
@ -671,6 +687,8 @@ void MainWindow::onPaint(wxPaintEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::refreshMapRender() {
|
void MainWindow::refreshMapRender() {
|
||||||
|
//printf("refreshMapRender map\n");
|
||||||
|
|
||||||
if(program && glCanvas) {
|
if(program && glCanvas) {
|
||||||
program->renderMap(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y);
|
program->renderMap(glCanvas->GetClientSize().x, glCanvas->GetClientSize().y);
|
||||||
glCanvas->SwapBuffers();
|
glCanvas->SwapBuffers();
|
||||||
|
@ -1550,6 +1568,7 @@ void GlCanvas::onPaint(wxPaintEvent &event) {
|
||||||
// mainWindow->program->renderMap(GetClientSize().x, GetClientSize().y);
|
// mainWindow->program->renderMap(GetClientSize().x, GetClientSize().y);
|
||||||
// SwapBuffers();
|
// SwapBuffers();
|
||||||
// event.Skip();
|
// event.Skip();
|
||||||
|
//printf("gl onPaint skip map\n");
|
||||||
mainWindow->onPaint(event);
|
mainWindow->onPaint(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,6 +265,7 @@ bool Program::redo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Program::renderMap(int w, int h) {
|
void Program::renderMap(int w, int h) {
|
||||||
|
//printf("Rendering map\n");
|
||||||
if(map) renderer.renderMap(map, ofsetX, ofsetY, w, h, cellSize, grid,heightmap,hideWater);
|
if(map) renderer.renderMap(map, ofsetX, ofsetY, w, h, cellSize, grid,heightmap,hideWater);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue