}
#endif
-AddonManager&
-AddonManager::get_instance()
-{
- static AddonManager instance;
- return instance;
-}
-
AddonManager::AddonManager() :
addons(),
ignored_addon_filenames()
#include <string>
#include <vector>
+#include "util/currenton.hpp"
#include "util/reader_fwd.hpp"
#include "util/writer_fwd.hpp"
/**
* Checks for, installs and removes Add-ons
*/
-class AddonManager
+class AddonManager : public Currenton<AddonManager>
{
public:
+ AddonManager();
+ ~AddonManager();
+
/**
* returns a list of installed Add-ons
*/
void load_addons();
/**
- * Returns the shared AddonManager instance
- */
- static AddonManager& get_instance();
-
- /**
* Write AddonManager configuration to Lisp
*/
void write(Writer& writer);
*/
void read(const Reader& lisp);
-protected:
+private:
std::vector<Addon*> addons;
std::vector<std::string> ignored_addon_filenames;
-
- AddonManager();
- ~AddonManager();
};
#endif
sound_enabled(true),
music_enabled(true),
console_enabled(false),
- random_seed(0), // set by time(), by default (unless in config)
+ random_seed(0), // set by time(), by default (unless in config)
start_level(),
enable_script_debugger(false),
start_demo(),
const lisp::Lisp* config_lisp = root->get_lisp("supertux-config");
if(!config_lisp)
+ {
throw std::runtime_error("File is not a supertux-config file");
+ }
config_lisp->get("profile", profile);
config_lisp->get("show_fps", show_fps);
config_lisp->get("random_seed", random_seed);
const lisp::Lisp* config_video_lisp = config_lisp->get_lisp("video");
- if(config_video_lisp) {
+ if(config_video_lisp)
+ {
config_video_lisp->get("fullscreen", use_fullscreen);
std::string video_string;
config_video_lisp->get("video", video_string);
}
const lisp::Lisp* config_control_lisp = config_lisp->get_lisp("control");
- if(config_control_lisp && InputManager::current()) {
+ if(config_control_lisp && InputManager::current())
+ {
InputManager::current()->read(*config_control_lisp);
}
const lisp::Lisp* config_addons_lisp = config_lisp->get_lisp("addons");
- if(config_addons_lisp) {
- AddonManager::get_instance().read(*config_addons_lisp);
+ if(config_addons_lisp && AddonManager::current())
+ {
+ AddonManager::current()->read(*config_addons_lisp);
}
}
writer.write("music_enabled", music_enabled);
writer.end_list("audio");
- if(InputManager::current()) {
+ if (InputManager::current())
+ {
writer.start_list("control");
InputManager::current()->write(writer);
writer.end_list("control");
}
- writer.start_list("addons");
- AddonManager::get_instance().write(writer);
- writer.end_list("addons");
+ if (AddonManager::current())
+ {
+ writer.start_list("addons");
+ AddonManager::current()->write(writer);
+ writer.end_list("addons");
+ }
writer.end_list("supertux-config");
}
int profile;
- // the width/height to be used to display the game in fullscreen
+ /** the width/height to be used to display the game in fullscreen */
Size fullscreen_size;
- // refresh rate for use in fullscreen, 0 for auto
+ /** refresh rate for use in fullscreen, 0 for auto */
int fullscreen_refresh_rate;
/** the width/height of the window managers window */
bool music_enabled;
bool console_enabled;
- int random_seed; // initial random seed. 0 ==> set from time()
+ /** initial random seed. 0 ==> set from time() */
+ int random_seed;
/** this variable is set if supertux should start in a specific level */
std::string start_level;
std::string start_demo;
std::string record_demo;
- std::string locale; /**< force SuperTux language to this locale, e.g. "de". A file "data/locale/xx.po" must exist for this to work. An empty string means autodetect. */
+ /** force SuperTux language to this locale, e.g. "de". A file
+ "data/locale/xx.po" must exist for this to work. An empty string
+ means autodetect. */
+ std::string locale;
};
#endif
Resources resources;
timelog("addons");
- AddonManager::get_instance().load_addons();
+ AddonManager addon_manager;
+ addon_manager.load_addons();
timelog(0);
{
clear();
- AddonManager& adm = AddonManager::get_instance();
+ AddonManager& adm = *AddonManager::current();
// refresh list of addons
m_addons = adm.get_addons();
{
try
{
- AddonManager::get_instance().check_online();
+ AddonManager::current()->check_online();
refresh();
set_active_item(index);
}
{
try
{
- AddonManager::get_instance().install(&addon);
+ AddonManager::current()->install(&addon);
}
catch (std::exception& e)
{
{
try
{
- AddonManager::get_instance().enable(&addon);
+ AddonManager::current()->enable(&addon);
}
catch (std::exception& e)
{
{
try
{
- AddonManager::get_instance().disable(&addon);
+ AddonManager::current()->disable(&addon);
}
catch (std::exception& e)
{