Beispiel #1
0
void
nsPopupSetFrame::OpenPopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
{
  nsWeakFrame weakFrame(this);
  nsIFrame* activeChild = aEntry->mPopupFrame;
  nsWeakFrame weakPopupFrame(activeChild);
  nsRefPtr<nsPresContext> presContext = GetPresContext();
  nsCOMPtr<nsIContent> popupContent = aEntry->mPopupContent;
  PRBool createHandlerSucceeded = aEntry->mCreateHandlerSucceeded;
  nsAutoString popupType = aEntry->mPopupType;
  if (aActivateFlag) {
    ActivatePopup(aEntry, PR_TRUE);

    // register the rollup listeners, etc, but not if we're a tooltip
    if (!popupType.EqualsLiteral("tooltip")) {
      nsIFrame* activeChild = aEntry->mPopupFrame;
      nsIMenuParent* childPopup = nsnull;
      if (weakPopupFrame.IsAlive())
        CallQueryInterface(activeChild, &childPopup);

      // Tooltips don't get keyboard navigation
      if (childPopup && !nsMenuFrame::sDismissalListener) {
        // First check and make sure this popup wants keyboard navigation
        nsAutoString property;    
        popupContent->GetAttr(kNameSpaceID_None, nsXULAtoms::ignorekeys, property);
        if (!property.EqualsLiteral("true"))
          childPopup->InstallKeyboardNavigator();
      }

      UpdateDismissalListener(childPopup);
    }
  }
  else {
    if (createHandlerSucceeded && !OnDestroy(popupContent))
      return;

    // Unregister, but not if we're a tooltip
    if (!popupType.EqualsLiteral("tooltip")) {
      if (nsMenuFrame::sDismissalListener)
        nsMenuFrame::sDismissalListener->Unregister();
    }
    
    // Remove any keyboard navigators
    nsIMenuParent* childPopup = nsnull;
    if (weakPopupFrame.IsAlive())
      CallQueryInterface(activeChild, &childPopup);
    if (childPopup)
      childPopup->RemoveKeyboardNavigator();

    if (weakPopupFrame.IsAlive())
      ActivatePopup(aEntry, PR_FALSE);

    OnDestroyed(presContext, popupContent);
  }

  if (weakFrame.IsAlive()) {
    nsBoxLayoutState state(mPresContext);
    MarkDirtyChildren(state); // Mark ourselves dirty.
  }
}
Beispiel #2
0
//------------------------------------------------------------------------
void CItem::OnHit(float damage, const char* damageType)
{
    if(!m_properties.hitpoints)
        return;

    if(damageType && !stricmp(damageType, "repair"))
    {
        if (m_stats.health < m_properties.hitpoints) //repair only to maximum
        {
            bool destroyed = m_stats.health<=0.f;
            m_stats.health = min(float(m_properties.hitpoints),m_stats.health+damage);

            UpdateDamageLevel();

            if(destroyed && m_stats.health>0.f)
                OnRepaired();
        }
    }
    else
    {
        if (m_stats.health > 0.0f)
        {
            m_stats.health -= damage;

            UpdateDamageLevel();

            if (m_stats.health <= 0.0f)
            {
                m_stats.health = 0.0f;
                OnDestroyed();

                int n=(int)m_damageLevels.size();
                for (int i=0; i<n; ++i)
                {
                    SDamageLevel &level=m_damageLevels[i];
                    if (level.min_health==0 && level.max_health==0)
                    {
                        int slot=(m_stats.viewmode&eIVM_FirstPerson)?eIGS_FirstPerson:eIGS_ThirdPerson;

                        SpawnEffect(slot, level.effect, level.helper, Vec3Constants<float>::fVec3_Zero,
                                    Vec3Constants<float>::fVec3_OneZ, level.scale);
                    }
                }
            }
        }
    }
}
Beispiel #3
0
//------------------------------------------------------------------------
bool CGunTurret::NetSerialize(TSerialize ser, EEntityAspects aspect, uint8 profile, int flags)
{
	// call base class
	if(!CWeapon::NetSerialize(ser, aspect, profile, flags))
		return false;

	if(aspect == ASPECT_STATEBITS)
	{
		bool was_destroyed = IsDestroyed();
		bool destr=was_destroyed;
		ser.Value("destroyed",destr,'bool');

		if(ser.IsReading() && destr != was_destroyed)
		{
			if(destr)
				OnDestroyed();
			else
			{
				OnRepaired();
			}
		}

		bool enabled = m_turretparams.enabled;
		ser.Value("enabled",m_turretparams.enabled,'bool');

		if(ser.IsReading() && enabled != m_turretparams.enabled)
			Activate(m_turretparams.enabled);

		ser.Value("health", m_stats.health, 'iii');

		if(ser.IsReading())
			UpdateDamageLevel();
	}

	if(aspect == ASPECT_GOALORIENTATION)
	{
		//adjust the range
		if(ser.IsReading())
		{
			float yaw = 0.f;
			ser.Value("target_yaw",yaw, 'frad');
			m_goalYaw = yaw<0.0f?yaw + gf_PI2:yaw;
		}
		else
		{
			float yaw = m_goalYaw>gf_PI?m_goalYaw - gf_PI2:m_goalYaw;
			ser.Value("target_yaw",yaw, 'frad');
		}

		ser.Value("target_pitch",m_goalPitch, 'frad');

		EntityId old_id = m_targetId;
		ser.Value("target", m_targetId, 'eid');

		if(old_id != m_targetId)
		{
			OnTargetLocked(m_targetId ? gEnv->pEntitySystem->GetEntity(m_targetId) : 0);
		}

		if(m_fireparams.deviation_amount != 0.f)
			ser.Value("deviation", m_deviationPos);
	}

	return true;
}