1
0
forked from 0ad/0ad

change to use new event handler interface

This was SVN commit r598.
This commit is contained in:
janwas 2004-06-24 14:06:24 +00:00
parent 74ad38fa95
commit a9e358b9bc
3 changed files with 23 additions and 21 deletions

View File

@ -52,16 +52,16 @@ void render(COverlayText* overlaytext)
// event is passed to other handlers if false is returned.
// trampoline: we don't want to make the implementation (in CGUI) static
//-------------------------------------------------------------------
bool gui_handler(const SDL_Event& ev)
int gui_handler(const SDL_Event* ev)
{
return g_GUI.HandleEvent(ev);
}
bool CGUI::HandleEvent(const SDL_Event& ev)
int CGUI::HandleEvent(const SDL_Event* ev)
{
if(ev.type == SDL_MOUSEMOTION)
if(ev->type == SDL_MOUSEMOTION)
{
m_MousePos = CPos(ev.motion.x, ev.motion.y);
m_MousePos = CPos(ev->motion.x, ev->motion.y);
// pNearest will after this point at the hovered object, possibly NULL
GUI<SGUIMessage>::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject,
@ -71,12 +71,12 @@ bool CGUI::HandleEvent(const SDL_Event& ev)
// TODO Gee: temp-stuff
// char buf[30];
// sprintf(buf, "type = %d", ev.type);
// sprintf(buf, "type = %d", ev->type);
//TEMPmessage = buf;
if (ev.type == SDL_MOUSEBUTTONDOWN)
if (ev->type == SDL_MOUSEBUTTONDOWN)
{
// sprintf(buf, "button = %d", ev.button.button);
// sprintf(buf, "button = %d", ev->button.button);
//TEMPmessage = buf;
}
@ -102,9 +102,9 @@ bool CGUI::HandleEvent(const SDL_Event& ev)
&IGUIObject::UpdateMouseOver,
pNearest);
if (ev.type == SDL_MOUSEBUTTONDOWN)
if (ev->type == SDL_MOUSEBUTTONDOWN)
{
switch (ev.button.button)
switch (ev->button.button)
{
case SDL_BUTTON_LEFT:
if (pNearest)
@ -159,9 +159,9 @@ bool CGUI::HandleEvent(const SDL_Event& ev)
}
else
if (ev.type == SDL_MOUSEBUTTONUP)
if (ev->type == SDL_MOUSEBUTTONUP)
{
if (ev.button.button == SDL_BUTTON_LEFT)
if (ev->button.button == SDL_BUTTON_LEFT)
{
if (pNearest)
pNearest->HandleMessage(SGUIMessage(GUIM_MOUSE_RELEASE_LEFT));
@ -191,7 +191,7 @@ bool CGUI::HandleEvent(const SDL_Event& ev)
}
*/
return false;
return EV_PASS;
}
//-------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ gee@pyro.nu
class XERCES_CPP_NAMESPACE::DOMElement;
extern bool gui_handler(const SDL_Event& ev);
extern int gui_handler(const SDL_Event* ev);
//--------------------------------------------------------
// Macros
@ -133,7 +133,7 @@ public:
*
* @param ev SDL Event, like mouse/keyboard input
*/
bool HandleEvent(const SDL_Event& ev);
int HandleEvent(const SDL_Event* ev);
/**
* Load a GUI XML file into the GUI.

View File

@ -11,6 +11,8 @@
#include "sdl.h"
#include "res/tex.h"
#include "detect.h"
#include "input.h"
#include "lib.h"
void InitScene ();
void InitResources ();
@ -287,23 +289,23 @@ void terr_update(const float DeltaTime)
bool terr_handler(const SDL_Event& ev)
int terr_handler(const SDL_Event* ev)
{
// put any events that must be processed even if inactive here
if(!active)
return false;
return EV_PASS;
switch(ev.type)
switch(ev->type)
{
case SDL_MOUSEMOTION:
mouse_x = ev.motion.x;
mouse_y = ev.motion.y;
mouse_x = ev->motion.x;
mouse_y = ev->motion.y;
break;
case SDL_KEYDOWN:
switch(ev.key.keysym.sym)
switch(ev->key.keysym.sym)
{
case SDLK_w:
if (g_Renderer.GetTerrainRenderMode()==WIREFRAME) {
@ -324,7 +326,7 @@ bool terr_handler(const SDL_Event& ev)
}
}
return false;
return EV_PASS;
}