#define Global #ifdef WIN32 # include #endif #include "Datei.h" #include "DLLRegister.h" #include "Fenster.h" #include "Globals.h" #include "Model3DList.h" #include "TexturList.h" #include "Thread.h" #include "Zeit.h" #ifdef WIN32 # include # pragma comment(lib, "gdiplus.lib") # include "Fenster.h" # include "Maus.h" #endif void Framework::initFramework(HINSTANCE__* hInst) { if (istInitialisiert) return; thRegister = new ThreadRegister(); #ifdef WIN32 Gdiplus::GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, 0); msgExit = 0; MausTrack = 1; #endif for (int i = 0; i < 3; ++i) MausStand[i] = 0; TexturList::init(); dlls = new DLLRegister(); logEnabled = 0; logFile = 0; _hinst = hInst; istInitialisiert = 1; debugDX = 0; cursorVisible = 1; } void Framework::releaseFramework() { if (!istInitialisiert) return; thRegister->cleanUpClosedThreads(); dlls->release(); TexturList::destroy(); if (logFile) logFile->release(); delete thRegister; 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 Framework::Punkt Framework::getMausPos() { POINT point; GetCursorPos(&point); return {point.x, point.y}; } //! Setzt die Position der Maus auf dem Bildschirm void Framework::setMausPos(const Punkt& pos) { SetCursorPos(pos.x, pos.y); } #endif bool Framework::getMausStand(int taste) { return MausStand[taste]; } bool Framework::getTastenStand(unsigned char taste) { #ifdef WIN32 return GetKeyState(taste) & 0x8000; #else return 0; #endif } // 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("\n", 1); logFile->close(); logC.unlock(); } } // Gibt das DLL Register zurück, in dem alle zurzeit dynamisch geladenen DLL // Dateien hinterlegt sind Framework::DLLRegister* Framework::getDLLRegister() { return Framework::dlls; } //! Versetzt DirectX in den Debug modus void Framework::setDebugDX(bool debug) { debugDX = debug; } #ifdef WIN32 // gibt eine Referenz auf die Maus zurück Framework::Maus& Framework::getMaus() { return Framework::MausZeiger; } //! setzt den Zustand der Maus auf sichtbar oder unsichtbar void Framework::setShowCursor(bool visible) { CURSORINFO info = {0}; info.cbSize = sizeof(CURSORINFO); GetCursorInfo(&info); if ((info.flags != 0) == (visible == 0)) ShowCursor(visible); cursorVisible = visible; } #endif