00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "State.h"
00031
00032 #include <string>
00034
00035 #define INIT_URI_MAX 1000000l
00036
00037 typedef struct
00038 {
00039 unsigned short esc;
00040 unsigned short toggleCamera;
00041 unsigned short accelerate;
00042 unsigned short slowDown;
00043 unsigned short turnLeft;
00044 unsigned short turnRight;
00045 unsigned short powerInc;
00046 unsigned short powerDec;
00047 unsigned short fiInc;
00048 unsigned short fiDec;
00049 unsigned short thetaInc;
00050 unsigned short thetaDec;
00051 unsigned short fire;
00052 unsigned short endTurn;
00053 unsigned short cycleMap;
00054 unsigned short zoomInMap;
00055 unsigned short zoomOutMap;
00056 unsigned short fsToggle;
00057
00058
00059 unsigned short grp_x1;
00060 unsigned short grp_x2;
00061 unsigned short grp_x3;
00062 unsigned short grp_x4;
00063 unsigned short grp_x5;
00064 unsigned short grp_x6;
00065 unsigned short grp_x7;
00066 unsigned short grp_x8;
00067 unsigned short grp_x9;
00068 unsigned short grp_x0;
00069 unsigned short leaveGrp;
00070
00071
00072 unsigned short panRight;
00073 unsigned short panLeft;
00074 unsigned short aimMode;
00075 } KeyBindings;
00076
00080 class GameState : public State
00081 {
00083 friend class State;
00084
00085 public:
00087 static GameState* currentGame;
00089 static KeyBindings kb;
00090
00091 protected:
00092 typedef void (GameState::*DoKeyFunc_t) (int, int, int, bool, bool, unsigned int);
00093
00095 static int initState;
00096 static long lastUpdate;
00097 int buttonsDown;
00098 float lastMouseX, lastMouseY;
00099 bool cameraLock;
00100 float turnStart;
00101 float turnTime_ms;
00102 bool turnActive;
00103 std::string mission;
00104 DoKeyFunc_t doKeyFunc;
00105
00106 public:
00107 GameState(StateID state, std::string m);
00108 ~GameState();
00109
00110 virtual void paint();
00111 virtual void doKey(int key, int x, int y, bool special,
00112 bool down, unsigned int modifiers);
00113 virtual void keyRelease(int key, int x, int y, bool special, unsigned int modifiers);
00114 virtual void doMouseDown(Interface::MouseButtonType button, int x, int y);
00115 virtual void doMouseUp(Interface::MouseButtonType button, int x, int y);
00116 virtual void doMouseDragged(int x, int y);
00117 virtual bool isActive();
00118
00119 void setupKeyBindings();
00120
00121 void doKey_InGame(int key, int x, int y, bool special,
00122 bool down, unsigned int modifiers);
00123 void doKey_GameOver(int key, int x, int y, bool special,
00124 bool down, unsigned int modifiers);
00125 protected:
00131 static void LoadMissionIncremental();
00132 static void Update(int value);
00133 static void GenerateTrees(short nmemb, float minRadius, float maxRadius);
00134 static void GenerateStones(short nmemb, float radius);
00135 static void Start();
00136 static void StartGameOver();
00137 static void GameOverPaint();
00138
00139 void setupProjectionMatrix();
00140 void setupOrthoMatrix();
00141 void endTurn();
00142
00143 };