123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #ifdef WIN32
- #include <Windows.h>
- #include <GdiPlus.h>
- #pragma comment( lib, "gdiplus.lib" )
- #include "Fenster.h"
- #include "Maus.h"
- #endif
- #define Global
- #include "Model3DList.h"
- #include "TexturList.h"
- #include "Globals.h"
- #include "Thread.h"
- #include "Datei.h"
- #include "Zeit.h"
- void Framework::initFramework( HINSTANCE__ *hInst )
- {
- if( istInitialisiert )
- return;
- #ifdef WIN32
- Gdiplus::GdiplusStartupInput gdiplusStartupInput;
- ULONG_PTR gdiplusToken;
- Gdiplus::GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, 0 );
- msgExit = 0;
- MausTrack = 1;
- #endif
- for( int i = 0; i < 255; ++i )
- TastenStand[ i ] = 0;
- for( int i = 0; i < 3; ++i )
- MausStand[ i ] = 0;
- Model3DList::init();
- m3dRegister = new Model3DList();
- TexturList::init();
- texturRegister = new TexturList();
- thRegister = new ThreadRegister();
- logEnabled = 0;
- logFile = 0;
- _hinst = hInst;
- istInitialisiert = 1;
- }
- void Framework::releaseFramework()
- {
- if( !istInitialisiert )
- return;
- thRegister->cleanUpClosedThreads();
- delete thRegister;
- m3dRegister->release();
- Model3DList::destroy();
- texturRegister->release();
- TexturList::destroy();
- if( logFile )
- logFile->release();
- istInitialisiert = 0;
- }
- bool Framework::istThreadOk( Thread *t )
- {
- return thRegister->isThread( t );
- }
- // Gibt das Thread Register des Frameworks zurück
- Framework::ThreadRegister *Framework::getThreadRegister()
- {
- return thRegister;
- }
- #ifdef WIN32
- const Framework::Punkt &Framework::getMausPos()
- {
- return mausPos;
- }
- #endif
- bool Framework::getMausStand( int taste )
- {
- return MausStand[ taste ];
- }
- void Framework::setTastenStand( unsigned char taste, bool st )
- {
- TastenStand[ taste ] = st;
- }
- bool Framework::getTastenStand( unsigned char taste )
- {
- return TastenStand[ taste ];
- }
- // Gibt das Model3DData Register des Frameworks ohne erhöhten reference Counter zurück
- Framework::Model3DList *Framework::zM3DRegister()
- {
- return m3dRegister;
- }
- // Gibt das Textur Register des Frameworks ohne erhöhten reference Counter zurück
- Framework::TexturList *Framework::zTexturRegister()
- {
- return texturRegister;
- }
- // Legt fest ob Log Nachrichten gespeichert werden sollen
- void Framework::setLogEnabled( bool le )
- {
- logEnabled = le;
- }
- // Speichert eine Zeile in die Logdatei
- // txt: die zu Speichernde Nachricht
- void Framework::logLine( char *txt )
- {
- if( logEnabled )
- {
- logC.lock();
- if( !logFile )
- {
- Zeit *z = getZeit();
- logFile = new Datei();
- logFile->setDatei( z->getZeit( "y-m-d h-i-s.log" ) );
- logFile->erstellen();
- z->release();
- }
- logFile->open( Datei::Style::schreiben | Datei::Style::lesen | Datei::Style::ende );
- Uhrzeit *uz = getUhrzeit();
- Text *time = uz->getUhrzeit( "h:i:s" );
- time->append( "_" );
- time->append( (int)GetThreadId( GetCurrentThread() ) );
- time->append( ": " );
- logFile->schreibe( time->getText(), time->getLength() );
- time->release();
- logFile->schreibe( txt, textLength( txt ) );
- logFile->schreibe( (char*)"\n", 1 );
- logFile->close();
- logC.unlock();
- }
- }
|