remove old bindings format support
This commit is contained in:
@@ -116,14 +116,6 @@ void Engine::loadControls() {
|
|||||||
logger.info() << "loading controls";
|
logger.info() << "loading controls";
|
||||||
std::string text = files::read_string(controls_file);
|
std::string text = files::read_string(controls_file);
|
||||||
Events::loadBindings(controls_file.u8string(), text);
|
Events::loadBindings(controls_file.u8string(), text);
|
||||||
} else {
|
|
||||||
controls_file = paths->getControlsFileOld();
|
|
||||||
if (fs::is_regular_file(controls_file)) {
|
|
||||||
logger.info() << "loading controls (old)";
|
|
||||||
std::string text = files::read_string(controls_file);
|
|
||||||
Events::loadBindingsOld(controls_file.u8string(), text);
|
|
||||||
fs::remove(controls_file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,10 +61,6 @@ fs::path EnginePaths::getControlsFile() {
|
|||||||
return userfiles/fs::path(CONTROLS_FILE);
|
return userfiles/fs::path(CONTROLS_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::path EnginePaths::getControlsFileOld() {
|
|
||||||
return userfiles/fs::path("controls.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
fs::path EnginePaths::getSettingsFile() {
|
fs::path EnginePaths::getSettingsFile() {
|
||||||
return userfiles/fs::path(SETTINGS_FILE);
|
return userfiles/fs::path(SETTINGS_FILE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public:
|
|||||||
fs::path getWorldFolder();
|
fs::path getWorldFolder();
|
||||||
fs::path getWorldFolder(const std::string& name);
|
fs::path getWorldFolder(const std::string& name);
|
||||||
fs::path getControlsFile();
|
fs::path getControlsFile();
|
||||||
fs::path getControlsFileOld(); // TODO: remove in 0.22
|
|
||||||
fs::path getSettingsFile();
|
fs::path getSettingsFile();
|
||||||
bool isWorldNameUsed(const std::string& name);
|
bool isWorldNameUsed(const std::string& name);
|
||||||
|
|
||||||
|
|||||||
@@ -182,31 +182,6 @@ std::string Events::writeBindings() {
|
|||||||
return toml::stringify(obj);
|
return toml::stringify(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::loadBindingsOld(const std::string& filename, const std::string& source) {
|
|
||||||
auto obj = json::parse(filename, source);
|
|
||||||
for (auto& entry : Events::bindings) {
|
|
||||||
auto& binding = entry.second;
|
|
||||||
|
|
||||||
auto jentry = obj->map(entry.first);
|
|
||||||
if (jentry == nullptr)
|
|
||||||
continue;
|
|
||||||
inputtype type;
|
|
||||||
std::string typestr;
|
|
||||||
jentry->str("type", typestr);
|
|
||||||
|
|
||||||
if (typestr == "keyboard") {
|
|
||||||
type = inputtype::keyboard;
|
|
||||||
} else if (typestr == "mouse") {
|
|
||||||
type = inputtype::mouse;
|
|
||||||
} else {
|
|
||||||
logger.error() << "unknown input type '" << typestr << "'";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
binding.type = type;
|
|
||||||
jentry->num("code", binding.code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Events::loadBindings(const std::string& filename, const std::string& source) {
|
void Events::loadBindings(const std::string& filename, const std::string& source) {
|
||||||
auto map = toml::parse(filename, source);
|
auto map = toml::parse(filename, source);
|
||||||
for (auto& entry : map->values) {
|
for (auto& entry : map->values) {
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ public:
|
|||||||
|
|
||||||
static std::string writeBindings();
|
static std::string writeBindings();
|
||||||
static void loadBindings(const std::string& filename, const std::string& source);
|
static void loadBindings(const std::string& filename, const std::string& source);
|
||||||
static void loadBindingsOld(const std::string& filename, const std::string& source); // TODO: remove in 0.22
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WINDOW_EVENTS_HPP_
|
#endif // WINDOW_EVENTS_HPP_
|
||||||
|
|||||||
Reference in New Issue
Block a user