]> git.mxchange.org Git - quix0rs-blobwars.git/blob - src/CEngine.h
Use time_t to store time data.
[quix0rs-blobwars.git] / src / CEngine.h
1 /*
2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 */
21
22 class Engine {
23
24         private:
25
26                 SDL_Event event;
27                 signed char frameLoop;
28                 int mouseX, mouseY;
29
30                 // Time Difference
31                 unsigned int time1;
32                 unsigned int time2;
33                 float timeDifference;
34                 
35                 // used for cheating!
36                 char lastKeyPressed[25];
37                 char lastKeyEvents[25];
38                 
39                 // Joystick config stuff
40                 int lastButtonPressed;
41                 
42                 Pak pak;
43
44         public:
45                 
46                 int extremeAvailable;
47
48                 char keyState[SDL_NUM_SCANCODES];
49                 char mouseLeft, mouseRight;
50                 
51                 int joyX, joyY;
52                 int joyprevX, joyprevY;
53                 int joykeyX, joykeyY;
54                 bool joykeyFire;
55                 int joystickState[32]; // hopefully no one has a joystick with this many buttons(!)
56                 bool waitForButton;
57                 bool waitForKey;
58                 bool allowJoypad;
59
60                 bool paused;
61                 bool saveConfig;
62                 bool allowQuit;
63
64                 char userHomeDirectory[PATH_MAX];
65
66                 int useAudio;
67                 int fullScreen;
68                 int skill;
69                 bool practice;
70
71                 // Development stuff
72                 bool devNoMonsters;
73
74                 SDL_RWops *sdlrw;
75
76                 unsigned char *binaryBuffer; // used for unzipping
77                 unsigned char *dataBuffer; // used for unzipping
78
79                 int messageTime;
80                 int messagePriority;
81                 int messageType;
82                 char message[100];
83
84                 char saveSlot[10][80];
85                 int continueSaveSlot;
86
87                 int playerPosX, playerPosY;
88
89                 List widgetList;
90
91                 Widget *highlightedWidget;
92
93                 Entity world;
94
95                 List defineList;
96
97                 bool cheats;
98                 int cheatHealth, cheatExtras, cheatFuel, cheatLevels, cheatBlood, cheatInvulnerable;
99                 int cheatReload, cheatSpeed, cheatSkipLevel;
100
101         Engine();
102         void destroy();
103         void getInput();
104         int getMouseX() const;
105         int getMouseY() const;
106
107         void moveMouse(int dx, int dy);
108         bool userAccepts();
109         
110         void clearCheatVars();
111         bool compareLastKeyInputs();
112         void addKeyEvent();
113         void flushInput();
114         void clearInput();
115         void setUserHome(const char *path);
116         Pak *getPak();
117         bool unpack(const char *filename, int fileType);
118         bool loadData(const char *filename);
119         void reportFontFailure();
120         void setPlayerPosition(int x, int y, int limitLeft, int limitRight, int limitUp, int limitDown);
121         int getFrameLoop() const;
122         void doFrameLoop();
123         void doTimeDifference();
124         float getTimeDifference() const;
125         void resetTimeDifference();
126         void setInfoMessage(const char *message, int priority, int type);
127         void deleteWidgets();
128         void addWidget(Widget *widget);
129         bool loadWidgets(const char *filename);
130         Widget *getWidgetByName(const char *name);
131         void showWidgetGroup(const char *groupName, bool show);
132         void enableWidgetGroup(const char *groupName, bool show);
133         void showWidget(const char *name, bool show);
134         void enableWidget(const char *name, bool enable);
135         void setWidgetVariable(const char *name, int *variable);
136         bool widgetChanged(const char *name);
137         void highlightWidget(int dir);
138         void highlightWidget(const char *name);
139         int processWidgets();
140         bool loadDefines();
141         int getValueOfDefine(const char *word);
142         char *getDefineOfValue(const char *prefix, int value);
143         int getValueOfFlagTokens(const char *line);
144         void delay(unsigned int frameLimit);
145 };