Fill the savegame with all levels from a levelset on start, so the ContribMenu shows...
authorIngo Ruhnke <grumbel@gmail.com>
Thu, 14 Aug 2014 03:19:46 +0000 (05:19 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Thu, 14 Aug 2014 03:19:46 +0000 (05:19 +0200)
src/supertux/levelset_screen.cpp
src/supertux/savegame.cpp

index 0aec48a..9ce906c 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "supertux/game_session.hpp"
 #include "supertux/globals.hpp"
+#include "supertux/levelset.hpp"
 #include "supertux/savegame.hpp"
 #include "supertux/screen_fade.hpp"
 #include "supertux/screen_manager.hpp"
@@ -31,6 +32,13 @@ LevelsetScreen::LevelsetScreen(const std::string& basedir, const std::string& le
   m_level_started(false),
   m_solved(false)
 {
+  Levelset levelset(basedir);
+  for(int i = 0; i < levelset.get_num_levels(); ++i)
+  {
+    std::string lev = levelset.get_level_filename(i);
+    m_savegame.set_levelset_state(m_basedir, lev, false);
+  }
+
   LevelsetState state = m_savegame.get_levelset_state(basedir);
   LevelState level_state = state.get_level_state(level_filename);
   m_solved = level_state.solved;
index c7a7330..4119a2d 100644 (file)
@@ -466,7 +466,9 @@ Savegame::set_levelset_state(const std::string& basedir,
     get_or_create_table_entry(vm, "levels");
     get_or_create_table_entry(vm, level_filename);
 
-    scripting::store_bool(vm, "solved", solved);
+    bool old_solved = false;
+    scripting::get_bool(vm, "solved", old_solved);
+    scripting::store_bool(vm, "solved", solved || old_solved);
   }
   catch(const std::exception& err)
   {