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];
30 GLuint terraintexture;
31 GLuint terraintexture2;
32 GLuint terraintexture3;
34 GLuint screentexture2;
36 GLuint loadscreentexture;
37 GLuint Maparrowtexture;
39 GLuint Mapcircletexture;
41 GLuint Mainmenuitems[10];
51 char registrationname[256];
52 float registrationnumber;
60 int mousecoordh,mousecoordv;
61 int oldmousecoordh,oldmousecoordv;
62 float rotation,rotation2;
86 std::vector<CampaignLevel> campaignlevels;
94 int musictype,oldmusictype,oldoldmusictype;
114 float editorrotation;
115 float editorrotation2;
124 int numpathpointconnect[30];
125 int pathpointconnect[30][30];
126 int pathpointselected;
130 int numchallengelevels;
134 char consoletext[15][256];
135 int consolechars[15];
137 char displaytext[15][256];
138 int displaychars[15];
139 float displaytime[15];
140 float displayblinkdelay;
144 float consoleblinkdelay;
149 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
150 unsigned short consolekey;
164 float musicvolume[4];
165 float oldmusicvolume[4];
170 Account* accountactive;
184 loadscreentexture = 0;
187 Mapcircletexture = 0;
190 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
200 memset(registrationname, 0, sizeof(registrationname));
201 registrationnumber = 0;
208 deltah = 0,deltav = 0;
209 mousecoordh = 0,mousecoordv = 0;
210 oldmousecoordh = 0,oldmousecoordv = 0;
211 rotation = 0,rotation2 = 0;
227 // XYZ realhawkcoords;
246 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
274 // XYZ pathpoint[30];
276 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
277 memset(pathpointconnect, 0, sizeof(pathpointconnect));
278 pathpointselected = 0;
282 numchallengelevels = 0;
287 memset(consoletext, 0, sizeof(consoletext));
288 memset(consolechars, 0, sizeof(consolechars));
290 memset(displaytext, 0, sizeof(displaytext));
291 memset(displaychars, 0, sizeof(displaychars));
292 memset(displaytime, 0, sizeof(displaytime));
293 displayblinkdelay = 0;
297 consoleblinkdelay = 0;
302 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
310 // XYZ boundary[360];
317 memset(musicvolume, 0, sizeof(musicvolume));
318 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
327 accountactive = NULL;
330 void Game::deleteGame(){
333 for(int i=0;i<10;i++){
334 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
336 glDeleteTextures( 1, &cursortexture );
337 glDeleteTextures( 1, &Maparrowtexture );
338 glDeleteTextures( 1, &Mapboxtexture );
339 glDeleteTextures( 1, &Mapcircletexture );
340 glDeleteTextures( 1, &terraintexture );
341 glDeleteTextures( 1, &terraintexture2 );
342 if(screentexture>0)glDeleteTextures( 1, &screentexture );
343 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
344 glDeleteTextures( 1, &hawktexture );
345 glDeleteTextures( 1, &logotexture );
346 glDeleteTextures( 1, &loadscreentexture );
351 void Game::fireSound(int sound) {
352 emit_sound_at(sound);
355 void Game::inputText(char* str, int* charselected, int* nb_chars) {
360 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
361 SDL_EnableUNICODE(true);
364 while(SDL_PollEvent(&evenement)) {
366 switch(evenement.type) {
368 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
369 for(int i=0;i<255;i++)
374 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
375 if((*charselected)!=0) {
376 for(int i=(*charselected)-1;i<255;i++)
382 } else if(evenement.key.keysym.sym==SDLK_DELETE){
383 if((*charselected)<(*nb_chars)){
384 for(int i=(*charselected);i<255;i++)
389 } else if(evenement.key.keysym.sym==SDLK_HOME){
391 } else if(evenement.key.keysym.sym==SDLK_END){
392 (*charselected)=(*nb_chars);
393 } else if(evenement.key.keysym.sym==SDLK_LEFT){
394 if((*charselected)!=0)
396 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
397 if((*charselected)<(*nb_chars))
399 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
401 } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
402 for(int i=255;i>=(*charselected)+1;i--)
404 str[*charselected]=evenement.key.keysym.unicode;
413 SDL_EnableKeyRepeat(0,0); // disable key repeat
414 SDL_EnableUNICODE(false);
418 void Game::setKeySelected() {
420 printf("launch thread\n");
421 SDL_Thread* thread = SDL_CreateThread(Game::setKeySelected_thread,NULL);
422 if ( thread == NULL ) {
423 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
429 int Game::setKeySelected_thread(void* data) {
433 SDL_WaitEvent(&evenement);
434 switch(evenement.type) {
436 keycode = evenement.key.keysym.sym;
438 case SDL_MOUSEBUTTONDOWN:
439 keycode = SDLK_LAST+evenement.button.button;
445 if(keycode != SDLK_ESCAPE) {
448 case 0: forwardkey=keycode;
450 case 1: backkey=keycode;
452 case 2: leftkey=keycode;
454 case 3: rightkey=keycode;
456 case 4: crouchkey=keycode;
458 case 5: jumpkey=keycode;
460 case 6: drawkey=keycode;
462 case 7: throwkey=keycode;
464 case 8: attackkey=keycode;
466 case 9: consolekey=keycode;
478 void Game::DrawGL() {
479 if ( stereomode == stereoNone ) {
480 DrawGLScene(stereoCenter);
482 DrawGLScene(stereoLeft);
483 DrawGLScene(stereoRight);