[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.17,1.18 gui_man
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.17,1.18 gui_manager.hxx,1.12,1.13 |
Date: |
20 Dec 2002 01:22:34 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/gui
In directory dark:/tmp/cvs-serv7667/gui
Modified Files:
gui_manager.cxx gui_manager.hxx
Log Message:
replaced input classes with a union, this makes all those ugly new/delete stuff
obsolete and makes the code quite a bit more readable (no cast, etc.)
Index: gui_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/gui_manager.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- gui_manager.cxx 5 Dec 2002 20:38:10 -0000 1.17
+++ gui_manager.cxx 20 Dec 2002 01:22:32 -0000 1.18
@@ -19,9 +19,7 @@
#include "../debug.hxx"
#include "../globals.hxx"
-#include "../input/axis_event.hxx"
-#include "../input/button_event.hxx"
-#include "../input/pointer_event.hxx"
+#include "../input/event.hxx"
#include "../game_delta.hxx"
#include "gui_manager.hxx"
@@ -62,34 +60,27 @@
void
GUIManager::process_input (const GameDelta& delta)
{
- const std::list<Input::Event*>& events = delta.get_events();
+ const std::vector<Input::Event>& events = delta.get_events();
- for (std::list<Event*>::const_iterator i = events.begin (); i != events.end
(); ++i)
+ for (std::vector<Input::Event>::const_iterator i = events.begin (); i !=
events.end (); ++i)
{
- switch ((*i)->get_type())
+ switch (i->type)
{
case Input::PointerEventType:
- {
- PointerEvent* event = dynamic_cast<PointerEvent*>(*i);
- process_pointer_event (event);
- break;
- }
+ process_pointer_event (i->pointer);
+ break;
+
case Input::ButtonEventType:
- {
- ButtonEvent* event = dynamic_cast<ButtonEvent*>(*i);
- process_button_event (delta.get_absolute_time(), event);
- break;
- }
-
+ process_button_event (delta.get_absolute_time(), i->button);
+ break;
+
case Input::AxisEventType:
- { // AxisEvents can be ignored in the GUI, they are handled elsewhere
- AxisEvent* event = dynamic_cast<AxisEvent*>(*i);
- pout (PINGUS_DEBUG_GUI) << "GUIManager: AxisEvent: " << event->dir
<< std::endl;
- break;
- }
-
+ // AxisEvents can be ignored in the GUI, they are handled elsewhere
+ pout (PINGUS_DEBUG_GUI) << "GUIManager: AxisEvent: " << i->axis.dir
<< std::endl;
+ break;
+
default:
- pwarn (PINGUS_DEBUG_GUI) << "GUIManager: unhandled event type " <<
(*i)->get_type() << std::endl;
+ pwarn (PINGUS_DEBUG_GUI) << "GUIManager: unhandled event type " <<
i->type << std::endl;
break;
}
}
@@ -137,10 +128,10 @@
}
void
-GUIManager::process_pointer_event (Input::PointerEvent* event)
+GUIManager::process_pointer_event (const Input::PointerEvent& event)
{
- x_pos = static_cast<int>(event->x);
- y_pos = static_cast<int>(event->y);
+ x_pos = static_cast<int>(event.x);
+ y_pos = static_cast<int>(event.y);
Component* comp = component_at(x_pos, y_pos);//FIXME
@@ -178,22 +169,22 @@
}
void
-GUIManager::process_button_event (unsigned int time_stamp, Input::ButtonEvent*
event)
+GUIManager::process_button_event (unsigned int time_stamp, const
Input::ButtonEvent& event)
{
- //std::cout << "GUIManager: Got button event: " << event->name << " " <<
event->state << std::endl;
+ //std::cout << "GUIManager: Got button event: " << event.name << " " <<
event.state << std::endl;
Component* comp = component_at (x_pos, y_pos);//FIXME: x/y_pos should be
inside controller
if (comp)
{
- if (event->name == primary && event->state == Input::pressed)
+ if (event.name == primary && event.state == Input::pressed)
{
primary_pressed_component = comp;
comp->on_primary_button_press (x_pos, y_pos);
// FIXME: add double click detection here
}
- else if (event->name == primary && event->state == Input::released)
+ else if (event.name == primary && event.state == Input::released)
{
/** Send the release event to the same component
which got the press event */
@@ -224,12 +215,12 @@
}
// Secondary button
- if (event->name == secondary && event->state == Input::pressed)
+ if (event.name == secondary && event.state == Input::pressed)
{
secondary_pressed_component = comp;
comp->on_secondary_button_press (x_pos, y_pos);
}
- else if (event->name == secondary && event->state == Input::released)
+ else if (event.name == secondary && event.state == Input::released)
{
/** Send the release event to the same component
which got the press event */
Index: gui_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui/gui_manager.hxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- gui_manager.hxx 27 Nov 2002 20:05:42 -0000 1.12
+++ gui_manager.hxx 20 Dec 2002 01:22:32 -0000 1.13
@@ -21,18 +21,11 @@
#define HEADER_PINGUS_GUI_GUI_MANAGER_HXX
#include <vector>
-#include <list>
+#include "../input/event.hxx"
#include "component.hxx"
class GameDelta;
-namespace Input
-{
- class Event;
- class PointerEvent;
- class ButtonEvent;
-}
-
namespace GUI
{
/** The GUIManager class holds a group of components and manages
@@ -62,8 +55,8 @@
int y_pos;
void process_input (const GameDelta& delta);
- void process_pointer_event (Input::PointerEvent* event);
- void process_button_event (unsigned int time_stamp, Input::ButtonEvent*
event);
+ void process_pointer_event (const Input::PointerEvent& event);
+ void process_button_event (unsigned int time_stamp, const
Input::ButtonEvent& event);
public:
GUIManager ();
virtual ~GUIManager () {}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.17,1.18 gui_manager.hxx,1.12,1.13,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.24,1.25 client.cxx,1.35,1.36 client.hxx,1.24,1.25 game_delta.hxx,1.10,1.11 gui_screen.cxx,1.14,1.15 gui_screen.hxx,1.13,1.14 input_debug_screen.cxx,1.6,1.7 smallmap.cxx,1.27,1.28
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/input Makefile.am,1.20,1.21 controller.cxx,1.25,1.26 controller.hxx,1.16,1.17 event.hxx,1.6,1.7 axis_event.hxx,1.4,NONE button_event.hxx,1.5,NONE pointer_event.hxx,1.4,NONE scroll_event.hxx,1.3,NONE
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.24,1.25 client.cxx,1.35,1.36 client.hxx,1.24,1.25 game_delta.hxx,1.10,1.11 gui_screen.cxx,1.14,1.15 gui_screen.hxx,1.13,1.14 input_debug_screen.cxx,1.6,1.7 smallmap.cxx,1.27,1.28
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/input Makefile.am,1.20,1.21 controller.cxx,1.25,1.26 controller.hxx,1.16,1.17 event.hxx,1.6,1.7 axis_event.hxx,1.4,NONE button_event.hxx,1.5,NONE pointer_event.hxx,1.4,NONE scroll_event.hxx,1.3,NONE
- Index(es):