56 lines
2.1 KiB
C++
56 lines
2.1 KiB
C++
#ifndef _AACTION_H_
|
|
# define _AACTION_H_
|
|
|
|
#include <SFML/Window/Joystick.hpp>
|
|
#include "Core/Core.hh"
|
|
|
|
#define DC_INPUT_NONE 99999
|
|
|
|
namespace DamnCute
|
|
{
|
|
template <typename T>
|
|
class AAction
|
|
{
|
|
|
|
protected:
|
|
sf::Keyboard::Key _key1;
|
|
sf::Keyboard::Key _key2;
|
|
sf::Joystick::Axis _stickAxis;
|
|
int _stickButton;
|
|
int _stickButton2;
|
|
bool _hasAxis;
|
|
T* _entity;
|
|
|
|
public:
|
|
explicit AAction(T *p, sf::Keyboard::Key k, sf::Joystick::Axis s)
|
|
: _key1(k), _key2(sf::Keyboard::Unknown), _stickAxis(s), _stickButton(DC_INPUT_NONE), _stickButton2(DC_INPUT_NONE), _hasAxis(true), _entity(p) { }
|
|
|
|
explicit AAction(T *p, sf::Keyboard::Key k1, sf::Keyboard::Key k2, sf::Joystick::Axis s)
|
|
: _key1(k1), _key2(k2), _stickAxis(s), _stickButton(DC_INPUT_NONE), _stickButton2(DC_INPUT_NONE), _hasAxis(true), _entity(p) { }
|
|
|
|
explicit AAction(T *p, sf::Keyboard::Key k, int s)
|
|
: _key1(k), _key2(sf::Keyboard::Unknown), _stickAxis(sf::Joystick::Axis::X), _stickButton(s), _stickButton2(DC_INPUT_NONE), _hasAxis(false), _entity(p) { }
|
|
|
|
explicit AAction(T *p, sf::Keyboard::Key k1, sf::Keyboard::Key k2, int s1, int s2)
|
|
: _key1(k1), _key2(k2), _stickAxis(sf::Joystick::Axis::X), _stickButton(s1), _stickButton2(s2), _hasAxis(false), _entity(p) {}
|
|
|
|
virtual ~AAction() = default;
|
|
|
|
virtual void execute() = 0;
|
|
virtual const std::string& getName() const = 0;
|
|
virtual bool hasInput(int) = 0;
|
|
|
|
inline bool hasStickAxis() const { return _hasAxis; }
|
|
|
|
void setStickInput(sf::Joystick::Axis input) { _stickAxis = input; }
|
|
void setStickInput(int input) { _stickButton = input; }
|
|
void setKeyboardInput1(sf::Keyboard::Key input) { _key1 = input; }
|
|
void setKeyboardInput2(sf::Keyboard::Key input) { _key2 = input; }
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|