// -----------------------------------------------------------------------------
// CDRMEventHandler::RegisterEventObserverL
// Adds the new handler to the list of handlers.
// Checks is the handler is already in the list
// Sets the active object active if it is not active yet.
// -----------------------------------------------------------------------------
//
void CDRMEventHandler::RegisterEventObserverL(
    MDRMEventObserver& aObserver,
    const TDRMEventType& aEvent,
    const TDesC8& aContentID )
    {
    TInt count = 0;
    TBool addToServer = ETrue;

    if( iIsDelayed )
        {
        TDelayedObserverData* delayData = new (ELeave) TDelayedObserverData;
        CleanupStack::PushL( delayData);
        delayData->iRequest = KRegisterURIOperation;
        delayData->iObserver = &aObserver;
        delayData->iEventType = aEvent;
        delayData->iContentID = aContentID.AllocLC();
        iDelayedObservers->AppendL( delayData );
        CleanupStack::Pop();    // iContentID;
        CleanupStack::Pop();    // delayData;
        return;
        }

    switch ( aEvent )
        {
        case KEventAddRemove:
            if ( iAddRemoveObservers )
                {
                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
                    {
                    if ( ( *iAddRemoveObservers )[ count ]->iObserver == &aObserver &&
                         ( *iAddRemoveObservers )[ count ]->iContentID &&
                         !( *iAddRemoveObservers )[ count ]->iContentID->Compare( aContentID ) )
                        {
                        return;
                        }
                    else if( addToServer && 
                        !( *iAddRemoveObservers)[ count ]->iContentID->Compare( aContentID ) ) 
                        {
                        addToServer = EFalse;
                        }
                    }
                }
            break;
        case KEventModify:
            if ( iModifyObservers )
                {
                for ( count = 0; count < iModifyObservers->Count(); ++count )
                    {
                    if ( ( *iModifyObservers )[ count ]->iObserver == &aObserver &&
                         ( *iModifyObservers )[ count ]->iContentID &&
                         !( *iModifyObservers )[ count ]->iContentID->Compare( aContentID ) )
                        {
                        return;
                        }
                    else if( addToServer && 
                        !( *iModifyObservers)[ count ]->iContentID->Compare( aContentID ) ) 
                        {
                        addToServer = EFalse;
                        }
                    }
                }
            break;
        default:
            User::Leave(KErrArgument);
            break;
        }  

    HBufC8* contentID = aContentID.AllocLC();
    struct TObserverData* observer = new (ELeave) TObserverData;
    CleanupStack::PushL(observer);

    observer->iObserver = &aObserver;
    observer->iContentID = contentID;

    switch( aEvent )
        {
        case KEventAddRemove:
            if( this->iAddRemoveObservers ) // coverity check
                {
                iAddRemoveObservers->AppendL( observer );
                }
            break;
        case KEventModify:
            if( this->iModifyObservers ) // coverity check
                {
                iModifyObservers->AppendL( observer );
                }
            break;
        default:
            User::Leave(KErrArgument);
            break;
        }
   
    if ( !IsAdded() )
        {
        CActiveScheduler::Add( this );
        }

    if ( !IsActive() )
        {
        if( iStatus != KRequestPending )
            {
            iStatus = KRequestPending;
            iHandler->WaitForCompletion(iStatus);
            }
        SetActive();
        }

    // Register the type to the server
    if ( addToServer )
        {
        iHandler->RegisterForType(aEvent,contentID);
        }

    CleanupStack::Pop(); // contentID
    CleanupStack::Pop(); // observer;
    }
Beispiel #2
0
 /**
  * The move constructor may only be used on inactive timers.  This
  * shall only be used by derived classes to pass inactive instances
  * around.
  */
 Timer(Timer &&other) {
   assert(!IsActive());
   assert(!other.IsActive());
 }
Beispiel #3
0
bool CMission::MatchesCriteria (CSpaceObject *pSource, const SCriteria &Criteria)

//	MatchesCriteria
//
//	Returns TRUE if the given mission matches the criteria

{
    int i;

    //	By status

    if (Criteria.bIncludeActive && !IsActive())
        return false;

    if (Criteria.bIncludeOpen && m_iStatus != statusOpen)
        return false;

    if (Criteria.bIncludeRecorded && !IsRecorded())
        return false;

    if (Criteria.bIncludeUnavailable && !IsUnavailable())
        return false;

    //	Owned by source

    if (Criteria.bOnlySourceOwner)
    {
        if (pSource)
        {
            if (pSource->GetID() != m_pOwner.GetID())
                return false;
        }
        else
        {
            if (m_pOwner.GetID() != OBJID_NULL)
                return false;
        }
    }

    //	Check required attributes

    for (i = 0; i < Criteria.AttribsRequired.GetCount(); i++)
        if (!HasAttribute(Criteria.AttribsRequired[i]))
            return false;

    //	Check attributes not allowed

    for (i = 0; i < Criteria.AttribsNotAllowed.GetCount(); i++)
        if (HasAttribute(Criteria.AttribsNotAllowed[i]))
            return false;

    //	Check special attribs required

    for (i = 0; i < Criteria.SpecialRequired.GetCount(); i++)
        if (!HasSpecialAttribute(Criteria.SpecialRequired[i]))
            return false;

    //	Check special attribs not allowed

    for (i = 0; i < Criteria.SpecialNotAllowed.GetCount(); i++)
        if (HasSpecialAttribute(Criteria.SpecialNotAllowed[i]))
            return false;

    //	Match

    return true;
}
// -----------------------------------------------------------------------------
// CFMSInterruptAob::Start()
// -----------------------------------------------------------------------------
void CFMSInterruptAob::StartL(TFmsIpcCommands aType)
	{	
	FLOG(_L("CFMSInterruptAob::Start- begin"));
	iInterruptType = aType;
	if(iInterruptType == EDLUserInterrupt && iServer->ChargerTobeMonitered())
		{
		FLOG(_L("CFMSInterruptAob::Start--EUserInterrupt"));
		if(!IsActive())
			{
			//RProperty pw;
			iProperty.Attach(KPSUidHWRMPowerState,KHWRMChargingStatus);
			iStatus=KRequestPending;
			iProperty.Subscribe(iStatus);	
			SetActive();	
			}
		}
	else if(iInterruptType == EDLNetworkInterrupt && iServer->NetworkTobeMonitered())
		{	  
		FLOG(_L("CFMSInterruptAob::Start--ENetworkInterrupt"));	
		if(!IsActive())
			{		  
			iStatus=KRequestPending;			  
			TBool phonenotoffline = CheckGlobalRFStateL();
			if ( ( iBearer == EBearerIdGPRS || iBearer == EBearerIdWCDMA )
					&& phonenotoffline )
				{
				FLOG(_L("CFMSInterruptAob::Start--ENetworkInterrupt iBearer is %d"),iBearer);	
				NotifyL();
				return;			  
				}
			else if ( iBearer == EBearerIdWLAN )
				{
				//feature supported check
				iWlanAvailable = EFalse;	  
				iConnMon.GetBoolAttribute( EBearerIdWLAN, 
						0, 
						KBearerAvailability, 
						iWlanAvailable, 
						iStatus );
				SetActive();
				}
			else
				{
				FLOG(_L("CFMSInterruptAob::Start--ENetworkInterrupt--other then GPRS/ WLan bearer "));	  
				//Stop the server	  
				//Dont delete the file if interrupt is network + offline( to differentiate from hard reboot
				iServer->DeleteFile(EFalse);
				StopServer();
				}	  
			}
		}
	else if(iInterruptType == EDLMemoryInterrupt && iServer->MemoryTobeMonitered())
		{
		FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt on drive %d"),(TInt)iDrive );		  
		if(!IsActive())
			{
			User::LeaveIfError(iFs.Connect());
			TBool critical = EFalse;
			TInt err = KErrNone;
			err=IsPkgSizeMoreThanWL(critical);		  
			if(critical)
				{	 
				FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt--critical pkg dont fit on drive %d"),(TInt)iDrive );		  
				iStatus=KRequestPending;					
				iFs.NotifyDiskSpace( iSize, iDrive, iStatus ); 
				FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt-setting as active") );		  
				SetActive();	
				}
			else
				{
				if(err == KErrNone)
					{
					FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt--critical pkg fits on drive %d"),(TInt)iDrive );
					LaunchFotaEngineL();
					}
				else
					{
					FLOG(_L("CFMSInterruptAob::Start--EMemoryInterrupt--System error %d on memory drive %d"), err,(TInt)iDrive );
					}
				//Stop the server	 
				StopServer();	   
				}
			}
		}  
	else //case where variation fails or by chance if a bad interrupt reason
		{
		StopServer();	  
		}	 
	}
