コード例 #1
0
ファイル: GameState.cpp プロジェクト: ZealousV/ART
void GameStateManager::NewState(GameStates state){
	if(onStateChange!=0){
		(_setting->*this->onStateChange)(CurrentState(), state);
	}
	_states.clear();
	_states.push_back(state);
}
コード例 #2
0
ファイル: LocalLinearTrendModule.cpp プロジェクト: cran/Boom
 void LocalLinearTrendModule::ObserveDraws(
     const ScalarStateSpaceModelBase &model) {
   auto state = CurrentState(model);
   trend_draws_.row(cursor()) = state.row(0);
   sigma_level_draws_[cursor()] = sqrt(trend_model_->Sigma()(0, 0));
   sigma_slope_draws_[cursor()] = sqrt(trend_model_->Sigma()(1, 1));
 }
コード例 #3
0
ファイル: StateMgr.cpp プロジェクト: xarly/mangos
void UnitStateMgr::DropAction(UnitActionPriority priority)
{
    // Don't remove action with NONE priority - static
    if (priority < UNIT_ACTION_PRIORITY_IDLE)
        return;

    UnitActionStorage::iterator itr = m_actions.find(priority);

    if (itr != m_actions.end())
    {
        bool bActiveActionChanged = false;
        ActionInfo* oldInfo = CurrentState();
        UnitActionPtr oldAction = oldInfo ? oldInfo->Action() : UnitActionPtr();

        // if dropped current active state...
        if (oldInfo && itr->second.Action() == oldInfo->Action() && !oldInfo->HasFlag(ACTION_STATE_FINALIZED))
            bActiveActionChanged = true;

        // in first - erasing current action, if his active
        if (itr->second.Action() == m_oldAction)
            m_oldAction = UnitActionPtr(NULL);

        // Possible erasing by iterator more fast and logic, but by Key much more safe
        m_actions.erase(priority);

        // Finalized not ActionInfo, but real action (saved before), due to ActionInfo wrapper already deleted.
        if (bActiveActionChanged && oldAction)
        {
            DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "DropAction: %s finalize (direct) action %s", GetOwnerStr().c_str(), oldAction->Name());
            oldAction->Finalize(*GetOwner());
        }
        // in this point we delete last link to UnitActionPtr, after this UnitAction be auto-deleted...
    }
}
コード例 #4
0
ファイル: StateMgr.cpp プロジェクト: xarly/mangos
void UnitStateMgr::Update(uint32 diff)
{
    if (m_needReinit)
    {
        m_needReinit = false;
        InitDefaults(true);
    }

    ActionInfo* state = CurrentState();

    if (!m_oldAction)
        m_oldAction = state->Action();
    else if (m_oldAction && m_oldAction != state->Action())
    {
        if (ActionInfo* oldAction = GetAction(m_oldAction))
        {
            if (oldAction->HasFlag(ACTION_STATE_ACTIVE) &&
                !oldAction->HasFlag(ACTION_STATE_FINALIZED) &&
                !oldAction->HasFlag(ACTION_STATE_INTERRUPTED))
                oldAction->Interrupt(this);
        }
        // else do nothing - action be deleted without interrupt/finalize (may be need correct?)
        m_oldAction = state->Action();
    }

    if (!state->Update(this, diff))
    {
        DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "UnitStateMgr: %s finished action %s", GetOwnerStr().c_str(), state->TypeName());
        DropAction(state->priority);
    }
}
コード例 #5
0
ファイル: map_mode.cpp プロジェクト: endoalir/ValyriaTear
void MapMode::Reset()
{
    _current_instance = this;

    // Reload the active and inactive status effects if necessary
    if (!_activated)
        _status_effect_supervisor.LoadStatusEffects();

    _activated = true;

    // Reset video engine context properties
    VideoManager->SetStandardCoordSys();
    VideoManager->SetDrawFlags(VIDEO_BLEND, VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);

    // Make the map location known globally to other code that may need to know this information
    GlobalManager->SetMap(_map_data_filename, _map_script_filename,
                          _map_image.GetFilename(), _map_hud_name.GetString());

    _ResetMusicState();

    // Restart ambient sounds
    _object_supervisor->RestartSoundObjects();

    _intro_timer.Run();

    // Reset potential map scripts
    GetScriptSupervisor().Reset();

    // If the sprite is based on the battle formation, we'd better refresh the data now
    // if the game in in the default mode.
    // Still, we won't change the sprite in the middle of a scene for instance.
    // I.e: When going out of the menu mode.
    if(CurrentState() == private_map::STATE_EXPLORE)
        _object_supervisor->ReloadVisiblePartyMember();
}
コード例 #6
0
ファイル: game_camera.cpp プロジェクト: cmeon/pienoon
void GameCamera::TerminateMovements() {
  GameCameraState state = CurrentState();
  start_ = state;
  end_ = state;
  if (percent_.Valid()) {
    percent_.SetTarget(motive::Current1f(1.0f));
  }
  movements_ = std::queue<GameCameraMovement>();
}
コード例 #7
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
bool CScriptProxy::GotoState( int nState )
{
	if (nState == m_nCurrStateId)
		return true; // Already in this state.

	SScriptState* pState = m_pScript->GetState( nState );

	// Call End state event.
	m_pScript->CallStateFunction( CurrentState(),m_pThis,ScriptState_OnEndState );

	// If state changed kill all old timers.
	m_pEntity->KillTimer(-1);

	SEntityEvent levent;
	levent.event     = ENTITY_EVENT_LEAVE_SCRIPT_STATE;
	levent.nParam[0] = m_nCurrStateId;
	levent.nParam[1] = 0;
	m_pEntity->SendEvent( levent );

	m_nCurrStateId = nState;

	// Call BeginState event.
	m_pScript->CallStateFunction( CurrentState(),m_pThis,ScriptState_OnBeginState );

	//////////////////////////////////////////////////////////////////////////
	// Repeat check if update script function is implemented.
	m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate);

	/*
	   //////////////////////////////////////////////////////////////////////////
	   // Check if need ResolveCollisions for OnContact script function.
	   m_bUpdateOnContact = IsStateFunctionImplemented(ScriptState_OnContact);
	   //////////////////////////////////////////////////////////////////////////
	 */

	SEntityEvent eevent;
	eevent.event     = ENTITY_EVENT_ENTER_SCRIPT_STATE;
	eevent.nParam[0] = nState;
	eevent.nParam[1] = 0;
	m_pEntity->SendEvent( eevent );

	return true;
}
コード例 #8
0
ファイル: BootManagerController.cpp プロジェクト: DonCN/haiku
void
BootManagerController::Previous(WizardView* wizard)
{
	if (CurrentState() != kStateEntry)
		WizardController::Previous(wizard);
	else {
		fSettings.ReplaceBool("install", false);
		WizardController::Next(wizard);
	}
}
コード例 #9
0
ファイル: NFCStateMachine.cpp プロジェクト: zh423328/NFServer
NFCStateMachine::NFCStateMachine(const NFGUID& self, NFIAIModule* pControl)
    : mOwnerID(self),
      meCurrentState(PatrolState), // 默认一开始就巡逻
      meLastState(IdleState),
      m_pAIControlInterface(pControl)
{
    NFIState* pState = m_pAIControlInterface->GetState(CurrentState());
    mfHeartBeatTime = pState->GetHeartBeatTime();

    m_pKernelModule = pControl->GetKernelModule();
    assert(NULL != m_pKernelModule);
}
コード例 #10
0
ファイル: robot.cpp プロジェクト: haresh-chudgar/grSim
int Robot::goToLocation(int currentFrame, Eigen::Vector3d location) {
  
  currentTime = 0.2;
  desiredLocation = location;
  initialLocation = CurrentState();
  controller = PIDController();

  _maxVelocity = PIDController::MAX_TRANS_VEL;
  _maxAngularVelocity = PIDController::MAX_ROT_VEL;
  
  return execute();
}
コード例 #11
0
ファイル: game_camera.cpp プロジェクト: cmeon/pienoon
void GameCamera::ExecuteMovement(const GameCameraMovement& movement) {
  // We interpolate between start_ and end_, so start_ should be the current
  // values.
  start_ = CurrentState();
  end_ = movement.end;

  // Initialize the Motivator.
  percent_.InitializeWithTarget(
      movement.init, engine_,
      motive::CurrentToTarget1f(0.0f, movement.start_velocity, 1.0f, 0.0f,
                                movement.time));
}
コード例 #12
0
ファイル: robot.cpp プロジェクト: haresh-chudgar/grSim
int Robot::dribbleToLocation(Eigen::Vector3d location) {
  
  _maxVelocity = PIDController::MAX_TRANS_VEL/10;
  _maxAngularVelocity = PIDController::MAX_ROT_VEL/ 10;
  
  currentTime = 0.2;
  desiredLocation = location;
  initialLocation = CurrentState();
  controller = PIDController();

  return execute();
}
コード例 #13
0
ファイル: map_mode.cpp プロジェクト: endoalir/ValyriaTear
void MapMode::DrawPostEffects()
{
    VideoManager->PushState();
    VideoManager->SetStandardCoordSys();
    VideoManager->SetDrawFlags(VIDEO_BLEND, VIDEO_X_CENTER, VIDEO_Y_BOTTOM, 0);
    // Halos are additive blending made, so they should be applied
    // as post-effects but before the GUI.
    _object_supervisor->DrawLights();

    GetScriptSupervisor().DrawPostEffects();

    // Draw the gui, unaffected by potential fading effects.
    _DrawGUI();

    if(CurrentState() == STATE_DIALOGUE)
        _dialogue_supervisor->Draw();

    // Draw the treasure menu if necessary
    if(CurrentState() == STATE_TREASURE)
        _treasure_supervisor->Draw();
    VideoManager->PopState();
}
コード例 #14
0
ファイル: game_camera.cpp プロジェクト: cmeon/pienoon
void GameCamera::AdvanceFrame(WorldTime /*delta_time*/) {
  // Update the directional vectors.
  GameCameraState current = CurrentState();
  forward_ = (current.target - current.position).Normalized();
  side_ = vec3::CrossProduct(mathfu::kAxisY3f, forward_);

  // If the camera has finished zooming in, transition to zoom out.
  // Transition to next movement that's been queued.
  if (!movements_.empty() &&
      (!percent_.Valid() || percent_.Difference() == 0.0f)) {
    ExecuteMovement(movements_.front());
    movements_.pop();
  }
}
コード例 #15
0
ファイル: GameState.cpp プロジェクト: ZealousV/ART
void GameStateManager::BackState(unsigned int count){
	if(_states.size() <= count){
		CleanUp();
	}
	else 
	{
		for(unsigned int i = 0; i < count; i++){
			if(onStateChange!=0){
				(_setting->*this->onStateChange)(CurrentState(), (_states.size() > 1) ? _states.at(_states.size() - 2) : GSNone);
			}
			_states.pop_back();
		}
	}
}
コード例 #16
0
ファイル: CORNMENT.CPP プロジェクト: jimmccurdy/ArchiveGit
BOOL COrnament::PositionChanged(CPropertyState* pState) const
{
	COrnamentState* pCurrent = CurrentState();
	COrnamentState* pCompare = StateType(pState);
	
	if (!PropertySet(pState))
	{
		return FALSE;
	}

	return
		(pState == NULL)
	|| (pCurrent->m_cpPosition != pCompare->m_cpPosition);
}
コード例 #17
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
void CScriptProxy::SendScriptEvent( int Event, int nParam, bool* pRet )
{
	SScriptState* pState = CurrentState();
	for (int i = 0; i < NUM_STATES; i++)
	{
		if (m_pScript->ShouldExecuteCall(i) && pState->pStateFuns[i] && pState->pStateFuns[i]->pFunction[ScriptState_OnEvent])
		{
			if (pRet)
				Script::CallReturn( GetIScriptSystem(),pState->pStateFuns[i]->pFunction[ScriptState_OnEvent],m_pThis,Event,nParam,*pRet );
			else
				Script::Call( GetIScriptSystem(),pState->pStateFuns[i]->pFunction[ScriptState_OnEvent],m_pThis,Event,nParam );
			pRet = 0;
		}
	}
}
コード例 #18
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
void CScriptProxy::Initialize( const SComponentInitializer &init )
{
	assert(init.m_pEntity);

	if (m_pEntity == NULL)
	{
		m_pEntity = (CEntity*)init.m_pEntity;
		m_pScript = static_cast<const SComponentInitializerScriptProxy &> (init).m_pScript;

		// New object must be created here.
		CreateScriptTable(static_cast<const SComponentInitializerScriptProxy &> (init).m_pSpawnParams);

		m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate);
	}
}
コード例 #19
0
ファイル: CORNMENT.CPP プロジェクト: jimmccurdy/ArchiveGit
BOOL COrnament::SizeChanged(CPropertyState* pState) const
{
	COrnamentState* pCurrent = CurrentState();
	COrnamentState* pCompare = StateType(pState);
	
	if (!PropertySet(pState))
	{
		return FALSE;
	}

	return
		(pState == NULL)
	|| (pCurrent->m_dwStyle						!= pCompare->m_dwStyle)
	|| (pCurrent->m_czExtent					!= pCompare->m_czExtent);
}
コード例 #20
0
// ----------------------------------------------------------------------------
// CSIPSecAgreement::HandleRequestL
// ----------------------------------------------------------------------------
//
void CSIPSecAgreement::HandleRequestL( TSIPTransportParams& aTransportParams,
									   CSIPRequest& aRequest,
									   const CUri8& aRemoteTarget,
									   const TDesC8& aOutboundProxy,
									   MSIPSecUser& aUser,
									   TRegistrationId aRegistrationId )
	{
	__TEST_INVARIANT;

	AddUserIfNotStoredL( aUser );

	RStringF secClient =
		SIPStrings::StringF( SipStrConsts::ESecurityClientHeader );
	
	switch ( CurrentState() )
		{
		case EWaitResponse:
			if ( aRequest.HasHeader( secClient ) )
				{
				ProcessSecurityClientL( aRequest );
				}
			break;

		case EMechanismSelected:
			CreateSecurityVerifyL();
			//lint -fallthrough

		case EVerified:			
		default:	
			if ( !SipSecUtils::Match( SipStrConsts::ERegister,
									  aRequest.Method() ) )
				{
				aRequest.DeleteHeaders( secClient );
				}			
			iMechanism->ProcessSecurityVerifyL( aTransportParams,
											    aRequest,
											    iNextHopAddr, 
											    aRemoteTarget,
											    aOutboundProxy,
											    &aUser,
											    aRegistrationId,
											    iSecurityServer,
											    iSecurityVerify );
			CopySecurityVerifyToRequestL( aRequest );
		}

	__TEST_INVARIANT;
	}
