track-width fixes
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "../coders/toml.h"
|
||||
#include "../coders/json.h"
|
||||
#include "../debug/Logger.hpp"
|
||||
#include "../settings.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -166,44 +167,3 @@ void SettingsHandler::setValue(const std::string& name, const dynamic::Value& va
|
||||
std::vector<Section>& SettingsHandler::getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
std::string write_controls() {
|
||||
dynamic::Map obj;
|
||||
for (auto& entry : Events::bindings) {
|
||||
const auto& binding = entry.second;
|
||||
|
||||
auto& jentry = obj.putMap(entry.first);
|
||||
switch (binding.type) {
|
||||
case inputtype::keyboard: jentry.put("type", "keyboard"); break;
|
||||
case inputtype::mouse: jentry.put("type", "mouse"); break;
|
||||
default: throw std::runtime_error("unsupported control type");
|
||||
}
|
||||
jentry.put("code", binding.code);
|
||||
}
|
||||
return json::stringify(&obj, true, " ");
|
||||
}
|
||||
|
||||
void load_controls(std::string filename, 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#ifndef FILES_SETTINGS_IO_HPP_
|
||||
#define FILES_SETTINGS_IO_HPP_
|
||||
|
||||
#include "../data/dynamic.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include "../settings.h"
|
||||
#include "../data/dynamic.h"
|
||||
|
||||
class Setting;
|
||||
struct EngineSettings;
|
||||
|
||||
struct Section {
|
||||
std::string name;
|
||||
@@ -27,8 +30,4 @@ public:
|
||||
std::vector<Section>& getSections();
|
||||
};
|
||||
|
||||
std::string write_controls();
|
||||
|
||||
void load_controls(std::string filename, std::string source);
|
||||
|
||||
#endif // FILES_SETTINGS_IO_HPP_
|
||||
|
||||
Reference in New Issue
Block a user