Beispiel #5
0
 /// \brief
 ///   Returns the current Revision Control System if it's active.
 VBASE_IMPEXP static IVRevisionControlSystem* GetActiveRCS()
 {
   return IsActive() ? GetRCS() : NULL;
 }
void CSyncCoreObjectMediator::OnMoveSpeedChangedDerived(const CMoveSpeedChangedDerivedArgs& Args)
{
	Ast(IsActive());
	CSyncCoreObjectDictator::MoveSpeedChangedExtraConn(Args,GetConnection());
}
//---------------------------------------------------------------------------
// Draw() draws the control into the parent window
// \param dirtyRect - portion of control (in window coordinates)
//        that requires redrawing.
//---------------------------------------------------------------------------
void CATSwitch::Draw(CATImage* image, const CATRect& dirtyRect)
{
    if (this->IsVisible() == false)
    {
        return;
    }

    // sanity check parent image / dirty rectangle
    CATRect imgRect(0,0,image->Width(), image->Height());
    CATASSERT(imgRect.Inside(dirtyRect), "Update rect is outside of img rect!");

    // Find intersection between dirty rect and us
    CATRect drawRect;
    bool   drawn = false;

    CATImage* disabled = fImageDisabled;
    CATImage* normal   = fImage;
    CATImage* pressed  = fImagePressed;
    CATImage* focus    = fImageFocus;
    CATImage* focusAct = fImageFocusAct;
    CATImage* active   = fImageActive;

    if (fValue > 0.5)
    {
        // All on...
        if (fImageDisabledOn)
            disabled    = fImageDisabledOn;

        if (fImageOn)
            normal      = fImageOn;

        if (fImagePressedOn)
            pressed     = fImagePressedOn;

        if (fImageFocusOn)
            focus       = fImageFocusOn;

        if (fImageFocusActOn)
            focusAct    = fImageFocusActOn;

        if (fImageActiveOn)
            active      = fImageActiveOn;
    }


    // Gracefully degrade depending on flags and whether the images are
    // available.
    if (this->fRect.Intersect(dirtyRect, &drawRect))
    {  
        CATRect ourRect;
        if ( (this->IsEnabled() == false) && (disabled))
        {
            if (drawRect.Intersect(CATRect(fRect.left, 
                fRect.top, 
                fRect.left + disabled->Width(),
                fRect.top  + disabled->Height()),
                &ourRect))
            {
                ourRect.Offset(-fRect.left, -fRect.top);

                image->Overlay(   disabled,
                    drawRect.left, 
                    drawRect.top, 
                    ourRect.left,
                    ourRect.top,
                    ourRect.Width(),
                    ourRect.Height());
                drawn = true;
            }        
        }
        else 
        {
            if (this->IsPressed() && (pressed))
            {
                if (drawRect.Intersect(CATRect(fRect.left, 
                                               fRect.top, 
                                               fRect.left + pressed->Width(),
                                               fRect.top  + pressed->Height()),
                                       &ourRect))
                {
                    ourRect.Offset(-fRect.left, -fRect.top);

                    image->Overlay( pressed,
                                    drawRect.left,
                                    drawRect.top,
                                    ourRect.left,
                                    ourRect.top,
                                    ourRect.Width(),
                                    ourRect.Height());
                    drawn = true;
                }
            }

            if ((!drawn) && ( (IsFocused() && IsActive()) || IsPressed()) && (focusAct))
            {
                if (drawRect.Intersect(CATRect( fRect.left, 
                                                fRect.top, 
                                                fRect.left + focusAct->Width(),
                                                fRect.top  + focusAct->Height()),
                                       &ourRect))
                {
                    ourRect.Offset(-fRect.left, -fRect.top);

                    image->Overlay( focusAct,
                                    drawRect.left,
                                    drawRect.top,
                                    ourRect.left,
                                    ourRect.top,
                                    ourRect.Width(),
                                    ourRect.Height());
                    drawn = true;
                }
            }

            if ((!drawn) && (IsFocused() || IsPressed()) && (focus))
            {
                if (drawRect.Intersect(CATRect( fRect.left, 
                                                fRect.top, 
                                                fRect.left + focus->Width(),
                                                fRect.top  + focus->Height()),
                                       &ourRect))
                {
                    ourRect.Offset(-fRect.left, -fRect.top);

                    image->Overlay( focus,
                                    drawRect.left,
                                    drawRect.top,
                                    ourRect.left,
                                    ourRect.top,
                                    ourRect.Width(),
                                    ourRect.Height());
                    drawn = true;
                }
            }

            if ((!drawn) && (IsActive()) && (active))
            {
                if (drawRect.Intersect(CATRect( fRect.left, 
                                                fRect.top, 
                                                fRect.left + active->Width(),
                                                fRect.top  + active->Height()),
                                       &ourRect))
                {
                    ourRect.Offset(-fRect.left, -fRect.top);

                    image->Overlay( active,
                                    drawRect.left,
                                    drawRect.top,
                                    ourRect.left,
                                    ourRect.top,
                                    ourRect.Width(),
                                    ourRect.Height());
                    drawn = true;
                }
            }
        }

        if ((!drawn) && (normal != 0))
        {
            if (drawRect.Intersect(CATRect(fRect.left, 
                fRect.top, 
                fRect.left + normal->Width(),
                fRect.top  + normal->Height()),
                &ourRect))
            {
                ourRect.Offset(-fRect.left, -fRect.top);

                image->Overlay(   normal,
                    drawRect.left,
                    drawRect.top,
                    ourRect.left,
                    ourRect.top,
                    ourRect.Width(),
                    ourRect.Height());
                drawn = true;
            }
        }

        if (!drawn)
        {

            // Right now, just make a big red rectangle where we should go.
            image->FillRect(drawRect, fBackgroundColor);
        }
    }
}
    bool ActiveWidget::AcceptInputKeyboard( const InputKeyboard &key )
    {
        _result = false; //-- Key is handled till something handle it

        if ( !key.Pressed() && key.KeyCode()==_activation_key )
        {// magic sequence of signal sends - to give nice mouse button like effet
            if ( 1 == _mb_down[0] )
            {
                _mb_down[0] = false;
                OnRelease[0].Schedule();
                OnClick[0].Schedule();
                InputDecEager(); NotifyAncestors(this);
            }
        }

        if (!OnFocusWay()) //-- Only widget with focus operates with keyboard
        {
            _pressed_keys.Clear();//-- Clear stored keyboard status
            return false;
        }
        bool likes_this_key = _on_path_key_mask.GetBit( key.KeyCode() );
        if ( HasFocus() ) { likes_this_key |= _key_mask.GetBit( key.KeyCode() ); }

        //-- Local state may be invalid, since focus changes
        bool invalid_state = !IsKeyPressed(key.KeyCode()) && !WasKeyPressed(key.KeyCode());
        if ( invalid_state ) return _result=likes_this_key;

        //-- Store local status
        bool state_changed  = MarkKey( key.KeyCode(), key.Pressed() );

        if ( !likes_this_key ) //-- If key is not handled by derivate, then
        {
            return _result=HandleKeyPress( key.KeyCode(), key.Pressed() );//-- apply internal keyboard handling
        }

        if (!IsActive()) return false; //-- Only ActiveWidget may send signals

        _result = ( _likes_chars && Keys::IsChar(key.KeyCode()) )? true : false;

        if ( !likes_this_key ) { return _result; }
        //-- If key state has changed
        if ( state_changed )
        {   
            if ( key.Pressed() )
            {
                if ( key.Cond() == Widget::FOCUSED )
                {
                    _result=OnKeyPress.Schedule_1( key.KeyCode());
                }
                else
                {
                    _result=OffKeyPress.Schedule_1( key.KeyCode());
                }
            }
            else
            {
                if ( key.Cond() == Widget::FOCUSED )
                {
                    _result=OnKeyRelease.Schedule_1( key.KeyCode()); 
                }
            }
        }
        else //-- If key state repeats
        {
            assert( key.Pressed() );

            if ( key.Cond() == Widget::FOCUSED )
            { 
                _result=WhileKey.Schedule_1( key.KeyCode() ); 
            }
            else
            { 
                _result=WhileOffKey.Schedule_1( key.KeyCode() ); 
            }
        }

        return (_result = _result && (key.Cond() == Widget::FOCUSED) );
    }