コード例 #21
0
ファイル: StateMgr.cpp プロジェクト: alolo/mangos
void UnitStateMgr::PushAction(UnitActionId actionId, UnitActionPtr state, UnitActionPriority priority, eActionType restoreable)
{
    ActionInfo* oldInfo = CurrentState();
    UnitActionPriority _priority = oldInfo ? oldInfo->priority : UNIT_ACTION_PRIORITY_IDLE;

    // Only interrupt action, if not drop his below and action lower by priority
    if (oldInfo &&
        oldInfo->HasFlag(ACTION_STATE_ACTIVE) && 
        oldInfo->Id != actionId &&
        _priority < priority)
        oldInfo->Interrupt(this);

    if (_priority > UNIT_ACTION_PRIORITY_IDLE)
    {
        // Some speedup - testing - not need drop Idle/None actions
        DropAction(actionId, priority);
        DropAction(priority);
    }

    bool needInsert = true;

    if (restoreable != ACTION_TYPE_NONRESTOREABLE)
    {
        // Don't replace (only interrupt and reset!) restoreable actions
        UnitActionStorage::iterator itr = m_actions.find(priority);
        if (itr != m_actions.end())
        {
            if (itr->second.Id == actionId)
            {
                itr->second.Reset(this);
                needInsert = false;
            }
        }
    }

    if (needInsert)
        m_actions.insert(UnitActionStorage::value_type(priority,ActionInfo(actionId, state, priority, restoreable)));

    IncreaseCounter(actionId);
/*
    ActionInfo* newInfo = CurrentState();
    if (newInfo && newInfo != oldInfo)
    {
        if (!newInfo->HasFlag(ACTION_STATE_INITIALIZED))
            newInfo->Initialize(this);
    }
*/
}
コード例 #22
0
ファイル: CORNMENT.CPP プロジェクト: jimmccurdy/ArchiveGit
BOOL COrnament::Contains(const CPoint& cpLocation)
{
	BOOL fContains = FALSE;
	
	// Make sure the object has been initialized.
	
	if (!CommitNeeded())
	{
		if (CurrentState()->m_crBounds.PtInRect(cpLocation))
		{
			fContains = TRUE;
		}
	}
	
	return fContains;
}
コード例 #23
0
NFCStateMachine::NFCStateMachine(const NFGUID& self, NFIPluginManager* p)
    : mOwnerID(self),
      meCurrentState(PatrolState),
      meLastState(IdleState)
{
	pPluginManager = p;

    NFIState* pState = GetState(CurrentState());
    mfHeartBeatTime = pState->GetHeartBeatTime();

	m_pKernelModule = pPluginManager->FindModule<NFIKernelModule>();
	m_pAIModule = pPluginManager->FindModule<NFIAIModule>();
	m_pMoveModule = pPluginManager->FindModule<NFIMoveModule>();
	m_pElementModule = pPluginManager->FindModule<NFIElementModule>();
	m_pHateModule = pPluginManager->FindModule<NFIHateModule>();
}
コード例 #24
0
// ----------------------------------------------------------------------------
// CSIPSecAgreement::ResponseReceivedL
// If a security-agreement related response containing Security-Server is
// received, (re)select the mechanism.
// Response is not received in EMechanismSelected state, as when the updated
// request is sent, agreement enters EVerified state.
// ----------------------------------------------------------------------------
//
void CSIPSecAgreement::ResponseReceivedL( CSIPResponse& aResponse,
										  const MSIPSecUser& aUser,
										  TBool aUseSecurityServerHeaders )
	{
	__TEST_INVARIANT;

	AddUserIfNotStoredL( aUser );

	TBool hasSecurityServer = aResponse.HasHeader(
		SIPStrings::StringF( SipStrConsts::ESecurityServerHeader ) );
	if ( hasSecurityServer &&
		 IsSecAgreeResponse( aResponse.ResponseCode() ) &&
		 aUseSecurityServerHeaders )
		{
		// Clear old Security-Verify and mechanism, causing agreement enter
		// EWaitResponse state.
		iSecurityVerify.ResetAndDestroy();
		iMechanism = NULL;
		}

	if ( CurrentState() == EWaitResponse )
		{
		// Don't accept a direct 2xx to the initial request which had
		// Security-Client and thus expects a challenge.
		__ASSERT_ALWAYS( aResponse.Type() != CSIPResponse::E2XX,
						 User::Leave( KErrNotFound ) );		
		if ( IsSecAgreeResponse( aResponse.ResponseCode() ) )
			{			
			// Security-Server required, as request had Security-Client.
			__ASSERT_ALWAYS( hasSecurityServer, User::Leave( KErrNotFound ) );

			if ( aUseSecurityServerHeaders )
				{
				ChooseMechanismL( aResponse );

				// Check if server initiated sec-agree is allowed
				if ( iClientMechanisms->IsEmpty() &&
					 !iMechanism->IsServerInitiatedSecAgreeAllowed() )
					{
					User::Leave( KErrNotSupported );
					}
				}
			}
		}

	__TEST_INVARIANT;
	}
