[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3668 - in trunk/pingus: . src src/worldmap
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3668 - in trunk/pingus: . src src/worldmap |
Date: |
Fri, 4 Jul 2008 10:51:10 +0200 |
Author: grumbel
Date: 2008-07-04 10:51:09 +0200 (Fri, 04 Jul 2008)
New Revision: 3668
Added:
trunk/pingus/src/worldmap/worldmap_screen.cpp
trunk/pingus/src/worldmap/worldmap_screen.hpp
Removed:
trunk/pingus/src/worldmap/manager.cpp
trunk/pingus/src/worldmap/manager.hpp
Modified:
trunk/pingus/SConstruct
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/pingus_menu.cpp
trunk/pingus/src/story_screen.cpp
trunk/pingus/src/worldmap/surface_drawable.cpp
trunk/pingus/src/worldmap/worldmap.cpp
trunk/pingus/src/worldmap/worldmap_component.cpp
Log:
Renamed manager.?pp to worldmap_screen.?pp
Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct 2008-07-04 08:48:07 UTC (rev 3667)
+++ trunk/pingus/SConstruct 2008-07-04 08:51:09 UTC (rev 3668)
@@ -250,7 +250,7 @@
'src/worldmap/drawable_factory.cpp',
'src/worldmap/graph.cpp',
'src/worldmap/level_dot.cpp',
-'src/worldmap/manager.cpp',
+'src/worldmap/worldmap_screen.cpp',
'src/worldmap/path.cpp',
'src/worldmap/path_drawable.cpp',
'src/worldmap/path_graph.cpp',
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2008-07-04 08:48:07 UTC (rev 3667)
+++ trunk/pingus/src/pingus_main.cpp 2008-07-04 08:51:09 UTC (rev 3668)
@@ -78,12 +78,12 @@
#include "pingu_action_factory.hpp"
#include "credits.hpp"
#include "sound/sound.hpp"
-#include "worldmap/manager.hpp"
+#include "worldmap/worldmap_screen.hpp"
#include "cheat.hpp"
// #include "blitter_test.hpp"
// #include "preview_renderer.hpp"
#include "font_test_screen.hpp"
-#include "worldmap/manager.hpp"
+#include "worldmap/worldmap_screen.hpp"
#include "worldobj_factory.hpp"
#include "editor/editor_screen.hpp"
Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp 2008-07-04 08:48:07 UTC (rev 3667)
+++ trunk/pingus/src/pingus_menu.cpp 2008-07-04 08:51:09 UTC (rev 3668)
@@ -26,7 +26,7 @@
#include "start_screen.hpp"
#include "story_screen.hpp"
#include "worldmap/worldmap.hpp"
-#include "worldmap/manager.hpp"
+#include "worldmap/worldmap_screen.hpp"
#include "screen/screen_manager.hpp"
#include "pingus_menu_manager.hpp"
#include "gui/gui_manager.hpp"
Modified: trunk/pingus/src/story_screen.cpp
===================================================================
--- trunk/pingus/src/story_screen.cpp 2008-07-04 08:48:07 UTC (rev 3667)
+++ trunk/pingus/src/story_screen.cpp 2008-07-04 08:51:09 UTC (rev 3668)
@@ -28,7 +28,7 @@
#include "story_screen.hpp"
#include "res_descriptor.hpp"
#include "worldmap/worldmap.hpp"
-#include "worldmap/manager.hpp"
+#include "worldmap/worldmap_screen.hpp"
#include "worldmap/worldmap_story.hpp"
#include "stat_manager.hpp"
#include "credits.hpp"
Deleted: trunk/pingus/src/worldmap/manager.cpp
===================================================================
--- trunk/pingus/src/worldmap/manager.cpp 2008-07-04 08:48:07 UTC (rev
3667)
+++ trunk/pingus/src/worldmap/manager.cpp 2008-07-04 08:51:09 UTC (rev
3668)
@@ -1,322 +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 <iostream>
-#include "../gettext.h"
-#include "../fonts.hpp"
-#include "../display/display.hpp"
-#include "../screen/screen_manager.hpp"
-#include "../gui/surface_button.hpp"
-#include "../path_manager.hpp"
-#include "../res_descriptor.hpp"
-#include "../sound/sound.hpp"
-#include "../stat_manager.hpp"
-#include "../display/scene_context.hpp"
-#include "../math.hpp"
-#include "worldmap.hpp"
-#include "worldmap_component.hpp"
-#include "resource.hpp"
-#include "worldmap_story.hpp"
-#include "pingus.hpp"
-#include "manager.hpp"
-#include "../story_screen.hpp"
-
-WorldMapScreen* WorldMapScreen::instance_ = 0;
-
-class WorldMapScreenCloseButton
- : public GUI::SurfaceButton
-{
-private:
- WorldMapScreen* worldmap_screen;
-public:
- WorldMapScreenCloseButton(WorldMapScreen* worldmap_screen);
- void on_click();
- void draw (DrawingContext& gc);
- void on_pointer_enter();
-};
-
-class WorldMapScreenStoryButton
- : public GUI::SurfaceButton
-{
-private:
- WorldMapScreen* worldmap_screen;
-public:
- WorldMapScreenStoryButton(WorldMapScreen* worldmap_screen);
- void on_click();
- void draw (DrawingContext& gc);
- void on_pointer_enter();
-};
-
-class WorldMapScreenCreditsButton
- : public GUI::SurfaceButton
-{
-private:
- WorldMapScreen* worldmap_screen;
-public:
- WorldMapScreenCreditsButton(WorldMapScreen* worldmap_screen);
- void on_click();
- void draw (DrawingContext& gc);
- void on_pointer_enter();
-};
-
-class WorldMapScreenEnterButton
- : public GUI::SurfaceButton
-{
-private:
- WorldMapScreen* worldmap_screen;
-public:
- WorldMapScreenEnterButton(WorldMapScreen* worldmap_screen);
- void on_click();
- void draw (DrawingContext& gc);
- void on_pointer_enter();
-};
-
-WorldMapScreenCreditsButton::WorldMapScreenCreditsButton(WorldMapScreen*
worldmap_screen)
- : GUI::SurfaceButton(Display::get_width() - 150, 0,
- ResDescriptor("core/worldmap/credits_button_normal"),
- ResDescriptor("core/worldmap/credits_button_pressed"),
- ResDescriptor("core/worldmap/credits_button_hover")),
- worldmap_screen(worldmap_screen)
-{
-}
-
-void
-WorldMapScreenCreditsButton::on_pointer_enter()
-{
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
-}
-
-void
-WorldMapScreenCreditsButton::draw (DrawingContext& gc)
-{
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_small, Display::get_width() - 59 - 24, 2,
_("Show Ending?"));
-}
-
-void
-WorldMapScreenCreditsButton::on_click()
-{
- ScreenManager::instance()->replace_screen
- (new StoryScreen(worldmap_screen->get_worldmap()->get_end_story()), true);
-}
-
-WorldMapScreenStoryButton::WorldMapScreenStoryButton(WorldMapScreen*
worldmap_screen)
- : GUI::SurfaceButton(0, 0,
- ResDescriptor("core/worldmap/story_button_normal"),
- ResDescriptor("core/worldmap/story_button_pressed"),
- ResDescriptor("core/worldmap/story_button_hover")),
- worldmap_screen(worldmap_screen)
-{
-}
-
-void
-WorldMapScreenStoryButton::on_pointer_enter()
-{
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
-}
-
-void
-WorldMapScreenStoryButton::draw (DrawingContext& gc)
-{
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_small, 59, 2, _("Show Story?"));
-}
-
-void
-WorldMapScreenStoryButton::on_click()
-{
- ScreenManager::instance()->replace_screen
- (new StoryScreen(worldmap_screen->get_worldmap()->get_intro_story()),
true);
-}
-
-WorldMapScreenCloseButton::WorldMapScreenCloseButton(WorldMapScreen*
worldmap_screen)
- : GUI::SurfaceButton(0, Display::get_height() - 37,
- ResDescriptor("core/worldmap/leave_button_normal"),
- ResDescriptor("core/worldmap/leave_button_pressed"),
- ResDescriptor("core/worldmap/leave_button_hover")),
- worldmap_screen(worldmap_screen)
-{
-}
-
-void
-WorldMapScreenCloseButton::on_pointer_enter()
-{
- SurfaceButton::on_pointer_enter();
- Sound::PingusSound::play_sound ("tick");
-}
-
-void
-WorldMapScreenCloseButton::draw (DrawingContext& gc)
-{
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_small, 44, Display::get_height() - 25,
_("Leave?"));
-}
-
-void
-WorldMapScreenCloseButton::on_click()
-{
- ScreenManager::instance ()->pop_screen ();
-}
-
-WorldMapScreenEnterButton::WorldMapScreenEnterButton(WorldMapScreen*
worldmap_screen)
- : GUI::SurfaceButton(Display::get_width() - 119, Display::get_height() - 37,
- ResDescriptor("core/worldmap/enter_button_normal"),
- ResDescriptor("core/worldmap/enter_button_pressed"),
- ResDescriptor("core/worldmap/enter_button_hover")),
- worldmap_screen(worldmap_screen)
-{
-}
-
-void
-WorldMapScreenEnterButton::on_pointer_enter()
-{
- SurfaceButton::on_pointer_enter();
- if (!worldmap_screen->get_worldmap()->get_pingus()->is_walking())
- {
- Sound::PingusSound::play_sound ("tick");
- }
-}
-
-void
-WorldMapScreenEnterButton::draw (DrawingContext& gc)
-{
- if (worldmap_screen->get_worldmap()->get_pingus()->is_walking())
- {
- gc.draw(button_surface, Vector2i(x_pos, y_pos));
- }
- else
- {
- SurfaceButton::draw(gc);
- gc.print_center(Fonts::chalk_small,
- Display::get_width() - 43 - 22,
- Display::get_height() - 25,
- _("Enter?"));
- }
-}
-
-void
-WorldMapScreenEnterButton::on_click()
-{
- worldmap_screen->get_worldmap()->enter_level();
-}
-
-WorldMapScreen::WorldMapScreen ()
- : levelname_bg(Sprite("core/worldmap/levelname_bg")),
- is_init(false),
- exit_worldmap(false),
- worldmap(0),
- new_worldmap(0)
-{
- // FIXME: a bit ugly because of the proteced member, but should work
- // FIXME: well enough. GUIScreen could also use multi-inheritage,
- // FIXME: but that could lead to member function name conflicts
- worldmap_component = new WorldMapComponent(this);
- gui_manager->add (worldmap_component, true);
- gui_manager->add(new WorldMapScreenCloseButton(this), true);
- gui_manager->add(new WorldMapScreenEnterButton(this), true);
- gui_manager->add(new WorldMapScreenStoryButton(this), true);
-}
-
-void
-WorldMapScreen::load (const std::string& filename)
-{
- if (worldmap)
- delete worldmap;
-
- worldmap = new WorldMap(filename);
-
- bool credits_unlocked = false;
- StatManager::instance()->get_bool(worldmap->get_shortname() +
"-endstory-seen",
- credits_unlocked);
- if (credits_unlocked)
- {
- gui_manager->add(new WorldMapScreenCreditsButton(this), true);
- }
-}
-
-void
-WorldMapScreen::on_startup ()
-{
- exit_worldmap = false;
- Sound::PingusSound::stop_music();
-
- if (worldmap)
- worldmap->on_startup ();
-}
-
-WorldMapScreen::~WorldMapScreen ()
-{
- delete worldmap;
- delete new_worldmap;
-}
-
-void
-WorldMapScreen::on_escape_press ()
-{
- //std::cout << "WorldMapScreen::on_escape_press ()..." << std::endl;
- exit_worldmap = true;
-}
-
-void
-WorldMapScreen::update (float delta)
-{
- GUIScreen::update(delta);
-
- // Exit the word
- if (exit_worldmap)
- ScreenManager::instance ()->pop_screen ();
-
- // Check if new worldmap is set and if so, change it
- if (new_worldmap)
- {
- delete worldmap;
- worldmap = new_worldmap;
- new_worldmap = 0;
- }
-}
-
-void
-WorldMapScreen::draw_foreground(DrawingContext& gc)
-{
- // Draw the levelname
- gc.draw(levelname_bg,
- Vector2i(gc.get_width()/2 - levelname_bg.get_width()/2,
- gc.get_height() - levelname_bg.get_height()));
-
- gc.print_center(Fonts::chalk_small, gc.get_width()/2, gc.get_height() - 25,
- worldmap->get_levelname());
-}
-
-void
-WorldMapScreen::change_map (const std::string& filename, NodeId node)
-{
- // Create the new worldmap and make it the current one
- new_worldmap = new WorldMap (path_manager.complete("worldmaps/" + filename));
- new_worldmap->set_pingus (node);
-}
-
-Rect
-WorldMapScreen::get_trans_rect() const
-{
- return Rect(Vector2i(Math::max((Display::get_width() -
worldmap->get_width())/2, 0),
- Math::max((Display::get_height() -
worldmap->get_height())/2, 0)),
- Size(Math::min(Display::get_width(), worldmap->get_width()),
- Math::min(Display::get_height(), worldmap->get_height())));
-}
-
-/* EOF */
Deleted: trunk/pingus/src/worldmap/manager.hpp
===================================================================
--- trunk/pingus/src/worldmap/manager.hpp 2008-07-04 08:48:07 UTC (rev
3667)
+++ trunk/pingus/src/worldmap/manager.hpp 2008-07-04 08:51:09 UTC (rev
3668)
@@ -1,97 +0,0 @@
-// Pingus - A free Lemmings clone
-// Copyright (C) 2000,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_WORLDMAP_MANAGER_HPP
-#define HEADER_PINGUS_WORLDMAP_MANAGER_HPP
-
-#include <string>
-#include "../sprite.hpp"
-#include "../gui/gui_manager.hpp"
-#include "../screen/gui_screen.hpp"
-
-class SceneContext;
-
-namespace WorldMapNS {
-
-typedef int NodeId;
-class WorldMap;
-class WorldMapComponent;
-
-/** The WorldMapScreen manages the worldmaps and the translation
- between two worldmaps, it also holds the GUI elements that are
- accessible in the WorldMap Screen */
-class WorldMapScreen : public GUIScreen
-{
- WorldMapComponent* worldmap_component;
-
- friend class WorldMapComponent;
-private:
- static WorldMapScreen* instance_;
-
- Sprite levelname_bg;
-
- bool is_init;
- bool exit_worldmap;
-
- WorldMap* worldmap;
- WorldMap* new_worldmap;
-
-public:
- WorldMapScreen ();
- ~WorldMapScreen ();
-
- void load (const std::string& filename);
-
- /** Check if WorldMap manager still needs to run and exit if if
- not */
- void update (float);
- void draw_foreground(DrawingContext& gc);
-
- /** @defgroup WorldMapScreenBindings Controller bindings of the
WorldMapScreen
- @{*/
- /** Calculate the node that was clicked and set the pingu to walk
- to that node. If a node is double-cliked, the pingu should go
- faster. */
- void on_primary_button_press (int x, int y);
-
- /** Exit the WorldMapScreen and return to the previous screen */
- void on_escape_press ();
- /** @}*/
-
- WorldMap* get_worldmap() { return worldmap; }
-
- /** Change the current map to the given map
-
- @param filename the filename of the new map, filename must be
- @param filename relative to the worldmap directory
- @param filename Example: "volcano.pingus" */
- void change_map (const std::string& filename, NodeId node);
-
- Rect get_trans_rect() const;
-
-private:
- /** Startup Hook of the Screen */
- void on_startup ();
-
- WorldMapScreen (const WorldMapScreen&);
- WorldMapScreen& operator= (const WorldMapScreen&);
-};
-
-} // namespace WorldMapNS
-
-#endif
-
-/* EOF */
Modified: trunk/pingus/src/worldmap/surface_drawable.cpp
===================================================================
--- trunk/pingus/src/worldmap/surface_drawable.cpp 2008-07-04 08:48:07 UTC
(rev 3667)
+++ trunk/pingus/src/worldmap/surface_drawable.cpp 2008-07-04 08:51:09 UTC
(rev 3668)
@@ -18,7 +18,7 @@
#include "../resource.hpp"
#include "../display/drawing_context.hpp"
-#include "manager.hpp"
+#include "worldmap_screen.hpp"
#include "worldmap.hpp"
#include "pingus.hpp"
#include "surface_drawable.hpp"
Modified: trunk/pingus/src/worldmap/worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.cpp 2008-07-04 08:48:07 UTC (rev
3667)
+++ trunk/pingus/src/worldmap/worldmap.cpp 2008-07-04 08:51:09 UTC (rev
3668)
@@ -34,7 +34,7 @@
#include "../lisp/lisp.hpp"
#include "worldmap.hpp"
#include "worldmap_story.hpp"
-#include "manager.hpp"
+#include "worldmap_screen.hpp"
#include "pingus.hpp"
#include "drawable_factory.hpp"
#include "drawable.hpp"
Modified: trunk/pingus/src/worldmap/worldmap_component.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_component.cpp 2008-07-04 08:48:07 UTC
(rev 3667)
+++ trunk/pingus/src/worldmap/worldmap_component.cpp 2008-07-04 08:51:09 UTC
(rev 3668)
@@ -16,7 +16,7 @@
#include "../display/display.hpp"
#include "../display/scene_context.hpp"
-#include "manager.hpp"
+#include "worldmap_screen.hpp"
#include "worldmap.hpp"
#include "worldmap_component.hpp"
Copied: trunk/pingus/src/worldmap/worldmap_screen.cpp (from rev 3667,
trunk/pingus/src/worldmap/manager.cpp)
===================================================================
--- trunk/pingus/src/worldmap/manager.cpp 2008-07-04 08:48:07 UTC (rev
3667)
+++ trunk/pingus/src/worldmap/worldmap_screen.cpp 2008-07-04 08:51:09 UTC
(rev 3668)
@@ -0,0 +1,322 @@
+// 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 <iostream>
+#include "../gettext.h"
+#include "../fonts.hpp"
+#include "../display/display.hpp"
+#include "../screen/screen_manager.hpp"
+#include "../gui/surface_button.hpp"
+#include "../path_manager.hpp"
+#include "../res_descriptor.hpp"
+#include "../sound/sound.hpp"
+#include "../stat_manager.hpp"
+#include "../display/scene_context.hpp"
+#include "../math.hpp"
+#include "worldmap.hpp"
+#include "worldmap_component.hpp"
+#include "resource.hpp"
+#include "worldmap_story.hpp"
+#include "pingus.hpp"
+#include "../story_screen.hpp"
+#include "worldmap_screen.hpp"
+
+WorldMapScreen* WorldMapScreen::instance_ = 0;
+
+class WorldMapScreenCloseButton
+ : public GUI::SurfaceButton
+{
+private:
+ WorldMapScreen* worldmap_screen;
+public:
+ WorldMapScreenCloseButton(WorldMapScreen* worldmap_screen);
+ void on_click();
+ void draw (DrawingContext& gc);
+ void on_pointer_enter();
+};
+
+class WorldMapScreenStoryButton
+ : public GUI::SurfaceButton
+{
+private:
+ WorldMapScreen* worldmap_screen;
+public:
+ WorldMapScreenStoryButton(WorldMapScreen* worldmap_screen);
+ void on_click();
+ void draw (DrawingContext& gc);
+ void on_pointer_enter();
+};
+
+class WorldMapScreenCreditsButton
+ : public GUI::SurfaceButton
+{
+private:
+ WorldMapScreen* worldmap_screen;
+public:
+ WorldMapScreenCreditsButton(WorldMapScreen* worldmap_screen);
+ void on_click();
+ void draw (DrawingContext& gc);
+ void on_pointer_enter();
+};
+
+class WorldMapScreenEnterButton
+ : public GUI::SurfaceButton
+{
+private:
+ WorldMapScreen* worldmap_screen;
+public:
+ WorldMapScreenEnterButton(WorldMapScreen* worldmap_screen);
+ void on_click();
+ void draw (DrawingContext& gc);
+ void on_pointer_enter();
+};
+
+WorldMapScreenCreditsButton::WorldMapScreenCreditsButton(WorldMapScreen*
worldmap_screen)
+ : GUI::SurfaceButton(Display::get_width() - 150, 0,
+ ResDescriptor("core/worldmap/credits_button_normal"),
+ ResDescriptor("core/worldmap/credits_button_pressed"),
+ ResDescriptor("core/worldmap/credits_button_hover")),
+ worldmap_screen(worldmap_screen)
+{
+}
+
+void
+WorldMapScreenCreditsButton::on_pointer_enter()
+{
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+}
+
+void
+WorldMapScreenCreditsButton::draw (DrawingContext& gc)
+{
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_small, Display::get_width() - 59 - 24, 2,
_("Show Ending?"));
+}
+
+void
+WorldMapScreenCreditsButton::on_click()
+{
+ ScreenManager::instance()->replace_screen
+ (new StoryScreen(worldmap_screen->get_worldmap()->get_end_story()), true);
+}
+
+WorldMapScreenStoryButton::WorldMapScreenStoryButton(WorldMapScreen*
worldmap_screen)
+ : GUI::SurfaceButton(0, 0,
+ ResDescriptor("core/worldmap/story_button_normal"),
+ ResDescriptor("core/worldmap/story_button_pressed"),
+ ResDescriptor("core/worldmap/story_button_hover")),
+ worldmap_screen(worldmap_screen)
+{
+}
+
+void
+WorldMapScreenStoryButton::on_pointer_enter()
+{
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+}
+
+void
+WorldMapScreenStoryButton::draw (DrawingContext& gc)
+{
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_small, 59, 2, _("Show Story?"));
+}
+
+void
+WorldMapScreenStoryButton::on_click()
+{
+ ScreenManager::instance()->replace_screen
+ (new StoryScreen(worldmap_screen->get_worldmap()->get_intro_story()),
true);
+}
+
+WorldMapScreenCloseButton::WorldMapScreenCloseButton(WorldMapScreen*
worldmap_screen)
+ : GUI::SurfaceButton(0, Display::get_height() - 37,
+ ResDescriptor("core/worldmap/leave_button_normal"),
+ ResDescriptor("core/worldmap/leave_button_pressed"),
+ ResDescriptor("core/worldmap/leave_button_hover")),
+ worldmap_screen(worldmap_screen)
+{
+}
+
+void
+WorldMapScreenCloseButton::on_pointer_enter()
+{
+ SurfaceButton::on_pointer_enter();
+ Sound::PingusSound::play_sound ("tick");
+}
+
+void
+WorldMapScreenCloseButton::draw (DrawingContext& gc)
+{
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_small, 44, Display::get_height() - 25,
_("Leave?"));
+}
+
+void
+WorldMapScreenCloseButton::on_click()
+{
+ ScreenManager::instance ()->pop_screen ();
+}
+
+WorldMapScreenEnterButton::WorldMapScreenEnterButton(WorldMapScreen*
worldmap_screen)
+ : GUI::SurfaceButton(Display::get_width() - 119, Display::get_height() - 37,
+ ResDescriptor("core/worldmap/enter_button_normal"),
+ ResDescriptor("core/worldmap/enter_button_pressed"),
+ ResDescriptor("core/worldmap/enter_button_hover")),
+ worldmap_screen(worldmap_screen)
+{
+}
+
+void
+WorldMapScreenEnterButton::on_pointer_enter()
+{
+ SurfaceButton::on_pointer_enter();
+ if (!worldmap_screen->get_worldmap()->get_pingus()->is_walking())
+ {
+ Sound::PingusSound::play_sound ("tick");
+ }
+}
+
+void
+WorldMapScreenEnterButton::draw (DrawingContext& gc)
+{
+ if (worldmap_screen->get_worldmap()->get_pingus()->is_walking())
+ {
+ gc.draw(button_surface, Vector2i(x_pos, y_pos));
+ }
+ else
+ {
+ SurfaceButton::draw(gc);
+ gc.print_center(Fonts::chalk_small,
+ Display::get_width() - 43 - 22,
+ Display::get_height() - 25,
+ _("Enter?"));
+ }
+}
+
+void
+WorldMapScreenEnterButton::on_click()
+{
+ worldmap_screen->get_worldmap()->enter_level();
+}
+
+WorldMapScreen::WorldMapScreen ()
+ : levelname_bg(Sprite("core/worldmap/levelname_bg")),
+ is_init(false),
+ exit_worldmap(false),
+ worldmap(0),
+ new_worldmap(0)
+{
+ // FIXME: a bit ugly because of the proteced member, but should work
+ // FIXME: well enough. GUIScreen could also use multi-inheritage,
+ // FIXME: but that could lead to member function name conflicts
+ worldmap_component = new WorldMapComponent(this);
+ gui_manager->add (worldmap_component, true);
+ gui_manager->add(new WorldMapScreenCloseButton(this), true);
+ gui_manager->add(new WorldMapScreenEnterButton(this), true);
+ gui_manager->add(new WorldMapScreenStoryButton(this), true);
+}
+
+void
+WorldMapScreen::load (const std::string& filename)
+{
+ if (worldmap)
+ delete worldmap;
+
+ worldmap = new WorldMap(filename);
+
+ bool credits_unlocked = false;
+ StatManager::instance()->get_bool(worldmap->get_shortname() +
"-endstory-seen",
+ credits_unlocked);
+ if (credits_unlocked)
+ {
+ gui_manager->add(new WorldMapScreenCreditsButton(this), true);
+ }
+}
+
+void
+WorldMapScreen::on_startup ()
+{
+ exit_worldmap = false;
+ Sound::PingusSound::stop_music();
+
+ if (worldmap)
+ worldmap->on_startup ();
+}
+
+WorldMapScreen::~WorldMapScreen ()
+{
+ delete worldmap;
+ delete new_worldmap;
+}
+
+void
+WorldMapScreen::on_escape_press ()
+{
+ //std::cout << "WorldMapScreen::on_escape_press ()..." << std::endl;
+ exit_worldmap = true;
+}
+
+void
+WorldMapScreen::update (float delta)
+{
+ GUIScreen::update(delta);
+
+ // Exit the word
+ if (exit_worldmap)
+ ScreenManager::instance ()->pop_screen ();
+
+ // Check if new worldmap is set and if so, change it
+ if (new_worldmap)
+ {
+ delete worldmap;
+ worldmap = new_worldmap;
+ new_worldmap = 0;
+ }
+}
+
+void
+WorldMapScreen::draw_foreground(DrawingContext& gc)
+{
+ // Draw the levelname
+ gc.draw(levelname_bg,
+ Vector2i(gc.get_width()/2 - levelname_bg.get_width()/2,
+ gc.get_height() - levelname_bg.get_height()));
+
+ gc.print_center(Fonts::chalk_small, gc.get_width()/2, gc.get_height() - 25,
+ worldmap->get_levelname());
+}
+
+void
+WorldMapScreen::change_map (const std::string& filename, NodeId node)
+{
+ // Create the new worldmap and make it the current one
+ new_worldmap = new WorldMap (path_manager.complete("worldmaps/" + filename));
+ new_worldmap->set_pingus (node);
+}
+
+Rect
+WorldMapScreen::get_trans_rect() const
+{
+ return Rect(Vector2i(Math::max((Display::get_width() -
worldmap->get_width())/2, 0),
+ Math::max((Display::get_height() -
worldmap->get_height())/2, 0)),
+ Size(Math::min(Display::get_width(), worldmap->get_width()),
+ Math::min(Display::get_height(), worldmap->get_height())));
+}
+
+/* EOF */
Copied: trunk/pingus/src/worldmap/worldmap_screen.hpp (from rev 3667,
trunk/pingus/src/worldmap/manager.hpp)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3668 - in trunk/pingus: . src src/worldmap,
grumbel at BerliOS <=