} // namespace
AddonManager::AddonManager(const std::string& addon_directory,
- std::vector<std::string>& ignored_addon_ids) :
+ std::vector<Config::Addon>& addon_config) :
m_downloader(),
m_addon_directory(addon_directory),
//m_repository_url("http://addons.supertux.googlecode.com/git/index-0_3_5.nfo"),
m_repository_url("http://localhost:8000/index-0_4_0.nfo"),
- m_ignored_addon_ids(ignored_addon_ids),
+ m_addon_config(addon_config),
m_installed_addons(),
m_repository_addons(),
m_has_been_updated(false)
PHYSFS_mkdir(m_addon_directory.c_str());
add_installed_addons();
- for(auto& addon : m_installed_addons)
+
+ // FIXME: We should also restore the order here
+ for(auto& addon : m_addon_config)
{
- if (std::find(m_ignored_addon_ids.begin(), m_ignored_addon_ids.end(),
- addon->get_id()) != m_ignored_addon_ids.end())
+ if (addon.enabled)
{
- enable_addon(addon->get_id());
+ enable_addon(addon.id);
}
}
}
AddonManager::~AddonManager()
{
+ // sync enabled/disabled addons into the config for saving
+ m_addon_config.clear();
+ for(auto& addon : m_installed_addons)
+ {
+ m_addon_config.push_back({addon->get_id(), addon->is_enabled()});
+ }
}
Addon&
#include <vector>
#include "addon/downloader.hpp"
+#include "supertux/gameconfig.hpp"
#include "util/currenton.hpp"
#include "util/reader_fwd.hpp"
#include "util/writer_fwd.hpp"
Downloader m_downloader;
std::string m_addon_directory;
std::string m_repository_url;
- std::vector<std::string>& m_ignored_addon_ids;
+ std::vector<Config::Addon>& m_addon_config;
AddonList m_installed_addons;
AddonList m_repository_addons;
public:
AddonManager(const std::string& addon_directory,
- std::vector<std::string>& enabled_addons_);
+ std::vector<Config::Addon>& addon_config);
~AddonManager();
bool has_online_support() const;
#include "addon/addon_manager.hpp"
#include "control/input_manager.hpp"
#include "lisp/writer.hpp"
+#include "lisp/list_iterator.hpp"
#include "lisp/parser.hpp"
#include "util/reader.hpp"
+#include "util/log.hpp"
#include "supertux/globals.hpp"
Config::Config() :
locale(),
keyboard_config(),
joystick_config(),
- disabled_addon_filenames(),
+ addons(),
developer_mode(false)
{
}
const lisp::Lisp* config_addons_lisp = config_lisp->get_lisp("addons");
if (config_addons_lisp)
{
- config_addons_lisp->get("disabled-addons", disabled_addon_filenames);
+ lisp::ListIterator iter(config_addons_lisp);
+ while(iter.next())
+ {
+ const std::string& token = iter.item();
+ if (token == "addon")
+ {
+ std::string id;
+ bool enabled = false;
+ if (iter.lisp()->get("id", id) &&
+ iter.lisp()->get("enabled", enabled))
+ {
+ addons.push_back({id, enabled});
+ }
+ }
+ else
+ {
+ log_warning << "Unknown token in config file: " << token << std::endl;
+ }
+ }
}
}
writer.end_list("control");
writer.start_list("addons");
- writer.write("disabled-addons", disabled_addon_filenames);
+ for(auto addon : addons)
+ {
+ writer.start_list("addon");
+ writer.write("id", addon.id);
+ writer.write("enabled", addon.enabled);
+ writer.end_list("addon");
+ }
writer.end_list("addons");
writer.end_list("supertux-config");
KeyboardConfig keyboard_config;
JoystickConfig joystick_config;
- std::vector<std::string> disabled_addon_filenames;
+ struct Addon
+ {
+ std::string id;
+ bool enabled;
+ };
+ std::vector<Addon> addons;
bool developer_mode;
};
Resources resources;
timelog("addons");
- AddonManager addon_manager("addons", g_config->disabled_addon_filenames);
+ AddonManager addon_manager("addons", g_config->addons);
timelog(0);