[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r4048 - in trunk/pingus: . src/editor src/pingus src/pingus
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r4048 - in trunk/pingus: . src/editor src/pingus src/pingus/components src/pingus/screens src/pingus/worldmap |
Date: |
Fri, 6 Nov 2009 01:10:56 +0100 |
Author: grumbel
Date: 2009-11-06 01:10:50 +0100 (Fri, 06 Nov 2009)
New Revision: 4048
Added:
trunk/pingus/src/pingus/screens/
trunk/pingus/src/pingus/screens/addon_menu.cpp
trunk/pingus/src/pingus/screens/addon_menu.hpp
trunk/pingus/src/pingus/screens/credits.cpp
trunk/pingus/src/pingus/screens/credits.hpp
trunk/pingus/src/pingus/screens/demo_session.cpp
trunk/pingus/src/pingus/screens/demo_session.hpp
trunk/pingus/src/pingus/screens/font_test_screen.cpp
trunk/pingus/src/pingus/screens/font_test_screen.hpp
trunk/pingus/src/pingus/screens/game_session.cpp
trunk/pingus/src/pingus/screens/game_session.hpp
trunk/pingus/src/pingus/screens/level_menu.cpp
trunk/pingus/src/pingus/screens/level_menu.hpp
trunk/pingus/src/pingus/screens/option_menu.cpp
trunk/pingus/src/pingus/screens/option_menu.hpp
trunk/pingus/src/pingus/screens/pingus_menu.cpp
trunk/pingus/src/pingus/screens/pingus_menu.hpp
trunk/pingus/src/pingus/screens/result_screen.cpp
trunk/pingus/src/pingus/screens/result_screen.hpp
trunk/pingus/src/pingus/screens/start_screen.cpp
trunk/pingus/src/pingus/screens/start_screen.hpp
trunk/pingus/src/pingus/screens/story_screen.cpp
trunk/pingus/src/pingus/screens/story_screen.hpp
Removed:
trunk/pingus/src/pingus/addon_menu.cpp
trunk/pingus/src/pingus/addon_menu.hpp
trunk/pingus/src/pingus/credits.cpp
trunk/pingus/src/pingus/credits.hpp
trunk/pingus/src/pingus/demo_session.cpp
trunk/pingus/src/pingus/demo_session.hpp
trunk/pingus/src/pingus/font_test_screen.cpp
trunk/pingus/src/pingus/font_test_screen.hpp
trunk/pingus/src/pingus/game_session.cpp
trunk/pingus/src/pingus/game_session.hpp
trunk/pingus/src/pingus/level_menu.cpp
trunk/pingus/src/pingus/level_menu.hpp
trunk/pingus/src/pingus/option_menu.cpp
trunk/pingus/src/pingus/option_menu.hpp
trunk/pingus/src/pingus/pingus_menu.cpp
trunk/pingus/src/pingus/pingus_menu.hpp
trunk/pingus/src/pingus/result_screen.cpp
trunk/pingus/src/pingus/result_screen.hpp
trunk/pingus/src/pingus/start_screen.cpp
trunk/pingus/src/pingus/start_screen.hpp
trunk/pingus/src/pingus/story_screen.cpp
trunk/pingus/src/pingus/story_screen.hpp
Modified:
trunk/pingus/SConscript
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/pingus/capture_rectangle.cpp
trunk/pingus/src/pingus/components/action_button.cpp
trunk/pingus/src/pingus/components/button_panel.cpp
trunk/pingus/src/pingus/components/menu_button.cpp
trunk/pingus/src/pingus/components/playfield.cpp
trunk/pingus/src/pingus/components/smallmap.cpp
trunk/pingus/src/pingus/components/time_display.cpp
trunk/pingus/src/pingus/global_event.cpp
trunk/pingus/src/pingus/pingus_main.cpp
trunk/pingus/src/pingus/worldmap/level_dot.cpp
trunk/pingus/src/pingus/worldmap/worldmap.cpp
trunk/pingus/src/pingus/worldmap/worldmap_screen.cpp
trunk/pingus/src/pingus/worldmap/worldmap_story.cpp
Log:
Moved Screen derived classes to src/pingus/screens/
Modified: trunk/pingus/SConscript
===================================================================
--- trunk/pingus/SConscript 2009-11-06 00:02:11 UTC (rev 4047)
+++ trunk/pingus/SConscript 2009-11-06 00:10:50 UTC (rev 4048)
@@ -299,6 +299,7 @@
Glob('src/pingus/components/*.cpp') + \
Glob('src/pingus/movers/*.cpp') + \
Glob('src/pingus/particles/*.cpp') + \
+ Glob('src/pingus/screens/*.cpp') + \
Glob('src/pingus/worldmap/*.cpp') + \
Glob('src/pingus/worldobjs/*.cpp') + \
Glob('src/util/*.cpp') + \
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/editor/editor_screen.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -33,7 +33,7 @@
#include "editor/file_dialog.hpp"
#include "pingus/path_manager.hpp"
#include "util/pathname.hpp"
-#include "pingus/game_session.hpp"
+#include "pingus/screens/game_session.hpp"
#include "editor/editor_level.hpp"
#include "editor/panel.hpp"
#include "editor/panel.hpp"
Deleted: trunk/pingus/src/pingus/addon_menu.cpp
===================================================================
--- trunk/pingus/src/pingus/addon_menu.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/addon_menu.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,65 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/addon_menu.hpp"
-
-#include "pingus/gettext.h"
-#include "pingus/resource.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "pingus/fonts.hpp"
-#include "engine/display/drawing_context.hpp"
-#include "pingus/option_menu.hpp"
-
-AddOnMenu::AddOnMenu() :
- background(),
- ok_button()
-{
- background = Sprite("core/menu/filedialog");
- ok_button = Sprite("core/start/ok");
-}
-
-AddOnMenu::~AddOnMenu()
-{
-}
-
-void
-AddOnMenu::draw_background(DrawingContext& gc)
-{
- // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
- gc.draw(background, Vector2i(gc.get_width()/2 - background.get_width()/2,
gc.get_height()/2 - background.get_height()/2));
-
- gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, 90), "Add-On
Menu");
-
- gc.print_left(Fonts::chalk_normal, Vector2i(120, 145), "X-Mas Pingus
Sprites");
- gc.print_left(Fonts::chalk_small, Vector2i(140, 170), "christmas look for
penguins");
- gc.print_left(Fonts::chalk_small, Vector2i(140, 190), "Author: John Foo
<address@hidden>");
-
- gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2,
gc.get_height()/2 + 160), "Update Online [ ]");
-
- gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 225 + 30,
gc.get_height()/2 + 125 - 20), _("Close"));
- gc.draw(ok_button, Vector2i(gc.get_width()/2 + 225, gc.get_height()/2 +
125));
-
- gc.draw(ok_button, Vector2i(610, 145));
-}
-
-void
-AddOnMenu::on_escape_press()
-{
- //std::cout << "OptionMenu: poping screen" << std::endl;
- ScreenManager::instance()->pop_screen();
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/addon_menu.hpp
===================================================================
--- trunk/pingus/src/pingus/addon_menu.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/addon_menu.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,59 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_ADDON_MENU_HPP
-#define HEADER_PINGUS_PINGUS_ADDON_MENU_HPP
-
-#include "engine/display/sprite.hpp"
-#include "engine/screen/gui_screen.hpp"
-
-/** */
-class AddOnMenu : public GUIScreen
-{
-private:
- Sprite background;
- Sprite ok_button;
-
- struct AddOnEntry
- {
- std::string title;
- std::string description;
- std::string author;
-
- AddOnEntry(const std::string& title_,
- const std::string& description_,
- const std::string& author_)
- : title(title_),
- description(description_),
- author(author_)
- {}
- };
-
-public:
- AddOnMenu();
- ~AddOnMenu();
-
- void draw_background (DrawingContext& gc);
- void on_escape_press ();
-
-private:
- AddOnMenu (const AddOnMenu&);
- AddOnMenu& operator= (const AddOnMenu&);
-};
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/pingus/capture_rectangle.cpp
===================================================================
--- trunk/pingus/src/pingus/capture_rectangle.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/capture_rectangle.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -18,7 +18,7 @@
#include "engine/display/scene_context.hpp"
#include "pingus/fonts.hpp"
-#include "pingus/game_session.hpp"
+#include "pingus/screens/game_session.hpp"
#include "pingus/globals.hpp"
#include "math/vector3f.hpp"
#include "pingus/pingu.hpp"
Modified: trunk/pingus/src/pingus/components/action_button.cpp
===================================================================
--- trunk/pingus/src/pingus/components/action_button.cpp 2009-11-06
00:02:11 UTC (rev 4047)
+++ trunk/pingus/src/pingus/components/action_button.cpp 2009-11-06
00:10:50 UTC (rev 4048)
@@ -18,7 +18,7 @@
#include "pingus/globals.hpp"
#include "pingus/server.hpp"
-#include "pingus/game_session.hpp"
+#include "pingus/screens/game_session.hpp"
#include "pingus/world.hpp"
#include "engine/display/drawing_context.hpp"
#include "pingus/fonts.hpp"
Modified: trunk/pingus/src/pingus/components/button_panel.cpp
===================================================================
--- trunk/pingus/src/pingus/components/button_panel.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/components/button_panel.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -24,7 +24,7 @@
#include "util/string_util.hpp"
#include "pingus/globals.hpp"
#include "pingus/server.hpp"
-#include "pingus/game_session.hpp"
+#include "pingus/screens/game_session.hpp"
#include "engine/display/drawing_context.hpp"
using namespace Actions;
Modified: trunk/pingus/src/pingus/components/menu_button.cpp
===================================================================
--- trunk/pingus/src/pingus/components/menu_button.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/components/menu_button.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -22,7 +22,7 @@
#include "engine/sound/sound.hpp"
#include "pingus/resource.hpp"
#include "pingus/gettext.h"
-#include "pingus/pingus_menu.hpp"
+#include "pingus/screens/pingus_menu.hpp"
MenuButton::MenuButton(PingusMenu* menu_,
Modified: trunk/pingus/src/pingus/components/playfield.cpp
===================================================================
--- trunk/pingus/src/pingus/components/playfield.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/components/playfield.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -26,7 +26,7 @@
#include "pingus/server.hpp"
#include "pingus/pingu.hpp"
#include "engine/display/display.hpp"
-#include "pingus/game_session.hpp"
+#include "pingus/screens/game_session.hpp"
Playfield::Playfield(Server* server_, GameSession* session_, const Rect&
rect_) :
RectComponent(rect_),
Modified: trunk/pingus/src/pingus/components/smallmap.cpp
===================================================================
--- trunk/pingus/src/pingus/components/smallmap.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/components/smallmap.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -16,7 +16,7 @@
#include "pingus/components/smallmap.hpp"
-#include "pingus/game_session.hpp"
+#include "pingus/screens/game_session.hpp"
#include "pingus/pingu_holder.hpp"
#include "engine/display/display.hpp"
#include "engine/display/drawing_context.hpp"
Modified: trunk/pingus/src/pingus/components/time_display.cpp
===================================================================
--- trunk/pingus/src/pingus/components/time_display.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/components/time_display.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -24,7 +24,7 @@
#include "pingus/resource.hpp"
#include "pingus/world.hpp"
#include "pingus/server.hpp"
-#include "pingus/game_session.hpp"
+#include "pingus/screens/game_session.hpp"
#include "pingus/game_time.hpp"
#include "util/string_util.hpp"
#include "pingus/fonts.hpp"
Deleted: trunk/pingus/src/pingus/credits.cpp
===================================================================
--- trunk/pingus/src/pingus/credits.cpp 2009-11-06 00:02:11 UTC (rev 4047)
+++ trunk/pingus/src/pingus/credits.cpp 2009-11-06 00:10:50 UTC (rev 4048)
@@ -1,341 +0,0 @@
-// 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/credits.hpp"
-
-#include <iostream>
-#include "engine/screen/screen_manager.hpp"
-#include "engine/gui/surface_button.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "engine/sound/sound.hpp"
-#include "pingus/stat_manager.hpp"
-#include "pingus/resource.hpp"
-#include "pingus/res_descriptor.hpp"
-#include "pingus/fonts.hpp"
-#include "gettext.h"
-#include "engine/display/display.hpp"
-#include "engine/display/blitter.hpp"
-
-class CreditsOkButton
- : public GUI::SurfaceButton
-{
-private:
- Credits* parent;
-public:
- CreditsOkButton(Credits* p)
- : GUI::SurfaceButton(Display::get_width()/2 + 260,
- Display::get_height()/2 + 170,
- "core/start/ok",
- "core/start/ok_clicked",
- "core/start/ok_hover"),
- parent(p)
- {
- }
-
- void on_pointer_enter ()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound("tick");
- }
-
- void on_click() {
- parent->on_escape_press();
- Sound::PingusSound::play_sound("yipee");
- }
-
-private:
- CreditsOkButton(const CreditsOkButton&);
- CreditsOkButton & operator=(const CreditsOkButton&);
-};
-
-Credits::Credits() :
- scene_context(),
- fast_scrolling(false),
- background("core/menu/wood"),
- blackboard("core/menu/blackboard"),
- pingu("core/misc/creditpingu"),
- font(),
- font_small(),
- is_init(),
- end_offset(),
- offset(),
- credits()
-{
- scene_context = new SceneContext();
- fast_scrolling = false;
- gui_manager->add(new CreditsOkButton(this));
-
- font = Fonts::chalk_normal;
- font_small = Fonts::chalk_large;
-
- // The credits vector holds the strings to display. The first
- // character of each string is a special character, which indicates
- // the size of the font or other special stuff. "-" means large
- // font, "_" is a small font and "n" means a newline.
-
- credits.push_back(_("-Idea"));
- credits.push_back("_Ingo Ruhnke");
- credits.push_back("n");
-
- credits.push_back(_("-Maintaining"));
- credits.push_back("_Ingo Ruhnke");
- credits.push_back("n");
-
- credits.push_back(_("-Programming"));
- credits.push_back("_David Philippi");
- credits.push_back("_Gervase Lam");
- credits.push_back("_Ingo Ruhnke");
- credits.push_back("_Jason Green");
- credits.push_back("_Jimmy Salmon");
- credits.push_back("_Michael Ploujnikov");
- credits.push_back("_Nehal Mistry");
- credits.push_back("n");
-
- credits.push_back(_("-Porting (Win32)"));
- credits.push_back("_Alberto Curro");
- credits.push_back("_Björn Christoph Fischer");
- credits.push_back("_Kenneth Gangstø");
- credits.push_back("_Michael Käser");
- credits.push_back("_Neil Mitchell");
- credits.push_back("_Jason Green");
- credits.push_back("n");
-
- credits.push_back(_("-Porting (MacOSX)"));
- credits.push_back("_Jason Green");
- credits.push_back("_Sean Heber");
- credits.push_back("n");
-
- credits.push_back(_("-Gfx"));
- credits.push_back("_Alan Tennent");
- credits.push_back("_Craig Timpany");
- credits.push_back("_Erik Søe Sørensen");
- credits.push_back("_Ingo Ruhnke");
- credits.push_back("_Jarno Elonen");
- credits.push_back("_Joel Fauche");
- credits.push_back("_Mark Collinson");
- credits.push_back("_Michael Mestre");
- credits.push_back("_Stefan Stiasny");
- credits.push_back("_Tom Flavel");
- credits.push_back("n");
-
- credits.push_back(_("-Music"));
- credits.push_back("_H. Matthew Smith");
- credits.push_back("_Joseph Toscano");
- credits.push_back("_Robbie Ferguson");
- credits.push_back("_Yuri Sucupira");
- credits.push_back("n");
-
- credits.push_back(_("-Level Design"));
- credits.push_back("_Craig Timpany");
- credits.push_back("_Ingo Ruhnke");
- credits.push_back("_Rune Zedeler");
- credits.push_back("n");
-
- credits.push_back(_("-Story"));
- credits.push_back("_Ingo Ruhnke");
- credits.push_back("n");
-
- credits.push_back(_("-Translation"));
- credits.push_back("_Cagri Coltekin");
- credits.push_back("_David Philippi");
- credits.push_back("_Giray Devlet");
- credits.push_back("_Ingo Ruhnke");
- credits.push_back("_Janne Morén");
- credits.push_back("_Jarno Elonen");
- credits.push_back("_Karl Ove Hufthammer");
- credits.push_back("_Milan Babuskov");
- credits.push_back("_Philippe Saint-Pierre");
- credits.push_back("_Ricardo Cruz");
- credits.push_back("_Skule Solvang");
- credits.push_back("_Tomas Blaha");
- credits.push_back("n");
-
- credits.push_back(_("-Special"));
- credits.push_back(_("-Thanks to"));
- credits.push_back("_Adam Gregory");
- credits.push_back("_Andy Balaam");
- credits.push_back("_Bernhard Trummer");
- credits.push_back("_Cagri Coltekin");
- credits.push_back("_David Fauthoux");
- credits.push_back("_David Flores");
- credits.push_back("_David M. Turner");
- credits.push_back("_Debian");
- credits.push_back("_Etienne Marcotte");
- credits.push_back("_Felix Natter");
- credits.push_back("_Francisco 'Pacho' Ramos");
- credits.push_back("_Giray Devlet ");
- credits.push_back("_Giuseppe D'Aqui");
- credits.push_back("_Henri Manson");
- credits.push_back("_Jeff Binder");
- credits.push_back("_Jens Henrik Goebbert");
- credits.push_back("_Jessica Philippi");
- credits.push_back("_John August");
- credits.push_back("_Johnny Taporg");
- credits.push_back("_Jules Bean");
- credits.push_back("_Keir Fraser");
- credits.push_back("_Magnus Norddahl");
- credits.push_back("_Mattias Andersson");
- credits.push_back("_Michael Wand");
- credits.push_back("_Peter Todd");
- credits.push_back("_Peter van Rossum");
- credits.push_back("_Richard Stallman");
- credits.push_back("_Rob Gietema");
- credits.push_back("_Robert Wittams");
- credits.push_back("_Robin Hogan");
- credits.push_back("_Shigeru Miyamoto");
- credits.push_back("_Stefan Ruhnke");
- credits.push_back("_SuSE");
- credits.push_back("_Till Hellweg");
- credits.push_back("_Tim Yamin");
- credits.push_back("_Tuomas (Tigert) Kuosmanen");
- credits.push_back("_Werner Steiner");
- credits.push_back("n");
- credits.push_back("n");
- credits.push_back("n");
- credits.push_back("n");
- credits.push_back("n");
-
- credits.push_back(_("_And a very Special Thanks"));
- credits.push_back(_("_to all the people who"));
- credits.push_back(_("_contribute to"));
- credits.push_back(_("_Free Software!"));
- credits.push_back("n");
- credits.push_back("n");
- credits.push_back("n");
- credits.push_back("n");
- credits.push_back("n");
- credits.push_back(_("_Thank you for"));
- credits.push_back(_("_playing!"));
-
- end_offset = -(float)Display::get_height()/2 - 50; // screen height + grace
time
- for (std::vector<std::string>::iterator i = credits.begin(); i !=
credits.end(); ++i)
- {
- switch ((*i)[0])
- {
- case '-':
- end_offset += static_cast<float>(font.get_height() + 5);
- break;
- case '_':
- end_offset += static_cast<float>(font_small.get_height() + 5);
- break;
- case 'n':
- end_offset += 50;
- break;
- default:
- std::cout << "Credits: Syntax error: Unknown format: '" << (*i)[0] <<
"'" << std::endl;
- break;
- }
- }
- end_offset = -end_offset;
-}
-
-Credits::~Credits ()
-{
- StatManager::instance()->set_bool("credits-seen", true);
- delete scene_context;
-}
-
-void
-Credits::update (float delta)
-{
- if (offset < end_offset)
- {
- //ScreenManager::instance()->pop_screen ();
- }
- else
- {
- if (fast_scrolling)
- offset -= 450.0f * delta;
- else
- offset -= 35.0f * delta;
- }
-}
-
-void
-Credits::draw_background (DrawingContext& gc)
-{
- {
- // Paint the background wood panel
- for(int y = 0; y < gc.get_height(); y += background.get_height())
- for(int x = 0; x < gc.get_width(); x += background.get_width())
- gc.draw(background, Vector2i(x, y));
- }
-
- int x;
- int y;
- int yof;
-
- x = Display::get_width()/2;
- y = (int)offset;
-
- gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
-
- gc.draw(pingu, Vector2i(gc.get_width()/2, gc.get_height()/2 - 20));
-
- yof = 0;
-
- scene_context->clear();
- scene_context->set_cliprect(Rect(gc.get_width()/2 - 685/2, gc.get_height()/2
- 250,
- gc.get_width()/2 + 685/2, gc.get_height()/2
+ 250));
-
- for (std::vector<std::string>::iterator i = credits.begin(); i !=
credits.end(); ++i)
- {
- switch ((*i)[0])
- {
- case '-':
- scene_context->color().print_center(font, Vector2i(x, (y + yof)),
i->substr(1));
- yof += font.get_height() + 5;
- break;
- case '_':
- scene_context->color().print_center(font_small, Vector2i(x, (y +
yof)), i->substr(1));
- yof += font_small.get_height() + 5;
- break;
- case 'n':
- yof += 50;
- break;
- default:
- std::cout << "Credits: Syntax error: Unknown format: '" << (*i)[0] <<
"'" << std::endl;
- break;
- }
- }
- gc.draw(new SceneContextDrawingRequest(scene_context, Vector2i(0,0), 100));
-}
-
-void
-Credits::on_startup ()
-{
- offset = (float)Display::get_height() - 50;
- //PingusSound::play_music("pingus-5.it");
-}
-
-void
-Credits::on_pause_press ()
-{
-}
-
-void
-Credits::on_fast_forward_press ()
-{
- fast_scrolling = ! fast_scrolling;
-}
-
-void
-Credits::on_escape_press ()
-{
- ScreenManager::instance ()->pop_screen ();
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/credits.hpp
===================================================================
--- trunk/pingus/src/pingus/credits.hpp 2009-11-06 00:02:11 UTC (rev 4047)
+++ trunk/pingus/src/pingus/credits.hpp 2009-11-06 00:10:50 UTC (rev 4048)
@@ -1,75 +0,0 @@
-// 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_CREDITS_HPP
-#define HEADER_PINGUS_PINGUS_CREDITS_HPP
-
-#include <string>
-#include <vector>
-#include "engine/screen/gui_screen.hpp"
-#include "pingus/font.hpp"
-#include "engine/display/scene_context.hpp"
-#include "engine/display/sprite.hpp"
-
-class Credits : public GUIScreen
-{
-private:
- SceneContext* scene_context;
-
- bool fast_scrolling;
- Sprite background;
- Sprite blackboard;
- Sprite pingu;
-
- Font font;
- Font font_small;
-
- bool is_init;
-
- float end_offset;
- float offset;
-
- /** The string's which are shown in the scrolling text, the first
- character of the string can be used to apply a special format.
-
- 'n' - Inserts a newline
- '_' - Use small font
- '-' - Use large font
- */
- std::vector<std::string> credits;
-
-public:
- Credits ();
- virtual ~Credits ();
-
- void update (float);
- void draw_background (DrawingContext& gc);
-
- void on_startup ();
-
- void on_pause_press ();
- void on_fast_forward_press ();
- void on_escape_press ();
-
-private:
- Credits (const Credits&);
- Credits& operator= (const Credits&);
-
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/demo_session.cpp
===================================================================
--- trunk/pingus/src/pingus/demo_session.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/demo_session.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,259 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/demo_session.hpp"
-
-#include <boost/function.hpp>
-#include <boost/bind.hpp>
-#include <iostream>
-
-#include "math/math.hpp"
-#include "pingus/server.hpp"
-#include "util/pathname.hpp"
-#include "pingus/world.hpp"
-#include "pingus/components/pingus_counter.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "engine/display/scene_context.hpp"
-#include "pingus/pingus_demo.hpp"
-#include "engine/gui/surface_button.hpp"
-#include "pingus/components/playfield.hpp"
-#include "pingus/components/smallmap.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "engine/display/display.hpp"
-#include "pingus/resource.hpp"
-
-static bool false_func() { return false; }
-
-class BButton : public GUI::SurfaceButton
-{
-private:
- Sprite highlight;
- boost::function<void(void)> callback;
- boost::function<bool(void)> highlight_func;
-
-public:
- BButton(int x, int y, const std::string& name,
- boost::function<void (void)> callback_,
- boost::function<bool(void)> highlight_func_ = &false_func)
- : SurfaceButton(x, y, name, name + "-pressed", name + "-hover"),
- highlight("core/demo/highlight"),
- callback(callback_),
- highlight_func(highlight_func_)
- {}
-
- virtual void draw (DrawingContext& gc)
- {
-
- if (highlight_func())
- {
- gc.draw(button_pressed_surface, Vector2i(x_pos, y_pos));
- gc.draw(highlight, Vector2i(x_pos, y_pos));
- }
- else
- {
- SurfaceButton::draw(gc);
- }
- }
-
- void on_click() {
- callback();
- }
-};
-
-DemoSession::DemoSession(const Pathname& pathname_) :
- pathname(pathname_),
- server(),
- demo(),
- events(),
- pcounter(),
- playfield(),
- small_map(),
- fastforward_button(),
- pause_button(),
- restart_button(),
- pause(false),
- fast_forward(false)
-{
- // Load Demo file
- demo = std::auto_ptr<PingusDemo>(new PingusDemo(pathname));
-
- events = demo->get_events();
- // Reverse the vector so that we can use pop_back()
- std::reverse(events.begin(), events.end());
-
- // Create server
- server = std::auto_ptr<Server>(new Server(PingusLevel(Pathname("levels/" +
demo->get_levelname() + ".pingus",
-
Pathname::DATA_PATH)),
- false));
-
- // Create GUI
- pcounter = new PingusCounter(server.get());
- gui_manager->add(pcounter);
-
- int world_width = server->get_world()->get_width();
- int world_height = server->get_world()->get_height();
-
- playfield = new Playfield(server.get(), 0,
- Rect(Vector2i(Math::max((size.width -
world_width)/2, 0),
- Math::max((size.height -
world_height)/2, 0)),
- Size(Math::min(size.width, world_width),
- Math::min(size.height, world_height))));
-
- gui_manager->add(playfield);
-
- small_map = new SmallMap(server.get(), playfield, Rect(Vector2i(5,
size.height - 105), Size(175, 100)));
- gui_manager->add(small_map);
-
- gui_manager->add(fastforward_button= new BButton(32+50, 32,
"core/demo/fastforward",
-
boost::bind(&DemoSession::on_fast_forward_press, this),
-
boost::bind(&DemoSession::is_fast_forward, this)));
- gui_manager->add(pause_button =new BButton(32, 32, "core/demo/pause",
-
boost::bind(&DemoSession::on_pause_press, this),
-
boost::bind(&DemoSession::is_pause, this)));
- gui_manager->add(restart_button = new BButton(size.width - 32 - 48, 32,
"core/demo/reload",
-
boost::bind(&DemoSession::restart, this)));
-}
-
-DemoSession::~DemoSession()
-{
-}
-
-/** Pass a delta to the screen */
-void
-DemoSession::update(float delta)
-{
- GUIScreen::update(delta);
-
- if (server->is_finished())
- {
- ScreenManager::instance()->pop_screen();
- }
- else
- {
- // FIXME: Duplicate all timing code here?!
-
- if (!pause)
- {
- if (fast_forward)
- {
- for (int i = 0; i < 4; ++i)
- {
- server->update();
- update_demo();
- }
- }
- else
- {
- server->update();
- update_demo();
- }
- }
- }
-}
-
-void
-DemoSession::update_demo()
-{
- while(!events.empty() && events.back().time_stamp == server->get_time())
- {
- ServerEvent& event = events.back();
-
- if (0)
- {
- std::cout << "Sending: ";
- event.write(std::cout);
- }
-
- event.send(server.get());
- events.pop_back();
- }
-
- // Check for unexpected things (might happen if the demo file is broken)
- if (!events.empty() && events.back().time_stamp < server->get_time())
- {
- std::cout << "DemoPlayer Bug: We missed a timestamp: " <<
events.back().time_stamp << std::endl;
- }
-}
-
-void
-DemoSession::on_pause_press()
-{
- if (0)
- {
- for(std::vector<ServerEvent>::iterator i = events.begin(); i !=
events.end(); ++i)
- {
- std::cout << "Event: ";
- i->write(std::cout);
- }
- }
-
- pause = !pause;
-
-}
-
-void
-DemoSession::on_fast_forward_press()
-{
- if (0)
- std::cout << "Fast Forward Pressed: " << events.size() << " " <<
server->get_time() << std::endl;
-
- fast_forward = !fast_forward;
-}
-
-void
-DemoSession::on_escape_press()
-{
- std::cout << "Escape Pressed" << std::endl;
- server->send_finish_event();
- ScreenManager::instance()->pop_screen();
-}
-
-void
-DemoSession::on_scroller_move(float x, float y)
-{
- // FIXME: Rounding considered evil?
- playfield->scroll(static_cast<int>(-x),
- static_cast<int>(-y));
-}
-
-void
-DemoSession::restart()
-{
- ScreenManager::instance()->replace_screen(new DemoSession(pathname));
-}
-
-void
-DemoSession::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
-
- int world_width = server->get_world()->get_width();
- int world_height = server->get_world()->get_height();
-
- playfield->set_rect(Rect(Vector2i(Math::max((size.width - world_width)/2,
0),
- Math::max((size.height - world_height)/2,
0)),
- Size(Math::min(size.width, world_width),
- Math::min(size.height, world_height))));
-
-
- fastforward_button->set_pos(32+50, 32);
- pause_button->set_pos(32, 32);
- restart_button->set_pos(size.width - 32 - 48, 32);
-
- small_map->set_rect(Rect(Vector2i(5, size.height - 105), Size(175, 100)));
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/demo_session.hpp
===================================================================
--- trunk/pingus/src/pingus/demo_session.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/demo_session.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,93 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_DEMO_SESSION_HPP
-#define HEADER_PINGUS_PINGUS_DEMO_SESSION_HPP
-
-#include <memory>
-#include <vector>
-
-#include "util/pathname.hpp"
-#include "engine/screen/gui_screen.hpp"
-#include "pingus/server_event.hpp"
-
-namespace Input {
-struct Event;
-struct ScrollEvent;
-} // namespace Input
-
-class Server;
-class XMLPDF;
-class DemoPlayer;
-class PingusCounter;
-class PingusDemo;
-class Playfield;
-class SmallMap;
-class BButton;
-
-/** A DemoSession is analog to a GameSession, but instead of loading a
- level and letting the player play a game, a demo file will be
- loaded and the level will be played automatically. */
-class DemoSession : public GUIScreen
-{
-private:
- Pathname pathname;
-
- std::auto_ptr<Server> server;
- std::auto_ptr<PingusDemo> demo;
- std::vector<ServerEvent> events;
-
- PingusCounter* pcounter;
- Playfield* playfield;
- SmallMap* small_map;
-
- BButton* fastforward_button;
- BButton* pause_button;
- BButton* restart_button;
-
- bool pause;
- bool fast_forward;
-
-public:
- /** @param filename the complete filename of the demo file */
- DemoSession(const Pathname& pathname);
- ~DemoSession();
-
- /** Pass a delta to the screen */
- void update(float delta);
- void update_demo();
-
- void on_pause_press ();
- void on_fast_forward_press ();
- void on_escape_press ();
-
- void restart();
-
- void on_scroller_move(float x, float y);
-
- bool is_pause() { return pause; }
- bool is_fast_forward() { return fast_forward; }
-
- void resize(const Size& size);
-
-private:
- DemoSession (const DemoSession&);
- DemoSession& operator= (const DemoSession&);
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/font_test_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/font_test_screen.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/font_test_screen.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -1,123 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/font_test_screen.hpp"
-
-#include <iostream>
-
-#include "engine/input/event.hpp"
-#include "pingus/fonts.hpp"
-#include "util/string_util.hpp"
-#include "engine/display/drawing_context.hpp"
-#include "engine/display/display.hpp"
-#include "pingus/font_description.hpp"
-
-FontTestScreen::FontTestScreen(const Pathname& fontfile) :
- Screen(Display::get_size()),
- font(),
- reference(),
- scroll(),
- dark(true)
-{
- std::cout << "### Loading font file: " << fontfile << std::endl;
- font = Font(FontDescription(fontfile));
- reference =
Font(FontDescription(Pathname("images/fonts/reference-iso-8859-1.font",
Pathname::DATA_PATH)));
-}
-
-void
-FontTestScreen::draw(DrawingContext& gc)
-{
- int checker = 40;
- for(int y = 0; y < gc.get_height()/checker; y += 1)
- for(int x = 0; x < gc.get_width()/checker; x += 1)
- {
- if ((x+y) % 2 != 0)
- gc.draw_fillrect(Rect(x*checker, y*checker,
- x*checker + checker, y*checker + checker),
- dark ? Color(50, 50, 50) : Color(255, 255, 255));
- else
- gc.draw_fillrect(Rect(x*checker, y*checker,
- x*checker + checker, y*checker + checker),
- dark ? Color(0, 0, 0) : Color(200,200,200));
- }
-
- gc.print_left(Fonts::chalk_large, Vector2i(10, 10), "Pingus - Font Test");
-
- gc.push_modelview();
- gc.translate(scroll.x, scroll.y);
-
- for(int i = 0; i < 256; ++i)
- {
- int x = 64 + (i%20)*(font.get_height() + 24);
- int y = 64 + (i/20)*(font.get_height() + reference.get_height()*3);
-
- // print the actual character
- gc.print_left(reference,
- Vector2i(x,
- y - reference.get_height()),
- std::string(1, char(i)));
- // print the index number
- gc.print_left(reference,
- Vector2i(x,
- y + font.get_height()),
- StringUtil::to_string(i));
-
- if (font.get_width(char(i)))
- {
- gc.draw_rect(Rect(x, y,
- x+font.get_height(),
- y+font.get_height()),
- Color(0,0,255));
- gc.draw_rect(Rect(x, y,
- x + static_cast<int>(font.get_width(char(i))),
- y + font.get_height()),
- Color(255,0,255));
- gc.print_left(font, Vector2i(x, y),
- std::string(1, char(i)));
- }
- else
- {
- gc.draw_rect(Rect(x, y,
- x+font.get_height(),
- y+font.get_height()),
- Color(255,0,0));
- }
- }
- gc.pop_modelview();
-}
-
-void
-FontTestScreen::update(const Input::Event& event)
-{
- switch (event.type)
- {
- 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:
- scroll.x += static_cast<int>(event.scroll.x_delta);
- scroll.y += static_cast<int>(event.scroll.y_delta);
- break;
-
- default:
- break;
- }
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/font_test_screen.hpp
===================================================================
--- trunk/pingus/src/pingus/font_test_screen.hpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/font_test_screen.hpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -1,47 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_FONT_TEST_SCREEN_HPP
-#define HEADER_PINGUS_PINGUS_FONT_TEST_SCREEN_HPP
-
-#include "engine/screen/screen.hpp"
-#include "pingus/font.hpp"
-
-class Pathname;
-
-class FontTestScreen : public Screen
-{
-private:
- Font font;
- Font reference;
- Vector2i scroll;
- bool dark;
-
-public:
- FontTestScreen(const Pathname& fontfile);
-
- void draw(DrawingContext& gc);
- void update(const Input::Event& event);
- void update(float delta) {}
-
-private:
- FontTestScreen (const FontTestScreen&);
- FontTestScreen& operator= (const FontTestScreen&);
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/game_session.cpp
===================================================================
--- trunk/pingus/src/pingus/game_session.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/game_session.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,395 +0,0 @@
-// 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/game_session.hpp"
-
-#include <iostream>
-#include "engine/screen/screen_manager.hpp"
-#include "pingus/server.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "engine/display/display.hpp"
-
-#include "pingus/components/button_panel.hpp"
-#include "pingus/components/pingus_counter.hpp"
-#include "pingus/components/time_display.hpp"
-#include "pingus/components/smallmap.hpp"
-#include "pingus/components/playfield.hpp"
-#include "engine/input/event.hpp"
-#include "engine/sound/sound.hpp"
-#include "math/math.hpp"
-#include "pingus/resource.hpp"
-#include "pingus/pingu_holder.hpp"
-#include "pingus/world.hpp"
-#include "pingus/result_screen.hpp"
-#include "pingus/savegame_manager.hpp"
-#include "pingus/globals.hpp"
-#include "pingus/debug.hpp"
-
-GameSession::GameSession (const PingusLevel& arg_plf, bool
arg_show_result_screen) :
- plf(arg_plf),
- show_result_screen(arg_show_result_screen),
- server(),
- world_delay(),
- is_finished (false),
- button_panel (0),
- pcounter (0),
- playfield (0),
- time_display (0),
- small_map (0),
- armageddon_button(),
- forward_button(),
- pause_button(),
- pause(false),
- fast_forward(false)
-{
- server = std::auto_ptr<Server>(new Server(plf, true));
-
- // the world is initially on time
- world_delay = 0;
-
- pout(PINGUS_DEBUG_LOADING) << "GameSession" << std::endl;
-
- // -- Client stuff
-
- // These object will get deleted by the gui_manager
- button_panel = new ButtonPanel(this, Vector2i(0, (size.height - 150)/2));
-
- int world_width = server->get_world()->get_width();
- int world_height = server->get_world()->get_height();
-
- playfield = new Playfield(get_server(), this,
- Rect(Vector2i(Math::max((Display::get_width()
- world_width)/2, 0),
- Math::max((Display::get_height()
- world_height)/2, 0)),
- Size(Math::min(Display::get_width(),
world_width),
- Math::min(Display::get_height(),
world_height))));
-
- pcounter = new PingusCounter(get_server());
- small_map = new SmallMap(get_server(), playfield, Rect(Vector2i(5,
size.height - 105), Size(175, 100)));
- time_display = new TimeDisplay(this);
-
- gui_manager->add(playfield);
- gui_manager->add(button_panel);
- gui_manager->add(pcounter);
- gui_manager->add(small_map);
- gui_manager->add(time_display);
-
- armageddon_button = new ArmageddonButton(get_server(), Display::get_width()
- 40, Display::get_height() - 62);
- forward_button = new ForwardButton(this, Display::get_width() - 40 * 2,
Display::get_height() - 62);
- pause_button = new PauseButton(this, Display::get_width() - 40 * 3,
Display::get_height() - 62);
-
- gui_manager->add(armageddon_button);
- gui_manager->add(forward_button);
- gui_manager->add(pause_button);
-}
-
-GameSession::~GameSession ()
-{
-}
-
-void
-GameSession::update_server(float delta)
-{
- if (server->is_finished())
- {
- PinguHolder* pingu_holder = server->get_world()->get_pingus();
- Result result;
-
- result.plf = server->get_plf();
-
- result.saved = pingu_holder->get_number_of_exited();
- result.killed = pingu_holder->get_number_of_killed();
- result.total = server->get_plf().get_number_of_pingus();
-
- result.needed = server->get_plf().get_number_to_save();
-
- result.max_time = server->get_plf().get_time();
- result.used_time = server->get_time();
-
- { // Write the savegame
- Savegame savegame(result.plf.get_resname(),
- (result.saved >= result.needed) ? Savegame::FINISHED
: Savegame::ACCESSIBLE,
- result.used_time,
- result.saved);
- SavegameManager::instance()->store(savegame);
- }
-
- if (show_result_screen)
- ScreenManager::instance()->replace_screen(new ResultScreen(result));
- else
- ScreenManager::instance()->pop_screen();
-
- }
- else
- {
- // how much time we have to account for while doing world updates
- int time_passed = int(delta * 1000) + world_delay;
- // how much time each world update represents
- int update_time = game_speed;
-
- // update the world (and the objects in it) in constant steps to account
- // for the time the previous frame took
-
- // invariant: world_updates - the number of times the world
- // has been updated during this frame
- int world_updates = 0;
-
- while ((world_updates+1)*update_time <= time_passed)
- {
- if (!pause)
- {
- if (fast_forward)
- {
- for (int i = 0; i < fast_forward_time_scale; ++i)
- server->update();
- }
- else
- {
- server->update();
- }
- }
-
- world_updates++;
- }
- // save how far behind is the world compared to the actual time
- // so that we can account for that while updating in the next frame
- world_delay = time_passed - (world_updates*update_time);
- }
-}
-
-void
-GameSession::draw_background (DrawingContext& gc)
-{
- Rect rect = playfield->get_rect();
-
- if (rect != Rect(Vector2i(0,0), Size(Display::get_width(),
Display::get_height())))
- { // Draw a black border around the playfield when the playfield is
smaller then the screen
- Color border_color(0, 0, 0);
- // top
- gc.draw_fillrect(Rect(0, 0, Display::get_width(), rect.top),
- border_color);
- // bottom
- gc.draw_fillrect(Rect(0, rect.bottom, Display::get_width(),
Display::get_height()),
- border_color);
- // left
- gc.draw_fillrect(Rect(0, rect.top, rect.left, rect.bottom),
- border_color);
- // right
- gc.draw_fillrect(Rect(rect.right, rect.top, Display::get_width(),
rect.bottom),
- border_color);
- }
-}
-
-void
-GameSession::update(float delta)
-{
- update_server(delta);
- GUIScreen::update(delta);
-}
-
-void
-GameSession::update(const Input::Event& event)
-{
- GUIScreen::update(event);
-
- //std::cout << "Events: " << event.get_type () << std::endl;
-
- switch (event.type)
- {
- case Input::BUTTON_EVENT_TYPE:
- {
- const Input::ButtonEvent& ev = event.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;
-
- case Input::POINTER_EVENT_TYPE:
- // Ignore, is handled in GUIScreen
- break;
-
- case Input::AXIS_EVENT_TYPE:
- // ???
- process_axis_event (event.axis);
- break;
-
- case Input::SCROLLER_EVENT_TYPE:
- process_scroll_event(event.scroll);
- break;
-
- case Input::KEYBOARD_EVENT_TYPE:
- break;
-
- default:
- // unhandled event
- std::cout << "GameSession::process_events (): unhandled event: " <<
event.type << std::endl;
- break;
- }
-}
-
-void
-GameSession::process_scroll_event (const Input::ScrollEvent& ev)
-{
- playfield->scroll(static_cast<int>(-ev.x_delta),
- static_cast<int>(-ev.y_delta));
-}
-
-void
-GameSession::process_axis_event (const Input::AxisEvent& event)
-{
- // std::cout << "GameSession::process_axis_event ()" << std::endl;
- UNUSED_ARG(event);
-}
-
-void
-GameSession::do_restart()
-{
- server->send_finish_event();
-}
-
-bool
-GameSession::finished()
-{
- return is_finished;
-}
-
-void
-GameSession::set_finished()
-{
- is_finished = true;
- server->send_finish_event();
-}
-
-void
-GameSession:: on_escape_press ()
-{
- server->send_finish_event();
-}
-
-void
-GameSession:: on_pause_press ()
-{
- pause = !pause;
-}
-
-void
-GameSession::on_fast_forward_press ()
-{
- fast_forward = !fast_forward;
-}
-
-void
-GameSession::on_armageddon_press ()
-{
- server->send_armageddon_event();
-}
-
-void
-GameSession::on_action_axis_move (float move)
-{
- if (move > 0)
- button_panel->next_action ();
- else if (move < 0)
- button_panel->previous_action ();
-}
-
-void
-GameSession::on_startup ()
-{
- is_finished = false;
-
- if (maintainer_mode)
- std::cout << "Starting Music: " << server->get_plf().get_music() <<
std::endl;
-
- if (server->get_plf().get_music() == "none")
- {
- Sound::PingusSound::stop_music();
- }
- else
- {
- Sound::PingusSound::play_music(server->get_plf().get_music());
- }
-}
-
-Actions::ActionName
-GameSession::get_action_name() const
-{
- return button_panel->get_action_name();
-}
-
-void
-GameSession::set_fast_forward(bool value)
-{
- fast_forward = value;
-}
-
-bool
-GameSession::get_fast_forward() const
-{
- return fast_forward;
-}
-
-void
-GameSession::set_pause(bool value)
-{
- pause = value;
-}
-
-bool
-GameSession::get_pause() const
-{
- return pause;
-}
-
-void
-GameSession::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
-
- int world_width = server->get_world()->get_width();
- int world_height = server->get_world()->get_height();
-
- playfield->set_rect(Rect(Vector2i(Math::max((size.width - world_width)/2,
0),
- Math::max((size.height - world_height)/2,
0)),
- Size(Math::min(size.width, world_width),
- Math::min(size.height, world_height))));
-
- armageddon_button->set_rect(Rect(Vector2i(size.width - 40, size.height - 62),
- Size(38, 60)));
- forward_button->set_rect(Rect(Vector2i(size.width - 40*2, size.height - 62),
- Size(38, 60)));
- pause_button->set_rect(Rect(Vector2i(size.width - 40*3, size.height - 62),
- Size(38, 60)));
-
- small_map->set_rect(Rect(Vector2i(5, size.height - 105), Size(175, 100)));
-
- button_panel->set_pos(Vector2i(0, (size.height - 150)/2));
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/game_session.hpp
===================================================================
--- trunk/pingus/src/pingus/game_session.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/game_session.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,123 +0,0 @@
-// 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_GAME_SESSION_HPP
-#define HEADER_PINGUS_PINGUS_GAME_SESSION_HPP
-
-#include <string>
-#include <memory>
-#include "engine/screen/gui_screen.hpp"
-#include "pingus/pingus_level.hpp"
-#include "pingus/pingu_enums.hpp"
-
-namespace Input {
-struct ScrollEvent;
-struct AxisEvent;
-struct Event;
-}
-
-class ButtonPanel;
-class PingusCounter;
-class Playfield;
-class TimeDisplay;
-class SmallMap;
-class ArmageddonButton;
-class ForwardButton;
-class PauseButton;
-class Server;
-
-/** You can use this class to start up a game session, which consist
- of a single level. */
-class GameSession : public GUIScreen
-{
-private:
- /// The level data
- PingusLevel plf;
-
- bool show_result_screen;
-
- /// The server
- std::auto_ptr<Server> server;
-
- int world_delay; ///< how many milliseconds is the world behind the actual
time
-
- // -- Client stuff
- bool is_finished;
-
- ButtonPanel* button_panel;
- PingusCounter* pcounter;
- Playfield* playfield;
- TimeDisplay* time_display;
- SmallMap* small_map;
-
- ArmageddonButton* armageddon_button;
- ForwardButton* forward_button;
- PauseButton* pause_button;
-
- bool pause;
- bool fast_forward;
-
-public:
- GameSession(const PingusLevel& arg_plf, bool arg_show_result_screen);
- ~GameSession ();
-
- /** Pass a delta to the screen */
- void update_server(float delta);
-
- Server* get_server() { return server.get(); }
- Playfield* get_playfield() { return playfield; }
-
- void do_restart();
- bool finished();
- void set_finished();
-
- /** Update all parts of the world */
- void update (float delta);
- void update (const Input::Event& event);
- void draw_background (DrawingContext& gc);
-
- ButtonPanel* get_button_panel () { return button_panel; }
-
- // Overloaded GUIScreen stuff
- void on_startup ();
-
- void on_pause_press ();
- void on_fast_forward_press ();
- void on_armageddon_press ();
- void on_escape_press ();
- void on_action_axis_move (float);
-
- Actions::ActionName get_action_name() const;
-
- void set_fast_forward(bool value);
- bool get_fast_forward() const;
-
- void set_pause(bool value);
- bool get_pause() const;
-
- void resize(const Size&);
-private:
- void process_scroll_event (const Input::ScrollEvent&);
- void process_axis_event (const Input::AxisEvent&);
-
- GameSession (const GameSession&);
- GameSession& operator= (const GameSession&);
-};
-
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/pingus/global_event.cpp
===================================================================
--- trunk/pingus/src/pingus/global_event.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/global_event.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -23,12 +23,12 @@
#include "engine/display/screenshot.hpp"
#include "engine/screen/screen_manager.hpp"
-#include "pingus/addon_menu.hpp"
+#include "pingus/screens/addon_menu.hpp"
#include "pingus/config_manager.hpp"
#include "pingus/fps_counter.hpp"
#include "pingus/globals.hpp"
-#include "pingus/level_menu.hpp"
-#include "pingus/option_menu.hpp"
+#include "pingus/screens/level_menu.hpp"
+#include "pingus/screens/option_menu.hpp"
GlobalEvent global_event;
Deleted: trunk/pingus/src/pingus/level_menu.cpp
===================================================================
--- trunk/pingus/src/pingus/level_menu.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/level_menu.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,482 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/level_menu.hpp"
-
-#include <boost/format.hpp>
-#include <boost/function.hpp>
-#include <boost/bind.hpp>
-#include "gettext.h"
-#include "pingus/resource.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "pingus/fonts.hpp"
-#include "engine/display/drawing_context.hpp"
-#include "pingus/option_menu.hpp"
-#include "util/system.hpp"
-#include "engine/display/display.hpp"
-#include "engine/gui/rect_component.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "pingus/game_session.hpp"
-#include "pingus/start_screen.hpp"
-#include "pingus/globals.hpp"
-#include "engine/gui/surface_button.hpp"
-#include "engine/sound/sound.hpp"
-
-class LevelMenuAbortButton : public GUI::SurfaceButton
-{
-private:
- LevelMenu* parent;
-
-public:
- LevelMenuAbortButton(LevelMenu* p, int x, int y)
- : GUI::SurfaceButton(x, y,
- "core/start/back",
- "core/start/back_clicked",
- "core/start/back_hover"),
- parent(p)
- {
- }
-
- void draw(DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 55, y_pos),
_("Abort"));
- }
-
- void on_click() {
- parent->on_escape_press();
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-
-private:
- LevelMenuAbortButton(const LevelMenuAbortButton&);
- LevelMenuAbortButton & operator=(const LevelMenuAbortButton&);
-};
-
-class LevelScrollButton : public GUI::SurfaceButton
-{
-private:
- boost::function<void(void)> callback;
-
-public:
- LevelScrollButton(int x, int y, const std::string& str, boost::function<void
(void)> callback_)
- : GUI::SurfaceButton(x, y,
- str,
- str + "_pressed",
- str + "_hover"),
- callback(callback_)
- {
- }
-
- void on_click() {
- callback();
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound("tick");
- }
-
-private:
- LevelScrollButton(const LevelScrollButton&);
- LevelScrollButton & operator=(const LevelScrollButton&);
-};
-
-class LevelsetSelector : public GUI::RectComponent
-{
-private:
- LevelMenu* level_menu;
- typedef std::vector<Levelset*> Levelsets;
- Levelsets levelsets;
- Levelset* current_levelset;
- Sprite marker;
- int page;
-
-public:
- LevelsetSelector(LevelMenu* level_menu_, const Rect& rect_) :
- RectComponent(rect_),
- level_menu(level_menu_),
- levelsets(),
- current_levelset(),
- marker(),
- page(0)
- {
- marker = Sprite("core/menu/marker");
-
- std::string path = Pathname("levelsets",
Pathname::DATA_PATH).get_sys_path();
- System::Directory directory = System::opendir(path, "*.levelset");
- for(System::Directory::iterator i = directory.begin(); i !=
directory.end(); ++i)
- {
- levelsets.push_back(new Levelset(Pathname(path + "/" + i->name,
Pathname::SYSTEM_PATH)));
- }
- }
-
- ~LevelsetSelector()
- {
- for(Levelsets::iterator i = levelsets.begin(); i != levelsets.end(); ++i)
- {
- delete *i;
- }
- }
-
- void draw(DrawingContext& gc)
- {
- gc.push_modelview();
- gc.translate(rect.left, rect.top);
-
- gc.print_center(Fonts::chalk_large, Vector2i(rect.get_width()/2, -50),
_("Levelsets"));
-
- //gc.draw_fillrect(Rect(Vector2i(0,0), Size(rect.get_width(),
rect.get_height())),
- // Color(255, 255, 0, 100));
-
- int y = 0;
- for(int i = 3*page; (i < 3*(page+1)) && (i < int(levelsets.size())); ++i)
- {
- Levelset* levelset = levelsets[i];
-
- if (levelset == current_levelset)
- gc.draw(marker, Vector2i(0, y - 5));
-
- gc.draw(levelset->get_image(), Vector2i(30, y));
-
- gc.print_left(Fonts::chalk_normal, Vector2i(85+30, 15 + y),
_(levelset->get_title()));
- gc.print_left(Fonts::chalk_small, Vector2i(85+50, 40 + y),
_(levelset->get_description()));
-
- gc.print_right(Fonts::chalk_normal, Vector2i(rect.get_width() - 30, 15
+ y), (boost::format("%1% %2%%%") % _("Solved:") %
levelset->get_completion()).str());
- gc.print_right(Fonts::chalk_small, Vector2i(rect.get_width() - 30, 60
+ y), (boost::format("%1% %2%") % levelset->get_level_count() %
_("levels")).str());
-
- //gc.draw(ok_button, 620, y);
-
- y += 95;
- }
-
- int total_pages = (int(levelsets.size())+2)/3;
-
- gc.print_center(Fonts::chalk_normal, Vector2i(rect.get_width()/2, 360),
- (boost::format("%1% %2%/%3%") % _("Page") % (page+1) %
total_pages).str());
-
- gc.pop_modelview();
- }
-
- void next_page()
- {
- page += 1;
- if (page >= ((int)levelsets.size()+2)/3)
- page = ((int)levelsets.size()+2)/3 - 1;
- }
-
- void prev_page()
- {
- page -= 1;
- if (page < 0)
- page = 0;
- }
-
- void on_pointer_leave()
- {
- current_levelset = 0;
- }
-
- void on_pointer_move(int x, int y)
- {
- x -= rect.left;
- y -= rect.top;
-
- if (!levelsets.empty())
- {
- int i = y / 95 + page*3;
-
- if (i >= 0 && i < static_cast<int>(levelsets.size()))
- current_levelset = levelsets[i];
- else
- current_levelset = NULL;
- }
- }
-
- void on_primary_button_press (int x, int y)
- {
- on_pointer_move(x, y);
-
- if (current_levelset)
- {
- level_menu->set_levelset(current_levelset);
- }
- }
-
- void update_layout() {}
-
-private:
- LevelsetSelector(const LevelsetSelector&);
- LevelsetSelector & operator=(const LevelsetSelector&);
-};
-
-class LevelSelector : public GUI::RectComponent
-{
-private:
- LevelMenu* level_menu;
- Sprite marker;
- Sprite marker_locked;
- Levelset* levelset;
- int current_level;
- int page;
-
-public:
- LevelSelector(LevelMenu* level_menu_, const Rect& rect_)
- : RectComponent(rect_),
- level_menu(level_menu_),
- marker(),
- marker_locked(),
- levelset(0),
- current_level(-1),
- page(0)
- {
- marker = Sprite("core/menu/marker2");
- marker_locked = Sprite("core/menu/marker_locked");
- }
-
- void draw(DrawingContext& gc)
- {
- gc.push_modelview();
- gc.translate(rect.left, rect.top);
-
- gc.print_center(Fonts::chalk_large, Vector2i(rect.get_width()/2, -70),
_(levelset->get_title()));
-
- if (levelset)
- {
- levelset->refresh(); // should be better placed in on_startup() or so
-
- //gc.draw_fillrect(Rect(Vector2i(0,0), Size(rect.get_width(),
rect.get_height())),
- // Color(255, 255, 0, 100));
-
- gc.print_left(Fonts::chalk_normal, Vector2i(30, -32), _("Title"));
- gc.print_right(Fonts::chalk_normal, Vector2i(rect.get_width() - 30,
-32), _("Status"));
-
- int y = 0;
- for(int i = page*8; i < (page+1)*8 && i < levelset->get_level_count();
++i)
- {
- if (!levelset->get_level(i)->accessible)
- gc.draw(marker_locked, Vector2i(0, y));
- else if (i == current_level)
- gc.draw(marker, Vector2i(0, y));
-
- if (maintainer_mode)
- gc.print_left(Fonts::chalk_small, Vector2i(30, y+4),
levelset->get_level(i)->plf.get_resname());
- else
- gc.print_left(Fonts::chalk_small, Vector2i(30, y+4),
_(levelset->get_level(i)->plf.get_levelname()));
-
- if (levelset->get_level(i)->finished)
- gc.print_right(Fonts::chalk_small, Vector2i(rect.get_width()
-30, y+4), _("solved"));
- else
- gc.print_right(Fonts::chalk_small, Vector2i(rect.get_width()
-30, y+4), _("unsolved"));
-
- y += 32;
- }
- }
-
- gc.print_center(Fonts::chalk_normal, Vector2i(rect.get_width()/2, 360),
- (boost::format("%1% %2%/%3%") % _("Page") % (page+1) %
((levelset->get_level_count()+7)/8)).str());
-
- gc.pop_modelview();
- }
-
- void prev_page()
- {
- page -= 1;
- if (page < 0)
- page = 0;
- }
-
- void next_page()
- {
- page += 1;
- if (page >= (levelset->get_level_count()+7)/8)
- page = (levelset->get_level_count()+7)/8 - 1;
- }
-
- void set_levelset(Levelset* levelset_)
- {
- levelset = levelset_;
- }
-
- void on_pointer_leave()
- {
- current_level = -1;
- }
-
- int get_current_level(int x, int y)
- {
- int cl = current_level = y / 32 + page*8;
- if (cl < 0 || cl >= levelset->get_level_count())
- cl = -1;
- return cl;
- }
-
- void on_pointer_move(int x, int y)
- {
- x -= rect.left;
- y -= rect.top;
-
- current_level = y / 32 + page*8;
- if (current_level < 0 || current_level >= levelset->get_level_count())
- current_level = -1;
- }
-
- void on_primary_button_press (int x, int y)
- {
- on_pointer_move(x, y);
- if (current_level != -1)
- {
- if (levelset->get_level(current_level)->accessible)
- {
- ScreenManager::instance()->push_screen(new
StartScreen(levelset->get_level(current_level)->plf));
- }
- }
- }
-
- void update_layout() {}
-
-private:
- LevelSelector(const LevelSelector&);
- LevelSelector & operator=(const LevelSelector&);
-};
-
-LevelMenu::LevelMenu() :
- x_pos((Display::get_width() - default_screen_width)/2),
- y_pos((Display::get_height() - default_screen_height)/2),
- background("core/menu/wood"),
- blackboard("core/menu/blackboard"),
- ok_button(),
- level_selector(),
- levelset_selector(),
- abort_button(),
- next_button(),
- prev_button()
-{
- ok_button = Sprite("core/start/ok");
-
- levelset_selector = new LevelsetSelector(this, Rect(Vector2i(x_pos + 100,
y_pos + 140), Size(600, 285)));
- level_selector = new LevelSelector(this, Rect(Vector2i(x_pos + 100, y_pos
+ 160), Size(600, 256)));
-
- gui_manager->add(prev_button = new LevelScrollButton(Display::get_width()/2
+ 160,
- Display::get_height()/2
+ 145,
- "core/menu/arrow_left",
-
boost::bind(&LevelMenu::prev_page, this)));
-
- gui_manager->add(next_button = new LevelScrollButton(Display::get_width()/2
+ 230,
- Display::get_height()/2
+ 145,
- "core/menu/arrow_right",
-
boost::bind(&LevelMenu::next_page, this)));
-
- gui_manager->add(levelset_selector);
- gui_manager->add(level_selector);
- gui_manager->add(abort_button = new LevelMenuAbortButton(this,
-
Display::get_width()/2 - 300,
-
Display::get_height()/2 + 144));
-
- level_selector->hide();
-}
-
-LevelMenu::~LevelMenu()
-{
-}
-
-void
-LevelMenu::draw_background(DrawingContext& gc)
-{
- // Paint the background wood panel
- for(int y = 0; y < gc.get_height(); y += background.get_height())
- for(int x = 0; x < gc.get_width(); x += background.get_width())
- gc.draw(background, Vector2i(x, y));
-
- gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
-}
-
-void
-LevelMenu::on_escape_press()
-{
- if (level_selector->is_visible())
- {
- levelset_selector->show();
- level_selector->hide();
- }
- else
- {
- //std::cout << "OptionMenu: poping screen" << std::endl;
- ScreenManager::instance()->pop_screen();
- }
-}
-
-void
-LevelMenu::next_page()
-{
- if (level_selector->is_visible())
- level_selector->next_page();
- else
- levelset_selector->next_page();
-}
-
-void
-LevelMenu::prev_page()
-{
- if (level_selector->is_visible())
- level_selector->prev_page();
- else
- levelset_selector->prev_page();
-}
-
-void
-LevelMenu::set_levelset(Levelset* levelset)
-{
- if (levelset)
- {
- level_selector->set_levelset(levelset);
- levelset_selector->hide();
- level_selector->show();
- }
- else
- {
- levelset_selector->show();
- level_selector->hide();
- }
-}
-
-void
-LevelMenu::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
-
- x_pos = (size.width - default_screen_width)/2;
- y_pos = (size.height - default_screen_height)/2;
-
- levelset_selector->set_rect(Rect(Vector2i(x_pos + 100, y_pos + 140),
Size(600, 285)));
- level_selector ->set_rect(Rect(Vector2i(x_pos + 100, y_pos + 160),
Size(600, 256)));
-
- prev_button->set_pos(size.width /2 + 160,
- size.height/2 + 145);
-
- next_button->set_pos(size.width /2 + 230,
- size.height/2 + 145);
-
- abort_button->set_pos(size.width /2 - 300,
- size.height/2 + 144);
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/level_menu.hpp
===================================================================
--- trunk/pingus/src/pingus/level_menu.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/level_menu.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,70 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_LEVEL_MENU_HPP
-#define HEADER_PINGUS_PINGUS_LEVEL_MENU_HPP
-
-#include "pingus/levelset.hpp"
-#include "engine/display/sprite.hpp"
-#include "engine/screen/gui_screen.hpp"
-
-namespace GUI {
-class SurfaceButton;
-} // namespace GUI
-
-class LevelSelector;
-class LevelsetSelector;
-
-/** */
-class LevelMenu : public GUIScreen
-{
-private:
- int x_pos;
- int y_pos;
-
- Sprite background;
- Sprite blackboard;
- Sprite ok_button;
-
- LevelSelector* level_selector;
- LevelsetSelector* levelset_selector;
-
- GUI::SurfaceButton* abort_button;
- GUI::SurfaceButton* next_button;
- GUI::SurfaceButton* prev_button;
-
-public:
- LevelMenu();
- ~LevelMenu();
-
- void draw_background (DrawingContext& gc);
- void on_escape_press ();
-
- void set_levelset(Levelset* levelset);
-
- void next_page();
- void prev_page();
-
- void resize(const Size& size);
-
-private:
- LevelMenu (const LevelMenu&);
- LevelMenu& operator= (const LevelMenu&);
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/option_menu.cpp
===================================================================
--- trunk/pingus/src/pingus/option_menu.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/option_menu.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,410 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/option_menu.hpp"
-
-#include <set>
-#include <boost/bind.hpp>
-#include <sstream>
-#include <iostream>
-
-#include "pingus/config_manager.hpp"
-#include "pingus/globals.hpp"
-#include "gettext.h"
-#include "pingus/resource.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "pingus/fonts.hpp"
-#include "engine/display/display.hpp"
-#include "engine/display/drawing_context.hpp"
-#include "pingus/components/label.hpp"
-#include "pingus/components/check_box.hpp"
-#include "pingus/components/slider_box.hpp"
-#include "pingus/components/choice_box.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "engine/sound/sound.hpp"
-#include "tinygettext/dictionary_manager.hpp"
-#include "tinygettext/language.hpp"
-
-#define C(x) connections.push_back(x)
-
-extern tinygettext::DictionaryManager dictionary_manager;
-
-class OptionMenuCloseButton
- : public GUI::SurfaceButton
-{
-private:
- OptionMenu* parent;
-public:
- OptionMenuCloseButton(OptionMenu* p, int x, int y)
- : GUI::SurfaceButton(x, y,
- "core/start/ok",
- "core/start/ok_clicked",
- "core/start/ok_hover"),
- parent(p)
- {
- }
-
- void on_pointer_enter ()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound("tick");
- }
-
- void on_click() {
- parent->save_language();
- config_manager.save();
- parent->close_screen();
- Sound::PingusSound::play_sound("yipee");
- }
-
-private:
- OptionMenuCloseButton(const OptionMenuCloseButton&);
- OptionMenuCloseButton & operator=(const OptionMenuCloseButton&);
-};
-
-OptionMenu::OptionMenu() :
- background(),
- ok_button(),
- x_pos(),
- y_pos(),
- options(),
- fullscreen_box(),
- swcursor_box(),
- autoscroll_box(),
- mousegrab_box(),
- printfps_box(),
- master_volume_box(),
- sound_volume_box(),
- music_volume_box(),
- defaults_label(),
- defaults_box(),
- connections(),
- language(),
- language_map()
-{
- background = Sprite("core/menu/optionmenu");
- gui_manager->add(ok_button = new OptionMenuCloseButton(this,
-
Display::get_width()/2 + 225,
-
Display::get_height()/2 + 125));
-
- x_pos = 0;
- y_pos = 0;
-
- int resolutions[][2] = {
- { 640, 480 }, // 4:3, VGA
- { 768, 576 }, // 4:3, PAL
- { 800, 480 }, // Nokia N770, N800
- { 800, 600 }, // 4:3, SVGA
- { 1024, 768 }, // 4:3, XGA
- { 1152, 864 }, // 4:3
- { 1280, 720 }, // 16:9, HD-TV, 720p
- { 1280, 960 }, // 4:3
- { 1280, 1024 }, // 5:4
- { 1366, 768 }, // ~16:9, Wide XGA
- { 1440, 900, }, // 16:10
- { 1600, 1200 }, // 4:3, UXGA
- { 1680, 1050 }, // 16:10, WSXGA
- { 1920, 1080 }, // 16:9, HD-TV, 1080p
- { 1920, 1200 }, // 16:10
- { -1, -1 }
- };
- int current_choice = -1;
- int n;
-
- ChoiceBox* resolution_box = new ChoiceBox(Rect());
- for (n = 0; resolutions[n][0] != -1; ++n)
- {
- std::ostringstream ostr;
- ostr << resolutions[n][0] << "x" << resolutions[n][1];
- resolution_box->add_choice(ostr.str());
- if (Display::get_width() == resolutions[n][0] &&
- Display::get_height() == resolutions[n][1])
- {
- current_choice = n;
- }
- }
- resolution_box->add_choice("Custom");
- if (current_choice == -1)
- current_choice = n;
-
- resolution_box->set_current_choice(current_choice);
-
- tinygettext::Language current_language = dictionary_manager.get_language();
- language = current_language;
- n = 0;
-
- ChoiceBox* language_box = new ChoiceBox(Rect());
- std::set<tinygettext::Language> languages =
dictionary_manager.get_languages();
-
- for (std::set<tinygettext::Language>::iterator i = languages.begin(); i !=
languages.end(); ++i)
- {
- language_box->add_choice(i->str());
- if (current_language == *i)
- language_box->set_current_choice(current_choice);
- }
-
- ChoiceBox* scroll_box = new ChoiceBox(Rect());
- scroll_box->add_choice("Drag&Drop");
- scroll_box->add_choice("Rubberband");
-
- swcursor_box = new CheckBox(Rect());
- fullscreen_box = new CheckBox(Rect());
- autoscroll_box = new CheckBox(Rect());
- mousegrab_box = new CheckBox(Rect());
- printfps_box = new CheckBox(Rect());
-
- master_volume_box = new SliderBox(Rect());
- sound_volume_box = new SliderBox(Rect());
- music_volume_box = new SliderBox(Rect());
-
-
C(swcursor_box->on_change.connect(boost::bind(&OptionMenu::on_swcursor_change,
this, _1)));
-
C(fullscreen_box->on_change.connect(boost::bind(&OptionMenu::on_fullscreen_change,
this, _1)));
-
C(autoscroll_box->on_change.connect(boost::bind(&OptionMenu::on_autoscroll_change,
this, _1)));
-
C(mousegrab_box->on_change.connect(boost::bind(&OptionMenu::on_mousegrab_change,
this, _1)));
-
C(printfps_box->on_change.connect(boost::bind(&OptionMenu::on_printfps_change,
this, _1)));
-
-
C(master_volume_box->on_change.connect(boost::bind(&OptionMenu::on_master_volume_change,
this, _1)));
-
C(sound_volume_box->on_change.connect(boost::bind(&OptionMenu::on_sound_volume_change,
this, _1)));
-
C(music_volume_box->on_change.connect(boost::bind(&OptionMenu::on_music_volume_change,
this, _1)));
-
-
C(language_box->on_change.connect(boost::bind(&OptionMenu::on_language_change,
this, _1)));
-
C(resolution_box->on_change.connect(boost::bind(&OptionMenu::on_resolution_change,
this, _1)));
-
- add_item(_("Language:"), language_box);
- // add_item(_("Scroll Mode:"), scroll_box);
- add_item(_("Resolution:"), resolution_box);
- add_item(_("Fullscreen:"), fullscreen_box);
- add_item(_("Master Volume:"), master_volume_box);
- add_item(_("Sound Volume:"), sound_volume_box);
- add_item(_("Music Volume:"), music_volume_box);
- add_item(_("Autoscrolling:"), autoscroll_box);
- add_item(_("Print FPS:"), printfps_box);
- add_item(_("Mouse Grab:"), mousegrab_box);
- add_item(_("Software Cursor:"), swcursor_box);
-
- // Connect with ConfigManager
- mousegrab_box->set_state(config_manager.get_mouse_grab(), false);
-
C(config_manager.on_mouse_grab_change.connect(boost::bind(&CheckBox::set_state,
mousegrab_box, _1, false)));
-
- printfps_box->set_state(config_manager.get_print_fps(), false);
-
C(config_manager.on_print_fps_change.connect(boost::bind(&CheckBox::set_state,
printfps_box, _1, false)));
-
- fullscreen_box->set_state(config_manager.get_fullscreen(), false);
-
C(config_manager.on_fullscreen_change.connect(boost::bind(&CheckBox::set_state,
fullscreen_box, _1, false)));
-
- swcursor_box->set_state(config_manager.get_swcursor(), false);
-
C(config_manager.on_swcursor_change.connect(boost::bind(&CheckBox::set_state,
swcursor_box, _1, false)));
-
- autoscroll_box->set_state(config_manager.get_autoscroll(), false);
-
C(config_manager.on_autoscroll_change.connect(boost::bind(&CheckBox::set_state,
autoscroll_box, _1, false)));
-
- defaults_label = new Label(_("Reset to Defaults:"),
Rect(Vector2i(Display::get_width()/2 - 100, Display::get_height()/2 + 160),
Size(170, 32)));
- gui_manager->add(defaults_label);
- defaults_box = new CheckBox(Rect(Vector2i(Display::get_width()/2 - 100 +
170, Display::get_height()/2 + 160), Size(32, 32)));
- gui_manager->add(defaults_box);
-}
-
-void
-OptionMenu::add_item(const std::string& label, GUI::RectComponent* control)
-{
- int x_offset = (Display::get_width() - 800) / 2;
- int y_offset = (Display::get_height() - 600) / 2;
-
- Label* label_component = new Label(label, Rect(Vector2i(120 + x_pos * 312 +
x_offset, 177 + y_pos*32 + y_offset),
- Size(140, 32)));
- gui_manager->add(label_component);
- gui_manager->add(control);
-
- if (dynamic_cast<ChoiceBox*>(control))
- {
- control->set_rect(Rect(120 + x_pos * 312 + 140 + x_offset, 177 +
y_pos*32 + y_offset,
- 120 + x_pos * 312 + 256 + x_offset, 177 +
y_pos*32 + 32 + y_offset));
- }
- else if (dynamic_cast<SliderBox*>(control))
- {
- control->set_rect(Rect(120 + x_pos * 312 + 140 + x_offset, 177 +
y_pos*32 + y_offset,
- 120 + x_pos * 312 + 256 + x_offset, 177 +
y_pos*32 + 32 + y_offset));
- }
- else if (dynamic_cast<CheckBox*>(control))
- {
- control->set_rect(Rect(Vector2i(120 + x_pos * 312 + 156 + 32+28+8 +
x_offset, 177 + y_pos*32 + y_offset),
- Size(32, 32)));
- }
- else
- {
- assert(!"Unhandled control type");
- }
-
- options.push_back(Option(label_component, control));
-
- y_pos += 1;
- if (y_pos > 5)
- {
- y_pos = 0;
- x_pos += 1;
- }
-}
-
-OptionMenu::~OptionMenu()
-{
- for(Connections::iterator i = connections.begin(); i != connections.end();
++i)
- {
- (*i).disconnect();
- }
-}
-
-struct OptionEntry {
- OptionEntry(const std::string& left_,
- const std::string& right_)
- : left(left_), right(right_)
- {}
-
- std::string left;
- std::string right;
-};
-
-void
-OptionMenu::draw_background(DrawingContext& gc)
-{
- gc.fill_screen(Color(0, 0, 0));
-
- // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
- gc.draw(background, Vector2i(gc.get_width()/2 - background.get_width()/2,
gc.get_height()/2 - background.get_height()/2));
-
- gc.print_center(Fonts::chalk_large,
- Vector2i(gc.get_width()/2,
- gc.get_height()/2 - 210),
- _("Option Menu"));
-
- gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 225 + 30,
gc.get_height()/2 + 125 - 20), _("Close"));
-}
-
-void
-OptionMenu::on_escape_press()
-{
- std::cout << "OptionMenu: popping screen" << std::endl;
- ScreenManager::instance()->pop_screen();
-}
-
-void
-OptionMenu::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
-
- if (ok_button)
- ok_button->set_pos(size.width/2 + 225, size.height/2 + 125);
- if (defaults_label)
- defaults_label->set_rect(Rect(Vector2i(Display::get_width()/2 - 100,
Display::get_height()/2 + 160), Size(170, 32)));
- if (defaults_box)
- defaults_box->set_rect(Rect(Vector2i(Display::get_width()/2 - 100 + 170,
Display::get_height()/2 + 160), Size(32, 32)));
-
- if (options.empty())
- return;
-
- Rect rect;
- rect = options.front().label->get_rect();
- int x_diff = 120 + (size.width - 800) / 2 - rect.left;
- int y_diff = 177 + (size.height - 600) / 2 - rect.top;
-
- for(std::vector<Option>::iterator i = options.begin(); i != options.end();
++i)
- {
- rect = (*i).label->get_rect();
- (*i).label->set_rect(Rect(Vector2i(rect.left + x_diff, rect.top +
y_diff), rect.get_size()));
- rect = (*i).control->get_rect();
- (*i).control->set_rect(Rect(Vector2i(rect.left + x_diff, rect.top +
y_diff), rect.get_size()));
- }
-}
-
-void
-OptionMenu::close_screen()
-{
- ScreenManager::instance()->pop_screen();
-}
-
-void
-OptionMenu::on_swcursor_change(bool v)
-{
- config_manager.set_swcursor(v);
-}
-
-void
-OptionMenu::on_fullscreen_change(bool v)
-{
- config_manager.set_fullscreen(v);
-}
-
-void
-OptionMenu::on_autoscroll_change(bool v)
-{
- config_manager.set_autoscroll(v);
-}
-
-void
-OptionMenu::on_mousegrab_change(bool v)
-{
- config_manager.set_mouse_grab(v);
-}
-
-void
-OptionMenu::on_printfps_change(bool v)
-{
- config_manager.set_print_fps(v);
-}
-
-void
-OptionMenu::on_master_volume_change(int v)
-{
- config_manager.set_master_volume(v);
-}
-
-void
-OptionMenu::on_sound_volume_change(int v)
-{
- config_manager.set_sound_volume(v);
-}
-
-void
-OptionMenu::on_music_volume_change(int v)
-{
- config_manager.set_music_volume(v);
-}
-
-void
-OptionMenu::on_language_change(const std::string &str)
-{
- language = str;
-}
-
-void
-OptionMenu::on_resolution_change(const std::string& str)
-{
- if (str != "Custom")
- {
- Size size_;
- if (sscanf(str.c_str(), "%dx%d", &size_.width, &size_.height) == 2)
- {
- config_manager.set_resolution(size_);
- }
- }
-}
-
-void
-OptionMenu::save_language()
-{
- config_manager.set_language(language_map[language]);
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/option_menu.hpp
===================================================================
--- trunk/pingus/src/pingus/option_menu.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/option_menu.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,108 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_OPTION_MENU_HPP
-#define HEADER_PINGUS_PINGUS_OPTION_MENU_HPP
-
-#include <vector>
-#include <map>
-#include <boost/signals.hpp>
-#include "engine/display/sprite.hpp"
-#include "engine/screen/gui_screen.hpp"
-#include "pingus/components/label.hpp"
-#include "engine/gui/rect_component.hpp"
-#include "engine/gui/surface_button.hpp"
-#include "tinygettext/language.hpp"
-
-class CheckBox;
-class SliderBox;
-
-/** */
-class OptionMenu : public GUIScreen
-{
-private:
- Sprite background;
- GUI::SurfaceButton* ok_button;
- int x_pos;
- int y_pos;
-
- struct Option {
- Label* label;
- GUI::RectComponent* control;
-
- Option(Label* label_, GUI::RectComponent* control_)
- : label(label_), control(control_)
- {}
- };
-
- typedef std::vector<Option> Options;
- Options options;
-
- CheckBox* fullscreen_box;
- CheckBox* swcursor_box;
- CheckBox* autoscroll_box;
- CheckBox* mousegrab_box;
- CheckBox* printfps_box;
-
- SliderBox* master_volume_box;
- SliderBox* sound_volume_box;
- SliderBox* music_volume_box;
-
- Label* defaults_label;
- CheckBox* defaults_box;
-
- typedef std::vector<boost::signals::connection> Connections;
- Connections connections;
-
- std::string language;
- std::map<std::string, tinygettext::Language> language_map;
-
-public:
- OptionMenu();
- ~OptionMenu();
-
- void draw_background (DrawingContext& gc);
- void on_escape_press ();
-
- void add_item(const std::string& label, GUI::RectComponent* control);
-
- void resize(const Size&);
- void close_screen();
-
- void on_swcursor_change(bool v);
- void on_fullscreen_change(bool v);
- void on_autoscroll_change(bool v);
- void on_fastmode_change(bool v);
- void on_mousegrab_change(bool v);
- void on_printfps_change(bool v);
-
- void on_master_volume_change(int v);
- void on_sound_volume_change(int v);
- void on_music_volume_change(int v);
-
- void on_language_change(const std::string& str);
- void on_resolution_change(const std::string& str);
-
- void save_language();
-
-private:
- OptionMenu (const OptionMenu&);
- OptionMenu& operator= (const OptionMenu&);
-};
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/pingus/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_main.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/pingus_main.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -26,12 +26,12 @@
#include "lisp/parser.hpp"
#include "editor/editor_level.hpp"
#include "util/string_util.hpp"
-#include "pingus/demo_session.hpp"
+#include "pingus/screens/demo_session.hpp"
#include "util/sexpr_file_reader.hpp"
#include "pingus/fonts.hpp"
#include "pingus/config_manager.hpp"
#include "engine/display/display.hpp"
-#include "pingus/pingus_menu.hpp"
+#include "pingus/screens/pingus_menu.hpp"
#if defined(__APPLE__)
/* Can't use the include, some type names conflict.
@@ -66,18 +66,18 @@
#include "pingus/pingus_error.hpp"
#include "pingus/fps_counter.hpp"
#include "pingus/plf_res_mgr.hpp"
-#include "pingus/game_session.hpp"
-#include "pingus/story_screen.hpp"
+#include "pingus/screens/game_session.hpp"
+#include "pingus/screens/story_screen.hpp"
-#include "pingus/start_screen.hpp"
+#include "pingus/screens/start_screen.hpp"
#include "pingus/savegame_manager.hpp"
#include "pingus/stat_manager.hpp"
#include "pingus/debug.hpp"
#include "pingus/resource.hpp"
-#include "pingus/credits.hpp"
+#include "pingus/screens/credits.hpp"
#include "engine/sound/sound.hpp"
#include "pingus/worldmap/worldmap_screen.hpp"
-#include "pingus/font_test_screen.hpp"
+#include "pingus/screens/font_test_screen.hpp"
#include "pingus/worldmap/worldmap_screen.hpp"
#include "pingus/worldobj_factory.hpp"
Deleted: trunk/pingus/src/pingus/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_menu.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/pingus_menu.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,274 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 1999 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/pingus_menu.hpp"
-
-#include <config.h>
-#include "gettext.h"
-#include "pingus/components/menu_button.hpp"
-#include "pingus/resource.hpp"
-#include "pingus/debug.hpp"
-#include "pingus/globals.hpp"
-#include "engine/sound/sound.hpp"
-#include "pingus/level_menu.hpp"
-#include "pingus/stat_manager.hpp"
-#include "pingus/start_screen.hpp"
-#include "pingus/story_screen.hpp"
-#include "pingus/worldmap/worldmap.hpp"
-#include "pingus/worldmap/worldmap_screen.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "pingus/plf_res_mgr.hpp"
-#include "pingus/path_manager.hpp"
-#include "util/pathname.hpp"
-#include "editor/editor_screen.hpp"
-#include "pingus/credits.hpp"
-#include "pingus/layer_manager.hpp"
-
-PingusMenu::PingusMenu() :
- is_init(),
- hint(),
- help(),
- text_scroll_offset(),
- background(),
- logo(),
- start_button(),
- quit_button(),
- editor_button(),
- contrib_button()
-{
- is_init = false;
-
- Size size_(Display::get_width(), Display::get_height());
-
- start_button = new MenuButton(this, Vector2i(size_.width/2 - 150,
- size_.height/2 + 20),
- _("Story"),
- _("..:: Start the game ::.."));
-
- editor_button = new MenuButton(this, Vector2i(size_.width/2 + 150,
- size_.height/2 + 20),
- _("Editor"),
- _("..:: Create your own levels ::.."));
-
- quit_button = new MenuButton(this, Vector2i(size_.width/2 + 150,
- size_.height/2 + 100),
- _("Exit"),
- _("..:: Bye, bye ::.."));
-
- contrib_button = new MenuButton(this, Vector2i(size_.width/2 - 150,
- size_.height/2 + 100),
- _("Levelsets"),
- _("..:: Play User Built levels ::.."));
-
- gui_manager->add(quit_button);
- gui_manager->add(contrib_button);
- gui_manager->add(start_button);
- gui_manager->add(editor_button);
-
- logo = Sprite("core/misc/logo");
-
- create_background(Size(Display::get_width(), Display::get_height()));
-
- help = _("..:: Ctrl-g: mouse grab :: F10: fps counter :: F11:
fullscreen :: F12: screenshot ::..");
-}
-
-PingusMenu::~PingusMenu()
-{
-}
-
-void
-PingusMenu::show_credits()
-{
- ScreenManager::instance()->push_screen(new Credits());
-}
-
-void
-PingusMenu::do_quit()
-{
- ScreenManager::instance ()->pop_screen ();
-}
-
-void
-PingusMenu::do_start(const std::string &filename)
-{ // Start the story or worldmap mode
- Sound::PingusSound::play_sound ("letsgo");
-
-#if 0 // FIXME: Fri Jul 4 10:33:01 2008
- bool story_seen = false;
- StatManager::instance()->get_bool("tutorial-startstory-seen", story_seen);
// FIXME: Hardcoding tutorial is evil
-
- if (!story_seen)
- {
- ScreenManager::instance()->push_screen
- (new
StoryScreen(WorldmapNS::WorldmapScreen::instance()->get_worldmap()->get_intro_story()),
true);
- }
- else
-#endif
- {
- std::auto_ptr<WorldmapNS::WorldmapScreen> worldmap_screen(new
WorldmapNS::WorldmapScreen());
- worldmap_screen->load(filename);
- ScreenManager::instance()->push_screen(worldmap_screen.release());
- }
-}
-
-void PingusMenu::do_contrib(const std::string &levelfile)
-{ // Launch the specified level - don't bother checking for it, it has to exist
- Sound::PingusSound::play_sound ("letsgo");
- ScreenManager::instance()->push_screen
- (new StartScreen(PLFResMgr::load_plf_from_filename(Pathname(levelfile,
Pathname::SYSTEM_PATH))));
-}
-
-void PingusMenu::do_edit()
-{ // Launch the level editor
- Sound::PingusSound::stop_music();
- ScreenManager::instance()->push_screen (new Editor::EditorScreen());
-}
-
-void
-PingusMenu::on_escape_press ()
-{
- //FIXME: get_manager()->show_exit_menu ();
-}
-
-void
-PingusMenu::draw_background(DrawingContext& gc)
-{
- background->draw(gc);
-
- gc.draw(logo, Vector2i((gc.get_width()/2) - (logo.get_width()/2),
- gc.get_height()/2 - 250));
-
- gc.print_left(Fonts::pingus_small, Vector2i(25, gc.get_height()-140),
- "Pingus "VERSION", Copyright (C) 1998-2007 Ingo Ruhnke
<address@hidden>\n"
- "See the file AUTHORS for a complete list of contributors.\n"
- "Pingus comes with ABSOLUTELY NO WARRANTY. This is free
software, and you are\n"
- "welcome to redistribute it under certain conditions; see the
file COPYING for details.\n");
-
- gc.draw_fillrect(Rect(0,
- Display::get_height () - 26,
- Display::get_width (),
- Display::get_height ()),
- Color(0, 0, 0, 255));
-
- gc.print_center(Fonts::pingus_small,
- Vector2i(gc.get_width() / 2,
- gc.get_height() - Fonts::pingus_small.get_height()
- 8),
- help);
-
- if (0) // display hint
- {
- gc.print_center(Fonts::pingus_small,
- Vector2i(gc.get_width() / 2,
- gc.get_height() -
Fonts::pingus_small.get_height()),
- hint);
- }
-}
-
-void
-PingusMenu::on_click(MenuButton* button)
-{
- if (button == start_button)
- {
- do_start("worldmaps/tutorial.worldmap");
- }
- else if (button == quit_button)
- {
- do_quit();
- }
- else if (button == editor_button)
- {
- do_edit();
- }
- else if (button == contrib_button)
- {
- ScreenManager::instance()->push_screen(new LevelMenu());
- }
-}
-
-void
-PingusMenu::set_hint(const std::string& str)
-{
- hint = str;
-}
-
-void
-PingusMenu::update(float delta)
-{
- background->update(delta);
-}
-
-void
-PingusMenu::create_background(const Size& size_)
-{
- // Recreate the layer manager in the new size
- background = std::auto_ptr<LayerManager>(new LayerManager());
-
- Surface layer1 = Resource::load_surface("core/menu/layer1");
- Surface layer2 = Resource::load_surface("core/menu/layer2");
- Surface layer3 = Resource::load_surface("core/menu/layer3");
- Surface layer4 = Resource::load_surface("core/menu/layer4");
- Surface layer5 = Resource::load_surface("core/menu/layer5");
-
- int w = size_.width;
- int h = size_.height;
-
-// We only need to scale the background main menu images if the screen
- // resolution is not default
- if (w != default_screen_width && h != default_screen_height)
- {
- layer1 = layer1.scale(w, 185 * h / default_screen_height);
- layer2 = layer2.scale(w, 362 * h / default_screen_height);
- layer3 = layer3.scale(w, 306 * h / default_screen_height);
- layer4 = layer4.scale(w, 171 * h / default_screen_height);
- layer5 = layer5.scale(302 * w / default_screen_width, 104 * h /
default_screen_height);
-
- background->add_layer(Sprite(layer1), 0, 0, 12, 0);
- background->add_layer(Sprite(layer2), 0, 150 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 25, 0);
- background->add_layer(Sprite(layer3), 0, 200 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 50, 0);
- background->add_layer(Sprite(layer4), 0, 429 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 100, 0);
- background->add_layer(Sprite(layer5), 0, 500 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 200, 0);
- }
- else
- {
- background->add_layer(Sprite(layer1), 0, 0, 12, 0);
- background->add_layer(Sprite(layer2), 0, 150, 25, 0);
- background->add_layer(Sprite(layer3), 0, 200, 50, 0);
- background->add_layer(Sprite(layer4), 0, 429, 100, 0);
- background->add_layer(Sprite(layer5), 0, 500, 200, 0);
- }
-}
-
-void
-PingusMenu::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
- create_background(size);
-
- start_button->set_pos(size.width/2 - 150,
- size.height/2 + 20);
-
- editor_button->set_pos(size.width/2 + 150,
- size.height/2 + 20);
-
- contrib_button->set_pos(size.width/2 - 150,
- size.height/2 + 100);
-
- quit_button->set_pos(size.width/2 + 150,
- size.height/2 + 100);
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/pingus_menu.hpp
===================================================================
--- trunk/pingus/src/pingus/pingus_menu.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/pingus_menu.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,85 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 1999 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_PINGUS_MENU_HPP
-#define HEADER_PINGUS_PINGUS_PINGUS_MENU_HPP
-
-#include <vector>
-#include <memory>
-
-#include "pingus/fonts.hpp"
-#include "engine/display/sprite.hpp"
-#include "engine/screen/gui_screen.hpp"
-
-namespace GUI {
-class GUIManager;
-} // namespace GUI
-
-class SurfaceButton;
-class GameDelta;
-class LayerManager;
-class MenuButton;
-
-class PingusMenu : public GUIScreen
-{
-public:
- bool is_init;
- std::string hint;
- std::string help;
- float text_scroll_offset;
-
-private:
- std::auto_ptr<LayerManager> background;
- Sprite logo;
-
- MenuButton* start_button;
- MenuButton* quit_button;
- MenuButton* editor_button;
- MenuButton* contrib_button;
-
- void show_credits();
-
- void do_quit();
- void do_start(const std::string &filename);
- void do_edit();
-
- void create_background(const Size& size);
-
-public:
- PingusMenu();
- ~PingusMenu();
-
- void on_click(MenuButton* button);
- void set_hint(const std::string& str);
-
- /// Load all images and other stuff for the menu
- void do_contrib(const std::string&);
-
- void on_escape_press ();
- void draw_background(DrawingContext& gc);
-
- void update(float delta);
-
- void resize(const Size& size);
-
-private:
- PingusMenu (const PingusMenu&);
- PingusMenu& operator= (const PingusMenu&);
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/result_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/result_screen.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/result_screen.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,342 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/result_screen.hpp"
-
-#include <iostream>
-#include "gettext.h"
-#include "engine/display/display.hpp"
-#include "engine/gui/surface_button.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "engine/display/blitter.hpp"
-#include "pingus/res_descriptor.hpp"
-#include "pingus/resource.hpp"
-#include "pingus/fonts.hpp"
-#include "pingus/game_session.hpp"
-#include "util/system.hpp"
-#include "util/string_util.hpp"
-#include "engine/sound/sound.hpp"
-#include "pingus/game_time.hpp"
-
-class ResultScreenComponent : public GUI::Component
-{
-public:
- Result result;
- Sprite background;
- Sprite blackboard;
- std::string time_str;
-
- ResultScreenComponent(Result arg_result);
- virtual ~ResultScreenComponent() {}
- void draw(DrawingContext& gc) ;
-};
-
-class ResultScreenOkButton
- : public GUI::SurfaceButton
-{
-private:
- ResultScreen* parent;
-public:
- ResultScreenOkButton(ResultScreen* p, int x, int y)
- : GUI::SurfaceButton(x, y,
- "core/start/ok",
- "core/start/ok_clicked",
- "core/start/ok_hover"),
- parent(p)
- {
- }
-
- void on_pointer_enter ()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound("tick");
- }
-
- void on_click() {
- parent->close_screen();
- Sound::PingusSound::play_sound("yipee");
- }
-
-private:
- ResultScreenOkButton(const ResultScreenOkButton&);
- ResultScreenOkButton & operator=(const ResultScreenOkButton&);
-};
-
-class ResultScreenAbortButton
- : public GUI::SurfaceButton
-{
-private:
- ResultScreen* parent;
-public:
- ResultScreenAbortButton(ResultScreen* p, int x, int y)
- : GUI::SurfaceButton(x, y,
- "core/start/back",
- "core/start/back_clicked",
- "core/start/back_hover"),
- parent(p)
- {
- }
-
- void draw(DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 55, y_pos - 4),
_("Abort"));
- }
-
- void on_click() {
- parent->close_screen();
- }
-
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-
-private:
- ResultScreenAbortButton(const ResultScreenAbortButton&);
- ResultScreenAbortButton & operator=(const ResultScreenAbortButton&);
-};
-
-class ResultScreenRetryButton : public GUI::SurfaceButton
-{
-private:
- ResultScreen* parent;
-
-public:
- ResultScreenRetryButton(ResultScreen* p, int x, int y)
- : GUI::SurfaceButton(x, y,
- "core/start/ok",
- "core/start/ok_clicked",
- "core/start/ok_hover"),
- parent(p)
- {
- }
-
- void draw (DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 30, y_pos - 24),
_("Retry"));
- }
-
- bool is_at(int x, int y) {
- return x > x_pos && x < x_pos + int(button_surface.get_width())
- && y > y_pos - 24 &&
- y < y_pos + int(button_surface.get_height());
- }
-
- void on_click()
- {
- parent->retry_level();
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-
-private:
- ResultScreenRetryButton(const ResultScreenRetryButton&);
- ResultScreenRetryButton & operator=(const ResultScreenRetryButton&);
-};
-
-ResultScreenComponent::ResultScreenComponent(Result arg_result) :
- result(arg_result),
- background("core/menu/wood"),
- blackboard("core/menu/blackboard"),
- time_str()
-{
- if (result.max_time == -1)
- time_str = "-";
- else
- time_str = GameTime::ticks_to_realtime_string(result.max_time -
result.used_time);
-}
-
-void
-ResultScreenComponent::draw(DrawingContext& gc)
-{
- // Paint the background wood panel
- for(int y = 0; y < gc.get_height(); y += background.get_height())
- for(int x = 0; x < gc.get_width(); x += background.get_width())
- gc.draw(background, Vector2i(x, y));
-
- gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
-
- gc.print_center(Fonts::chalk_large,
- Vector2i(gc.get_width()/2,
- Display::get_height()/2 - 200),
- _(result.plf.get_levelname()));
-
- if (result.success())
- {
- gc.print_center(Fonts::chalk_large,
- Vector2i(gc.get_width()/2,
- Display::get_height()/2 - 140),
- _("Success!"));
- /*gc.print_center(Fonts::pingus_small, gc.get_width()/2,
gc.get_height()-30,
- "..:: Press Space to continue ::..");*/
- }
- else
- {
- gc.print_center(Fonts::chalk_large,
- Vector2i(gc.get_width()/2, Display::get_height()/2 -
140),
- _("Failure!"));
- /*gc.print_center(Fonts::pingus_normal, gc.get_width()/2,
gc.get_height()-30,
- "..:: Press Space to retry the level ::..");*/
- }
-
- std::string message;
- if (result.success())
- {
- if (result.killed == 0 && result.saved == result.total)
- message = _("Perfect! You saved everyone possible - great!");
- else if (result.killed == 0)
- message = _("No-one got killed, pretty good work.");
- else if (result.saved == result.needed)
- message = _("You saved exactly what you needed - you made it, but\n"
- "maybe you can do better?");
- else if (result.killed >= 5)
- message = _("Not everybody was saved, but still good work!");
- else
- message = _("What can I say, you made it - congratulations!");
- }
- else
- {
- if (result.killed == result.total)
- message = _("You killed everybody, not good.");
- else if (result.saved == 0)
- message = _("No-one got saved - I know you can do better.");
- else if (result.saved > 0)
- message = _("You didn't save enough, but you saved a few. Next\n"
- "time you might do better.");
- else if (result.saved + 1 >= result.needed)
- message = _("Only one more and you would have made it - try again!");
- else if (result.saved + 5 >= result.needed)
- message = _("Only a handful more and you would have made it - try
again!");
- else
- message = _("Better luck next time!");
- }
- gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2,
gc.get_height()/2 - 70), message);
-
- int left_x = gc.get_width()/2 - 100;
- int right_x = gc.get_width()/2 + 100;
- int y = Display::get_height()/2 + 10;
-
- gc.print_left(Fonts::chalk_normal, Vector2i(left_x, y), _("Saved: "));
- gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(result.saved)
- + "/" + StringUtil::to_string(result.needed));;
-
- gc.print_left(Fonts::chalk_normal, Vector2i(left_x, (y+=30)), _("Died: "));
- gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(result.killed));
-
-
- gc.print_left(Fonts::chalk_normal, Vector2i(left_x, (y+=30)), _("Time left:
"));
- gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), time_str);
-}
-
-ResultScreen::ResultScreen(Result arg_result) :
- result(arg_result),
- ok_button(),
- abort_button(),
- retry_button()
-{
- ResultScreenComponent* comp = new ResultScreenComponent(result);
- gui_manager->add(comp);
-
- ok_button = abort_button = retry_button = 0;
-
- if (result.success())
- {
- gui_manager->add(ok_button = new ResultScreenOkButton(this,
-
Display::get_width()/2 + 225,
-
Display::get_height()/2 + 125));
- }
- else
- {
- gui_manager->add(abort_button = new ResultScreenAbortButton(this,
-
Display::get_width()/2 - 278,
-
Display::get_height()/2 + 144));
- gui_manager->add(retry_button = new ResultScreenRetryButton(this,
-
Display::get_width()/2 + 225,
-
Display::get_height()/2 + 125));
- }
-
- //gui_manager->add(new GUI::SurfaceButton(500, 500, cancel_desc,
cancel_desc, cancel_desc), true);
-}
-
-void
-ResultScreen::on_startup()
-{
- if (result.success())
- {
- Sound::PingusSound::play_music("success_1.it", 1.f, false);
- }
- else
- {
- Sound::PingusSound::play_music("pingus-2.it", 1.f, false);
- }
-}
-
-void
-ResultScreen::retry_level()
-{
- ScreenManager::instance()->replace_screen(new GameSession (result.plf,
true));
-}
-
-void
-ResultScreen::close_screen()
-{
- ScreenManager::instance()->pop_screen();
-}
-
-void
-ResultScreen::on_fast_forward_press()
-{
- on_pause_press();
-}
-
-void
-ResultScreen::on_pause_press()
-{
- if (result.success())
- close_screen();
- else
- retry_level();
-}
-
-void
-ResultScreen::on_escape_press()
-{
- close_screen();
-}
-
-void
-ResultScreen::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
-
- if (ok_button)
- ok_button->set_pos(size.width/2 + 225, size.height/2 + 125);
-
- if (abort_button)
- abort_button->set_pos(size.width/2 - 278, size.height/2 + 144);
-
- if (retry_button)
- retry_button->set_pos(size.width/2 + 225, size.height/2 + 125);
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/result_screen.hpp
===================================================================
--- trunk/pingus/src/pingus/result_screen.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/result_screen.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,55 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_RESULT_SCREEN_HPP
-#define HEADER_PINGUS_PINGUS_RESULT_SCREEN_HPP
-
-#include "pingus/result.hpp"
-#include "engine/screen/gui_screen.hpp"
-
-namespace GUI {
-class SurfaceButton;
-} // namespace GUI
-
-/** */
-class ResultScreen : public GUIScreen
-{
-private:
- Result result;
- GUI::SurfaceButton* ok_button;
- GUI::SurfaceButton* abort_button;
- GUI::SurfaceButton* retry_button;
-
-public:
- ResultScreen(Result result);
- void on_startup();
-
- void on_pause_press();
- void on_fast_forward_press();
- void on_escape_press();
-
- void retry_level();
- void close_screen();
-
- void resize(const Size&);
-private:
- ResultScreen (const ResultScreen&);
- ResultScreen& operator= (const ResultScreen&);
-};
-
-#endif
-
-/* EOF */
Copied: trunk/pingus/src/pingus/screens/addon_menu.cpp (from rev 4041,
trunk/pingus/src/pingus/addon_menu.cpp)
===================================================================
--- trunk/pingus/src/pingus/addon_menu.cpp 2009-11-05 22:48:38 UTC (rev
4041)
+++ trunk/pingus/src/pingus/screens/addon_menu.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,65 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/addon_menu.hpp"
+
+#include "pingus/gettext.h"
+#include "pingus/resource.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "pingus/fonts.hpp"
+#include "engine/display/drawing_context.hpp"
+#include "pingus/screens/option_menu.hpp"
+
+AddOnMenu::AddOnMenu() :
+ background(),
+ ok_button()
+{
+ background = Sprite("core/menu/filedialog");
+ ok_button = Sprite("core/start/ok");
+}
+
+AddOnMenu::~AddOnMenu()
+{
+}
+
+void
+AddOnMenu::draw_background(DrawingContext& gc)
+{
+ // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
+ gc.draw(background, Vector2i(gc.get_width()/2 - background.get_width()/2,
gc.get_height()/2 - background.get_height()/2));
+
+ gc.print_center(Fonts::chalk_large, Vector2i(gc.get_width()/2, 90), "Add-On
Menu");
+
+ gc.print_left(Fonts::chalk_normal, Vector2i(120, 145), "X-Mas Pingus
Sprites");
+ gc.print_left(Fonts::chalk_small, Vector2i(140, 170), "christmas look for
penguins");
+ gc.print_left(Fonts::chalk_small, Vector2i(140, 190), "Author: John Foo
<address@hidden>");
+
+ gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2,
gc.get_height()/2 + 160), "Update Online [ ]");
+
+ gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 225 + 30,
gc.get_height()/2 + 125 - 20), _("Close"));
+ gc.draw(ok_button, Vector2i(gc.get_width()/2 + 225, gc.get_height()/2 +
125));
+
+ gc.draw(ok_button, Vector2i(610, 145));
+}
+
+void
+AddOnMenu::on_escape_press()
+{
+ //std::cout << "OptionMenu: poping screen" << std::endl;
+ ScreenManager::instance()->pop_screen();
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/addon_menu.hpp (from rev 4043,
trunk/pingus/src/pingus/addon_menu.hpp)
Copied: trunk/pingus/src/pingus/screens/credits.cpp (from rev 4044,
trunk/pingus/src/pingus/credits.cpp)
===================================================================
--- trunk/pingus/src/pingus/credits.cpp 2009-11-05 23:13:19 UTC (rev 4044)
+++ trunk/pingus/src/pingus/screens/credits.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -0,0 +1,341 @@
+// 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/credits.hpp"
+
+#include <iostream>
+#include "engine/screen/screen_manager.hpp"
+#include "engine/gui/surface_button.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "engine/sound/sound.hpp"
+#include "pingus/stat_manager.hpp"
+#include "pingus/resource.hpp"
+#include "pingus/res_descriptor.hpp"
+#include "pingus/fonts.hpp"
+#include "pingus/gettext.h"
+#include "engine/display/display.hpp"
+#include "engine/display/blitter.hpp"
+
+class CreditsOkButton
+ : public GUI::SurfaceButton
+{
+private:
+ Credits* parent;
+public:
+ CreditsOkButton(Credits* p)
+ : GUI::SurfaceButton(Display::get_width()/2 + 260,
+ Display::get_height()/2 + 170,
+ "core/start/ok",
+ "core/start/ok_clicked",
+ "core/start/ok_hover"),
+ parent(p)
+ {
+ }
+
+ void on_pointer_enter ()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound("tick");
+ }
+
+ void on_click() {
+ parent->on_escape_press();
+ Sound::PingusSound::play_sound("yipee");
+ }
+
+private:
+ CreditsOkButton(const CreditsOkButton&);
+ CreditsOkButton & operator=(const CreditsOkButton&);
+};
+
+Credits::Credits() :
+ scene_context(),
+ fast_scrolling(false),
+ background("core/menu/wood"),
+ blackboard("core/menu/blackboard"),
+ pingu("core/misc/creditpingu"),
+ font(),
+ font_small(),
+ is_init(),
+ end_offset(),
+ offset(),
+ credits()
+{
+ scene_context = new SceneContext();
+ fast_scrolling = false;
+ gui_manager->add(new CreditsOkButton(this));
+
+ font = Fonts::chalk_normal;
+ font_small = Fonts::chalk_large;
+
+ // The credits vector holds the strings to display. The first
+ // character of each string is a special character, which indicates
+ // the size of the font or other special stuff. "-" means large
+ // font, "_" is a small font and "n" means a newline.
+
+ credits.push_back(_("-Idea"));
+ credits.push_back("_Ingo Ruhnke");
+ credits.push_back("n");
+
+ credits.push_back(_("-Maintaining"));
+ credits.push_back("_Ingo Ruhnke");
+ credits.push_back("n");
+
+ credits.push_back(_("-Programming"));
+ credits.push_back("_David Philippi");
+ credits.push_back("_Gervase Lam");
+ credits.push_back("_Ingo Ruhnke");
+ credits.push_back("_Jason Green");
+ credits.push_back("_Jimmy Salmon");
+ credits.push_back("_Michael Ploujnikov");
+ credits.push_back("_Nehal Mistry");
+ credits.push_back("n");
+
+ credits.push_back(_("-Porting (Win32)"));
+ credits.push_back("_Alberto Curro");
+ credits.push_back("_Björn Christoph Fischer");
+ credits.push_back("_Kenneth Gangstø");
+ credits.push_back("_Michael Käser");
+ credits.push_back("_Neil Mitchell");
+ credits.push_back("_Jason Green");
+ credits.push_back("n");
+
+ credits.push_back(_("-Porting (MacOSX)"));
+ credits.push_back("_Jason Green");
+ credits.push_back("_Sean Heber");
+ credits.push_back("n");
+
+ credits.push_back(_("-Gfx"));
+ credits.push_back("_Alan Tennent");
+ credits.push_back("_Craig Timpany");
+ credits.push_back("_Erik Søe Sørensen");
+ credits.push_back("_Ingo Ruhnke");
+ credits.push_back("_Jarno Elonen");
+ credits.push_back("_Joel Fauche");
+ credits.push_back("_Mark Collinson");
+ credits.push_back("_Michael Mestre");
+ credits.push_back("_Stefan Stiasny");
+ credits.push_back("_Tom Flavel");
+ credits.push_back("n");
+
+ credits.push_back(_("-Music"));
+ credits.push_back("_H. Matthew Smith");
+ credits.push_back("_Joseph Toscano");
+ credits.push_back("_Robbie Ferguson");
+ credits.push_back("_Yuri Sucupira");
+ credits.push_back("n");
+
+ credits.push_back(_("-Level Design"));
+ credits.push_back("_Craig Timpany");
+ credits.push_back("_Ingo Ruhnke");
+ credits.push_back("_Rune Zedeler");
+ credits.push_back("n");
+
+ credits.push_back(_("-Story"));
+ credits.push_back("_Ingo Ruhnke");
+ credits.push_back("n");
+
+ credits.push_back(_("-Translation"));
+ credits.push_back("_Cagri Coltekin");
+ credits.push_back("_David Philippi");
+ credits.push_back("_Giray Devlet");
+ credits.push_back("_Ingo Ruhnke");
+ credits.push_back("_Janne Morén");
+ credits.push_back("_Jarno Elonen");
+ credits.push_back("_Karl Ove Hufthammer");
+ credits.push_back("_Milan Babuskov");
+ credits.push_back("_Philippe Saint-Pierre");
+ credits.push_back("_Ricardo Cruz");
+ credits.push_back("_Skule Solvang");
+ credits.push_back("_Tomas Blaha");
+ credits.push_back("n");
+
+ credits.push_back(_("-Special"));
+ credits.push_back(_("-Thanks to"));
+ credits.push_back("_Adam Gregory");
+ credits.push_back("_Andy Balaam");
+ credits.push_back("_Bernhard Trummer");
+ credits.push_back("_Cagri Coltekin");
+ credits.push_back("_David Fauthoux");
+ credits.push_back("_David Flores");
+ credits.push_back("_David M. Turner");
+ credits.push_back("_Debian");
+ credits.push_back("_Etienne Marcotte");
+ credits.push_back("_Felix Natter");
+ credits.push_back("_Francisco 'Pacho' Ramos");
+ credits.push_back("_Giray Devlet ");
+ credits.push_back("_Giuseppe D'Aqui");
+ credits.push_back("_Henri Manson");
+ credits.push_back("_Jeff Binder");
+ credits.push_back("_Jens Henrik Goebbert");
+ credits.push_back("_Jessica Philippi");
+ credits.push_back("_John August");
+ credits.push_back("_Johnny Taporg");
+ credits.push_back("_Jules Bean");
+ credits.push_back("_Keir Fraser");
+ credits.push_back("_Magnus Norddahl");
+ credits.push_back("_Mattias Andersson");
+ credits.push_back("_Michael Wand");
+ credits.push_back("_Peter Todd");
+ credits.push_back("_Peter van Rossum");
+ credits.push_back("_Richard Stallman");
+ credits.push_back("_Rob Gietema");
+ credits.push_back("_Robert Wittams");
+ credits.push_back("_Robin Hogan");
+ credits.push_back("_Shigeru Miyamoto");
+ credits.push_back("_Stefan Ruhnke");
+ credits.push_back("_SuSE");
+ credits.push_back("_Till Hellweg");
+ credits.push_back("_Tim Yamin");
+ credits.push_back("_Tuomas (Tigert) Kuosmanen");
+ credits.push_back("_Werner Steiner");
+ credits.push_back("n");
+ credits.push_back("n");
+ credits.push_back("n");
+ credits.push_back("n");
+ credits.push_back("n");
+
+ credits.push_back(_("_And a very Special Thanks"));
+ credits.push_back(_("_to all the people who"));
+ credits.push_back(_("_contribute to"));
+ credits.push_back(_("_Free Software!"));
+ credits.push_back("n");
+ credits.push_back("n");
+ credits.push_back("n");
+ credits.push_back("n");
+ credits.push_back("n");
+ credits.push_back(_("_Thank you for"));
+ credits.push_back(_("_playing!"));
+
+ end_offset = -(float)Display::get_height()/2 - 50; // screen height + grace
time
+ for (std::vector<std::string>::iterator i = credits.begin(); i !=
credits.end(); ++i)
+ {
+ switch ((*i)[0])
+ {
+ case '-':
+ end_offset += static_cast<float>(font.get_height() + 5);
+ break;
+ case '_':
+ end_offset += static_cast<float>(font_small.get_height() + 5);
+ break;
+ case 'n':
+ end_offset += 50;
+ break;
+ default:
+ std::cout << "Credits: Syntax error: Unknown format: '" << (*i)[0] <<
"'" << std::endl;
+ break;
+ }
+ }
+ end_offset = -end_offset;
+}
+
+Credits::~Credits ()
+{
+ StatManager::instance()->set_bool("credits-seen", true);
+ delete scene_context;
+}
+
+void
+Credits::update (float delta)
+{
+ if (offset < end_offset)
+ {
+ //ScreenManager::instance()->pop_screen ();
+ }
+ else
+ {
+ if (fast_scrolling)
+ offset -= 450.0f * delta;
+ else
+ offset -= 35.0f * delta;
+ }
+}
+
+void
+Credits::draw_background (DrawingContext& gc)
+{
+ {
+ // Paint the background wood panel
+ for(int y = 0; y < gc.get_height(); y += background.get_height())
+ for(int x = 0; x < gc.get_width(); x += background.get_width())
+ gc.draw(background, Vector2i(x, y));
+ }
+
+ int x;
+ int y;
+ int yof;
+
+ x = Display::get_width()/2;
+ y = (int)offset;
+
+ gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
+
+ gc.draw(pingu, Vector2i(gc.get_width()/2, gc.get_height()/2 - 20));
+
+ yof = 0;
+
+ scene_context->clear();
+ scene_context->set_cliprect(Rect(gc.get_width()/2 - 685/2, gc.get_height()/2
- 250,
+ gc.get_width()/2 + 685/2, gc.get_height()/2
+ 250));
+
+ for (std::vector<std::string>::iterator i = credits.begin(); i !=
credits.end(); ++i)
+ {
+ switch ((*i)[0])
+ {
+ case '-':
+ scene_context->color().print_center(font, Vector2i(x, (y + yof)),
i->substr(1));
+ yof += font.get_height() + 5;
+ break;
+ case '_':
+ scene_context->color().print_center(font_small, Vector2i(x, (y +
yof)), i->substr(1));
+ yof += font_small.get_height() + 5;
+ break;
+ case 'n':
+ yof += 50;
+ break;
+ default:
+ std::cout << "Credits: Syntax error: Unknown format: '" << (*i)[0] <<
"'" << std::endl;
+ break;
+ }
+ }
+ gc.draw(new SceneContextDrawingRequest(scene_context, Vector2i(0,0), 100));
+}
+
+void
+Credits::on_startup ()
+{
+ offset = (float)Display::get_height() - 50;
+ //PingusSound::play_music("pingus-5.it");
+}
+
+void
+Credits::on_pause_press ()
+{
+}
+
+void
+Credits::on_fast_forward_press ()
+{
+ fast_scrolling = ! fast_scrolling;
+}
+
+void
+Credits::on_escape_press ()
+{
+ ScreenManager::instance ()->pop_screen ();
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/credits.hpp (from rev 4043,
trunk/pingus/src/pingus/credits.hpp)
Copied: trunk/pingus/src/pingus/screens/demo_session.cpp (from rev 4041,
trunk/pingus/src/pingus/demo_session.cpp)
===================================================================
--- trunk/pingus/src/pingus/demo_session.cpp 2009-11-05 22:48:38 UTC (rev
4041)
+++ trunk/pingus/src/pingus/screens/demo_session.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,259 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/demo_session.hpp"
+
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+#include <iostream>
+
+#include "math/math.hpp"
+#include "pingus/server.hpp"
+#include "util/pathname.hpp"
+#include "pingus/world.hpp"
+#include "pingus/components/pingus_counter.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "engine/display/scene_context.hpp"
+#include "pingus/pingus_demo.hpp"
+#include "engine/gui/surface_button.hpp"
+#include "pingus/components/playfield.hpp"
+#include "pingus/components/smallmap.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "engine/display/display.hpp"
+#include "pingus/resource.hpp"
+
+static bool false_func() { return false; }
+
+class BButton : public GUI::SurfaceButton
+{
+private:
+ Sprite highlight;
+ boost::function<void(void)> callback;
+ boost::function<bool(void)> highlight_func;
+
+public:
+ BButton(int x, int y, const std::string& name,
+ boost::function<void (void)> callback_,
+ boost::function<bool(void)> highlight_func_ = &false_func)
+ : SurfaceButton(x, y, name, name + "-pressed", name + "-hover"),
+ highlight("core/demo/highlight"),
+ callback(callback_),
+ highlight_func(highlight_func_)
+ {}
+
+ virtual void draw (DrawingContext& gc)
+ {
+
+ if (highlight_func())
+ {
+ gc.draw(button_pressed_surface, Vector2i(x_pos, y_pos));
+ gc.draw(highlight, Vector2i(x_pos, y_pos));
+ }
+ else
+ {
+ SurfaceButton::draw(gc);
+ }
+ }
+
+ void on_click() {
+ callback();
+ }
+};
+
+DemoSession::DemoSession(const Pathname& pathname_) :
+ pathname(pathname_),
+ server(),
+ demo(),
+ events(),
+ pcounter(),
+ playfield(),
+ small_map(),
+ fastforward_button(),
+ pause_button(),
+ restart_button(),
+ pause(false),
+ fast_forward(false)
+{
+ // Load Demo file
+ demo = std::auto_ptr<PingusDemo>(new PingusDemo(pathname));
+
+ events = demo->get_events();
+ // Reverse the vector so that we can use pop_back()
+ std::reverse(events.begin(), events.end());
+
+ // Create server
+ server = std::auto_ptr<Server>(new Server(PingusLevel(Pathname("levels/" +
demo->get_levelname() + ".pingus",
+
Pathname::DATA_PATH)),
+ false));
+
+ // Create GUI
+ pcounter = new PingusCounter(server.get());
+ gui_manager->add(pcounter);
+
+ int world_width = server->get_world()->get_width();
+ int world_height = server->get_world()->get_height();
+
+ playfield = new Playfield(server.get(), 0,
+ Rect(Vector2i(Math::max((size.width -
world_width)/2, 0),
+ Math::max((size.height -
world_height)/2, 0)),
+ Size(Math::min(size.width, world_width),
+ Math::min(size.height, world_height))));
+
+ gui_manager->add(playfield);
+
+ small_map = new SmallMap(server.get(), playfield, Rect(Vector2i(5,
size.height - 105), Size(175, 100)));
+ gui_manager->add(small_map);
+
+ gui_manager->add(fastforward_button= new BButton(32+50, 32,
"core/demo/fastforward",
+
boost::bind(&DemoSession::on_fast_forward_press, this),
+
boost::bind(&DemoSession::is_fast_forward, this)));
+ gui_manager->add(pause_button =new BButton(32, 32, "core/demo/pause",
+
boost::bind(&DemoSession::on_pause_press, this),
+
boost::bind(&DemoSession::is_pause, this)));
+ gui_manager->add(restart_button = new BButton(size.width - 32 - 48, 32,
"core/demo/reload",
+
boost::bind(&DemoSession::restart, this)));
+}
+
+DemoSession::~DemoSession()
+{
+}
+
+/** Pass a delta to the screen */
+void
+DemoSession::update(float delta)
+{
+ GUIScreen::update(delta);
+
+ if (server->is_finished())
+ {
+ ScreenManager::instance()->pop_screen();
+ }
+ else
+ {
+ // FIXME: Duplicate all timing code here?!
+
+ if (!pause)
+ {
+ if (fast_forward)
+ {
+ for (int i = 0; i < 4; ++i)
+ {
+ server->update();
+ update_demo();
+ }
+ }
+ else
+ {
+ server->update();
+ update_demo();
+ }
+ }
+ }
+}
+
+void
+DemoSession::update_demo()
+{
+ while(!events.empty() && events.back().time_stamp == server->get_time())
+ {
+ ServerEvent& event = events.back();
+
+ if (0)
+ {
+ std::cout << "Sending: ";
+ event.write(std::cout);
+ }
+
+ event.send(server.get());
+ events.pop_back();
+ }
+
+ // Check for unexpected things (might happen if the demo file is broken)
+ if (!events.empty() && events.back().time_stamp < server->get_time())
+ {
+ std::cout << "DemoPlayer Bug: We missed a timestamp: " <<
events.back().time_stamp << std::endl;
+ }
+}
+
+void
+DemoSession::on_pause_press()
+{
+ if (0)
+ {
+ for(std::vector<ServerEvent>::iterator i = events.begin(); i !=
events.end(); ++i)
+ {
+ std::cout << "Event: ";
+ i->write(std::cout);
+ }
+ }
+
+ pause = !pause;
+
+}
+
+void
+DemoSession::on_fast_forward_press()
+{
+ if (0)
+ std::cout << "Fast Forward Pressed: " << events.size() << " " <<
server->get_time() << std::endl;
+
+ fast_forward = !fast_forward;
+}
+
+void
+DemoSession::on_escape_press()
+{
+ std::cout << "Escape Pressed" << std::endl;
+ server->send_finish_event();
+ ScreenManager::instance()->pop_screen();
+}
+
+void
+DemoSession::on_scroller_move(float x, float y)
+{
+ // FIXME: Rounding considered evil?
+ playfield->scroll(static_cast<int>(-x),
+ static_cast<int>(-y));
+}
+
+void
+DemoSession::restart()
+{
+ ScreenManager::instance()->replace_screen(new DemoSession(pathname));
+}
+
+void
+DemoSession::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+
+ int world_width = server->get_world()->get_width();
+ int world_height = server->get_world()->get_height();
+
+ playfield->set_rect(Rect(Vector2i(Math::max((size.width - world_width)/2,
0),
+ Math::max((size.height - world_height)/2,
0)),
+ Size(Math::min(size.width, world_width),
+ Math::min(size.height, world_height))));
+
+
+ fastforward_button->set_pos(32+50, 32);
+ pause_button->set_pos(32, 32);
+ restart_button->set_pos(size.width - 32 - 48, 32);
+
+ small_map->set_rect(Rect(Vector2i(5, size.height - 105), Size(175, 100)));
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/demo_session.hpp (from rev 4041,
trunk/pingus/src/pingus/demo_session.hpp)
Copied: trunk/pingus/src/pingus/screens/font_test_screen.cpp (from rev 4041,
trunk/pingus/src/pingus/font_test_screen.cpp)
===================================================================
--- trunk/pingus/src/pingus/font_test_screen.cpp 2009-11-05 22:48:38 UTC
(rev 4041)
+++ trunk/pingus/src/pingus/screens/font_test_screen.cpp 2009-11-06
00:10:50 UTC (rev 4048)
@@ -0,0 +1,123 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/font_test_screen.hpp"
+
+#include <iostream>
+
+#include "engine/input/event.hpp"
+#include "pingus/fonts.hpp"
+#include "util/string_util.hpp"
+#include "engine/display/drawing_context.hpp"
+#include "engine/display/display.hpp"
+#include "pingus/font_description.hpp"
+
+FontTestScreen::FontTestScreen(const Pathname& fontfile) :
+ Screen(Display::get_size()),
+ font(),
+ reference(),
+ scroll(),
+ dark(true)
+{
+ std::cout << "### Loading font file: " << fontfile << std::endl;
+ font = Font(FontDescription(fontfile));
+ reference =
Font(FontDescription(Pathname("images/fonts/reference-iso-8859-1.font",
Pathname::DATA_PATH)));
+}
+
+void
+FontTestScreen::draw(DrawingContext& gc)
+{
+ int checker = 40;
+ for(int y = 0; y < gc.get_height()/checker; y += 1)
+ for(int x = 0; x < gc.get_width()/checker; x += 1)
+ {
+ if ((x+y) % 2 != 0)
+ gc.draw_fillrect(Rect(x*checker, y*checker,
+ x*checker + checker, y*checker + checker),
+ dark ? Color(50, 50, 50) : Color(255, 255, 255));
+ else
+ gc.draw_fillrect(Rect(x*checker, y*checker,
+ x*checker + checker, y*checker + checker),
+ dark ? Color(0, 0, 0) : Color(200,200,200));
+ }
+
+ gc.print_left(Fonts::chalk_large, Vector2i(10, 10), "Pingus - Font Test");
+
+ gc.push_modelview();
+ gc.translate(scroll.x, scroll.y);
+
+ for(int i = 0; i < 256; ++i)
+ {
+ int x = 64 + (i%20)*(font.get_height() + 24);
+ int y = 64 + (i/20)*(font.get_height() + reference.get_height()*3);
+
+ // print the actual character
+ gc.print_left(reference,
+ Vector2i(x,
+ y - reference.get_height()),
+ std::string(1, char(i)));
+ // print the index number
+ gc.print_left(reference,
+ Vector2i(x,
+ y + font.get_height()),
+ StringUtil::to_string(i));
+
+ if (font.get_width(char(i)))
+ {
+ gc.draw_rect(Rect(x, y,
+ x+font.get_height(),
+ y+font.get_height()),
+ Color(0,0,255));
+ gc.draw_rect(Rect(x, y,
+ x + static_cast<int>(font.get_width(char(i))),
+ y + font.get_height()),
+ Color(255,0,255));
+ gc.print_left(font, Vector2i(x, y),
+ std::string(1, char(i)));
+ }
+ else
+ {
+ gc.draw_rect(Rect(x, y,
+ x+font.get_height(),
+ y+font.get_height()),
+ Color(255,0,0));
+ }
+ }
+ gc.pop_modelview();
+}
+
+void
+FontTestScreen::update(const Input::Event& event)
+{
+ switch (event.type)
+ {
+ 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:
+ scroll.x += static_cast<int>(event.scroll.x_delta);
+ scroll.y += static_cast<int>(event.scroll.y_delta);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/font_test_screen.hpp (from rev 4041,
trunk/pingus/src/pingus/font_test_screen.hpp)
Copied: trunk/pingus/src/pingus/screens/game_session.cpp (from rev 4041,
trunk/pingus/src/pingus/game_session.cpp)
===================================================================
--- trunk/pingus/src/pingus/game_session.cpp 2009-11-05 22:48:38 UTC (rev
4041)
+++ trunk/pingus/src/pingus/screens/game_session.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,395 @@
+// 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/game_session.hpp"
+
+#include <iostream>
+#include "engine/screen/screen_manager.hpp"
+#include "pingus/server.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "engine/display/display.hpp"
+
+#include "pingus/components/button_panel.hpp"
+#include "pingus/components/pingus_counter.hpp"
+#include "pingus/components/time_display.hpp"
+#include "pingus/components/smallmap.hpp"
+#include "pingus/components/playfield.hpp"
+#include "engine/input/event.hpp"
+#include "engine/sound/sound.hpp"
+#include "math/math.hpp"
+#include "pingus/resource.hpp"
+#include "pingus/pingu_holder.hpp"
+#include "pingus/world.hpp"
+#include "pingus/screens/result_screen.hpp"
+#include "pingus/savegame_manager.hpp"
+#include "pingus/globals.hpp"
+#include "pingus/debug.hpp"
+
+GameSession::GameSession (const PingusLevel& arg_plf, bool
arg_show_result_screen) :
+ plf(arg_plf),
+ show_result_screen(arg_show_result_screen),
+ server(),
+ world_delay(),
+ is_finished (false),
+ button_panel (0),
+ pcounter (0),
+ playfield (0),
+ time_display (0),
+ small_map (0),
+ armageddon_button(),
+ forward_button(),
+ pause_button(),
+ pause(false),
+ fast_forward(false)
+{
+ server = std::auto_ptr<Server>(new Server(plf, true));
+
+ // the world is initially on time
+ world_delay = 0;
+
+ pout(PINGUS_DEBUG_LOADING) << "GameSession" << std::endl;
+
+ // -- Client stuff
+
+ // These object will get deleted by the gui_manager
+ button_panel = new ButtonPanel(this, Vector2i(0, (size.height - 150)/2));
+
+ int world_width = server->get_world()->get_width();
+ int world_height = server->get_world()->get_height();
+
+ playfield = new Playfield(get_server(), this,
+ Rect(Vector2i(Math::max((Display::get_width()
- world_width)/2, 0),
+ Math::max((Display::get_height()
- world_height)/2, 0)),
+ Size(Math::min(Display::get_width(),
world_width),
+ Math::min(Display::get_height(),
world_height))));
+
+ pcounter = new PingusCounter(get_server());
+ small_map = new SmallMap(get_server(), playfield, Rect(Vector2i(5,
size.height - 105), Size(175, 100)));
+ time_display = new TimeDisplay(this);
+
+ gui_manager->add(playfield);
+ gui_manager->add(button_panel);
+ gui_manager->add(pcounter);
+ gui_manager->add(small_map);
+ gui_manager->add(time_display);
+
+ armageddon_button = new ArmageddonButton(get_server(), Display::get_width()
- 40, Display::get_height() - 62);
+ forward_button = new ForwardButton(this, Display::get_width() - 40 * 2,
Display::get_height() - 62);
+ pause_button = new PauseButton(this, Display::get_width() - 40 * 3,
Display::get_height() - 62);
+
+ gui_manager->add(armageddon_button);
+ gui_manager->add(forward_button);
+ gui_manager->add(pause_button);
+}
+
+GameSession::~GameSession ()
+{
+}
+
+void
+GameSession::update_server(float delta)
+{
+ if (server->is_finished())
+ {
+ PinguHolder* pingu_holder = server->get_world()->get_pingus();
+ Result result;
+
+ result.plf = server->get_plf();
+
+ result.saved = pingu_holder->get_number_of_exited();
+ result.killed = pingu_holder->get_number_of_killed();
+ result.total = server->get_plf().get_number_of_pingus();
+
+ result.needed = server->get_plf().get_number_to_save();
+
+ result.max_time = server->get_plf().get_time();
+ result.used_time = server->get_time();
+
+ { // Write the savegame
+ Savegame savegame(result.plf.get_resname(),
+ (result.saved >= result.needed) ? Savegame::FINISHED
: Savegame::ACCESSIBLE,
+ result.used_time,
+ result.saved);
+ SavegameManager::instance()->store(savegame);
+ }
+
+ if (show_result_screen)
+ ScreenManager::instance()->replace_screen(new ResultScreen(result));
+ else
+ ScreenManager::instance()->pop_screen();
+
+ }
+ else
+ {
+ // how much time we have to account for while doing world updates
+ int time_passed = int(delta * 1000) + world_delay;
+ // how much time each world update represents
+ int update_time = game_speed;
+
+ // update the world (and the objects in it) in constant steps to account
+ // for the time the previous frame took
+
+ // invariant: world_updates - the number of times the world
+ // has been updated during this frame
+ int world_updates = 0;
+
+ while ((world_updates+1)*update_time <= time_passed)
+ {
+ if (!pause)
+ {
+ if (fast_forward)
+ {
+ for (int i = 0; i < fast_forward_time_scale; ++i)
+ server->update();
+ }
+ else
+ {
+ server->update();
+ }
+ }
+
+ world_updates++;
+ }
+ // save how far behind is the world compared to the actual time
+ // so that we can account for that while updating in the next frame
+ world_delay = time_passed - (world_updates*update_time);
+ }
+}
+
+void
+GameSession::draw_background (DrawingContext& gc)
+{
+ Rect rect = playfield->get_rect();
+
+ if (rect != Rect(Vector2i(0,0), Size(Display::get_width(),
Display::get_height())))
+ { // Draw a black border around the playfield when the playfield is
smaller then the screen
+ Color border_color(0, 0, 0);
+ // top
+ gc.draw_fillrect(Rect(0, 0, Display::get_width(), rect.top),
+ border_color);
+ // bottom
+ gc.draw_fillrect(Rect(0, rect.bottom, Display::get_width(),
Display::get_height()),
+ border_color);
+ // left
+ gc.draw_fillrect(Rect(0, rect.top, rect.left, rect.bottom),
+ border_color);
+ // right
+ gc.draw_fillrect(Rect(rect.right, rect.top, Display::get_width(),
rect.bottom),
+ border_color);
+ }
+}
+
+void
+GameSession::update(float delta)
+{
+ update_server(delta);
+ GUIScreen::update(delta);
+}
+
+void
+GameSession::update(const Input::Event& event)
+{
+ GUIScreen::update(event);
+
+ //std::cout << "Events: " << event.get_type () << std::endl;
+
+ switch (event.type)
+ {
+ case Input::BUTTON_EVENT_TYPE:
+ {
+ const Input::ButtonEvent& ev = event.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;
+
+ case Input::POINTER_EVENT_TYPE:
+ // Ignore, is handled in GUIScreen
+ break;
+
+ case Input::AXIS_EVENT_TYPE:
+ // ???
+ process_axis_event (event.axis);
+ break;
+
+ case Input::SCROLLER_EVENT_TYPE:
+ process_scroll_event(event.scroll);
+ break;
+
+ case Input::KEYBOARD_EVENT_TYPE:
+ break;
+
+ default:
+ // unhandled event
+ std::cout << "GameSession::process_events (): unhandled event: " <<
event.type << std::endl;
+ break;
+ }
+}
+
+void
+GameSession::process_scroll_event (const Input::ScrollEvent& ev)
+{
+ playfield->scroll(static_cast<int>(-ev.x_delta),
+ static_cast<int>(-ev.y_delta));
+}
+
+void
+GameSession::process_axis_event (const Input::AxisEvent& event)
+{
+ // std::cout << "GameSession::process_axis_event ()" << std::endl;
+ UNUSED_ARG(event);
+}
+
+void
+GameSession::do_restart()
+{
+ server->send_finish_event();
+}
+
+bool
+GameSession::finished()
+{
+ return is_finished;
+}
+
+void
+GameSession::set_finished()
+{
+ is_finished = true;
+ server->send_finish_event();
+}
+
+void
+GameSession:: on_escape_press ()
+{
+ server->send_finish_event();
+}
+
+void
+GameSession:: on_pause_press ()
+{
+ pause = !pause;
+}
+
+void
+GameSession::on_fast_forward_press ()
+{
+ fast_forward = !fast_forward;
+}
+
+void
+GameSession::on_armageddon_press ()
+{
+ server->send_armageddon_event();
+}
+
+void
+GameSession::on_action_axis_move (float move)
+{
+ if (move > 0)
+ button_panel->next_action ();
+ else if (move < 0)
+ button_panel->previous_action ();
+}
+
+void
+GameSession::on_startup ()
+{
+ is_finished = false;
+
+ if (maintainer_mode)
+ std::cout << "Starting Music: " << server->get_plf().get_music() <<
std::endl;
+
+ if (server->get_plf().get_music() == "none")
+ {
+ Sound::PingusSound::stop_music();
+ }
+ else
+ {
+ Sound::PingusSound::play_music(server->get_plf().get_music());
+ }
+}
+
+Actions::ActionName
+GameSession::get_action_name() const
+{
+ return button_panel->get_action_name();
+}
+
+void
+GameSession::set_fast_forward(bool value)
+{
+ fast_forward = value;
+}
+
+bool
+GameSession::get_fast_forward() const
+{
+ return fast_forward;
+}
+
+void
+GameSession::set_pause(bool value)
+{
+ pause = value;
+}
+
+bool
+GameSession::get_pause() const
+{
+ return pause;
+}
+
+void
+GameSession::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+
+ int world_width = server->get_world()->get_width();
+ int world_height = server->get_world()->get_height();
+
+ playfield->set_rect(Rect(Vector2i(Math::max((size.width - world_width)/2,
0),
+ Math::max((size.height - world_height)/2,
0)),
+ Size(Math::min(size.width, world_width),
+ Math::min(size.height, world_height))));
+
+ armageddon_button->set_rect(Rect(Vector2i(size.width - 40, size.height - 62),
+ Size(38, 60)));
+ forward_button->set_rect(Rect(Vector2i(size.width - 40*2, size.height - 62),
+ Size(38, 60)));
+ pause_button->set_rect(Rect(Vector2i(size.width - 40*3, size.height - 62),
+ Size(38, 60)));
+
+ small_map->set_rect(Rect(Vector2i(5, size.height - 105), Size(175, 100)));
+
+ button_panel->set_pos(Vector2i(0, (size.height - 150)/2));
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/game_session.hpp (from rev 4041,
trunk/pingus/src/pingus/game_session.hpp)
Copied: trunk/pingus/src/pingus/screens/level_menu.cpp (from rev 4041,
trunk/pingus/src/pingus/level_menu.cpp)
===================================================================
--- trunk/pingus/src/pingus/level_menu.cpp 2009-11-05 22:48:38 UTC (rev
4041)
+++ trunk/pingus/src/pingus/screens/level_menu.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,483 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/level_menu.hpp"
+
+#include <boost/format.hpp>
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+
+#include "pingus/gettext.h"
+#include "pingus/resource.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "pingus/fonts.hpp"
+#include "engine/display/drawing_context.hpp"
+#include "pingus/screens/option_menu.hpp"
+#include "util/system.hpp"
+#include "engine/display/display.hpp"
+#include "engine/gui/rect_component.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "pingus/screens/game_session.hpp"
+#include "pingus/screens/start_screen.hpp"
+#include "pingus/globals.hpp"
+#include "engine/gui/surface_button.hpp"
+#include "engine/sound/sound.hpp"
+
+class LevelMenuAbortButton : public GUI::SurfaceButton
+{
+private:
+ LevelMenu* parent;
+
+public:
+ LevelMenuAbortButton(LevelMenu* p, int x, int y)
+ : GUI::SurfaceButton(x, y,
+ "core/start/back",
+ "core/start/back_clicked",
+ "core/start/back_hover"),
+ parent(p)
+ {
+ }
+
+ void draw(DrawingContext& gc) {
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 55, y_pos),
_("Abort"));
+ }
+
+ void on_click() {
+ parent->on_escape_press();
+ }
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+ }
+
+private:
+ LevelMenuAbortButton(const LevelMenuAbortButton&);
+ LevelMenuAbortButton & operator=(const LevelMenuAbortButton&);
+};
+
+class LevelScrollButton : public GUI::SurfaceButton
+{
+private:
+ boost::function<void(void)> callback;
+
+public:
+ LevelScrollButton(int x, int y, const std::string& str, boost::function<void
(void)> callback_)
+ : GUI::SurfaceButton(x, y,
+ str,
+ str + "_pressed",
+ str + "_hover"),
+ callback(callback_)
+ {
+ }
+
+ void on_click() {
+ callback();
+ }
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound("tick");
+ }
+
+private:
+ LevelScrollButton(const LevelScrollButton&);
+ LevelScrollButton & operator=(const LevelScrollButton&);
+};
+
+class LevelsetSelector : public GUI::RectComponent
+{
+private:
+ LevelMenu* level_menu;
+ typedef std::vector<Levelset*> Levelsets;
+ Levelsets levelsets;
+ Levelset* current_levelset;
+ Sprite marker;
+ int page;
+
+public:
+ LevelsetSelector(LevelMenu* level_menu_, const Rect& rect_) :
+ RectComponent(rect_),
+ level_menu(level_menu_),
+ levelsets(),
+ current_levelset(),
+ marker(),
+ page(0)
+ {
+ marker = Sprite("core/menu/marker");
+
+ std::string path = Pathname("levelsets",
Pathname::DATA_PATH).get_sys_path();
+ System::Directory directory = System::opendir(path, "*.levelset");
+ for(System::Directory::iterator i = directory.begin(); i !=
directory.end(); ++i)
+ {
+ levelsets.push_back(new Levelset(Pathname(path + "/" + i->name,
Pathname::SYSTEM_PATH)));
+ }
+ }
+
+ ~LevelsetSelector()
+ {
+ for(Levelsets::iterator i = levelsets.begin(); i != levelsets.end(); ++i)
+ {
+ delete *i;
+ }
+ }
+
+ void draw(DrawingContext& gc)
+ {
+ gc.push_modelview();
+ gc.translate(rect.left, rect.top);
+
+ gc.print_center(Fonts::chalk_large, Vector2i(rect.get_width()/2, -50),
_("Levelsets"));
+
+ //gc.draw_fillrect(Rect(Vector2i(0,0), Size(rect.get_width(),
rect.get_height())),
+ // Color(255, 255, 0, 100));
+
+ int y = 0;
+ for(int i = 3*page; (i < 3*(page+1)) && (i < int(levelsets.size())); ++i)
+ {
+ Levelset* levelset = levelsets[i];
+
+ if (levelset == current_levelset)
+ gc.draw(marker, Vector2i(0, y - 5));
+
+ gc.draw(levelset->get_image(), Vector2i(30, y));
+
+ gc.print_left(Fonts::chalk_normal, Vector2i(85+30, 15 + y),
_(levelset->get_title()));
+ gc.print_left(Fonts::chalk_small, Vector2i(85+50, 40 + y),
_(levelset->get_description()));
+
+ gc.print_right(Fonts::chalk_normal, Vector2i(rect.get_width() - 30, 15
+ y), (boost::format("%1% %2%%%") % _("Solved:") %
levelset->get_completion()).str());
+ gc.print_right(Fonts::chalk_small, Vector2i(rect.get_width() - 30, 60
+ y), (boost::format("%1% %2%") % levelset->get_level_count() %
_("levels")).str());
+
+ //gc.draw(ok_button, 620, y);
+
+ y += 95;
+ }
+
+ int total_pages = (int(levelsets.size())+2)/3;
+
+ gc.print_center(Fonts::chalk_normal, Vector2i(rect.get_width()/2, 360),
+ (boost::format("%1% %2%/%3%") % _("Page") % (page+1) %
total_pages).str());
+
+ gc.pop_modelview();
+ }
+
+ void next_page()
+ {
+ page += 1;
+ if (page >= ((int)levelsets.size()+2)/3)
+ page = ((int)levelsets.size()+2)/3 - 1;
+ }
+
+ void prev_page()
+ {
+ page -= 1;
+ if (page < 0)
+ page = 0;
+ }
+
+ void on_pointer_leave()
+ {
+ current_levelset = 0;
+ }
+
+ void on_pointer_move(int x, int y)
+ {
+ x -= rect.left;
+ y -= rect.top;
+
+ if (!levelsets.empty())
+ {
+ int i = y / 95 + page*3;
+
+ if (i >= 0 && i < static_cast<int>(levelsets.size()))
+ current_levelset = levelsets[i];
+ else
+ current_levelset = NULL;
+ }
+ }
+
+ void on_primary_button_press (int x, int y)
+ {
+ on_pointer_move(x, y);
+
+ if (current_levelset)
+ {
+ level_menu->set_levelset(current_levelset);
+ }
+ }
+
+ void update_layout() {}
+
+private:
+ LevelsetSelector(const LevelsetSelector&);
+ LevelsetSelector & operator=(const LevelsetSelector&);
+};
+
+class LevelSelector : public GUI::RectComponent
+{
+private:
+ LevelMenu* level_menu;
+ Sprite marker;
+ Sprite marker_locked;
+ Levelset* levelset;
+ int current_level;
+ int page;
+
+public:
+ LevelSelector(LevelMenu* level_menu_, const Rect& rect_)
+ : RectComponent(rect_),
+ level_menu(level_menu_),
+ marker(),
+ marker_locked(),
+ levelset(0),
+ current_level(-1),
+ page(0)
+ {
+ marker = Sprite("core/menu/marker2");
+ marker_locked = Sprite("core/menu/marker_locked");
+ }
+
+ void draw(DrawingContext& gc)
+ {
+ gc.push_modelview();
+ gc.translate(rect.left, rect.top);
+
+ gc.print_center(Fonts::chalk_large, Vector2i(rect.get_width()/2, -70),
_(levelset->get_title()));
+
+ if (levelset)
+ {
+ levelset->refresh(); // should be better placed in on_startup() or so
+
+ //gc.draw_fillrect(Rect(Vector2i(0,0), Size(rect.get_width(),
rect.get_height())),
+ // Color(255, 255, 0, 100));
+
+ gc.print_left(Fonts::chalk_normal, Vector2i(30, -32), _("Title"));
+ gc.print_right(Fonts::chalk_normal, Vector2i(rect.get_width() - 30,
-32), _("Status"));
+
+ int y = 0;
+ for(int i = page*8; i < (page+1)*8 && i < levelset->get_level_count();
++i)
+ {
+ if (!levelset->get_level(i)->accessible)
+ gc.draw(marker_locked, Vector2i(0, y));
+ else if (i == current_level)
+ gc.draw(marker, Vector2i(0, y));
+
+ if (maintainer_mode)
+ gc.print_left(Fonts::chalk_small, Vector2i(30, y+4),
levelset->get_level(i)->plf.get_resname());
+ else
+ gc.print_left(Fonts::chalk_small, Vector2i(30, y+4),
_(levelset->get_level(i)->plf.get_levelname()));
+
+ if (levelset->get_level(i)->finished)
+ gc.print_right(Fonts::chalk_small, Vector2i(rect.get_width()
-30, y+4), _("solved"));
+ else
+ gc.print_right(Fonts::chalk_small, Vector2i(rect.get_width()
-30, y+4), _("unsolved"));
+
+ y += 32;
+ }
+ }
+
+ gc.print_center(Fonts::chalk_normal, Vector2i(rect.get_width()/2, 360),
+ (boost::format("%1% %2%/%3%") % _("Page") % (page+1) %
((levelset->get_level_count()+7)/8)).str());
+
+ gc.pop_modelview();
+ }
+
+ void prev_page()
+ {
+ page -= 1;
+ if (page < 0)
+ page = 0;
+ }
+
+ void next_page()
+ {
+ page += 1;
+ if (page >= (levelset->get_level_count()+7)/8)
+ page = (levelset->get_level_count()+7)/8 - 1;
+ }
+
+ void set_levelset(Levelset* levelset_)
+ {
+ levelset = levelset_;
+ }
+
+ void on_pointer_leave()
+ {
+ current_level = -1;
+ }
+
+ int get_current_level(int x, int y)
+ {
+ int cl = current_level = y / 32 + page*8;
+ if (cl < 0 || cl >= levelset->get_level_count())
+ cl = -1;
+ return cl;
+ }
+
+ void on_pointer_move(int x, int y)
+ {
+ x -= rect.left;
+ y -= rect.top;
+
+ current_level = y / 32 + page*8;
+ if (current_level < 0 || current_level >= levelset->get_level_count())
+ current_level = -1;
+ }
+
+ void on_primary_button_press (int x, int y)
+ {
+ on_pointer_move(x, y);
+ if (current_level != -1)
+ {
+ if (levelset->get_level(current_level)->accessible)
+ {
+ ScreenManager::instance()->push_screen(new
StartScreen(levelset->get_level(current_level)->plf));
+ }
+ }
+ }
+
+ void update_layout() {}
+
+private:
+ LevelSelector(const LevelSelector&);
+ LevelSelector & operator=(const LevelSelector&);
+};
+
+LevelMenu::LevelMenu() :
+ x_pos((Display::get_width() - default_screen_width)/2),
+ y_pos((Display::get_height() - default_screen_height)/2),
+ background("core/menu/wood"),
+ blackboard("core/menu/blackboard"),
+ ok_button(),
+ level_selector(),
+ levelset_selector(),
+ abort_button(),
+ next_button(),
+ prev_button()
+{
+ ok_button = Sprite("core/start/ok");
+
+ levelset_selector = new LevelsetSelector(this, Rect(Vector2i(x_pos + 100,
y_pos + 140), Size(600, 285)));
+ level_selector = new LevelSelector(this, Rect(Vector2i(x_pos + 100, y_pos
+ 160), Size(600, 256)));
+
+ gui_manager->add(prev_button = new LevelScrollButton(Display::get_width()/2
+ 160,
+ Display::get_height()/2
+ 145,
+ "core/menu/arrow_left",
+
boost::bind(&LevelMenu::prev_page, this)));
+
+ gui_manager->add(next_button = new LevelScrollButton(Display::get_width()/2
+ 230,
+ Display::get_height()/2
+ 145,
+ "core/menu/arrow_right",
+
boost::bind(&LevelMenu::next_page, this)));
+
+ gui_manager->add(levelset_selector);
+ gui_manager->add(level_selector);
+ gui_manager->add(abort_button = new LevelMenuAbortButton(this,
+
Display::get_width()/2 - 300,
+
Display::get_height()/2 + 144));
+
+ level_selector->hide();
+}
+
+LevelMenu::~LevelMenu()
+{
+}
+
+void
+LevelMenu::draw_background(DrawingContext& gc)
+{
+ // Paint the background wood panel
+ for(int y = 0; y < gc.get_height(); y += background.get_height())
+ for(int x = 0; x < gc.get_width(); x += background.get_width())
+ gc.draw(background, Vector2i(x, y));
+
+ gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
+}
+
+void
+LevelMenu::on_escape_press()
+{
+ if (level_selector->is_visible())
+ {
+ levelset_selector->show();
+ level_selector->hide();
+ }
+ else
+ {
+ //std::cout << "OptionMenu: poping screen" << std::endl;
+ ScreenManager::instance()->pop_screen();
+ }
+}
+
+void
+LevelMenu::next_page()
+{
+ if (level_selector->is_visible())
+ level_selector->next_page();
+ else
+ levelset_selector->next_page();
+}
+
+void
+LevelMenu::prev_page()
+{
+ if (level_selector->is_visible())
+ level_selector->prev_page();
+ else
+ levelset_selector->prev_page();
+}
+
+void
+LevelMenu::set_levelset(Levelset* levelset)
+{
+ if (levelset)
+ {
+ level_selector->set_levelset(levelset);
+ levelset_selector->hide();
+ level_selector->show();
+ }
+ else
+ {
+ levelset_selector->show();
+ level_selector->hide();
+ }
+}
+
+void
+LevelMenu::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+
+ x_pos = (size.width - default_screen_width)/2;
+ y_pos = (size.height - default_screen_height)/2;
+
+ levelset_selector->set_rect(Rect(Vector2i(x_pos + 100, y_pos + 140),
Size(600, 285)));
+ level_selector ->set_rect(Rect(Vector2i(x_pos + 100, y_pos + 160),
Size(600, 256)));
+
+ prev_button->set_pos(size.width /2 + 160,
+ size.height/2 + 145);
+
+ next_button->set_pos(size.width /2 + 230,
+ size.height/2 + 145);
+
+ abort_button->set_pos(size.width /2 - 300,
+ size.height/2 + 144);
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/level_menu.hpp (from rev 4043,
trunk/pingus/src/pingus/level_menu.hpp)
Copied: trunk/pingus/src/pingus/screens/option_menu.cpp (from rev 4041,
trunk/pingus/src/pingus/option_menu.cpp)
===================================================================
--- trunk/pingus/src/pingus/option_menu.cpp 2009-11-05 22:48:38 UTC (rev
4041)
+++ trunk/pingus/src/pingus/screens/option_menu.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,410 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2007 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/option_menu.hpp"
+
+#include <set>
+#include <boost/bind.hpp>
+#include <sstream>
+#include <iostream>
+
+#include "pingus/config_manager.hpp"
+#include "pingus/globals.hpp"
+#include "pingus/gettext.h"
+#include "pingus/resource.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "pingus/fonts.hpp"
+#include "engine/display/display.hpp"
+#include "engine/display/drawing_context.hpp"
+#include "pingus/components/label.hpp"
+#include "pingus/components/check_box.hpp"
+#include "pingus/components/slider_box.hpp"
+#include "pingus/components/choice_box.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "engine/sound/sound.hpp"
+#include "tinygettext/dictionary_manager.hpp"
+#include "tinygettext/language.hpp"
+
+#define C(x) connections.push_back(x)
+
+extern tinygettext::DictionaryManager dictionary_manager;
+
+class OptionMenuCloseButton
+ : public GUI::SurfaceButton
+{
+private:
+ OptionMenu* parent;
+public:
+ OptionMenuCloseButton(OptionMenu* p, int x, int y)
+ : GUI::SurfaceButton(x, y,
+ "core/start/ok",
+ "core/start/ok_clicked",
+ "core/start/ok_hover"),
+ parent(p)
+ {
+ }
+
+ void on_pointer_enter ()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound("tick");
+ }
+
+ void on_click() {
+ parent->save_language();
+ config_manager.save();
+ parent->close_screen();
+ Sound::PingusSound::play_sound("yipee");
+ }
+
+private:
+ OptionMenuCloseButton(const OptionMenuCloseButton&);
+ OptionMenuCloseButton & operator=(const OptionMenuCloseButton&);
+};
+
+OptionMenu::OptionMenu() :
+ background(),
+ ok_button(),
+ x_pos(),
+ y_pos(),
+ options(),
+ fullscreen_box(),
+ swcursor_box(),
+ autoscroll_box(),
+ mousegrab_box(),
+ printfps_box(),
+ master_volume_box(),
+ sound_volume_box(),
+ music_volume_box(),
+ defaults_label(),
+ defaults_box(),
+ connections(),
+ language(),
+ language_map()
+{
+ background = Sprite("core/menu/optionmenu");
+ gui_manager->add(ok_button = new OptionMenuCloseButton(this,
+
Display::get_width()/2 + 225,
+
Display::get_height()/2 + 125));
+
+ x_pos = 0;
+ y_pos = 0;
+
+ int resolutions[][2] = {
+ { 640, 480 }, // 4:3, VGA
+ { 768, 576 }, // 4:3, PAL
+ { 800, 480 }, // Nokia N770, N800
+ { 800, 600 }, // 4:3, SVGA
+ { 1024, 768 }, // 4:3, XGA
+ { 1152, 864 }, // 4:3
+ { 1280, 720 }, // 16:9, HD-TV, 720p
+ { 1280, 960 }, // 4:3
+ { 1280, 1024 }, // 5:4
+ { 1366, 768 }, // ~16:9, Wide XGA
+ { 1440, 900, }, // 16:10
+ { 1600, 1200 }, // 4:3, UXGA
+ { 1680, 1050 }, // 16:10, WSXGA
+ { 1920, 1080 }, // 16:9, HD-TV, 1080p
+ { 1920, 1200 }, // 16:10
+ { -1, -1 }
+ };
+ int current_choice = -1;
+ int n;
+
+ ChoiceBox* resolution_box = new ChoiceBox(Rect());
+ for (n = 0; resolutions[n][0] != -1; ++n)
+ {
+ std::ostringstream ostr;
+ ostr << resolutions[n][0] << "x" << resolutions[n][1];
+ resolution_box->add_choice(ostr.str());
+ if (Display::get_width() == resolutions[n][0] &&
+ Display::get_height() == resolutions[n][1])
+ {
+ current_choice = n;
+ }
+ }
+ resolution_box->add_choice("Custom");
+ if (current_choice == -1)
+ current_choice = n;
+
+ resolution_box->set_current_choice(current_choice);
+
+ tinygettext::Language current_language = dictionary_manager.get_language();
+ language = current_language;
+ n = 0;
+
+ ChoiceBox* language_box = new ChoiceBox(Rect());
+ std::set<tinygettext::Language> languages =
dictionary_manager.get_languages();
+
+ for (std::set<tinygettext::Language>::iterator i = languages.begin(); i !=
languages.end(); ++i)
+ {
+ language_box->add_choice(i->str());
+ if (current_language == *i)
+ language_box->set_current_choice(current_choice);
+ }
+
+ ChoiceBox* scroll_box = new ChoiceBox(Rect());
+ scroll_box->add_choice("Drag&Drop");
+ scroll_box->add_choice("Rubberband");
+
+ swcursor_box = new CheckBox(Rect());
+ fullscreen_box = new CheckBox(Rect());
+ autoscroll_box = new CheckBox(Rect());
+ mousegrab_box = new CheckBox(Rect());
+ printfps_box = new CheckBox(Rect());
+
+ master_volume_box = new SliderBox(Rect());
+ sound_volume_box = new SliderBox(Rect());
+ music_volume_box = new SliderBox(Rect());
+
+
C(swcursor_box->on_change.connect(boost::bind(&OptionMenu::on_swcursor_change,
this, _1)));
+
C(fullscreen_box->on_change.connect(boost::bind(&OptionMenu::on_fullscreen_change,
this, _1)));
+
C(autoscroll_box->on_change.connect(boost::bind(&OptionMenu::on_autoscroll_change,
this, _1)));
+
C(mousegrab_box->on_change.connect(boost::bind(&OptionMenu::on_mousegrab_change,
this, _1)));
+
C(printfps_box->on_change.connect(boost::bind(&OptionMenu::on_printfps_change,
this, _1)));
+
+
C(master_volume_box->on_change.connect(boost::bind(&OptionMenu::on_master_volume_change,
this, _1)));
+
C(sound_volume_box->on_change.connect(boost::bind(&OptionMenu::on_sound_volume_change,
this, _1)));
+
C(music_volume_box->on_change.connect(boost::bind(&OptionMenu::on_music_volume_change,
this, _1)));
+
+
C(language_box->on_change.connect(boost::bind(&OptionMenu::on_language_change,
this, _1)));
+
C(resolution_box->on_change.connect(boost::bind(&OptionMenu::on_resolution_change,
this, _1)));
+
+ add_item(_("Language:"), language_box);
+ // add_item(_("Scroll Mode:"), scroll_box);
+ add_item(_("Resolution:"), resolution_box);
+ add_item(_("Fullscreen:"), fullscreen_box);
+ add_item(_("Master Volume:"), master_volume_box);
+ add_item(_("Sound Volume:"), sound_volume_box);
+ add_item(_("Music Volume:"), music_volume_box);
+ add_item(_("Autoscrolling:"), autoscroll_box);
+ add_item(_("Print FPS:"), printfps_box);
+ add_item(_("Mouse Grab:"), mousegrab_box);
+ add_item(_("Software Cursor:"), swcursor_box);
+
+ // Connect with ConfigManager
+ mousegrab_box->set_state(config_manager.get_mouse_grab(), false);
+
C(config_manager.on_mouse_grab_change.connect(boost::bind(&CheckBox::set_state,
mousegrab_box, _1, false)));
+
+ printfps_box->set_state(config_manager.get_print_fps(), false);
+
C(config_manager.on_print_fps_change.connect(boost::bind(&CheckBox::set_state,
printfps_box, _1, false)));
+
+ fullscreen_box->set_state(config_manager.get_fullscreen(), false);
+
C(config_manager.on_fullscreen_change.connect(boost::bind(&CheckBox::set_state,
fullscreen_box, _1, false)));
+
+ swcursor_box->set_state(config_manager.get_swcursor(), false);
+
C(config_manager.on_swcursor_change.connect(boost::bind(&CheckBox::set_state,
swcursor_box, _1, false)));
+
+ autoscroll_box->set_state(config_manager.get_autoscroll(), false);
+
C(config_manager.on_autoscroll_change.connect(boost::bind(&CheckBox::set_state,
autoscroll_box, _1, false)));
+
+ defaults_label = new Label(_("Reset to Defaults:"),
Rect(Vector2i(Display::get_width()/2 - 100, Display::get_height()/2 + 160),
Size(170, 32)));
+ gui_manager->add(defaults_label);
+ defaults_box = new CheckBox(Rect(Vector2i(Display::get_width()/2 - 100 +
170, Display::get_height()/2 + 160), Size(32, 32)));
+ gui_manager->add(defaults_box);
+}
+
+void
+OptionMenu::add_item(const std::string& label, GUI::RectComponent* control)
+{
+ int x_offset = (Display::get_width() - 800) / 2;
+ int y_offset = (Display::get_height() - 600) / 2;
+
+ Label* label_component = new Label(label, Rect(Vector2i(120 + x_pos * 312 +
x_offset, 177 + y_pos*32 + y_offset),
+ Size(140, 32)));
+ gui_manager->add(label_component);
+ gui_manager->add(control);
+
+ if (dynamic_cast<ChoiceBox*>(control))
+ {
+ control->set_rect(Rect(120 + x_pos * 312 + 140 + x_offset, 177 +
y_pos*32 + y_offset,
+ 120 + x_pos * 312 + 256 + x_offset, 177 +
y_pos*32 + 32 + y_offset));
+ }
+ else if (dynamic_cast<SliderBox*>(control))
+ {
+ control->set_rect(Rect(120 + x_pos * 312 + 140 + x_offset, 177 +
y_pos*32 + y_offset,
+ 120 + x_pos * 312 + 256 + x_offset, 177 +
y_pos*32 + 32 + y_offset));
+ }
+ else if (dynamic_cast<CheckBox*>(control))
+ {
+ control->set_rect(Rect(Vector2i(120 + x_pos * 312 + 156 + 32+28+8 +
x_offset, 177 + y_pos*32 + y_offset),
+ Size(32, 32)));
+ }
+ else
+ {
+ assert(!"Unhandled control type");
+ }
+
+ options.push_back(Option(label_component, control));
+
+ y_pos += 1;
+ if (y_pos > 5)
+ {
+ y_pos = 0;
+ x_pos += 1;
+ }
+}
+
+OptionMenu::~OptionMenu()
+{
+ for(Connections::iterator i = connections.begin(); i != connections.end();
++i)
+ {
+ (*i).disconnect();
+ }
+}
+
+struct OptionEntry {
+ OptionEntry(const std::string& left_,
+ const std::string& right_)
+ : left(left_), right(right_)
+ {}
+
+ std::string left;
+ std::string right;
+};
+
+void
+OptionMenu::draw_background(DrawingContext& gc)
+{
+ gc.fill_screen(Color(0, 0, 0));
+
+ // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
+ gc.draw(background, Vector2i(gc.get_width()/2 - background.get_width()/2,
gc.get_height()/2 - background.get_height()/2));
+
+ gc.print_center(Fonts::chalk_large,
+ Vector2i(gc.get_width()/2,
+ gc.get_height()/2 - 210),
+ _("Option Menu"));
+
+ gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2 + 225 + 30,
gc.get_height()/2 + 125 - 20), _("Close"));
+}
+
+void
+OptionMenu::on_escape_press()
+{
+ std::cout << "OptionMenu: popping screen" << std::endl;
+ ScreenManager::instance()->pop_screen();
+}
+
+void
+OptionMenu::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+
+ if (ok_button)
+ ok_button->set_pos(size.width/2 + 225, size.height/2 + 125);
+ if (defaults_label)
+ defaults_label->set_rect(Rect(Vector2i(Display::get_width()/2 - 100,
Display::get_height()/2 + 160), Size(170, 32)));
+ if (defaults_box)
+ defaults_box->set_rect(Rect(Vector2i(Display::get_width()/2 - 100 + 170,
Display::get_height()/2 + 160), Size(32, 32)));
+
+ if (options.empty())
+ return;
+
+ Rect rect;
+ rect = options.front().label->get_rect();
+ int x_diff = 120 + (size.width - 800) / 2 - rect.left;
+ int y_diff = 177 + (size.height - 600) / 2 - rect.top;
+
+ for(std::vector<Option>::iterator i = options.begin(); i != options.end();
++i)
+ {
+ rect = (*i).label->get_rect();
+ (*i).label->set_rect(Rect(Vector2i(rect.left + x_diff, rect.top +
y_diff), rect.get_size()));
+ rect = (*i).control->get_rect();
+ (*i).control->set_rect(Rect(Vector2i(rect.left + x_diff, rect.top +
y_diff), rect.get_size()));
+ }
+}
+
+void
+OptionMenu::close_screen()
+{
+ ScreenManager::instance()->pop_screen();
+}
+
+void
+OptionMenu::on_swcursor_change(bool v)
+{
+ config_manager.set_swcursor(v);
+}
+
+void
+OptionMenu::on_fullscreen_change(bool v)
+{
+ config_manager.set_fullscreen(v);
+}
+
+void
+OptionMenu::on_autoscroll_change(bool v)
+{
+ config_manager.set_autoscroll(v);
+}
+
+void
+OptionMenu::on_mousegrab_change(bool v)
+{
+ config_manager.set_mouse_grab(v);
+}
+
+void
+OptionMenu::on_printfps_change(bool v)
+{
+ config_manager.set_print_fps(v);
+}
+
+void
+OptionMenu::on_master_volume_change(int v)
+{
+ config_manager.set_master_volume(v);
+}
+
+void
+OptionMenu::on_sound_volume_change(int v)
+{
+ config_manager.set_sound_volume(v);
+}
+
+void
+OptionMenu::on_music_volume_change(int v)
+{
+ config_manager.set_music_volume(v);
+}
+
+void
+OptionMenu::on_language_change(const std::string &str)
+{
+ language = str;
+}
+
+void
+OptionMenu::on_resolution_change(const std::string& str)
+{
+ if (str != "Custom")
+ {
+ Size size_;
+ if (sscanf(str.c_str(), "%dx%d", &size_.width, &size_.height) == 2)
+ {
+ config_manager.set_resolution(size_);
+ }
+ }
+}
+
+void
+OptionMenu::save_language()
+{
+ config_manager.set_language(language_map[language]);
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/option_menu.hpp (from rev 4043,
trunk/pingus/src/pingus/option_menu.hpp)
Copied: trunk/pingus/src/pingus/screens/pingus_menu.cpp (from rev 4041,
trunk/pingus/src/pingus/pingus_menu.cpp)
===================================================================
--- trunk/pingus/src/pingus/pingus_menu.cpp 2009-11-05 22:48:38 UTC (rev
4041)
+++ trunk/pingus/src/pingus/screens/pingus_menu.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,275 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 1999 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/pingus_menu.hpp"
+
+#include <config.h>
+
+#include "pingus/gettext.h"
+#include "pingus/components/menu_button.hpp"
+#include "pingus/resource.hpp"
+#include "pingus/debug.hpp"
+#include "pingus/globals.hpp"
+#include "engine/sound/sound.hpp"
+#include "pingus/screens/level_menu.hpp"
+#include "pingus/stat_manager.hpp"
+#include "pingus/screens/start_screen.hpp"
+#include "pingus/screens/story_screen.hpp"
+#include "pingus/worldmap/worldmap.hpp"
+#include "pingus/worldmap/worldmap_screen.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "pingus/plf_res_mgr.hpp"
+#include "pingus/path_manager.hpp"
+#include "util/pathname.hpp"
+#include "editor/editor_screen.hpp"
+#include "pingus/screens/credits.hpp"
+#include "pingus/layer_manager.hpp"
+
+PingusMenu::PingusMenu() :
+ is_init(),
+ hint(),
+ help(),
+ text_scroll_offset(),
+ background(),
+ logo(),
+ start_button(),
+ quit_button(),
+ editor_button(),
+ contrib_button()
+{
+ is_init = false;
+
+ Size size_(Display::get_width(), Display::get_height());
+
+ start_button = new MenuButton(this, Vector2i(size_.width/2 - 150,
+ size_.height/2 + 20),
+ _("Story"),
+ _("..:: Start the game ::.."));
+
+ editor_button = new MenuButton(this, Vector2i(size_.width/2 + 150,
+ size_.height/2 + 20),
+ _("Editor"),
+ _("..:: Create your own levels ::.."));
+
+ quit_button = new MenuButton(this, Vector2i(size_.width/2 + 150,
+ size_.height/2 + 100),
+ _("Exit"),
+ _("..:: Bye, bye ::.."));
+
+ contrib_button = new MenuButton(this, Vector2i(size_.width/2 - 150,
+ size_.height/2 + 100),
+ _("Levelsets"),
+ _("..:: Play User Built levels ::.."));
+
+ gui_manager->add(quit_button);
+ gui_manager->add(contrib_button);
+ gui_manager->add(start_button);
+ gui_manager->add(editor_button);
+
+ logo = Sprite("core/misc/logo");
+
+ create_background(Size(Display::get_width(), Display::get_height()));
+
+ help = _("..:: Ctrl-g: mouse grab :: F10: fps counter :: F11:
fullscreen :: F12: screenshot ::..");
+}
+
+PingusMenu::~PingusMenu()
+{
+}
+
+void
+PingusMenu::show_credits()
+{
+ ScreenManager::instance()->push_screen(new Credits());
+}
+
+void
+PingusMenu::do_quit()
+{
+ ScreenManager::instance ()->pop_screen ();
+}
+
+void
+PingusMenu::do_start(const std::string &filename)
+{ // Start the story or worldmap mode
+ Sound::PingusSound::play_sound ("letsgo");
+
+#if 0 // FIXME: Fri Jul 4 10:33:01 2008
+ bool story_seen = false;
+ StatManager::instance()->get_bool("tutorial-startstory-seen", story_seen);
// FIXME: Hardcoding tutorial is evil
+
+ if (!story_seen)
+ {
+ ScreenManager::instance()->push_screen
+ (new
StoryScreen(WorldmapNS::WorldmapScreen::instance()->get_worldmap()->get_intro_story()),
true);
+ }
+ else
+#endif
+ {
+ std::auto_ptr<WorldmapNS::WorldmapScreen> worldmap_screen(new
WorldmapNS::WorldmapScreen());
+ worldmap_screen->load(filename);
+ ScreenManager::instance()->push_screen(worldmap_screen.release());
+ }
+}
+
+void PingusMenu::do_contrib(const std::string &levelfile)
+{ // Launch the specified level - don't bother checking for it, it has to exist
+ Sound::PingusSound::play_sound ("letsgo");
+ ScreenManager::instance()->push_screen
+ (new StartScreen(PLFResMgr::load_plf_from_filename(Pathname(levelfile,
Pathname::SYSTEM_PATH))));
+}
+
+void PingusMenu::do_edit()
+{ // Launch the level editor
+ Sound::PingusSound::stop_music();
+ ScreenManager::instance()->push_screen (new Editor::EditorScreen());
+}
+
+void
+PingusMenu::on_escape_press ()
+{
+ //FIXME: get_manager()->show_exit_menu ();
+}
+
+void
+PingusMenu::draw_background(DrawingContext& gc)
+{
+ background->draw(gc);
+
+ gc.draw(logo, Vector2i((gc.get_width()/2) - (logo.get_width()/2),
+ gc.get_height()/2 - 250));
+
+ gc.print_left(Fonts::pingus_small, Vector2i(25, gc.get_height()-140),
+ "Pingus "VERSION", Copyright (C) 1998-2007 Ingo Ruhnke
<address@hidden>\n"
+ "See the file AUTHORS for a complete list of contributors.\n"
+ "Pingus comes with ABSOLUTELY NO WARRANTY. This is free
software, and you are\n"
+ "welcome to redistribute it under certain conditions; see the
file COPYING for details.\n");
+
+ gc.draw_fillrect(Rect(0,
+ Display::get_height () - 26,
+ Display::get_width (),
+ Display::get_height ()),
+ Color(0, 0, 0, 255));
+
+ gc.print_center(Fonts::pingus_small,
+ Vector2i(gc.get_width() / 2,
+ gc.get_height() - Fonts::pingus_small.get_height()
- 8),
+ help);
+
+ if (0) // display hint
+ {
+ gc.print_center(Fonts::pingus_small,
+ Vector2i(gc.get_width() / 2,
+ gc.get_height() -
Fonts::pingus_small.get_height()),
+ hint);
+ }
+}
+
+void
+PingusMenu::on_click(MenuButton* button)
+{
+ if (button == start_button)
+ {
+ do_start("worldmaps/tutorial.worldmap");
+ }
+ else if (button == quit_button)
+ {
+ do_quit();
+ }
+ else if (button == editor_button)
+ {
+ do_edit();
+ }
+ else if (button == contrib_button)
+ {
+ ScreenManager::instance()->push_screen(new LevelMenu());
+ }
+}
+
+void
+PingusMenu::set_hint(const std::string& str)
+{
+ hint = str;
+}
+
+void
+PingusMenu::update(float delta)
+{
+ background->update(delta);
+}
+
+void
+PingusMenu::create_background(const Size& size_)
+{
+ // Recreate the layer manager in the new size
+ background = std::auto_ptr<LayerManager>(new LayerManager());
+
+ Surface layer1 = Resource::load_surface("core/menu/layer1");
+ Surface layer2 = Resource::load_surface("core/menu/layer2");
+ Surface layer3 = Resource::load_surface("core/menu/layer3");
+ Surface layer4 = Resource::load_surface("core/menu/layer4");
+ Surface layer5 = Resource::load_surface("core/menu/layer5");
+
+ int w = size_.width;
+ int h = size_.height;
+
+// We only need to scale the background main menu images if the screen
+ // resolution is not default
+ if (w != default_screen_width && h != default_screen_height)
+ {
+ layer1 = layer1.scale(w, 185 * h / default_screen_height);
+ layer2 = layer2.scale(w, 362 * h / default_screen_height);
+ layer3 = layer3.scale(w, 306 * h / default_screen_height);
+ layer4 = layer4.scale(w, 171 * h / default_screen_height);
+ layer5 = layer5.scale(302 * w / default_screen_width, 104 * h /
default_screen_height);
+
+ background->add_layer(Sprite(layer1), 0, 0, 12, 0);
+ background->add_layer(Sprite(layer2), 0, 150 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 25, 0);
+ background->add_layer(Sprite(layer3), 0, 200 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 50, 0);
+ background->add_layer(Sprite(layer4), 0, 429 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 100, 0);
+ background->add_layer(Sprite(layer5), 0, 500 * static_cast<float>(h) /
static_cast<float>(default_screen_height), 200, 0);
+ }
+ else
+ {
+ background->add_layer(Sprite(layer1), 0, 0, 12, 0);
+ background->add_layer(Sprite(layer2), 0, 150, 25, 0);
+ background->add_layer(Sprite(layer3), 0, 200, 50, 0);
+ background->add_layer(Sprite(layer4), 0, 429, 100, 0);
+ background->add_layer(Sprite(layer5), 0, 500, 200, 0);
+ }
+}
+
+void
+PingusMenu::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+ create_background(size);
+
+ start_button->set_pos(size.width/2 - 150,
+ size.height/2 + 20);
+
+ editor_button->set_pos(size.width/2 + 150,
+ size.height/2 + 20);
+
+ contrib_button->set_pos(size.width/2 - 150,
+ size.height/2 + 100);
+
+ quit_button->set_pos(size.width/2 + 150,
+ size.height/2 + 100);
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/pingus_menu.hpp (from rev 4043,
trunk/pingus/src/pingus/pingus_menu.hpp)
Copied: trunk/pingus/src/pingus/screens/result_screen.cpp (from rev 4044,
trunk/pingus/src/pingus/result_screen.cpp)
===================================================================
--- trunk/pingus/src/pingus/result_screen.cpp 2009-11-05 23:13:19 UTC (rev
4044)
+++ trunk/pingus/src/pingus/screens/result_screen.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,343 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/result_screen.hpp"
+
+#include <iostream>
+
+#include "engine/display/blitter.hpp"
+#include "engine/display/display.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "engine/gui/surface_button.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "engine/sound/sound.hpp"
+#include "pingus/fonts.hpp"
+#include "pingus/game_time.hpp"
+#include "pingus/gettext.h"
+#include "pingus/res_descriptor.hpp"
+#include "pingus/resource.hpp"
+#include "pingus/screens/game_session.hpp"
+#include "util/string_util.hpp"
+#include "util/system.hpp"
+
+class ResultScreenComponent : public GUI::Component
+{
+public:
+ Result result;
+ Sprite background;
+ Sprite blackboard;
+ std::string time_str;
+
+ ResultScreenComponent(Result arg_result);
+ virtual ~ResultScreenComponent() {}
+ void draw(DrawingContext& gc) ;
+};
+
+class ResultScreenOkButton
+ : public GUI::SurfaceButton
+{
+private:
+ ResultScreen* parent;
+public:
+ ResultScreenOkButton(ResultScreen* p, int x, int y)
+ : GUI::SurfaceButton(x, y,
+ "core/start/ok",
+ "core/start/ok_clicked",
+ "core/start/ok_hover"),
+ parent(p)
+ {
+ }
+
+ void on_pointer_enter ()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound("tick");
+ }
+
+ void on_click() {
+ parent->close_screen();
+ Sound::PingusSound::play_sound("yipee");
+ }
+
+private:
+ ResultScreenOkButton(const ResultScreenOkButton&);
+ ResultScreenOkButton & operator=(const ResultScreenOkButton&);
+};
+
+class ResultScreenAbortButton
+ : public GUI::SurfaceButton
+{
+private:
+ ResultScreen* parent;
+public:
+ ResultScreenAbortButton(ResultScreen* p, int x, int y)
+ : GUI::SurfaceButton(x, y,
+ "core/start/back",
+ "core/start/back_clicked",
+ "core/start/back_hover"),
+ parent(p)
+ {
+ }
+
+ void draw(DrawingContext& gc) {
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 55, y_pos - 4),
_("Abort"));
+ }
+
+ void on_click() {
+ parent->close_screen();
+ }
+
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+ }
+
+private:
+ ResultScreenAbortButton(const ResultScreenAbortButton&);
+ ResultScreenAbortButton & operator=(const ResultScreenAbortButton&);
+};
+
+class ResultScreenRetryButton : public GUI::SurfaceButton
+{
+private:
+ ResultScreen* parent;
+
+public:
+ ResultScreenRetryButton(ResultScreen* p, int x, int y)
+ : GUI::SurfaceButton(x, y,
+ "core/start/ok",
+ "core/start/ok_clicked",
+ "core/start/ok_hover"),
+ parent(p)
+ {
+ }
+
+ void draw (DrawingContext& gc) {
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 30, y_pos - 24),
_("Retry"));
+ }
+
+ bool is_at(int x, int y) {
+ return x > x_pos && x < x_pos + int(button_surface.get_width())
+ && y > y_pos - 24 &&
+ y < y_pos + int(button_surface.get_height());
+ }
+
+ void on_click()
+ {
+ parent->retry_level();
+ }
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+ }
+
+private:
+ ResultScreenRetryButton(const ResultScreenRetryButton&);
+ ResultScreenRetryButton & operator=(const ResultScreenRetryButton&);
+};
+
+ResultScreenComponent::ResultScreenComponent(Result arg_result) :
+ result(arg_result),
+ background("core/menu/wood"),
+ blackboard("core/menu/blackboard"),
+ time_str()
+{
+ if (result.max_time == -1)
+ time_str = "-";
+ else
+ time_str = GameTime::ticks_to_realtime_string(result.max_time -
result.used_time);
+}
+
+void
+ResultScreenComponent::draw(DrawingContext& gc)
+{
+ // Paint the background wood panel
+ for(int y = 0; y < gc.get_height(); y += background.get_height())
+ for(int x = 0; x < gc.get_width(); x += background.get_width())
+ gc.draw(background, Vector2i(x, y));
+
+ gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
+
+ gc.print_center(Fonts::chalk_large,
+ Vector2i(gc.get_width()/2,
+ Display::get_height()/2 - 200),
+ _(result.plf.get_levelname()));
+
+ if (result.success())
+ {
+ gc.print_center(Fonts::chalk_large,
+ Vector2i(gc.get_width()/2,
+ Display::get_height()/2 - 140),
+ _("Success!"));
+ /*gc.print_center(Fonts::pingus_small, gc.get_width()/2,
gc.get_height()-30,
+ "..:: Press Space to continue ::..");*/
+ }
+ else
+ {
+ gc.print_center(Fonts::chalk_large,
+ Vector2i(gc.get_width()/2, Display::get_height()/2 -
140),
+ _("Failure!"));
+ /*gc.print_center(Fonts::pingus_normal, gc.get_width()/2,
gc.get_height()-30,
+ "..:: Press Space to retry the level ::..");*/
+ }
+
+ std::string message;
+ if (result.success())
+ {
+ if (result.killed == 0 && result.saved == result.total)
+ message = _("Perfect! You saved everyone possible - great!");
+ else if (result.killed == 0)
+ message = _("No-one got killed, pretty good work.");
+ else if (result.saved == result.needed)
+ message = _("You saved exactly what you needed - you made it, but\n"
+ "maybe you can do better?");
+ else if (result.killed >= 5)
+ message = _("Not everybody was saved, but still good work!");
+ else
+ message = _("What can I say, you made it - congratulations!");
+ }
+ else
+ {
+ if (result.killed == result.total)
+ message = _("You killed everybody, not good.");
+ else if (result.saved == 0)
+ message = _("No-one got saved - I know you can do better.");
+ else if (result.saved > 0)
+ message = _("You didn't save enough, but you saved a few. Next\n"
+ "time you might do better.");
+ else if (result.saved + 1 >= result.needed)
+ message = _("Only one more and you would have made it - try again!");
+ else if (result.saved + 5 >= result.needed)
+ message = _("Only a handful more and you would have made it - try
again!");
+ else
+ message = _("Better luck next time!");
+ }
+ gc.print_center(Fonts::chalk_normal, Vector2i(gc.get_width()/2,
gc.get_height()/2 - 70), message);
+
+ int left_x = gc.get_width()/2 - 100;
+ int right_x = gc.get_width()/2 + 100;
+ int y = Display::get_height()/2 + 10;
+
+ gc.print_left(Fonts::chalk_normal, Vector2i(left_x, y), _("Saved: "));
+ gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(result.saved)
+ + "/" + StringUtil::to_string(result.needed));;
+
+ gc.print_left(Fonts::chalk_normal, Vector2i(left_x, (y+=30)), _("Died: "));
+ gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(result.killed));
+
+
+ gc.print_left(Fonts::chalk_normal, Vector2i(left_x, (y+=30)), _("Time left:
"));
+ gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), time_str);
+}
+
+ResultScreen::ResultScreen(Result arg_result) :
+ result(arg_result),
+ ok_button(),
+ abort_button(),
+ retry_button()
+{
+ ResultScreenComponent* comp = new ResultScreenComponent(result);
+ gui_manager->add(comp);
+
+ ok_button = abort_button = retry_button = 0;
+
+ if (result.success())
+ {
+ gui_manager->add(ok_button = new ResultScreenOkButton(this,
+
Display::get_width()/2 + 225,
+
Display::get_height()/2 + 125));
+ }
+ else
+ {
+ gui_manager->add(abort_button = new ResultScreenAbortButton(this,
+
Display::get_width()/2 - 278,
+
Display::get_height()/2 + 144));
+ gui_manager->add(retry_button = new ResultScreenRetryButton(this,
+
Display::get_width()/2 + 225,
+
Display::get_height()/2 + 125));
+ }
+
+ //gui_manager->add(new GUI::SurfaceButton(500, 500, cancel_desc,
cancel_desc, cancel_desc), true);
+}
+
+void
+ResultScreen::on_startup()
+{
+ if (result.success())
+ {
+ Sound::PingusSound::play_music("success_1.it", 1.f, false);
+ }
+ else
+ {
+ Sound::PingusSound::play_music("pingus-2.it", 1.f, false);
+ }
+}
+
+void
+ResultScreen::retry_level()
+{
+ ScreenManager::instance()->replace_screen(new GameSession (result.plf,
true));
+}
+
+void
+ResultScreen::close_screen()
+{
+ ScreenManager::instance()->pop_screen();
+}
+
+void
+ResultScreen::on_fast_forward_press()
+{
+ on_pause_press();
+}
+
+void
+ResultScreen::on_pause_press()
+{
+ if (result.success())
+ close_screen();
+ else
+ retry_level();
+}
+
+void
+ResultScreen::on_escape_press()
+{
+ close_screen();
+}
+
+void
+ResultScreen::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+
+ if (ok_button)
+ ok_button->set_pos(size.width/2 + 225, size.height/2 + 125);
+
+ if (abort_button)
+ abort_button->set_pos(size.width/2 - 278, size.height/2 + 144);
+
+ if (retry_button)
+ retry_button->set_pos(size.width/2 + 225, size.height/2 + 125);
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/result_screen.hpp (from rev 4041,
trunk/pingus/src/pingus/result_screen.hpp)
Copied: trunk/pingus/src/pingus/screens/start_screen.cpp (from rev 4044,
trunk/pingus/src/pingus/start_screen.cpp)
===================================================================
--- trunk/pingus/src/pingus/start_screen.cpp 2009-11-05 23:13:19 UTC (rev
4044)
+++ trunk/pingus/src/pingus/screens/start_screen.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,267 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/start_screen.hpp"
+
+#include <iostream>
+
+#include "engine/display/blitter.hpp"
+#include "engine/display/display.hpp"
+#include "engine/gui/component.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "engine/gui/surface_button.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "engine/sound/sound.hpp"
+#include "pingus/fonts.hpp"
+#include "pingus/game_time.hpp"
+#include "pingus/gettext.h"
+#include "pingus/globals.hpp"
+#include "pingus/pingus_level.hpp"
+#include "pingus/resource.hpp"
+#include "pingus/screens/game_session.hpp"
+#include "pingus/string_format.hpp"
+#include "util/string_util.hpp"
+#include "util/system.hpp"
+
+class StartScreenComponent : public GUI::Component
+{
+private:
+ PingusLevel plf;
+ Sprite background;
+ Sprite blackboard;
+ std::string time_str;
+ std::string description;
+
+public:
+ StartScreenComponent(const PingusLevel& plf);
+ void draw(DrawingContext& gc);
+ virtual ~StartScreenComponent() {}
+
+private:
+ const std::string& format_description(int length);
+};
+
+class StartScreenOkButton : public GUI::SurfaceButton
+{
+private:
+ StartScreen* parent;
+public:
+ StartScreenOkButton(StartScreen* p)
+ : GUI::SurfaceButton(Display::get_width()/2 + 225,
+ Display::get_height()/2 + 125,
+ "core/start/ok",
+ "core/start/ok_clicked",
+ "core/start/ok_hover"),
+ parent(p)
+ {
+ }
+
+ void draw(DrawingContext& gc) {
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 30, y_pos - 20),
_("Ok"));
+ }
+
+ bool is_at(int x, int y) {
+ return x > x_pos && x < x_pos + int(button_surface.get_width())
+ && y > y_pos - 20 && y < y_pos +
int(button_surface.get_height());
+ }
+
+ void on_click()
+ {
+ Sound::PingusSound::play_sound("yipee");
+ parent->start_game();
+ }
+
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+ }
+
+private:
+ StartScreenOkButton(const StartScreenOkButton&);
+ StartScreenOkButton & operator=(const StartScreenOkButton&);
+};
+
+class StartScreenAbortButton
+ : public GUI::SurfaceButton
+{
+private:
+ StartScreen* parent;
+
+public:
+ StartScreenAbortButton(StartScreen* p)
+ : GUI::SurfaceButton(Display::get_width()/2 - 300,
+ Display::get_height()/2 + 144,
+ "core/start/back",
+ "core/start/back_clicked",
+ "core/start/back_hover"),
+ parent(p)
+ {
+ }
+
+ void draw(DrawingContext& gc) {
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 55, y_pos),
_("Abort"));
+ }
+
+ void on_click() {
+ parent->cancel_game();
+ }
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+ }
+
+private:
+ StartScreenAbortButton(const StartScreenAbortButton&);
+ StartScreenAbortButton & operator=(const StartScreenAbortButton&);
+};
+
+StartScreenComponent::StartScreenComponent(const PingusLevel& p) :
+ plf(p),
+ background("core/menu/wood"),
+ blackboard("core/menu/blackboard"),
+ time_str(),
+ description()
+{
+ time_str = GameTime::ticks_to_realtime_string(plf.get_time());
+}
+
+void
+StartScreenComponent::draw(DrawingContext& gc)
+{
+ // Paint the background wood panel
+ for(int y = 0; y < gc.get_height(); y += background.get_height())
+ for(int x = 0; x < gc.get_width(); x += background.get_width())
+ gc.draw(background, Vector2i(x, y));
+
+ gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
+
+ int left_x = gc.get_width()/2 - 150;
+ int right_x = gc.get_width()/2 + 150;
+ int y = gc.get_height()/2 + 40;
+
+ gc.print_center(Fonts::chalk_large,
+ Vector2i(gc.get_width() /2,
+ gc.get_height()/2 - 230),
+ _(plf.get_levelname()));
+
+ gc.print_left(Fonts::chalk_normal,
+ Vector2i(gc.get_width() /2 - 300,
+ gc.get_height()/2 - 170),
+ format_description(800 - 200));
+
+ y += 32;
+ y += 30;
+
+ gc.print_left (Fonts::chalk_normal, Vector2i(left_x, y), _("Number of
Pingus: "));
+ gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(plf.get_number_of_pingus()));
+
+ gc.print_left (Fonts::chalk_normal, Vector2i(left_x, (y += 30)), _("Number
to Save: "));
+ gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(plf.get_number_to_save()));
+
+ gc.print_left (Fonts::chalk_normal, Vector2i(left_x, (y += 30)), _("Time:
"));
+ gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), time_str);
+
+ //gc.print_left (Fonts::chalk_normal, left_x, (y += 30), _("Difficulty:"));
+ //gc.print_right(Fonts::chalk_normal, right_x, y,
StringUtil::to_string(plf.get_difficulty()) + "/100");
+
+ gc.print_center(Fonts::chalk_small,
+ Vector2i(gc.get_width()/2,
+ gc.get_height()/2 + 215),
+ _("Author: ") + plf.get_author());
+
+ if (maintainer_mode)
+ gc.print_left(Fonts::chalk_small, Vector2i(110, 430), _("Filename: ") +
plf.get_resname());
+}
+
+const std::string&
+StartScreenComponent::format_description(int length)
+{
+ if (description != "")
+ return description;
+
+ description = _(plf.get_description());
+
+ if (description == "")
+ return description;
+
+ description = StringFormat::break_line(description, length,
Fonts::chalk_normal);
+
+ return description;
+}
+
+StartScreen::StartScreen(const PingusLevel& arg_plf) :
+ plf(arg_plf),
+ abort_button(),
+ ok_button()
+{
+ StartScreenComponent* comp = new StartScreenComponent(plf);
+ gui_manager->add(comp);
+ gui_manager->add(ok_button = new StartScreenOkButton(this));
+ gui_manager->add(abort_button = new StartScreenAbortButton(this));
+}
+
+StartScreen::~StartScreen()
+{
+
+}
+
+void
+StartScreen::on_fast_forward_press()
+{
+ start_game();
+}
+
+void
+StartScreen::on_pause_press ()
+{
+ start_game();
+}
+
+void
+StartScreen::on_escape_press()
+{
+ cancel_game();
+}
+
+void
+StartScreen::start_game()
+{
+ GameSession* game_session = new GameSession(plf, true);
+ ScreenManager::instance()->replace_screen(game_session);
+}
+
+void
+StartScreen::cancel_game()
+{
+ ScreenManager::instance()->pop_screen();
+}
+
+void
+StartScreen::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+
+ abort_button->set_pos(size.width/2 - 300, size.height/2 + 144);
+ ok_button ->set_pos(size.width/2 + 225, size.height/2 + 125);
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/start_screen.hpp (from rev 4041,
trunk/pingus/src/pingus/start_screen.hpp)
Copied: trunk/pingus/src/pingus/screens/story_screen.cpp (from rev 4041,
trunk/pingus/src/pingus/story_screen.cpp)
===================================================================
--- trunk/pingus/src/pingus/story_screen.cpp 2009-11-05 22:48:38 UTC (rev
4041)
+++ trunk/pingus/src/pingus/screens/story_screen.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -0,0 +1,324 @@
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
+
+#include "pingus/screens/story_screen.hpp"
+
+#include <algorithm>
+#include <vector>
+
+#include "engine/display/display.hpp"
+#include "engine/gui/component.hpp"
+#include "engine/gui/gui_manager.hpp"
+#include "engine/gui/surface_button.hpp"
+#include "engine/screen/screen_manager.hpp"
+#include "engine/sound/sound.hpp"
+#include "math/math.hpp"
+#include "pingus/fonts.hpp"
+#include "pingus/gettext.h"
+#include "pingus/globals.hpp"
+#include "pingus/res_descriptor.hpp"
+#include "pingus/resource.hpp"
+#include "pingus/screens/credits.hpp"
+#include "pingus/stat_manager.hpp"
+#include "pingus/worldmap/worldmap.hpp"
+#include "pingus/worldmap/worldmap_screen.hpp"
+#include "pingus/worldmap/worldmap_story.hpp"
+#include "util/utf8.hpp"
+
+class StoryScreenComponent : public GUI::Component
+{
+private:
+ Sprite background;
+ Sprite blackboard;
+
+ std::string display_text;
+ float time_passed;
+
+ bool page_displayed_completly;
+
+ WorldmapNS::WorldmapStory* story;
+ std::vector<StoryPage> pages;
+ Sprite page_surface;
+ StoryPage current_page;
+
+public:
+ StoryScreenComponent (WorldmapNS::WorldmapStory *arg_pages);
+ virtual ~StoryScreenComponent () {}
+
+ void draw (DrawingContext& gc);
+ void update(float delta);
+
+ void skip_story();
+ /** starts to display the next text page */
+ void next_text();
+ WorldmapNS::WorldmapStory* get_story() const { return story; }
+
+private:
+ StoryScreenComponent(const StoryScreenComponent&);
+ StoryScreenComponent & operator=(const StoryScreenComponent&);
+};
+
+class StoryScreenContinueButton : public GUI::SurfaceButton
+{
+private:
+ StoryScreenComponent* story_comp;
+public:
+ StoryScreenContinueButton(StoryScreenComponent* arg_story_comp, int x, int y)
+ : GUI::SurfaceButton(x, y,
+ "core/misc/next",
+ "core/misc/next",
+ "core/misc/next_hover"),
+ story_comp(arg_story_comp)
+ {
+ }
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick", 0.3f);
+ }
+
+ void on_click()
+ {
+ story_comp->next_text();
+ }
+
+private:
+ StoryScreenContinueButton(const StoryScreenContinueButton&);
+ StoryScreenContinueButton & operator=(const StoryScreenContinueButton&);
+};
+
+class StoryScreenSkipButton : public GUI::SurfaceButton
+{
+private:
+ StoryScreenComponent* story_comp;
+
+public:
+ StoryScreenSkipButton(StoryScreenComponent* arg_story_comp, int x, int y)
+ : GUI::SurfaceButton(x, y, "", "", ""), // FIXME: Little fugly way to do a
text button
+ story_comp(arg_story_comp)
+ {
+ }
+
+ void draw (DrawingContext& gc)
+ {
+ gc.print_right(Fonts::chalk_small, Vector2i(x_pos, y_pos), _("skip"));
+ }
+
+ bool is_at(int x, int y)
+ {
+ return
+ x > x_pos - static_cast<int>(Fonts::chalk_small.get_width(_("skip"))) &&
+ x < x_pos &&
+ y > y_pos &&
+ y < y_pos + static_cast<int>(Fonts::chalk_small.get_height());
+ }
+
+ void on_pointer_enter()
+ {
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick", 0.3f);
+ }
+
+ void on_click()
+ {
+ story_comp->skip_story();
+ }
+
+private:
+ StoryScreenSkipButton(const StoryScreenSkipButton&);
+ StoryScreenSkipButton & operator=(const StoryScreenSkipButton&);
+};
+
+StoryScreen::StoryScreen(FileReader reader) :
+ story(new WorldmapNS::WorldmapStory(reader)),
+ story_comp(),
+ continue_button(0),
+ skip_button(0)
+{
+ story_comp = new StoryScreenComponent(story.get());
+ gui_manager->add(story_comp);
+ gui_manager->add(continue_button = new StoryScreenContinueButton(story_comp,
+
Display::get_width()/2 + 220 + 40,
+
Display::get_height()/2 + 180 + 32));
+ if (maintainer_mode)
+ gui_manager->add(skip_button = new StoryScreenSkipButton(story_comp,
+
Display::get_width() - 4,
+
Display::get_height() - 26));
+}
+
+StoryScreen::~StoryScreen()
+{
+}
+
+StoryScreenComponent::StoryScreenComponent (WorldmapNS::WorldmapStory
*arg_story) :
+ background(),
+ blackboard(),
+ display_text(),
+ time_passed(),
+ page_displayed_completly(),
+ story(arg_story),
+ pages(),
+ page_surface(),
+ current_page()
+{
+ page_displayed_completly = false;
+ time_passed = 0;
+ pages = story->get_pages();
+
+ current_page = pages.back();
+ page_surface = Sprite(current_page.image);
+
+ background = Sprite("core/menu/wood");
+ blackboard = Sprite("core/menu/blackboard");
+}
+
+void
+StoryScreenComponent::draw (DrawingContext& gc)
+{
+ // Paint the background wood panel
+ for(int y = 0; y < gc.get_height(); y += background.get_height())
+ for(int x = 0; x < gc.get_width(); x += background.get_width())
+ gc.draw(background, Vector2i(x, y));
+
+ gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
+
+ gc.print_center(Fonts::chalk_large,
+ Vector2i(gc.get_width()/2, gc.get_height()/2 - 200),
+ story->get_title());
+ gc.draw(page_surface, Vector2i(gc.get_width()/2, gc.get_height()/2 - 65));
+
+ gc.print_left(Fonts::chalk_normal,
+ Vector2i(gc.get_width()/2 - 280,
+ gc.get_height()/2 + 35),
+ display_text);
+}
+
+void
+StoryScreenComponent::update(float delta)
+{
+ time_passed += delta;
+
+ if (!page_displayed_completly)
+ {
+ std::string::size_type len = static_cast<std::string::size_type>(20.0f *
time_passed);
+ std::string::size_type text_len = UTF8::length(current_page.text);
+
+ display_text = UTF8::substr(current_page.text, 0, Math::min(text_len,
len));
+
+ if (text_len < len)
+ {
+ page_displayed_completly = true;
+ }
+ }
+}
+
+void
+StoryScreen::on_fast_forward_press ()
+{
+ story_comp->next_text();
+}
+
+void
+StoryScreen::on_escape_press ()
+{
+ ScreenManager::instance()->pop_screen();
+}
+
+void
+StoryScreen::on_startup()
+{
+ // FIXME: Load the song from the WorldmapStory
+ Sound::PingusSound::play_music(story_comp->get_story()->get_music(), .7f);
+}
+
+void StoryScreenComponent::skip_story()
+{
+ page_displayed_completly = true;
+ while (pages.size() > 1)
+ pages.pop_back();
+ next_text();
+}
+
+void
+StoryScreenComponent::next_text()
+{
+ if (!page_displayed_completly)
+ {
+ page_displayed_completly = true;
+ display_text = current_page.text;
+ }
+ else
+ {
+ pages.pop_back();
+ if (!pages.empty())
+ {
+ current_page = pages.back();
+ page_surface = Sprite(current_page.image);
+ display_text = "";
+ time_passed = 0;
+ page_displayed_completly = false;
+ }
+ else
+ {
+#if 0 // FIXME: Sat Jul 5 04:17:01 2008
+ //Out of story pages - figure out which one this was (start or end)
+ std::string which_story = "start";
+
+ //Out of story pages - figure out which one this was (start or end)
+ if (story ==
WorldmapNS::WorldmapScreen::instance()->get_worldmap()->get_intro_story())
+ which_story = "start";
+ else
+ which_story = "end";
+
+ // Record that player has seen this story.
+
StatManager::instance()->set_bool(WorldmapNS::WorldmapScreen::instance()->get_worldmap()->get_shortname()
+ + "-" + which_story +
"story-seen", true);
+ bool credits_seen = false;
+ //Check if this is the last worldmap
+ if (which_story == "end" &&
+
WorldmapNS::WorldmapScreen::instance()->get_worldmap()->is_final_map())
+ {
+ // Check if final credits have been seen
+ StatManager::instance()->get_bool("credits-seen", credits_seen);
+ if (!credits_seen)
+ ScreenManager::instance()->replace_screen(new Credits(), true);
+ else
+ ScreenManager::instance()->replace_screen(new
WorldmapNS::WorldmapScreen(), true);
+ }
+ else
+ {
+ ScreenManager::instance()->replace_screen(new
WorldmapNS::WorldmapScreen(), true);
+ }
+#endif
+ ScreenManager::instance()->pop_screen();
+ }
+ }
+}
+
+void
+StoryScreen::resize(const Size& size_)
+{
+ GUIScreen::resize(size_);
+
+ continue_button->set_pos(size.width/2 + 220 + 40,
+ size.height/2 + 180 +32);
+ if (skip_button)
+ skip_button->set_pos(size.width - 4,
+ size.height - 26);
+}
+
+/* EOF */
Copied: trunk/pingus/src/pingus/screens/story_screen.hpp (from rev 4041,
trunk/pingus/src/pingus/story_screen.hpp)
Deleted: trunk/pingus/src/pingus/start_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/start_screen.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/start_screen.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,266 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/start_screen.hpp"
-
-#include <iostream>
-#include "engine/gui/gui_manager.hpp"
-#include "engine/gui/surface_button.hpp"
-#include "engine/gui/component.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "engine/display/blitter.hpp"
-#include "gettext.h"
-#include "pingus/game_session.hpp"
-#include "pingus/globals.hpp"
-#include "util/system.hpp"
-#include "pingus/fonts.hpp"
-#include "pingus/resource.hpp"
-#include "pingus/game_time.hpp"
-#include "engine/sound/sound.hpp"
-#include "pingus/pingus_level.hpp"
-#include "pingus/string_format.hpp"
-#include "engine/display/display.hpp"
-#include "util/string_util.hpp"
-
-class StartScreenComponent : public GUI::Component
-{
-private:
- PingusLevel plf;
- Sprite background;
- Sprite blackboard;
- std::string time_str;
- std::string description;
-
-public:
- StartScreenComponent(const PingusLevel& plf);
- void draw(DrawingContext& gc);
- virtual ~StartScreenComponent() {}
-
-private:
- const std::string& format_description(int length);
-};
-
-class StartScreenOkButton : public GUI::SurfaceButton
-{
-private:
- StartScreen* parent;
-public:
- StartScreenOkButton(StartScreen* p)
- : GUI::SurfaceButton(Display::get_width()/2 + 225,
- Display::get_height()/2 + 125,
- "core/start/ok",
- "core/start/ok_clicked",
- "core/start/ok_hover"),
- parent(p)
- {
- }
-
- void draw(DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 30, y_pos - 20),
_("Ok"));
- }
-
- bool is_at(int x, int y) {
- return x > x_pos && x < x_pos + int(button_surface.get_width())
- && y > y_pos - 20 && y < y_pos +
int(button_surface.get_height());
- }
-
- void on_click()
- {
- Sound::PingusSound::play_sound("yipee");
- parent->start_game();
- }
-
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-
-private:
- StartScreenOkButton(const StartScreenOkButton&);
- StartScreenOkButton & operator=(const StartScreenOkButton&);
-};
-
-class StartScreenAbortButton
- : public GUI::SurfaceButton
-{
-private:
- StartScreen* parent;
-
-public:
- StartScreenAbortButton(StartScreen* p)
- : GUI::SurfaceButton(Display::get_width()/2 - 300,
- Display::get_height()/2 + 144,
- "core/start/back",
- "core/start/back_clicked",
- "core/start/back_hover"),
- parent(p)
- {
- }
-
- void draw(DrawingContext& gc) {
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_normal, Vector2i(x_pos + 55, y_pos),
_("Abort"));
- }
-
- void on_click() {
- parent->cancel_game();
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
- }
-
-private:
- StartScreenAbortButton(const StartScreenAbortButton&);
- StartScreenAbortButton & operator=(const StartScreenAbortButton&);
-};
-
-StartScreenComponent::StartScreenComponent(const PingusLevel& p) :
- plf(p),
- background("core/menu/wood"),
- blackboard("core/menu/blackboard"),
- time_str(),
- description()
-{
- time_str = GameTime::ticks_to_realtime_string(plf.get_time());
-}
-
-void
-StartScreenComponent::draw(DrawingContext& gc)
-{
- // Paint the background wood panel
- for(int y = 0; y < gc.get_height(); y += background.get_height())
- for(int x = 0; x < gc.get_width(); x += background.get_width())
- gc.draw(background, Vector2i(x, y));
-
- gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
-
- int left_x = gc.get_width()/2 - 150;
- int right_x = gc.get_width()/2 + 150;
- int y = gc.get_height()/2 + 40;
-
- gc.print_center(Fonts::chalk_large,
- Vector2i(gc.get_width() /2,
- gc.get_height()/2 - 230),
- _(plf.get_levelname()));
-
- gc.print_left(Fonts::chalk_normal,
- Vector2i(gc.get_width() /2 - 300,
- gc.get_height()/2 - 170),
- format_description(800 - 200));
-
- y += 32;
- y += 30;
-
- gc.print_left (Fonts::chalk_normal, Vector2i(left_x, y), _("Number of
Pingus: "));
- gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(plf.get_number_of_pingus()));
-
- gc.print_left (Fonts::chalk_normal, Vector2i(left_x, (y += 30)), _("Number
to Save: "));
- gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y),
StringUtil::to_string(plf.get_number_to_save()));
-
- gc.print_left (Fonts::chalk_normal, Vector2i(left_x, (y += 30)), _("Time:
"));
- gc.print_right(Fonts::chalk_normal, Vector2i(right_x, y), time_str);
-
- //gc.print_left (Fonts::chalk_normal, left_x, (y += 30), _("Difficulty:"));
- //gc.print_right(Fonts::chalk_normal, right_x, y,
StringUtil::to_string(plf.get_difficulty()) + "/100");
-
- gc.print_center(Fonts::chalk_small,
- Vector2i(gc.get_width()/2,
- gc.get_height()/2 + 215),
- _("Author: ") + plf.get_author());
-
- if (maintainer_mode)
- gc.print_left(Fonts::chalk_small, Vector2i(110, 430), _("Filename: ") +
plf.get_resname());
-}
-
-const std::string&
-StartScreenComponent::format_description(int length)
-{
- if (description != "")
- return description;
-
- description = _(plf.get_description());
-
- if (description == "")
- return description;
-
- description = StringFormat::break_line(description, length,
Fonts::chalk_normal);
-
- return description;
-}
-
-StartScreen::StartScreen(const PingusLevel& arg_plf) :
- plf(arg_plf),
- abort_button(),
- ok_button()
-{
- StartScreenComponent* comp = new StartScreenComponent(plf);
- gui_manager->add(comp);
- gui_manager->add(ok_button = new StartScreenOkButton(this));
- gui_manager->add(abort_button = new StartScreenAbortButton(this));
-}
-
-StartScreen::~StartScreen()
-{
-
-}
-
-void
-StartScreen::on_fast_forward_press()
-{
- start_game();
-}
-
-void
-StartScreen::on_pause_press ()
-{
- start_game();
-}
-
-void
-StartScreen::on_escape_press()
-{
- cancel_game();
-}
-
-void
-StartScreen::start_game()
-{
- GameSession* game_session = new GameSession(plf, true);
- ScreenManager::instance()->replace_screen(game_session);
-}
-
-void
-StartScreen::cancel_game()
-{
- ScreenManager::instance()->pop_screen();
-}
-
-void
-StartScreen::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
-
- abort_button->set_pos(size.width/2 - 300, size.height/2 + 144);
- ok_button ->set_pos(size.width/2 + 225, size.height/2 + 125);
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/start_screen.hpp
===================================================================
--- trunk/pingus/src/pingus/start_screen.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/start_screen.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,55 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_START_SCREEN_HPP
-#define HEADER_PINGUS_PINGUS_START_SCREEN_HPP
-
-#include "pingus/pingus_level.hpp"
-#include "engine/screen/gui_screen.hpp"
-
-namespace GUI {
-class SurfaceButton;
-} // namespace GUI
-
-/** */
-class StartScreen : public GUIScreen
-{
-private:
- PingusLevel plf;
- GUI::SurfaceButton* abort_button;
- GUI::SurfaceButton* ok_button;
-
-public:
- StartScreen(const PingusLevel& plf);
- ~StartScreen();
-
- void start_game();
- void cancel_game();
-
- void on_pause_press();
- void on_fast_forward_press();
- void on_escape_press();
-
- void resize(const Size&);
-
-private:
- StartScreen (const StartScreen&);
- StartScreen& operator= (const StartScreen&);
-};
-
-#endif
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/story_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/story_screen.cpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/story_screen.cpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,323 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/story_screen.hpp"
-
-#include <algorithm>
-#include <vector>
-#include "gettext.h"
-#include "pingus/globals.hpp"
-#include "pingus/resource.hpp"
-#include "engine/gui/gui_manager.hpp"
-#include "engine/gui/surface_button.hpp"
-#include "engine/screen/screen_manager.hpp"
-#include "engine/gui/component.hpp"
-#include "math/math.hpp"
-#include "pingus/fonts.hpp"
-#include "pingus/res_descriptor.hpp"
-#include "pingus/worldmap/worldmap.hpp"
-#include "pingus/worldmap/worldmap_screen.hpp"
-#include "pingus/worldmap/worldmap_story.hpp"
-#include "pingus/stat_manager.hpp"
-#include "pingus/credits.hpp"
-#include "engine/display/display.hpp"
-#include "util/utf8.hpp"
-#include "engine/sound/sound.hpp"
-
-class StoryScreenComponent : public GUI::Component
-{
-private:
- Sprite background;
- Sprite blackboard;
-
- std::string display_text;
- float time_passed;
-
- bool page_displayed_completly;
-
- WorldmapNS::WorldmapStory* story;
- std::vector<StoryPage> pages;
- Sprite page_surface;
- StoryPage current_page;
-
-public:
- StoryScreenComponent (WorldmapNS::WorldmapStory *arg_pages);
- virtual ~StoryScreenComponent () {}
-
- void draw (DrawingContext& gc);
- void update(float delta);
-
- void skip_story();
- /** starts to display the next text page */
- void next_text();
- WorldmapNS::WorldmapStory* get_story() const { return story; }
-
-private:
- StoryScreenComponent(const StoryScreenComponent&);
- StoryScreenComponent & operator=(const StoryScreenComponent&);
-};
-
-class StoryScreenContinueButton : public GUI::SurfaceButton
-{
-private:
- StoryScreenComponent* story_comp;
-public:
- StoryScreenContinueButton(StoryScreenComponent* arg_story_comp, int x, int y)
- : GUI::SurfaceButton(x, y,
- "core/misc/next",
- "core/misc/next",
- "core/misc/next_hover"),
- story_comp(arg_story_comp)
- {
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick", 0.3f);
- }
-
- void on_click()
- {
- story_comp->next_text();
- }
-
-private:
- StoryScreenContinueButton(const StoryScreenContinueButton&);
- StoryScreenContinueButton & operator=(const StoryScreenContinueButton&);
-};
-
-class StoryScreenSkipButton : public GUI::SurfaceButton
-{
-private:
- StoryScreenComponent* story_comp;
-
-public:
- StoryScreenSkipButton(StoryScreenComponent* arg_story_comp, int x, int y)
- : GUI::SurfaceButton(x, y, "", "", ""), // FIXME: Little fugly way to do a
text button
- story_comp(arg_story_comp)
- {
- }
-
- void draw (DrawingContext& gc)
- {
- gc.print_right(Fonts::chalk_small, Vector2i(x_pos, y_pos), _("skip"));
- }
-
- bool is_at(int x, int y)
- {
- return
- x > x_pos - static_cast<int>(Fonts::chalk_small.get_width(_("skip"))) &&
- x < x_pos &&
- y > y_pos &&
- y < y_pos + static_cast<int>(Fonts::chalk_small.get_height());
- }
-
- void on_pointer_enter()
- {
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick", 0.3f);
- }
-
- void on_click()
- {
- story_comp->skip_story();
- }
-
-private:
- StoryScreenSkipButton(const StoryScreenSkipButton&);
- StoryScreenSkipButton & operator=(const StoryScreenSkipButton&);
-};
-
-StoryScreen::StoryScreen(FileReader reader) :
- story(new WorldmapNS::WorldmapStory(reader)),
- story_comp(),
- continue_button(0),
- skip_button(0)
-{
- story_comp = new StoryScreenComponent(story.get());
- gui_manager->add(story_comp);
- gui_manager->add(continue_button = new StoryScreenContinueButton(story_comp,
-
Display::get_width()/2 + 220 + 40,
-
Display::get_height()/2 + 180 + 32));
- if (maintainer_mode)
- gui_manager->add(skip_button = new StoryScreenSkipButton(story_comp,
-
Display::get_width() - 4,
-
Display::get_height() - 26));
-}
-
-StoryScreen::~StoryScreen()
-{
-}
-
-StoryScreenComponent::StoryScreenComponent (WorldmapNS::WorldmapStory
*arg_story) :
- background(),
- blackboard(),
- display_text(),
- time_passed(),
- page_displayed_completly(),
- story(arg_story),
- pages(),
- page_surface(),
- current_page()
-{
- page_displayed_completly = false;
- time_passed = 0;
- pages = story->get_pages();
-
- current_page = pages.back();
- page_surface = Sprite(current_page.image);
-
- background = Sprite("core/menu/wood");
- blackboard = Sprite("core/menu/blackboard");
-}
-
-void
-StoryScreenComponent::draw (DrawingContext& gc)
-{
- // Paint the background wood panel
- for(int y = 0; y < gc.get_height(); y += background.get_height())
- for(int x = 0; x < gc.get_width(); x += background.get_width())
- gc.draw(background, Vector2i(x, y));
-
- gc.draw(blackboard, Vector2i(gc.get_width()/2, gc.get_height()/2));
-
- gc.print_center(Fonts::chalk_large,
- Vector2i(gc.get_width()/2, gc.get_height()/2 - 200),
- story->get_title());
- gc.draw(page_surface, Vector2i(gc.get_width()/2, gc.get_height()/2 - 65));
-
- gc.print_left(Fonts::chalk_normal,
- Vector2i(gc.get_width()/2 - 280,
- gc.get_height()/2 + 35),
- display_text);
-}
-
-void
-StoryScreenComponent::update(float delta)
-{
- time_passed += delta;
-
- if (!page_displayed_completly)
- {
- std::string::size_type len = static_cast<std::string::size_type>(20.0f *
time_passed);
- std::string::size_type text_len = UTF8::length(current_page.text);
-
- display_text = UTF8::substr(current_page.text, 0, Math::min(text_len,
len));
-
- if (text_len < len)
- {
- page_displayed_completly = true;
- }
- }
-}
-
-void
-StoryScreen::on_fast_forward_press ()
-{
- story_comp->next_text();
-}
-
-void
-StoryScreen::on_escape_press ()
-{
- ScreenManager::instance()->pop_screen();
-}
-
-void
-StoryScreen::on_startup()
-{
- // FIXME: Load the song from the WorldmapStory
- Sound::PingusSound::play_music(story_comp->get_story()->get_music(), .7f);
-}
-
-void StoryScreenComponent::skip_story()
-{
- page_displayed_completly = true;
- while (pages.size() > 1)
- pages.pop_back();
- next_text();
-}
-
-void
-StoryScreenComponent::next_text()
-{
- if (!page_displayed_completly)
- {
- page_displayed_completly = true;
- display_text = current_page.text;
- }
- else
- {
- pages.pop_back();
- if (!pages.empty())
- {
- current_page = pages.back();
- page_surface = Sprite(current_page.image);
- display_text = "";
- time_passed = 0;
- page_displayed_completly = false;
- }
- else
- {
-#if 0 // FIXME: Sat Jul 5 04:17:01 2008
- //Out of story pages - figure out which one this was (start or end)
- std::string which_story = "start";
-
- //Out of story pages - figure out which one this was (start or end)
- if (story ==
WorldmapNS::WorldmapScreen::instance()->get_worldmap()->get_intro_story())
- which_story = "start";
- else
- which_story = "end";
-
- // Record that player has seen this story.
-
StatManager::instance()->set_bool(WorldmapNS::WorldmapScreen::instance()->get_worldmap()->get_shortname()
- + "-" + which_story +
"story-seen", true);
- bool credits_seen = false;
- //Check if this is the last worldmap
- if (which_story == "end" &&
-
WorldmapNS::WorldmapScreen::instance()->get_worldmap()->is_final_map())
- {
- // Check if final credits have been seen
- StatManager::instance()->get_bool("credits-seen", credits_seen);
- if (!credits_seen)
- ScreenManager::instance()->replace_screen(new Credits(), true);
- else
- ScreenManager::instance()->replace_screen(new
WorldmapNS::WorldmapScreen(), true);
- }
- else
- {
- ScreenManager::instance()->replace_screen(new
WorldmapNS::WorldmapScreen(), true);
- }
-#endif
- ScreenManager::instance()->pop_screen();
- }
- }
-}
-
-void
-StoryScreen::resize(const Size& size_)
-{
- GUIScreen::resize(size_);
-
- continue_button->set_pos(size.width/2 + 220 + 40,
- size.height/2 + 180 +32);
- if (skip_button)
- skip_button->set_pos(size.width - 4,
- size.height - 26);
-}
-
-/* EOF */
Deleted: trunk/pingus/src/pingus/story_screen.hpp
===================================================================
--- trunk/pingus/src/pingus/story_screen.hpp 2009-11-06 00:02:11 UTC (rev
4047)
+++ trunk/pingus/src/pingus/story_screen.hpp 2009-11-06 00:10:50 UTC (rev
4048)
@@ -1,62 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2002 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 3 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, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_STORY_SCREEN_HPP
-#define HEADER_PINGUS_PINGUS_STORY_SCREEN_HPP
-
-#include <string>
-#include <memory>
-#include "pingus/res_descriptor.hpp"
-#include "engine/screen/gui_screen.hpp"
-#include "pingus/worldmap/worldmap_story.hpp"
-
-class StoryScreenComponent;
-
-namespace WorldmapNS {
-class WorldmapStory;
-} // namespace WorldmapNS
-
-namespace GUI {
-class SurfaceButton;
-}
-
-/** */
-class StoryScreen : public GUIScreen
-{
-private:
- std::auto_ptr<WorldmapNS::WorldmapStory> story;
- StoryScreenComponent* story_comp;
- GUI::SurfaceButton* continue_button;
- GUI::SurfaceButton* skip_button;
-
-public:
- StoryScreen(FileReader reader);
- ~StoryScreen();
-
- void on_startup();
- void on_fast_forward_press ();
- void on_escape_press ();
-
- void resize(const Size& size);
-
-private:
- StoryScreen (const StoryScreen&);
- StoryScreen& operator= (const StoryScreen&);
-};
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/pingus/worldmap/level_dot.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/level_dot.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/worldmap/level_dot.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -30,7 +30,7 @@
#include "pingus/plf_res_mgr.hpp"
#include "pingus/resource.hpp"
#include "pingus/savegame_manager.hpp"
-#include "pingus/start_screen.hpp"
+#include "pingus/screens/start_screen.hpp"
#include "engine/screen/screen_manager.hpp"
#include "util/file_reader.hpp"
#include "util/system.hpp"
Modified: trunk/pingus/src/pingus/worldmap/worldmap.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/worldmap.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/worldmap/worldmap.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -45,7 +45,7 @@
#include "math/math.hpp"
#include "pingus/stat_manager.hpp"
-#include "pingus/story_screen.hpp"
+#include "pingus/screens/story_screen.hpp"
#include "engine/screen/screen_manager.hpp"
namespace WorldmapNS {
Modified: trunk/pingus/src/pingus/worldmap/worldmap_screen.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/worldmap_screen.cpp 2009-11-06
00:02:11 UTC (rev 4047)
+++ trunk/pingus/src/pingus/worldmap/worldmap_screen.cpp 2009-11-06
00:10:50 UTC (rev 4048)
@@ -29,7 +29,7 @@
#include "pingus/res_descriptor.hpp"
#include "pingus/resource.hpp"
#include "pingus/stat_manager.hpp"
-#include "pingus/story_screen.hpp"
+#include "pingus/screens/story_screen.hpp"
#include "engine/screen/screen_manager.hpp"
#include "engine/sound/sound.hpp"
#include "pingus/worldmap/pingus.hpp"
Modified: trunk/pingus/src/pingus/worldmap/worldmap_story.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/worldmap_story.cpp 2009-11-06 00:02:11 UTC
(rev 4047)
+++ trunk/pingus/src/pingus/worldmap/worldmap_story.cpp 2009-11-06 00:10:50 UTC
(rev 4048)
@@ -18,7 +18,7 @@
#include <algorithm>
#include <vector>
-#include "pingus/story_screen.hpp"
+#include "pingus/screens/story_screen.hpp"
#include "util/file_reader.hpp"
#include "pingus/res_descriptor.hpp"
#include "pingus/pingus_error.hpp"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r4048 - in trunk/pingus: . src/editor src/pingus src/pingus/components src/pingus/screens src/pingus/worldmap,
grumbel at BerliOS <=