pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r2546 - in trunk: data/worldmaps src src/components src/wor


From: jave27
Subject: [Pingus-CVS] r2546 - in trunk: data/worldmaps src src/components src/worldmap
Date: Thu, 8 Dec 2005 01:19:23 +0100

Author: jave27
Date: 2005-12-08 01:18:36 +0100 (Thu, 08 Dec 2005)
New Revision: 2546

Added:
   trunk/src/worldmap/worldmap_story.cxx
   trunk/src/worldmap/worldmap_story.hxx
Removed:
   trunk/src/story.cxx
   trunk/src/story.hxx
Modified:
   trunk/data/worldmaps/tutorial.xml
   trunk/data/worldmaps/volcano.xml
   trunk/src/Makefile.am
   trunk/src/components/menu_button.cxx
   trunk/src/pingus_main.cxx
   trunk/src/pingus_menu.cxx
   trunk/src/story_screen.cxx
   trunk/src/story_screen.hxx
   trunk/src/worldmap/Makefile.am
   trunk/src/worldmap/manager.cxx
   trunk/src/worldmap/worldmap.cxx
   trunk/src/worldmap/worldmap.hxx
Log:
Moved the story data to the Worldmap XML file.  This will allow for easily 
added worldmaps and 3rd party ones as well.

This breaks:
* Translation generation
* Credits (for the moment)


Modified: trunk/data/worldmaps/tutorial.xml
===================================================================
--- trunk/data/worldmaps/tutorial.xml   2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/data/worldmaps/tutorial.xml   2005-12-08 00:18:36 UTC (rev 2546)
@@ -8,6 +8,105 @@
     <width>1161</width>
     <height>600</height>
   </head>
+  
+  <intro_story>
+    <title>The Journey Begins</title>
+    <music>pingus-4.it</music>
+    <pages>
+      <page00>
+        <surface>
+          <image>story/story0</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>For a long time, the Pingus have lived happily in peace on the 
South Pole along with all the other animals. Everything was in balance and it 
seemed like nothing could disrupt their peace.  The Pingus were happy and it 
seemed like this could never end.</text>
+      </page00>
+      <page01>
+        <surface>
+          <image>story/story1</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>But then one day, things began to change slowly: the sky got 
darker and the earth got warmer. Firstly, they thought this was just a normal 
fluctuation in the world's climate, but things seemed to get worse and worse 
with every year.</text>
+      </page01>
+      <page02>
+        <surface>
+          <image>story/story2</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>The snow began to melt away in a few areas and food became an 
issue. Other animals tried to leave the region to search for colder areas, but 
the Pingus knew that this wouldn't help: they knew that they had to do 
something about it.</text>
+      </page02>
+      <page03>
+        <surface>
+          <image>story/story3</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>So the circle of the eldest came together to decide what to do 
about it. They decided to send out an expedition around the world to find the 
cause of this warming. The expedition consisted of hundreds of the bravest 
Pingus on the South Pole.</text>
+      </page03>
+      <page04>
+        <surface>
+          <image>story/story4</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>And they picked you to lead them on their journey around the 
world. Since the journey will be dangerous and difficult, your first goal is 
the Island of Mogorok, also known as the Tutorial Island. According to the 
eldest, this island has always been the first stop of Pingus that were sent out 
into the world.</text>
+      </page04>
+      <page05>
+        <surface>
+          <image>story/story5</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>The island consists of many areas that are ideal to teach the 
Pingus their abilities. The Pingus can learn to build bridges, climb, bash and 
use many other talents which they will need on their long and dangerous 
journey.</text>
+      </page05>
+      <page06>
+        <surface>
+          <image>story/story6</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>While there, you can practice your abilities in commanding and 
guiding the Pingus. You can also get familiar with all the abilities the Pingus 
provide and learn to master them, since you will need all of them on your 
journey around the world.</text>
+      </page06>
+      <page07>
+        <surface>
+          <image>story/story6</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>Now that you and the Pingus have arrived at Tutorial Island it 
is time to take command and begin your mission. Good Luck!</text>
+      </page07>
+    </pages>
+  </intro_story>
+  
+  <end_story>
+    <title>The Journey Continues</title>
+    <music>pingus-4.it</music>
+    <pages>
+      <page01>
+        <surface>
+          <image>story/credits1</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>Now after you and the Pingus have learned the basics and 
practiced a bit it is time to move on and begin the journey into the world. 
Since the ice floe with which the Pingus traveled to the Tutorial Island isn't 
going to hold on the whole way into the warmer climates the Pingus have to find 
something else to guide them on their journey.</text>
+      </page01>
+      <page02>
+        <surface>
+          <image>story/credits2</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>But as the eldest have said, the Tutorial Island provides not 
only a good way to practice, but it is also the starting point into the world. 
After some searching the Pingus discovered the meaning of this, and they found 
the large tree at the end of the island which gave them wood to construct a 
float.</text>
+      </page02>
+      <page03>
+        <surface>
+          <image>story/credits3</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>So the Pingus set out and constructed some large rafts, enough 
to carry them all. After also packing a bunch of provisions they were prepared 
to start their journey and leave their familiar ground and enter the unknown 
parts of the world.</text>
+      </page03>
+      <page04>
+        <surface>
+          <image>story/credits4</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>So the Pingus sit on their raft, worrying about what's to come 
and where to go, while floating into the sunset.  To be continued...</text>
+      </page04>
+    </pages>
+  </end_story>
+  
   <graph>
     <nodes>
       <leveldot>

