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];
37 loadscreentexture = 0;
43 memset(Mainmenuitems, 0, sizeof(Mainmenuitems));
47 memset(startx, 0, sizeof(startx));
48 memset(starty, 0, sizeof(starty));
49 memset(endx, 0, sizeof(endx));
50 memset(endy, 0, sizeof(endy));
52 memset(selectedlong, 0, sizeof(selectedlong));
53 memset(offsetx, 0, sizeof(offsetx));
54 memset(offsety, 0, sizeof(offsety));
55 memset(movex, 0, sizeof(movex));
56 memset(movey, 0, sizeof(movey));
57 memset(endy, 0, sizeof(endy));
70 memset(menustring, 0, sizeof(menustring));
71 memset(registrationname, 0, sizeof(registrationname));
72 registrationnumber = 0;
79 deltah = 0,deltav = 0;
80 mousecoordh = 0,mousecoordv = 0;
81 oldmousecoordh = 0,oldmousecoordv = 0;
82 rotation = 0,rotation2 = 0;
98 // XYZ realhawkcoords;
110 campaignnumlevels = 0;
112 memset(campaignmapname, 0, sizeof(campaignmapname));
113 memset(campaigndescription, 0, sizeof(campaigndescription));
114 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
115 memset(campaignnumnext, 0, sizeof(campaignnumnext));
116 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
117 int campaignchoicesmade;
118 memset(campaignchoices, 0, sizeof(campaignchoices));
119 memset(campaignlocationx, 0, sizeof(campaignlocationx));
120 memset(campaignlocationy, 0, sizeof(campaignlocationy));
121 memset(campaignlocationy, 0, sizeof(campaignlocationy));
123 campaignchoicenum = 0;
125 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
131 memset(levelorder, 0, sizeof(levelorder));
132 memset(levelvisible, 0, sizeof(levelvisible));
133 memset(levelhighlight, 0, sizeof(levelhighlight));
137 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
165 // XYZ pathpoint[30];
167 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
168 memset(pathpointconnect, 0, sizeof(pathpointconnect));
169 pathpointselected = 0;
173 numchallengelevels = 0;
178 memset(consoletext, 0, sizeof(consoletext));
179 memset(consolechars, 0, sizeof(consolechars));
181 memset(displaytext, 0, sizeof(displaytext));
182 memset(displaychars, 0, sizeof(displaychars));
183 memset(displaytime, 0, sizeof(displaytime));
184 displayblinkdelay = 0;
188 consoleblinkdelay = 0;
193 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
200 // XYZ boundary[360];
207 memset(musicvolume, 0, sizeof(musicvolume));
208 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
217 accountactive = NULL;
222 void (Game::*method)();
225 void Game::fireSound(int sound) {
226 emit_sound_at(sound);
229 void Game::inputText(char* str, int* charselected, int* nb_chars) {
235 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
236 SDL_EnableUNICODE(true);
239 SDL_PollEvent(&evenement);
241 switch(evenement.type) {
243 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
250 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
251 if((*charselected)!=0) {
252 for(i=(*charselected)-1;i<255;i++){
259 } else if(evenement.key.keysym.sym==SDLK_DELETE){
260 for(i=(*charselected);i<255;i++){
265 } else if(evenement.key.keysym.sym==SDLK_LEFT){
266 if((*charselected)!=0)
268 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
269 if((*charselected)<(*nb_chars))
271 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
273 } else if((evenement.key.keysym.unicode<127)&&((*nb_chars)<60)&&(evenement.key.keysym.sym!=SDLK_LSHIFT)&&(evenement.key.keysym.sym!=SDLK_RSHIFT)) {
274 for(i=255;i>=(*charselected)+1;i--){
277 str[*charselected]=evenement.key.keysym.unicode;
285 SDL_EnableKeyRepeat(0,0); // disable key repeat
286 SDL_EnableUNICODE(false);
290 void Game::setKeySelected() {
292 params_thread* data = new params_thread;
294 data->method = &Game::setKeySelected_thread;
295 printf("launch thread\n");
296 SDL_Thread* thread = SDL_CreateThread(Game::thread, data);
297 if ( thread == NULL ) {
298 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
304 void Game::setKeySelected_thread() {
308 SDL_WaitEvent(&evenement);
309 switch(evenement.type) {
311 keycode = evenement.key.keysym.sym;
313 case SDL_MOUSEBUTTONDOWN:
314 keycode = SDLK_LAST+evenement.button.button;
320 if(keycode != SDLK_ESCAPE) {
323 case 0: forwardkey=keycode;
325 case 1: backkey=keycode;
327 case 2: leftkey=keycode;
329 case 3: rightkey=keycode;
331 case 4: crouchkey=keycode;
333 case 5: jumpkey=keycode;
335 case 6: drawkey=keycode;
337 case 7: throwkey=keycode;
339 case 8: attackkey=keycode;
349 int Game::thread(void *data) {
350 params_thread* pt = (params_thread*)data;
352 (pt->game->*(pt->method))();
356 void Game::DrawGL() {
357 if ( stereomode == stereoNone ) {
358 DrawGLScene(stereoCenter);
360 DrawGLScene(stereoLeft);
361 DrawGLScene(stereoRight);