RacerGame.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. #include "RacerGame.h"
  2. // Render queue indexes (in order of drawing).
  3. enum RenderQueue
  4. {
  5. QUEUE_OPAQUE = 0,
  6. QUEUE_TRANSPARENT,
  7. QUEUE_COUNT
  8. };
  9. bool __viewFrustumCulling = true;
  10. bool __flythruCamera = false;
  11. bool __drawDebug = false;
  12. bool __useAccelerometer = false;
  13. bool __showMenu = false;
  14. bool __menuFlag = false;
  15. // Declare our game instance
  16. RacerGame game;
  17. // Input bit-flags (powers of 2)
  18. #define ACCELERATOR (1 << 0)
  19. #define BRAKE (1 << 1)
  20. #define REVERSE (1 << 2)
  21. #define UPRIGHT (1 << 3)
  22. #define STEER_LEFT (1 << 4)
  23. #define STEER_RIGHT (1 << 5)
  24. #define ACCELERATOR_MOUSE (1 << 6)
  25. #define BRAKE_MOUSE (1 << 7)
  26. #define STEERING_RESPONSE (7.0f)
  27. RacerGame::RacerGame()
  28. : _scene(NULL), _keyFlags(0), _mouseFlags(0), _steering(0), _gamepad(NULL), _carVehicle(NULL), _upsetTimer(0),
  29. _backgroundSound(NULL), _engineSound(NULL), _brakingSound(NULL)
  30. {
  31. }
  32. void RacerGame::initialize()
  33. {
  34. setMultiTouch(true);
  35. _font = Font::create("res/common/arial.gpb");
  36. // Display the gameplay splash screen during loading, for at least 1 second.
  37. displayScreen(this, &RacerGame::drawSplash, NULL, 1000L);
  38. // Create the menu and start listening to its controls.
  39. _menu = Form::create("res/common/menu.form");
  40. _menu->setEnabled(false);
  41. static_cast<Button*>(_menu->getControl("newGameButton"))->addListener(this, Listener::CLICK);
  42. static_cast<Button*>(_menu->getControl("quitGameButton"))->addListener(this, Listener::CLICK);
  43. static_cast<RadioButton*>(_menu->getControl("useGamepad"))->addListener(this, Listener::VALUE_CHANGED);
  44. static_cast<RadioButton*>(_menu->getControl("useTilt"))->addListener(this, Listener::VALUE_CHANGED);
  45. if (!canExit())
  46. {
  47. // Prevent a programmatic exit on platforms that don't allow it.
  48. _menu->removeControl("quitGameButton");
  49. }
  50. // Create a pause button to display the menu
  51. _overlay = Form::create("res/common/overlay.form");
  52. static_cast<Button*>(_overlay->getControl("menuButton"))->addListener(this, Listener::CLICK);
  53. // Load the scene
  54. _scene = Scene::load("res/common/racer.scene");
  55. // Set the aspect ratio for the scene's camera to match the current resolution
  56. _scene->getActiveCamera()->setAspectRatio(getAspectRatio());
  57. // Initialize scene
  58. _scene->visit(this, &RacerGame::initializeScene);
  59. // Load and initialize game script
  60. getScriptController()->loadScript("res/common/racer.lua");
  61. getScriptController()->executeFunction<void>("setScene", "<Scene>", _scene);
  62. Node* carNode = _scene->findNode("carbody");
  63. if (carNode && carNode->getCollisionObject()->getType() == PhysicsCollisionObject::VEHICLE)
  64. {
  65. _carVehicle = static_cast<PhysicsVehicle*>(carNode->getCollisionObject());
  66. resetToStart();
  67. }
  68. // Create audio tracks
  69. _backgroundSound = AudioSource::create("res/common/background_track.ogg");
  70. if (_backgroundSound)
  71. {
  72. _backgroundSound->setLooped(true);
  73. _backgroundSound->play();
  74. _backgroundSound->setGain(0.3f);
  75. }
  76. _engineSound = AudioSource::create("res/common/engine_loop.ogg");
  77. if (_engineSound)
  78. {
  79. _engineSound->setLooped(true);
  80. _engineSound->play();
  81. _engineSound->setGain(0.7f);
  82. }
  83. _brakingSound = AudioSource::create("res/common/braking.wav");
  84. _brakingSound->setLooped(false);
  85. _brakingSound->setGain(0.5f);
  86. _gamepad = getGamepad(0);
  87. }
  88. bool RacerGame::initializeScene(Node* node)
  89. {
  90. static Node* lightNode = _scene->findNode("directionalLight1");
  91. Model* model = node->getModel();
  92. if (model)
  93. {
  94. Material* material = model->getMaterial();
  95. if (material && material->getTechnique()->getPassByIndex(0)->getEffect()->getUniform("u_directionalLightDirection[0]"))
  96. {
  97. material->getParameter("u_ambientColor")->setValue(_scene->getAmbientColor());
  98. material->getParameter("u_directionalLightColor[0]")->setValue(lightNode->getLight()->getColor());
  99. material->getParameter("u_directionalLightDirection[0]")->setValue(lightNode->getForwardVectorView());
  100. }
  101. }
  102. return true;
  103. }
  104. void RacerGame::finalize()
  105. {
  106. SAFE_RELEASE(_backgroundSound);
  107. SAFE_RELEASE(_engineSound);
  108. SAFE_RELEASE(_brakingSound);
  109. SAFE_RELEASE(_scene);
  110. SAFE_RELEASE(_font);
  111. SAFE_RELEASE(_menu);
  112. SAFE_RELEASE(_overlay);
  113. }
  114. void RacerGame::update(float elapsedTime)
  115. {
  116. // The "Start" button is mapped to MENU2.
  117. if (!__showMenu && !__menuFlag && _gamepad->isButtonDown(Gamepad::BUTTON_MENU2))
  118. {
  119. __menuFlag = true;
  120. menuEvent();
  121. }
  122. if (__menuFlag && !_gamepad->isButtonDown(Gamepad::BUTTON_MENU2))
  123. {
  124. __menuFlag = false;
  125. }
  126. if (__showMenu && !__menuFlag && _gamepad->isButtonDown(Gamepad::BUTTON_MENU2))
  127. {
  128. __menuFlag = true;
  129. menuEvent();
  130. }
  131. Node* cameraNode;
  132. if (_scene->getActiveCamera() && (cameraNode = _scene->getActiveCamera()->getNode()))
  133. {
  134. float dt = elapsedTime / 1000.0f;
  135. float braking = 0;
  136. float driving = 0;
  137. if (_carVehicle)
  138. {
  139. float v = _carVehicle->getSpeedKph();
  140. bool isVirt = _gamepad->isVirtual();
  141. if (!__flythruCamera)
  142. {
  143. // Vehicle Control (Normal Mode)
  144. Vector2 direction;
  145. if (_gamepad->getJoystickCount())
  146. {
  147. _gamepad->getJoystickValues(0, &direction);
  148. }
  149. if (_gamepad->isButtonDown(Gamepad::BUTTON_LEFT))
  150. {
  151. direction.set(-1.0f, 0.0f);
  152. }
  153. else if (_gamepad->isButtonDown(Gamepad::BUTTON_RIGHT))
  154. {
  155. direction.set(1.0f, 0.0f);
  156. }
  157. // Allow keys to control steering
  158. if (_keyFlags & STEER_LEFT)
  159. {
  160. _steering += STEERING_RESPONSE * dt;
  161. }
  162. else if (_keyFlags & STEER_RIGHT)
  163. {
  164. _steering -= STEERING_RESPONSE * dt;
  165. }
  166. else if (__useAccelerometer)
  167. {
  168. float pitch, roll;
  169. Game::getAccelerometerValues(&pitch, &roll);
  170. _steering = -0.16 * roll;
  171. }
  172. else
  173. {
  174. _steering = -direction.x;
  175. }
  176. _steering = max(-1.0f, min(_steering, 1.0f));
  177. if (_gamepad->getTriggerCount() > 1)
  178. {
  179. driving = _gamepad->getTriggerValue(1);
  180. _engineSound->setGain(0.8f + (driving * 0.2f));
  181. }
  182. if (!driving && (_keyFlags & ACCELERATOR || _keyFlags & ACCELERATOR_MOUSE || _gamepad->isButtonDown(Gamepad::BUTTON_A)))
  183. {
  184. driving = 1;
  185. _engineSound->setGain(1.0f);
  186. }
  187. else
  188. {
  189. _engineSound->setGain(0.8f);
  190. }
  191. float s = _carVehicle->getSpeedSmoothKph() / 100.0f;
  192. _engineSound->setPitch(max(0.2f, min(s, 2.0f)));
  193. // Reverse only below a reasonable speed
  194. bool isReverseCommanded = (_keyFlags & REVERSE) ||
  195. (!isVirt && _gamepad->isButtonDown(Gamepad::BUTTON_X)) ||
  196. (direction.y < -0.1 && _gamepad->isButtonDown(Gamepad::BUTTON_A));
  197. if (isReverseCommanded && v < 30.0f)
  198. {
  199. driving = -0.6f;
  200. }
  201. if ( (_keyFlags & BRAKE) || (_keyFlags & BRAKE_MOUSE) || _gamepad->isButtonDown(Gamepad::BUTTON_B))
  202. {
  203. braking = 1;
  204. if (_brakingSound && (_brakingSound->getState() != AudioSource::PLAYING) && (v > 30.0f))
  205. _brakingSound->play();
  206. }
  207. else
  208. {
  209. _brakingSound->stop();
  210. }
  211. // Make the camera follow the car
  212. Node* carNode = _carVehicle->getNode();
  213. Vector3 carPosition(carNode->getTranslation());
  214. Vector3 commandedPosition(carPosition + Vector3::unitY()*4.0f - carNode->getBackVector()*10.0f);
  215. cameraNode->translateSmooth(commandedPosition, dt, 0.2f);
  216. Matrix m;
  217. Matrix::createLookAt(cameraNode->getTranslation(), carPosition, Vector3::unitY(), &m);
  218. m.transpose();
  219. Quaternion q;
  220. m.getRotation(&q);
  221. cameraNode->setRotation(q);
  222. }
  223. // Slightly different steering gain based on gamepad type.
  224. _carVehicle->setSteerdown( (isVirt ? 94.0f : 87.0f), (isVirt ? 0.15f : 0.22f) );
  225. _carVehicle->update(elapsedTime, _steering, braking, driving);
  226. // Auto-detect an upset car
  227. if (fabs(v) < 10.0f && isUpset())
  228. {
  229. _upsetTimer += dt;
  230. }
  231. else
  232. {
  233. _upsetTimer = 0;
  234. }
  235. if (_upsetTimer > 3.0f)
  236. {
  237. _upsetTimer = 0;
  238. resetInPlace();
  239. }
  240. else if ( (_keyFlags & UPRIGHT) ||
  241. (!isVirt && _gamepad->isButtonDown(Gamepad::BUTTON_Y)) ||
  242. (_carVehicle->getNode()->getTranslationY() < -300.0f) )
  243. {
  244. resetToStart();
  245. }
  246. }
  247. }
  248. }
  249. bool RacerGame::isUpset() const
  250. {
  251. GP_ASSERT(_carVehicle);
  252. return _carVehicle->getNode()->getUpVector().y < 0.4f;
  253. }
  254. void RacerGame::render(float elapsedTime)
  255. {
  256. // Clear the color and depth buffers
  257. clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
  258. // Visit all the nodes in the scene to build our render queues
  259. for (unsigned int i = 0; i < QUEUE_COUNT; ++i)
  260. _renderQueues[i].clear();
  261. _scene->visit(this, &RacerGame::buildRenderQueues);
  262. // Draw the scene from our render queues
  263. drawScene();
  264. if (__drawDebug)
  265. {
  266. Game::getInstance()->getPhysicsController()->drawDebug(_scene->getActiveCamera()->getViewProjectionMatrix());
  267. }
  268. // Draw the gamepad
  269. if (_gamepad && _gamepad->isVirtual())
  270. _gamepad->draw();
  271. // Draw the menu
  272. if (__showMenu)
  273. {
  274. _menu->draw();
  275. }
  276. _overlay->draw();
  277. // Draw FPS and speed
  278. int carSpeed = _carVehicle ? (int)_carVehicle->getSpeedKph() : 0;
  279. _font->start();
  280. char fps[32];
  281. sprintf(fps, "%d", getFrameRate());
  282. _font->drawText(fps, 5, 5, Vector4(0,0.5f,1,1), 20);
  283. char kph[32];
  284. sprintf(kph, "%d [km/h]", carSpeed);
  285. _font->drawText(kph, getWidth() / 2 - 50, getHeight() - 60, Vector4(1,1,1,1), 40);
  286. _font->finish();
  287. }
  288. bool RacerGame::buildRenderQueues(Node* node)
  289. {
  290. Model* model = node->getModel();
  291. if (model)
  292. {
  293. // Perform view-frustum culling for this node
  294. if (__viewFrustumCulling && !node->getBoundingSphere().intersects(_scene->getActiveCamera()->getFrustum()))
  295. return true;
  296. // Determine which render queue to insert the node into
  297. std::vector<Node*>* queue;
  298. if (node->hasTag("transparent"))
  299. queue = &_renderQueues[QUEUE_TRANSPARENT];
  300. else
  301. queue = &_renderQueues[QUEUE_OPAQUE];
  302. queue->push_back(node);
  303. }
  304. return true;
  305. }
  306. void RacerGame::drawScene()
  307. {
  308. // Iterate through each render queue and draw the nodes in them
  309. for (unsigned int i = 0; i < QUEUE_COUNT; ++i)
  310. {
  311. std::vector<Node*>& queue = _renderQueues[i];
  312. for (size_t j = 0, ncount = queue.size(); j < ncount; ++j)
  313. {
  314. queue[j]->getModel()->draw();
  315. }
  316. }
  317. }
  318. void RacerGame::drawSplash(void* param)
  319. {
  320. clear(CLEAR_COLOR_DEPTH, Vector4(0, 0, 0, 1), 1.0f, 0);
  321. SpriteBatch* batch = SpriteBatch::create("res/logo_powered_white.png");
  322. batch->start();
  323. batch->draw(this->getWidth() * 0.5f, this->getHeight() * 0.5f, 0.0f, 512.0f, 512.0f, 0.0f, 1.0f, 1.0f, 0.0f, Vector4::one(), true);
  324. batch->finish();
  325. SAFE_DELETE(batch);
  326. }
  327. void RacerGame::keyEvent(Keyboard::KeyEvent evt, int key)
  328. {
  329. if (evt == Keyboard::KEY_PRESS)
  330. {
  331. switch (key)
  332. {
  333. case Keyboard::KEY_ESCAPE:
  334. menuEvent();
  335. break;
  336. case Keyboard::KEY_A:
  337. case Keyboard::KEY_CAPITAL_A:
  338. case Keyboard::KEY_LEFT_ARROW:
  339. _keyFlags |= STEER_LEFT;
  340. break;
  341. case Keyboard::KEY_D:
  342. case Keyboard::KEY_CAPITAL_D:
  343. case Keyboard::KEY_RIGHT_ARROW:
  344. _keyFlags |= STEER_RIGHT;
  345. break;
  346. case Keyboard::KEY_W:
  347. case Keyboard::KEY_CAPITAL_W:
  348. case Keyboard::KEY_UP_ARROW:
  349. _keyFlags |= ACCELERATOR;
  350. break;
  351. case Keyboard::KEY_S:
  352. case Keyboard::KEY_CAPITAL_S:
  353. case Keyboard::KEY_DOWN_ARROW:
  354. _keyFlags |= REVERSE;
  355. break;
  356. case Keyboard::KEY_SPACE:
  357. _keyFlags |= BRAKE;
  358. break;
  359. case Keyboard::KEY_Y:
  360. case Keyboard::KEY_CAPITAL_Y:
  361. _keyFlags |= UPRIGHT;
  362. break;
  363. case Keyboard::KEY_V:
  364. __viewFrustumCulling = !__viewFrustumCulling;
  365. break;
  366. case Keyboard::KEY_F:
  367. __flythruCamera = !__flythruCamera;
  368. getScriptController()->executeFunction<void>("toggleCamera");
  369. break;
  370. case Keyboard::KEY_B:
  371. __drawDebug = !__drawDebug;
  372. break;
  373. case Keyboard::KEY_J:
  374. __useAccelerometer = !__useAccelerometer;
  375. break;
  376. }
  377. }
  378. else if (evt == Keyboard::KEY_RELEASE)
  379. {
  380. switch (key)
  381. {
  382. case Keyboard::KEY_A:
  383. case Keyboard::KEY_CAPITAL_A:
  384. case Keyboard::KEY_LEFT_ARROW:
  385. _keyFlags &= ~STEER_LEFT;
  386. break;
  387. case Keyboard::KEY_D:
  388. case Keyboard::KEY_CAPITAL_D:
  389. case Keyboard::KEY_RIGHT_ARROW:
  390. _keyFlags &= ~STEER_RIGHT;
  391. break;
  392. case Keyboard::KEY_W:
  393. case Keyboard::KEY_CAPITAL_W:
  394. case Keyboard::KEY_UP_ARROW:
  395. _keyFlags &= ~ACCELERATOR;
  396. break;
  397. case Keyboard::KEY_S:
  398. case Keyboard::KEY_CAPITAL_S:
  399. case Keyboard::KEY_DOWN_ARROW:
  400. _keyFlags &= ~REVERSE;
  401. break;
  402. case Keyboard::KEY_SPACE:
  403. _keyFlags &= ~BRAKE;
  404. break;
  405. case Keyboard::KEY_Y:
  406. case Keyboard::KEY_CAPITAL_Y:
  407. _keyFlags &= ~UPRIGHT;
  408. break;
  409. }
  410. }
  411. }
  412. void RacerGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
  413. {
  414. switch (evt)
  415. {
  416. case Touch::TOUCH_PRESS:
  417. break;
  418. case Touch::TOUCH_RELEASE:
  419. break;
  420. case Touch::TOUCH_MOVE:
  421. break;
  422. };
  423. }
  424. bool RacerGame::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
  425. {
  426. bool consumed = false;
  427. switch (evt)
  428. {
  429. case Mouse::MOUSE_PRESS_LEFT_BUTTON:
  430. _keyFlags |= ACCELERATOR_MOUSE;
  431. break;
  432. case Mouse::MOUSE_PRESS_RIGHT_BUTTON:
  433. _keyFlags |= BRAKE_MOUSE;
  434. break;
  435. case Mouse::MOUSE_RELEASE_LEFT_BUTTON:
  436. _keyFlags &= ~ACCELERATOR_MOUSE;
  437. break;
  438. case Mouse::MOUSE_RELEASE_RIGHT_BUTTON:
  439. _keyFlags &= ~BRAKE_MOUSE;
  440. break;
  441. }
  442. return consumed;
  443. }
  444. void RacerGame::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad)
  445. {
  446. // Prioritise physical gamepads over the virtual one.
  447. switch(evt)
  448. {
  449. case Gamepad::CONNECTED_EVENT:
  450. if (gamepad->isVirtual())
  451. {
  452. float from = 0.0f;
  453. float to = getHeight();
  454. Animation* virtualGamepadAnimation = gamepad->getForm()->createAnimationFromTo("gamepad_transition", Form::ANIMATE_POSITION_Y, &from, &to, Curve::LINEAR, 2000L);
  455. _virtualGamepadClip = virtualGamepadAnimation->getClip();
  456. _virtualGamepad = gamepad;
  457. }
  458. else
  459. {
  460. if (!_physicalGamepad)
  461. _physicalGamepad = gamepad;
  462. }
  463. if (_physicalGamepad)
  464. {
  465. if (_virtualGamepadClip && _gamepad == _virtualGamepad)
  466. {
  467. _virtualGamepadClip->setSpeed(1.0f);
  468. _virtualGamepadClip->play();
  469. }
  470. _gamepad = _physicalGamepad;
  471. if (_virtualGamepad)
  472. {
  473. _virtualGamepad->getForm()->setEnabled(false);
  474. }
  475. }
  476. else if (_virtualGamepad)
  477. {
  478. if (_gamepad == _physicalGamepad)
  479. {
  480. _virtualGamepadClip->setSpeed(-1.0f);
  481. _virtualGamepadClip->play();
  482. }
  483. _gamepad = _virtualGamepad;
  484. _virtualGamepad->getForm()->setEnabled(true);
  485. }
  486. break;
  487. case Gamepad::DISCONNECTED_EVENT:
  488. if (gamepad == _physicalGamepad)
  489. {
  490. _gamepad = _virtualGamepad;
  491. _physicalGamepad = NULL;
  492. _virtualGamepadClip->setSpeed(-1.0f);
  493. _virtualGamepadClip->play();
  494. _virtualGamepad->getForm()->setEnabled(true);
  495. }
  496. break;
  497. }
  498. }
  499. void RacerGame::menuEvent()
  500. {
  501. __showMenu = !__showMenu;
  502. if (__showMenu)
  503. {
  504. static_cast<Button*>(_overlay->getControl("menuButton"))->setText("Resume");
  505. pause();
  506. _menu->setEnabled(true);
  507. _menu->setState(Control::FOCUS);
  508. }
  509. else
  510. {
  511. static_cast<Button*>(_overlay->getControl("menuButton"))->setText("Menu");
  512. resume();
  513. _menu->setEnabled(false);
  514. }
  515. }
  516. void RacerGame::resetToStart()
  517. {
  518. Vector3 pos(-258, 1, 278);
  519. Quaternion rot(Vector3::unitY(), MATH_DEG_TO_RAD(143.201f));
  520. reset(pos, rot);
  521. }
  522. void RacerGame::resetInPlace()
  523. {
  524. Node* carNode = _carVehicle->getNode();
  525. Vector3 pos;
  526. carNode->getTranslation(&pos);
  527. pos.y += 3.0f;
  528. float angle = 0;
  529. Vector3 v;
  530. carNode->getForwardVector(&v);
  531. if (v.x*v.x + v.z*v.z > 0)
  532. {
  533. angle += atan2(-v.x, -v.z);
  534. }
  535. Quaternion rot(Vector3::unitY(), angle);
  536. reset(pos, rot);
  537. }
  538. void RacerGame::reset(const Vector3& pos, const Quaternion& rot)
  539. {
  540. Node* carNode = _carVehicle->getNode();
  541. _carVehicle->setEnabled(false);
  542. carNode->setTranslation(pos);
  543. carNode->setRotation(rot);
  544. _carVehicle->reset();
  545. _carVehicle->setEnabled(true);
  546. }
  547. void RacerGame::controlEvent(Control* control, EventType evt)
  548. {
  549. if (strcmp(control->getId(), "newGameButton") == 0)
  550. {
  551. resetToStart();
  552. // Close the menu and resume the game.
  553. menuEvent();
  554. }
  555. else if (strcmp(control->getId(), "quitGameButton") == 0)
  556. {
  557. exit();
  558. }
  559. else if (strcmp(control->getId(), "useGamepad") == 0)
  560. {
  561. __useAccelerometer = false;
  562. }
  563. else if (strcmp(control->getId(), "useTilt") == 0)
  564. {
  565. __useAccelerometer = true;
  566. }
  567. else if (strcmp(control->getId(), "menuButton") == 0)
  568. {
  569. menuEvent();
  570. }
  571. }