Modified: trunk/data/worldmaps/volcano.xml
===================================================================
--- trunk/data/worldmaps/volcano.xml    2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/data/worldmaps/volcano.xml    2005-12-08 00:18:36 UTC (rev 2546)
@@ -8,6 +8,41 @@
     <height>600</height>
   </head>
   
+  <intro_story>
+    <title>Volcano Island</title>
+    <music>pingus-6.it</music>
+    <pages>
+      <page01>
+        <surface>
+          <image>core/menu/folder</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>This is sample Volcano text.</text>
+      </page01>
+      <page02>
+        <surface>
+          <image>core/menu/folder</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>This is page 2 of the volcano story.</text>
+      </page02>
+    </pages>
+  </intro_story>
+  
+  <end_story>
+    <title>Volcano Island</title>
+    <music>pingus-6.it</music>
+    <pages>
+      <page01>
+        <surface>
+          <image>core/menu/folder</image>
+          <modifier>ROT0</modifier>
+        </surface>
+        <text>Hi</text>
+      </page01>
+    </pages>
+  </end_story>
+  
   <!-- The graph specifies the path on which the pingu can walk -->
   <graph>
     <nodes>

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am       2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/Makefile.am       2005-12-08 00:18:36 UTC (rev 2546)
@@ -234,8 +234,6 @@
 stat_manager.hxx \
 state_sprite.cxx \
 state_sprite.hxx \
-story.cxx \
-story.hxx \
 story_screen.cxx \
 story_screen.hxx \
 string_format.cxx \

Modified: trunk/src/components/menu_button.cxx
===================================================================
--- trunk/src/components/menu_button.cxx        2005-12-07 03:52:07 UTC (rev 
2545)
+++ trunk/src/components/menu_button.cxx        2005-12-08 00:18:36 UTC (rev 
2546)
@@ -31,10 +31,13 @@
 #include "../story_screen.hxx"
 #include "../gettext.h"
 #include "../stat_manager.hxx"
-#include "../story.hxx"
 
 #include "menu_button.hxx"
 
