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 menustring[100][256];
52 char registrationname[256];
53 float registrationnumber;
61 int mousecoordh,mousecoordv;
62 int oldmousecoordh,oldmousecoordv;
63 float rotation,rotation2;
87 std::vector<CampaignLevel> campaignlevels;
95 int musictype,oldmusictype,oldoldmusictype;
115 float editorrotation;
116 float editorrotation2;
125 int numpathpointconnect[30];
126 int pathpointconnect[30][30];
127 int pathpointselected;
131 int numchallengelevels;
135 char consoletext[15][256];
136 int consolechars[15];
138 char displaytext[15][256];
139 int displaychars[15];
140 float displaytime[15];
141 float displayblinkdelay;
145 float consoleblinkdelay;
150 unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
151 unsigned short consolekey;
165 float musicvolume[4];
166 float oldmusicvolume[4];
171 Account* accountactive;
185 loadscreentexture = 0;
188 Mapcircletexture = 0;
191 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
201 memset(menustring, 0, sizeof(menustring));
202 memset(registrationname, 0, sizeof(registrationname));
203 registrationnumber = 0;
210 deltah = 0,deltav = 0;
211 mousecoordh = 0,mousecoordv = 0;
212 oldmousecoordh = 0,oldmousecoordv = 0;
213 rotation = 0,rotation2 = 0;
229 // XYZ realhawkcoords;
248 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
276 // XYZ pathpoint[30];
278 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
279 memset(pathpointconnect, 0, sizeof(pathpointconnect));
280 pathpointselected = 0;
284 numchallengelevels = 0;
289 memset(consoletext, 0, sizeof(consoletext));
290 memset(consolechars, 0, sizeof(consolechars));
292 memset(displaytext, 0, sizeof(displaytext));
293 memset(displaychars, 0, sizeof(displaychars));
294 memset(displaytime, 0, sizeof(displaytime));
295 displayblinkdelay = 0;
299 consoleblinkdelay = 0;
304 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
312 // XYZ boundary[360];
319 memset(musicvolume, 0, sizeof(musicvolume));
320 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
329 accountactive = NULL;
332 void Game::deleteGame(){
335 for(int i=0;i<10;i++){
336 if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
338 glDeleteTextures( 1, &cursortexture );
339 glDeleteTextures( 1, &Maparrowtexture );
340 glDeleteTextures( 1, &Mapboxtexture );
341 glDeleteTextures( 1, &Mapcircletexture );
342 glDeleteTextures( 1, &terraintexture );
343 glDeleteTextures( 1, &terraintexture2 );
344 if(screentexture>0)glDeleteTextures( 1, &screentexture );
345 if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
346 glDeleteTextures( 1, &hawktexture );
347 glDeleteTextures( 1, &logotexture );
348 glDeleteTextures( 1, &loadscreentexture );
353 void Game::fireSound(int sound) {
354 emit_sound_at(sound);
357 void Game::inputText(char* str, int* charselected, int* nb_chars) {
362 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
363 SDL_EnableUNICODE(true);
366 while(SDL_PollEvent(&evenement)) {
368 switch(evenement.type) {
370 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
371 for(int i=0;i<255;i++)
376 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
377 if((*charselected)!=0) {
378 for(int i=(*charselected)-1;i<255;i++)
384 } else if(evenement.key.keysym.sym==SDLK_DELETE){
385 if((*charselected)<(*nb_chars)){
386 for(int i=(*charselected);i<255;i++)
391 } else if(evenement.key.keysym.sym==SDLK_HOME){
393 } else if(evenement.key.keysym.sym==SDLK_END){
394 (*charselected)=(*nb_chars);
395 } else if(evenement.key.keysym.sym==SDLK_LEFT){
396 if((*charselected)!=0)
398 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
399 if((*charselected)<(*nb_chars))
401 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
403 } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
404 for(int i=255;i>=(*charselected)+1;i--)
406 str[*charselected]=evenement.key.keysym.unicode;
415 SDL_EnableKeyRepeat(0,0); // disable key repeat
416 SDL_EnableUNICODE(false);
420 void Game::setKeySelected() {
422 printf("launch thread\n");
423 SDL_Thread* thread = SDL_CreateThread(Game::setKeySelected_thread,NULL);
424 if ( thread == NULL ) {
425 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
431 int Game::setKeySelected_thread(void* data) {
435 SDL_WaitEvent(&evenement);
436 switch(evenement.type) {
438 keycode = evenement.key.keysym.sym;
440 case SDL_MOUSEBUTTONDOWN:
441 keycode = SDLK_LAST+evenement.button.button;
447 if(keycode != SDLK_ESCAPE) {
450 case 0: forwardkey=keycode;
452 case 1: backkey=keycode;
454 case 2: leftkey=keycode;
456 case 3: rightkey=keycode;
458 case 4: crouchkey=keycode;
460 case 5: jumpkey=keycode;
462 case 6: drawkey=keycode;
464 case 7: throwkey=keycode;
466 case 8: attackkey=keycode;
468 case 9: consolekey=keycode;
479 void Game::DrawGL() {
480 if ( stereomode == stereoNone ) {
481 DrawGLScene(stereoCenter);
483 DrawGLScene(stereoLeft);
484 DrawGLScene(stereoRight);