[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src credits.cxx,1.2,1.3 credits.hxx,1.2,1
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src credits.cxx,1.2,1.3 credits.hxx,1.2,1.3 pingus_main.cxx,1.9,1.10 pingus_menu_manager.cxx,1.8,1.9 pingus_menu_manager.hxx,1.7,1.8 screen_manager.cxx,1.6,1.7 surface_button.cxx,1.6,1.7 |
Date: |
4 Aug 2002 15:42:26 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv32416
Modified Files:
credits.cxx credits.hxx pingus_main.cxx
pingus_menu_manager.cxx pingus_menu_manager.hxx
screen_manager.cxx surface_button.cxx
Log Message:
- turned credit screen into a Screen
- turned editor into a screen (half finished)
- some cleanup
Index: credits.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/credits.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- credits.cxx 19 Jun 2002 15:19:26 -0000 1.2
+++ credits.cxx 4 Aug 2002 15:42:23 -0000 1.3
@@ -27,17 +27,19 @@
#include "sound.hxx"
#include "pingus_resource.hxx"
#include "credits.hxx"
+#include "game_delta.hxx"
+#include "screen_manager.hxx"
/* Headers needed for i18n / gettext */
#include <clocale>
#include <config.h>
#include "my_gettext.hxx"
+Credits* Credits::instance_ = 0;
-Credits credit_screen;
-
-Credits::Credits() : is_init(false)
-{
+Credits::Credits()
+ : is_init(false)
+{
}
///
@@ -94,6 +96,8 @@
credits.push_back("_Keir Fraser");
credits.push_back("n");
+
+ credits.push_back("-### END ###");
}
}
@@ -102,45 +106,13 @@
}
-// FIXME: We have no time handling here, so it might run too fast on
-// fast computers
-void
-Credits::display()
-{
- init ();
- offset = 0;
-
- bool quit = false;
-
- PingusSound::play_music("music/pingus-2.it");
-
- offset = CL_Display::get_height() + 50;
-
- DeltaManager delta;
- while(!quit)
- {
- if (CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
- quit = true;
-
- if (CL_Keyboard::get_keycode(CL_KEY_SPACE))
- update (delta.getset () * 500.0f);
- else
- update (delta.getset () * 25.0f);
-
- draw ();
- Display::flip_display ();
-
- CL_System::keep_alive();
- }
-
- while (CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
- CL_System::keep_alive ();
-}
-
void
-Credits::update (float delta)
+Credits::update (const GameDelta& delta)
{
- offset -= 1.0f * delta;
+ offset -= 50.0f * delta.get_time ();
+
+ if (offset < -1200.0f)
+ ScreenManager::instance()->pop_screen ();
}
void
@@ -183,6 +155,25 @@
break;
}
}
+}
+
+void
+Credits::on_startup ()
+{
+ init ();
+
+ offset = CL_Display::get_height() + 50;
+
+ PingusSound::play_music("music/pingus-2.it");
+}
+
+Credits*
+Credits::instance ()
+{
+ if (instance_)
+ return instance_;
+ else
+ return instance_ = new Credits ();
}
/* EOF */
Index: credits.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/credits.hxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- credits.hxx 24 Jun 2002 22:52:54 -0000 1.2
+++ credits.hxx 4 Aug 2002 15:42:23 -0000 1.3
@@ -23,20 +23,20 @@
#include <string>
#include <vector>
#include <ClanLib/Display/Display/surface.h>
+#include "screen.hxx"
class CL_Font;
+class GameDelta;
-///
-class Credits
+class Credits : public Screen
{
private:
- ///
+ static Credits* instance_;
+
CL_Surface surface;
- ///
CL_Font* font;
- ///
CL_Font* font_small;
- ///
+
bool is_init;
float offset;
@@ -49,20 +49,19 @@
'-' - Use large font
*/
std::vector<std::string> credits;
-public:
- ///
+
Credits();
- ///
+public:
~Credits();
- ///
+
void init ();
- void update (float delta);
+ void update (const GameDelta& delta);
void draw ();
- ///
- void display();
-};
-extern Credits credit_screen;
+ void on_startup ();
+
+ static Credits* instance ();
+};
#endif
Index: pingus_main.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_main.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- pingus_main.cxx 2 Aug 2002 11:25:46 -0000 1.9
+++ pingus_main.cxx 4 Aug 2002 15:42:23 -0000 1.10
@@ -827,26 +827,24 @@
successfull = false;
}
}
-#if 0
+
if (successfull)
{
- if (start_editor) {
- Editor::instance ()->load_level (levelfile);
- levelfile = "";
- } else {
- PingusGameSession game (levelfile);
- game.start ();
- }
- }
-#endif
-
+ if (start_editor)
+ {
+ Editor::instance ()->load_level (levelfile);
+ levelfile = "";
+ ScreenManager::instance()->push_screen(Editor::instance (),
false);
+ }
+ else
+ {
+ ScreenManager::instance()->push_screen(new PingusGameSession
(levelfile), true);
+ }
+ }
}
// show the main menu, the rest of the game is spawn from there
try {
- //PingusMenuManager menu;
- // This is the main loop
- //menu.display ();
std::cout << "PingusMain::start screen manager" << std::endl;
ScreenManager::instance ()->display ();
std::cout << "PingusMain::quit game and screen_manager" << std::endl;
Index: pingus_menu_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu_manager.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pingus_menu_manager.cxx 3 Aug 2002 17:20:37 -0000 1.8
+++ pingus_menu_manager.cxx 4 Aug 2002 15:42:23 -0000 1.9
@@ -45,139 +45,6 @@
{
}
-/// Register all event-handling stuff
-void
-PingusMenuManager::register_events ()
-{
- //FIXME: I don't like event handling in pingus, should be handled
- //FIXME: otherwise.
-
- if (event_register_counter == 0)
- {
- ++event_register_counter;
-
- /*
- on_button_press_slot
- = CL_Input::sig_button_press ().connect (this,
&PingusMenuManager::on_button_press);
- on_button_release_slot
- = CL_Input::sig_button_release ().connect (this,
&PingusMenuManager::on_button_release);
- on_mouse_move_slot
- = CL_Input::sig_mouse_move ().connect (this,
&PingusMenuManager::on_mouse_move);
- */
- }
- else
- {
- std::cout << "PingusMenuManager::register_events (): handler already
registered" << std::endl;
- }
-}
-
-void
-PingusMenuManager::unregister_events ()
-{
- /*
- CL_Input::sig_button_press ().disconnect (on_button_press_slot);
- CL_Input::sig_button_release ().disconnect (on_button_release_slot);
- CL_Input::sig_mouse_move ().disconnect (on_mouse_move_slot);
- */
-}
-
-void
-PingusMenuManager::enable_events ()
-{
- ++event_register_counter;
-}
-
-void
-PingusMenuManager::disable_events ()
-{
- --event_register_counter;
-}
-
-/*
-void
-PingusMenuManager::on_button_press (CL_InputDevice* device,const CL_Key& key)
-{
- if (event_register_counter <= 0) return;
-
- std::cout << "PingusMenuManager::on_button_press ("
- << device << ", " << key.id
- << ")" << std::endl;
- if (device == CL_Input::keyboards[0] && key.id == CL_KEY_ESCAPE)
- {
- if (menu_stack.size () > 2)
- pop_menu ();
- else if (menu_stack.size () == 2 && current_menu () != &mainmenu)
- set_menu (&mainmenu);
- else if (menu_stack.size () == 2 && current_menu () == &mainmenu)
- push_menu (&exitmenu);
- }
- else
- current_menu ()->on_button_press (device, key);
-}
-
-void
-PingusMenuManager::on_button_release (CL_InputDevice* device,const CL_Key& key)
-{
- if (event_register_counter <= 0) return;
- current_menu ()->on_button_release (device, key);
-}
-
-void
-PingusMenuManager::on_mouse_move (CL_InputDevice* device, int x, int y)
-{
- if (event_register_counter <= 0) return;
- // std::cout << "PingusMenuManager::on_mouse_move ("
- //<< device << ", " << x << ", " << y << ")" << std::endl;
- current_menu ()->on_mouse_move (device, x, y);
-}
-*/
-
-/*
-void
-PingusMenuManager::display ()
-{
- //std::cout << "Pingusmenumanager: display ()" << std::endl;
- DeltaManager delta_manager;
-
- 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;
- 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)
-
- 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()
- std::vector<PingusSubMenu *> tmp_menu_stack = menu_stack;
-
- for (MenuStackIter i = tmp_menu_stack.begin (); i != tmp_menu_stack.end
(); ++i)
- (*i)->draw ();
-
- for (MenuStackIter i = tmp_menu_stack.begin (); i != tmp_menu_stack.end
(); ++i)
- (*i)->update (delta);
-
- Display::flip_display ();
-
-
- CL_System::keep_alive ();
- CL_System::sleep (0);
- }
- unregister_events ();
-}
-*/
void
PingusMenuManager::draw ()
{
@@ -203,12 +70,8 @@
void
PingusMenuManager::set_menu (PingusSubMenu * menu)
{
- /*if (current_menu.get ())
- fadeout ();*/
pop_menu ();
push_menu (menu);
- //current_menu = menu;
- //current_menu->preload ();
}
void
Index: pingus_menu_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/pingus_menu_manager.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- pingus_menu_manager.hxx 3 Aug 2002 17:20:37 -0000 1.7
+++ pingus_menu_manager.hxx 4 Aug 2002 15:42:23 -0000 1.8
@@ -63,11 +63,6 @@
virtual ~PingusMenuManager ();
- /// Disable events
- void enable_events ();
- /// Enable events
- void disable_events ();
-
void fadeout ();
void draw ();
Index: screen_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/screen_manager.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- screen_manager.cxx 3 Aug 2002 17:20:37 -0000 1.6
+++ screen_manager.cxx 4 Aug 2002 15:42:23 -0000 1.7
@@ -35,6 +35,7 @@
replace_screen_arg = std::pair<Screen*, bool>(0, false);
cached_action = none;
+ // Set the root screen
push_screen (PingusMenuManager::instance (), false);
}
Index: surface_button.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/surface_button.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- surface_button.cxx 3 Aug 2002 17:20:37 -0000 1.6
+++ surface_button.cxx 4 Aug 2002 15:42:23 -0000 1.7
@@ -27,6 +27,7 @@
#include "editor/editor.hxx"
#include "theme_selector.hxx"
#include "surface_button.hxx"
+#include "screen_manager.hxx"
/* Headers needed for i18n / gettext */
#include <clocale>
@@ -185,8 +186,8 @@
void
CreditButton::on_click()
{
- Credits credits;
- credits.display();
+ std::cout << "Pushing credits screen" << std::endl;
+ ScreenManager::instance()->push_screen (Credits::instance(), false);
}
///////////////////////////////////////////////
@@ -326,9 +327,7 @@
void
EditorButton::on_click()
{
- menu->get_manager ()->disable_events ();
- Editor::instance()->edit();
- menu->get_manager ()->enable_events ();
+ ScreenManager::instance()->push_screen (Editor::instance(), false);
}
StoryButton::StoryButton (PingusMenu* menu)
@@ -382,10 +381,8 @@
{
PingusSound::play_sound ("sounds/letsgo.wav");
- menu->get_manager ()->disable_events ();
ThemeSelector theme_selector;
theme_selector.display();
- menu->get_manager ()->enable_events ();
}
MultiplayerButton::MultiplayerButton (PingusMenu* menu)
@@ -409,9 +406,7 @@
void
MultiplayerButton::on_click()
{
- menu->get_manager ()->disable_events ();
multiplayer_config.display ();
- menu->get_manager ()->enable_events ();
}
/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src credits.cxx,1.2,1.3 credits.hxx,1.2,1.3 pingus_main.cxx,1.9,1.10 pingus_menu_manager.cxx,1.8,1.9 pingus_menu_manager.hxx,1.7,1.8 screen_manager.cxx,1.6,1.7 surface_button.cxx,1.6,1.7,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.7,1.8
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src screen.hxx,1.5,1.6 screen_manager.cxx,1.7,1.8 xml_helper.cxx,1.8,1.9
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/gui gui_manager.cxx,1.7,1.8
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src screen.hxx,1.5,1.6 screen_manager.cxx,1.7,1.8 xml_helper.cxx,1.8,1.9
- Index(es):