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);
288 void Menu::updateSettingsMenu()
290 std::string sbuf = std::string("Resolution: ") + to_string(newscreenwidth) + "*" + to_string(newscreenheight);
291 if (((float)newscreenwidth <= (float)newscreenheight * 1.61) && ((float)newscreenwidth >= (float)newscreenheight * 1.59)) {
292 sbuf += " (widescreen)";
295 setText(14, fullscreen ? "Fullscreen: On" : "Fullscreen: Off");
296 if (newdetail == 0) setText(1, "Detail: Low");
297 if (newdetail == 1) setText(1, "Detail: Medium");
298 if (newdetail == 2) setText(1, "Detail: High");
299 if (bloodtoggle == 0) setText(2, "Blood: Off");
300 if (bloodtoggle == 1) setText(2, "Blood: On, low detail");
301 if (bloodtoggle == 2) setText(2, "Blood: On, high detail (slower)");
302 setText(4, ismotionblur ? "Blur Effects: Enabled (less compatible)" : "Blur Effects: Disabled (more compatible)");
303 setText(5, decalstoggle ? "Decals: Enabled (slower)" : "Decals: Disabled");
304 setText(6, musictoggle ? "Music: Enabled" : "Music: Disabled");
305 setText(9, invertmouse ? "Invert mouse: Yes" : "Invert mouse: No");
306 setText(10, std::string("Mouse Speed: ") + to_string(int(usermousesensitivity * 5)));
307 setText(11, std::string("Volume: ") + to_string(int(volume * 100)) + "%");
308 setText(13, showdamagebar ? "Damage Bar: On" : "Damage Bar: Off");
309 if ((newdetail == detail) && (newscreenheight == (int)screenheight) && (newscreenwidth == (int)screenwidth)) {
312 setText(8, "Back (some changes take effect next time Lugaru is opened)");
316 void Menu::updateStereoConfigMenu()
318 setText(0, std::string("Stereo mode: ") + StereoModeName(newstereomode));
319 setText(1, std::string("Stereo separation: ") + to_string(stereoseparation));
320 setText(2, std::string("Reverse stereo: ") + (stereoreverse ? "Yes" : "No"));
323 void Menu::updateControlsMenu()
325 setText(0, (string)"Forwards: " + (keyselect == 0 ? "_" : Input::keyToChar(forwardkey)));
326 setText(1, (string)"Back: " + (keyselect == 1 ? "_" : Input::keyToChar(backkey)));
327 setText(2, (string)"Left: " + (keyselect == 2 ? "_" : Input::keyToChar(leftkey)));
328 setText(3, (string)"Right: " + (keyselect == 3 ? "_" : Input::keyToChar(rightkey)));
329 setText(4, (string)"Crouch: " + (keyselect == 4 ? "_" : Input::keyToChar(crouchkey)));
330 setText(5, (string)"Jump: " + (keyselect == 5 ? "_" : Input::keyToChar(jumpkey)));
331 setText(6, (string)"Draw: " + (keyselect == 6 ? "_" : Input::keyToChar(drawkey)));
332 setText(7, (string)"Throw: " + (keyselect == 7 ? "_" : Input::keyToChar(throwkey)));
333 setText(8, (string)"Attack: " + (keyselect == 8 ? "_" : Input::keyToChar(attackkey)));
335 setText(9, (string)"Console: " + (keyselect == 9 ? "_" : Input::keyToChar(consolekey)));
342 2 Menu pause (resume/end game)
344 4 Controls configuration menu
345 5 Main game menu (choose level or challenge)
347 7 User managment menu (select/add)
348 8 Choose difficulty menu
349 9 Challenge level selection menu
350 10 End of the campaign congratulation (is that really a menu?)
351 11 Same that 9 ??? => unused
352 18 stereo configuration
361 addImage(0, Mainmenuitems[0], 150, 480 - 128, 256, 128);
362 addButtonImage(1, Mainmenuitems[mainmenu == 1 ? 1 : 5], 18, 480 - 152 - 32, 128, 32);
363 addButtonImage(2, Mainmenuitems[2], 18, 480 - 228 - 32, 112, 32);
364 addButtonImage(3, Mainmenuitems[mainmenu == 1 ? 3 : 6], 18, 480 - 306 - 32, mainmenu == 1 ? 68 : 132, 32);
367 addButton( 0, "", 10 + 20, 440);
368 addButton(14, "", 10 + 400, 440);
369 addButton( 1, "", 10 + 60, 405);
370 addButton( 2, "", 10 + 70, 370);
371 addButton( 4, "", 10 , 335);
372 addButton( 5, "", 10 + 60, 300);
373 addButton( 6, "", 10 + 70, 265);
374 addButton( 9, "", 10 , 230);
375 addButton(10, "", 20 , 195);
376 addButton(11, "", 10 + 60, 160);
377 addButton(13, "", 30 , 125);
378 addButton( 7, "-Configure Controls-", 10 + 15, 90);
379 addButton(12, "-Configure Stereo -", 10 + 15, 55);
380 addButton(8, "Back", 10, 10);
381 updateSettingsMenu();
384 addButton(0, "", 10 , 400);
385 addButton(1, "", 10 + 40, 360);
386 addButton(2, "", 10 + 40, 320);
387 addButton(3, "", 10 + 30, 280);
388 addButton(4, "", 10 + 20, 240);
389 addButton(5, "", 10 + 40, 200);
390 addButton(6, "", 10 + 40, 160);
391 addButton(7, "", 10 + 30, 120);
392 addButton(8, "", 10 + 20, 80);
394 addButton(9, "", 10 + 10, 40);
396 addButton(devtools ? 10 : 9, "Back", 10, 10);
397 updateControlsMenu();
401 addLabel(-1, Account::active().getName(), 5, 400);
402 addButton(1, "Tutorial", 5, 300);
403 addButton(2, "Challenge", 5, 240);
404 addButton(3, "Delete User", 400, 10);
405 addButton(4, "Main Menu", 5, 10);
406 addButton(5, "Change User", 5, 180);
407 addButton(6, "Campaign : " + Account::active().getCurrentCampaign(), 200, 420);
410 //with (2,-5) offset from old code
411 addImage(-1, Mainmenuitems[7], 150 + 2, 60 - 5, 400, 400);
413 int numlevels = Account::active().getCampaignChoicesMade();
414 numlevels += numlevels > 0 ? campaignlevels[numlevels - 1].nextlevel.size() : 1;
415 for (int i = 0; i < numlevels; i++) {
416 XYZ midpoint = campaignlevels[i].getCenter();
417 float itemsize = campaignlevels[i].getWidth();
418 const bool active = (i >= Account::active().getCampaignChoicesMade());
424 XYZ start = campaignlevels[i - 1].getCenter();
425 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);
427 addMapMarker(NB_CAMPAIGN_MENU_ITEM + i, Mapcircletexture,
428 midpoint.x - itemsize / 2, midpoint.y - itemsize / 2, itemsize, itemsize, active ? 1 : 0.5, 0, 0);
431 addMapLabel(-2, campaignlevels[i].description,
432 campaignlevels[i].getStartX() + 10,
433 campaignlevels[i].getStartY() - 4);
439 addLabel(-1, "Are you sure you want to delete this user?", 10, 400);
440 addButton(1, "Yes", 10, 360);
441 addButton(2, "No", 10, 320);
444 if (Account::getNbAccounts() < 8)
445 addButton(0, "New User", 10, 400);
447 addLabel(0, "No More Users", 10, 400);
448 addLabel(-2, "", 20, 400);
449 addButton(Account::getNbAccounts() + 1, "Back", 10, 10);
450 for (int i = 0; i < Account::getNbAccounts(); i++) {
451 addButton(i + 1, Account::get(i).getName(), 10, 340 - 20 * (i + 1));
455 addButton(0, "Easier", 10, 400);
456 addButton(1, "Difficult", 10, 360);
457 addButton(2, "Insane", 10, 320);
460 for (int i = 0; i < numchallengelevels; i++) {
461 string name = "Level ";
462 name += to_string(i + 1);
463 if (name.size() < 17) {
464 name.append((17 - name.size()), ' ');
466 name += to_string(int(Account::active().getHighScore(i)));
467 if (name.size() < 32) {
468 name.append((32 - name.size()), ' ');
470 int fasttime = (int)round(Account::active().getFastTime(i));
471 name += to_string(int((fasttime - fasttime % 60) / 60));
473 if (fasttime % 60 < 10)
475 name += to_string(fasttime % 60);
477 addButton(i, name, 10, 400 - i * 25, i > Account::active().getProgress() ? 0.5 : 1, 0, 0);
480 addButton(-1, " High Score Best Time", 10, 440);
481 addButton(numchallengelevels, "Back", 10, 10);
484 addLabel(0, "Congratulations!", 220, 330);
485 addLabel(1, "You have avenged your family and", 140, 300);
486 addLabel(2, "restored peace to the island of Lugaru.", 110, 270);
487 addButton(3, "Back", 10, 10);
488 addLabel(4, string("Your score: ") + to_string((int)Account::active().getCampaignScore()), 190, 200);
489 addLabel(5, string("Highest score: ") + to_string((int)Account::active().getCampaignHighScore()), 190, 180);
493 addButton(0, "", 70, 400);
494 addButton(1, "", 10, 360);
495 addButton(2, "", 40, 320);
496 addButton(3, "Back", 10, 10);
497 updateStereoConfigMenu();
505 if (Input::isKeyPressed(SDL_SCANCODE_ESCAPE) &&
506 (mainmenu >= 3) && (mainmenu != 8) && !((mainmenu == 7) && entername)) {
508 //finished with settings menu
513 if (mainmenu >= 3 && mainmenu != 8) {
521 mainmenu = gameon ? 2 : 1;
537 selected = getSelected(mousecoordh * 640 / screenwidth, 480 - mousecoordv * 480 / screenheight);
539 // some specific case where we do something even if the left mouse button is not pressed.
540 if ((mainmenu == 5) && (endgame == 2)) {
541 Account::active().endGame();
546 if (mainmenu == 18 && Input::isKeyPressed(MOUSEBUTTON_RIGHT) && selected == 1) {
547 stereoseparation -= 0.001;
548 updateStereoConfigMenu();
551 static int oldmainmenu = mainmenu;
553 if (Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus
554 set<pair<int,int>>::iterator newscreenresolution;
560 if (gameon) { //resume
562 pause_sound(stream_menutheme);
563 resume_stream(leveltheme);
565 fireSound(firestartsound);
567 mainmenu = (Account::hasActive() ? 5 : 7);
579 if (newscreenwidth > 3000)
580 newscreenwidth = screenwidth;
581 if (newscreenwidth < 0)
582 newscreenwidth = screenwidth;
583 if (newscreenheight > 3000)
584 newscreenheight = screenheight;
585 if (newscreenheight < 0)
586 newscreenheight = screenheight;
591 if (gameon) { //end game
596 pause_sound(stream_menutheme);
605 newscreenresolution = resolutions.find(make_pair(newscreenwidth, newscreenheight));
606 /* Next one (end() + 1 is also end() so the ++ is safe even if it was not found) */
607 newscreenresolution++;
608 if (newscreenresolution == resolutions.end()) {
609 /* It was the last one (or not found), go back to the beginning */
610 newscreenresolution = resolutions.begin();
612 newscreenwidth = newscreenresolution->first;
613 newscreenheight = newscreenresolution->second;
626 ismotionblur = !ismotionblur;
629 decalstoggle = !decalstoggle;
632 musictoggle = !musictoggle;
634 emit_stream_np(stream_menutheme);
636 pause_sound(leveltheme);
637 pause_sound(stream_fighttheme);
638 pause_sound(stream_menutheme);
640 for (int i = 0; i < 4; i++) {
641 oldmusicvolume[i] = 0;
655 mainmenu = gameon ? 2 : 1;
658 invertmouse = !invertmouse;
661 usermousesensitivity += .2;
662 if (usermousesensitivity > 2)
663 usermousesensitivity = .2;
667 if (volume > 1.0001f)
669 OPENAL_SetSFXMasterVolume((int)(volume * 255));
673 newstereomode = stereomode;
678 showdamagebar = !showdamagebar;
684 updateSettingsMenu();
689 if (selected < (devtools ? 10 : 9) && keyselect == -1)
690 keyselect = selected;
693 if (selected == (devtools ? 10 : 9)) {
698 updateControlsMenu();
703 if ((selected - NB_CAMPAIGN_MENU_ITEM >= Account::active().getCampaignChoicesMade())) {
714 whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade();
715 actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0);
716 visibleloading = true;
718 LoadLevel(campaignlevels[actuallevel].mapname.c_str());
722 pause_sound(stream_menutheme);
740 pause_sound(stream_menutheme);
749 mainmenu = (gameon ? 2 : 1);
755 vector<string> campaigns = ListCampaigns();
756 vector<string>::iterator c;
757 if ((c = find(campaigns.begin(), campaigns.end(), Account::active().getCurrentCampaign())) == campaigns.end()) {
758 if (!campaigns.empty())
759 Account::active().setCurrentCampaign(campaigns.front());
762 if (c == campaigns.end())
763 c = campaigns.begin();
764 Account::active().setCurrentCampaign(*c);
774 Account::destroyActive();
776 } else if (selected == 2) {
783 if (selected == 0 && Account::getNbAccounts() < 8) {
785 } else if (selected < Account::getNbAccounts() + 1) {
788 Account::setActive(selected - 1);
789 } else if (selected == Account::getNbAccounts() + 1) {
791 if (Account::hasActive()) {
805 Account::active().setDifficulty(selected);
809 if (selected < numchallengelevels && selected <= Account::active().getProgress()) {
817 targetlevel = selected;
828 pause_sound(stream_menutheme);
830 if (selected == numchallengelevels) {
845 stereoseparation += 0.001;
849 newstereomode = (StereoMode)(newstereomode + 1);
850 while (!CanInitStereo(newstereomode)) {
851 printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode).c_str(), newstereomode);
852 newstereomode = (StereoMode)(newstereomode + 1);
853 if (newstereomode >= stereoCount)
854 newstereomode = stereoNone;
856 } else if (selected == 2) {
857 stereoreverse = !stereoreverse;
858 } else if (selected == 3) {
862 stereomode = newstereomode;
863 InitStereo(stereomode);
866 updateStereoConfigMenu();
871 OPENAL_SetFrequency(channels[stream_menutheme]);
874 inputText(newusername, &newuserselected);
875 if (!waiting) { // the input as finished
876 if (!newusername.empty()) { // with enter
877 Account::add(string(newusername));
883 fireSound(firestartsound);
893 newuserblinkdelay -= multiplier;
894 if (newuserblinkdelay <= 0) {
895 newuserblinkdelay = .3;
896 newuserblink = !newuserblink;
901 setText(0, newusername, 20, 400, -1, -1);
902 setText(-2, newuserblink ? "_" : "", 20 + newuserselected * 10, 400, -1, -1);
905 if (oldmainmenu != mainmenu)
907 oldmainmenu = mainmenu;
911 int setKeySelected_thread(void*)
913 using namespace Game;
916 while (scancode == -1) {
917 SDL_WaitEvent(&evenement);
918 switch (evenement.type) {
920 scancode = evenement.key.keysym.scancode;
922 case SDL_MOUSEBUTTONDOWN:
923 scancode = SDL_NUM_SCANCODES + evenement.button.button;
929 if (scancode != SDL_SCANCODE_ESCAPE) {
933 forwardkey = scancode;
945 crouchkey = scancode;
957 attackkey = scancode;
960 consolekey = scancode;
972 void Menu::setKeySelected()
975 printf("launch thread\n");
976 SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread, NULL, NULL);
977 if ( thread == NULL ) {
978 fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());