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/>.
21 #include "Menu/Menu.hpp"
23 #include "Audio/openal_wrapper.hpp"
24 #include "Graphic/gamegl.hpp"
25 #include "Level/Campaign.hpp"
26 #include "User/Settings.hpp"
27 #include "Utils/Input.hpp"
29 // Should not be needed, Menu should call methods from other classes to launch maps and challenges and so on
30 #include "Level/Awards.hpp"
38 extern float multiplier;
39 extern std::set<std::pair<int, int>> resolutions;
41 extern std::vector<CampaignLevel> campaignlevels;
42 extern float musicvolume[4];
43 extern float oldmusicvolume[4];
44 extern bool stillloading;
45 extern bool visibleloading;
46 extern int whichchoice;
47 extern int leveltheme;
49 extern void toggleFullscreen();
52 std::string newusername = "";
53 unsigned newuserselected = 0;
54 float newuserblinkdelay = 0;
55 bool newuserblink = false;
57 std::vector<MenuItem> Menu::items;
59 MenuItem::MenuItem(MenuItemType _type, int _id, const string& _text, Texture _texture,
60 int _x, int _y, int _w, int _h, float _r, float _g, float _b,
61 float _linestartsize, float _lineendsize)
74 , linestartsize(_linestartsize)
75 , lineendsize(_lineendsize)
77 if (type == MenuItem::BUTTON) {
79 w = text.length() * 10;
87 void Menu::clearMenu()
92 void Menu::addLabel(int id, const string& text, int x, int y, float r, float g, float b)
94 items.emplace_back(MenuItem::LABEL, id, text, Texture(), x, y, -1, -1, r, g, b);
96 void Menu::addButton(int id, const string& text, int x, int y, float r, float g, float b)
98 items.emplace_back(MenuItem::BUTTON, id, text, Texture(), x, y, -1, -1, r, g, b);
100 void Menu::addImage(int id, Texture texture, int x, int y, int w, int h, float r, float g, float b)
102 items.emplace_back(MenuItem::IMAGE, id, "", texture, x, y, w, h, r, g, b);
104 void Menu::addButtonImage(int id, Texture texture, int x, int y, int w, int h, float r, float g, float b)
106 items.emplace_back(MenuItem::IMAGEBUTTON, id, "", texture, x, y, w, h, r, g, b);
108 void Menu::addMapLine(int x, int y, int w, int h, float startsize, float endsize, float r, float g, float b)
110 items.emplace_back(MenuItem::MAPLINE, -1, "", Texture(), x, y, w, h, r, g, b, startsize, endsize);
112 void Menu::addMapMarker(int id, Texture texture, int x, int y, int w, int h, float r, float g, float b)
114 items.emplace_back(MenuItem::MAPMARKER, id, "", texture, x, y, w, h, r, g, b);
116 void Menu::addMapLabel(int id, const string& text, int x, int y, float r, float g, float b)
118 items.emplace_back(MenuItem::MAPLABEL, id, text, Texture(), x, y, -1, -1, r, g, b);
121 void Menu::setText(int id, const string& text)
123 for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++)
126 it->w = it->text.length() * 10;
131 void Menu::setText(int id, const string& text, int x, int y, int w, int h)
133 for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++)
139 it->w = it->text.length() * 10;
146 int Menu::getSelected(int mousex, int mousey)
148 for (vector<MenuItem>::reverse_iterator it = items.rbegin(); it != items.rend(); it++)
149 if (it->type == MenuItem::BUTTON || it->type == MenuItem::IMAGEBUTTON || it->type == MenuItem::MAPMARKER) {
152 if (it->type == MenuItem::MAPMARKER) {
156 if (mx >= it->x && mx < it->x + it->w && my >= it->y && my < it->y + it->h)
162 void Menu::handleFadeEffect()
164 for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
165 if (it->id == Game::selected) {
166 it->effectfade += multiplier * 5;
167 if (it->effectfade > 1)
170 it->effectfade -= multiplier * 5;
171 if (it->effectfade < 0)
177 void Menu::drawItems()
180 glEnable(GL_TEXTURE_2D);
181 glEnable(GL_ALPHA_TEST);
183 for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
185 case MenuItem::IMAGE:
186 case MenuItem::IMAGEBUTTON:
187 case MenuItem::MAPMARKER:
188 glColor4f(it->r, it->g, it->b, 1);
190 if (it->type == MenuItem::MAPMARKER) {
191 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
192 glTranslatef(2.5, -4.5, 0); //from old code
194 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
197 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
198 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
201 glVertex3f(it->x, it->y, 0);
203 glVertex3f(it->x + it->w, it->y, 0);
205 glVertex3f(it->x + it->w, it->y + it->h, 0);
207 glVertex3f(it->x, it->y + it->h, 0);
209 if (it->type != MenuItem::IMAGE) {
210 //mouseover highlight
211 for (int i = 0; i < 10; i++) {
212 if (1 - ((float)i) / 10 - (1 - it->effectfade) > 0) {
213 glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade)) * .25);
216 glVertex3f(it->x - ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
218 glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
220 glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
222 glVertex3f(it->x - ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
229 case MenuItem::LABEL:
230 case MenuItem::BUTTON:
231 glColor4f(it->r, it->g, it->b, 1);
232 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
233 Game::text->glPrint(it->x, it->y, it->text.c_str(), 0, 1, 640, 480);
234 if (it->type != MenuItem::LABEL) {
235 //mouseover highlight
236 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
237 for (int i = 0; i < 15; i++) {
238 if (1 - ((float)i) / 15 - (1 - it->effectfade) > 0) {
239 glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade)) * .25);
240 Game::text->glPrint(it->x - ((float)i), it->y, it->text.c_str(), 0, 1 + ((float)i) / 70, 640, 480);
245 case MenuItem::MAPLABEL:
246 Game::text->glPrintOutlined(0.9, 0, 0, 1, it->x, it->y, it->text.c_str(), 0, 0.6, 640, 480);
248 case MenuItem::MAPLINE: {
254 lineend.x = it->x + it->w;
255 lineend.y = it->y + it->h;
257 XYZ offset = lineend - linestart;
260 offset = DoRotation(offset, 0, 0, 90);
263 linestart += fac * 4 * it->linestartsize;
264 lineend -= fac * 4 * it->lineendsize;
266 glDisable(GL_TEXTURE_2D);
267 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
268 glColor4f(it->r, it->g, it->b, 1);
270 glTranslatef(2, -5, 0); //from old code
272 glVertex3f(linestart.x - offset.x * it->linestartsize, linestart.y - offset.y * it->linestartsize, 0.0f);
273 glVertex3f(linestart.x + offset.x * it->linestartsize, linestart.y + offset.y * it->linestartsize, 0.0f);
274 glVertex3f(lineend.x + offset.x * it->lineendsize, lineend.y + offset.y * it->lineendsize, 0.0f);
275 glVertex3f(lineend.x - offset.x * it->lineendsize, lineend.y - offset.y * it->lineendsize, 0.0f);
278 glEnable(GL_TEXTURE_2D);
287 void Menu::updateSettingsMenu()
289 std::string sbuf = std::string("Resolution: ") + to_string(newscreenwidth) + "*" + to_string(newscreenheight);
290 if (((float)newscreenwidth <= (float)newscreenheight * 1.61) && ((float)newscreenwidth >= (float)newscreenheight * 1.59)) {
291 sbuf += " (widescreen)";
294 setText(14, fullscreen ? "Fullscreen: On" : "Fullscreen: Off");
296 setText(1, "Detail: Low");
298 setText(1, "Detail: Medium");
300 setText(1, "Detail: High");
301 if (bloodtoggle == 0)
302 setText(2, "Blood: Off");
303 if (bloodtoggle == 1)
304 setText(2, "Blood: On, low detail");
305 if (bloodtoggle == 2)
306 setText(2, "Blood: On, high detail (slower)");
307 setText(4, ismotionblur ? "Blur Effects: Enabled (less compatible)" : "Blur Effects: Disabled (more compatible)");
308 setText(5, decalstoggle ? "Decals: Enabled (slower)" : "Decals: Disabled");
309 setText(6, musictoggle ? "Music: Enabled" : "Music: Disabled");
310 setText(9, invertmouse ? "Invert mouse: Yes" : "Invert mouse: No");
311 setText(10, std::string("Mouse Speed: ") + to_string(int(usermousesensitivity * 5)));
312 setText(11, std::string("Volume: ") + to_string(int(volume * 100)) + "%");
313 setText(13, showdamagebar ? "Damage Bar: On" : "Damage Bar: Off");
314 if ((newdetail == detail) && (newscreenheight == (int)screenheight) && (newscreenwidth == (int)screenwidth)) {
317 setText(8, "Back (some changes take effect next time Lugaru is opened)");
321 void Menu::updateStereoConfigMenu()
323 setText(0, std::string("Stereo mode: ") + StereoModeName(newstereomode));
324 setText(1, std::string("Stereo separation: ") + to_string(stereoseparation));
325 setText(2, std::string("Reverse stereo: ") + (stereoreverse ? "Yes" : "No"));
328 void Menu::updateControlsMenu()
330 setText(0, (string) "Forwards: " + (keyselect == 0 ? "_" : Input::keyToChar(forwardkey)));
331 setText(1, (string) "Back: " + (keyselect == 1 ? "_" : Input::keyToChar(backkey)));
332 setText(2, (string) "Left: " + (keyselect == 2 ? "_" : Input::keyToChar(leftkey)));
333 setText(3, (string) "Right: " + (keyselect == 3 ? "_" : Input::keyToChar(rightkey)));
334 setText(4, (string) "Crouch: " + (keyselect == 4 ? "_" : Input::keyToChar(crouchkey)));
335 setText(5, (string) "Jump: " + (keyselect == 5 ? "_" : Input::keyToChar(jumpkey)));
336 setText(6, (string) "Draw: " + (keyselect == 6 ? "_" : Input::keyToChar(drawkey)));
337 setText(7, (string) "Throw: " + (keyselect == 7 ? "_" : Input::keyToChar(throwkey)));
338 setText(8, (string) "Attack: " + (keyselect == 8 ? "_" : Input::keyToChar(attackkey)));
340 setText(9, (string) "Console: " + (keyselect == 9 ? "_" : Input::keyToChar(consolekey)));
347 2 Menu pause (resume/end game)
349 4 Controls configuration menu
350 5 Main game menu (choose level or challenge)
352 7 User managment menu (select/add)
353 8 Choose difficulty menu
354 9 Challenge level selection menu
355 10 End of the campaign congratulation (is that really a menu?)
356 11 Same that 9 ??? => unused
357 18 stereo configuration
366 addImage(0, Mainmenuitems[0], 150, 480 - 128, 256, 128);
367 addButtonImage(1, Mainmenuitems[mainmenu == 1 ? 1 : 5], 18, 480 - 152 - 32, 128, 32);
368 addButtonImage(2, Mainmenuitems[2], 18, 480 - 228 - 32, 112, 32);
369 addButtonImage(3, Mainmenuitems[mainmenu == 1 ? 3 : 6], 18, 480 - 306 - 32, mainmenu == 1 ? 68 : 132, 32);
372 addButton(0, "", 10 + 20, 440);
373 addButton(14, "", 10 + 400, 440);
374 addButton(1, "", 10 + 60, 405);
375 addButton(2, "", 10 + 70, 370);
376 addButton(4, "", 10, 335);
377 addButton(5, "", 10 + 60, 300);
378 addButton(6, "", 10 + 70, 265);
379 addButton(9, "", 10, 230);
380 addButton(10, "", 20, 195);
381 addButton(11, "", 10 + 60, 160);
382 addButton(13, "", 30, 125);
383 addButton(7, "-Configure Controls-", 10 + 15, 90);
384 addButton(12, "-Configure Stereo -", 10 + 15, 55);
385 addButton(8, "Back", 10, 10);
386 updateSettingsMenu();
389 addButton(0, "", 10, 400);
390 addButton(1, "", 10 + 40, 360);
391 addButton(2, "", 10 + 40, 320);
392 addButton(3, "", 10 + 30, 280);
393 addButton(4, "", 10 + 20, 240);
394 addButton(5, "", 10 + 40, 200);
395 addButton(6, "", 10 + 40, 160);
396 addButton(7, "", 10 + 30, 120);
397 addButton(8, "", 10 + 20, 80);
399 addButton(9, "", 10 + 10, 40);
401 addButton(devtools ? 10 : 9, "Back", 10, 10);
402 updateControlsMenu();
406 addLabel(-1, Account::active().getName(), 5, 400);
407 addButton(1, "Tutorial", 5, 300);
408 addButton(2, "Challenge", 5, 240);
409 addButton(3, "Delete User", 400, 10);
410 addButton(4, "Main Menu", 5, 10);
411 addButton(5, "Change User", 5, 180);
412 addButton(6, "Campaign : " + Account::active().getCurrentCampaign(), 200, 420);
415 //with (2,-5) offset from old code
416 addImage(-1, Mainmenuitems[7], 150 + 2, 60 - 5, 400, 400);
418 int numlevels = Account::active().getCampaignChoicesMade();
419 numlevels += numlevels > 0 ? campaignlevels[numlevels - 1].nextlevel.size() : 1;
420 for (int i = 0; i < numlevels; i++) {
421 XYZ midpoint = campaignlevels[i].getCenter();
422 float itemsize = campaignlevels[i].getWidth();
423 const bool active = (i >= Account::active().getCampaignChoicesMade());
429 XYZ start = campaignlevels[i - 1].getCenter();
430 addMapLine(start.x, start.y, midpoint.x - start.x, midpoint.y - start.y, 0.5, active ? 1 : 0.5, active ? 1 : 0.5, 0, 0);
432 addMapMarker(NB_CAMPAIGN_MENU_ITEM + i, Mapcircletexture,
433 midpoint.x - itemsize / 2, midpoint.y - itemsize / 2, itemsize, itemsize, active ? 1 : 0.5, 0, 0);
436 addMapLabel(-2, campaignlevels[i].description,
437 campaignlevels[i].getStartX() + 10,
438 campaignlevels[i].getStartY() - 4);
443 addLabel(-1, "Are you sure you want to delete this user?", 10, 400);
444 addButton(1, "Yes", 10, 360);
445 addButton(2, "No", 10, 320);
448 if (Account::getNbAccounts() < 8)
449 addButton(0, "New User", 10, 400);
451 addLabel(0, "No More Users", 10, 400);
452 addLabel(-2, "", 20, 400);
453 addButton(Account::getNbAccounts() + 1, "Back", 10, 10);
454 for (int i = 0; i < Account::getNbAccounts(); i++) {
455 addButton(i + 1, Account::get(i).getName(), 10, 340 - 20 * (i + 1));
459 addButton(0, "Easier", 10, 400);
460 addButton(1, "Difficult", 10, 360);
461 addButton(2, "Insane", 10, 320);
464 for (int i = 0; i < numchallengelevels; i++) {
465 string name = "Level ";
466 name += to_string(i + 1);
467 if (name.size() < 17) {
468 name.append((17 - name.size()), ' ');
470 name += to_string(int(Account::active().getHighScore(i)));
471 if (name.size() < 32) {
472 name.append((32 - name.size()), ' ');
474 int fasttime = (int)round(Account::active().getFastTime(i));
475 name += to_string(int((fasttime - fasttime % 60) / 60));
477 if (fasttime % 60 < 10)
479 name += to_string(fasttime % 60);
481 addButton(i, name, 10, 400 - i * 25, i > Account::active().getProgress() ? 0.5 : 1, 0, 0);
484 addButton(-1, " High Score Best Time", 10, 440);
485 addButton(numchallengelevels, "Back", 10, 10);
488 addLabel(0, "Congratulations!", 220, 330);
489 addLabel(1, "You have avenged your family and", 140, 300);
490 addLabel(2, "restored peace to the island of Lugaru.", 110, 270);
491 addButton(3, "Back", 10, 10);
492 addLabel(4, string("Your score: ") + to_string((int)Account::active().getCampaignScore()), 190, 200);
493 addLabel(5, string("Highest score: ") + to_string((int)Account::active().getCampaignHighScore()), 190, 180);
496 addButton(0, "", 70, 400);
497 addButton(1, "", 10, 360);
498 addButton(2, "", 40, 320);
499 addButton(3, "Back", 10, 10);
500 updateStereoConfigMenu();
508 if (Input::isKeyPressed(SDL_SCANCODE_ESCAPE) &&
509 (mainmenu >= 3) && (mainmenu != 8) && !((mainmenu == 7) && entername)) {
511 //finished with settings menu
516 if (mainmenu >= 3 && mainmenu != 8) {
524 mainmenu = gameon ? 2 : 1;
540 selected = getSelected(mousecoordh * 640 / screenwidth, 480 - mousecoordv * 480 / screenheight);
542 // some specific case where we do something even if the left mouse button is not pressed.
543 if ((mainmenu == 5) && (endgame == 2)) {
544 Account::active().endGame();
549 if (mainmenu == 18 && Input::isKeyPressed(MOUSEBUTTON_RIGHT) && selected == 1) {
550 stereoseparation -= 0.001;
551 updateStereoConfigMenu();
554 static int oldmainmenu = mainmenu;
556 if (Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus
557 set<pair<int, int>>::iterator newscreenresolution;
563 if (gameon) { //resume
565 pause_sound(stream_menutheme);
566 resume_stream(leveltheme);
568 fireSound(firestartsound);
570 mainmenu = (Account::hasActive() ? 5 : 7);
582 if (newscreenwidth > 3000)
583 newscreenwidth = screenwidth;
584 if (newscreenwidth < 0)
585 newscreenwidth = screenwidth;
586 if (newscreenheight > 3000)
587 newscreenheight = screenheight;
588 if (newscreenheight < 0)
589 newscreenheight = screenheight;
594 if (gameon) { //end game
599 pause_sound(stream_menutheme);
608 newscreenresolution = resolutions.find(make_pair(newscreenwidth, newscreenheight));
609 /* Next one (end() + 1 is also end() so the ++ is safe even if it was not found) */
610 newscreenresolution++;
611 if (newscreenresolution == resolutions.end()) {
612 /* It was the last one (or not found), go back to the beginning */
613 newscreenresolution = resolutions.begin();
615 newscreenwidth = newscreenresolution->first;
616 newscreenheight = newscreenresolution->second;
629 ismotionblur = !ismotionblur;
632 decalstoggle = !decalstoggle;
635 musictoggle = !musictoggle;
637 emit_stream_np(stream_menutheme);
639 pause_sound(leveltheme);
640 pause_sound(stream_fighttheme);
641 pause_sound(stream_menutheme);
643 for (int i = 0; i < 4; i++) {
644 oldmusicvolume[i] = 0;
658 mainmenu = gameon ? 2 : 1;
661 invertmouse = !invertmouse;
664 usermousesensitivity += .2;
665 if (usermousesensitivity > 2)
666 usermousesensitivity = .2;
670 if (volume > 1.0001f)
672 OPENAL_SetSFXMasterVolume((int)(volume * 255));
676 newstereomode = stereomode;
681 showdamagebar = !showdamagebar;
687 updateSettingsMenu();
692 if (selected < (devtools ? 10 : 9) && keyselect == -1)
693 keyselect = selected;
696 if (selected == (devtools ? 10 : 9)) {
701 updateControlsMenu();
706 if ((selected - NB_CAMPAIGN_MENU_ITEM >= Account::active().getCampaignChoicesMade())) {
717 whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade();
718 actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0);
719 visibleloading = true;
721 LoadLevel(campaignlevels[actuallevel].mapname.c_str());
725 pause_sound(stream_menutheme);
743 pause_sound(stream_menutheme);
752 mainmenu = (gameon ? 2 : 1);
758 vector<string> campaigns = ListCampaigns();
759 vector<string>::iterator c;
760 if ((c = find(campaigns.begin(), campaigns.end(), Account::active().getCurrentCampaign())) == campaigns.end()) {
761 if (!campaigns.empty())
762 Account::active().setCurrentCampaign(campaigns.front());
765 if (c == campaigns.end())
766 c = campaigns.begin();
767 Account::active().setCurrentCampaign(*c);
777 Account::destroyActive();
779 } else if (selected == 2) {
786 if (selected == 0 && Account::getNbAccounts() < 8) {
788 } else if (selected < Account::getNbAccounts() + 1) {
791 Account::setActive(selected - 1);
792 } else if (selected == Account::getNbAccounts() + 1) {
794 if (Account::hasActive()) {
808 Account::active().setDifficulty(selected);
812 if (selected < numchallengelevels && selected <= Account::active().getProgress()) {
820 targetlevel = selected;
831 pause_sound(stream_menutheme);
833 if (selected == numchallengelevels) {
848 stereoseparation += 0.001;
852 newstereomode = (StereoMode)(newstereomode + 1);
853 while (!CanInitStereo(newstereomode)) {
854 printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode).c_str(), newstereomode);
855 newstereomode = (StereoMode)(newstereomode + 1);
856 if (newstereomode >= stereoCount)
857 newstereomode = stereoNone;
859 } else if (selected == 2) {
860 stereoreverse = !stereoreverse;
861 } else if (selected == 3) {
865 stereomode = newstereomode;
866 InitStereo(stereomode);
869 updateStereoConfigMenu();
874 OPENAL_SetFrequency(channels[stream_menutheme]);
877 inputText(newusername, &newuserselected);
878 if (!waiting) { // the input as finished
879 if (!newusername.empty()) { // with enter
880 Account::add(string(newusername));
886 fireSound(firestartsound);
896 newuserblinkdelay -= multiplier;
897 if (newuserblinkdelay <= 0) {
898 newuserblinkdelay = .3;
899 newuserblink = !newuserblink;
904 setText(0, newusername, 20, 400, -1, -1);
905 setText(-2, newuserblink ? "_" : "", 20 + newuserselected * 10, 400, -1, -1);
908 if (oldmainmenu != mainmenu)
910 oldmainmenu = mainmenu;
913 int setKeySelected_thread(void*)
915 using namespace Game;
918 while (scancode == -1) {
919 SDL_WaitEvent(&evenement);
920 switch (evenement.type) {
922 scancode = evenement.key.keysym.scancode;
924 case SDL_MOUSEBUTTONDOWN:
925 scancode = SDL_NUM_SCANCODES + evenement.button.button;
931 if (scancode != SDL_SCANCODE_ESCAPE) {
935 forwardkey = scancode;
947 crouchkey = scancode;
959 attackkey = scancode;
962 consolekey = scancode;
974 void Menu::setKeySelected()
977 printf("launch thread\n");
978 SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread, NULL, NULL);
979 if (thread == NULL) {
980 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());