From c96d031b903e27cf2c14247acab044c8a2f20dc1 Mon Sep 17 00:00:00 2001 From: danzel Date: Sun, 13 Aug 2017 10:19:26 +1200 Subject: [PATCH] scripted_input is active is a script is loaded, not based on the button mapping --- src/scripted_input/script_runner.cpp | 4 ++++ src/scripted_input/script_runner.h | 1 + src/scripted_input/scripted_buttons.cpp | 5 ----- src/scripted_input/scripted_buttons.h | 6 ------ src/scripted_input/scripted_input.cpp | 3 +-- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/scripted_input/script_runner.cpp b/src/scripted_input/script_runner.cpp index 8cd880022..363e8ec22 100644 --- a/src/scripted_input/script_runner.cpp +++ b/src/scripted_input/script_runner.cpp @@ -77,6 +77,10 @@ void ScriptRunner::LoadScript(std::string script_name) { fclose(file); } +bool ScriptRunner::HasScript() const { + return script.size() > 0; +} + void ScriptRunner::NotifyFrameFinished() { frame_number++; diff --git a/src/scripted_input/script_runner.h b/src/scripted_input/script_runner.h index cbdf2fa5c..75b0af1e4 100644 --- a/src/scripted_input/script_runner.h +++ b/src/scripted_input/script_runner.h @@ -31,6 +31,7 @@ class ScriptRunner final { public: void SetButtons(std::shared_ptr buttons); void LoadScript(std::string script_name); + bool HasScript() const; void NotifyFrameFinished(); private: diff --git a/src/scripted_input/scripted_buttons.cpp b/src/scripted_input/scripted_buttons.cpp index 4e4965277..e4e9dd8dd 100644 --- a/src/scripted_input/scripted_buttons.cpp +++ b/src/scripted_input/scripted_buttons.cpp @@ -63,16 +63,11 @@ std::unique_ptr ScriptedButtons::Create(const Common::Param int index = IndexOfButton(button_str); if (index >= 0) { scripted_button_list.get()->buttons[index] = button.get(); - is_in_use = true; } return std::move(button); } -bool ScriptedButtons::IsInUse() { - return is_in_use; -} - void ScriptedButtons::SetActiveButtons(const std::vector& buttons_active) { for (int i = 0; i < button_count; i++) { diff --git a/src/scripted_input/scripted_buttons.h b/src/scripted_input/scripted_buttons.h index 5201b1434..1cf327a56 100644 --- a/src/scripted_input/scripted_buttons.h +++ b/src/scripted_input/scripted_buttons.h @@ -26,15 +26,9 @@ public: */ std::unique_ptr Create(const Common::ParamPackage& params) override; - /** - * True if any button is being controlled - */ - bool IsInUse(); - void SetActiveButtons(const std::vector& buttons_active); private: std::shared_ptr scripted_button_list; - bool is_in_use {false}; }; } // namespace InputCommon diff --git a/src/scripted_input/scripted_input.cpp b/src/scripted_input/scripted_input.cpp index 9029eedc1..5662ca5df 100644 --- a/src/scripted_input/scripted_input.cpp +++ b/src/scripted_input/scripted_input.cpp @@ -31,8 +31,7 @@ void Shutdown() { } bool IsInUse() { - //TODO return script_runner.HasScript(); - return scripted_buttons.get()->IsInUse(); + return script_runner.HasScript(); } void NotifyFrameFinished() {