flexlay.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Flexlay - A Generic 2D Game Editor
  2. // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #include "flexlay.hpp"
  17. #include <ClanLib/core.h>
  18. #include <ClanLib/display.h>
  19. #include <ClanLib/gui.h>
  20. #include <ClanLib/gl.h>
  21. #include "globals.hpp"
  22. #include "fonts.hpp"
  23. Flexlay* Flexlay::current_ = 0;
  24. Flexlay::Flexlay()
  25. {
  26. screen_width = 800;
  27. screen_height = 600;
  28. fullscreen = false;
  29. allow_resize = false;
  30. use_opengl = true;
  31. current_ = this;
  32. }
  33. CL_Signal_v2<int, int>&
  34. Flexlay::sig_resize()
  35. {
  36. return window->sig_resize();
  37. }
  38. void
  39. Flexlay::init(const std::string& title, int width, int height, bool fullscreen_, bool allow_resize_)
  40. {
  41. screen_width = width;
  42. screen_height = height;
  43. fullscreen = fullscreen_;
  44. allow_resize = allow_resize_;
  45. std::cout << "Flexlay::init()" << std::endl;
  46. try {
  47. #ifdef WIN32
  48. CL_SetupCore::set_instance(GetModuleHandle("flexlay_wrap.dll"));
  49. #endif
  50. CL_SetupCore::init();
  51. #ifdef HAVE_LIBSDL
  52. if (use_opengl)
  53. CL_SetupGL::init();
  54. else
  55. CL_SetupSDL::init();
  56. #else
  57. CL_SetupGL::init();
  58. #endif
  59. CL_SetupDisplay::init();
  60. CL_SetupGUI::init();
  61. window = new CL_DisplayWindow(title,
  62. screen_width, screen_height, fullscreen, allow_resize);
  63. resources = CL_ResourceManager(datadir + "/flexlay.xml");
  64. Fonts::verdana11 = CL_Font("verdana11_black", &resources);
  65. Fonts::verdana11_yellow = CL_Font("verdana11_yellow", &resources);
  66. } catch (CL_Error& err) {
  67. std::cout << "CL_Error: " << err.message << std::endl;
  68. }
  69. }
  70. void
  71. Flexlay::deinit()
  72. {
  73. std::cout << "Flexlay::deinit()" << std::endl;
  74. CL_SetupDisplay::deinit();
  75. #ifdef HAVE_LIBSDL
  76. if (use_opengl)
  77. CL_SetupGL::deinit();
  78. else
  79. CL_SetupSDL::init();
  80. #else
  81. CL_SetupGL::deinit();
  82. #endif
  83. CL_SetupCore::deinit();
  84. }
  85. void
  86. Flexlay::set_datadir(const std::string& datadir_)
  87. {
  88. datadir = datadir_;
  89. }
  90. /* EOF */