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];
31 Texture terraintexture;
32 Texture terraintexture2;
33 Texture loadscreentexture;
34 Texture Maparrowtexture;
35 Texture Mapboxtexture;
36 Texture Mapcircletexture;
37 Texture cursortexture;
38 GLuint screentexture = 0;
39 GLuint screentexture2 = 0;
40 Texture Mainmenuitems[10];
46 int newscreenwidth = 0;
47 int newscreenheight = 0;
54 int oldmousecoordh = 0;
55 int oldmousecoordv = 0;
58 SkyBox *skybox = NULL;
64 float hawkcalldelay = 0;
76 bool stealthloading = 0;
86 bool editorenabled = 0;
90 float editorpitch = 0;
95 int numpathpoints = 0;
96 int numpathpointconnect[30] = {};
97 int pathpointconnect[30][30] = {};
98 int pathpointselected = 0;
102 int numchallengelevels = 0;
104 bool console = false;
105 char consoletext[15][256] = {};
106 int consolechars[15] = {};
108 char displaytext[15][256] = {};
109 int displaychars[15] = {};
110 float displaytime[15] = {};
111 float displayblinkdelay = 0;
112 bool displayblink = 0;
113 int displayselected = 0;
114 float consoleblinkdelay = 0;
115 bool consoleblink = 0;
116 int consoleselected = 0;
118 unsigned short crouchkey = 0, jumpkey = 0, forwardkey = 0, chatkey = 0, backkey = 0, leftkey = 0, rightkey = 0, drawkey = 0, throwkey = 0, attackkey = 0;
119 unsigned short consolekey = 0;
123 int oldenvironment = 0;
125 float changedelay = 0;
127 bool waiting = false;
128 Account* accountactive = NULL;
131 void Game::fireSound(int sound)
133 emit_sound_at(sound);
136 void Game::inputText(char* str, int* charselected, int* nb_chars)
142 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
143 SDL_EnableUNICODE(true);
146 while (SDL_PollEvent(&evenement)) {
148 switch (evenement.type) {
150 if (evenement.key.keysym.sym == SDLK_ESCAPE) {
151 for (int i = 0; i < 255; i++)
156 } else if (evenement.key.keysym.sym == SDLK_BACKSPACE) {
157 if ((*charselected) != 0) {
158 for (int i = (*charselected) - 1; i < 255; i++)
164 } else if (evenement.key.keysym.sym == SDLK_DELETE) {
165 if ((*charselected) < (*nb_chars)) {
166 for (int i = (*charselected); i < 255; i++)
171 } else if (evenement.key.keysym.sym == SDLK_HOME) {
173 } else if (evenement.key.keysym.sym == SDLK_END) {
174 (*charselected) = (*nb_chars);
175 } else if (evenement.key.keysym.sym == SDLK_LEFT) {
176 if ((*charselected) != 0)
178 } else if (evenement.key.keysym.sym == SDLK_RIGHT) {
179 if ((*charselected) < (*nb_chars))
181 } else if (evenement.key.keysym.sym == SDLK_RETURN) {
183 } else if (evenement.key.keysym.unicode >= 32 && evenement.key.keysym.unicode < 127 && (*nb_chars) < 60) {
184 for (int i = 255; i >= (*charselected) + 1; i--)
186 str[*charselected] = evenement.key.keysym.unicode;
195 SDL_EnableKeyRepeat(0, 0); // disable key repeat
196 SDL_EnableUNICODE(false);
200 int setKeySelected_thread(void* data)
202 using namespace Game;
205 while (keycode == -1) {
206 SDL_WaitEvent(&evenement);
207 switch (evenement.type) {
209 keycode = evenement.key.keysym.sym;
211 case SDL_MOUSEBUTTONDOWN:
212 keycode = SDLK_LAST + evenement.button.button;
218 if (keycode != SDLK_ESCAPE) {
222 forwardkey = keycode;
249 consolekey = keycode;
261 void Game::setKeySelected()
264 printf("launch thread\n");
265 SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread, NULL);
266 if ( thread == NULL ) {
267 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());