// SuperTux
-// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
//
// 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
#include "supertux/menu/contrib_menu.hpp"
#include <physfs.h>
+#include <sstream>
#include "gui/menu_manager.hpp"
+#include "supertux/game_manager.hpp"
+#include "supertux/gameconfig.hpp"
#include "supertux/menu/contrib_world_menu.hpp"
#include "supertux/menu/menu_storage.hpp"
#include "supertux/title_screen.hpp"
#include "supertux/world.hpp"
+#include "util/file_system.hpp"
#include "util/gettext.hpp"
ContribMenu::ContribMenu() :
{
try
{
- std::unique_ptr<World> world (new World());
- world->load(*it + "/info");
- if (!world->hide_from_contribs)
+ std::unique_ptr<World> world = World::load(*it);
+
+ if (!world->hide_from_contribs())
{
- add_entry(i++, world->get_title());
+ world->load_state();
+
+ std::ostringstream title;
+ title << world->get_title() << " (" << world->get_num_solved_levels() << "/" << world->get_num_levels() << ")";
+ add_entry(i++, title.str());
m_contrib_worlds.push_back(std::move(world));
}
}
add_hl();
add_back(_("Back"));
-
- std::cout << "ContribMenu" << std::endl;
}
ContribMenu::~ContribMenu()
{
- std::cout << "~ContribMenu" << std::endl;
}
void
if (index != -1)
{
World* world = m_contrib_worlds[index].get();
-
- if (!world->is_levelset)
+ if (!world->is_levelset())
{
- TitleScreen::start_game(world);
+ // FIXME: not the most elegant of solutions to std::move() the
+ // World, but the ContribMenu should get destructed after this,
+ // so it might be ok
+ GameManager::current()->start_game(std::move(m_contrib_worlds[index]));
}
- else
+ else
{
- MenuManager::instance().push_menu(std::unique_ptr<Menu>(new ContribWorldMenu(*world)));
+ MenuManager::instance().push_menu(std::unique_ptr<Menu>(new ContribWorldMenu(std::move(m_contrib_worlds[index]))));
}
}
}