Global.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #define Global
  2. #ifdef WIN32
  3. # include <objidl.h>
  4. #endif
  5. #include "Datei.h"
  6. #include "DLLRegister.h"
  7. #include "Fenster.h"
  8. #include "Globals.h"
  9. #include "Logging.h"
  10. #include "Model3DList.h"
  11. #include "TexturList.h"
  12. #include "Thread.h"
  13. #include "Zeit.h"
  14. #ifdef WIN32
  15. # include <GdiPlus.h>
  16. # pragma comment(lib, "gdiplus.lib")
  17. # include "Fenster.h"
  18. # include "Maus.h"
  19. #endif
  20. void Framework::initFramework(HINSTANCE__* hInst)
  21. {
  22. if (istInitialisiert) return;
  23. loggingHandler = new Logging::LoggingHandler();
  24. thRegister = new ThreadRegister();
  25. #ifdef WIN32
  26. Gdiplus::GdiplusStartupInput gdiplusStartupInput;
  27. ULONG_PTR gdiplusToken;
  28. Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, 0);
  29. msgExit = 0;
  30. MausTrack = 1;
  31. #endif
  32. for (int i = 0; i < 3; ++i)
  33. MausStand[i] = 0;
  34. TexturList::init();
  35. dlls = new DLLRegister();
  36. _hinst = hInst;
  37. istInitialisiert = 1;
  38. debugDX = 0;
  39. cursorVisible = 1;
  40. }
  41. void Framework::releaseFramework()
  42. {
  43. if (!istInitialisiert) return;
  44. thRegister->cleanUpClosedThreads();
  45. dlls->release();
  46. TexturList::destroy();
  47. delete thRegister;
  48. loggingHandler->release();
  49. istInitialisiert = 0;
  50. }
  51. bool Framework::istThreadOk(Thread* t)
  52. {
  53. return thRegister->isThread(t);
  54. }
  55. // Returns the thread register of the framework
  56. Framework::ThreadRegister* Framework::getThreadRegister()
  57. {
  58. return thRegister;
  59. }
  60. #ifdef WIN32
  61. Framework::Punkt Framework::getMausPos()
  62. {
  63. POINT point;
  64. GetCursorPos(&point);
  65. return {point.x, point.y};
  66. }
  67. //! Sets the mouse position on the screen
  68. void Framework::setMausPos(const Punkt& pos)
  69. {
  70. SetCursorPos(pos.x, pos.y);
  71. }
  72. #endif
  73. bool Framework::getMausStand(int taste)
  74. {
  75. return MausStand[taste];
  76. }
  77. bool Framework::getTastenStand(unsigned char taste)
  78. {
  79. #ifdef WIN32
  80. return GetKeyState(taste) & 0x8000;
  81. #else
  82. return 0;
  83. #endif
  84. }
  85. // Returns the DLL register containing all currently dynamically loaded DLLs
  86. Framework::DLLRegister* Framework::getDLLRegister()
  87. {
  88. return Framework::dlls;
  89. }
  90. //! Sets DirectX to debug mode
  91. void Framework::setDebugDX(bool debug)
  92. {
  93. debugDX = debug;
  94. }
  95. #ifdef WIN32
  96. // returns a reference to the mouse
  97. Framework::Maus& Framework::getMaus()
  98. {
  99. return Framework::MausZeiger;
  100. }
  101. //! sets the mouse state to visible or invisible
  102. void Framework::setShowCursor(bool visible)
  103. {
  104. CURSORINFO info = {0};
  105. info.cbSize = sizeof(CURSORINFO);
  106. GetCursorInfo(&info);
  107. if ((info.flags != 0) == (visible == 0)) ShowCursor(visible);
  108. cursorVisible = visible;
  109. }
  110. #endif