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;
132 void Menu::setText(int id, const string& text, int x, int y, int w, int h)
134 for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
140 it->w = it->text.length() * 10;
150 int Menu::getSelected(int mousex, int mousey)
152 for (vector<MenuItem>::reverse_iterator it = items.rbegin(); it != items.rend(); it++) {
153 if (it->type == MenuItem::BUTTON || it->type == MenuItem::IMAGEBUTTON || it->type == MenuItem::MAPMARKER) {
156 if (it->type == MenuItem::MAPMARKER) {
160 if (mx >= it->x && mx < it->x + it->w && my >= it->y && my < it->y + it->h) {
168 void Menu::handleFadeEffect()
170 for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
171 if (it->id == Game::selected) {
172 it->effectfade += multiplier * 5;
173 if (it->effectfade > 1) {
177 it->effectfade -= multiplier * 5;
178 if (it->effectfade < 0) {
185 void Menu::drawItems()
188 glEnable(GL_TEXTURE_2D);
189 glEnable(GL_ALPHA_TEST);
191 for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
193 case MenuItem::IMAGE:
194 case MenuItem::IMAGEBUTTON:
195 case MenuItem::MAPMARKER:
196 glColor4f(it->r, it->g, it->b, 1);
198 if (it->type == MenuItem::MAPMARKER) {
199 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
200 glTranslatef(2.5, -4.5, 0); //from old code
202 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
205 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
206 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
209 glVertex3f(it->x, it->y, 0);
211 glVertex3f(it->x + it->w, it->y, 0);
213 glVertex3f(it->x + it->w, it->y + it->h, 0);
215 glVertex3f(it->x, it->y + it->h, 0);
217 if (it->type != MenuItem::IMAGE) {
218 //mouseover highlight
219 for (int i = 0; i < 10; i++) {
220 if (1 - ((float)i) / 10 - (1 - it->effectfade) > 0) {
221 glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade)) * .25);
224 glVertex3f(it->x - ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
226 glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
228 glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
230 glVertex3f(it->x - ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
237 case MenuItem::LABEL:
238 case MenuItem::BUTTON:
239 glColor4f(it->r, it->g, it->b, 1);
240 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
241 Game::text->glPrint(it->x, it->y, it->text.c_str(), 0, 1, 640, 480);
242 if (it->type != MenuItem::LABEL) {
243 //mouseover highlight
244 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
245 for (int i = 0; i < 15; i++) {
246 if (1 - ((float)i) / 15 - (1 - it->effectfade) > 0) {
247 glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade)) * .25);
248 Game::text->glPrint(it->x - ((float)i), it->y, it->text.c_str(), 0, 1 + ((float)i) / 70, 640, 480);
253 case MenuItem::MAPLABEL:
254 Game::text->glPrintOutlined(0.9, 0, 0, 1, it->x, it->y, it->text.c_str(), 0, 0.6, 640, 480);
256 case MenuItem::MAPLINE: {
262 lineend.x = it->x + it->w;
263 lineend.y = it->y + it->h;
265 XYZ offset = lineend - linestart;
268 offset = DoRotation(offset, 0, 0, 90);
271 linestart += fac * 4 * it->linestartsize;
272 lineend -= fac * 4 * it->lineendsize;
274 glDisable(GL_TEXTURE_2D);
275 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
276 glColor4f(it->r, it->g, it->b, 1);
278 glTranslatef(2, -5, 0); //from old code
280 glVertex3f(linestart.x - offset.x * it->linestartsize, linestart.y - offset.y * it->linestartsize, 0.0f);
281 glVertex3f(linestart.x + offset.x * it->linestartsize, linestart.y + offset.y * it->linestartsize, 0.0f);
282 glVertex3f(lineend.x + offset.x * it->lineendsize, lineend.y + offset.y * it->lineendsize, 0.0f);
283 glVertex3f(lineend.x - offset.x * it->lineendsize, lineend.y - offset.y * it->lineendsize, 0.0f);
286 glEnable(GL_TEXTURE_2D);
295 void Menu::updateSettingsMenu()
297 std::string sbuf = std::string("Resolution: ") + to_string(newscreenwidth) + "*" + to_string(newscreenheight);
298 if (((float)newscreenwidth <= (float)newscreenheight * 1.61) && ((float)newscreenwidth >= (float)newscreenheight * 1.59)) {
299 sbuf += " (widescreen)";
302 setText(14, fullscreen ? "Fullscreen: On" : "Fullscreen: Off");
303 if (newdetail == 0) {
304 setText(1, "Detail: Low");
306 if (newdetail == 1) {
307 setText(1, "Detail: Medium");
309 if (newdetail == 2) {
310 setText(1, "Detail: High");
312 if (bloodtoggle == 0) {
313 setText(2, "Blood: Off");
315 if (bloodtoggle == 1) {
316 setText(2, "Blood: On, low detail");
318 if (bloodtoggle == 2) {
319 setText(2, "Blood: On, high detail (slower)");
321 setText(4, ismotionblur ? "Blur Effects: Enabled (less compatible)" : "Blur Effects: Disabled (more compatible)");
322 setText(5, decalstoggle ? "Decals: Enabled (slower)" : "Decals: Disabled");
323 setText(6, musictoggle ? "Music: Enabled" : "Music: Disabled");
324 setText(9, invertmouse ? "Invert mouse: Yes" : "Invert mouse: No");
325 setText(10, std::string("Mouse Speed: ") + to_string(int(usermousesensitivity * 5)));
326 setText(11, std::string("Volume: ") + to_string(int(volume * 100)) + "%");
327 setText(13, showdamagebar ? "Damage Bar: On" : "Damage Bar: Off");
328 if ((newdetail == detail) && (newscreenheight == (int)screenheight) && (newscreenwidth == (int)screenwidth)) {
331 setText(8, "Back (some changes take effect next time Lugaru is opened)");
335 void Menu::updateStereoConfigMenu()
337 setText(0, std::string("Stereo mode: ") + StereoModeName(newstereomode));
338 setText(1, std::string("Stereo separation: ") + to_string(stereoseparation));
339 setText(2, std::string("Reverse stereo: ") + (stereoreverse ? "Yes" : "No"));
342 void Menu::updateControlsMenu()
344 setText(0, (string) "Forwards: " + (keyselect == 0 ? "_" : Input::keyToChar(forwardkey)));
345 setText(1, (string) "Back: " + (keyselect == 1 ? "_" : Input::keyToChar(backkey)));
346 setText(2, (string) "Left: " + (keyselect == 2 ? "_" : Input::keyToChar(leftkey)));
347 setText(3, (string) "Right: " + (keyselect == 3 ? "_" : Input::keyToChar(rightkey)));
348 setText(4, (string) "Crouch: " + (keyselect == 4 ? "_" : Input::keyToChar(crouchkey)));
349 setText(5, (string) "Jump: " + (keyselect == 5 ? "_" : Input::keyToChar(jumpkey)));
350 setText(6, (string) "Draw: " + (keyselect == 6 ? "_" : Input::keyToChar(drawkey)));
351 setText(7, (string) "Throw: " + (keyselect == 7 ? "_" : Input::keyToChar(throwkey)));
352 setText(8, (string) "Attack: " + (keyselect == 8 ? "_" : Input::keyToChar(attackkey)));
354 setText(9, (string) "Console: " + (keyselect == 9 ? "_" : Input::keyToChar(consolekey)));
361 2 Menu pause (resume/end game)
363 4 Controls configuration menu
364 5 Main game menu (choose level or challenge)
366 7 User managment menu (select/add)
367 8 Choose difficulty menu
368 9 Challenge level selection menu
369 10 End of the campaign congratulation (is that really a menu?)
370 11 Same that 9 ??? => unused
371 18 stereo configuration
380 addImage(0, Mainmenuitems[0], 150, 480 - 128, 256, 128);
381 addButtonImage(1, Mainmenuitems[mainmenu == 1 ? 1 : 5], 18, 480 - 152 - 32, 128, 32);
382 addButtonImage(2, Mainmenuitems[2], 18, 480 - 228 - 32, 112, 32);
383 addButtonImage(3, Mainmenuitems[mainmenu == 1 ? 3 : 6], 18, 480 - 306 - 32, mainmenu == 1 ? 68 : 132, 32);
386 addButton(0, "", 10 + 20, 440);
387 addButton(14, "", 10 + 400, 440);
388 addButton(1, "", 10 + 60, 405);
389 addButton(2, "", 10 + 70, 370);
390 addButton(4, "", 10, 335);
391 addButton(5, "", 10 + 60, 300);
392 addButton(6, "", 10 + 70, 265);
393 addButton(9, "", 10, 230);
394 addButton(10, "", 20, 195);
395 addButton(11, "", 10 + 60, 160);
396 addButton(13, "", 30, 125);
397 addButton(7, "-Configure Controls-", 10 + 15, 90);
398 addButton(12, "-Configure Stereo -", 10 + 15, 55);
399 addButton(8, "Back", 10, 10);
400 updateSettingsMenu();
403 addButton(0, "", 10, 400);
404 addButton(1, "", 10 + 40, 360);
405 addButton(2, "", 10 + 40, 320);
406 addButton(3, "", 10 + 30, 280);
407 addButton(4, "", 10 + 20, 240);
408 addButton(5, "", 10 + 40, 200);
409 addButton(6, "", 10 + 40, 160);
410 addButton(7, "", 10 + 30, 120);
411 addButton(8, "", 10 + 20, 80);
413 addButton(9, "", 10 + 10, 40);
415 addButton(devtools ? 10 : 9, "Back", 10, 10);
416 updateControlsMenu();
420 addLabel(-1, Account::active().getName(), 5, 400);
421 addButton(1, "Tutorial", 5, 300);
422 addButton(2, "Challenge", 5, 240);
423 addButton(3, "Delete User", 400, 10);
424 addButton(4, "Main Menu", 5, 10);
425 addButton(5, "Change User", 5, 180);
426 addButton(6, "Campaign : " + Account::active().getCurrentCampaign(), 200, 420);
429 //with (2,-5) offset from old code
430 addImage(-1, Mainmenuitems[7], 150 + 2, 60 - 5, 400, 400);
432 int numlevels = Account::active().getCampaignChoicesMade();
433 numlevels += numlevels > 0 ? campaignlevels[numlevels - 1].nextlevel.size() : 1;
434 for (int i = 0; i < numlevels; i++) {
435 XYZ midpoint = campaignlevels[i].getCenter();
436 float itemsize = campaignlevels[i].getWidth();
437 const bool active = (i >= Account::active().getCampaignChoicesMade());
443 XYZ start = campaignlevels[i - 1].getCenter();
444 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);
446 addMapMarker(NB_CAMPAIGN_MENU_ITEM + i, Mapcircletexture,
447 midpoint.x - itemsize / 2, midpoint.y - itemsize / 2, itemsize, itemsize, active ? 1 : 0.5, 0, 0);
450 addMapLabel(-2, campaignlevels[i].description,
451 campaignlevels[i].getStartX() + 10,
452 campaignlevels[i].getStartY() - 4);
457 addLabel(-1, "Are you sure you want to delete this user?", 10, 400);
458 addButton(1, "Yes", 10, 360);
459 addButton(2, "No", 10, 320);
462 if (Account::getNbAccounts() < 8) {
463 addButton(0, "New User", 10, 400);
465 addLabel(0, "No More Users", 10, 400);
467 addLabel(-2, "", 20, 400);
468 addButton(Account::getNbAccounts() + 1, "Back", 10, 10);
469 for (int i = 0; i < Account::getNbAccounts(); i++) {
470 addButton(i + 1, Account::get(i).getName(), 10, 340 - 20 * (i + 1));
474 addButton(0, "Easier", 10, 400);
475 addButton(1, "Difficult", 10, 360);
476 addButton(2, "Insane", 10, 320);
479 for (int i = 0; i < numchallengelevels; i++) {
480 string name = "Level ";
481 name += to_string(i + 1);
482 if (name.size() < 17) {
483 name.append((17 - name.size()), ' ');
485 name += to_string(int(Account::active().getHighScore(i)));
486 if (name.size() < 32) {
487 name.append((32 - name.size()), ' ');
489 int fasttime = (int)round(Account::active().getFastTime(i));
490 name += to_string(int((fasttime - fasttime % 60) / 60));
492 if (fasttime % 60 < 10) {
495 name += to_string(fasttime % 60);
497 addButton(i, name, 10, 400 - i * 25, i > Account::active().getProgress() ? 0.5 : 1, 0, 0);
500 addButton(-1, " High Score Best Time", 10, 440);
501 addButton(numchallengelevels, "Back", 10, 10);
504 addLabel(0, "Congratulations!", 220, 330);
505 addLabel(1, "You have avenged your family and", 140, 300);
506 addLabel(2, "restored peace to the island of Lugaru.", 110, 270);
507 addButton(3, "Back", 10, 10);
508 addLabel(4, string("Your score: ") + to_string((int)Account::active().getCampaignScore()), 190, 200);
509 addLabel(5, string("Highest score: ") + to_string((int)Account::active().getCampaignHighScore()), 190, 180);
512 addButton(0, "", 70, 400);
513 addButton(1, "", 10, 360);
514 addButton(2, "", 40, 320);
515 addButton(3, "Back", 10, 10);
516 updateStereoConfigMenu();
524 if (Input::isKeyPressed(SDL_SCANCODE_ESCAPE) &&
525 (mainmenu >= 3) && (mainmenu != 8) && !((mainmenu == 7) && entername)) {
527 //finished with settings menu
532 if (mainmenu >= 3 && mainmenu != 8) {
540 mainmenu = gameon ? 2 : 1;
556 selected = getSelected(mousecoordh * 640 / screenwidth, 480 - mousecoordv * 480 / screenheight);
558 // some specific case where we do something even if the left mouse button is not pressed.
559 if ((mainmenu == 5) && (endgame == 2)) {
560 Account::active().endGame();
563 if (mainmenu == 10) {
566 if (mainmenu == 18 && Input::isKeyPressed(MOUSEBUTTON_RIGHT) && selected == 1) {
567 stereoseparation -= 0.001;
568 updateStereoConfigMenu();
571 static int oldmainmenu = mainmenu;
573 if (Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus
574 set<pair<int, int>>::iterator newscreenresolution;
580 if (gameon) { //resume
582 pause_sound(stream_menutheme);
583 resume_stream(leveltheme);
585 fireSound(firestartsound);
587 mainmenu = (Account::hasActive() ? 5 : 7);
601 if (newscreenwidth > 3000) {
602 newscreenwidth = screenwidth;
604 if (newscreenwidth < 0) {
605 newscreenwidth = screenwidth;
607 if (newscreenheight > 3000) {
608 newscreenheight = screenheight;
610 if (newscreenheight < 0) {
611 newscreenheight = screenheight;
617 if (gameon) { //end game
622 pause_sound(stream_menutheme);
631 newscreenresolution = resolutions.find(make_pair(newscreenwidth, newscreenheight));
632 /* Next one (end() + 1 is also end() so the ++ is safe even if it was not found) */
633 newscreenresolution++;
634 if (newscreenresolution == resolutions.end()) {
635 /* It was the last one (or not found), go back to the beginning */
636 newscreenresolution = resolutions.begin();
638 newscreenwidth = newscreenresolution->first;
639 newscreenheight = newscreenresolution->second;
649 if (bloodtoggle > 2) {
654 ismotionblur = !ismotionblur;
657 decalstoggle = !decalstoggle;
660 musictoggle = !musictoggle;
662 emit_stream_np(stream_menutheme);
664 pause_sound(leveltheme);
665 pause_sound(stream_fighttheme);
666 pause_sound(stream_menutheme);
668 for (int i = 0; i < 4; i++) {
669 oldmusicvolume[i] = 0;
683 mainmenu = gameon ? 2 : 1;
686 invertmouse = !invertmouse;
689 usermousesensitivity += .2;
690 if (usermousesensitivity > 2) {
691 usermousesensitivity = .2;
696 if (volume > 1.0001f) {
699 OPENAL_SetSFXMasterVolume((int)(volume * 255));
703 newstereomode = stereomode;
708 showdamagebar = !showdamagebar;
714 updateSettingsMenu();
719 if (selected < (devtools ? 10 : 9) && keyselect == -1) {
720 keyselect = selected;
722 if (keyselect != -1) {
725 if (selected == (devtools ? 10 : 9)) {
730 updateControlsMenu();
735 if ((selected - NB_CAMPAIGN_MENU_ITEM >= Account::active().getCampaignChoicesMade())) {
746 whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade();
747 actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0);
748 visibleloading = true;
750 LoadLevel(campaignlevels[actuallevel].mapname.c_str());
754 pause_sound(stream_menutheme);
772 pause_sound(stream_menutheme);
781 mainmenu = (gameon ? 2 : 1);
787 vector<string> campaigns = ListCampaigns();
788 vector<string>::iterator c;
789 if ((c = find(campaigns.begin(), campaigns.end(), Account::active().getCurrentCampaign())) == campaigns.end()) {
790 if (!campaigns.empty()) {
791 Account::active().setCurrentCampaign(campaigns.front());
795 if (c == campaigns.end()) {
796 c = campaigns.begin();
798 Account::active().setCurrentCampaign(*c);
808 Account::destroyActive();
810 } else if (selected == 2) {
817 if (selected == 0 && Account::getNbAccounts() < 8) {
819 } else if (selected < Account::getNbAccounts() + 1) {
822 Account::setActive(selected - 1);
823 } else if (selected == Account::getNbAccounts() + 1) {
825 if (Account::hasActive()) {
839 Account::active().setDifficulty(selected);
844 if (selected < numchallengelevels && selected <= Account::active().getProgress()) {
852 targetlevel = selected;
863 pause_sound(stream_menutheme);
865 if (selected == numchallengelevels) {
880 stereoseparation += 0.001;
884 newstereomode = (StereoMode)(newstereomode + 1);
885 while (!CanInitStereo(newstereomode)) {
886 printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode).c_str(), newstereomode);
887 newstereomode = (StereoMode)(newstereomode + 1);
888 if (newstereomode >= stereoCount) {
889 newstereomode = stereoNone;
892 } else if (selected == 2) {
893 stereoreverse = !stereoreverse;
894 } else if (selected == 3) {
898 stereomode = newstereomode;
899 InitStereo(stereomode);
902 updateStereoConfigMenu();
907 OPENAL_SetFrequency(channels[stream_menutheme]);
910 inputText(newusername, &newuserselected);
911 if (!waiting) { // the input as finished
912 if (!newusername.empty()) { // with enter
913 Account::add(string(newusername));
919 fireSound(firestartsound);
929 newuserblinkdelay -= multiplier;
930 if (newuserblinkdelay <= 0) {
931 newuserblinkdelay = .3;
932 newuserblink = !newuserblink;
937 setText(0, newusername, 20, 400, -1, -1);
938 setText(-2, newuserblink ? "_" : "", 20 + newuserselected * 10, 400, -1, -1);
941 if (oldmainmenu != mainmenu) {
944 oldmainmenu = mainmenu;
947 int setKeySelected_thread(void*)
949 using namespace Game;
952 while (scancode == -1) {
953 SDL_WaitEvent(&evenement);
954 switch (evenement.type) {
956 scancode = evenement.key.keysym.scancode;
958 case SDL_MOUSEBUTTONDOWN:
959 scancode = SDL_NUM_SCANCODES + evenement.button.button;
965 if (scancode != SDL_SCANCODE_ESCAPE) {
969 forwardkey = scancode;
981 crouchkey = scancode;
993 attackkey = scancode;
996 consolekey = scancode;
1008 void Menu::setKeySelected()
1011 printf("launch thread\n");
1012 SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread, NULL, NULL);
1013 if (thread == NULL) {
1014 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());