コード例 #25
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
void CScriptProxy::ChangeScript( IEntityScript* pScript, SEntitySpawnParams* params )
{
	if (pScript)
	{
		// Release current
		SAFE_RELEASE(m_pThis);

		m_pScript                = static_cast<CEntityScript*>(pScript);
		m_nCurrStateId           = 0;
		m_fScriptUpdateRate      = 0;
		m_fScriptUpdateTimer     = 0;
		m_bEnableSoundAreaEvents = false;

		m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate);

		// New object must be created here.
		CreateScriptTable(params);
	}
}
コード例 #26
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
void CScriptProxy::Update( SEntityUpdateContext &ctx )
{
	// Update`s script function if present.
	if (m_bUpdateScript)
	{
		// Shouldn't be the case, but we must not call Lua with a 0 frametime to avoid potential FPE
		assert(ctx.fFrameTime > FLT_EPSILON);

		if (CVar::pUpdateScript->GetIVal())
		{
			m_fScriptUpdateTimer -= ctx.fFrameTime;
			if (m_fScriptUpdateTimer <= 0)
			{
				ENTITY_PROFILER
				  m_fScriptUpdateTimer = m_fScriptUpdateRate;

				//////////////////////////////////////////////////////////////////////////
				// Script Update.
				m_pScript->CallStateFunction( CurrentState(),m_pThis,ScriptState_OnUpdate,ctx.fFrameTime );
			}
		}
	}
}
コード例 #27
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
void CScriptProxy::Reload( IEntity* pEntity,SEntitySpawnParams &params )
{
	FUNCTION_PROFILER( GetISystem(), PROFILE_ENTITY );

	IEntityClass*  pClass        = (pEntity ? pEntity->GetClass() : NULL);
	CEntityScript* pEntityScript = (pClass ? (CEntityScript*)pClass->GetIEntityScript() : NULL);
	if (pEntityScript && pEntityScript->LoadScript())
	{
		// Release current
		SAFE_RELEASE(m_pThis);

		m_pEntity                = (CEntity*)pEntity;
		m_pScript                = pEntityScript;
		m_nCurrStateId           = 0;
		m_fScriptUpdateRate      = 0;
		m_fScriptUpdateTimer     = 0;
		m_bEnableSoundAreaEvents = false;

		m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate);

		// New object must be created here.
		CreateScriptTable(&params);
	}
}
コード例 #28
0
ファイル: StateMgr.cpp プロジェクト: alolo/mangos
UnitActionPtr UnitStateMgr::CurrentAction()
{
    ActionInfo* action = CurrentState();
    return action ? action->Action() : UnitActionPtr(NULL);
}
コード例 #29
0
ファイル: CORNMENT.CPP プロジェクト: jimmccurdy/ArchiveGit
CBitmap* COrnament::GetImage(void)
{
	CDC *pDC = m_pContext->GetDC();
	ASSERT(pDC != NULL);

	// If the image bitmap is not valid give the current state, free the
	// current bitmap and build the new one.
			
	if (ImageNeeded())
	{
		m_bmImage.DeleteObject();
	}

	// Check if we need to build a new bitmap.		
		
	if (m_bmImage.GetSafeHandle() == NULL)
	{
		// Create the bitmap for the image.
			
		CRect crImage(0, 0, Max(CurrentState()->m_czExtent.cx, 1), Max(CurrentState()->m_czExtent.cy, 1));
		
		if (m_bmImage.CreateCompatibleBitmap(pDC, crImage.Width(), crImage.Height()))
		{
			// Create a memory compatible DC and select the new bitmap into it.
				
			CDC ImageDC;
				
			if (ImageDC.CreateCompatibleDC(pDC))
			{
				CBrush cbTransparent(RGB(0,0,0));
				
				int nContext;
							
				if ((nContext = ImageDC.SaveDC()) != 0)
				{
					ImageDC.SetMapMode(MM_TEXT);
						
					if (ImageDC.SelectObject(&m_bmImage) != NULL)
					{
						// Create the image. Pixels that are transparent should be set to sero (black).
							
						ImageDC.FillRect(&crImage, &cbTransparent);
						DrawImage(&ImageDC);
						ClearImageNeeded();
					}
						
					ImageDC.RestoreDC(nContext);
				}
			}
		}
	}
	
	m_pContext->ReleaseDC();

	ASSERT(m_bmImage.GetSafeHandle() != NULL);
	
	if (m_bmImage.GetSafeHandle() == NULL)
	{
		return NULL;
	}
	
	return &m_bmImage;
}
コード例 #30
0
ファイル: CORNMENT.CPP プロジェクト: jimmccurdy/ArchiveGit
CBitmap* COrnament::GetMask(void)
{
	CDC *pDC	= m_pContext->GetDC();
	ASSERT(pDC != NULL);

	// If the mask bitmap is not valid give the current state, free the
	// current bitmap and build the new one.
	
	if (MaskNeeded())
	{
		m_bmMask.DeleteObject();
	}

	// Check if we need to build a new bitmap.		
	
	if (m_bmMask.GetSafeHandle() == NULL)
	{
		// Create the bitmap for the mask.

		CRect crMask(0, 0, Max(CurrentState()->m_czExtent.cx, 1), Max(CurrentState()->m_czExtent.cy, 1));
		
		if (m_bmMask.CreateBitmap(crMask.Width(), crMask.Height(), 1, 1, NULL))
		{
			// Create a memory compatible DC and select the new bitmap into it.
			
			CDC MaskDC;
			
			if (MaskDC.CreateCompatibleDC(pDC))
			{
				CBrush cbTransparent(RGB(255,255,255));
				
				int nContext;
					
				if ((nContext = MaskDC.SaveDC()) != 0)
				{
					MaskDC.SetMapMode(MM_TEXT);
					
					if (MaskDC.SelectObject(&m_bmMask) != NULL)
					{
						// Create the mask image. Pixels that should be masked out should
						// be set to zero (black). Pixels that should be transparent should
						// be set to one (white).
						
						MaskDC.FillRect(&crMask, &cbTransparent);
						DrawMask(&MaskDC);
						ClearMaskNeeded();
					}
					
					MaskDC.RestoreDC(nContext);
				}
			}
		}
	}
	
	m_pContext->ReleaseDC();

	ASSERT(m_bmMask.GetSafeHandle() != NULL);
	
	if (m_bmMask.GetSafeHandle() == NULL)
	{
		return NULL;
	}
	
	return &m_bmMask;
}