Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00025
00028
00029 #ifndef THOR_ACTION_HPP
00030 #define THOR_ACTION_HPP
00031
00032 #include <Thor/Input/Detail/ActionOperations.hpp>
00033 #include <Thor/Config.hpp>
00034
00035 #include <functional>
00036
00037
00038 namespace thor
00039 {
00040 namespace detail
00041 {
00042
00043 class EventBuffer;
00044
00045 }
00046
00047
00048
00049
00052
00056 class THOR_API Action
00057 {
00058
00059
00060 public:
00061
00064 enum ActionType
00065 {
00066 Hold,
00067 PressOnce,
00068 ReleaseOnce,
00069 };
00070
00071
00072
00073
00074 public:
00078 explicit Action(sf::Keyboard::Key key, ActionType action = Hold);
00079
00083 explicit Action(sf::Mouse::Button mouseButton, ActionType action = Hold);
00084
00089 explicit Action(JoystickButton joystickState, ActionType action = Hold);
00090
00096 explicit Action(JoystickAxis joystickAxis);
00097
00100 explicit Action(sf::Event::EventType eventType);
00101
00102
00103
00104
00105 public:
00106
00107 Action();
00108
00109
00110 bool isActive(const detail::EventBuffer& buffer) const;
00111
00112
00113 bool isActive(const detail::EventBuffer& buffer, detail::ActionResult& out) const;
00114
00115
00116
00117
00118 private:
00119
00120 explicit Action(detail::ActionNode::CopiedPtr operation);
00121
00122
00123
00124
00125 private:
00126 detail::ActionNode::CopiedPtr mOperation;
00127
00128
00129
00130
00132 friend Action THOR_API operator|| (const Action& lhs, const Action& rhs);
00133 friend Action THOR_API operator&& (const Action& lhs, const Action& rhs);
00134 friend Action THOR_API operator! (const Action& action);
00135 friend Action THOR_API eventAction(std::function<bool(const sf::Event&)> filter);
00136 friend Action THOR_API realtimeAction(std::function<bool()> filter);
00138 };
00139
00140
00150 Action THOR_API operator|| (const Action& lhs, const Action& rhs);
00151
00162 Action THOR_API operator&& (const Action& lhs, const Action& rhs);
00163
00174 Action THOR_API operator! (const Action& action);
00175
00190 Action THOR_API eventAction(std::function<bool(const sf::Event&)> filter);
00191
00206 Action THOR_API realtimeAction(std::function<bool()> filter);
00207
00208
00210
00211 }
00212
00213 #endif // THOR_ACTION_HPP