2 #include "openal_wrapper.h"
3 #include "SDL_thread.h"
8 int numdialogueboxes[max_dialogues];
9 int dialoguetype[max_dialogues];
10 int dialogueboxlocation[max_dialogues][max_dialoguelength];
11 float dialogueboxcolor[max_dialogues][max_dialoguelength][3];
12 int dialogueboxsound[max_dialogues][max_dialoguelength];
13 char dialoguetext[max_dialogues][max_dialoguelength][128];
14 char dialoguename[max_dialogues][max_dialoguelength][64];
15 XYZ dialoguecamera[max_dialogues][max_dialoguelength];
16 XYZ participantlocation[max_dialogues][10];
17 int participantfocus[max_dialogues][max_dialoguelength];
18 int participantaction[max_dialogues][max_dialoguelength];
19 float participantrotation[max_dialogues][10];
20 XYZ participantfacing[max_dialogues][max_dialoguelength][10];
21 float dialoguecamerarotation[max_dialogues][max_dialoguelength];
22 float dialoguecamerarotation2[max_dialogues][max_dialoguelength];
27 int dialoguegonethrough[20];
29 std::vector<TextureInfo> Game::textures;
39 loadscreentexture = 0;
45 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
49 memset(startx, 0, sizeof(startx));
50 memset(starty, 0, sizeof(starty));
51 memset(endx, 0, sizeof(endx));
52 memset(endy, 0, sizeof(endy));
54 memset(selectedlong, 0, sizeof(selectedlong));
55 memset(offsetx, 0, sizeof(offsetx));
56 memset(offsety, 0, sizeof(offsety));
57 memset(movex, 0, sizeof(movex));
58 memset(movey, 0, sizeof(movey));
59 memset(endy, 0, sizeof(endy));
72 memset(menustring, 0, sizeof(menustring));
73 memset(registrationname, 0, sizeof(registrationname));
74 registrationnumber = 0;
81 deltah = 0,deltav = 0;
82 mousecoordh = 0,mousecoordv = 0;
83 oldmousecoordh = 0,oldmousecoordv = 0;
84 rotation = 0,rotation2 = 0;
100 // XYZ realhawkcoords;
112 campaignnumlevels = 0;
114 memset(campaignmapname, 0, sizeof(campaignmapname));
115 memset(campaigndescription, 0, sizeof(campaigndescription));
116 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
117 memset(campaignnumnext, 0, sizeof(campaignnumnext));
118 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
119 int campaignchoicesmade;
120 memset(campaignchoices, 0, sizeof(campaignchoices));
121 memset(campaignlocationx, 0, sizeof(campaignlocationx));
122 memset(campaignlocationy, 0, sizeof(campaignlocationy));
123 memset(campaignlocationy, 0, sizeof(campaignlocationy));
125 campaignchoicenum = 0;
127 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
133 memset(levelorder, 0, sizeof(levelorder));
134 memset(levelvisible, 0, sizeof(levelvisible));
135 memset(levelhighlight, 0, sizeof(levelhighlight));
139 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
167 // XYZ pathpoint[30];
169 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
170 memset(pathpointconnect, 0, sizeof(pathpointconnect));
171 pathpointselected = 0;
175 numchallengelevels = 0;
180 memset(consoletext, 0, sizeof(consoletext));
181 memset(consolechars, 0, sizeof(consolechars));
183 memset(displaytext, 0, sizeof(displaytext));
184 memset(displaychars, 0, sizeof(displaychars));
185 memset(displaytime, 0, sizeof(displaytime));
186 displayblinkdelay = 0;
190 consoleblinkdelay = 0;
195 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
202 // XYZ boundary[360];
209 memset(musicvolume, 0, sizeof(musicvolume));
210 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
219 accountactive = NULL;
224 void (Game::*method)();
227 void Game::fireSound(int sound) {
228 emit_sound_at(sound);
231 void Game::inputText(char* str, int* charselected, int* nb_chars) {
237 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
238 SDL_EnableUNICODE(true);
241 SDL_PollEvent(&evenement);
243 switch(evenement.type) {
245 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
251 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
252 if((*charselected)!=0) {
253 for(i=(*charselected)-1;i<255;i++)
259 } else if(evenement.key.keysym.sym==SDLK_DELETE){
260 if((*charselected)<(*nb_chars)){
261 for(i=(*charselected);i<255;i++)
266 } else if(evenement.key.keysym.sym==SDLK_HOME){
268 } else if(evenement.key.keysym.sym==SDLK_END){
269 (*charselected)=(*nb_chars);
270 } else if(evenement.key.keysym.sym==SDLK_LEFT){
271 if((*charselected)!=0)
273 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
274 if((*charselected)<(*nb_chars))
276 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
278 } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
279 for(i=255;i>=(*charselected)+1;i--)
281 str[*charselected]=evenement.key.keysym.unicode;
289 SDL_EnableKeyRepeat(0,0); // disable key repeat
290 SDL_EnableUNICODE(false);
294 void Game::setKeySelected() {
296 params_thread* data = new params_thread;
298 data->method = &Game::setKeySelected_thread;
299 printf("launch thread\n");
300 SDL_Thread* thread = SDL_CreateThread(Game::thread, data);
301 if ( thread == NULL ) {
302 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
308 void Game::setKeySelected_thread() {
312 SDL_WaitEvent(&evenement);
313 switch(evenement.type) {
315 keycode = evenement.key.keysym.sym;
317 case SDL_MOUSEBUTTONDOWN:
318 keycode = SDLK_LAST+evenement.button.button;
324 if(keycode != SDLK_ESCAPE) {
327 case 0: forwardkey=keycode;
329 case 1: backkey=keycode;
331 case 2: leftkey=keycode;
333 case 3: rightkey=keycode;
335 case 4: crouchkey=keycode;
337 case 5: jumpkey=keycode;
339 case 6: drawkey=keycode;
341 case 7: throwkey=keycode;
343 case 8: attackkey=keycode;
353 int Game::thread(void *data) {
354 params_thread* pt = (params_thread*)data;
356 (pt->game->*(pt->method))();
360 void Game::DrawGL() {
361 if ( stereomode == stereoNone ) {
362 DrawGLScene(stereoCenter);
364 DrawGLScene(stereoLeft);
365 DrawGLScene(stereoRight);