+#if _MSC_VER > 1000
+#pragma warning( once : 4244 )
+#endif
+
 namespace Pingus {
 
 MenuButton::MenuButton(const CL_Point& pos_, const CL_Sprite& sprite_, 

Modified: trunk/src/pingus_main.cxx
===================================================================
--- trunk/src/pingus_main.cxx   2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/pingus_main.cxx   2005-12-08 00:18:36 UTC (rev 2546)
@@ -64,7 +64,6 @@
 #include "credits.hxx"
 #include "sound/sound.hxx"
 #include "worldmap/manager.hxx"
-#include "story.hxx"
 #include "cheat.hxx"
 #include "blitter_test.hxx"
 #include "preview_renderer.hxx"
@@ -905,7 +904,6 @@
 
   Resource::init();
   Fonts::init();
-  Story::init();
   ScreenManager::init();
   PingusMenuManager::init();
   Sound::PingusSound::init();

Modified: trunk/src/pingus_menu.cxx
===================================================================
--- trunk/src/pingus_menu.cxx   2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/pingus_menu.cxx   2005-12-08 00:18:36 UTC (rev 2546)
@@ -29,7 +29,7 @@
 #include "stat_manager.hxx"
 #include "start_screen.hxx"
 #include "story_screen.hxx"
-#include "story.hxx"
+#include "worldmap/worldmap.hxx"
 #include "worldmap/manager.hxx"
 #include "gui/screen_manager.hxx"
 #include "pingus_menu_manager.hxx"
@@ -161,7 +161,8 @@
 
   if (!story_seen)
     {
-      ScreenManager::instance()->push_screen(new StoryScreen(Story::intro), 
true);
+      ScreenManager::instance()->push_screen(
+                               new 
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
 true);
     }
   else
     {

Deleted: trunk/src/story.cxx
===================================================================
--- trunk/src/story.cxx 2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/story.cxx 2005-12-08 00:18:36 UTC (rev 2546)
@@ -1,179 +0,0 @@
-//  $Id: story.cxx,v 1.32 2003/10/18 23:17:27 grumbel Exp $
-//
-//  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 2
-//  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, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#include <algorithm>
-#include "gettext.h"
-#include "story.hxx"
-#include "string_format.hxx"
-#include "fonts.hxx"
-
-namespace Pingus {
-
-Story Story::credits;
-Story Story::intro;
-
-void
-Story::init()
-{
-  init_intro();
-  init_credits();
-}
-
-void
-Story::init_credits()
-{
-  credits.title = _("The Journey Continues");
-  credits.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/credits1"),
-      StringFormat::break_line(
-      _("Now after you and the Pingus have learned the basics and\n"
-        "practiced a bit it is time to move on and begin the journey into\n"
-        "the world. Since the ice floe with which the Pingus traveled to the\n"
-        "Tutorial Island isn't going to hold on the whole way into the 
warmer\n"
-        "climates the Pingus have to find something else to guide\n"
-        "them on their journey.\n"), 570, Fonts::chalk_normal)
-        ));
-
-  credits.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/credits2"),
-      StringFormat::break_line(
-      _("But as the eldest have said, the Tutorial Island provides not\n"
-        "only a good way to practice, but it is also the starting point into\n"
-        "the world. After some searching the Pingus discovered the meaning\n"
-        "of this, and they found the large tree at the end of the island\n"
-        "which gave them wood to construct a float.\n"), 570, 
Fonts::chalk_normal)
-       ));
-
-  credits.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/credits3"),
-      StringFormat::break_line(
-      _("So the Pingus set out and constructed some large rafts, enough\n"
-        "to carry them all. After also packing a bunch of provisions\n"
-        "they were prepared to start their journey and leave\n"
-        "their familiar ground and enter the unknown parts of the world.\n"), 
570, Fonts::chalk_normal)
-        ));
-
-  credits.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/credits4"),
-      StringFormat::break_line(
-      _("So the Pingus sit on their raft, worrying about what's to come and\n"
-        "where to go, while floating into the sunset.\n"
-        "\n"
-        "To be continued..."), 570, Fonts::chalk_normal)
-       ));
-
-  std::reverse(credits.pages.begin(), credits.pages.end());
-}
-
-void
-Story::init_intro()
-{
-  intro.title = _("The Journey Begins");
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story0"),
-      StringFormat::break_line(
-      _("For a long time, the Pingus have lived happily in peace on the\n"
-        "South Pole along with all the other animals. Everything was in\n"
-        "balance and it seemed like nothing could disrupt their peace.  The\n"
-        "Pingus were happy and it seemed like this could never end.\n"), 570, 
Fonts::chalk_normal)
-       ));
-
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story1"),
-      StringFormat::break_line(
-      _("But then one day, things began to change slowly: the sky got darker\n"
-        "and the earth got warmer. Firstly, they thought this was just a\n"
-        "normal fluctuation in the world's climate, but things seemed to get\n"
-        "worse and worse with every year."), 570, Fonts::chalk_normal)
-       ));
-
-
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story2"),
-      StringFormat::break_line(
-      _("The snow began to melt away in a few areas and food became an\n"
-        "issue. Other animals tried to leave the region to search\n"
-        "for colder areas, but the Pingus knew that this wouldn't help:\n"
-        "they knew that they had to do something about it."), 570, 
Fonts::chalk_normal)
-       ));
-
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story3"),
-      StringFormat::break_line(
-      _("So the circle of the eldest came together to decide what to do\n"
-        "about it. They decided to send out an expedition around the world\n"
-        "to find the cause of this warming. The expedition consisted of\n"
-        "hundreds of the bravest Pingus on the South Pole."), 570, 
Fonts::chalk_normal)
-       ));
-
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story4"),
-      StringFormat::break_line(
-      _("And they picked you to lead them on their journey around the\n"
-        "world. Since the journey will be dangerous and difficult, your\n"
-        "first goal is the Island of Mogorok, also known as the Tutorial\n"
-        "Island. According to the eldest, this island has always been the\n"
-        "first stop of Pingus that were sent out into the world."), 570, 
Fonts::chalk_normal)
-       ));
-
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story5"),
-      StringFormat::break_line(
-      _("The island consists of many areas that are ideal to teach the\n"
-        "Pingus their abilities. The Pingus can learn to build\n"
-        "bridges, climb, bash and use many other talents which they\n"
-        "will need on their long and dangerous journey."), 570, 
Fonts::chalk_normal)
-       ));
-
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story6"),
-      StringFormat::break_line(
-      _("While there, you can practice your abilities in commanding\n"
-        "and guiding the Pingus. You can also get familiar with\n"
-        "all the abilities the Pingus provide and learn to master them,\n"
-        "since you will need all of them on your journey around the\n"
-        "world."), 570, Fonts::chalk_normal)
-       ));
-
-  intro.pages.push_back
-    (StoryPage
-     (ResDescriptor("story/story6"),
-      StringFormat::break_line(
-      _("Now that you and the Pingus have arrived at Tutorial Island it\n"
-        "is time to take command and begin your mission.\n"
-        "\nGood Luck!"), 570, Fonts::chalk_normal)
-       ));
-
-  std::reverse(intro.pages.begin(), intro.pages.end());
-}
-
-} // namespace Pingus
-
-/* EOF */

