CWsSprite::~CWsSprite() { if (!IsFloating() && IsActivated() && iWin && iWin->IsVisible() && !Screen()->ChangeTracking()) ForceRedraw(); if (iAnim) CWsAnim::CloseAnim(iAnim); }
bool CEXIETHERNET::RecvStart() { if (!IsActivated()) return false; if (mHRecvEvent == INVALID_HANDLE_VALUE) RecvInit(); DWORD res = ReadFile(mHAdapter, mRecvBuffer, BBA_RECV_SIZE, (LPDWORD)&mRecvBufferLength, &mReadOverlapped); if (!res && (GetLastError() != ERROR_IO_PENDING)) { // error occurred return false; } if (res) { // Completed immediately RecvHandlePacket(); } return true; }
//----------------------------------------------------------------------------- // Update //----------------------------------------------------------------------------- void CPhysicObjSimple::Update (float fDeltaTime) { if ( ! IsActivated() ) return; // TODO: // - Actualizacion del objeto visual asociado }
//----------------------------------------------------------------------------- // Destructor //----------------------------------------------------------------------------- CPhysicObjSimple::~CPhysicObjSimple (void) { if ( IsActivated() ) { Deactivate(); } }
//----------------------------------------------------------------------------- // Activate //----------------------------------------------------------------------------- bool CPhysicObjSimple::Activate (void) { assert( !IsActivated() ); // Creacion del actor de PhysX a partir de la descripcion del modelo CPhysicModelSimple* pModel = (CPhysicModelSimple*) m_InitInfo.pPhysicModel; // Preparar la descripción del actor NxActorDesc actorDesc = pModel->GetNxActorDesc(); actorDesc.globalPose = m_InitInfo.vWorldPose; if ( m_InitInfo.ePhysicMode == PMODE_STATIC ) { actorDesc.body = NULL; } m_pActor = m_pScene->GetNxScene()->createActor (actorDesc); // Añadimos la informacion de usuario m_pActor->userData = new TActorInfo (this, 0); // Establecer el flag de actor cinematico if ( m_InitInfo.ePhysicMode == PMODE_KINEMATIC ) m_pActor->raiseBodyFlag (NX_BF_KINEMATIC); if ( m_InitInfo.ePhysicMode == PMODE_DYNAMIC ) m_pActor->clearBodyFlag (NX_BF_KINEMATIC); // Activacion de la clase padre: return CPhysicObj::Activate (); }
// ----------------------------------------------------------------------------- // ShowL // // ----------------------------------------------------------------------------- // void CAknInfoPopupNote::ShowL() { // Info pop-up note is not shown, when it does not contain any text, or // when the screen background is faded by some other UI component. if ( !iText->Text().Length() || ( !iAvkonAppUi->IsForeground() && iAvkonAppUi->IsFaded() && iHideWhenAppFaded )) { return; } // Because info pop-up note has to be drawn over pop-up toolbar, which has // normal window priority, the window priority of info pop-up note has to // be also set again to be shown over toolbar. Window().SetOrdinalPosition( 0, ECoeWinPriorityNormal ); if( !IsActivated() ) { ActivateL(); } MakeVisible( ETrue ); // Change stacked control not to refuse key events iAvkonAppUi->UpdateStackedControlFlags( this, NULL, ECoeStackFlagRefusesAllKeys ); }
bool CEXIETHERNET::RecvStart() { if (!IsActivated()) return false; if (mHRecvEvent == INVALID_HANDLE_VALUE) RecvInit(); DWORD res = ReadFile(mHAdapter, mRecvBuffer, BBA_RECV_SIZE, (LPDWORD)&mRecvBufferLength, &mReadOverlapped); if (res) { // Since the read is synchronous here, complete immediately RecvHandlePacket(); return true; } else { DWORD err = GetLastError(); if (err == ERROR_IO_PENDING) { return true; } // Unexpected error ERROR_LOG(SP1, "Failed to recieve packet with error 0x%X", err); return false; } }
void TrackballManipulator::OnMouseMove(Int32 /*pRelX*/, Int32 /*pRelY*/) { if(!IsActivated() || mEntities.size() == 0 || !HasFocus() || InputSubsystem::GetMouse().IsUp(Mouse::Button_Left)) { return; } mDragPos = CursorToSpherePos(); Quaternionf quat; Matrix4f matRotation; matRotation = mBallRot.GetInverted().ToMatrix( matRotation ); Vector3f localStart = (mDragStart-mBallPos) * matRotation; Vector3f localPos = (mDragPos-mBallPos) * matRotation; quat = quat.GetRotationArc( localPos, localStart ).GetNormalized(); mNewRotation = quat*mBallRot; mNewRotation.Normalize(); // #TODO: Rotate all objects around the center of the arcball for( std::list<Entity*>::iterator it = mEntities.begin(); it != mEntities.end(); ++it ) (*it)->SetOrientation( mNewRotation ); }
void CRandomEventCtrl::CalcExploreEvent(const CPoint &ko, CMajor *pRace, CShipMap* ships) const { if (!IsActivated()) return; if(rand() % 99 >= static_cast<int>(m_uiGlobalProb)) return; //Es findet kein Ereignis statt CBotEDoc* pDoc = resources::pDoc; AssertBotE(pDoc); //ko=Koordinate wo es passiert, pRace = die Rasse der es passiert int eventnumber=rand()%2; CString sMessageText = ""; EMPIRE_NEWS_TYPE::Typ typ = EMPIRE_NEWS_TYPE::NO_TYPE; if (eventnumber == ALIENTEC) { // Forschung insgesamt um (50 bis 150) * Anzahl Systeme erhöhen int nSystemCount = pRace->GetEmpire()->GetSystemList()->GetSize(); int nAdd = (50 + rand()%101) * nSystemCount; pRace->GetEmpire()->AddFP(nAdd); const CString& sSectorName = pDoc->GetSystem(ko.x, ko.y).CoordsName(true); sMessageText = CLoc::GetString("ALIENTEC",false,sSectorName); typ = EMPIRE_NEWS_TYPE::RESEARCH; if (pRace->IsHumanPlayer()) { const boost::shared_ptr<CEventRandom> EmpireEvent = boost::make_shared<CEventRandom>( pRace->GetRaceID(),"alientech",CLoc::GetString("ALIENTECHEADLINE"),CLoc::GetString("ALIENTECLONG",false,sSectorName)); pRace->GetEmpire()->PushEvent(EmpireEvent); } } else if(eventnumber == EVENTSHIPXP) { for (CShipMap::iterator i = ships->begin(); i != ships->end(); ++i) { if (i->second->OwnerID() == pRace->GetRaceID() && i->second->GetCo()==ko) { const int additional_experience = rand() % 401 + 50; i->second->SetCrewExperiance(additional_experience); } } sMessageText = CLoc::GetString("EVENTSHIPXP",false,pDoc->GetSystem(ko.x, ko.y).CoordsName(true)); typ = EMPIRE_NEWS_TYPE::MILITARY; } if (!sMessageText.IsEmpty()) { CEmpireNews message; message.CreateNews(sMessageText,typ,"",ko);//Nachricht erstellen pRace->GetEmpire()->AddMsg(message); resources::pClientWorker->SetToEmpireViewFor(*pRace); } }
void DragManipulator::OnMouseMove( Int32 /*pRelX*/, Int32 /*pRelY*/ ) { if(!IsActivated() || mEntities.size() == 0 || !HasFocus() || InputSubsystem::GetMouse().IsUp(Mouse::Button_Left)) { return; } mEditor->GetMainView()->MakeCurrent(); // Get the current camera. Camera* camera = mEditor->GetWorldManager().GetCurrentCamera(); // Get the renderer. Renderer* renderer = GraphicSubsystem::Instance()->GetRenderer(); GD_ASSERT(renderer); // Get the new widget and screen position. Int32 x, y; InputSubsystem::GetMouse().GetPos(x, y); Vector2f newScreenPos(x, y); QPoint widgetPos = mEditor->GetMainView()->mapFromGlobal(QPoint(x, y)); Vector2f newWidgetPos(widgetPos.x(), widgetPos.y()); // Calculate the origin screen position. Vector3f originWindowPos = renderer->WorldToScreen( mWorldPosition ); // Calculate the right offset. Vector3f rightWorldOffet = mWorldPosition + camera->GetRight(); Vector3f rightWindowOffset = renderer->WorldToScreen( rightWorldOffet ); // Calculate the up offset. Vector3f upWorldOffet = mWorldPosition + camera->GetUp(); Vector3f upWindowOffset = renderer->WorldToScreen( upWorldOffet ); // Get the offsets for 1 pixel. Float nbPixelRight = rightWindowOffset.x - originWindowPos.x; Float nbPixelUp = upWindowOffset.y - originWindowPos.y; // Get the nb. of pixels between the current mouse position and the click position. Float screenOffsetRight = newScreenPos.x - mScreenClickPos.x; Float screenOffsetUp = newScreenPos.y - mScreenClickPos.y; GD_ASSERT(mEntities.size() == mOriginPositions.size()); std::list<Entity*>::iterator itEntity = mEntities.begin(); std::list<Vector3f>::iterator itOriginPos = mOriginPositions.begin(); while(itEntity != mEntities.end()) { Vector3f newPosition = *itOriginPos + (camera->GetRight() * screenOffsetRight / nbPixelRight) + (camera->GetUp() * screenOffsetUp / -nbPixelUp); Vector3f oldPosition = (*itEntity)->GetPosition(); (*itEntity)->SetPosition(newPosition); ++itEntity; ++itOriginPos; } }
void CameraManipulator::OnMouseMove( Int32 pRelX, Int32 pRelY ) { if(!IsActivated()) return; mCamera->Pitch(-pRelY * sgk_rotationSpeed); mCamera->Yaw(-pRelX * sgk_rotationSpeed); }
bool CEXIETHERNET::Activate() { if (IsActivated()) return true; DWORD len; std::vector<std::basic_string<TCHAR>> device_guids; if (!Win32TAPHelper::GetGUIDs(device_guids)) { ERROR_LOG(SP1, "Failed to find a TAP GUID"); return false; } for (size_t i = 0; i < device_guids.size(); i++) { if (Win32TAPHelper::OpenTAP(mHAdapter, device_guids.at(i))) { INFO_LOG(SP1, "OPENED %s", device_guids.at(i).c_str()); break; } } if (mHAdapter == INVALID_HANDLE_VALUE) { PanicAlert("Failed to open any TAP"); return false; } /* get driver version info */ ULONG info[3]; if (DeviceIoControl(mHAdapter, TAP_IOCTL_GET_VERSION, &info, sizeof(info), &info, sizeof(info), &len, nullptr)) { INFO_LOG(SP1, "TAP-Win32 Driver Version %d.%d %s", info[0], info[1], info[2] ? "(DEBUG)" : ""); } if (!(info[0] > TAP_WIN32_MIN_MAJOR || (info[0] == TAP_WIN32_MIN_MAJOR && info[1] >= TAP_WIN32_MIN_MINOR))) { PanicAlertT("ERROR: This version of Dolphin requires a TAP-Win32 driver" " that is at least version %d.%d -- If you recently upgraded your Dolphin" " distribution, a reboot is probably required at this point to get" " Windows to see the new driver.", TAP_WIN32_MIN_MAJOR, TAP_WIN32_MIN_MINOR); return false; } /* set driver media status to 'connected' */ ULONG status = TRUE; if (!DeviceIoControl(mHAdapter, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status, sizeof(status), &len, nullptr)) { ERROR_LOG(SP1, "WARNING: The TAP-Win32 driver rejected a" "TAP_IOCTL_SET_MEDIA_STATUS DeviceIoControl call."); return false; } return true; }
/*************** TREE CHANGED ( EVENT ) ***************/ void QmitkFunctionalityComponentContainer::TreeChanged(const itk::EventObject & /*treeChangedEvent*/) { if(IsActivated()) { TreeChanged(); } else TreeChanged(); }
// --------------------------------------------------------- // CMsgBodyControlEditor::ActivateL // // This function is needed for overriding // CMsgExpandableControlEditor::ActivateL(). // --------------------------------------------------------- // void CMsgBodyControlEditor::ActivateL() { if ( IsActivated() ) { return; } CMsgExpandableControlEditor::ActivateL(); }
void CEXIETHERNET::Deactivate() { if (!IsActivated()) return; RecvStop(); CloseHandle(mHAdapter); mHAdapter = INVALID_HANDLE_VALUE; }
void CEXIETHERNET::RecvStop() { if (!IsActivated()) return; UnregisterWaitEx(mHReadWait, INVALID_HANDLE_VALUE); CloseHandle(mHRecvEvent); mHRecvEvent = INVALID_HANDLE_VALUE; }
void MMatchActiveTrap::AddForcedEnteredPlayer(const MUID& uid) { // 이 함수는 던져졌으나 아직 발동되지 않은 트랩을 난입자에게 나중에 알려주기 위해 사용된다. _ASSERT(!IsActivated()); int n = (int)m_vecUidForcedEntered.size(); for (int i=0; i<n; ++i) if (m_vecUidForcedEntered[i] == uid) return; m_vecUidForcedEntered.push_back(uid); }
void CWsSpriteBase::SendState(MWsWindowTreeObserver& aWindowTreeObserver) const { if(iNext) iNext->SendState(aWindowTreeObserver); if(IsActivated()) { //Sprite NodeCreated must only be sent if activated aWindowTreeObserver.NodeCreated(*this, ParentNode()); aWindowTreeObserver.NodeExtentChanged(*this, Rect()); aWindowTreeObserver.NodeActivated(*this); } }
//----------------------------------------------------------------------------- // Deactivate //----------------------------------------------------------------------------- void CPhysicObjSimple::Deactivate (void) { assert( IsActivated() ); // Destruir la informacion de usuario TActorInfo* pActorInfo = (TActorInfo*) m_pActor->userData; delete pActorInfo; // Destruccion de los actores y joints m_pScene->GetNxScene()->releaseActor (*m_pActor); // Desactivacion de la clase padre CPhysicObj::Deactivate (); }
bool CEXIETHERNET::Activate() { #ifdef __linux__ if (IsActivated()) return true; // Assumes that there is a TAP device named "Dolphin" preconfigured for // bridge/NAT/whatever the user wants it configured. if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { ERROR_LOG(SP1, "Couldn't open /dev/net/tun, unable to init BBA"); return false; } struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE; const int MAX_INTERFACES = 32; for (int i = 0; i < MAX_INTERFACES; ++i) { strncpy(ifr.ifr_name, StringFromFormat("Dolphin%d", i).c_str(), IFNAMSIZ); int err; if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0) { if (i == (MAX_INTERFACES - 1)) { close(fd); fd = -1; ERROR_LOG(SP1, "TUNSETIFF failed: Interface=%s err=%d", ifr.ifr_name, err); return false; } } else { break; } } ioctl(fd, TUNSETNOCSUM, 1); INFO_LOG(SP1, "BBA initialized with associated tap %s", ifr.ifr_name); return RecvInit(); #else NOTIMPLEMENTED("Activate"); return false; #endif }
void CameraManipulator::OnKeyDown( const Keyboard::Key& pKey ) { if(!IsActivated()) return; if(pKey == Keyboard::Key_W) mCamera->Move(sgk_movementSpeed); else if(pKey == Keyboard::Key_S) mCamera->Move(-sgk_movementSpeed); if(pKey == Keyboard::Key_D) mCamera->PanLeftRight(sgk_movementSpeed); else if(pKey == Keyboard::Key_A) mCamera->PanLeftRight(-sgk_movementSpeed); }
//In this function, calculate whether an event fails or succeeds due to given probabilities. //Functions executed in succession only decide whether an event fails due to constraints //such as population already being at minimum. void CRandomEventCtrl::CalcEvents(CMajor* pRace) { if (!IsActivated()) return; CBotEDoc const* pDoc = resources::pDoc; const unsigned event_type = rand() % (GLOBALEVENTMINOR + 1); if(event_type == GLOBALEVENTSYSTEM)//system affecting event { //Calculate whether such event happens. The more systems we have, the more //likely it is that one of them is affected. CArray<EMPIRE_SYSTEMS> const* systems = pRace->GetEmpire()->GetSystemList(); const unsigned size = systems->GetSize(); const int prob = min(m_uiProbPerSystem * size, 1000); if(rand() % 999 >= prob) return; int whichsystem = rand() % size;//wählt System aus const CPoint ko = systems->GetAt(whichsystem).ko; //sucht koordinaten des Systems //Major home systems are generally unaffected. Unbalances too much. if(pRace->GetCo() == ko) return; for(int i=0; i<100; i++) if(SystemEvent(ko, pRace)) break; } else if (event_type == GLOBALEVENTRESEARCH){ if(rand() % 99 >= static_cast<int>(m_uiGlobalProb)) return; //Es findet kein Ereignis statt GlobalEventResearch(pRace); } else //event_type == GLOBALEVENTMINOR { std::vector<CMinor*> PossibleMinors; const std::map<CString, CMinor*>* pmMinors = pDoc->GetRaceCtrl()->GetMinors(); for (map<CString, CMinor*>::const_iterator it = pmMinors->begin(); it != pmMinors->end(); ++it) { CMinor* pMinor = it->second; if(pRace->IsRaceContacted(pMinor->GetRaceID())&& pMinor->GetRelation(pRace->GetRaceID())<85 && !pMinor->GetSubjugated()) PossibleMinors.insert(PossibleMinors.end(),pMinor); } const unsigned size = PossibleMinors.size(); const int prob = min(m_uiProbPerMinor * size, 1000); if(rand() % 999 >= prob) return; GlobalEventMinor(pRace, PossibleMinors.at(rand() % size)); } }
bool CEXIETHERNET::Activate() { if (IsActivated()) return true; // Assumes TunTap OS X is installed, and /dev/tun0 is not in use // and readable / writable by the logged-in user if ((fd = open("/dev/tap0", O_RDWR)) < 0) { ERROR_LOG(SP1, "Couldn't open /dev/tap0, unable to init BBA"); return false; } INFO_LOG(SP1, "BBA initialized."); return RecvInit(); }
bool CLatentEffect::Deactivate() { if (IsActivated()) { //remove the modifier from weapon, not player if (GetModValue() == Mod::ADDITIONAL_EFFECT || GetModValue() == Mod::DMG) { CCharEntity* PChar = (CCharEntity*)m_POwner; CItemWeapon* weapon = (CItemWeapon*)PChar->getEquip((SLOTTYPE)GetSlot()); int16 modPower = GetModPower(); if (weapon != nullptr && (weapon->isType(ITEM_ARMOR) || weapon->isType(ITEM_WEAPON))) { if (GetModValue() == Mod::ADDITIONAL_EFFECT) { for (uint8 i = 0; i < weapon->modList.size(); ++i) { //ensure the additional effect is fully removed from the weapon if (weapon->modList.at(i).getModID() == Mod::ADDITIONAL_EFFECT) { weapon->modList.at(i).setModAmount(0); } } } else { weapon->addModifier(CModifier(GetModValue(), -modPower)); } } } else { m_POwner->delModifier(m_ModValue, m_ModPower); } m_Activated = false; //printf("LATENT DEACTIVATED: %d\n", m_ModValue); return true; } return false; }
void CLatentEffect::Activate() { if( !IsActivated() ) { //additional effect/dmg latents add mod to weapon, not player if (GetModValue() == MOD_ADDITIONAL_EFFECT || GetModValue() == MOD_DMG) { CCharEntity* PChar = (CCharEntity*)m_POwner; CItemWeapon* weapon = (CItemWeapon*)PChar->getEquip((SLOTTYPE)GetSlot()); weapon->addModifier(new CModifier(GetModValue(), GetModPower())); } else { m_POwner->addModifier(m_ModValue, m_ModPower); } m_Activated = true; //printf("LATENT ACTIVATED: %d, Current value: %d\n", m_ModValue, m_POwner->getMod(m_ModValue)); } }
bool CEXIETHERNET::Activate() { #ifdef __linux__ if (IsActivated()) return true; // Assumes that there is a TAP device named "Dolphin" preconfigured for // bridge/NAT/whatever the user wants it configured. if ((fd = open("/dev/net/tun", O_RDWR)) < 0) { ERROR_LOG(SP1, "Couldn't open /dev/net/tun, unable to init BBA"); return false; } struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_ONE_QUEUE; strncpy(ifr.ifr_name, "Dolphin", IFNAMSIZ); int err; if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0) { close(fd); fd = -1; ERROR_LOG(SP1, "TUNSETIFF failed: err=%d", err); return false; } ioctl(fd, TUNSETNOCSUM, 1); readEnabled = false; INFO_LOG(SP1, "BBA initialized with associated tap %s", ifr.ifr_name); return true; #else NOTIMPLEMENTED("Activate"); return false; #endif }
void CEXIETHERNET::Deactivate() { if (!IsActivated()) return; // Signal read thread to exit. readEnabled.Clear(); readThreadShutdown.Set(); // Cancel any outstanding requests from both this thread (writes), and the read thread. CancelIoEx(mHAdapter, nullptr); // Wait for read thread to exit. if (readThread.joinable()) readThread.join(); // Clean-up handles CloseHandle(mReadOverlapped.hEvent); CloseHandle(mWriteOverlapped.hEvent); CloseHandle(mHAdapter); mHAdapter = INVALID_HANDLE_VALUE; memset(&mReadOverlapped, 0, sizeof(mReadOverlapped)); memset(&mWriteOverlapped, 0, sizeof(mWriteOverlapped)); }
void FDatationControl::OnActivate(wxCommandEvent& event) { Activate(IsActivated()); }
void CExampleShellContainer::NotifyStatus(const TDesC& aMessage) { iLabel->SetTextL(aMessage); if (IsActivated()) iLabel->DrawNow(); }
void CRandomEventCtrl::CalcShipEvents() const { if (!IsActivated()) return; CBotEDoc* pDoc = resources::pDoc; AssertBotE(pDoc); // Hüllenvirus for (int x = 0; x < STARMAP_SECTORS_HCOUNT; x++) { for (int y = 0; y < STARMAP_SECTORS_VCOUNT; y++) { // 0.1% Wahrscheinlichkeit für einen Hüllenvirus pro Sektor if (rand()%1000 != 0) continue; // gibt es keine Schiffe im Sektor, dann macht ein Hüllenvirus auch nichts CSector* pSector = &(pDoc->GetSystem(x, y)); if (!pSector->GetIsShipInSector()) continue; // allen Schiffe im Sektor die Hülle auf 1 reduzieren (außer Aliens) for (CShipMap::iterator i = pDoc->m_ShipMap.begin(); i != pDoc->m_ShipMap.end(); ++i) { if (i->second->IsAlien()) continue; if (i->second->GetCo() != pSector->GetCo()) continue; int nCurrentHull = i->second->GetHull()->GetCurrentHull(); i->second->GetHull()->SetCurrentHull(-(nCurrentHull - 1), true); // allen Schiffen in der Flotte ebenfalls die Hülle auf 1 setzen for (CShips::iterator j = i->second->begin(); j != i->second->end(); ++j) { nCurrentHull = j->second->GetHull()->GetCurrentHull(); j->second->GetHull()->SetCurrentHull(-(nCurrentHull - 1), true); } } // Nachrichten an alle Major welche Schiffe in diesem Sektor hatten const std::map<CString, CMajor*>* pmMajors = pDoc->GetRaceCtrl()->GetMajors(); for (map<CString, CMajor*>::const_iterator it = pmMajors->begin(); it != pmMajors->end(); ++it) { if (!pSector->GetOwnerOfShip(it->first, true)) continue; CMajor* pMajor = it->second; if (!pMajor) continue; const CString& sSectorName = pSector->CoordsName(true); CString sMessageText = CLoc::GetString("EVENTHULLVIRUS", false, sSectorName); CEmpireNews message; message.CreateNews(sMessageText,EMPIRE_NEWS_TYPE::MILITARY,pSector->GetName(),pSector->GetCo()); pMajor->GetEmpire()->AddMsg(message); if (pMajor->IsHumanPlayer()) { resources::pClientWorker->SetToEmpireViewFor(*pMajor); pMajor->GetEmpire()->PushEvent(boost::make_shared<CEventRandom>(pMajor->GetRaceID(), "HullVirus", sMessageText, "")); } } } } }