Compare commits
No commits in common. "ccf149b2c6d2a21d3738867545f17ac25443b2f6" and "71f42913d6537913b25a4f1b146c98ec890ec1ca" have entirely different histories.
ccf149b2c6
...
71f42913d6
10
Doxyfile
10
Doxyfile
|
@ -227,7 +227,7 @@ JAVADOC_BANNER = NO
|
||||||
# requiring an explicit \brief command for a brief description.)
|
# requiring an explicit \brief command for a brief description.)
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
QT_AUTOBRIEF = YES
|
QT_AUTOBRIEF = NO
|
||||||
|
|
||||||
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
|
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
|
||||||
# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
|
# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
|
||||||
|
@ -524,13 +524,13 @@ EXTRACT_ALL = NO
|
||||||
# be included in the documentation.
|
# be included in the documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
EXTRACT_PRIVATE = YES
|
EXTRACT_PRIVATE = NO
|
||||||
|
|
||||||
# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
|
# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual
|
||||||
# methods of a class will be included in the documentation.
|
# methods of a class will be included in the documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
EXTRACT_PRIV_VIRTUAL = YES
|
EXTRACT_PRIV_VIRTUAL = NO
|
||||||
|
|
||||||
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
|
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
|
||||||
# scope will be included in the documentation.
|
# scope will be included in the documentation.
|
||||||
|
@ -542,7 +542,7 @@ EXTRACT_PACKAGE = NO
|
||||||
# included in the documentation.
|
# included in the documentation.
|
||||||
# The default value is: NO.
|
# The default value is: NO.
|
||||||
|
|
||||||
EXTRACT_STATIC = YES
|
EXTRACT_STATIC = NO
|
||||||
|
|
||||||
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
|
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
|
||||||
# locally in source files will be included in the documentation. If set to NO,
|
# locally in source files will be included in the documentation. If set to NO,
|
||||||
|
@ -1416,7 +1416,7 @@ HTML_EXTRA_FILES =
|
||||||
# The default value is: AUTO_LIGHT.
|
# The default value is: AUTO_LIGHT.
|
||||||
# This tag requires that the tag GENERATE_HTML is set to YES.
|
# This tag requires that the tag GENERATE_HTML is set to YES.
|
||||||
|
|
||||||
HTML_COLORSTYLE = TOGGLE
|
HTML_COLORSTYLE = AUTO_LIGHT
|
||||||
|
|
||||||
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
|
||||||
# will adjust the colors in the style sheet and background images according to
|
# will adjust the colors in the style sheet and background images according to
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
#include <godot_cpp/classes/resource.hpp>
|
#include <godot_cpp/classes/resource.hpp>
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
/*! Parent class for saved game state.
|
|
||||||
*
|
|
||||||
* Inherit and add godot properties to save persistently.
|
|
||||||
*/
|
|
||||||
class GameState : public godot::Resource {
|
class GameState : public godot::Resource {
|
||||||
GDCLASS(GameState, godot::Resource);
|
GDCLASS(GameState, godot::Resource);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
|
@ -20,7 +20,6 @@ class PlayerInput : public gd::Node {
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
/*! A PlayerInput action listener.
|
/*! A PlayerInput action listener.
|
||||||
*
|
|
||||||
* A listener is a combination of a positive and negative action and a callable.
|
* A listener is a combination of a positive and negative action and a callable.
|
||||||
* The expected callable signature is `void (godot::Ref<godot::InputEvent> event, float value)`
|
* The expected callable signature is `void (godot::Ref<godot::InputEvent> event, float value)`
|
||||||
* actions can also be "special" actions prefixed with `_`.
|
* actions can also be "special" actions prefixed with `_`.
|
||||||
|
@ -29,18 +28,14 @@ public:
|
||||||
struct Listener {
|
struct Listener {
|
||||||
friend class PlayerInput;
|
friend class PlayerInput;
|
||||||
private:
|
private:
|
||||||
//! Negative action on axis, evaluates to -1.
|
// the two actions, evaluated as positive - negative
|
||||||
gd::String actionNegative{""};
|
gd::String actionNegative{""};
|
||||||
//! Positive action on axis, evaluates to +1.
|
|
||||||
gd::String actionPositive{""};
|
gd::String actionPositive{""};
|
||||||
/*! The last cached action.
|
// the last cached action, if the newest result matches this, the event will be considered
|
||||||
*
|
// duplicate and ignored (not passed to listener)
|
||||||
* If the newest result matches this, the event will be considered duplicate and ignored (not passed to listener)
|
|
||||||
*/
|
|
||||||
float lastCached{0.f};
|
float lastCached{0.f};
|
||||||
//! The listening function.
|
|
||||||
gd::Callable callable;
|
gd::Callable callable;
|
||||||
//! If either actionNegative or actionPositive is a _mouse_ event this will be true
|
// if either actionNegative or actionPositive is a _mouse_ event this will be true
|
||||||
bool isMouseEvent{false};
|
bool isMouseEvent{false};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -49,17 +44,15 @@ public:
|
||||||
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);
|
||||||
/*! Check if this event has any chance to result in a trigger.
|
// check if this event has any chance to result in a trigger, does not evaluate the event or
|
||||||
*
|
// poll current input state
|
||||||
* Does not evaluate the event or poll current input state
|
|
||||||
*/
|
|
||||||
bool has_changed(gd::Ref<gd::InputEvent> const &event);
|
bool has_changed(gd::Ref<gd::InputEvent> const &event);
|
||||||
//! evaluate the event for changes to either actionPositive or actionNegative
|
// evaluate the event for changes to either actionPositive or actionNegative
|
||||||
float evaluate(gd::Ref<gd::InputEvent> const &event);
|
float evaluate(gd::Ref<gd::InputEvent> const &event);
|
||||||
|
|
||||||
bool operator==(PlayerInput::Listener const& b) const;
|
bool operator==(PlayerInput::Listener const& b) const;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
//! Returns the last stored mouse delta.
|
|
||||||
static gd::Vector2 get_last_mouse_motion();
|
static gd::Vector2 get_last_mouse_motion();
|
||||||
|
|
||||||
virtual void _enter_tree() override;
|
virtual void _enter_tree() override;
|
||||||
|
@ -67,41 +60,27 @@ public:
|
||||||
virtual void _unhandled_input(gd::Ref<gd::InputEvent> const &event) override;
|
virtual void _unhandled_input(gd::Ref<gd::InputEvent> const &event) override;
|
||||||
virtual void _process(double deltaTime) override;
|
virtual void _process(double deltaTime) override;
|
||||||
|
|
||||||
//! Start listening for action.
|
|
||||||
void listen_to(Listener const &listener);
|
void listen_to(Listener const &listener);
|
||||||
/*! Start listening for action.
|
|
||||||
*
|
|
||||||
* Shorthand for `listen_to(Listener(action, callable))`.
|
|
||||||
*/
|
|
||||||
void listen_to(gd::String action, gd::Callable callable);
|
void listen_to(gd::String action, gd::Callable callable);
|
||||||
/*! Start listening for action.
|
|
||||||
*
|
|
||||||
* Shorthand for `listen_to(Listener(negative, positive, callable))`.
|
|
||||||
*/
|
|
||||||
void listen_to(gd::String negative, gd::String positive, gd::Callable callable);
|
void listen_to(gd::String negative, gd::String positive, gd::Callable callable);
|
||||||
|
|
||||||
//! Remove any listeners related to node.
|
|
||||||
void stop_listening(Node *node);
|
void stop_listening(Node *node);
|
||||||
//! Remove listeners exactly equal to listener.
|
|
||||||
void stop_listening(Listener const &listener);
|
void stop_listening(Listener const &listener);
|
||||||
//! Remove all listeners.
|
|
||||||
void clear_listeners();
|
void clear_listeners();
|
||||||
//! set the device observe events from.
|
|
||||||
void set_device(int id);
|
void set_device(int id);
|
||||||
private:
|
private:
|
||||||
//! The last mouse motion, updated by the primary instance
|
// the last mouse motion, updated by the primary instance
|
||||||
static gd::Vector2 lastMouseMotion;
|
static gd::Vector2 lastMouseMotion;
|
||||||
//! Does a primary instance exist
|
// does a primary instance exist
|
||||||
static bool primaryExists;
|
static bool primaryExists;
|
||||||
/*! Is this the primary instance.
|
// is this the primary instance
|
||||||
*
|
// the primary instance is responsible for updating static
|
||||||
* The primary instance is responsible for updating static variables like lastMouseMotion.
|
// variables like lastMouseMotion
|
||||||
*/
|
|
||||||
bool isPrimary{false};
|
bool isPrimary{false};
|
||||||
//! which device to observe events from.
|
|
||||||
int device{-1};
|
int device{-1};
|
||||||
|
|
||||||
//! current listeners for this instance
|
// current listeners for this instance
|
||||||
gd::Vector<Listener> listeners{};
|
gd::Vector<Listener> listeners{};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue