allow lua mousepress event to cancel drawing, fixes #229
This commit is contained in:
parent
5bb1d484d0
commit
a801f0a0b4
@ -727,6 +727,11 @@ bool GameController::KeyRelease(int key, Uint16 character, bool shift, bool ctrl
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GameController::MouseTick()
|
||||||
|
{
|
||||||
|
return commandInterface->OnMouseTick();
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::Tick()
|
void GameController::Tick()
|
||||||
{
|
{
|
||||||
if(firstTick)
|
if(firstTick)
|
||||||
|
@ -68,6 +68,7 @@ public:
|
|||||||
bool MouseWheel(int x, int y, int d);
|
bool MouseWheel(int x, int y, int d);
|
||||||
bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
bool KeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
bool KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
bool KeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
|
bool MouseTick();
|
||||||
void Tick();
|
void Tick();
|
||||||
void Exit();
|
void Exit();
|
||||||
|
|
||||||
|
@ -1729,6 +1729,19 @@ void GameView::DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo
|
|||||||
Window::DoKeyRelease(key, character, shift, ctrl, alt);
|
Window::DoKeyRelease(key, character, shift, ctrl, alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameView::DoTick(float dt)
|
||||||
|
{
|
||||||
|
//mouse events trigger every frame when mouse is held down, needs to happen here (before things are drawn) so it can clear the point queue if false is returned from a lua mouse event
|
||||||
|
if (!c->MouseTick())
|
||||||
|
{
|
||||||
|
isMouseDown = false;
|
||||||
|
drawMode = DrawPoints;
|
||||||
|
while (!pointQueue.empty())
|
||||||
|
pointQueue.pop();
|
||||||
|
}
|
||||||
|
Window::DoTick(dt);
|
||||||
|
}
|
||||||
|
|
||||||
void GameView::DoDraw()
|
void GameView::DoDraw()
|
||||||
{
|
{
|
||||||
Window::DoDraw();
|
Window::DoDraw();
|
||||||
|
@ -188,6 +188,7 @@ public:
|
|||||||
virtual void OnBlur();
|
virtual void OnBlur();
|
||||||
|
|
||||||
//Top-level handlers, for Lua interface
|
//Top-level handlers, for Lua interface
|
||||||
|
virtual void DoTick(float dt);
|
||||||
virtual void DoDraw();
|
virtual void DoDraw();
|
||||||
virtual void DoMouseMove(int x, int y, int dx, int dy);
|
virtual void DoMouseMove(int x, int y, int dx, int dy);
|
||||||
virtual void DoMouseDown(int x, int y, unsigned button);
|
virtual void DoMouseDown(int x, int y, unsigned button);
|
||||||
|
@ -29,7 +29,8 @@ public:
|
|||||||
virtual bool OnMouseWheel(int x, int y, int d) {return true;}
|
virtual bool OnMouseWheel(int x, int y, int d) {return true;}
|
||||||
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
|
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
|
||||||
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
|
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) {return true;}
|
||||||
virtual void OnTick() {}
|
virtual bool OnMouseTick() { return true; }
|
||||||
|
virtual void OnTick() { }
|
||||||
virtual int Command(std::string command);
|
virtual int Command(std::string command);
|
||||||
virtual std::string FormatCommand(std::string command);
|
virtual std::string FormatCommand(std::string command);
|
||||||
std::string GetLastError();
|
std::string GetLastError();
|
||||||
|
@ -3004,14 +3004,20 @@ bool LuaScriptInterface::OnKeyRelease(int key, Uint16 character, bool shift, boo
|
|||||||
return luacon_keyevent(key, modifiers, LUACON_KUP);
|
return luacon_keyevent(key, modifiers, LUACON_KUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LuaScriptInterface::OnMouseTick()
|
||||||
|
{
|
||||||
|
ui::Engine::Ref().LastTick(gettime());
|
||||||
|
if (luacon_mousedown)
|
||||||
|
return luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void LuaScriptInterface::OnTick()
|
void LuaScriptInterface::OnTick()
|
||||||
{
|
{
|
||||||
lua_getglobal(l, "simulation");
|
lua_getglobal(l, "simulation");
|
||||||
lua_pushinteger(l, luacon_sim->NUM_PARTS); lua_setfield(l, -2, "NUM_PARTS");
|
lua_pushinteger(l, luacon_sim->NUM_PARTS); lua_setfield(l, -2, "NUM_PARTS");
|
||||||
lua_pop(l, 1);
|
lua_pop(l, 1);
|
||||||
ui::Engine::Ref().LastTick(gettime());
|
ui::Engine::Ref().LastTick(gettime());
|
||||||
if(luacon_mousedown)
|
|
||||||
luacon_mouseevent(luacon_mousex, luacon_mousey, luacon_mousebutton, LUACON_MPRESS, 0);
|
|
||||||
luacon_step(luacon_mousex, luacon_mousey);
|
luacon_step(luacon_mousex, luacon_mousey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@ public:
|
|||||||
virtual bool OnMouseWheel(int x, int y, int d);
|
virtual bool OnMouseWheel(int x, int y, int d);
|
||||||
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
virtual bool OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
virtual bool OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt);
|
||||||
|
virtual bool OnMouseTick();
|
||||||
virtual void OnTick();
|
virtual void OnTick();
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void SetWindow(ui::Window * window);
|
virtual void SetWindow(ui::Window * window);
|
||||||
|
Loading…
Reference in New Issue
Block a user