Ejemplo n.º 1
0
void CMomentaryRotButton :: UpdateButton( void )
{
	// reverse our direction and play movement sound every time the player
	// pauses between uses.
	bool bPlaySound = false;
	
	if( !m_lastUsed )
	{
		bPlaySound = true;
		m_direction = -m_direction;
	}

	m_lastUsed = 1;

	float flPos = GetPos( GetLocalAngles() );
	UpdateSelf( flPos, bPlaySound );

	// Think every frame while we are moving.
	// HACK: Don't reset the think time if we already have a pending think.
	// This works around an issue with host_thread_mode > 0 when the player's
	// clock runs ahead of the server.
	if( !m_pfnThink )
	{
		SetThink( &CMomentaryRotButton::UpdateThink );
		SetNextThink( 0 );
	}
}
Ejemplo n.º 2
0
void OUGUIObject::UpdateGUI(float fDeltaTime, float fX, float fY)
{
    OUGUIObject* pControl;
    float fDX;
    float fDY;
    OUPOINT pt;

    //for(GUIMap::iterator it = m_pControlList.begin(); it != m_pControlList.end(); it++)
    //{
    //    pControl = it->second->m_pObject;
    //    
    //    pt = pControl->GetRelativePos();
    //    fDX = fX - pt.m_fX;
    //    fDY = fY - pt.m_fY;
    //    pControl->UpdateGUI(fDeltaTime, fDX, fDY);
    //}

    pt = GetRelativePos();
    for(GUIList::reverse_iterator it = m_pControlList.rbegin(); it != m_pControlList.rend(); it++)
    {
        pControl = (*it)->m_pObject;

        if(!pControl->GetShowMode()) continue;

        fDX = fX - pt.m_fX;
        fDY = fY - pt.m_fY;
        pControl->UpdateGUI(fDeltaTime, fDX, fDY);
    }

    /** 更新自身 */
    UpdateSelf(fDeltaTime, fX, fY);

    /** 查看焦点控件 */
    OUGUIObject* pFocus = OUGUIObject::GetFocusControl();
    //if(pFocus)
    //{
    //    /** 若自身或者有子控件是焦点,则将其移至父控件的链表尾 */
    //    if(this == pFocus || this->IsChild(pFocus))
    //    {
    //        if(m_pParent) m_pParent->MoveToTail(this);
    //    }
    //}
    for(GUIList::iterator it = m_pControlList.begin(); it != m_pControlList.end(); it++)
    {
        pControl = (*it)->m_pObject;
        if(pFocus == pControl || pControl->IsChild(pFocus))
        {
            MoveToTail(pControl);
            break;
        }
    }
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pActivator - 
//			pCaller - 
//			useType - 
//			value - 
//-----------------------------------------------------------------------------
void CMomentaryRotButton::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	if ( m_bDisabled == true )
		return;

	if (m_bLocked)
	{
		if ( OnUseLocked( pActivator ) && HasSpawnFlags( SF_BUTTON_JIGGLE_ON_USE_LOCKED ) )
		{
			// Jiggle two degrees.
			float flDist = 2.0 / m_flMoveDistance;

			// Must be first!
			g_EventQueue.AddEvent( this, "_DisableUpdateTarget", 0, this, this );

			variant_t value;
			value.SetFloat( flDist );
			g_EventQueue.AddEvent( this, "SetPosition", value, 0.01, this, this );

			value.SetFloat( 0.0 );
			g_EventQueue.AddEvent( this, "SetPosition", value, 0.1, this, this );

			value.SetFloat( 0.5 * flDist );
			g_EventQueue.AddEvent( this, "SetPosition", value, 0.2, this, this );

			value.SetFloat( 0.0 );
			g_EventQueue.AddEvent( this, "SetPosition", value, 0.3, this, this );

			// Must be last! And must be late enough to cover the settling time.
			g_EventQueue.AddEvent( this, "_EnableUpdateTarget", 0.5, this, this );
		}

		return;
	}

	//
	// Reverse our direction and play movement sound every time the player
	// pauses between uses.
	//
	bool bPlaySound = false;
	
	if ( !m_lastUsed )
	{
		bPlaySound = true;
		m_direction = -m_direction;

		//Alert that we've been pressed
		m_OnPressed.FireOutput( m_hActivator, this );
	}

	m_lastUsed = 1;

	float flPos = GetPos( GetLocalAngles() );
	UpdateSelf( flPos, bPlaySound );

	//
	// Think every frame while we are moving.
	// HACK: Don't reset the think time if we already have a pending think.
	// This works around an issue with host_thread_mode > 0 when the player's
	// clock runs ahead of the server.
	//
	if ( !m_pfnThink )
	{
		SetThink( &CMomentaryRotButton::UpdateThink );
		SetNextThink( gpGlobals->curtime );
	}
}