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 Texture terraintexture;
31 Texture terraintexture2;
32 Texture loadscreentexture;
33 Texture Maparrowtexture;
34 Texture Mapboxtexture;
35 Texture Mapcircletexture;
36 Texture cursortexture;
37 GLuint screentexture = 0;
38 GLuint screentexture2 = 0;
39 Texture Mainmenuitems[10];
45 int newscreenwidth = 0;
46 int newscreenheight = 0;
53 int oldmousecoordh = 0;
54 int oldmousecoordv = 0;
57 SkyBox *skybox = NULL;
63 float hawkcalldelay = 0;
75 bool stealthloading = 0;
85 bool editorenabled = 0;
89 float editorpitch = 0;
94 int numpathpoints = 0;
95 int numpathpointconnect[30] = {};
96 int pathpointconnect[30][30] = {};
97 int pathpointselected = 0;
101 int numchallengelevels = 0;
103 bool console = false;
104 char consoletext[15][256] = {};
105 int consolechars[15] = {};
107 char displaytext[15][256] = {};
108 int displaychars[15] = {};
109 float displaytime[15] = {};
110 float displayblinkdelay = 0;
111 bool displayblink = 0;
112 int displayselected = 0;
113 float consoleblinkdelay = 0;
114 bool consoleblink = 0;
115 int consoleselected = 0;
117 unsigned short crouchkey=0,jumpkey=0,forwardkey=0,chatkey=0,backkey=0,leftkey=0,rightkey=0,drawkey=0,throwkey=0,attackkey=0;
118 unsigned short consolekey=0;
122 int oldenvironment = 0;
124 float changedelay = 0;
126 bool waiting = false;
127 Account* accountactive = NULL;
130 void Game::fireSound(int sound) {
131 emit_sound_at(sound);
134 void Game::inputText(char* str, int* charselected, int* nb_chars) {
139 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
140 SDL_EnableUNICODE(true);
143 while(SDL_PollEvent(&evenement)) {
145 switch(evenement.type) {
147 if(evenement.key.keysym.sym == SDLK_ESCAPE) {
148 for(int i=0;i<255;i++)
153 } else if(evenement.key.keysym.sym==SDLK_BACKSPACE){
154 if((*charselected)!=0) {
155 for(int i=(*charselected)-1;i<255;i++)
161 } else if(evenement.key.keysym.sym==SDLK_DELETE){
162 if((*charselected)<(*nb_chars)){
163 for(int i=(*charselected);i<255;i++)
168 } else if(evenement.key.keysym.sym==SDLK_HOME){
170 } else if(evenement.key.keysym.sym==SDLK_END){
171 (*charselected)=(*nb_chars);
172 } else if(evenement.key.keysym.sym==SDLK_LEFT){
173 if((*charselected)!=0)
175 } else if(evenement.key.keysym.sym==SDLK_RIGHT){
176 if((*charselected)<(*nb_chars))
178 } else if(evenement.key.keysym.sym==SDLK_RETURN) {
180 } else if(evenement.key.keysym.unicode>=32&&evenement.key.keysym.unicode<127&&(*nb_chars)<60){
181 for(int i=255;i>=(*charselected)+1;i--)
183 str[*charselected]=evenement.key.keysym.unicode;
192 SDL_EnableKeyRepeat(0,0); // disable key repeat
193 SDL_EnableUNICODE(false);
197 int setKeySelected_thread(void* data) {
198 using namespace Game;
202 SDL_WaitEvent(&evenement);
203 switch(evenement.type) {
205 keycode = evenement.key.keysym.sym;
207 case SDL_MOUSEBUTTONDOWN:
208 keycode = SDLK_LAST+evenement.button.button;
214 if(keycode != SDLK_ESCAPE) {
217 case 0: forwardkey=keycode;
219 case 1: backkey=keycode;
221 case 2: leftkey=keycode;
223 case 3: rightkey=keycode;
225 case 4: crouchkey=keycode;
227 case 5: jumpkey=keycode;
229 case 6: drawkey=keycode;
231 case 7: throwkey=keycode;
233 case 8: attackkey=keycode;
235 case 9: consolekey=keycode;
247 void Game::setKeySelected() {
249 printf("launch thread\n");
250 SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread,NULL);
251 if ( thread == NULL ) {
252 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());