pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3334 - trunk/pingus/src


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3334 - trunk/pingus/src
Date: Sat, 27 Oct 2007 06:53:12 +0200

Author: grumbel
Date: 2007-10-27 06:53:11 +0200 (Sat, 27 Oct 2007)
New Revision: 3334

Modified:
   trunk/pingus/src/level_menu.cpp
   trunk/pingus/src/level_menu.hpp
   trunk/pingus/src/levelset.cpp
   trunk/pingus/src/levelset.hpp
   trunk/pingus/src/pingus_menu.cpp
Log:
- some levelset stuff

Modified: trunk/pingus/src/level_menu.cpp
===================================================================
--- trunk/pingus/src/level_menu.cpp     2007-10-27 04:52:21 UTC (rev 3333)
+++ trunk/pingus/src/level_menu.cpp     2007-10-27 04:53:11 UTC (rev 3334)
@@ -26,36 +26,21 @@
 #include "option_menu.hpp"
 #include "level_menu.hpp"
 
-
 LevelMenu::LevelMenu()
 {
   background = Resource::load_sprite("core/menu/filedialog");
   ok_button  = Resource::load_sprite("core/start/ok");
   marker     = Resource::load_sprite("core/menu/marker");
 
-  levelsets.push_back(LevelsetEntry("Desert Set 1",
-                                    "20 Levels in a desert setting of easy 
difficulty\n"
-                                    "Author: John Foo <address@hidden>",
-                                    78, 20));
-
-  levelsets.push_back(LevelsetEntry("Random Set 2",
-                                    "10 Levels in a random setting of easy 
difficulty\n"
-                                    "Author: John Foo <address@hidden>",
-                                    48, 10));
-
-  levelsets.push_back(LevelsetEntry("Unsorted Levels",
-                                    "Levels that aren't group in any 
levelset\n"
-                                    "Created by lots of random people",
-                                    48, 10));
-
-  levelsets.push_back(LevelsetEntry("User Created Levels",
-                                    "Levels created by you\n"
-                                    "Use the editor to create them if you 
haven't already",
-                                    48, 10));
+  levelsets.push_back(new Levelset(Pathname("levelsets/halloween.levelset", 
Pathname::DATA_PATH)));
 }
 
 LevelMenu::~LevelMenu()
 {
+  for(Levelsets::iterator i = levelsets.begin(); i != levelsets.end(); ++i)
+    {
+      delete *i;
+    }
 }
 
 void
