When a script is configured, override the controls settings so it is used. This means you only need to set one thing in the config to use a script (script_name).

This commit is contained in:
danzel 2017-08-13 18:03:56 +12:00
parent c70b49be17
commit 196a09fefa
3 changed files with 14 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <atomic>
#include <vector>
#include "core/settings.h"
#include "scripted_input/scripted_buttons.h"
const int button_count = 15;
@ -40,6 +41,12 @@ public:
ScriptedButton* buttons[button_count];
};
void ScriptedButtons::OverrideControlsSettings() {
for (int i = 0; i < button_count; i++) {
Settings::values.buttons[i] = "engine:scripted,button:" + button_name_to_index[i];
}
}
ScriptedButtons::ScriptedButtons() : scripted_button_list{std::make_shared<ScriptedButtonList>()} {}
std::unique_ptr<Input::ButtonDevice> ScriptedButtons::Create(const Common::ParamPackage& params) {

View File

@ -18,6 +18,11 @@ class ScriptedButtonList;
*/
class ScriptedButtons final : public Input::Factory<Input::ButtonDevice> {
public:
/**
* Overrides the Settings for buttons so they are controlled by us
*/
static void OverrideControlsSettings();
ScriptedButtons();
/**

View File

@ -22,6 +22,8 @@ void Init() {
void LoadScript(std::string script_name) {
if (script_name.length() > 0) {
script_runner.LoadScript(script_name);
ScriptedButtons::OverrideControlsSettings();
}
}