Exemplo n.º 1
0
    void DoWork(Threading::DefaultThreadSpecificStorage::Type& CurrentThreadStorage)
    {
        //this will either set the pointer to 0 or return a valid pointer to work with.
        EventManager* EventMan = static_cast<EventManager*>( TheEntresol->GetManager(ManagerBase::MT_EventManager) );
        EventUserInput* OneInput = EventMan->PopNextUserInputEvent();

        //We check each Event
        while( 0 != OneInput )
        {
            if( OneInput->GetType() != EventBase::UserInput )
                { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Trying to process a non-EventUserInput as an EventUserInput."); }

            //we check each MetaCode in each Event
            for (unsigned int c=0; c<OneInput->GetMetaCodeCount(); c++ )
            {
                //Is the key we just pushed ESCAPE
                if(Input::KEY_ESCAPE == OneInput->GetMetaCode(c).GetCode() && Input::BUTTON_PRESSING == OneInput->GetMetaCode(c).GetMetaValue())
                    { TheEntresol->BreakMainLoop(); }
            }

            delete OneInput;
            OneInput = EventMan->PopNextUserInputEvent();
        }

        EventGameWindow* OneWindowEvent = EventMan->PopNextGameWindowEvent();
        while(0 != OneWindowEvent)
        {
            if(OneWindowEvent->GetType()!=EventBase::GameWindow)
                { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Trying to process a non-EventGameWindow as an EventGameWindow."); }

            if( !OneWindowEvent->IsEventIDValid() ) {
                StringStream ExceptionStream;
                ExceptionStream << "Invalid EventID on GameWindow Event: " << OneWindowEvent->GetEventID() << std::endl;
                MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,ExceptionStream.str());
            }

            delete OneWindowEvent;
            OneWindowEvent = EventMan->PopNextGameWindowEvent();
        }
    }