[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3675 - in trunk/pingus/src: . worldmap
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3675 - in trunk/pingus/src: . worldmap |
Date: |
Sat, 5 Jul 2008 03:40:14 +0200 |
Author: grumbel
Date: 2008-07-05 03:40:10 +0200 (Sat, 05 Jul 2008)
New Revision: 3675
Modified:
trunk/pingus/src/pingus_menu.cpp
trunk/pingus/src/story_screen.cpp
trunk/pingus/src/story_screen.hpp
trunk/pingus/src/worldmap/pingus_worldmap.cpp
trunk/pingus/src/worldmap/worldmap.cpp
trunk/pingus/src/worldmap/worldmap.hpp
trunk/pingus/src/worldmap/worldmap_screen.cpp
trunk/pingus/src/worldmap/worldmap_screen.hpp
trunk/pingus/src/worldmap/worldmap_story.cpp
Log:
Some more worldmap reorganisation/fixing (still incomplete)
Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp 2008-07-05 01:00:06 UTC (rev 3674)
+++ trunk/pingus/src/pingus_menu.cpp 2008-07-05 01:40:10 UTC (rev 3675)
@@ -109,7 +109,7 @@
else
#endif
{
- std::auto_ptr<WorldmapScreen> worldmap_screen(new WorldmapScreen());
+ std::auto_ptr<WorldmapNS::WorldmapScreen> worldmap_screen(new
WorldmapNS::WorldmapScreen());
worldmap_screen->load(filename);
ScreenManager::instance()->push_screen(worldmap_screen.release(), true);
}
Modified: trunk/pingus/src/story_screen.cpp
===================================================================
--- trunk/pingus/src/story_screen.cpp 2008-07-05 01:00:06 UTC (rev 3674)
+++ trunk/pingus/src/story_screen.cpp 2008-07-05 01:40:10 UTC (rev 3675)
@@ -33,9 +33,7 @@
#include "stat_manager.hpp"
#include "credits.hpp"
#include "sound/sound.hpp"
-
-#define SKIP_TEXT _("skip")
-
+
class StoryScreenComponent : public GUI::Component
{
private:
@@ -49,6 +47,7 @@
std::vector<StoryPage> pages;
Sprite page_surface;
StoryPage current_page;
+
public:
StoryScreenComponent (WorldmapNS::WorldmapStory *arg_pages);
virtual ~StoryScreenComponent () {}
@@ -61,7 +60,7 @@
void next_text();
WorldmapNS::WorldmapStory* get_story() const { return story; }
};
-
+
class StoryScreenContinueButton : public GUI::SurfaceButton
{
private:
@@ -87,7 +86,7 @@
story_comp->next_text();
}
};
-
+
class StoryScreenSkipButton : public GUI::SurfaceButton
{
private:
@@ -102,11 +101,11 @@
void draw (DrawingContext& gc)
{
- gc.print_right(Fonts::chalk_small, x_pos, y_pos, SKIP_TEXT);
+ gc.print_right(Fonts::chalk_small, x_pos, y_pos, _("skip"));
}
bool is_at(int x, int y) {
- return x > x_pos - Fonts::chalk_small.get_width(SKIP_TEXT) && x <
x_pos
+ return x > x_pos - Fonts::chalk_small.get_width(_("skip")) && x <
x_pos
&& y > y_pos && y < y_pos + Fonts::chalk_small.get_height();
}
@@ -121,13 +120,14 @@
story_comp->skip_story();
}
};
-
-StoryScreen::StoryScreen(WorldmapNS::WorldmapStory *arg_pages)
+
+StoryScreen::StoryScreen(FileReader reader)
+ : story(new WorldmapNS::WorldmapStory(reader))
{
- story_comp = new StoryScreenComponent(arg_pages);
- gui_manager->add (story_comp, true);
- gui_manager->add (new StoryScreenContinueButton(story_comp), true);
- gui_manager->add (new StoryScreenSkipButton(story_comp), true);
+ story_comp = new StoryScreenComponent(story.get());
+ gui_manager->add(story_comp, true);
+ gui_manager->add(new StoryScreenContinueButton(story_comp), true);
+ gui_manager->add(new StoryScreenSkipButton(story_comp), true);
}
StoryScreen::~StoryScreen()
@@ -189,7 +189,7 @@
void
StoryScreen::on_escape_press ()
{
- ScreenManager::instance()->replace_screen(new WorldmapScreen(), true);
+ ScreenManager::instance()->replace_screen(new WorldmapNS::WorldmapScreen(),
true);
}
void
@@ -261,5 +261,5 @@
}
}
}
-
+
/* EOF */
Modified: trunk/pingus/src/story_screen.hpp
===================================================================
--- trunk/pingus/src/story_screen.hpp 2008-07-05 01:00:06 UTC (rev 3674)
+++ trunk/pingus/src/story_screen.hpp 2008-07-05 01:40:10 UTC (rev 3675)
@@ -22,23 +22,27 @@
#include "screen/gui_screen.hpp"
#include "worldmap/worldmap_story.hpp"
-
class StoryScreenComponent;
-using namespace WorldmapNS;
+namespace WorldmapNS {
+class WorldmapStory;
+} // namespace WorldmapNS
/** */
class StoryScreen : public GUIScreen
{
private:
+ std::auto_ptr<WorldmapNS::WorldmapStory> story;
StoryScreenComponent* story_comp;
+
public:
- StoryScreen(WorldmapStory *pages);
+ StoryScreen(FileReader reader);
~StoryScreen();
void on_startup();
void on_fast_forward_press ();
void on_escape_press ();
+
private:
StoryScreen (const StoryScreen&);
StoryScreen& operator= (const StoryScreen&);
Modified: trunk/pingus/src/worldmap/pingus_worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/pingus_worldmap.cpp 2008-07-05 01:00:06 UTC
(rev 3674)
+++ trunk/pingus/src/worldmap/pingus_worldmap.cpp 2008-07-05 01:40:10 UTC
(rev 3675)
@@ -165,5 +165,17 @@
{
return impl->objects;
}
+
+FileReader
+PingusWorldmap::get_intro_story() const
+{
+ return impl->intro_story;
+}
+
+FileReader
+PingusWorldmap::get_end_story() const
+{
+ return impl->end_story;
+}
/* EOF */
Modified: trunk/pingus/src/worldmap/worldmap.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.cpp 2008-07-05 01:00:06 UTC (rev
3674)
+++ trunk/pingus/src/worldmap/worldmap.cpp 2008-07-05 01:40:10 UTC (rev
3675)
@@ -306,7 +306,7 @@
{
if (dot->finished())
{
- ScreenManager::instance()->replace_screen(new
StoryScreen(end_story), true);
+ ScreenManager::instance()->replace_screen(new
StoryScreen(worldmap.get_end_story()), true);
}
}
else
Modified: trunk/pingus/src/worldmap/worldmap.hpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap.hpp 2008-07-05 01:00:06 UTC (rev
3674)
+++ trunk/pingus/src/worldmap/worldmap.hpp 2008-07-05 01:40:10 UTC (rev
3675)
@@ -50,9 +50,6 @@
/** name of the file to parse */
std::string filename;
- WorldmapStory *intro_story;
- WorldmapStory *end_story;
-
typedef std::vector<Drawable*> ObjectLst;
typedef std::vector<Drawable*> DrawableLst;
@@ -113,6 +110,7 @@
int get_width() const;
int get_height() const;
+ PingusWorldmap get_worldmap() const { return worldmap; }
private:
/** Unlock nodes according to the finished ones */
void update_locked_nodes();
Modified: trunk/pingus/src/worldmap/worldmap_screen.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_screen.cpp 2008-07-05 01:00:06 UTC
(rev 3674)
+++ trunk/pingus/src/worldmap/worldmap_screen.cpp 2008-07-05 01:40:10 UTC
(rev 3675)
@@ -33,6 +33,8 @@
#include "pingus.hpp"
#include "../story_screen.hpp"
#include "worldmap_screen.hpp"
+
+namespace WorldmapNS {
class WorldmapScreenCloseButton
: public GUI::SurfaceButton
@@ -108,10 +110,7 @@
void
WorldmapScreenCreditsButton::on_click()
{
-#if 0
- ScreenManager::instance()->replace_screen
- (new StoryScreen(worldmap_screen->get_worldmap()->get_end_story()), true);
-#endif
+ worldmap_screen->show_end_story();
}
WorldmapScreenStoryButton::WorldmapScreenStoryButton(WorldmapScreen*
worldmap_screen)
@@ -140,10 +139,7 @@
void
WorldmapScreenStoryButton::on_click()
{
-#if 0
- ScreenManager::instance()->replace_screen
- (new StoryScreen(worldmap_screen->get_worldmap()->get_intro_story()),
true);
-#endif
+ worldmap_screen->show_intro_story();
}
WorldmapScreenCloseButton::WorldmapScreenCloseButton(WorldmapScreen*
worldmap_screen)
@@ -217,9 +213,7 @@
WorldmapScreen::WorldmapScreen ()
: levelname_bg(Sprite("core/worldmap/levelname_bg")),
is_init(false),
- exit_worldmap(false),
- worldmap(0),
- new_worldmap(0)
+ exit_worldmap(false)
{
// FIXME: a bit ugly because of the proteced member, but should work
// FIXME: well enough. GUIScreen could also use multi-inheritage,
@@ -233,10 +227,7 @@
void
WorldmapScreen::load (const std::string& filename)
{
- if (worldmap)
- delete worldmap;
-
- worldmap = new Worldmap(filename);
+ worldmap = std::auto_ptr<Worldmap>(new Worldmap(filename));
bool credits_unlocked = false;
//StatManager::instance()->get_bool(worldmap->get_short_name() +
"-endstory-seen", credits_unlocked);
@@ -252,14 +243,12 @@
exit_worldmap = false;
Sound::PingusSound::stop_music();
- if (worldmap)
+ if (worldmap.get())
worldmap->on_startup ();
}
WorldmapScreen::~WorldmapScreen ()
{
- delete worldmap;
- delete new_worldmap;
}
void
@@ -279,11 +268,9 @@
ScreenManager::instance ()->pop_screen ();
// Check if new worldmap is set and if so, change it
- if (new_worldmap)
+ if (new_worldmap.get())
{
- delete worldmap;
- worldmap = new_worldmap;
- new_worldmap = 0;
+ worldmap = new_worldmap;
}
}
@@ -307,5 +294,19 @@
Size(Math::min(Display::get_width(), worldmap->get_width()),
Math::min(Display::get_height(), worldmap->get_height())));
}
+
+void
+WorldmapScreen::show_intro_story()
+{
+ ScreenManager::instance()->replace_screen (new
StoryScreen(worldmap->get_worldmap().get_intro_story()), true);
+}
+
+void
+WorldmapScreen::show_end_story()
+{
+ ScreenManager::instance()->replace_screen (new
StoryScreen(worldmap->get_worldmap().get_end_story()), true);
+}
+} // namespace WorldmapNS
+
/* EOF */
Modified: trunk/pingus/src/worldmap/worldmap_screen.hpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_screen.hpp 2008-07-05 01:00:06 UTC
(rev 3674)
+++ trunk/pingus/src/worldmap/worldmap_screen.hpp 2008-07-05 01:40:10 UTC
(rev 3675)
@@ -18,12 +18,12 @@
#define HEADER_PINGUS_WORLDMAP_MANAGER_HPP
#include <string>
+#include <memory>
#include "../sprite.hpp"
#include "../gui/gui_manager.hpp"
#include "../screen/gui_screen.hpp"
class SceneContext;
-
namespace WorldmapNS {
typedef int NodeId;
@@ -41,8 +41,8 @@
bool is_init;
bool exit_worldmap;
- Worldmap* worldmap;
- Worldmap* new_worldmap;
+ std::auto_ptr<Worldmap> worldmap;
+ std::auto_ptr<Worldmap> new_worldmap;
public:
WorldmapScreen ();
@@ -66,10 +66,12 @@
void on_escape_press ();
/** @}*/
- Worldmap* get_worldmap() { return worldmap; }
+ Worldmap* get_worldmap() { return worldmap.get(); }
Rect get_trans_rect() const;
+ void show_intro_story();
+ void show_end_story();
private:
/** Startup Hook of the Screen */
void on_startup ();
Modified: trunk/pingus/src/worldmap/worldmap_story.cpp
===================================================================
--- trunk/pingus/src/worldmap/worldmap_story.cpp 2008-07-05 01:00:06 UTC
(rev 3674)
+++ trunk/pingus/src/worldmap/worldmap_story.cpp 2008-07-05 01:40:10 UTC
(rev 3675)
@@ -24,6 +24,8 @@
#include "../string_format.hpp"
#include "../fonts.hpp"
#include "../gettext.h"
+
+namespace WorldmapNS {
WorldmapStory::WorldmapStory(const FileReader &reader)
{
@@ -55,4 +57,6 @@
PingusError::raise("WorldmapStory: Worldmap does not include a valid
story");
}
+} // namespace WorldmapNS
+
/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3675 - in trunk/pingus/src: . worldmap,
grumbel at BerliOS <=