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));
66 memset(menustring, 0, sizeof(menustring));
67 memset(registrationname, 0, sizeof(registrationname));
68 registrationnumber = 0;
75 deltah = 0,deltav = 0;
76 mousecoordh = 0,mousecoordv = 0;
77 oldmousecoordh = 0,oldmousecoordv = 0;
78 rotation = 0,rotation2 = 0;
94 // XYZ realhawkcoords;
106 campaignnumlevels = 0;
108 memset(campaignmapname, 0, sizeof(campaignmapname));
109 memset(campaigndescription, 0, sizeof(campaigndescription));
110 memset(campaignchoosenext, 0, sizeof(campaignchoosenext));
111 memset(campaignnumnext, 0, sizeof(campaignnumnext));
112 memset(campaignnextlevel, 0, sizeof(campaignnextlevel));
113 memset(campaignlocationx, 0, sizeof(campaignlocationx));
114 memset(campaignlocationy, 0, sizeof(campaignlocationy));
115 memset(campaignlocationy, 0, sizeof(campaignlocationy));
117 campaignchoicenum = 0;
119 memset(campaignchoicewhich, 0, sizeof(campaignchoicewhich));
125 memset(levelorder, 0, sizeof(levelorder));
126 memset(levelvisible, 0, sizeof(levelvisible));
127 memset(levelhighlight, 0, sizeof(levelhighlight));
131 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
159 // XYZ pathpoint[30];
161 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
162 memset(pathpointconnect, 0, sizeof(pathpointconnect));
163 pathpointselected = 0;
167 numchallengelevels = 0;
172 memset(consoletext, 0, sizeof(consoletext));
173 memset(consolechars, 0, sizeof(consolechars));
175 memset(displaytext, 0, sizeof(displaytext));
176 memset(displaychars, 0, sizeof(displaychars));
177 memset(displaytime, 0, sizeof(displaytime));
178 displayblinkdelay = 0;
182 consoleblinkdelay = 0;
187 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
194 // XYZ boundary[360];
201 memset(musicvolume, 0, sizeof(musicvolume));
202 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
211 accountactive = NULL;
216 void (Game::*method)();
219 void Game::fireSound(int sound) {
220 emit_sound_at(sound);
223 void Game::inputText(char* str, int* charselected, int* nb_chars) {
229 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
230 SDL_EnableUNICODE(true);
233 SDL_PollEvent(&evenement);
235 switch(evenement.type) {
237 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
243 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
244 if((*charselected)!=0) {
245 for(i=(*charselected)-1;i<255;i++)
251 } else if(evenement.key.keysym.sym==SDLK_DELETE){
252 if((*charselected)<(*nb_chars)){
253 for(i=(*charselected);i<255;i++)
258 } else if(evenement.key.keysym.sym==SDLK_HOME){
260 } else if(evenement.key.keysym.sym==SDLK_END){
261 (*charselected)=(*nb_chars);
262 } else if(evenement.key.keysym.sym==SDLK_LEFT){
263 if((*charselected)!=0)
265 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
266 if((*charselected)<(*nb_chars))
268 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
270 } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
271 for(i=255;i>=(*charselected)+1;i--)
273 str[*charselected]=evenement.key.keysym.unicode;
281 SDL_EnableKeyRepeat(0,0); // disable key repeat
282 SDL_EnableUNICODE(false);
286 void Game::setKeySelected() {
288 params_thread* data = new params_thread;
290 data->method = &Game::setKeySelected_thread;
291 printf("launch thread\n");
292 SDL_Thread* thread = SDL_CreateThread(Game::thread, data);
293 if ( thread == NULL ) {
294 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
300 void Game::setKeySelected_thread() {
304 SDL_WaitEvent(&evenement);
305 switch(evenement.type) {
307 keycode = evenement.key.keysym.sym;
309 case SDL_MOUSEBUTTONDOWN:
310 keycode = SDLK_LAST+evenement.button.button;
316 if(keycode != SDLK_ESCAPE) {
319 case 0: forwardkey=keycode;
321 case 1: backkey=keycode;
323 case 2: leftkey=keycode;
325 case 3: rightkey=keycode;
327 case 4: crouchkey=keycode;
329 case 5: jumpkey=keycode;
331 case 6: drawkey=keycode;
333 case 7: throwkey=keycode;
335 case 8: attackkey=keycode;
345 int Game::thread(void *data) {
346 params_thread* pt = (params_thread*)data;
348 (pt->game->*(pt->method))();
352 void Game::DrawGL() {
353 if ( stereomode == stereoNone ) {
354 DrawGLScene(stereoCenter);
356 DrawGLScene(stereoLeft);
357 DrawGLScene(stereoRight);