Deleted: trunk/src/story.hxx
===================================================================
--- trunk/src/story.hxx 2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/story.hxx 2005-12-08 00:18:36 UTC (rev 2546)
@@ -1,48 +0,0 @@
-//  $Id: story.hxx,v 1.15 2003/10/18 23:17:27 grumbel Exp $
-//
-//  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 2
-//  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, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-#ifndef HEADER_PINGUS_STORY_HXX
-#define HEADER_PINGUS_STORY_HXX
-
-#include "story_screen.hxx"
-
-namespace Pingus {
-
-/** */
-class Story
-{
-private:
-public:
-  std::string title;
-  std::vector<StoryPage> pages;
-
-  static Story credits;
-  static Story intro;
-
-  static void init();
-private:
-  static void init_intro();
-  static void init_credits();
-};
-
-} // namespace Pingus
-
-#endif
-
-/* EOF */

Modified: trunk/src/story_screen.cxx
===================================================================
--- trunk/src/story_screen.cxx  2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/story_screen.cxx  2005-12-08 00:18:36 UTC (rev 2546)
@@ -32,8 +32,8 @@
 #include "story_screen.hxx"
 #include "res_descriptor.hxx"
 #include "worldmap/manager.hxx"
+#include "worldmap/worldmap_story.hxx"
 #include "stat_manager.hxx"
-#include "story.hxx"
 #include "credits.hxx"
 #include "sound/sound.hxx"
 
@@ -50,11 +50,12 @@
 
   bool page_displayed_completly;
 
-  Story story;
+       WorldMapNS::WorldMapStory *story;
+       std::vector<StoryPage> pages;
   CL_Sprite page_surface;
   StoryPage  current_page;
 public:
-  StoryScreenComponent (const Story&);
+       StoryScreenComponent (WorldMapNS::WorldMapStory *arg_pages);
   virtual ~StoryScreenComponent () {}
 
   void draw (DrawingContext& gc);
@@ -62,6 +63,7 @@
 
   /** starts to display the next text page */
   void next_text();
+       WorldMapNS::WorldMapStory* get_story() const { return story; }
 };
 
 class StoryScreenContinueButton : public GUI::SurfaceButton
@@ -92,7 +94,7 @@
 };
 
 
