[Supertux-Commit] r5409 - trunk/supertux/src

grumbel at millhouse.dreamhost.com grumbel at millhouse.dreamhost.com
Mon May 5 06:34:02 PDT 2008


Author: grumbel
Date: 2008-05-05 06:34:01 -0700 (Mon, 05 May 2008)
New Revision: 5409

Modified:
   trunk/supertux/src/gameconfig.cpp
   trunk/supertux/src/gameconfig.hpp
   trunk/supertux/src/profile_menu.cpp
   trunk/supertux/src/title.cpp
Log:
Some more Profile code, they now basically work (to preserve your saves copy them from ~/.supertux2/save/ to ~/.supertux2/profile1/)

Modified: trunk/supertux/src/gameconfig.cpp
===================================================================
--- trunk/supertux/src/gameconfig.cpp	2008-05-05 12:56:36 UTC (rev 5408)
+++ trunk/supertux/src/gameconfig.cpp	2008-05-05 13:34:01 UTC (rev 5409)
@@ -35,6 +35,7 @@
 
 Config::Config()
 {
+  profile = 1;
   use_fullscreen = false;
   video = AUTO_VIDEO;
   try_vsync = true;

Modified: trunk/supertux/src/gameconfig.hpp
===================================================================
--- trunk/supertux/src/gameconfig.hpp	2008-05-05 12:56:36 UTC (rev 5408)
+++ trunk/supertux/src/gameconfig.hpp	2008-05-05 13:34:01 UTC (rev 5409)
@@ -34,6 +34,8 @@
   void load();
   void save();
 
+  int profile;
+
   /** screen width in pixel (warning: this is the real screen width+height,
    * you should use the logical SCREEN_WIDTH and SCREEN_HEIGHT for your
    * rendering code.)

Modified: trunk/supertux/src/profile_menu.cpp
===================================================================
--- trunk/supertux/src/profile_menu.cpp	2008-05-05 12:56:36 UTC (rev 5408)
+++ trunk/supertux/src/profile_menu.cpp	2008-05-05 13:34:01 UTC (rev 5409)
@@ -16,6 +16,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <sstream>
+#include "gameconfig.hpp"
 #include "gettext.hpp"
 #include "gui/menu.hpp"
 
@@ -33,13 +34,17 @@
       {
         std::ostringstream out;
         out << "Profile " << i+1;
-        add_entry(i, out.str());
+        add_entry(i+1, out.str());
       }
 
     add_hl();
     add_back(_("Back"));
   }
- 
+
+  void menu_action(MenuItem* item) {
+    config->profile = item->id;
+    Menu::set_current(0);
+  }
 };
 
 Menu* profile_menu = 0;

Modified: trunk/supertux/src/title.cpp
===================================================================
--- trunk/supertux/src/title.cpp	2008-05-05 12:56:36 UTC (rev 5408)
+++ trunk/supertux/src/title.cpp	2008-05-05 13:34:01 UTC (rev 5409)
@@ -34,6 +34,7 @@
 #include <physfs.h>
 #include <algorithm>
 
+#include "gameconfig.hpp"
 #include "title.hpp"
 #include "mainloop.hpp"
 #include "video/drawing_context.hpp"
@@ -494,7 +495,7 @@
         std::string str = _("Are you sure you want to delete slot") + stream.str() + "?";
 
         if(confirm_dialog(bkg_title, str.c_str())) {
-          str = "save/slot" + stream.str() + ".stsg";
+          str = "profile1/slot" + stream.str() + ".stsg";
           log_debug << "Removing: " << str << std::endl;
           PHYSFS_delete(str.c_str());
         }
@@ -530,7 +531,7 @@
   basename = basename.substr(0, basename.length()-1);
   std::string worlddirname = FileSystem::basename(basename);
   std::ostringstream stream;
-  stream << "save/" << worlddirname << "_" << slot << ".stsg";
+  stream << "profile" << config->profile << "/" << worlddirname << "_" << slot << ".stsg";
   std::string slotfile = stream.str();
 
   try {
@@ -567,8 +568,8 @@
   std::string basename = current_world->get_basedir();
   basename = basename.substr(0, basename.length()-1);
   std::string worlddirname = FileSystem::basename(basename);
-  std::stringstream stream;
-  stream << "save/" << worlddirname << "_" << slot << ".stsg";
+  std::ostringstream stream;
+  stream << "profile" << config->profile << "/" << worlddirname << "_" << slot << ".stsg";
   std::string slotfile = stream.str();
 
   try {




More information about the Supertux-Commit mailing list