Global.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifdef WIN32
  2. #include <Windows.h>
  3. #include <GdiPlus.h>
  4. #pragma comment( lib, "gdiplus.lib" )
  5. #include "Fenster.h"
  6. #include "Maus.h"
  7. #endif
  8. #define Global
  9. #include "Model3DList.h"
  10. #include "TexturList.h"
  11. #include "Globals.h"
  12. #include "Thread.h"
  13. #include "Datei.h"
  14. #include "Zeit.h"
  15. #include "DLLRegister.h"
  16. void Framework::initFramework( HINSTANCE__ *hInst )
  17. {
  18. if( istInitialisiert )
  19. return;
  20. thRegister = new ThreadRegister();
  21. #ifdef WIN32
  22. Gdiplus::GdiplusStartupInput gdiplusStartupInput;
  23. ULONG_PTR gdiplusToken;
  24. Gdiplus::GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, 0 );
  25. msgExit = 0;
  26. MausTrack = 1;
  27. #endif
  28. for( int i = 0; i < 255; ++i )
  29. TastenStand[ i ] = 0;
  30. for( int i = 0; i < 3; ++i )
  31. MausStand[ i ] = 0;
  32. Model3DList::init();
  33. m3dRegister = new Model3DList();
  34. TexturList::init();
  35. dlls = new DLLRegister();
  36. logEnabled = 0;
  37. logFile = 0;
  38. _hinst = hInst;
  39. istInitialisiert = 1;
  40. }
  41. void Framework::releaseFramework()
  42. {
  43. if( !istInitialisiert )
  44. return;
  45. thRegister->cleanUpClosedThreads();
  46. dlls->release();
  47. m3dRegister->release();
  48. Model3DList::destroy();
  49. TexturList::destroy();
  50. if( logFile )
  51. logFile->release();
  52. delete thRegister;
  53. istInitialisiert = 0;
  54. }
  55. bool Framework::istThreadOk( Thread *t )
  56. {
  57. return thRegister->isThread( t );
  58. }
  59. // Gibt das Thread Register des Frameworks zurück
  60. Framework::ThreadRegister *Framework::getThreadRegister()
  61. {
  62. return thRegister;
  63. }
  64. #ifdef WIN32
  65. const Framework::Punkt &Framework::getMausPos()
  66. {
  67. return mausPos;
  68. }
  69. #endif
  70. bool Framework::getMausStand( int taste )
  71. {
  72. return MausStand[ taste ];
  73. }
  74. void Framework::setTastenStand( unsigned char taste, bool st )
  75. {
  76. TastenStand[ taste ] = st;
  77. }
  78. bool Framework::getTastenStand( unsigned char taste )
  79. {
  80. return TastenStand[ taste ];
  81. }
  82. // Gibt das Model3DData Register des Frameworks ohne erhöhten reference Counter zurück
  83. Framework::Model3DList *Framework::zM3DRegister()
  84. {
  85. return m3dRegister;
  86. }
  87. // Legt fest ob Log Nachrichten gespeichert werden sollen
  88. void Framework::setLogEnabled( bool le )
  89. {
  90. logEnabled = le;
  91. }
  92. // Speichert eine Zeile in die Logdatei
  93. // txt: die zu Speichernde Nachricht
  94. void Framework::logLine( char *txt )
  95. {
  96. if( logEnabled )
  97. {
  98. logC.lock();
  99. if( !logFile )
  100. {
  101. Zeit *z = getZeit();
  102. logFile = new Datei();
  103. logFile->setDatei( z->getZeit( "y-m-d h-i-s.log" ) );
  104. logFile->erstellen();
  105. z->release();
  106. }
  107. logFile->open( Datei::Style::schreiben | Datei::Style::lesen | Datei::Style::ende );
  108. Uhrzeit *uz = getUhrzeit();
  109. Text *time = uz->getUhrzeit( "h:i:s" );
  110. time->append( "_" );
  111. time->append( (int)GetThreadId( GetCurrentThread() ) );
  112. time->append( ": " );
  113. logFile->schreibe( time->getText(), time->getLength() );
  114. time->release();
  115. logFile->schreibe( txt, textLength( txt ) );
  116. logFile->schreibe( (char*)"\n", 1 );
  117. logFile->close();
  118. logC.unlock();
  119. }
  120. }
  121. // Gibt das DLL Register zurück, in dem alle zurzeit dynamisch geladenen DLL Dateien hinterlegt sind
  122. Framework::DLLRegister *Framework::getDLLRegister()
  123. {
  124. return Framework::dlls;
  125. }
  126. //! Versetzt DirectX in den Debug modus
  127. void Framework::setDebugDX( bool debug )
  128. {
  129. debugDX = debug;
  130. }
  131. #ifdef WIN32
  132. // gibt eine Referenz auf die Maus zurück
  133. Framework::Maus &Framework::getMaus()
  134. {
  135. return Framework::MausZeiger;
  136. }
  137. #endif