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));
62 memset(menustring, 0, sizeof(menustring));
63 memset(registrationname, 0, sizeof(registrationname));
64 registrationnumber = 0;
71 deltah = 0,deltav = 0;
72 mousecoordh = 0,mousecoordv = 0;
73 oldmousecoordh = 0,oldmousecoordv = 0;
74 rotation = 0,rotation2 = 0;
90 // XYZ realhawkcoords;
107 musictype = 0,oldmusictype = 0,oldoldmusictype = 0;
135 // XYZ pathpoint[30];
137 memset(numpathpointconnect, 0, sizeof(numpathpointconnect));
138 memset(pathpointconnect, 0, sizeof(pathpointconnect));
139 pathpointselected = 0;
143 numchallengelevels = 0;
148 memset(consoletext, 0, sizeof(consoletext));
149 memset(consolechars, 0, sizeof(consolechars));
151 memset(displaytext, 0, sizeof(displaytext));
152 memset(displaychars, 0, sizeof(displaychars));
153 memset(displaytime, 0, sizeof(displaytime));
154 displayblinkdelay = 0;
158 consoleblinkdelay = 0;
163 crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
171 // XYZ boundary[360];
178 memset(musicvolume, 0, sizeof(musicvolume));
179 memset(oldmusicvolume, 0, sizeof(oldmusicvolume));
188 accountactive = NULL;
193 void (Game::*method)();
196 void Game::fireSound(int sound) {
197 emit_sound_at(sound);
200 void Game::inputText(char* str, int* charselected, int* nb_chars) {
206 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
207 SDL_EnableUNICODE(true);
210 SDL_PollEvent(&evenement);
212 switch(evenement.type) {
214 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
220 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
221 if((*charselected)!=0) {
222 for(i=(*charselected)-1;i<255;i++)
228 } else if(evenement.key.keysym.sym==SDLK_DELETE){
229 if((*charselected)<(*nb_chars)){
230 for(i=(*charselected);i<255;i++)
235 } else if(evenement.key.keysym.sym==SDLK_HOME){
237 } else if(evenement.key.keysym.sym==SDLK_END){
238 (*charselected)=(*nb_chars);
239 } else if(evenement.key.keysym.sym==SDLK_LEFT){
240 if((*charselected)!=0)
242 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
243 if((*charselected)<(*nb_chars))
245 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
247 } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
248 for(i=255;i>=(*charselected)+1;i--)
250 str[*charselected]=evenement.key.keysym.unicode;
258 SDL_EnableKeyRepeat(0,0); // disable key repeat
259 SDL_EnableUNICODE(false);
263 void Game::setKeySelected() {
265 params_thread* data = new params_thread;
267 data->method = &Game::setKeySelected_thread;
268 printf("launch thread\n");
269 SDL_Thread* thread = SDL_CreateThread(Game::thread, data);
270 if ( thread == NULL ) {
271 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
277 void Game::setKeySelected_thread() {
281 SDL_WaitEvent(&evenement);
282 switch(evenement.type) {
284 keycode = evenement.key.keysym.sym;
286 case SDL_MOUSEBUTTONDOWN:
287 keycode = SDLK_LAST+evenement.button.button;
293 if(keycode != SDLK_ESCAPE) {
296 case 0: forwardkey=keycode;
298 case 1: backkey=keycode;
300 case 2: leftkey=keycode;
302 case 3: rightkey=keycode;
304 case 4: crouchkey=keycode;
306 case 5: jumpkey=keycode;
308 case 6: drawkey=keycode;
310 case 7: throwkey=keycode;
312 case 8: attackkey=keycode;
314 case 9: consolekey=keycode;
324 int Game::thread(void *data) {
325 params_thread* pt = (params_thread*)data;
327 (pt->game->*(pt->method))();
331 void Game::DrawGL() {
332 if ( stereomode == stereoNone ) {
333 DrawGLScene(stereoCenter);
335 DrawGLScene(stereoLeft);
336 DrawGLScene(stereoRight);