@@ -76,11 +61,11 @@
   int y = 145;
   for(Levelsets::iterator i = levelsets.begin(); i != levelsets.end(); ++i)
     {
-      gc.print_left(Fonts::chalk_normal, 120,  0 + y, i->title);
-      gc.print_left(Fonts::chalk_small,  140, 25 + y, i->description);
+      gc.print_left(Fonts::chalk_normal, 120,  0 + y, (*i)->get_title());
+      gc.print_left(Fonts::chalk_small,  140, 25 + y, (*i)->get_description());
 
-      gc.print_right(Fonts::chalk_normal, 650, 0 + y, 
(boost::format("Completion: %1%%%") % i->completion).str());
-      gc.print_right(Fonts::chalk_small, 650, 45 + y, (boost::format("%1% 
levels") % i->number_of_levels).str());
+      gc.print_right(Fonts::chalk_normal, 650, 0 + y, 
(boost::format("Completion: %1%%%") % (*i)->get_completion()).str());
+      gc.print_right(Fonts::chalk_small, 650, 45 + y, (boost::format("%1% 
levels") % (*i)->get_level_count()).str());
 
       y += 90;
     }
@@ -89,6 +74,12 @@
 }
 
 void
+LevelMenu::on_pointer_move (int x, int y)
+{
+  
+}
+
+void
 LevelMenu::on_escape_press()
 {
   std::cout << "OptionMenu: poping screen" << std::endl;

Modified: trunk/pingus/src/level_menu.hpp
===================================================================
--- trunk/pingus/src/level_menu.hpp     2007-10-27 04:52:21 UTC (rev 3333)
+++ trunk/pingus/src/level_menu.hpp     2007-10-27 04:53:11 UTC (rev 3334)
@@ -20,6 +20,7 @@
 #ifndef HEADER_LEVEL_MENU_HPP
 #define HEADER_LEVEL_MENU_HPP
 
+#include "levelset.hpp"
 #include "sprite.hpp"
 #include "screen/gui_screen.hpp"
 
@@ -31,26 +32,7 @@
   Sprite ok_button;
   Sprite marker;
 
-  struct LevelsetEntry
-  {
-    std::string title;
-    std::string description;
-
-    int completion;
-    int number_of_levels;
-
-    LevelsetEntry(const std::string& title,
-                  const std::string& description,
-                  int completion,
-                  int number_of_levels)
-      : title(title),
-        description(description),
-        completion(completion),
-        number_of_levels(number_of_levels)
-    {}
-  };
-
-  typedef std::vector<LevelsetEntry> Levelsets;
+  typedef std::vector<Levelset*> Levelsets;
   Levelsets levelsets;
 
 public:
@@ -60,6 +42,7 @@
   void draw_background (DrawingContext& gc);
   void update (const GameDelta& delta);
   void on_escape_press ();
+  void on_pointer_move (int x, int y);
 
 private:
   LevelMenu (const LevelMenu&);

Modified: trunk/pingus/src/levelset.cpp
===================================================================
--- trunk/pingus/src/levelset.cpp       2007-10-27 04:52:21 UTC (rev 3333)
+++ trunk/pingus/src/levelset.cpp       2007-10-27 04:53:11 UTC (rev 3334)
@@ -39,10 +39,13 @@
         {
           if (i->get_name() == "level")
             {
-              std::string filename;
-              if (i->read_string("filename", filename))
+              Level level;
+              level.accessible = false;
+              level.finished   = false;
+
+              if (i->read_string("filename", level.filename))
                 {
-                  levels.push_back(filename);
+                  levels.push_back(level);
                 }
               else
                 {
@@ -51,6 +54,9 @@
             }
         }
     }
+
+  if (!levels.empty())
+    levels.front().accessible = true;
 }
 
 Levelset::~Levelset()
@@ -72,8 +78,8 @@
 std::string
 Levelset::get_level(int num) const
 {
-  if (num >= 0 && num < static_cast<int>(levels.size()))
-    return levels[num];
+  if (num >= 0 && num < int(levels.size()))
+    return levels[num].filename;
   else
     return "";
 }
@@ -84,4 +90,11 @@
   return levels.size();
 }
 
+int
+Levelset::get_completion()  const
+{
+  // FIXME: insert savegame magic
+  return 0;
+}
+
 /* EOF */

Modified: trunk/pingus/src/levelset.hpp
===================================================================
--- trunk/pingus/src/levelset.hpp       2007-10-27 04:52:21 UTC (rev 3333)
+++ trunk/pingus/src/levelset.hpp       2007-10-27 04:53:11 UTC (rev 3334)
@@ -28,9 +28,15 @@
 class Levelset
 {
 private:
+  struct Level {
+    std::string filename;
+    bool accessible;
+    bool finished;
+  };
+
   std::string title;
   std::string description;
-  std::vector<std::string> levels;
+  std::vector<Level> levels;
 
 public:
   Levelset(const Pathname& pathname);
@@ -41,6 +47,9 @@
   std::string get_level(int num) const;
   int get_level_count() const;
 
+  /** Return the number of completed levels */
+  int get_completion()  const;
+
 private:
   Levelset (const Levelset&);
   Levelset& operator= (const Levelset&);

Modified: trunk/pingus/src/pingus_menu.cpp
===================================================================
--- trunk/pingus/src/pingus_menu.cpp    2007-10-27 04:52:21 UTC (rev 3333)
+++ trunk/pingus/src/pingus_menu.cpp    2007-10-27 04:53:11 UTC (rev 3334)
@@ -24,6 +24,7 @@
 #include "debug.hpp"
 #include "globals.hpp"
 #include "sound/sound.hpp"
+#include "level_menu.hpp"
 #include "stat_manager.hpp"
 #include "start_screen.hpp"
 #include "story_screen.hpp"
@@ -161,8 +162,8 @@
   delete start_button;
   delete quit_button;
   delete editor_button;
+  delete contrib_button;
 #ifdef NEW_MENU
-  delete contrib_button;
   delete story_button;
   delete multiplayer_button;
 #endif
@@ -171,7 +172,7 @@
 void
 PingusMenu::do_quit()
 {
-  get_manager ()->show_exit_menu ();
+  get_manager()->show_exit_menu ();
 }
 
 void
@@ -290,11 +291,11 @@
     {
       do_edit();
     }
-#ifdef NEW_MENU
   else if (button == contrib_button)
     {
-      setup_contrib_menu();
+      ScreenManager::instance()->push_screen(new LevelMenu(), true);
     }
+#ifdef NEW_MENU
   else if (button == story_button)
     {
       setup_worldmap_menu();





reply via email to

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