// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool SliderControl::VOnAction() { m_sliderPos = CalculateSliderPositionFromButton(); IEventDataPtr sliderActionEvent(GCC_NEW EvtData_Slider_Action(AbstractWidget::VGetId(), m_eventTypeId, m_sliderPos)); if(!safeQueEvent(sliderActionEvent)) { std::string idStr; try { idStr = boost::lexical_cast<std::string, ScreenElementId>(AbstractWidget::VGetId()); } catch(...) {} GF_LOG_TRACE_ERR("SliderControl::VOnAction()", std::string("Failed to send the EvtData_Slider_Action event for the button ") + idStr); return (false); } return (true); }
// // TeapotWarsBaseGame::VRemoveActor - TODO // void CometConquestBaseGame::VRemoveActor(ActorId aid) { shared_ptr<IActor> actor = VGetActor( aid ); assert(actor && "No such actor!"); if (!actor) { return; } //Stuff about calling function when actor is destroyed BaseGameLogic::VRemoveActor(aid); //Now remove the actor from the system. safeQueEvent( IEventDataPtr( GCC_NEW EvtData_Destroy_Actor( aid ) ) ); }
void BaseGameLogic::VChangeState(BaseGameState newState) { if (newState==BGS_WaitingForPlayers) { // Get rid of the Main Menu... m_gameViews.pop_front(); //todo // Note: Split screen support would require this to change! m_ExpectedPlayers = 1; m_ExpectedRemotePlayers = g_pApp->m_pOptions->m_expectedPlayers; if (!g_pApp->m_pOptions->m_gameHost.empty()) { VSetProxy(); m_ExpectedRemotePlayers = 0; // the server will create these ClientSocketManager *pClient = GCC_NEW ClientSocketManager(g_pApp->m_pOptions->m_gameHost, g_pApp->m_pOptions->m_listenPort); if (!pClient->Connect()) { // Throw up a main menu VChangeState(BGS_MainMenu); return; } g_pApp->m_pBaseSocketManager = pClient; } else if (m_ExpectedRemotePlayers > 0) { BaseSocketManager *pServer = GCC_NEW BaseSocketManager(); if (!pServer->Init()) { // Throw up a main menu VChangeState(BGS_MainMenu); return; } pServer->AddSocket(new GameServerListenSocket(g_pApp->m_pOptions->m_listenPort)); g_pApp->m_pBaseSocketManager = pServer; } } m_State = newState; if (!m_bProxy) { safeQueEvent( IEventDataPtr(GCC_NEW EvtData_Game_State(m_State)) ); } }
// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool ListButtonControl::VOnAction() { std::string text; if(!m_list.empty()) { text.assign(*m_curr); } IEventDataPtr buttonActionEvent(GCC_NEW EvtData_List_Button_Action(AbstractWidget::VGetId(), AbstractButtonControl::GetEventType(), text)); if(!safeQueEvent(buttonActionEvent)) { std::string idStr; try { idStr = boost::lexical_cast<std::string, ScreenElementId>(AbstractWidget::VGetId()); } catch(...) {} GF_LOG_TRACE_ERR("ListButtonControl::ListButtonControl()", std::string("Failed to send the EvtData_List_Button_Action event for the list button ") + idStr); return (false); } return (true); }
// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool EventManager::ScriptDefinedEvent::VQueueEventFromScript( LuaObject & srcData ) const { IEventDataPtr queueEventPtr(GCC_NEW EvtData_ScriptEvtData( m_EventType, srcData )); return safeQueEvent( queueEventPtr ); }