add contentpacks controls reset
This commit is contained in:
parent
17655eef45
commit
b4d3f9ea15
@ -112,17 +112,25 @@ static int l_is_pressed(lua::State* L) {
|
||||
}
|
||||
}
|
||||
|
||||
static int l_reset_bindings(lua::State*) {
|
||||
auto resFolder = engine->getPaths()->getResourcesFolder();
|
||||
auto configFolder = resFolder/fs::path("config");
|
||||
static void resetPackBindings(fs::path& packFolder) {
|
||||
auto configFolder = packFolder/fs::path("config");
|
||||
auto bindsFile = configFolder/fs::path("bindings.toml");
|
||||
if (fs::is_regular_file(bindsFile)) {
|
||||
Events::loadBindings(
|
||||
bindsFile.u8string(), files::read_string(bindsFile), BindType::REBIND
|
||||
bindsFile.u8string(),
|
||||
files::read_string(bindsFile),
|
||||
BindType::REBIND
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_reset_bindings(lua::State*) {
|
||||
auto resFolder = engine->getPaths()->getResourcesFolder();
|
||||
resetPackBindings(resFolder);
|
||||
for (auto& pack : engine->getContentPacks()) {
|
||||
resetPackBindings(pack.folder);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg inputlib[] = {
|
||||
|
||||
@ -108,7 +108,7 @@ void Events::pollEvents() {
|
||||
Binding& Events::getBinding(const std::string& name) {
|
||||
const auto found = bindings.find(name);
|
||||
if (found == bindings.end()) {
|
||||
throw std::runtime_error("binding '" + name + "' does not exists");
|
||||
throw std::runtime_error("binding '" + name + "' does not exist");
|
||||
}
|
||||
return found->second;
|
||||
}
|
||||
@ -128,7 +128,7 @@ void Events::bind(const std::string& name, inputtype type, int code) {
|
||||
void Events::rebind(const std::string& name, inputtype type, int code) {
|
||||
const auto& found = bindings.find(name);
|
||||
if (found == bindings.end()) {
|
||||
throw std::runtime_error("binding '" + name + "' does not exists");
|
||||
throw std::runtime_error("binding '" + name + "' does not exist");
|
||||
}
|
||||
bindings[name] = Binding(type, code);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user