-StoryScreen::StoryScreen(const Story& arg_pages)
+StoryScreen::StoryScreen(WorldMapNS::WorldMapStory *arg_pages)
 {
   story_comp = new StoryScreenComponent(arg_pages);
   gui_manager->add (story_comp);
@@ -103,18 +105,20 @@
 {
 }
 
-StoryScreenComponent::StoryScreenComponent (const Story& arg_story)
+StoryScreenComponent::StoryScreenComponent (WorldMapNS::WorldMapStory 
*arg_story)
   : story(arg_story)
 {
-  if (&arg_story == &Story::credits)
+       // FIXME: Need to Re-enable credits
+  /*if (&arg_story == &Story::credits)
     show_credits = true;
-  else
+  else */
     show_credits = false;
 
   page_displayed_completly = false;
   time_passed  = 0;
+       pages = story->get_pages();
 
-  current_page = story.pages.back();
+  current_page = pages.back();
   page_surface = Resource::load_sprite(current_page.image);
   background   = Resource::load_sprite("core/menu/startscreenbg");
 }
@@ -125,7 +129,7 @@
   gc.draw(background, Vector(gc.get_width()/2, gc.get_height()/2));
 
   gc.print_center(Fonts::chalk_large, 
static_cast<float>(CL_Display::get_width()/2),
-                  static_cast<float>(CL_Display::get_height()/2 - 200), 
story.title);
+                  static_cast<float>(CL_Display::get_height()/2 - 200), 
story->get_title());
   gc.draw(page_surface, Vector(gc.get_width()/2, gc.get_height()/2 - 65));
   
   gc.print_left(Fonts::chalk_normal,
@@ -166,8 +170,8 @@
 void
 StoryScreen::on_startup()
 {
-  //PingusSound::play_sound ("letsgo");
-  Sound::PingusSound::play_music("pingus-4.it", .7f);
+       // FIXME: Load the song from the WorldMapStory
+  Sound::PingusSound::play_music(story_comp->get_story()->get_music(), .7f);
 }
 
 void
@@ -180,10 +184,10 @@
     }
   else
     {
-      story.pages.pop_back();
-      if (!story.pages.empty())
+      pages.pop_back();
+      if (!pages.empty())
         {
-          current_page = story.pages.back();
+          current_page = pages.back();
           page_surface = Resource::load_sprite(current_page.image);
           display_text = "";
           time_passed = 0;
@@ -191,9 +195,9 @@
         }
       else
         {
-          //std::cout << "StoryScreenComponent: Out of story pages" << 
std::endl;
+          //Out of story pages
           StatManager::instance()->set_bool("story-seen", true);
-          //ScreenManager::instance()->replace_screen 
(PingusMenuManager::instance (), false);
+          
           if (show_credits)
             ScreenManager::instance()->replace_screen(Credits::instance(), 
false);
           else

Modified: trunk/src/story_screen.hxx
===================================================================
--- trunk/src/story_screen.hxx  2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/story_screen.hxx  2005-12-08 00:18:36 UTC (rev 2546)
@@ -23,33 +23,21 @@
 #include <string>
 #include "res_descriptor.hxx"
 #include "gui/gui_screen.hxx"
+#include "worldmap/worldmap_story.hxx"
 
 namespace Pingus {
 
-class Story;
 class StoryScreenComponent;
 
-class StoryPage
-{
-public:
-  StoryPage() {}
+using namespace Pingus::WorldMapNS;
 
-  StoryPage(ResDescriptor arg_image, std::string arg_text)
-    : image(arg_image), text(arg_text)
-
-  {}
-
-  ResDescriptor image;
-  std::string   text;
-};
-
 /** */
 class StoryScreen : public GUIScreen
 {
 private:
   StoryScreenComponent* story_comp;
 public:
-  StoryScreen(const Story& pages);
+       StoryScreen(WorldMapStory *pages);
   ~StoryScreen();
 
   void on_startup();

Modified: trunk/src/worldmap/Makefile.am
===================================================================
--- trunk/src/worldmap/Makefile.am      2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/worldmap/Makefile.am      2005-12-08 00:18:36 UTC (rev 2546)
@@ -48,7 +48,9 @@
 surface_drawable.cxx \
 surface_drawable.hxx \
 worldmap.cxx \
-worldmap.hxx
+worldmap.hxx \
+worldmap_story.cxx \
+worlmap_story.hxx
 
 #node.cxx
 #node.hxx

Modified: trunk/src/worldmap/manager.cxx
===================================================================
--- trunk/src/worldmap/manager.cxx      2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/worldmap/manager.cxx      2005-12-08 00:18:36 UTC (rev 2546)
@@ -27,9 +27,9 @@
 #include "../sound/sound.hxx"
 #include "../stat_manager.hxx"
 #include "worldmap.hxx"
+#include "worldmap_story.hxx"
 #include "pingus.hxx"
 #include "manager.hxx"
-#include "../story.hxx"
 #include "../story_screen.hxx"
 
 namespace Pingus {
@@ -106,7 +106,8 @@
 void
 WorldMapManagerCreditsButton::on_click()
 {
-  ScreenManager::instance()->replace_screen(new StoryScreen(Story::credits), 
true);
+       ScreenManager::instance()->replace_screen(
+               new 
StoryScreen(WorldMapManager::instance()->get_worldmap()->get_end_story()), 
true);
 }
 
 WorldMapManagerStoryButton::WorldMapManagerStoryButton()
@@ -136,7 +137,8 @@
 void
 WorldMapManagerStoryButton::on_click()
 {
-  ScreenManager::instance()->replace_screen(new StoryScreen(Story::intro), 
true);
+  ScreenManager::instance()->replace_screen(
+               new 
StoryScreen(WorldMapNS::WorldMapManager::instance()->get_worldmap()->get_intro_story()),
 true);
 }
 
 WorldMapManagerCloseButton::WorldMapManagerCloseButton()

Modified: trunk/src/worldmap/worldmap.cxx
===================================================================
--- trunk/src/worldmap/worldmap.cxx     2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/worldmap/worldmap.cxx     2005-12-08 00:18:36 UTC (rev 2546)
@@ -31,11 +31,13 @@
 #include "../sound/sound.hxx"
 #include "../pingus_error.hxx"
 #include "../gettext.h"
-#include "pingus.hxx"
 #include "../globals.hxx"
 #include "../xml_file_reader.hxx"
 #include "../debug.hxx"
 #include "worldmap.hxx"
+#include "worldmap_story.hxx"
+#include "manager.hxx"
+#include "pingus.hxx"
 #include "drawable_factory.hxx"
 #include "drawable.hxx"
 #include "dot.hxx"
@@ -44,7 +46,6 @@
 #include "../math.hxx"
 #include "../stat_manager.hxx"
 
-#include "../story.hxx"
 #include "../story_screen.hxx"
 #include "../gui/screen_manager.hxx"
 
@@ -95,12 +96,8 @@
     {
       delete (*i);
     }
-//  for (ObjectLst::iterator j = objects.begin (); j != objects.end (); ++j)
-//    {
-//      delete (*j);
-//    }
-
-//  delete pingus;
+       delete intro_story;
+       delete end_story;
   delete path_graph;
 }
 
@@ -112,6 +109,8 @@
       parse_graph(reader.read_section("graph"));
       parse_objects(reader.read_section("objects"));
       parse_properties(reader.read_section("head"));
+                       intro_story = new 
WorldMapStory(reader.read_section("intro_story"));
+                       end_story = new 
WorldMapStory(reader.read_section("end_story"));
     }
   else
     {
@@ -403,7 +402,8 @@
         {
           if (dot->finished())
             {
-              ScreenManager::instance()->replace_screen(new 
StoryScreen(Story::credits), true);
+              ScreenManager::instance()->replace_screen(
+                                                               new 
StoryScreen(get_end_story()), true);
               StatManager::instance()->set_bool("credits-unlocked", true);
             }
         }

Modified: trunk/src/worldmap/worldmap.hxx
===================================================================
--- trunk/src/worldmap/worldmap.hxx     2005-12-07 03:52:07 UTC (rev 2545)
+++ trunk/src/worldmap/worldmap.hxx     2005-12-08 00:18:36 UTC (rev 2546)
@@ -39,6 +39,7 @@
 typedef int EdgeId;
 typedef int NodeId;
 
+class WorldMapStory;
 class PathGraph;
 class Drawable;
 class Pingus;
@@ -56,6 +57,9 @@
   /** 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;
 
@@ -91,6 +95,8 @@
   ~WorldMap();
 
   Pingus* get_pingus() { return pingus; }
+       WorldMapStory* get_intro_story() const { return intro_story; }
+       WorldMapStory* get_end_story() const { return end_story; }
 
   void on_startup();
 
@@ -114,13 +120,8 @@
   void on_primary_button_press(int x, int y);
   void on_secondary_button_press(int x, int y);
   void on_pointer_move(int x, int y);
+
 private:
-#if 0
-  /** @return the node at the given position. x and y are in
-      world-COs, not screen. */
-  NodeId get_node (int x, int y);
-#endif
-
   /** Parses a WorldMap XML file */
   void parse_file(FileReader reader);
 

Added: trunk/src/worldmap/worldmap_story.cxx
===================================================================
--- trunk/src/worldmap/worldmap_story.cxx       2005-12-07 03:52:07 UTC (rev 
2545)
+++ trunk/src/worldmap/worldmap_story.cxx       2005-12-08 00:18:36 UTC (rev 
2546)
@@ -0,0 +1,72 @@
+//  $Id: worldmap_story.cxx,v 1.32 2005/12/06 00:30:04 Jave27 Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2005 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 2
+//  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, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#include <algorithm>
+#include <vector>
+#include "worldmap_story.hxx"
+#include "../story_screen.hxx"
+#include "../file_reader.hxx"
+#include "../res_descriptor.hxx"
+#include "../pingus_error.hxx"
+#include "../string_format.hxx"
+#include "../fonts.hxx"
+#include "../gettext.h"
+
+namespace Pingus {
+namespace WorldMapNS {
+
+       bool StoryPageCompare(const StoryPage& a, const StoryPage& b)
+       {
+               // Reverse the sort order since we pull the page off the back
+               return (a.page_name > b.page_name);
+       }
+
+       WorldMapStory::WorldMapStory(const FileReader &reader)
+       {
+               reader.read_string("title", title);
+               reader.read_string("music", music);
+               FileReader all_pages = reader.read_section("pages");
+
+               // Temporary objects
+               ResDescriptor desc;
+               std::string text;
+               std::string page_name;
+               
+               // Read each page into the pages vector
+               const std::vector<FileReader>& childs = 
all_pages.get_sections();
+       for(std::vector<FileReader>::const_iterator i = childs.begin(); 
+      i != childs.end(); ++i)
+               {
+                       page_name = i->get_name();
+                       i->read_desc("surface", desc);
+                       i->read_string("text", text);
+                       // Translate the text and break it up.
+                       text = StringFormat::break_line(_(text), 570, 
Fonts::chalk_normal);
+                       pages.push_back(StoryPage(desc, text, page_name));
+               }
+               std::stable_sort(pages.begin(), pages.end(), &StoryPageCompare);
+
+               if (pages.empty())
+                       PingusError::raise("WorldMapStory: WorldMap does not 
include a valid story");
+       }
+
+}      // namespace WorldMapNS
+}      // namespace Pingus
+
+/* EOF */


Property changes on: trunk/src/worldmap/worldmap_story.cxx
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/src/worldmap/worldmap_story.hxx
===================================================================
--- trunk/src/worldmap/worldmap_story.hxx       2005-12-07 03:52:07 UTC (rev 
2545)
+++ trunk/src/worldmap/worldmap_story.hxx       2005-12-08 00:18:36 UTC (rev 
2546)
@@ -0,0 +1,71 @@
+//  $Id: worldmap_story.hxx,v 1.32 2005/12/06 00:30:04 Jave27 Exp $
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2005 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 2
+//  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, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#ifndef HEADER_PINGUS_WORLDMAP_STORY_HXX
+#define HEADER_PINGUS_WORLDMAP_STORY_HXX
+
+#include <vector>
+#include <string>
+#include "../res_descriptor.hxx"
+
+namespace Pingus {
+       
+       class FileReader;
+
+       class StoryPage
+       {
+       public:
+               StoryPage() {}
+
+               StoryPage(ResDescriptor arg_image, std::string arg_text, 
std::string arg_name = "")
+                       : image(arg_image), text(arg_text), page_name(arg_name)
+               {
+               
+               }
+
+               ResDescriptor image;
+               std::string   text;
+               std::string             page_name;
+       };
+
+namespace WorldMapNS {
+
+       class WorldMapStory
+       {
+       public:
+               WorldMapStory(const FileReader &reader);
+               ~WorldMapStory() { }
+
+               std::string get_title() const { return title; }
+               std::string get_music() const { return music; }
+               std::vector<StoryPage> get_pages() const { return pages; }
+
+       private:
+               std::string title;
+               std::string music;
+               std::vector<StoryPage> pages;
+
+       };      // class WorldMapStory
+
+}      // namespace WorldmapNS
+} // namespace Pingus
+
+#endif
+
+/*EOF*/


Property changes on: trunk/src/worldmap/worldmap_story.hxx
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

[Prev in Thread] Current Thread [Next in Thread]