]> git.jsancho.org Git - lugaru.git/blob - Source/Game.h
DialogBox is protected on Windows, rename to DialogScene
[lugaru.git] / Source / Game.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
4
5 This file is part of Lugaru.
6
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _GAME_H_
22 #define _GAME_H_
23
24 #include "SDL.h"
25
26 #include "ImageIO.h"
27
28 #include "Terrain.h"
29 #include "Skybox.h"
30 #include "Skeleton.h"
31 #include "Models.h"
32 #include "Lights.h"
33 #include "Person.h"
34 #include "Sprite.h"
35 #include "Text.h"
36 #include "Objects.h"
37 #include "Weapons.h"
38 #include "binio.h"
39 #include <fstream>
40 #include "gamegl.h"
41 #include "Stereo.h"
42 #include "Account.h"
43 #include "Sounds.h"
44 #include "Texture.h"
45 #include "optionparser.h"
46
47 #define NB_CAMPAIGN_MENU_ITEM 7
48
49 namespace Game
50 {
51 extern Texture terraintexture;
52 extern Texture terraintexture2;
53 extern Texture loadscreentexture;
54 extern Texture Maparrowtexture;
55 extern Texture Mapboxtexture;
56 extern Texture Mapcircletexture;
57 extern Texture cursortexture;
58 extern GLuint screentexture;
59 extern GLuint screentexture2;
60 extern Texture Mainmenuitems[10];
61
62 extern int selected;
63 extern int keyselect;
64
65 extern int newdetail;
66 extern int newscreenwidth;
67 extern int newscreenheight;
68
69 extern bool gameon;
70 extern float deltah, deltav;
71 extern int mousecoordh, mousecoordv;
72 extern int oldmousecoordh, oldmousecoordv;
73 extern float yaw, pitch;
74 extern SkyBox *skybox;
75 extern bool cameramode;
76 extern bool firstload;
77
78 extern float leveltime;
79 extern float loadtime;
80
81 extern Model hawk;
82 extern XYZ hawkcoords;
83 extern XYZ realhawkcoords;
84 extern Texture hawktexture;
85 extern float hawkyaw;
86 extern float hawkcalldelay;
87
88 extern Model eye;
89 extern Model iris;
90 extern Model cornea;
91
92 extern bool stealthloading;
93 extern int loading;
94
95 extern int musictype;
96
97 extern XYZ mapcenter;
98 extern float mapradius;
99
100 extern Text *text;
101 extern float fps;
102
103 extern bool editorenabled;
104 extern int editortype;
105 extern float editorsize;
106 extern float editoryaw;
107 extern float editorpitch;
108
109 extern int tryquit;
110
111 extern XYZ pathpoint[30];
112 extern int numpathpoints;
113 extern int numpathpointconnect[30];
114 extern int pathpointconnect[30][30];
115 extern int pathpointselected;
116
117 extern int endgame;
118 extern bool scoreadded;
119 extern int numchallengelevels;
120
121 extern bool console;
122 extern std::string consoletext[15];
123 extern std::string displaytext[15];
124 extern float displaytime[15];
125 extern float displayblinkdelay;
126 extern bool displayblink;
127 extern unsigned displayselected;
128 extern float consoleblinkdelay;
129 extern bool consoleblink;
130 extern unsigned consoleselected;
131
132 extern int oldenvironment;
133 extern int targetlevel;
134 extern float changedelay;
135
136 extern bool waiting;
137 extern Account* accountactive;
138
139 extern unsigned short crouchkey, jumpkey, forwardkey, backkey, leftkey, rightkey, drawkey, throwkey, attackkey;
140 extern unsigned short consolekey;
141
142 void newGame();
143 void deleteGame();
144
145 void InitGame();
146 void LoadStuff();
147 void LoadScreenTexture();
148 void LoadingScreen();
149 int DrawGLScene(StereoSide side);
150 void LoadMenu();
151 void playdialoguescenesound();
152 int findClosestPlayer();
153 void Loadlevel(int which);
154 void Loadlevel(const char *name);
155 void Tick();
156 void TickOnce();
157 void TickOnceAfter();
158 void SetUpLighting();
159 GLvoid ReSizeGLScene(float fov, float near);
160 int checkcollide(XYZ startpoint, XYZ endpoint);
161 int checkcollide(XYZ startpoint, XYZ endpoint, int what);
162
163 void fireSound(int sound = fireendsound);
164 void setKeySelected();
165
166 void inputText(std::string& str, unsigned* charselected);
167 void flash(float amount = 1, int delay = 1);
168 }
169
170 #ifndef __forceinline
171 #  ifdef __GNUC__
172 #    define __forceinline inline __attribute__((always_inline))
173 #  endif
174 #endif
175
176 static __forceinline void swap_gl_buffers(void)
177 {
178     extern SDL_Window *sdlwindow;
179     SDL_GL_SwapWindow(sdlwindow);
180
181     // try to limit this to 60fps, even if vsync fails.
182     Uint32 now;
183     static Uint32 frameticks = 0;
184     const Uint32 endticks = (frameticks + 16);
185     while ((now = SDL_GetTicks()) < endticks) { /* spin. */ }
186     frameticks = now;
187 }
188
189 extern "C" {
190     void UndefinedSymbolToExposeStubbedCode(void);
191 }
192 //#define STUBBED(x) UndefinedSymbolToExposeStubbedCode();
193 #define STUBBED(x) { static bool seen = false; if (!seen) { seen = true; fprintf(stderr, "STUBBED: %s at %s:%d\n", x, __FILE__, __LINE__); } }
194 //#define STUBBED(x)
195
196 enum maptypes {
197     mapkilleveryone, mapgosomewhere,
198     mapkillsomeone, mapkillmost // These two are unused
199 };
200
201 enum pathtypes {wpkeepwalking, wppause};
202
203 extern const char *pathtypenames[2];
204
205 enum editortypes {typeactive, typesitting, typesittingwall, typesleeping,
206                   typedead1, typedead2, typedead3, typedead4
207                  };
208
209 extern const char *editortypenames[8];
210
211 extern const char *rabbitskin[10];
212
213 extern const char *wolfskin[3];
214
215 extern const char **creatureskin[2];
216
217 SDL_bool sdlEventProc(const SDL_Event &e);
218
219
220
221 enum  optionIndex { UNKNOWN, HELP, FULLSCREEN, NOMOUSEGRAB, SOUND, OPENALINFO, SHOWRESOLUTIONS };
222 /* Number of options + 1 */
223 const int commandLineOptionsNumber = 8;
224
225 extern const option::Descriptor usage[12];
226
227 extern option::Option commandLineOptions[commandLineOptionsNumber];
228 extern option::Option* commandLineOptionsBuffer;
229
230 #endif