- fixed CPU usage on windows for map editor
This commit is contained in:
parent
c85b8baa49
commit
75c50f1052
|
@ -54,7 +54,8 @@ MainWindow::MainWindow()
|
||||||
, enabledGroup(ctHeight)
|
, enabledGroup(ctHeight)
|
||||||
, fileModified(false)
|
, fileModified(false)
|
||||||
, menuBar(NULL)
|
, menuBar(NULL)
|
||||||
, panel(NULL) {
|
, panel(NULL)
|
||||||
|
, timer(NULL) {
|
||||||
|
|
||||||
this->panel = new wxPanel(this, wxID_ANY);
|
this->panel = new wxPanel(this, wxID_ANY);
|
||||||
|
|
||||||
|
@ -302,9 +303,11 @@ MainWindow::MainWindow()
|
||||||
//std::cout << "C" << std::endl;
|
//std::cout << "C" << std::endl;
|
||||||
SetIcon(icon);
|
SetIcon(icon);
|
||||||
|
|
||||||
|
lastPaintEvent.start();
|
||||||
|
|
||||||
//#ifndef WIN32
|
//#ifndef WIN32
|
||||||
timer = new wxTimer(this);
|
//timer = new wxTimer(this);
|
||||||
timer->Start(250);
|
//timer->Start(250);
|
||||||
//#endif
|
//#endif
|
||||||
glCanvas->SetFocus();
|
glCanvas->SetFocus();
|
||||||
}
|
}
|
||||||
|
@ -342,8 +345,8 @@ MainWindow::~MainWindow() {
|
||||||
if(timer != NULL) delete timer;
|
if(timer != NULL) delete timer;
|
||||||
timer = NULL;
|
timer = NULL;
|
||||||
|
|
||||||
delete program;
|
|
||||||
delete glCanvas;
|
delete glCanvas;
|
||||||
|
delete program;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setDirty(bool val) {
|
void MainWindow::setDirty(bool val) {
|
||||||
|
@ -430,6 +433,12 @@ void MainWindow::onMouseMove(wxMouseEvent &event, int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onPaint(wxPaintEvent &event) {
|
void MainWindow::onPaint(wxPaintEvent &event) {
|
||||||
|
if(lastPaintEvent.getMillis() < 100) {
|
||||||
|
sleep(5);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastPaintEvent.start();
|
||||||
|
|
||||||
if(panel) panel->Update();
|
if(panel) panel->Update();
|
||||||
if(menuBar) menuBar->Update();
|
if(menuBar) menuBar->Update();
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,12 @@
|
||||||
|
|
||||||
#include "program.h"
|
#include "program.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "platform_common.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
using namespace Shared::PlatformCommon;
|
||||||
|
|
||||||
namespace MapEditor {
|
namespace MapEditor {
|
||||||
|
|
||||||
|
@ -165,6 +167,7 @@ private:
|
||||||
|
|
||||||
string fileName;
|
string fileName;
|
||||||
bool fileModified;
|
bool fileModified;
|
||||||
|
Chrono lastPaintEvent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user