Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Menu.cpp 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*!
  2. * \file src/Menu.cpp
  3. * \brief Menu 'overlay'
  4. *
  5. * \author xythobuz
  6. */
  7. #include <cstdarg>
  8. #ifdef __APPLE__
  9. #include <OpenGL/gl.h>
  10. #include <OpenGL/glu.h>
  11. #else
  12. #include <GL/gl.h>
  13. #include <GL/glu.h>
  14. #endif
  15. #include "config.h"
  16. #include "main.h"
  17. #include "Menu.h"
  18. #include "utils/strings.h"
  19. Menu::Menu() {
  20. mVisible = false;
  21. mainText.text = bufferString(VERSION);
  22. mainText.color[0] = 0xFF;
  23. mainText.color[1] = 0xFF;
  24. mainText.color[2] = 0xFF;
  25. mainText.color[3] = 0xFF;
  26. mainText.scale = 1.2f;
  27. mainText.w = 0;
  28. mainText.h = 0;
  29. }
  30. Menu::~Menu() {
  31. }
  32. void Menu::setVisible(bool visible) {
  33. mVisible = visible;
  34. }
  35. bool Menu::isVisible() {
  36. return mVisible;
  37. }
  38. void Menu::drawText(unsigned int x, unsigned int y, float scale, const char *s, ...) {
  39. va_list args;
  40. va_start(args, s);
  41. WindowString w;
  42. w.text = bufferString(s, args);
  43. va_end(args);
  44. w.scale = scale;
  45. w.x = x;
  46. w.y = y;
  47. w.color[0] = 0xFF;
  48. w.color[1] = 0xFF;
  49. w.color[2] = 0xFF;
  50. w.color[3] = 0xFF;
  51. gOpenRaider->mWindow->writeString(&w);
  52. }
  53. void Menu::display() {
  54. Window *window = gOpenRaider->mWindow;
  55. if (mVisible) {
  56. // Draw half-transparent *overlay*
  57. glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
  58. glDisable(GL_TEXTURE_2D);
  59. glRecti(0, 0, window->mWidth, window->mHeight);
  60. glEnable(GL_TEXTURE_2D);
  61. // Draw heading text
  62. mainText.x = (window->mWidth / 2) - (mainText.w / 2);
  63. mainText.y = 10;
  64. window->writeString(&mainText);
  65. drawText(20, (window->mHeight / 2) - 20, 0.75f, "Generating map list...");
  66. }
  67. }
  68. void Menu::actionMouse(unsigned int x, unsigned int y, int button) {
  69. }
  70. void Menu::actionKeyboard(int key) {
  71. }