2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
23 #include "Audio/openal_wrapper.hpp"
24 #include "Level/Dialog.hpp"
26 #include <SDL_thread.h>
30 const char *pathtypenames[] = {"keepwalking", "pause"};
31 const char *editortypenames[] = {
32 "active", "sitting", "sitting wall", "sleeping",
33 "dead1", "dead2", "dead3", "dead4"
38 Texture terraintexture;
39 Texture terraintexture2;
40 Texture loadscreentexture;
41 Texture Maparrowtexture;
42 Texture Mapboxtexture;
43 Texture Mapcircletexture;
44 Texture cursortexture;
45 GLuint screentexture = 0;
46 GLuint screentexture2 = 0;
47 Texture Mainmenuitems[10];
53 int newscreenwidth = 0;
54 int newscreenheight = 0;
61 int oldmousecoordh = 0;
62 int oldmousecoordv = 0;
65 SkyBox *skybox = NULL;
71 float hawkcalldelay = 0;
74 float wonleveltime = 0;
85 bool stealthloading = 0;
95 bool editorenabled = 0;
99 float editorpitch = 0;
104 int numpathpoints = 0;
105 int numpathpointconnect[30] = {};
106 int pathpointconnect[30][30] = {};
107 int pathpointselected = 0;
111 int numchallengelevels = 0;
113 bool console = false;
114 std::string consoletext[15] = {};
115 std::string displaytext[15] = {};
116 float displaytime[15] = {};
117 float displayblinkdelay = 0;
118 bool displayblink = 0;
119 unsigned displayselected = 0;
120 float consoleblinkdelay = 0;
121 bool consoleblink = 0;
122 unsigned consoleselected = 0;
124 unsigned short crouchkey = 0, jumpkey = 0, forwardkey = 0, backkey = 0, leftkey = 0, rightkey = 0, drawkey = 0, throwkey = 0, attackkey = 0;
125 unsigned short consolekey = 0;
129 int oldenvironment = 0;
131 float changedelay = 0;
133 bool waiting = false;
136 void Game::fireSound(int sound)
138 emit_sound_at(sound);
141 void Game::inputText(string& str, unsigned* charselected)
146 SDL_StartTextInput();
150 while (SDL_PollEvent(&evenement)) {
151 if (!sdlEventProc(evenement)) {
155 switch (evenement.type) {
156 case SDL_TEXTEDITING:
157 /* FIXME - We should handle this for complete input method support */
160 str.insert(*charselected, evenement.text.text);
161 (*charselected) += strlen(evenement.text.text);
164 if (evenement.key.keysym.sym == SDLK_ESCAPE) {
168 } else if (evenement.key.keysym.sym == SDLK_BACKSPACE) {
169 if ((*charselected) > 0) {
171 str.erase(*charselected, 1);
173 } else if (evenement.key.keysym.sym == SDLK_DELETE) {
174 if ((*charselected) < str.size()) {
175 str.erase(*charselected, 1);
177 } else if (evenement.key.keysym.sym == SDLK_HOME) {
179 } else if (evenement.key.keysym.sym == SDLK_END) {
180 (*charselected) = str.size();
181 } else if (evenement.key.keysym.sym == SDLK_LEFT) {
182 if ((*charselected) != 0)
184 } else if (evenement.key.keysym.sym == SDLK_RIGHT) {
185 if ((*charselected) < str.size())
187 } else if (evenement.key.keysym.sym == SDLK_RETURN) {