#include <sstream>
#include "gui/menu_manager.hpp"
+#include "lisp/lisp.hpp"
+#include "lisp/parser.hpp"
#include "supertux/game_session.hpp"
#include "supertux/gameconfig.hpp"
#include "supertux/globals.hpp"
}
}
+std::string
+GameManager::get_level_name(const std::string& filename) const
+{
+ try
+ {
+ lisp::Parser parser;
+ const lisp::Lisp* root = parser.parse(filename);
+
+ const lisp::Lisp* level = root->get_lisp("supertux-level");
+ if(!level)
+ return "";
+
+ std::string name;
+ level->get("name", name);
+ return name;
+ }
+ catch(const std::exception& e)
+ {
+ log_warning << "Problem getting name of '" << filename << "': "
+ << e.what() << std::endl;
+ return "";
+ }
+}
+
/* EOF */
void start_game(std::unique_ptr<World> world);
void start_level(std::unique_ptr<World> world, int index);
+ std::string get_level_name(const std::string& levelfile) const;
+
private:
GameManager(const GameManager&) = delete;
GameManager& operator=(const GameManager&) = delete;
add_label(m_world->get_title());
add_hl();
- for (unsigned int i = 0; i < m_world->get_num_levels(); ++i)
+ for (int i = 0; i < m_world->get_num_levels(); ++i)
{
/** get level's title */
std::string filename = m_world->get_level_filename(i);
- std::string title = TitleScreen::get_level_name(filename);
+ std::string title = GameManager::current()->get_level_name(filename);
add_entry(i, title);
}
);
}
-std::string
-TitleScreen::get_level_name(const std::string& filename)
-{
- try {
- lisp::Parser parser;
- const lisp::Lisp* root = parser.parse(filename);
-
- const lisp::Lisp* level = root->get_lisp("supertux-level");
- if(!level)
- return "";
-
- std::string name;
- level->get("name", name);
- return name;
- } catch(std::exception& e) {
- log_warning << "Problem getting name of '" << filename << "': "
- << e.what() << std::endl;
- return "";
- }
-}
-
void
TitleScreen::make_tux_jump()
{
class TitleScreen : public Screen
{
public:
- static std::string get_level_name(const std::string& levelfile);
-
-public:
TitleScreen(PlayerStatus* player_status);
virtual ~TitleScreen();