world->load(*it + "/info");
if (!world->hide_from_contribs)
{
- add_entry(i++, world->title);
+ add_entry(i++, world->get_title());
m_contrib_worlds.push_back(world.release());
}
}
ContribWorldMenu::ContribWorldMenu(const World& current_world) :
m_current_world(current_world)
{
- add_label(m_current_world.title);
+ add_label(m_current_world.get_title());
add_hl();
for (unsigned int i = 0; i < m_current_world.get_num_levels(); ++i)
#include "supertux/world.hpp"
#include "util/file_system.hpp"
#include "util/reader.hpp"
+#include "util/string_util.hpp"
#include "worldmap/worldmap.hpp"
-static bool has_suffix(const std::string& data, const std::string& suffix)
-{
- if (data.length() >= suffix.length())
- return data.compare(data.length() - suffix.length(), suffix.length(), suffix) == 0;
- else
- return false;
-}
-
World* World::current_ = NULL;
World::World() :
}
for(const char* const* filename = files; *filename != 0; ++filename) {
- if(has_suffix(*filename, ".stl")) {
+ if(StringUtil::has_suffix(*filename, ".stl")) {
levels.push_back(path + *filename);
}
}
return basedir;
}
+const std::string&
+World::get_title() const
+{
+ return title;
+}
+
/* EOF */
class World
{
public:
+ static World* current()
+ {
+ return current_;
+ }
+
+private:
+ static World* current_;
+
+public:
World();
~World();
void save_state();
void load_state();
- const std::string& get_level_filename(unsigned int i) const;
unsigned int get_num_levels() const;
+ const std::string& get_level_filename(unsigned int i) const;
const std::string& get_basedir() const;
-
- static World* current()
- {
- return current_;
- }
+ const std::string& get_title() const;
void run();
/// squirrel table that saves persistent state (about the world)
HSQOBJECT state_table;
HSQOBJECT world_thread;
- static World* current_;
-
-public:
std::string title;
std::string description;
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "string_util.hpp"
+
+bool
+StringUtil::has_suffix(const std::string& data, const std::string& suffix)
+{
+ if (data.length() >= suffix.length())
+ {
+ return data.compare(data.length() - suffix.length(), suffix.length(), suffix) == 0;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+/* EOF */
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_UTIL_STRING_UTIL_HPP
+#define HEADER_SUPERTUX_UTIL_STRING_UTIL_HPP
+
+#include <string>
+
+class StringUtil
+{
+public:
+ static bool has_suffix(const std::string& data, const std::string& suffix);
+};
+
+#endif
+
+/* EOF */