Beispiel #9
0
void
BTextWidget::StartEdit(BRect bounds, BPoseView* view, BPose* pose)
{
	view->SetTextWidgetToCheck(NULL, this);
	if (!IsEditable() || IsActive())
		return;

	BEntry entry(pose->TargetModel()->EntryRef());
	if (entry.InitCheck() == B_OK
		&& !ConfirmChangeIfWellKnownDirectory(&entry,
			B_TRANSLATE_COMMENT("rename",
				"As in 'if you rename this folder...' (en) "
				"'Wird dieser Ordner umbenannt...' (de)"),
			B_TRANSLATE_COMMENT("rename",
				"As in 'to rename this folder...' (en) "
				"'Um diesen Ordner umzubenennen...' (de)"),
			B_TRANSLATE_COMMENT("Rename",
				"Button label, 'Rename' (en), 'Umbenennen' (de)")))
		return;

	// get bounds with full text length
	BRect rect(bounds);
	BRect textRect(bounds);
	rect.OffsetBy(-2, -1);
	rect.right += 1;

	BFont font;
	view->GetFont(&font);
	BTextView* textView = new BTextView(rect, "WidgetTextView", textRect,
		&font, 0, B_FOLLOW_ALL, B_WILL_DRAW);

	textView->SetWordWrap(false);
	DisallowMetaKeys(textView);
	fText->SetUpEditing(textView);

	textView->AddFilter(new BMessageFilter(B_KEY_DOWN, TextViewFilter));

	rect.right = rect.left + textView->LineWidth() + 3;
	// center new width, if necessary
	if (view->ViewMode() == kIconMode
		|| (view->ViewMode() == kListMode && fAlignment == B_ALIGN_CENTER)) {
		rect.OffsetBy(bounds.Width() / 2 - rect.Width() / 2, 0);
	}

	rect.bottom = rect.top + textView->LineHeight() + 1;
	textRect = rect.OffsetToCopy(2, 1);
	textRect.right -= 3;
	textRect.bottom--;
	textView->SetTextRect(textRect);

	BPoint origin = view->LeftTop();
	textRect = view->Bounds();

	bool hitBorder = false;
	if (rect.left <= origin.x)
		rect.left = origin.x + 1, hitBorder = true;
	if (rect.right >= textRect.right)
		rect.right = textRect.right - 1, hitBorder = true;

	textView->MoveTo(rect.LeftTop());
	textView->ResizeTo(rect.Width(), rect.Height());

	BScrollView* scrollView = new BScrollView("BorderView", textView, 0, 0,
		false, false, B_PLAIN_BORDER);
	view->AddChild(scrollView);

	// configure text view
	switch (view->ViewMode()) {
		case kIconMode:
			textView->SetAlignment(B_ALIGN_CENTER);
			break;

		case kMiniIconMode:
			textView->SetAlignment(B_ALIGN_LEFT);
			break;

		case kListMode:
			textView->SetAlignment(fAlignment);
			break;
	}
	textView->MakeResizable(true, hitBorder ? NULL : scrollView);

	view->SetActivePose(pose);
		// tell view about pose
	SetActive(true);
		// for widget

	textView->SelectAll();
	textView->MakeFocus();

	// make this text widget invisible while we edit it
	SetVisible(false);

	ASSERT(view->Window() != NULL);
		// how can I not have a Window here???

	if (view->Window()) {
		// force immediate redraw so TextView appears instantly
		view->Window()->UpdateIfNeeded();
	}
}
Beispiel #10
0
void CAPCController::TrackTarget( void )
{
	trace_t tr;
	bool updateTime = FALSE, lineOfSight;
	QAngle angles;
	Vector barrelEnd;
	CBaseEntity *pTarget = NULL;

	barrelEnd.Init();

	if ( IsActive() )
	{
		SetNextThink( gpGlobals->curtime + 0.1f );
	}
	else
	{
		return;
	}

	// -----------------------------------
	//  Get world target position
	// -----------------------------------
	barrelEnd = WorldBarrelPosition();
	Vector worldTargetPosition;
	CBaseEntity *pEntity = (CBaseEntity *)m_hTarget;
	if ( !pEntity || ( pEntity->GetFlags() & FL_NOTARGET ) )
	{
		m_hTarget = FindTarget( m_targetEntityName, NULL );
		if ( IsActive() )
		{
			SetNextThink( gpGlobals->curtime + 2 );	// Wait 2 sec s
		}

		return;
	}
	pTarget = pEntity;

	// Calculate angle needed to aim at target
	worldTargetPosition = pEntity->EyePosition();

	float range = (worldTargetPosition - barrelEnd).Length();

	if ( !InRange( range ) )
	{
		m_bFireDelayed = false;
		return;
	}

	UTIL_TraceLine( barrelEnd, worldTargetPosition, MASK_OPAQUE, this, COLLISION_GROUP_NONE, &tr );

	lineOfSight = FALSE;
	// No line of sight, don't track
	if ( tr.fraction == 1.0 || tr.m_pEnt == pTarget )
	{
		lineOfSight = TRUE;

		CBaseEntity *pInstance = pTarget;
		if ( InRange( range ) && pInstance && pInstance->IsAlive() )
		{
			updateTime = TRUE;

			// Sight position is BodyTarget with no noise (so gun doesn't bob up and down)
			m_sightOrigin = pInstance->BodyTarget( GetLocalOrigin(), false );
		}
	}

	// Convert targetPosition to parent
	angles = AimBarrelAt( m_parentMatrix.WorldToLocal( m_sightOrigin ) );


	// Force the angles to be relative to the center position
	float offsetY = UTIL_AngleDistance( angles.y, m_yawCenter );
	float offsetX = UTIL_AngleDistance( angles.x, m_pitchCenter );
	angles.y = m_yawCenter + offsetY;
	angles.x = m_pitchCenter + offsetX;

	// Move toward target at rate or less
	float distY = UTIL_AngleDistance( angles.y, GetLocalAngles().y );

	QAngle vecAngVel = GetLocalAngularVelocity();
	vecAngVel.y = distY * 10;
	vecAngVel.y = clamp( vecAngVel.y, -m_yawRate, m_yawRate );

	// Move toward target at rate or less
	float distX = UTIL_AngleDistance( angles.x, GetLocalAngles().x );
	vecAngVel.x = distX  * 10;
	vecAngVel.x = clamp( vecAngVel.x, -m_pitchRate, m_pitchRate );
	SetLocalAngularVelocity( vecAngVel );

	SetMoveDoneTime( 0.1 );

	Vector forward;
	AngleVectors( GetLocalAngles(), &forward );
	forward = m_parentMatrix.ApplyRotation( forward );

	AngleVectors(angles, &forward);

	if ( lineOfSight == TRUE )
	{
		// FIXME: This will ultimately have to deal with NPCs being in the vehicle as well
		// See if the target is in a vehicle. If so, check its relationship
		CBasePlayer *pPlayer = ToBasePlayer( pTarget );
		if ( pPlayer && pPlayer->IsInAVehicle() )
		{
			IServerVehicle *pVehicle = pPlayer->GetVehicle();
			if ( pVehicle->ClassifyPassenger( pPlayer, CLASS_PLAYER ) == CLASS_PLAYER)
			{
				if ( !m_bFireDelayed )
				{
					m_bFireDelayed = true;
					m_flFiringDelay = gpGlobals->curtime + 1.5;	// setup delay time before we start firing
					return;
				}
				if ( gpGlobals->curtime > m_flFiringDelay )
				{
					m_OnFireAtTarget.Set(forward, this, this);		// tell apc to fire rockets, and what direction
				}
			}
		}
	}
	else
	{
		m_bFireDelayed = false;		// reset flag since we can no longer see target
	}
}
    bool ActiveWidget::AcceptInputCursor( const InputCursor &cur)
    {
        DBG_AcceptC
            int i;
        _cursor=cur.Position();
        _result=false;
        bool drag = false;
        bool was_over = IsOver(_cursor);

        if ( !IsActive() )
        {
            PointerIdle( _cursor, false );
            _was_over = was_over;
        }
        else if ( !IsOver(_cursor) || cur.Cond()==Widget::NORMAL )
        {
            for (i=0; i!=NUM_BUTTONS; ++i)
            {
                if (_mb_down[i]) { _result |= PointerMove(_cursor,i); drag=true; }
                if (_is_dragging[i]) { _result |= OnDrag[i].Send_3(_cursor,cur.Move(),_touch_pos[i]); }
            }
            if (!drag)
            {
                _result |= PointerIdle(_cursor, drag);
                _result |= WhileMoving.Schedule_3(_cursor,cur.Move(),_was_over);
            }
            _was_over = was_over; // prevent from changing shape "on-events"
        }
        else
        {
            if ( _was_over )
            {
                DBG_Text("------");
                for (i=0; i!=NUM_BUTTONS; ++i)
                {
                    if (_mb_down[i] && cur.Cond()==Widget::OFFSIDE ) 
                    { 
                        _result |= OnMoveOut[i].Schedule_1(_cursor); InputDecEager(this);
                        DBG_Text("MoveOut+");
                    }
                    else if ( cur.Cond()==Widget::INACTIVE )
                    {
                        if (_mb_down[i]) InputDecEager(this);
                        _is_dragging[i] = _mb_down[i] = false;
                        DBG_Text("ForceOut");
                    }
                }

                _result |= OnMoveOutside.Schedule_1(_cursor); HideHint();

                InputDecEager(this);
                _was_over = false;
                DBG_Text("OffSide");
            }

            if ( cur.Cond()==Widget::OFFSIDE )
            {
                _result |= WhileMoving.Schedule_3( _cursor, cur.Move(), _was_over);
            }
        }
        return ( _result = _was_over && (cur.Cond()==Widget::NORMAL) );
    }
