Compare commits

..

No commits in common. "527415677f308fbf997fb42a7fac677bfe151189" and "3cad3af3fe5ebdc7191f8146d3191189aedcff15" have entirely different histories.

2 changed files with 3 additions and 14 deletions

View File

@ -14,14 +14,14 @@ void PlayerInput::_bind_methods() {
gd::Vector2 PlayerInput::lastMouseMotion{0.f, 0.f}; gd::Vector2 PlayerInput::lastMouseMotion{0.f, 0.f};
bool PlayerInput::primaryExists{false}; bool PlayerInput::primaryExists{false};
PlayerInput::Listener::Listener(gd::String negative, gd::String positive, gd::Callable callable) PlayerInput::Listener::Listener(gd::String positive, gd::String negative, gd::Callable callable)
: actionNegative{negative} : actionNegative{negative}
, actionPositive{positive} , actionPositive{positive}
, callable{callable} , callable{callable}
, isMouseEvent{positive.begins_with("_mouse_") || negative.begins_with("_mouse_")} {} , isMouseEvent{positive.begins_with("_mouse_") || negative.begins_with("_mouse_")} {}
PlayerInput::Listener::Listener(gd::String action, gd::Callable callable) PlayerInput::Listener::Listener(gd::String action, gd::Callable callable)
: PlayerInput::Listener::Listener(gd::String(), action, callable) {} : PlayerInput::Listener::Listener(action, gd::String(), callable) {}
std::optional<float> PlayerInput::Listener::evaluate_action(gd::String const &action) { std::optional<float> PlayerInput::Listener::evaluate_action(gd::String const &action) {
gd::Input *input = gd::Input::get_singleton(); gd::Input *input = gd::Input::get_singleton();
@ -107,14 +107,6 @@ void PlayerInput::listen_to(Listener const& listener) {
this->listeners.push_back(listener); this->listeners.push_back(listener);
} }
void PlayerInput::listen_to(gd::String action, gd::Callable callable) {
this->listeners.push_back(Listener(action, callable));
}
void PlayerInput::listen_to(gd::String negative, gd::String positive, gd::Callable callable) {
this->listeners.push_back(Listener(negative, positive, callable));
}
void PlayerInput::stop_listening(Node *node) { void PlayerInput::stop_listening(Node *node) {
for(size_t i = 0; i < this->listeners.size(); ++i) { for(size_t i = 0; i < this->listeners.size(); ++i) {
Listener l = this->listeners.get(i); Listener l = this->listeners.get(i);

View File

@ -40,7 +40,7 @@ public:
public: public:
Listener() = default; Listener() = default;
Listener(gd::String negative, gd::String positive, gd::Callable callable); Listener(gd::String positive, gd::String negative, gd::Callable callable);
Listener(gd::String action, gd::Callable callable); Listener(gd::String action, gd::Callable callable);
// evaluate the current state of an action. // evaluate the current state of an action.
static std::optional<float> evaluate_action(gd::String const &action); static std::optional<float> evaluate_action(gd::String const &action);
@ -73,9 +73,6 @@ public:
virtual void _process(double deltaTime) override; virtual void _process(double deltaTime) override;
void listen_to(Listener const &listener); void listen_to(Listener const &listener);
void listen_to(gd::String action, gd::Callable callable);
void listen_to(gd::String negative, gd::String positive, gd::Callable callable);
void stop_listening(Node *node); void stop_listening(Node *node);
void stop_listening(Listener const &listener); void stop_listening(Listener const &listener);
void clear_listeners(); void clear_listeners();