Exemple #1
0
void CUIActorMenu::UpdateConditionProgressBars()
{
	PIItem itm = m_pActorInvOwner->inventory().ItemFromSlot(INV_SLOT_2);
	if(itm)
	{
		m_WeaponSlot1_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	}
	else
		m_WeaponSlot1_progress->SetProgressPos(0);

	itm = m_pActorInvOwner->inventory().ItemFromSlot(INV_SLOT_3);
	if(itm)
		m_WeaponSlot2_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	else
		m_WeaponSlot2_progress->SetProgressPos(0);

	itm = m_pActorInvOwner->inventory().ItemFromSlot(OUTFIT_SLOT);
	if(itm)
		m_Outfit_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	else
		m_Outfit_progress->SetProgressPos(0);

	itm = m_pActorInvOwner->inventory().ItemFromSlot(HELMET_SLOT);
	if(itm)
		m_Helmet_progress->SetProgressPos(iCeil(itm->GetCondition()*15.0f)/15.0f);
	else
		m_Helmet_progress->SetProgressPos(0);
}
Exemple #2
0
void CUICellItem::UpdateConditionProgressBar()
{
    if(m_pParentList && m_pParentList->GetConditionProgBarVisibility())
    {
        PIItem itm = (PIItem)m_pData;
        CWeapon* pWeapon = smart_cast<CWeapon*>(itm);
        CCustomOutfit* pOutfit = smart_cast<CCustomOutfit*>(itm);

        if(pWeapon || pOutfit )
        {
            Ivector2 itm_grid_size = GetGridSize(true);
            if(m_pParentList->GetVerticalPlacement())
                std::swap(itm_grid_size.x, itm_grid_size.y);
            Ivector2 cell_size = m_pParentList->CellSize();

			m_pConditionState->SetWidth(cell_size.x);

			float x = 0.5f*(itm_grid_size.x * (cell_size.x)-m_pConditionState->GetWidth());
            float y = itm_grid_size.y * (cell_size.y) - m_pConditionState->GetHeight() - 1.f;

            m_pConditionState->SetWndPos(Fvector2().set(x,y));
            m_pConditionState->SetProgressPos(itm->GetCondition()*100.0f);
            m_pConditionState->Show(true);
            return;
        }
    }
    m_pConditionState->Show(false);
}
void CUIActorMenu::TryRepairItem(CUIWindow* w, void* d)
{
	PIItem item = get_upgrade_item();
	if ( !item )
	{
		return;
	}
	if ( item->GetCondition() > 0.99f )
	{
		return;
	}
	LPCSTR item_name = item->m_section_id.c_str();
	LPCSTR partner = m_pPartnerInvOwner->CharacterInfo().Profile().c_str();

	luabind::functor<bool> funct;
	R_ASSERT2(
		ai().script_engine().functor( "inventory_upgrades.can_repair_item", funct ),
		make_string( "Failed to get functor <inventory_upgrades.can_repair_item>, item = %s", item_name )
		);
	bool can_repair = funct( item_name, item->GetCondition(), partner );

	luabind::functor<LPCSTR> funct2;
	R_ASSERT2(
		ai().script_engine().functor( "inventory_upgrades.question_repair_item", funct2 ),
		make_string( "Failed to get functor <inventory_upgrades.question_repair_item>, item = %s", item_name )
		);
	LPCSTR question = funct2( item_name, item->GetCondition(), can_repair, partner );

	m_repair_mode = true;
	if ( can_repair )
	{
		CallMessageBoxYesNo( question );
	} 
	else
	{
		CallMessageBoxOK( question );
	}
}
void CUIActorMenu::RepairEffect_CurItem()
{
	PIItem item = CurrentIItem();
	if ( !item )
	{
		return;	
	}
	LPCSTR item_name = item->m_section_id.c_str();

	luabind::functor<void>	funct;
	R_ASSERT( ai().script_engine().functor( "inventory_upgrades.effect_repair_item", funct ) );
	funct( item_name, item->GetCondition() );

	item->SetCondition( 1.0f );
}
Exemple #5
0
void CUIMainIngameWnd::Update()
{
#ifdef DEBUG
	test_update();
#endif
	if (m_pMPChatWnd)
		m_pMPChatWnd->Update();
	if (m_pMPLogWnd)
		m_pMPLogWnd->Update();



	m_pActor = smart_cast<CActor*>(Level().CurrentViewEntity());
	if (!m_pActor) 
	{
		m_pItem					= NULL;
		m_pWeapon				= NULL;
		m_pGrenade				= NULL;
		CUIWindow::Update		();
		return;
	}

	if( !(Device.dwFrame%30) && IsGameTypeSingle() )
	{
			string256				text_str;
			CPda* _pda	= m_pActor->GetPDA();
			u32 _cn		= 0;
			if(_pda && 0!= (_cn=_pda->ActiveContactsNum()) )
			{
				sprintf_s(text_str, "%d", _cn);
				UIPdaOnline.SetText(text_str);
			}
			else
			{
				UIPdaOnline.SetText("");
			}
	};

	if( !(Device.dwFrame%5) )
	{
		
		if(!(Device.dwFrame%30))
		{
			bool b_God = (GodMode()||(!Game().local_player)) ? true : Game().local_player->testFlag(GAME_PLAYER_FLAG_INVINCIBLE);
			if(b_God)
				SetWarningIconColor	(ewiInvincible,0xffffffff);
			else
			if (!external_icon_ctrl)
				TurnOffWarningIcon (ewiInvincible);
		}
		// ewiArtefact
		if( (GameID() == GAME_ARTEFACTHUNT) && !(Device.dwFrame%30) ){
			bool b_Artefact = (NULL != m_pActor->inventory().ItemFromSlot(ARTEFACT_SLOT));
			if(b_Artefact)
				SetWarningIconColor	(ewiArtefact,0xffffffff);			
			else
			if (!external_icon_ctrl)
				TurnOffWarningIcon (ewiArtefact);
		}

		// Armor indicator stuff
		PIItem	pItem = m_pActor->inventory().ItemFromSlot(OUTFIT_SLOT);
		if (pItem)
		{
			UIArmorBar.Show					(true);
			UIStaticArmor.Show				(true);
			UIArmorBar.SetProgressPos		(pItem->GetCondition()*100);
		}
		else
		{
			UIArmorBar.Show					(false);
			UIStaticArmor.Show				(false);
		}

		UpdateActiveItemInfo				();


		EWarningIcons i					= ewiWeaponJammed;		
		while (!external_icon_ctrl && i < ewiInvincible)
		{
			float value = 0;
			switch (i)
			{
				//radiation
			case ewiRadiation:
				value = m_pActor->conditions().GetRadiation();
				break;
			case ewiWound:
				value = m_pActor->conditions().BleedingSpeed();
				break;
			case ewiWeaponJammed:
				if (m_pWeapon)
					value = 1 - m_pWeapon->GetConditionToShow();
				break;
			case ewiStarvation:
				value = 1 - m_pActor->conditions().GetSatiety();
				break;		
			case ewiPsyHealth:
				value = 1 - m_pActor->conditions().GetPsyHealth();
				break;
			default:
				R_ASSERT(!"Unknown type of warning icon");
			}

			xr_vector<float>::reverse_iterator	rit;

			// Сначала проверяем на точное соответсвие
			rit  = std::find(m_Thresholds[i].rbegin(), m_Thresholds[i].rend(), value);

			// Если его нет, то берем последнее меньшее значение ()
			if (rit == m_Thresholds[i].rend())
				rit = std::find_if(m_Thresholds[i].rbegin(), m_Thresholds[i].rend(), std::bind2nd(std::less<float>(), value));

			// Минимальное и максимальное значения границы
			float min = m_Thresholds[i].front();
			float max = m_Thresholds[i].back();

			if (rit != m_Thresholds[i].rend()){
				float v = *rit;
				SetWarningIconColor(i, color_argb(0xFF, clampr<u32>(static_cast<u32>(255 * ((v - min) / (max - min) * 2)), 0, 255), 
					clampr<u32>(static_cast<u32>(255 * (2.0f - (v - min) / (max - min) * 2)), 0, 255),
					0));
			}else
				TurnOffWarningIcon(i);

			i = (EWarningIcons)(i + 1);
		}
	}

	// health&armor
	UIHealthBar.SetProgressPos		(m_pActor->GetfHealth()*100.0f);
	UIMotionIcon.SetPower			(m_pActor->conditions().GetPower()*100.0f);

	UIZoneMap->UpdateRadar			(Device.vCameraPosition);
	float h,p;
	Device.vCameraDirection.getHP	(h,p);
	UIZoneMap->SetHeading			(-h);

	UpdatePickUpItem				();
	CUIWindow::Update				();
}