Beispiel #12
0
void GWindow::SetFocus(GViewI *ctrl, FocusType type)
{
	#if DEBUG_SETFOCUS
	const char *TypeName = NULL;
	switch (type)
	{
		case GainFocus: TypeName = "Gain"; break;
		case LoseFocus: TypeName = "Lose"; break;
		case ViewDelete: TypeName = "Delete"; break;
	}
	#endif

	switch (type)
	{
		case GainFocus:
		{
			if (d->Focus == ctrl)
			{
				#if DEBUG_SETFOCUS
				GAutoString _ctrl = DescribeView(ctrl);
				LgiTrace("SetFocus(%s, %s) already has focus.\n", _ctrl.Get(), TypeName);
				#endif
				return;
			}

			if (d->Focus)
			{
				GView *gv = d->Focus->GetGView();
				if (gv)
				{
					#if DEBUG_SETFOCUS
					GAutoString _foc = DescribeView(d->Focus);
					LgiTrace(".....defocus GView: %s\n", _foc.Get());
					#endif
					gv->_Focus(false);
				}
				else if (IsActive())
				{
					#if DEBUG_SETFOCUS
					GAutoString _foc = DescribeView(d->Focus);
					LgiTrace(".....defocus view: %s (active=%i)\n", _foc.Get(), IsActive());
					#endif
					d->Focus->OnFocus(false);
					d->Focus->Invalidate();
				}
			}

			d->Focus = ctrl;

			if (d->Focus)
			{
				GView *gv = d->Focus->GetGView();
				if (gv)
				{
					#if DEBUG_SETFOCUS
					GAutoString _set = DescribeView(d->Focus);
					LgiTrace("GWindow::SetFocus(%s, %s) focusing GView %p\n",
						_set.Get(),
						TypeName,
						d->Focus->Handle());
					#endif

					gv->_Focus(true);
				}
				else if (IsActive())
				{			
					#if DEBUG_SETFOCUS
					GAutoString _set = DescribeView(d->Focus);
					LgiTrace("GWindow::SetFocus(%s, %s) focusing nonGView %p (active=%i)\n",
						_set.Get(),
						TypeName,
						d->Focus->Handle(),
						IsActive());
					#endif

					d->Focus->OnFocus(true);
					d->Focus->Invalidate();
				}
			}
			break;
		}
		case LoseFocus:
		{
			#if DEBUG_SETFOCUS
			GAutoString _Ctrl = DescribeView(d->Focus);
			GAutoString _Focus = DescribeView(d->Focus);
			LgiTrace("GWindow::SetFocus(%s, %s) d->Focus=%s\n",
				_Ctrl.Get(),
				TypeName,
				_Focus.Get());
			#endif
			if (ctrl == d->Focus)
			{
				d->Focus = NULL;
			}
			break;
		}
		case ViewDelete:
		{
			if (ctrl == d->Focus)
			{
				#if DEBUG_SETFOCUS
				GAutoString _Ctrl = DescribeView(d->Focus);
				LgiTrace("GWindow::SetFocus(%s, %s) on delete\n",
					_Ctrl.Get(),
					TypeName);
				#endif
				d->Focus = NULL;
			}
			break;
		}
	}
}
Beispiel #13
0
    bool Call::AddParticipant(int peerId, std::string& peerName, bool bRemoteCall)
    {
        if(m_Observers.end() != m_Observers.find(peerId))
        {
            return false;
        }
        
        if(NULL != m_pEvtQ && true == bRemoteCall)
        {
            ThreadSafeMessageQueue::ParsedMessage event;
            event["type"] = "RemotePeerCall";
            event["message"] = peerName;
            m_pEvtQ->PostMessage(event);
        }
        
        
#if(defined(GOCAST_ENABLE_VIDEO) && defined(GOCAST_LINUX))
        if(false == IsActive())
        {

            std::string title = "me";
            m_pLocalRenderer = VideoRenderer::Create(
                                    
                                    title,
                                    GOCAST_DEFAULT_RENDER_WIDTH,
                                    GOCAST_DEFAULT_RENDER_HEIGHT
                               );
            if(false == m_pLocalRenderer->Init())
            {
                VideoRenderer::Destroy(m_pLocalRenderer);
                return false;
            }
            
            m_pMediaEngine->SetVideoCapture(true);
            m_pMediaEngine->SetLocalRenderer(m_pLocalRenderer);
        }
#endif

        m_Participants[peerId] = peerName;
        m_Observers[peerId] = new PeerConnectionObserver(
                                        m_pMsgQ,
                                        &m_pWorkerThread,
                                        &m_pPeerConnectionFactory
                                  );
        
        if(false == bRemoteCall)
        {
            if(false == m_Observers[peerId]->ConnectToPeer(peerId,peerName))
            {
                RemoveParticipant(peerId, true);
                return false;
            }
        }
        else
        {
            m_Observers[peerId]->SetPeerId(peerId);
            m_Observers[peerId]->SetPeerName(peerName);            
        }

        ListParticipants();
        
        return true;
    }
Beispiel #14
0
void CMenus::OnRender()
{
	/*
	// text rendering test stuff
	render_background();

	CTextCursor cursor;
	TextRender()->SetCursor(&cursor, 10, 10, 20, TEXTFLAG_RENDER);
	TextRender()->TextEx(&cursor, "ようこそ - ガイド", -1);

	TextRender()->SetCursor(&cursor, 10, 30, 15, TEXTFLAG_RENDER);
	TextRender()->TextEx(&cursor, "ようこそ - ガイド", -1);
	
	//Graphics()->TextureSet(-1);
	Graphics()->QuadsBegin();
	Graphics()->QuadsDrawTL(60, 60, 5000, 5000);
	Graphics()->QuadsEnd();
	return;*/
	
	if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)
		SetActive(true);

	if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
	{
		CUIRect Screen = *UI()->Screen();
		Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
		RenderDemoPlayer(Screen);
	}
	
	if(Client()->State() == IClient::STATE_ONLINE && m_pClient->m_ServerMode == m_pClient->SERVERMODE_PUREMOD)
	{
		Client()->Disconnect();
		SetActive(true);
		m_Popup = POPUP_PURE;
	}
	
	if(!IsActive())
	{
		m_EscapePressed = false;
		m_EnterPressed = false;
		m_NumInputEvents = 0;
		return;
	}
	
	// update colors
	vec3 Rgb = HslToRgb(vec3(g_Config.m_UiColorHue/255.0f, g_Config.m_UiColorSat/255.0f, g_Config.m_UiColorLht/255.0f));
	ms_GuiColor = vec4(Rgb.r, Rgb.g, Rgb.b, g_Config.m_UiColorAlpha/255.0f);

	ms_ColorTabbarInactiveOutgame = vec4(0,0,0,0.25f);
	ms_ColorTabbarActiveOutgame = vec4(0,0,0,0.5f);

	float ColorIngameScaleI = 0.5f;
	float ColorIngameAcaleA = 0.2f;
	ms_ColorTabbarInactiveIngame = vec4(
		ms_GuiColor.r*ColorIngameScaleI,
		ms_GuiColor.g*ColorIngameScaleI,
		ms_GuiColor.b*ColorIngameScaleI,
		ms_GuiColor.a*0.8f);
	
	ms_ColorTabbarActiveIngame = vec4(
		ms_GuiColor.r*ColorIngameAcaleA,
		ms_GuiColor.g*ColorIngameAcaleA,
		ms_GuiColor.b*ColorIngameAcaleA,
		ms_GuiColor.a);
    
	// update the ui
	CUIRect *pScreen = UI()->Screen();
	float mx = (m_MousePos.x/(float)Graphics()->ScreenWidth())*pScreen->w;
	float my = (m_MousePos.y/(float)Graphics()->ScreenHeight())*pScreen->h;
		
	int Buttons = 0;
	if(m_UseMouseButtons)
	{
		if(Input()->KeyPressed(KEY_MOUSE_1)) Buttons |= 1;
		if(Input()->KeyPressed(KEY_MOUSE_2)) Buttons |= 2;
		if(Input()->KeyPressed(KEY_MOUSE_3)) Buttons |= 4;
	}
		
	UI()->Update(mx,my,mx*3.0f,my*3.0f,Buttons);
    
	// render
	if(Client()->State() != IClient::STATE_DEMOPLAYBACK)
		Render();

	// render cursor
	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CURSOR].m_Id);
	Graphics()->QuadsBegin();
	Graphics()->SetColor(1,1,1,1);
	IGraphics::CQuadItem QuadItem(mx, my, 24, 24);
	Graphics()->QuadsDrawTL(&QuadItem, 1);
	Graphics()->QuadsEnd();

	// render debug information
	if(g_Config.m_Debug)
	{
		CUIRect Screen = *UI()->Screen();
		Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);

		char aBuf[512];
		str_format(aBuf, sizeof(aBuf), "%p %p %p", UI()->HotItem(), UI()->ActiveItem(), UI()->LastActiveItem());
		CTextCursor Cursor;
		TextRender()->SetCursor(&Cursor, 10, 10, 10, TEXTFLAG_RENDER);
		TextRender()->TextEx(&Cursor, aBuf, -1);
	}

	m_EscapePressed = false;
	m_EnterPressed = false;
	m_NumInputEvents = 0;
}
void CSyncCoreObjectMediator::OnMoveSteppedDerived(const CFPos&)
{
	Ast(IsActive());
	CSyncCoreObjectDictator::StepExtraConn(GetConnection(),GetMovState()->GetMovedDist());
}
// ----------------------------------------------------------------------------
// CObjectExchangeClient::IsBusy()
// True, if the client is performing some operation..
// ----------------------------------------------------------------------------
//
TBool CObjectExchangeClient::IsBusy()
    {
    return IsActive();
    }
