| 1 |
#ifndef HEADER_CONTROLS_H |
| 2 |
#define HEADER_CONTROLS_H |
| 3 |
|
| 4 |
class V2; |
| 5 |
class Unit; |
| 6 |
class Cube; |
| 7 |
class PhaseLocker; |
| 8 |
class KeyStroke; |
| 9 |
class InputProvider; |
| 10 |
class MouseStroke; |
| 11 |
|
| 12 |
#include "NoCopy.h" |
| 13 |
#include "KeyControl.h" |
| 14 |
#include "StepCounter.h" |
| 15 |
|
| 16 |
#include <vector> |
| 17 |
#include <string> |
| 18 |
|
| 19 |
/** |
| 20 |
* Keyboard and mouse controls. |
| 21 |
*/ |
| 22 |
class Controls : public StepCounter, public NoCopy { |
| 23 |
private: |
| 24 |
typedef std::vector<Unit*> t_units; |
| 25 |
t_units m_units; |
| 26 |
t_units::iterator m_active; |
| 27 |
int m_speedup; |
| 28 |
KeyControl m_arrows; |
| 29 |
bool m_switch; |
| 30 |
std::string m_moves; |
| 31 |
PhaseLocker *m_locker; |
| 32 |
char m_strokeSymbol; |
| 33 |
private: |
| 34 |
bool useSwitch(); |
| 35 |
bool useStroke(); |
| 36 |
bool driveUnit(const InputProvider *input); |
| 37 |
void setActive(t_units::iterator active); |
| 38 |
int getNeededPhases(int speedup) const; |
| 39 |
bool activateDriven(char symbol); |
| 40 |
public: |
| 41 |
Controls(PhaseLocker *locker); |
| 42 |
~Controls(); |
| 43 |
void setMoves(const std::string &moves); |
| 44 |
void addUnit(Unit *unit); |
| 45 |
const Unit *getActive(); |
| 46 |
|
| 47 |
bool driving(const InputProvider *input); |
| 48 |
void lockPhases(); |
| 49 |
|
| 50 |
void checkActive(); |
| 51 |
void switchActive(); |
| 52 |
bool makeMove(char move); |
| 53 |
bool cannotMove() const; |
| 54 |
|
| 55 |
void controlEvent(const KeyStroke &stroke); |
| 56 |
bool activateSelected(const Cube *occupant); |
| 57 |
|
| 58 |
virtual int getStepCount() const { return m_moves.size(); } |
| 59 |
virtual std::string getMoves() const { return m_moves; } |
| 60 |
virtual bool isPowerful() const; |
| 61 |
virtual bool isDangerousMove() const; |
| 62 |
}; |
| 63 |
|
| 64 |
#endif |