[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src game_delta.hxx,1.5,1.6 menu_backgroun
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src game_delta.hxx,1.5,1.6 menu_background.cxx,1.1,1.2 menu_background.hxx,1.2,1.3 pingus_main.cxx,1.6,1.7 pingus_menu.cxx,1.4,1.5 pingus_menu.hxx,1.3,1.4 pingus_menu_manager.cxx,1.5,1.6 pingus_menu_manager.hxx,1.4,1.5 pingus_sub_menu.hxx,1.3,1.4 |
Date: |
30 Jul 2002 14:57:28 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv13286
Modified Files:
game_delta.hxx menu_background.cxx menu_background.hxx
pingus_main.cxx pingus_menu.cxx pingus_menu.hxx
pingus_menu_manager.cxx pingus_menu_manager.hxx
pingus_sub_menu.hxx
Log Message:
some cleanup in the input/gui handling, gamedelta is now usable
Index: game_delta.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_delta.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- game_delta.hxx 29 Jul 2002 10:44:12 -0000 1.5
+++ game_delta.hxx 30 Jul 2002 14:57:25 -0000 1.6
@@ -20,33 +20,35 @@
#ifndef HEADER_PINGUS_GAME_DELTA_HXX
#define HEADER_PINGUS_GAME_DELTA_HXX
-#error "Don't used this the moment, its underdevelopment and not compilable"
-
-class InputEvent;
+#include <list>
-namespace Pingus
+namespace Input
{
- /** Input for the game engine */
- class GameDelta
- {
- private:
- std::list<Event*> events;
- float time;
-
- public:
- void set_time (float t) { time = t; }
-
- /** add an event (FIXME: Memory handling?!)*/
- void add_event (Event* e) { events.push_back(); }
+ class Event;
+}
+/** Input for the game engine */
+class GameDelta
+{
+private:
+ /** time delta since the last update */
+ float time_delta;
+
+ /** Reference to the event list from the controller, we must not
+ delete the Event* */
+ const std::list<Input::Event*>& events;
+
+public:
+ /** Construct a GameDelta with both time and events */
+ GameDelta (float d,std::list<Input::Event*>& e)
+ : time_delta (d), events (e) {}
- /** Return the time that has passed in seconds */
- float get_time () { return time; }
+ /** Return the time that has passed in seconds since the last update() */
+ float get_time () const { return time_delta; }
- /** Return the events */
- std::list<Event*>& get_events () { return events; }
- };
-}
+ /** Return the events */
+ const std::list<Input::Event*>& get_events () const { return events; }
+};
#endif
Index: menu_background.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/menu_background.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- menu_background.cxx 12 Jun 2002 19:09:37 -0000 1.1
+++ menu_background.cxx 30 Jul 2002 14:57:25 -0000 1.2
@@ -42,9 +42,9 @@
}
void
-MenuBackground::update (float delta)
+MenuBackground::update (const GameDelta& delta)
{
- layer_manager.update (delta);
+ layer_manager.update (delta.get_time ());
}
void
Index: menu_background.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/menu_background.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- menu_background.hxx 24 Jun 2002 22:52:55 -0000 1.2
+++ menu_background.hxx 30 Jul 2002 14:57:25 -0000 1.3
@@ -35,7 +35,7 @@
~MenuBackground ();
void draw ();
- void update (float delta);
+ void update (const GameDelta& delta);
void preload ();
};
Index: pingus_main.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- pingus_main.cxx 10 Jul 2002 18:10:06 -0000 1.6
+++ pingus_main.cxx 30 Jul 2002 14:57:25 -0000 1.7
@@ -843,6 +843,7 @@
// show the main menu, the rest of the game is spawn from there
try {
PingusMenuManager menu;
+ // This is the main loop
menu.display ();
}
Index: pingus_menu.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pingus_menu.cxx 29 Jul 2002 22:17:53 -0000 1.4
+++ pingus_menu.cxx 30 Jul 2002 14:57:25 -0000 1.5
@@ -30,16 +30,13 @@
#include "display.hxx"
#include "sound.hxx"
#include "debug.hxx"
+#include "game_delta.hxx"
#include "gui/root_gui_manager.hxx"
PingusMenu::PingusMenu(PingusMenuManager* m)
: PingusSubMenu (m)
{
is_init = false;
-
- // FIXME: Memory leak
- controller = new Input::Controller ("../doc/mycontroller.xml");
- gui_manager = new GUI::RootGUIManager (controller);
}
void
@@ -61,13 +58,13 @@
background = PingusResource::load_surface("misc/logo", "core");
// FIXME: Lilla... memory leak
- gui_manager->add(new OptionsButton (this));
- gui_manager->add(new CreditButton (this));
- gui_manager->add(new QuitButton (this));
- gui_manager->add(new MultiplayerButton (this));
- gui_manager->add(new ThemeButton (this));
- gui_manager->add(new StoryButton (this));
- gui_manager->add(editor_button);
+ add(new OptionsButton (this));
+ add(new CreditButton (this));
+ add(new QuitButton (this));
+ add(new MultiplayerButton (this));
+ add(new ThemeButton (this));
+ add(new StoryButton (this));
+ add(editor_button);
}
// FIXME: Preload is probally the wrong place for this, there should
@@ -77,19 +74,7 @@
PingusMenu::~PingusMenu()
{
-}
-
-void
-PingusMenu::draw()
-{
- gui_manager->draw ();
-}
-
-void
-PingusMenu::update (float delta)
-{
- controller->update (delta);
- gui_manager->update (delta);
+ delete gui_manager;
}
void
Index: pingus_menu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pingus_menu.hxx 29 Jul 2002 22:17:53 -0000 1.3
+++ pingus_menu.hxx 30 Jul 2002 14:57:25 -0000 1.4
@@ -21,12 +21,14 @@
#define HEADER_PINGUS_PINGUS_MENU_HXX
#include <list>
+#include "game_delta.hxx"
#include "pingus_sub_menu.hxx"
#include "layer_manager.hxx"
class CL_Key;
class CL_InputDevice;
class SurfaceButton;
+class GameDelta;
namespace GUI
{
@@ -59,9 +61,6 @@
/// Load all images and other stuff for the menu
void preload ();
-
- void update (float /*delta*/);
- void draw(void);
};
#endif
Index: pingus_menu_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu_manager.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pingus_menu_manager.cxx 30 Jul 2002 01:58:16 -0000 1.5
+++ pingus_menu_manager.cxx 30 Jul 2002 14:57:25 -0000 1.6
@@ -23,6 +23,7 @@
#include "display.hxx"
#include "delta_manager.hxx"
#include "fade_out.hxx"
+#include "input/controller.hxx"
#include "pingus_menu_manager.hxx"
PingusMenuManager::PingusMenuManager ()
@@ -135,24 +136,32 @@
{
//std::cout << "Pingusmenumanager: display ()" << std::endl;
DeltaManager delta_manager;
- float delta;
-
+
current_menu ()->preload ();
register_events ();
loop = true;
+ Input::Controller input_controller("../doc/mycontroller.xml");
// Main loop for the menu
while (loop)
{
//std::cout << "Displaying menu..." << std::endl;
- delta = delta_manager.getset ();
+ float time_delta = delta_manager.getset ();
+
+ input_controller.update (time_delta);
// We ignore delta's larger then one second, to avoid jumps in
// the scrolling (for example when starting a level and then
// after some minutes going back to the menu would cause delta's
// from >100, not nice)
- if (delta > 1.0)
- delta = 0;
+ if (time_delta > 1.0)
+ {
+ std::cout << "PingusMenuManager: detected large delta (" << time_delta
+ << "), ignoring and doing frameskip" << std::endl;
+ continue;
+ }
+
+ GameDelta delta (time_delta, input_controller.get_events ());
// We copy the menu_stack so that we don't invalidate our
// iterators when menu's are removed/added in update()
@@ -218,13 +227,15 @@
void
PingusMenuManager::fadeout ()
{
+ std::cout << "PingusMenuManager::fadeout () Not implemented" << std::endl;
DeltaManager delta_manager;
EnlargingRectFadeOut fadeout;
while (!fadeout.finished ())
{
- float delta = delta_manager.getset ();
- fadeout.update (delta);
- current_menu ()->update (delta);
+ float time_delta = delta_manager.getset ();
+ fadeout.update (time_delta);
+
+ //current_menu ()->update ();
current_menu ()->draw ();
fadeout.draw ();
Display::flip_display ();
Index: pingus_menu_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu_manager.hxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- pingus_menu_manager.hxx 30 Jul 2002 01:58:16 -0000 1.4
+++ pingus_menu_manager.hxx 30 Jul 2002 14:57:25 -0000 1.5
@@ -47,7 +47,8 @@
/// Unregister all event-handling stuff
void unregister_events ();
public:
- /* Menu's */
+ /* Menu's FIXME: These shouldn't get exported to the outsite,
+ instead only handles (enum's) should be visible */
Intro intro;
PingusMenu mainmenu;
OptionMenu optionmenu;
@@ -57,9 +58,6 @@
PingusMenuManager ();
~PingusMenuManager ();
-
- void draw ();
- void update (float delta);
/// Display the menu (this is basically the game's main loop)
void display ();
Index: pingus_sub_menu.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_sub_menu.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- pingus_sub_menu.hxx 30 Jul 2002 01:58:16 -0000 1.3
+++ pingus_sub_menu.hxx 30 Jul 2002 14:57:25 -0000 1.4
@@ -20,13 +20,13 @@
#ifndef HEADER_PINGUS_PINGUS_SUB_MENU_HXX
#define HEADER_PINGUS_PINGUS_SUB_MENU_HXX
-#include "gui/component.hxx"
+#include "gui/gui_manager.hxx"
class CL_Key;
class CL_InputDevice;
class PingusMenuManager;
-class PingusSubMenu : public GUI::Component
+class PingusSubMenu : public GUI::GUIManager
{
protected:
PingusMenuManager* manager;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src game_delta.hxx,1.5,1.6 menu_background.cxx,1.1,1.2 menu_background.hxx,1.2,1.3 pingus_main.cxx,1.6,1.7 pingus_menu.cxx,1.4,1.5 pingus_menu.hxx,1.3,1.4 pingus_menu_manager.cxx,1.5,1.6 pingus_menu_manager.hxx,1.4,1.5 pingus_sub_menu.hxx,1.3,1.4,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.3,1.4 gui_manager.hxx,1.3,1.4 root_gui_manager.cxx,1.3,1.4
- Next by Date:
[Pingus-CVS] [Bug #926] Laser Exit trap does not kill pingus
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.3,1.4 gui_manager.hxx,1.3,1.4 root_gui_manager.cxx,1.3,1.4
- Next by thread:
[Pingus-CVS] [Bug #926] Laser Exit trap does not kill pingus
- Index(es):