[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src action_button.cxx,1.24,1.25 client.cx
From: |
grumbel |
Subject: |
[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 |
Date: |
20 Dec 2002 01:22:34 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv7667
Modified Files:
action_button.cxx client.cxx client.hxx game_delta.hxx
gui_screen.cxx gui_screen.hxx input_debug_screen.cxx
smallmap.cxx
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: action_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/action_button.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- action_button.cxx 5 Dec 2002 20:38:09 -0000 1.24
+++ action_button.cxx 20 Dec 2002 01:22:32 -0000 1.25
@@ -50,18 +50,18 @@
font = PingusResource::load_font("Fonts/pingus_small", "fonts");
font_b = PingusResource::load_font("Fonts/pingus", "fonts");
- sprite = Sprite("Pingus/" + action_to_string(name) + to_string(owner_id),
"pingus", 20.0f);
+ sprite = Sprite("Pingus/" + action_to_string(name) + to_string(owner_id),
"pingus", 25.0f);
sprite.set_align_center_bottom();
// FIXME: Big fat hack
if ( name == Digger || name == Bomber
|| name == Floater || name == Blocker)
{
- is_multi_direct = true;
+ is_multi_direct = false;
}
else
{
- is_multi_direct = false;
+ is_multi_direct = true;
}
}
Index: client.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.cxx,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- client.cxx 8 Nov 2002 01:38:27 -0000 1.35
+++ client.cxx 20 Dec 2002 01:22:32 -0000 1.36
@@ -41,9 +41,6 @@
// Input
#include "input/controller.hxx"
#include "input/event.hxx"
-#include "input/axis_event.hxx"
-#include "input/scroll_event.hxx"
-#include "input/button_event.hxx"
Client::Client (TrueServer * s)
: server (s),
@@ -112,31 +109,31 @@
void
Client::process_events (const GameDelta& delta)
{
- const std::list<Input::Event*>& events = delta.get_events ();
+ const Input::EventLst& events = delta.get_events ();
- for (std::list<Input::Event*>::const_iterator i = events.begin ();
+ for (Input::EventLst::const_iterator i = events.begin ();
i != events.end ();
++i)
{
//std::cout << "Events: " << (*i)->get_type () << std::endl;
- switch ((*i)->get_type ())
+ switch (i->type)
{
case Input::ButtonEventType:
{
- Input::ButtonEvent* ev = dynamic_cast<Input::ButtonEvent*
const>(*i);
+ const Input::ButtonEvent& ev = i->button;
- if (ev->state == Input::pressed)
+ if (ev.state == Input::pressed)
{
- if (ev->name >= Input::action_1 && ev->name <=
Input::action_10)
+ if (ev.name >= Input::action_1 && ev.name <= Input::action_10)
{
- button_panel->set_button(ev->name - Input::action_1);
+ button_panel->set_button(ev.name - Input::action_1);
}
- else if (ev->name == Input::action_down)
+ else if (ev.name == Input::action_down)
{
button_panel->next_action();
}
- else if (ev->name == Input::action_up)
+ else if (ev.name == Input::action_up)
{
button_panel->previous_action();
}
@@ -151,31 +148,31 @@
case Input::AxisEventType:
// ???
- process_axis_event (dynamic_cast<Input::AxisEvent* const>(*i));
+ process_axis_event (i->axis);
break;
case Input::ScrollEventType:
- process_scroll_event(dynamic_cast<Input::ScrollEvent* const>(*i));
+ process_scroll_event(i->scroll);
break;
default:
// unhandled event
- std::cout << "Client::process_events (): unhandled event: " <<
(*i)->get_type() << std::endl;
+ std::cout << "Client::process_events (): unhandled event: " <<
i->type << std::endl;
break;
}
}
}
void
-Client::process_scroll_event (Input::ScrollEvent* ev)
+Client::process_scroll_event (const Input::ScrollEvent& ev)
{
std::cout << "Client::process_scroll_event ()" << std::endl;
- playfield->scroll(static_cast<int>(ev->x_delta),
- static_cast<int>(ev->y_delta));
+ playfield->scroll(static_cast<int>(ev.x_delta),
+ static_cast<int>(ev.y_delta));
}
void
-Client::process_axis_event (Input::AxisEvent* event)
+Client::process_axis_event (const Input::AxisEvent& event)
{
std::cout << "Client::process_axis_event ()" << std::endl;
UNUSED_ARG(event);
Index: client.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/client.hxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- client.hxx 28 Oct 2002 20:13:40 -0000 1.24
+++ client.hxx 20 Dec 2002 01:22:32 -0000 1.25
@@ -111,8 +111,8 @@
private:
void process_events (const GameDelta& events);
- void process_scroll_event (Input::ScrollEvent*);
- void process_axis_event (Input::AxisEvent*);
+ void process_scroll_event (const Input::ScrollEvent&);
+ void process_axis_event (const Input::AxisEvent&);
Client (const Client&);
Client& operator= (const Client&);
Index: game_delta.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_delta.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- game_delta.hxx 27 Nov 2002 20:05:42 -0000 1.10
+++ game_delta.hxx 20 Dec 2002 01:22:32 -0000 1.11
@@ -23,11 +23,7 @@
#include <list>
#include "pingus.hxx"
#include "delta_manager.hxx"
-
-namespace Input
-{
- class Event;
-}
+#include "input/event.hxx"
/** Input for the game engine */
class GameDelta
@@ -38,12 +34,12 @@
/** Reference to the event list from the controller, we must not
delete the Event* */
- const std::list<Input::Event*>& events;
+ const Input::EventLst& events;
public:
/** Construct a GameDelta with both time and events */
GameDelta (const DeltaManager& d,
- const std::list<Input::Event*>& e)
+ const Input::EventLst& e)
: time_delta (d), events (e) {}
/** Return the time that has passed in seconds since the last update() */
@@ -54,7 +50,7 @@
unsigned int get_absolute_time () const { return time_delta.get_absolute(); }
/** Return the events */
- const std::list<Input::Event*>& get_events () const { return events; }
+ const Input::EventLst& get_events () const { return events; }
private:
GameDelta (const GameDelta&);
Index: gui_screen.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- gui_screen.cxx 1 Dec 2002 21:45:14 -0000 1.14
+++ gui_screen.cxx 20 Dec 2002 01:22:32 -0000 1.15
@@ -20,8 +20,6 @@
#include <iostream>
#include "globals.hxx"
#include "debug.hxx"
-#include "input/button_event.hxx"
-#include "input/axis_event.hxx"
#include "gui_screen.hxx"
#include "gui/gui_manager.hxx"
@@ -56,10 +54,10 @@
update (delta.get_time ());
- for (std::list<Input::Event*>::const_iterator i = delta.get_events ().begin
();
+ for (Input::EventLst::const_iterator i = delta.get_events ().begin ();
i != delta.get_events ().end (); ++i)
{
- switch ((*i)->get_type())
+ switch (i->type)
{
case Input::PointerEventType:
{
@@ -69,16 +67,15 @@
case Input::ButtonEventType:
{
- process_button_event (dynamic_cast<Input::ButtonEvent*>(*i));
+ process_button_event (i->button);
}
break;
case Input::AxisEventType:
{
- Input::AxisEvent* event = dynamic_cast<Input::AxisEvent*>(*i);
- if (event->name == Input::action)
+ if (i->axis.name == Input::action)
{
- on_action_axis_move (event->dir);
+ on_action_axis_move (i->axis.dir);
}
}
break;
@@ -90,20 +87,20 @@
break;
default:
- std::cout << "GUIScreen::update (): unhandled event type: " <<
(*i)->get_type() << std::endl;
+ std::cout << "GUIScreen::update (): unhandled event type: " <<
i->type << std::endl;
break;
}
}
}
void
-GUIScreen::process_button_event (const Input::ButtonEvent* event)
+GUIScreen::process_button_event (const Input::ButtonEvent& event)
{
//std::cout << "GUIScreen::process_button_event (Input::ButtonEvent* event)"
<< std::endl;
- if (event->state == Input::pressed)
+ if (event.state == Input::pressed)
{
- switch (event->name)
+ switch (event.name)
{
case Input::primary:
// ignoring, handled in the gui_manager
@@ -124,13 +121,13 @@
on_escape_press ();
break;
default:
- perr(PINGUS_DEBUG_GUI) << "GUIScreen: ButtonEvent: unhandled event: "
<< event->name << std::endl;
+ perr(PINGUS_DEBUG_GUI) << "GUIScreen: ButtonEvent: unhandled event: "
<< event.name << std::endl;
break;
}
}
- else if (event->state == Input::released)
+ else if (event.state == Input::released)
{
- switch (event->name)
+ switch (event.name)
{
case Input::primary:
// ignoring, handled in the gui_manager
@@ -151,14 +148,14 @@
on_escape_release ();
break;
default:
- perr(PINGUS_DEBUG_GUI) << "GUIScreen: ButtonEvent: unhandled event: "
<< event->name << std::endl;
+ perr(PINGUS_DEBUG_GUI) << "GUIScreen: ButtonEvent: unhandled event: "
<< event.name << std::endl;
break;
}
}
else
{
- perr(PINGUS_DEBUG_GUI) << "GUIScreen::process_button_event: got unknown
event->state: "
- << event->state << std::endl;;
+ perr(PINGUS_DEBUG_GUI) << "GUIScreen::process_button_event: got unknown
event.state: "
+ << event.state << std::endl;;
}
}
Index: gui_screen.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/gui_screen.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- gui_screen.hxx 28 Oct 2002 20:13:40 -0000 1.13
+++ gui_screen.hxx 20 Dec 2002 01:22:32 -0000 1.14
@@ -65,7 +65,7 @@
virtual void on_action_axis_move (float) {}
private:
- void process_button_event (const Input::ButtonEvent* event);
+ void process_button_event (const Input::ButtonEvent& event);
GUIScreen (const GUIScreen&);
GUIScreen& operator= (const GUIScreen&);
Index: input_debug_screen.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/input_debug_screen.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- input_debug_screen.cxx 31 Oct 2002 13:58:42 -0000 1.6
+++ input_debug_screen.cxx 20 Dec 2002 01:22:32 -0000 1.7
@@ -21,7 +21,7 @@
#include <iostream>
#include <ClanLib/Core/System/system.h>
#include "input/event.hxx"
-#include "input/scroll_event.hxx"
+//#include "input/scroll_event.hxx"
#include "input_debug_screen.hxx"
using namespace Input;
@@ -49,35 +49,33 @@
InputDebugScreen::update (const GameDelta& delta)
{
std::cout << "InputDebugScreen::update (" << delta.get_time () << ")" <<
std::endl;
- for (std::list<Input::Event*>::const_iterator i = delta.get_events ().begin
();
+ for (Input::EventLst::const_iterator i = delta.get_events ().begin ();
i != delta.get_events ().end ();
++i)
{
- switch((*i)->get_type())
+ switch(i->type)
{
case ButtonEventType:
- std::cout << "InputDebugScreen: Button event : " << (*i)->get_type()
<< std::endl;
+ std::cout << "InputDebugScreen: Button event : " << i->type <<
std::endl;
break;
case PointerEventType:
- std::cout << "InputDebugScreen: Pointer event : " <<
(*i)->get_type() << std::endl;
+ std::cout << "InputDebugScreen: Pointer event : " << i->type <<
std::endl;
break;
case AxisEventType:
- std::cout << "InputDebugScreen: Axis event : " << (*i)->get_type()
<< std::endl;
+ std::cout << "InputDebugScreen: Axis event : " << i->type <<
std::endl;
break;
case ScrollEventType:
{
- ScrollEvent* ev = dynamic_cast<ScrollEvent*>(*i);
- assert(ev);
std::cout << "InputDebugScreen: Scroll event : "
- << ev->x_delta << " " << ev->y_delta << std::endl;
+ << i->scroll.x_delta << " " << i->scroll.y_delta <<
std::endl;
}
break;
default:
- std::cout << "InputDebugScreen: Unknown event : " <<
(*i)->get_type() << std::endl;
+ std::cout << "InputDebugScreen: Unknown event : " << i->type <<
std::endl;
break;
}
}
Index: smallmap.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/smallmap.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- smallmap.cxx 26 Oct 2002 17:31:42 -0000 1.27
+++ smallmap.cxx 20 Dec 2002 01:22:32 -0000 1.28
@@ -189,10 +189,12 @@
sur.put_screen(x_pos, y_pos);
+#if 0
if (has_focus)
Display::draw_rect(x_pos, y_pos,
x_pos + sur.get_width (), y_pos + sur.get_height () - 1,
1.0f, 1.0f, 1.0f, 1.0f);
+#endif
x_of = x_pos - x_of * width /
client->get_server()->get_world()->get_colmap()->get_width();
[Prev in Thread] |
Current Thread |
[Next in 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,
grumbel <=
- Prev by Date:
[Pingus-CVS] [Bug #1999] Pingus Crashes with segmentation fault, while bashing out of right screen
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.17,1.18 gui_manager.hxx,1.12,1.13
- Previous by thread:
[Pingus-CVS] [Bug #1999] Pingus Crashes with segmentation fault, while bashing out of right screen
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.17,1.18 gui_manager.hxx,1.12,1.13
- Index(es):