From a9e358b9bc46e40a861057abf8617b8f39f3a741 Mon Sep 17 00:00:00 2001 From: janwas Date: Thu, 24 Jun 2004 14:06:24 +0000 Subject: [PATCH] change to use new event handler interface This was SVN commit r598. --- source/gui/CGUI.cpp | 24 ++++++++++++------------ source/gui/CGUI.h | 4 ++-- source/terrain/terrainMain.cpp | 16 +++++++++------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 061b6f99e4..7b5317c37a 100755 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -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::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; } //------------------------------------------------------------------- diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h index bb34ca6cad..6cb11321db 100755 --- a/source/gui/CGUI.h +++ b/source/gui/CGUI.h @@ -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. diff --git a/source/terrain/terrainMain.cpp b/source/terrain/terrainMain.cpp index d2b8d8a7d3..aa5dce4373 100755 --- a/source/terrain/terrainMain.cpp +++ b/source/terrain/terrainMain.cpp @@ -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; }