void CSyncCoreObjectMediator::OnMoveBeganDerived(const CMoveBeganDerivedArgs& Args)
{
	Ast(IsActive());
	CSyncCoreObjectDictator::MoveBeganExtraConn(Args,GetConnection());
	CSyncCoreObjectServer::OnMoveBeganDerived(Args);
}
void CSyncCoreObjectMediator::AddConnBlockCount()
{
	m_uDirBlockCount = IsActive()? 1: 0;
	m_pConn->AddConnBlockCount();
	m_queDirMaxSpeed.clear();
}
void CSyncCoreObjectMediator::OnPixelPosSetDerived(bool bForceSync)
{
	Ast( IsActive() );
	CSyncCoreObjectDictator::SyncPixelPosExtraConn(bForceSync,GetConnection());
	CSyncCoreObjectServer::OnPixelPosSetDerived(bForceSync);
}
void CSyncCoreObjectMediator::BroadCastForSyncAoi(const void* pData,uint32 uSize)const
{
	BroadCastForSyncAoiExtraConn( pData , uSize , IsActive() ? GetConnection() : NULL );
}
// -----------------------------------------------------------------------------
// CFMSInterruptAob::RunL()
// -----------------------------------------------------------------------------
void CFMSInterruptAob::RunL()
	{
	FLOG(_L("CFMSInterruptAob::RunL()- begin"));
	TInt value = 0;
	if( EUpdMonitorPhoneCallEnd == iUpdInterruptType)
      {
      FLOG(_L("RunL EPhoneCallActiveAsync--call status %d"),iCallStatus);
      if(iStatus == KErrNone && RCall::EStatusIdle == iCallStatus )
          {
          //call fota scheduler & Stop the server          
          LaunchFotaUpdate();
          StopServer();
          }
      else //call in progress, subscribe again
          {
          FLOG(_L("call in progress, subscribing again"));
          iLine.NotifyStatusChange(iStatus, iCallStatus);
          SetActive();
          }
      }
	else if( iUpdInterruptType == EUpdMonitorbattery)
	  {
	  	 FLOG(_L("CFMSInterruptAob::RunL()- handling battery monitor"));
	  	 iProperty.Attach(KPSUidHWRMPowerState,KHWRMBatteryLevel);
		   TInt err=iProperty.Get(KPSUidHWRMPowerState,KHWRMBatteryLevel,value);
		   if(err != KErrNone)
		    { 
		    	FLOG(_L("CFMSInterruptAob::RunL()- error  in getiing the battery level")); 
		    	StopServer();
		    }  
		   if(value >= iChargeToMonitor)
	    	{ iProperty.Cancel();
			    iProperty.Close();	
			  TRAPD(err, LaunchFotaScheduleUpdate());
			  if(err)
			  {
			  	FLOG(_L("CFMSInterruptAob::RunL()- error in launch fota schedule"));
			  }
            iUpdInterruptType = ENoInterrupt;
            StopServer();
			   
		    }
		
	    	else 
		   	{			
		    	FLOG(_L("CFMSInterruptAob::RunL()--status charger not connected"));
			   if(!IsActive())
			  	{
				  iStatus=KRequestPending;	
				  iProperty.Subscribe(iStatus);
				  FLOG(_L("CFMSInterruptAob::RunL()--waiting for charger Connectivity"));
				  SetActive();
				  }	
	       }
	  }     	
  else if( iInterruptType == EDLUserInterrupt)
		{
		TInt value;	
		//RProperty   pw;
		iProperty.Attach(KPSUidHWRMPowerState,KHWRMChargingStatus);
		iProperty.Get(KPSUidHWRMPowerState,KHWRMChargingStatus,value);
		// charger connected or already charging going on
		if( value == EChargingStatusCharging /*|| value == EChargingStatusChargingComplete ||
				value == EChargingStatusAlmostComplete || value == EChargingStatusChargingContinued */)
			{	
			 	FLOG(_L("CFMSInterruptAob::RunL()--status charging"));
			  HandleChargingInterruptL();			
						
			}
		else 
			{			
			FLOG(_L("CFMSInterruptAob::RunL()--status charger not connected"));
			if(!IsActive())
				{
				iStatus=KRequestPending;	
				iProperty.Subscribe(iStatus);
				FLOG(_L("CFMSInterruptAob::RunL()--waiting for charger Connectivity"));
				SetActive();
				}				
			}
		}
	else if( iInterruptType == EDLNetworkInterrupt )
		{
		FLOG(_L("CFMSInterruptAob::RunL()--ENetworkInterrupt" ));	
		/*if( iBearer == EBearerIdGPRS || iBearer == EBearerIdWCDMA )
			{
			FLOG(_L("CFMSInterruptAob::RunL()--ENetworkInterrupt:GPRS/WCDMA" ));
			}*/
		 if ( iBearer == EBearerIdWLAN )
			{
			TBuf<10> num;
			FLOG(_L("CFMSInterruptAob::RunL()--ENetworkInterrupt due to bearer id WLAN, iStatus %d"),iStatus.Int());	
			/*if(iWlanAvailable)
				FLOG(_L("iWlanAvailable :TRUE"));
			else
				FLOG(_L("iWlanAvailable :FALSE"));	*/				
			if( iWlanAvailable && iStatus == KErrNone )
				{
				FLOG(_L("CFMSInterruptAob::RunL()--status WLAN networks found"));		
				LaunchFotaEngineL();
				StopServer();				
				}
			else if( iStatus == KErrNotSupported )//feture not supported
				{
				FLOG(_L("CFMSInterruptAob::RunL()--status WLAN feature not supported"));
				StopServer();				
				}
			else 
				{
				FLOG(_L("CFMSInterruptAob::RunL()--status WLAN networks not found"));  			  
				if(!IsActive())
					{	
					iWlanAvailable = EFalse;
					iStatus=KRequestPending;	
					iConnMon.GetBoolAttribute( EBearerIdWLAN, 
							0, 
							KBearerAvailability, 
							iWlanAvailable, 
							iStatus );
					FLOG(_L("CFMSInterruptAob::RunL()--search for wlan availability"));
					SetActive();
					}		   
				}	
			}
		}	
	else if( iInterruptType == EDLMemoryInterrupt )
		{
		FLOG(_L("CFMSInterruptAob::RunL()--EMemoryInterrupt,iStatus %d"),iStatus.Int());			
		if( iStatus == KErrNone  || iStatus == KErrCancel )
			{
			TBool critical = EFalse;
			IsPkgSizeMoreThanWL(critical);
			//if download size doesn't lead to memory less than critical level
			if( !critical )	
				{
				FLOG(_L("CFMSInterruptAob::RunL()--Ok download not greater than critical level"));
				//Check network status at this moment
				
				HandleAboveCriticallevelL();
				
				
				}
			else
				{
				FLOG(_L("CFMSInterruptAob::RunL()--Ok download greater than critical level"));
				// space monitor for this		
				if(!IsActive())
					{
					iStatus=KRequestPending;					
					iFs.NotifyDiskSpace( iSize, iDrive, iStatus ); 
					SetActive(); 	
					}			
				}
			}			
		else // for size request more than disk space
			{
			FLOG(_L("CFMSInterruptAob::RunL()--bad request size greater than the disk limit"));		
			StopServer();			
			}		
		}
	else //general
		{
		//Already ahandled in session class
		}
	FLOG(_L("CFMSInterruptAob::RunL()- End"));
	}
