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 participantyaw[max_dialogues][10];
20 XYZ participantfacing[max_dialogues][max_dialoguelength][10];
21 float dialoguecamerayaw[max_dialogues][max_dialoguelength];
22 float dialoguecamerapitch[max_dialogues][max_dialoguelength];
27 int dialoguegonethrough[20];
30 GLuint terraintexture = 0;
31 GLuint terraintexture2 = 0;
32 GLuint terraintexture3 = 0;
33 GLuint screentexture = 0;
34 GLuint screentexture2 = 0;
35 GLuint logotexture = 0;
36 GLuint loadscreentexture = 0;
37 GLuint Maparrowtexture = 0;
38 GLuint Mapboxtexture = 0;
39 GLuint Mapcircletexture = 0;
40 GLuint cursortexture = 0;
41 GLuint Mainmenuitems[10] = {};
47 int newscreenwidth = 0;
48 int newscreenheight = 0;
55 int oldmousecoordh = 0;
56 int oldmousecoordv = 0;
59 SkyBox *skybox = NULL;
63 GLuint hawktexture = 0;
65 float hawkcalldelay = 0;
77 bool stealthloading = 0;
87 bool editorenabled = 0;
91 float editorpitch = 0;
96 int numpathpoints = 0;
97 int numpathpointconnect[30] = {};
98 int pathpointconnect[30][30] = {};
99 int pathpointselected = 0;
103 int numchallengelevels = 0;
105 bool console = false;
106 char consoletext[15][256] = {};
107 int consolechars[15] = {};
109 char displaytext[15][256] = {};
110 int displaychars[15] = {};
111 float displaytime[15] = {};
112 float displayblinkdelay = 0;
113 bool displayblink = 0;
114 int displayselected = 0;
115 float consoleblinkdelay = 0;
116 bool consoleblink = 0;
117 int consoleselected = 0;
119 unsigned short crouchkey=0,jumpkey=0,forwardkey=0,chatkey=0,backkey=0,leftkey=0,rightkey=0,drawkey=0,throwkey=0,attackkey=0;
120 unsigned short consolekey=0;
124 int oldenvironment = 0;
126 float changedelay = 0;
128 bool waiting = false;
129 Account* accountactive = NULL;
132 void Game::fireSound(int sound) {
133 emit_sound_at(sound);
136 void Game::inputText(char* str, int* charselected, int* nb_chars) {
141 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
142 SDL_EnableUNICODE(true);
145 while(SDL_PollEvent(&evenement)) {
147 switch(evenement.type) {
149 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
150 for(int i=0;i<255;i++)
155 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
156 if((*charselected)!=0) {
157 for(int i=(*charselected)-1;i<255;i++)
163 } else if(evenement.key.keysym.sym==SDLK_DELETE){
164 if((*charselected)<(*nb_chars)){
165 for(int i=(*charselected);i<255;i++)
170 } else if(evenement.key.keysym.sym==SDLK_HOME){
172 } else if(evenement.key.keysym.sym==SDLK_END){
173 (*charselected)=(*nb_chars);
174 } else if(evenement.key.keysym.sym==SDLK_LEFT){
175 if((*charselected)!=0)
177 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
178 if((*charselected)<(*nb_chars))
180 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
182 } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
183 for(int i=255;i>=(*charselected)+1;i--)
185 str[*charselected]=evenement.key.keysym.unicode;
194 SDL_EnableKeyRepeat(0,0); // disable key repeat
195 SDL_EnableUNICODE(false);
199 int setKeySelected_thread(void* data) {
200 using namespace Game;
204 SDL_WaitEvent(&evenement);
205 switch(evenement.type) {
207 keycode = evenement.key.keysym.sym;
209 case SDL_MOUSEBUTTONDOWN:
210 keycode = SDLK_LAST+evenement.button.button;
216 if(keycode != SDLK_ESCAPE) {
219 case 0: forwardkey=keycode;
221 case 1: backkey=keycode;
223 case 2: leftkey=keycode;
225 case 3: rightkey=keycode;
227 case 4: crouchkey=keycode;
229 case 5: jumpkey=keycode;
231 case 6: drawkey=keycode;
233 case 7: throwkey=keycode;
235 case 8: attackkey=keycode;
237 case 9: consolekey=keycode;
249 void Game::setKeySelected() {
251 printf("launch thread\n");
252 SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread,NULL);
253 if ( thread == NULL ) {
254 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());