From 44a22ced3db79b25504d506e74e4e31d63446f1a Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Mon, 5 May 2008 13:34:01 +0000 Subject: [PATCH] Some more Profile code, they now basically work (to preserve your saves copy them from ~/.supertux2/save/ to ~/.supertux2/profile1/) SVN-Revision: 5409 --- src/gameconfig.cpp | 1 + src/gameconfig.hpp | 2 ++ src/profile_menu.cpp | 9 +++++++-- src/title.cpp | 9 +++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gameconfig.cpp b/src/gameconfig.cpp index 2b8929ec6..38250118c 100644 --- a/src/gameconfig.cpp +++ b/src/gameconfig.cpp @@ -35,6 +35,7 @@ Config* config = 0; Config::Config() { + profile = 1; use_fullscreen = false; video = AUTO_VIDEO; try_vsync = true; diff --git a/src/gameconfig.hpp b/src/gameconfig.hpp index ac45730c7..bfd5ab956 100644 --- a/src/gameconfig.hpp +++ b/src/gameconfig.hpp @@ -34,6 +34,8 @@ public: 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.) diff --git a/src/profile_menu.cpp b/src/profile_menu.cpp index d7f93c21d..70d840262 100644 --- a/src/profile_menu.cpp +++ b/src/profile_menu.cpp @@ -16,6 +16,7 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include +#include "gameconfig.hpp" #include "gettext.hpp" #include "gui/menu.hpp" @@ -33,13 +34,17 @@ public: { 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; diff --git a/src/title.cpp b/src/title.cpp index 6c0c09545..8609a4d32 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -34,6 +34,7 @@ #include #include +#include "gameconfig.hpp" #include "title.hpp" #include "mainloop.hpp" #include "video/drawing_context.hpp" @@ -494,7 +495,7 @@ TitleScreen::update(float elapsed_time) 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 @@ TitleScreen::get_slotinfo(int slot) 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 @@ TitleScreen::process_load_game_menu() 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 { -- 2.11.0