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