[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3623 - in trunk/pingus/src: . editor gui screen
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3623 - in trunk/pingus/src: . editor gui screen |
Date: |
Wed, 2 Jul 2008 20:00:00 +0200 |
Author: grumbel
Date: 2008-07-02 19:59:58 +0200 (Wed, 02 Jul 2008)
New Revision: 3623
Removed:
trunk/pingus/src/dummy_screen.hpp
trunk/pingus/src/screen/game_delta.hpp
Modified:
trunk/pingus/src/addon_menu.cpp
trunk/pingus/src/addon_menu.hpp
trunk/pingus/src/demo_session.cpp
trunk/pingus/src/demo_session.hpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/editor_screen.hpp
trunk/pingus/src/editor/object_properties.cpp
trunk/pingus/src/editor/object_selector.cpp
trunk/pingus/src/font_test_screen.cpp
trunk/pingus/src/font_test_screen.hpp
trunk/pingus/src/game_session.cpp
trunk/pingus/src/game_session.hpp
trunk/pingus/src/gui/gui_manager.cpp
trunk/pingus/src/gui/gui_manager.hpp
trunk/pingus/src/option_menu.cpp
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/pingus_menu_manager.cpp
trunk/pingus/src/pingus_menu_manager.hpp
trunk/pingus/src/screen/gui_screen.cpp
trunk/pingus/src/screen/gui_screen.hpp
trunk/pingus/src/screen/screen.hpp
trunk/pingus/src/screen/screen_manager.cpp
Log:
Removed GameDelta, give Events one by one to the Screen and thus avoid the
accidental double push of Screens
Modified: trunk/pingus/src/addon_menu.cpp
===================================================================
--- trunk/pingus/src/addon_menu.cpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/addon_menu.cpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -36,12 +36,6 @@
}
void
-AddOnMenu::update(const GameDelta& delta)
-{
- GUIScreen::update(delta);
-}
-
-void
AddOnMenu::draw_background(DrawingContext& gc)
{
// gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
@@ -64,7 +58,7 @@
void
AddOnMenu::on_escape_press()
{
- std::cout << "OptionMenu: poping screen" << std::endl;
+ //std::cout << "OptionMenu: poping screen" << std::endl;
ScreenManager::instance()->pop_screen();
}
Modified: trunk/pingus/src/addon_menu.hpp
===================================================================
--- trunk/pingus/src/addon_menu.hpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/addon_menu.hpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -50,7 +50,6 @@
~AddOnMenu();
void draw_background (DrawingContext& gc);
- void update (const GameDelta& delta);
void on_escape_press ();
private:
Modified: trunk/pingus/src/demo_session.cpp
===================================================================
--- trunk/pingus/src/demo_session.cpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/demo_session.cpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -19,6 +19,8 @@
#include <boost/function.hpp>
#include <boost/bind.hpp>
+#include <iostream>
+
#include "math.hpp"
#include "server.hpp"
#include "pathname.hpp"
Modified: trunk/pingus/src/demo_session.hpp
===================================================================
--- trunk/pingus/src/demo_session.hpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/demo_session.hpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -25,6 +25,11 @@
#include <vector>
#include "server_event.hpp"
+namespace Input {
+class Event;
+class ScrollEvent;
+}
+
class Server;
class XMLPDF;
class DemoPlayer;
Deleted: trunk/pingus/src/dummy_screen.hpp
===================================================================
--- trunk/pingus/src/dummy_screen.hpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/dummy_screen.hpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -1,52 +0,0 @@
-// $Id$
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef HEADER_PINGUS_DUMMY_SCREEN_HPP
-#define HEADER_PINGUS_DUMMY_SCREEN_HPP
-
-#include "screen/screen.hpp"
-
-
-class DrawingContext;
-
-/** DummyScreen without any actual functionality, just for testing */
-class DummyScreen : public Screen
-{
-private:
-
-public:
- DummyScreen () { }
- virtual ~DummyScreen () {}
-
- /** Draw this screen @return true if draw was successfull, false if
- frameskip has taken place ('causes a skip of flip_display) */
- bool draw (DrawingContext& gc) { return 0; }
-
- /** Pass a delta to the screen */
- void update (const GameDelta& delta) {}
-
-private:
- DummyScreen (const DummyScreen&);
- DummyScreen& operator= (const DummyScreen&);
-};
-
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/editor/editor_screen.cpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -247,27 +247,21 @@
}
void
-EditorScreen::update(const GameDelta &delta)
+EditorScreen::update(const Input::Event& event)
{
- GUIScreen::update(delta);
+ GUIScreen::update(event);
- const Input::EventLst& events = delta.get_events ();
- for (Input::EventLst::const_iterator i = events.begin ();
- i != events.end ();
- ++i)
+ switch (event.type)
{
- switch (i->type)
- {
- case Input::SCROLLER_EVENT_TYPE:
- viewport->set_scroll_pos(viewport->get_scroll_pos() -
- Vector2f(i->scroll.x_delta,
- i->scroll.y_delta));
- break;
+ case Input::SCROLLER_EVENT_TYPE:
+ viewport->set_scroll_pos(viewport->get_scroll_pos() -
+ Vector2f(event.scroll.x_delta,
+ event.scroll.y_delta));
+ break;
- default:
- // other events are for most part handled by the
GUIScreen/GUIManager
- break;
- }
+ default:
+ // other events are for most part handled by the GUIScreen/GUIManager
+ break;
}
}
Modified: trunk/pingus/src/editor/editor_screen.hpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.hpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/editor/editor_screen.hpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -80,7 +80,7 @@
bool draw (DrawingContext& gc);
/** Update the GUI objects */
- void update (const GameDelta& delta);
+ void update(const Input::Event& delta);
/** Return the gui_manager */
GUI::GUIManager* get_gui_manager() const { return gui_manager; }
Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp 2008-07-02 05:15:35 UTC
(rev 3622)
+++ trunk/pingus/src/editor/object_properties.cpp 2008-07-02 17:59:58 UTC
(rev 3623)
@@ -18,6 +18,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <boost/bind.hpp>
+#include <iostream>
+
#include "string_util.hpp"
#include "button.hpp"
#include "editor_screen.hpp"
Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/editor/object_selector.cpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -18,6 +18,8 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <boost/bind.hpp>
+#include <iostream>
+
#include "display/display.hpp"
#include "gui_style.hpp"
#include "sprite.hpp"
Modified: trunk/pingus/src/font_test_screen.cpp
===================================================================
--- trunk/pingus/src/font_test_screen.cpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/font_test_screen.cpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -17,6 +17,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <iostream>
+
+#include "input/event.hpp"
#include "fonts.hpp"
#include "string_util.hpp"
#include "display/drawing_context.hpp"
@@ -99,31 +102,24 @@
}
void
-FontTestScreen::update(const GameDelta& delta)
+FontTestScreen::update(const Input::Event& event)
{
- const Input::EventLst& events = delta.get_events ();
-
- for (Input::EventLst::const_iterator i = events.begin ();
- i != events.end ();
- ++i)
+ switch (event.type)
{
- switch (i->type)
- {
- case Input::BUTTON_EVENT_TYPE:
- if (i->button.state == Input::BUTTON_PRESSED &&
- i->button.name == Input::PRIMARY_BUTTON)
- dark = !dark;
- break;
+ case Input::BUTTON_EVENT_TYPE:
+ if (event.button.state == Input::BUTTON_PRESSED &&
+ event.button.name == Input::PRIMARY_BUTTON)
+ dark = !dark;
+ break;
- case Input::SCROLLER_EVENT_TYPE:
- scrollx += i->scroll.x_delta;
- scrolly += i->scroll.y_delta;
- break;
+ case Input::SCROLLER_EVENT_TYPE:
+ scrollx += event.scroll.x_delta;
+ scrolly += event.scroll.y_delta;
+ break;
- default:
- break;
- }
- }
-}
+ default:
+ break;
+ }
+}
/* EOF */
Modified: trunk/pingus/src/font_test_screen.hpp
===================================================================
--- trunk/pingus/src/font_test_screen.hpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/font_test_screen.hpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -36,7 +36,8 @@
FontTestScreen(const Pathname& fontfile);
bool draw(DrawingContext& gc);
- void update (const GameDelta& delta);
+ void update(const Input::Event& event);
+ void update(float delta) {}
private:
FontTestScreen (const FontTestScreen&);
Modified: trunk/pingus/src/game_session.cpp
===================================================================
--- trunk/pingus/src/game_session.cpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/game_session.cpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -28,7 +28,7 @@
#include "components/time_display.hpp"
#include "components/smallmap.hpp"
#include "components/playfield.hpp"
-
+#include "input/event.hpp"
#include "sound/sound.hpp"
#include "math.hpp"
#include "game_session.hpp"
@@ -192,69 +192,63 @@
}
void
-GameSession::update (const GameDelta& delta)
+GameSession::update(float delta)
{
- update_server(delta.get_time());
+ update_server(delta);
GUIScreen::update(delta);
- process_events(delta);
}
void
-GameSession::process_events (const GameDelta& delta)
+GameSession::update(const Input::Event& event)
{
- const Input::EventLst& events = delta.get_events();
+ GUIScreen::update(event);
- for (Input::EventLst::const_iterator i = events.begin();
- i != events.end();
- ++i)
+ //std::cout << "Events: " << event.get_type () << std::endl;
+
+ switch (event.type)
{
- //std::cout << "Events: " << (*i)->get_type () << std::endl;
+ case Input::BUTTON_EVENT_TYPE:
+ {
+ const Input::ButtonEvent& ev = event.button;
- switch (i->type)
- {
- case Input::BUTTON_EVENT_TYPE:
- {
- const Input::ButtonEvent& ev = i->button;
+ if (ev.state == Input::BUTTON_PRESSED)
+ {
+ if (ev.name >= Input::ACTION_1_BUTTON && ev.name <=
Input::ACTION_10_BUTTON)
+ {
+ button_panel->set_button(ev.name - Input::ACTION_1_BUTTON);
+ }
+ else if (ev.name == Input::ACTION_DOWN_BUTTON)
+ {
+ button_panel->next_action();
+ }
+ else if (ev.name == Input::ACTION_UP_BUTTON)
+ {
+ button_panel->previous_action();
+ }
+ }
+ }
+ break;
- if (ev.state == Input::BUTTON_PRESSED)
- {
- if (ev.name >= Input::ACTION_1_BUTTON && ev.name <=
Input::ACTION_10_BUTTON)
- {
- button_panel->set_button(ev.name - Input::ACTION_1_BUTTON);
- }
- else if (ev.name == Input::ACTION_DOWN_BUTTON)
- {
- button_panel->next_action();
- }
- else if (ev.name == Input::ACTION_UP_BUTTON)
- {
- button_panel->previous_action();
- }
- }
- }
- break;
+ case Input::POINTER_EVENT_TYPE:
+ // Ignore, is handled in GUIScreen
+ break;
- case Input::POINTER_EVENT_TYPE:
- // Ignore, is handled in GUIScreen
- break;
+ case Input::AXIS_EVENT_TYPE:
+ // ???
+ process_axis_event (event.axis);
+ break;
- case Input::AXIS_EVENT_TYPE:
- // ???
- process_axis_event (i->axis);
- break;
+ case Input::SCROLLER_EVENT_TYPE:
+ process_scroll_event(event.scroll);
+ break;
- case Input::SCROLLER_EVENT_TYPE:
- process_scroll_event(i->scroll);
- break;
+ case Input::KEYBOARD_EVENT_TYPE:
+ break;
- case Input::KEYBOARD_EVENT_TYPE:
- break;
-
- default:
- // unhandled event
- std::cout << "GameSession::process_events (): unhandled event: " <<
i->type << std::endl;
- break;
- }
+ default:
+ // unhandled event
+ std::cout << "GameSession::process_events (): unhandled event: " <<
event.type << std::endl;
+ break;
}
}
Modified: trunk/pingus/src/game_session.hpp
===================================================================
--- trunk/pingus/src/game_session.hpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/game_session.hpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -26,6 +26,12 @@
#include "pingus_level.hpp"
#include "pingu_enums.hpp"
+namespace Input {
+class ScrollEvent;
+class AxisEvent;
+class Event;
+}
+
class ButtonPanel;
class PingusCounter;
class Playfield;
@@ -78,7 +84,8 @@
void set_finished();
/** Update all parts of the world */
- void update (const GameDelta&);
+ void update (float delta);
+ void update (const Input::Event& event);
void draw_background (DrawingContext& gc);
ButtonPanel* get_button_panel () { return button_panel; }
@@ -102,7 +109,6 @@
bool get_pause() const;
private:
- void process_events (const GameDelta& events);
void process_scroll_event (const Input::ScrollEvent&);
void process_axis_event (const Input::AxisEvent&);
Modified: trunk/pingus/src/gui/gui_manager.cpp
===================================================================
--- trunk/pingus/src/gui/gui_manager.cpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/gui/gui_manager.cpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -22,7 +22,6 @@
#include "../globals.hpp"
#include "../input/event.hpp"
#include "display/display.hpp"
-#include "screen/game_delta.hpp"
#include "gui_manager.hpp"
using namespace Input;
@@ -44,62 +43,57 @@
GUIManager::~GUIManager ()
{
}
+
void
-GUIManager::update(const GameDelta& delta)
+GUIManager::update(float delta)
{
- process_input (delta);
- GroupComponent::update(delta.get_time());
+ GroupComponent::update(delta);
}
void
-GUIManager::process_input(const GameDelta& delta)
+GUIManager::update(const Input::Event& event)
{
- const std::vector<Input::Event>& events = delta.get_events();
-
- for (std::vector<Input::Event>::const_iterator i = events.begin (); i !=
events.end (); ++i)
+ switch (event.type)
{
- switch (i->type)
- {
- case Input::POINTER_EVENT_TYPE:
- mouse_pos.x = int(i->pointer.x);
- mouse_pos.y = int(i->pointer.y);
- on_pointer_move(mouse_pos.x, mouse_pos.y);
- break;
+ case Input::POINTER_EVENT_TYPE:
+ mouse_pos.x = int(event.pointer.x);
+ mouse_pos.y = int(event.pointer.y);
+ on_pointer_move(mouse_pos.x, mouse_pos.y);
+ break;
- case Input::BUTTON_EVENT_TYPE:
- if (i->button.name == PRIMARY_BUTTON)
- {
- if (i->button.state == Input::BUTTON_PRESSED)
- on_primary_button_press(mouse_pos.x, mouse_pos.y);
- else if (i->button.state == Input::BUTTON_RELEASED)
- on_primary_button_release(mouse_pos.x, mouse_pos.y);
- }
- else if (i->button.name == SECONDARY_BUTTON)
- {
- if (i->button.state == Input::BUTTON_PRESSED)
- on_secondary_button_press(mouse_pos.x, mouse_pos.y);
- else if (i->button.state == Input::BUTTON_RELEASED)
- on_secondary_button_release(mouse_pos.x, mouse_pos.y);
- }
- break;
+ case Input::BUTTON_EVENT_TYPE:
+ if (event.button.name == PRIMARY_BUTTON)
+ {
+ if (event.button.state == Input::BUTTON_PRESSED)
+ on_primary_button_press(mouse_pos.x, mouse_pos.y);
+ else if (event.button.state == Input::BUTTON_RELEASED)
+ on_primary_button_release(mouse_pos.x, mouse_pos.y);
+ }
+ else if (event.button.name == SECONDARY_BUTTON)
+ {
+ if (event.button.state == Input::BUTTON_PRESSED)
+ on_secondary_button_press(mouse_pos.x, mouse_pos.y);
+ else if (event.button.state == Input::BUTTON_RELEASED)
+ on_secondary_button_release(mouse_pos.x, mouse_pos.y);
+ }
+ break;
- case Input::AXIS_EVENT_TYPE:
- // AxisEvents can be ignored in the GUI, they are handled elsewhere
- pout(PINGUS_DEBUG_GUI) << "GUIManager: AxisEvent: " << i->axis.dir
<< std::endl;
- break;
+ case Input::AXIS_EVENT_TYPE:
+ // AxisEvents can be ignored in the GUI, they are handled elsewhere
+ pout(PINGUS_DEBUG_GUI) << "GUIManager: AxisEvent: " << event.axis.dir
<< std::endl;
+ break;
- case Input::KEYBOARD_EVENT_TYPE:
- on_key_pressed(i->keyboard.key);
- break;
+ case Input::KEYBOARD_EVENT_TYPE:
+ on_key_pressed(event.keyboard.key);
+ break;
- case Input::SCROLLER_EVENT_TYPE:
- break;
+ case Input::SCROLLER_EVENT_TYPE:
+ break;
- default:
- pwarn (PINGUS_DEBUG_GUI) << "GUIManager: unhandled event type " <<
i->type << std::endl;
- break;
- }
+ default:
+ pwarn (PINGUS_DEBUG_GUI) << "GUIManager: unhandled event type " <<
event.type << std::endl;
+ break;
}
}
Modified: trunk/pingus/src/gui/gui_manager.hpp
===================================================================
--- trunk/pingus/src/gui/gui_manager.hpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/gui/gui_manager.hpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -43,17 +43,13 @@
private:
Vector2i mouse_pos;
- void process_input (const GameDelta& delta);
- void process_pointer_event (const Input::PointerEvent& event);
- void process_button_event (unsigned int time_stamp, const
Input::ButtonEvent& event);
- void process_keyboard_event (const Input::KeyboardEvent& event);
-
public:
GUIManager();
GUIManager(const Rect&);
virtual ~GUIManager ();
- void update(const GameDelta& delta);
+ virtual void update(float delta);
+ virtual void update(const Input::Event& event);
private:
GUIManager (const GUIManager&);
Modified: trunk/pingus/src/option_menu.cpp
===================================================================
--- trunk/pingus/src/option_menu.cpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/option_menu.cpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -19,6 +19,8 @@
#include <set>
#include <boost/bind.hpp>
+#include <iostream>
+
#include "config_manager.hpp"
#include "globals.hpp"
#include "gettext.h"
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/pingus_main.cpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -63,7 +63,6 @@
#include "command_line.hpp"
#include "screen/screen_manager.hpp"
-#include "dummy_screen.hpp"
// #include "gui/input_debug_screen.hpp"
#include "path_manager.hpp"
#include "pingus_main.hpp"
Modified: trunk/pingus/src/pingus_menu_manager.cpp
===================================================================
--- trunk/pingus/src/pingus_menu_manager.cpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/pingus_menu_manager.cpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -82,13 +82,19 @@
}
void
-PingusMenuManager::update (const GameDelta& delta)
+PingusMenuManager::update(float delta)
{
- background.update (delta.get_time ());
- menu_stack.back()->update (delta);
+ background.update(delta);
+ menu_stack.back()->update(delta);
}
void
+PingusMenuManager::update(const Input::Event& event)
+{
+ menu_stack.back()->update(event);
+}
+
+void
PingusMenuManager::set_menu (PingusSubMenu * menu)
{
pop_menu ();
Modified: trunk/pingus/src/pingus_menu_manager.hpp
===================================================================
--- trunk/pingus/src/pingus_menu_manager.hpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/pingus_menu_manager.hpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -50,7 +50,8 @@
virtual ~PingusMenuManager();
bool draw(DrawingContext& gc);
- void update(const GameDelta&);
+ void update(float delta);
+ void update(const Input::Event& event);
/// Exit the menu manager (which means to exit the while() loop in display
())
void show_exit_menu ();
Deleted: trunk/pingus/src/screen/game_delta.hpp
===================================================================
--- trunk/pingus/src/screen/game_delta.hpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/screen/game_delta.hpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -1,68 +0,0 @@
-// $Id$
-//
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000 Ingo Ruhnke <address@hidden>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-#ifndef HEADER_PINGUS_GAME_DELTA_HPP
-#define HEADER_PINGUS_GAME_DELTA_HPP
-
-#include <list>
-#include "../delta_manager.hpp"
-#include "../input/event.hpp"
-
-
-/** Input for the game engine */
-class GameDelta
-{
-private:
- /** time delta since the last update */
- const float time_delta;
-
- const unsigned int absolute_time;
-
- /** Reference to the event list from the controller, we must not
- delete the Event* */
- Input::EventLst events;
-
-public:
- /** Construct a GameDelta with both time and events */
- GameDelta (float time_delta_arg,
- unsigned int absolute_time_arg,
- const Input::EventLst& e)
- : time_delta (time_delta_arg),
- absolute_time (absolute_time_arg),
- events (e) {}
-
- /** Return the time that has passed in seconds since the last update() */
- float get_time () const { return time_delta; }
-
- /** @return the time since the application startup in miliseconds
- (1/1000 second) */
- unsigned int get_absolute_time () const { return absolute_time; }
-
- /** Return the events */
- const Input::EventLst& get_events () const { return events; }
-
-private:
- GameDelta (const GameDelta&);
- GameDelta& operator= (const GameDelta&);
-};
-
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/screen/gui_screen.cpp
===================================================================
--- trunk/pingus/src/screen/gui_screen.cpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/screen/gui_screen.cpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -43,57 +43,56 @@
return true;
}
- /** Pass a delta to the screen */
void
-GUIScreen::update (const GameDelta& delta)
+GUIScreen::update(float delta)
{
+ gui_manager->update(delta);
+}
+
+void
+GUIScreen::update (const Input::Event& event)
+{
// Dispatch the recieved input events
- gui_manager->update (delta);
+ gui_manager->update(event);
- update(delta.get_time ());
-
- for (Input::EventLst::const_iterator i = delta.get_events ().begin ();
- i != delta.get_events ().end (); ++i)
+ switch (event.type)
{
- switch (i->type)
- {
- case Input::POINTER_EVENT_TYPE:
- {
- // ignored cause this is handled in the gui_manager
- }
- break;
+ case Input::POINTER_EVENT_TYPE:
+ {
+ // ignored cause this is handled in the gui_manager
+ }
+ break;
- case Input::BUTTON_EVENT_TYPE:
- {
- process_button_event (i->button);
- }
- break;
+ case Input::BUTTON_EVENT_TYPE:
+ {
+ process_button_event (event.button);
+ }
+ break;
- case Input::AXIS_EVENT_TYPE:
+ case Input::AXIS_EVENT_TYPE:
+ {
+ if (event.axis.name == Input::ACTION_AXIS)
{
- if (i->axis.name == Input::ACTION_AXIS)
- {
- on_action_axis_move(i->axis.dir);
- }
+ on_action_axis_move(event.axis.dir);
}
- break;
+ }
+ break;
- case Input::SCROLLER_EVENT_TYPE:
- {
+ case Input::SCROLLER_EVENT_TYPE:
+ {
- }
- break;
+ }
+ break;
- case Input::KEYBOARD_EVENT_TYPE:
- {
+ case Input::KEYBOARD_EVENT_TYPE:
+ {
- }
- break;
+ }
+ break;
- default:
- std::cout << "GUIScreen::update (): unhandled event type: " <<
i->type << std::endl;
- break;
- }
+ default:
+ std::cout << "GUIScreen::update (): unhandled event type: " <<
event.type << std::endl;
+ break;
}
}
Modified: trunk/pingus/src/screen/gui_screen.hpp
===================================================================
--- trunk/pingus/src/screen/gui_screen.hpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/screen/gui_screen.hpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -40,16 +40,13 @@
virtual ~GUIScreen ();
/** Draw this screen */
- virtual void draw_foreground (DrawingContext& gc) { UNUSED_ARG(gc); }
- virtual void draw_background (DrawingContext& gc) { UNUSED_ARG(gc); }
+ virtual void draw_foreground (DrawingContext&) {}
+ virtual void draw_background (DrawingContext&) {}
virtual bool draw(DrawingContext& gc);
- /** Pass a game delta to the screen */
- virtual void update (const GameDelta& delta);
+ virtual void update (const Input::Event& event);
+ virtual void update (float);
- /** */
- virtual void update (float) {}
-
virtual void on_pause_press () {}
virtual void on_fast_forward_press () {}
virtual void on_armageddon_press () {}
Modified: trunk/pingus/src/screen/screen.hpp
===================================================================
--- trunk/pingus/src/screen/screen.hpp 2008-07-02 05:15:35 UTC (rev 3622)
+++ trunk/pingus/src/screen/screen.hpp 2008-07-02 17:59:58 UTC (rev 3623)
@@ -21,11 +21,14 @@
#define HEADER_PINGUS_SCREEN_HPP
#include "SDL.h"
-#include "game_delta.hpp"
+namespace Input {
+class Event;
+}
+
class Size;
class DrawingContext;
-
+
/** A interface for screens. A screen is a Pingus 'thing' which gets
complete controll over the display and input. Examples of
screens are the PingusMenu or a PingusGameSession */
@@ -42,7 +45,8 @@
virtual bool draw(DrawingContext& gc) =0;
/** Pass a delta to the screen */
- virtual void update (const GameDelta& delta) =0;
+ virtual void update (const Input::Event& event) =0;
+ virtual void update (float delta) =0;
/** Called once the screen gets activated and becomes the current
screen */
@@ -58,8 +62,7 @@
Screen (const Screen&);
Screen& operator= (const Screen&);
};
-
-
+
#endif
/* EOF */
Modified: trunk/pingus/src/screen/screen_manager.cpp
===================================================================
--- trunk/pingus/src/screen/screen_manager.cpp 2008-07-02 05:15:35 UTC (rev
3622)
+++ trunk/pingus/src/screen/screen_manager.cpp 2008-07-02 17:59:58 UTC (rev
3623)
@@ -19,6 +19,7 @@
#include "SDL.h"
#include <iostream>
+#include "../delta_manager.hpp"
#include "../globals.hpp"
#include "math/size.hpp"
#include "pathname.hpp"
@@ -84,18 +85,19 @@
continue; // skip this frame
}
+ last_screen = get_current_screen();
+
// update the input
input_manager.update(time_delta);
+ std::vector<Input::Event> events = input_controller->poll_events();
+ for(std::vector<Input::Event>::iterator i = events.begin();
+ i != events.end() && last_screen == get_current_screen();
+ ++i)
+ {
+ get_current_screen()->update(*i);
+ }
+ get_current_screen()->update(time_delta);
- // Fill the delta with values
- GameDelta delta(time_delta, delta_manager.get_absolute(),
- input_controller->poll_events());
-
- last_screen = get_current_screen();
-
- // Most likely the screen will get changed in this update call
- get_current_screen()->update (delta);
-
if (cursor)
cursor->update(time_delta);
@@ -257,7 +259,7 @@
}
void
-ScreenManager::fade_over (ScreenPtr& old_screen, ScreenPtr& new_screen)
+ScreenManager::fade_over(ScreenPtr& old_screen, ScreenPtr& new_screen)
{
DeltaManager delta_manager;
float passed_time = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3623 - in trunk/pingus/src: . editor gui screen,
grumbel at BerliOS <=