ESetSpeedResult CSyncCoreObjectMediator::SetSpeed(float fSpeed)
{
	if( !IsActive() )
		return eSSR_NotAllowed;
	return CSyncCoreObjectDictator::SetSpeed( fSpeed );
}
Beispiel #23
0
 /**
  * Start fast-forwarding the replay by the specified number of
  * seconds.  This replays the given amount of time from the input
  * time as quickly as possible.
  */
 void FastForward(fixed delta_s) {
   if (IsActive() && !negative(virtual_time))
     fast_forward = virtual_time + delta_s;
 }
EStopMovingResult CSyncCoreObjectMediator::StopMoving()
{
	if( !IsActive() )
		return eSMR_NotAllowed;
	return CSyncCoreObjectDictator::StopMoving();
}
Beispiel #25
0
void GlowTextFieldWidget::OnWidgetPaint()
{
	GLOW_DEBUGSCOPE("GlowTextFieldWidget::OnWidgetPaint");
	
	// Backing
	if (!IsActive())
	{
		disableBackColor_.Apply();
	}
	else if (HasKeyboardFocus())
	{
		focusBackColor_.Apply();
	}
	else
	{
		backColor_.Apply();
	}
	::glRectf(-1.0f, -1.0f, 1.0f, 1.0f);
	
	// Bevels for backing
	float bevelHeight = float(4)/float(Height());
	float bevelWidth = float(4)/float(Width());
	float etchHeight = float(2)/float(Height());
	float etchWidth = float(2)/float(Width());
	if (IsActive())
	{
		if (style_ == etchedStyle)
		{
			lightBevelColor_.Apply();
			::glBegin(GL_LINE_LOOP);
			::glVertex2f(-1.0f+etchWidth, -1.0f);
			::glVertex2f(-1.0f+etchWidth, 1.0f-etchHeight-etchHeight);
			::glVertex2f(1.0f-etchWidth, 1.0f-etchHeight-etchHeight);
			::glVertex2f(1.0f-etchWidth, -1.0f);
			::glEnd();
			darkBevelColor_.Apply();
			::glBegin(GL_LINE_LOOP);
			::glVertex2f(-1.0f, -1.0f+etchHeight);
			::glVertex2f(-1.0f, 1.0f-etchHeight);
			::glVertex2f(1.0f-etchWidth-etchWidth, 1.0f-etchHeight);
			::glVertex2f(1.0f-etchWidth-etchWidth, -1.0f+etchHeight);
			::glEnd();
		}
		else if (style_ == raisedStyle || style_ == loweredStyle)
		{
			if (style_ == raisedStyle)
			{
				lightBevelColor_.Apply();
			}
			else
			{
				darkBevelColor_.Apply();
			}
			::glBegin(GL_QUAD_STRIP);
			::glVertex2f(-1.0f, -1.0f);
			::glVertex2f(-1.0f+bevelWidth, -1.0f+bevelHeight);
			::glVertex2f(-1.0f, 1.0f);
			::glVertex2f(-1.0f+bevelWidth, 1.0f-bevelHeight);
			::glVertex2f(1.0f, 1.0f);
			::glVertex2f(1.0f-bevelWidth, 1.0f-bevelHeight);
			::glEnd();

			if (style_ == raisedStyle)
			{
				darkBevelColor_.Apply();
			}
			else
			{
				lightBevelColor_.Apply();
			}
			::glBegin(GL_QUAD_STRIP);
			::glVertex2f(-1.0f, -1.0f);
			::glVertex2f(-1.0f+bevelWidth, -1.0f+bevelHeight);
			::glVertex2f(1.0f, -1.0f);
			::glVertex2f(1.0f-bevelWidth, -1.0f+bevelHeight);
			::glVertex2f(1.0f, 1.0f);
			::glVertex2f(1.0f-bevelWidth, 1.0f-bevelHeight);
			::glEnd();
		}
	}
	else
	{
		disableOutlineColor_.Apply();
		::glBegin(GL_LINE_LOOP);
		::glVertex2f(-1.0f, -1.0f);
		::glVertex2f(-1.0f, 1.0f-etchHeight);
		::glVertex2f(1.0f-etchWidth, 1.0f-etchHeight);
		::glVertex2f(1.0f-etchWidth, -1.0f);
		::glEnd();
	}
	
	// Everything else gets scissored
	GLint oldScissor[4];
	::glGetIntegerv(GL_SCISSOR_BOX, oldScissor);
	::glScissor(RootPositionX()+inset_,
		Root()->Subwindow()->Height()-Height()-RootPositionY()+inset_,
		Width()-inset_-inset_, Height()-inset_-inset_);
	
	// Highlight backing
	if (data_.SelectionLength() > 0 && HasKeyboardFocus())
	{
		hiliteBackColor_.Apply();
		float left = 0;
		float top = 0;
		float right = 0;
		float bottom = 0;
		NormalizeCoordinates(inset_-hpos_+
			data_.PixelPosOf(font_, data_.SelectionStart(), 0),
			inset_, left, top);
		NormalizeCoordinates(inset_-hpos_+
			data_.PixelPosOf(font_, data_.SelectionEnd(), 0),
			inset_+font_.Leading(), right, bottom);
		::glRectf(left, bottom, right, top);
	}
	
	// Text
	if (!IsActive())
	{
		disableTextColor_.Apply();
	}
	else if (HasKeyboardFocus())
	{
		focusTextColor_.Apply();
	}
	else
	{
		textColor_.Apply();
	}
	int startpos = 0;
	int endpos = 0;
	int pixoffset = 0;
	data_.CalcLineDrawInfo(font_, 0, hpos_, Width()-inset_-inset_,
		startpos, endpos, pixoffset);
	const char* dat = data_.String().data();
	while (pixoffset > inset_)
	{
		pixoffset -= ::glutBitmapWidth(font_, dat[startpos]);
		++startpos;
	}
	float x = 0;
	float y = 0;
	NormalizeCoordinates(inset_-pixoffset,
		inset_+font_.BaselinePos(), x, y);
	::glRasterPos2f(x, y);
	for (int i=startpos; i<endpos; i++)
	{
		::glutBitmapCharacter(font_, dat[i]);
	}
	
	// Insertion caret
	// Special scissoring
	if (blink_ || !HasKeyboardFocus() || !IsActive())
	{
		::glScissor(RootPositionX()+caretInset_,
			Root()->Subwindow()->Height()-Height()-RootPositionY()+caretInset_,
			Width()-caretInset_-caretInset_, Height()-caretInset_-caretInset_);
		if (!IsActive())
		{
			disableCaretColor_.Apply();
		}
		else if (HasKeyboardFocus())
		{
			focusCaretColor_.Apply();
		}
		else
		{
			caretColor_.Apply();
		}
		float horiz = 0;
		float top = 0;
		float bottom = 0;
		NormalizeCoordinates(inset_-hpos_+data_.PixelPosOf(font_, dragEnd_, 0),
			inset_, horiz, top);
		NormalizeCoordinates(inset_-hpos_+data_.PixelPosOf(font_, dragEnd_, 0),
			inset_+font_.Leading(), horiz, bottom);
		float hBump = float(2)/float(Width());
		float vBump = float(2)/float(Height());
		::glBegin(GL_LINES);
		::glVertex2f(horiz, bottom);
		::glVertex2f(horiz, top-vBump);
		::glVertex2f(horiz-bevelWidth, bottom);
		::glVertex2f(horiz+bevelWidth+hBump, bottom);
		::glVertex2f(horiz-bevelWidth, top-vBump);
		::glVertex2f(horiz+bevelWidth+hBump, top-vBump);
		::glEnd();
	}
	
	// Unscissor
	::glScissor(oldScissor[0], oldScissor[1], oldScissor[2], oldScissor[3]);
	
	// Activate autoscroll timer
	if (toggleAutoScroll_)
	{
		toggleAutoScroll_ = false;
		_autoScrollTimer->SetTextField(this);
		_autoScrollTimerID = Glow::RegisterTimer(autoScrollInterval_, _autoScrollTimer);
	}
}
bool CSyncCoreObjectMediator::IsMoving()const
{
	if( !IsActive() )
		return m_pFolState != NULL;
	return CSyncCoreObjectDictator::IsMoving();
}
//==========================================================================
//
//
//
//==========================================================================
void ADynamicLight::Tick()
{
    if (vid_renderer == 0)
    {
        return;
    }
    if (IsOwned())
    {
        if (!target || !target->state)
        {
            this->Destroy();
            return;
        }
        if (target->flags & MF_UNMORPHED) return;
    }

    // Don't bother if the light won't be shown
    if (!IsActive()) return;

    // I am doing this with a type field so that I can dynamically alter the type of light
    // without having to create or maintain multiple objects.
    switch(lighttype)
    {
    case PulseLight:
    {
        float diff = (level.maptime - m_lastUpdate) / (float)TICRATE;

        m_lastUpdate = level.maptime;
        m_cycler.Update(diff);
        m_currentIntensity = m_cycler.GetVal();
        break;
    }

    case FlickerLight:
    {
        BYTE rnd = randLight();
        float pct = ANGLE_TO_FLOAT(angle)/360.f;

        m_currentIntensity = float(m_intensity[rnd >= pct * 255]);
        break;
    }

    case RandomFlickerLight:
    {
        int flickerRange = m_intensity[1] - m_intensity[0];
        float amt = randLight() / 255.f;

        m_tickCount++;

        if (m_tickCount > ANGLE_TO_FLOAT(angle))
        {
            m_currentIntensity = float(m_intensity[0] + (amt * flickerRange));
            m_tickCount = 0;
        }
        break;
    }

#if 0
    // These need some more work elsewhere
    case ColorFlickerLight:
    {
        BYTE rnd = randLight();
        float pct = ANGLE_TO_FLOAT(angle)/360.f;

        m_currentIntensity = m_intensity[rnd >= pct * 255];
        break;
    }

    case RandomColorFlickerLight:
    {
        int flickerRange = m_intensity[1] - m_intensity[0];
        float amt = randLight() / 255.f;

        m_tickCount++;

        if (m_tickCount > ANGLE_TO_FLOAT(angle))
        {
            m_currentIntensity = m_intensity[0] + (amt * flickerRange);
            m_tickCount = 0;
        }
        break;
    }
#endif

    case SectorLight:
    {
        float intensity;
        float scale = args[LIGHT_SCALE] / 8.f;

        if (scale == 0.f) scale = 1.f;

        intensity = Sector->lightlevel * scale;
        intensity = clamp<float>(intensity, 0.f, 255.f);

        m_currentIntensity = intensity;
        break;
    }

    case PointLight:
        m_currentIntensity = float(m_intensity[0]);
        break;
    }

    UpdateLocation();
}
ESetPosResult CSyncCoreObjectMediator::SetPixelPos(const CFPos& PixelPos)
{
	if( !IsActive() )
		return eSPR_NotAllowed;
	return CSyncCoreObjectDictator::SetPixelPos(PixelPos);
}
Beispiel #29
0
void CFuncTank::TrackTarget( void )
{
	TraceResult tr;
	edict_t *pPlayer = FIND_CLIENT_IN_PVS( edict() );
	BOOL updateTime = FALSE, lineOfSight;
	Vector angles, direction, targetPosition, barrelEnd;
	edict_t *pTarget;

	// Get a position to aim for
	if (m_pController)
	{
		// Tanks attempt to mirror the player's angles
		angles = m_pController->pev->v_angle;
		angles[0] = 0 - angles[0];
		pev->nextthink = pev->ltime + 0.05;
	}
	else
	{
		if ( IsActive() )
			pev->nextthink = pev->ltime + 0.1;
		else
			return;

		if ( FNullEnt( pPlayer ) )
		{
			if ( IsActive() )
				pev->nextthink = pev->ltime + 2;	// Wait 2 secs
			return;
		}
		pTarget = FindTarget( pPlayer );
		if ( !pTarget )
			return;

		// Calculate angle needed to aim at target
		barrelEnd = BarrelPosition();
		targetPosition = pTarget->v.origin + pTarget->v.view_ofs;
		float range = (targetPosition - barrelEnd).Length();

		if ( !InRange( range ) )
			return;

		UTIL_TraceLine( barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr );

		lineOfSight = FALSE;
		// No line of sight, don't track
		if ( tr.flFraction == 1.0 || tr.pHit == pTarget )
		{
			lineOfSight = TRUE;

			CBaseEntity *pInstance = CBaseEntity::Instance(pTarget);
			if ( InRange( range ) && pInstance && pInstance->IsAlive() )
			{
				updateTime = TRUE;
				m_sightOrigin = UpdateTargetPosition( pInstance );
			}
		}

		// Track sight origin

// !!! I'm not sure what i changed
		direction = m_sightOrigin - pev->origin;
//		direction = m_sightOrigin - barrelEnd;
		angles = UTIL_VecToAngles( direction );

		// Calculate the additional rotation to point the end of the barrel at the target (not the gun's center)
		AdjustAnglesForBarrel( angles, direction.Length() );
	}

	angles.x = -angles.x;

	// Force the angles to be relative to the center position
	angles.y = m_yawCenter + UTIL_AngleDistance( angles.y, m_yawCenter );
	angles.x = m_pitchCenter + UTIL_AngleDistance( angles.x, m_pitchCenter );

	// Limit against range in y
	if ( angles.y > m_yawCenter + m_yawRange )
	{
		angles.y = m_yawCenter + m_yawRange;
		updateTime = FALSE;	// Don't update if you saw the player, but out of range
	}
	else if ( angles.y < (m_yawCenter - m_yawRange) )
	{
		angles.y = (m_yawCenter - m_yawRange);
		updateTime = FALSE; // Don't update if you saw the player, but out of range
	}

	if ( updateTime )
		m_lastSightTime = gpGlobals->time;

	// Move toward target at rate or less
	float distY = UTIL_AngleDistance( angles.y, pev->angles.y );
	pev->avelocity.y = distY * 10;
	if ( pev->avelocity.y > m_yawRate )
		pev->avelocity.y = m_yawRate;
	else if ( pev->avelocity.y < -m_yawRate )
		pev->avelocity.y = -m_yawRate;

	// Limit against range in x
	if ( angles.x > m_pitchCenter + m_pitchRange )
		angles.x = m_pitchCenter + m_pitchRange;
	else if ( angles.x < m_pitchCenter - m_pitchRange )
		angles.x = m_pitchCenter - m_pitchRange;

	// Move toward target at rate or less
	float distX = UTIL_AngleDistance( angles.x, pev->angles.x );
	pev->avelocity.x = distX  * 10;

	if ( pev->avelocity.x > m_pitchRate )
		pev->avelocity.x = m_pitchRate;
	else if ( pev->avelocity.x < -m_pitchRate )
		pev->avelocity.x = -m_pitchRate;

	if ( m_pController )
		return;

	if ( CanFire() && ( (fabs(distX) < m_pitchTolerance && fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT) ) )
	{
		BOOL fire = FALSE;
		Vector forward;
		UTIL_MakeVectorsPrivate( pev->angles, forward, NULL, NULL );

		if ( pev->spawnflags & SF_TANK_LINEOFSIGHT )
		{
			float length = direction.Length();
			UTIL_TraceLine( barrelEnd, barrelEnd + forward * length, dont_ignore_monsters, edict(), &tr );
			if ( tr.pHit == pTarget )
				fire = TRUE;
		}
		else
			fire = TRUE;

		if ( fire )
		{
			Fire( BarrelPosition(), forward, pev );
		}
		else
			m_fireLast = 0;
	}
	else
		m_fireLast = 0;
}
Beispiel #30
0
/*
===================
idSWF::HandleEvent
===================
*/
bool idSWF::HandleEvent( const sysEvent_t* event )
{
	if( !IsLoaded() || !IsActive() || ( !inhibitControl && useInhibtControl ) )
	{
		return false;
	}
	if( event->evType == SE_KEY )
	{
		if( event->evValue == K_MOUSE1 )
		{
			mouseEnabled = true;
			idSWFScriptVar var;
			if( event->evValue2 )
			{
			
				idSWFScriptVar waitInput = globals->Get( "waitInput" );
				if( waitInput.IsFunction() )
				{
					useMouse = false;
					idSWFParmList waitParms;
					waitParms.Append( event->evValue );
					waitInput.GetFunction()->Call( NULL, waitParms );
					waitParms.Clear();
				}
				else
				{
					useMouse = true;
				}
				
				idSWFScriptObject* hitObject = HitTest( mainspriteInstance, swfRenderState_t(), mouseX, mouseY, NULL );
				if( hitObject != NULL )
				{
					mouseObject = hitObject;
					mouseObject->AddRef();
					
					var = hitObject->Get( "onPress" );
					if( var.IsFunction() )
					{
						idSWFParmList parms;
						parms.Append( event->inputDevice );
						var.GetFunction()->Call( hitObject, parms );
						parms.Clear();
						return true;
					}
					
					idSWFScriptVar var = hitObject->Get( "onDrag" );
					if( var.IsFunction() )
					{
						idSWFParmList parms;
						parms.Append( mouseX );
						parms.Append( mouseY );
						parms.Append( true );
						var.GetFunction()->Call( hitObject, parms );
						parms.Clear();
						return true;
					}
				}
				
				idSWFParmList parms;
				parms.Append( hitObject );
				Invoke( "setHitObject", parms );
				
			}
			else
			{
				if( mouseObject )
				{
					var = mouseObject->Get( "onRelease" );
					if( var.IsFunction() )
					{
						idSWFParmList parms;
						parms.Append( mouseObject ); // FIXME: Remove this
						var.GetFunction()->Call( mouseObject, parms );
					}
					mouseObject->Release();
					mouseObject = NULL;
				}
				if( hoverObject )
				{
					hoverObject->Release();
					hoverObject = NULL;
				}
				
				if( var.IsFunction() )
				{
					return true;
				}
			}
			
			return false;
		}
		const char* keyName = idKeyInput::KeyNumToString( ( keyNum_t )event->evValue );
		idSWFScriptVar var = shortcutKeys->Get( keyName );
		// anything more than 32 levels of indirection we can be pretty sure is an infinite loop
		for( int runaway = 0; runaway < 32; runaway++ )
		{
			idSWFParmList eventParms;
			eventParms.Clear();
			eventParms.Append( event->inputDevice );
			if( var.IsString() )
			{
				// alias to another key
				var = shortcutKeys->Get( var.ToString() );
				continue;
			}
			else if( var.IsObject() )
			{
				// if this object is a sprite, send fake mouse events to it
				idSWFScriptObject* object = var.GetObject();
				// make sure we don't send an onRelease event unless we have already sent that object an onPress
				bool wasPressed = object->Get( "_pressed" ).ToBool();
				object->Set( "_pressed", event->evValue2 );
				if( event->evValue2 )
				{
					var = object->Get( "onPress" );
				}
				else if( wasPressed )
				{
					var = object->Get( "onRelease" );
				}
				if( var.IsFunction() )
				{
					var.GetFunction()->Call( object, eventParms );
					return true;
				}
			}
			else if( var.IsFunction() )
			{
				if( event->evValue2 )
				{
					// anonymous functions only respond to key down events
					var.GetFunction()->Call( NULL, eventParms );
					return true;
				}
				return false;
			}
			
			idSWFScriptVar useFunction = globals->Get( "useFunction" );
			if( useFunction.IsFunction() && event->evValue2 )
			{
				const char* action = idKeyInput::GetBinding( event->evValue );
				if( idStr::Cmp( "_use", action ) == 0 )
				{
					useFunction.GetFunction()->Call( NULL, idSWFParmList() );
				}
			}
			
			idSWFScriptVar waitInput = globals->Get( "waitInput" );
			if( waitInput.IsFunction() )
			{
				useMouse = false;
				if( event->evValue2 )
				{
					idSWFParmList waitParms;
					waitParms.Append( event->evValue );
					waitInput.GetFunction()->Call( NULL, waitParms );
				}
			}
			else
			{
				useMouse = true;
			}
			
			idSWFScriptVar focusWindow = globals->Get( "focusWindow" );
			if( focusWindow.IsObject() )
			{
				idSWFScriptVar onKey = focusWindow.GetObject()->Get( "onKey" );
				if( onKey.IsFunction() )
				{
				
					// make sure we don't send an onRelease event unless we have already sent that object an onPress
					idSWFScriptObject* object = focusWindow.GetObject();
					bool wasPressed = object->Get( "_kpressed" ).ToBool();
					object->Set( "_kpressed", event->evValue2 );
					if( event->evValue2 || wasPressed )
					{
						idSWFParmList parms;
						parms.Append( event->evValue );
						parms.Append( event->evValue2 );
						onKey.GetFunction()->Call( focusWindow.GetObject(), parms ).ToBool();
						return true;
					}
					else if( event->evValue == K_LSHIFT || event->evValue == K_RSHIFT )
					{
						idSWFParmList parms;
						parms.Append( event->evValue );
						parms.Append( event->evValue2 );
						onKey.GetFunction()->Call( focusWindow.GetObject(), parms ).ToBool();
					}
				}
			}
			return false;
		}
		idLib::Warning( "Circular reference in %s shortcutKeys.%s", filename.c_str(), keyName );
	}
	else if( event->evType == SE_CHAR )
	{
		idSWFScriptVar focusWindow = globals->Get( "focusWindow" );
		if( focusWindow.IsObject() )
		{
			idSWFScriptVar onChar = focusWindow.GetObject()->Get( "onChar" );
			if( onChar.IsFunction() )
			{
				idSWFParmList parms;
				parms.Append( event->evValue );
				parms.Append( idKeyInput::KeyNumToString( ( keyNum_t )event->evValue ) );
				onChar.GetFunction()->Call( focusWindow.GetObject(), parms ).ToBool();
				return true;
			}
		}
	}
	else if( event->evType == SE_MOUSE_ABSOLUTE || event->evType == SE_MOUSE )
	{
		mouseEnabled = true;
		isMouseInClientArea = true;
		
		// Mouse position in screen space needs to be converted to SWF space
		if( event->evType == SE_MOUSE_ABSOLUTE )
		{
			const float pixelAspect = renderSystem->GetPixelAspect();
			const float sysWidth = renderSystem->GetWidth() * ( pixelAspect > 1.0f ? pixelAspect : 1.0f );
			const float sysHeight = renderSystem->GetHeight() / ( pixelAspect < 1.0f ? pixelAspect : 1.0f );
			float scale = swfScale * sysHeight / ( float )frameHeight;
			float invScale = 1.0f / scale;
			float tx = 0.5f * ( sysWidth - ( frameWidth * scale ) );
			float ty = 0.5f * ( sysHeight - ( frameHeight * scale ) );
			
			mouseX = idMath::Ftoi( ( static_cast<float>( event->evValue ) - tx ) * invScale );
			mouseY = idMath::Ftoi( ( static_cast<float>( event->evValue2 ) - ty ) * invScale );
		}
		else
		{
		
			mouseX += event->evValue;
			mouseY += event->evValue2;
			
			mouseX = Max( Min( mouseX, idMath::Ftoi( frameWidth + renderBorder ) ), idMath::Ftoi( 0.0f - renderBorder ) );
			mouseY = Max( Min( mouseY, idMath::Ftoi( frameHeight ) ), 0 );
		}
		
		bool retVal = false;
		
		idSWFScriptObject* hitObject = HitTest( mainspriteInstance, swfRenderState_t(), mouseX, mouseY, NULL );
		if( hitObject != NULL )
		{
			hasHitObject = true;
		}
		else
		{
			hasHitObject = false;
		}
		
		if( hitObject != hoverObject )
		{
			// First check to see if we should call onRollOut on our previous hoverObject
			if( hoverObject != NULL )
			{
				idSWFScriptVar var = hoverObject->Get( "onRollOut" );
				if( var.IsFunction() )
				{
					var.GetFunction()->Call( hoverObject, idSWFParmList() );
					retVal = true;
				}
				hoverObject->Release();
				hoverObject = NULL;
			}
			// Then call onRollOver on our hitObject
			if( hitObject != NULL )
			{
				hoverObject = hitObject;
				hoverObject->AddRef();
				idSWFScriptVar var = hitObject->Get( "onRollOver" );
				if( var.IsFunction() )
				{
					var.GetFunction()->Call( hitObject, idSWFParmList() );
					retVal = true;
				}
			}
		}
		if( mouseObject != NULL )
		{
			idSWFScriptVar var = mouseObject->Get( "onDrag" );
			if( var.IsFunction() )
			{
				idSWFParmList parms;
				parms.Append( mouseX );
				parms.Append( mouseY );
				parms.Append( false );
				var.GetFunction()->Call( mouseObject, parms );
				return true;
			}
		}
		return retVal;
	}
	else if( event->evType == SE_MOUSE_LEAVE )
	{
		isMouseInClientArea = false;
	}
	else if( event->evType == SE_JOYSTICK )
	{
		idSWFParmList parms;
		parms.Append( event->evValue );
		parms.Append( event->evValue2 / 32.0f );
		Invoke( "onJoystick", parms );
	}
	return false;
}