#ifndef Globals_H
#define Globals_H

#include "Critical.h"
#include "Point.h"

#ifdef WIN32
#    include "Mouse.h"
#    include "Window.h"
#endif

#ifndef Global
#    define Global extern
#endif

struct HINSTANCE__; //! windows.h

namespace Framework
{
    class ThreadRegister; //! Thread.h
    class Thread;         //! Thread.h
    class Model3DList;    //! Model3DList.h
    class TextureList;    //! TextureList.h
    class File;           //! File.h
    class DLLRegister;    //! DLLRegister.h

    namespace Logging
    {
        class LoggingHandler; //! LoggingHandler.h
    }

#ifdef WIN32
    Global NativeWindowArray nativeWindows;
    Global bool MouseTrack;
    Global Mouse mousePointer;
    Global bool msgExit;
#endif
    Global bool MouseState[3];
    Global bool isInitialized;
    Global ThreadRegister* thRegister;
    Global HINSTANCE__* _hinst;
    Global DLLRegister* dlls;
    Global bool debugDX;
    Global bool cursorVisible;
    Global Logging::LoggingHandler* loggingHandler;
    Global thread_local int currentThreadId;
    Global thread_local int currentThreadLockCount;

#ifdef WIN32
    //! Returns the mouse coordinates on the screen
    DLLEXPORT Point getMousePos();
    //! Sets the position of the mouse on the screen
    DLLEXPORT void setMousePos(const Point& pos);
#endif
    //! Returns whether a mouse button is currently pressed
    //! \param key The button to check
    //! Example: getMouseState( M_Left ); (Requires include <MouseEvent.h>)
    DLLEXPORT bool getMouseState(int key);
    //! Returns whether a keyboard key is currently pressed
    //! \param key The key to check
    //! Example: getKeyState( T_Enter ); (Requires include
    //! <KeyboardEvent.h>)
    DLLEXPORT bool getKeyState(unsigned char key);
    //! Initializes the framework.
    //! Called automatically in the framework's (WinMain)
    DLLEXPORT void initFramework(HINSTANCE__* hInst = 0);
    //! Releases the memory used by (initFramework).
    //! Called automatically in the framework's (WinMain)
    DLLEXPORT void releaseFramework();
    //! Checks whether a specific pointer points to a valid Thread object
    //! \param t The pointer to check
    //! \return 1 if the pointer is valid. 0 if the pointer does not
    //! point to an existing Thread object
    DLLEXPORT bool isThreadOk(Thread* t);
    //! Returns the framework's thread register
    DLLEXPORT ThreadRegister* getThreadRegister();
    //! Returns the DLL register containing all currently dynamically loaded
    //! DLL files
    DLLEXPORT DLLRegister* getDLLRegister();
    //! Sets DirectX to debug mode
    DLLEXPORT void setDebugDX(bool debug);
#ifdef WIN32
    //! Returns a reference to the mouse
    DLLEXPORT Mouse& getMouse();
    //! Sets the mouse cursor visibility
    DLLEXPORT void setShowCursor(bool visible);
#endif
} // namespace Framework

#endif