コード例 #1
0
ファイル: GUIOverview.c プロジェクト: Kyle873/DoomRPG
NamedScript void UpdateOverviewPanel(GUIPanel *OverviewPanel)
{
    //-------------------------
    //Character
    //-------------------------
    
    GUILabels.NameLabel->Text = StrParam("%tS", PlayerNumber() + 1);
    GUILabels.LevelLabel->Text = StrParam("Level: %d", Player.Level);
    GUILabels.XPLabel->Text = StrParam("XP: %ld / %ld", Player.XP, Player.XPNext);
    GUILabels.TitleLabel->Text = StrParam("Title: %S (%d/%d)", Ranks[Player.RankLevel], Player.RankLevel, MAX_RANK);
    GUILabels.RankLabel->Text = StrParam("Rank: %ld / %ld", Player.Rank, Player.RankNext);
    if (Player.PayReady && !Player.PayingOut)
        GUILabels.PPLabel->Text = StrParam("PP: %d (%S) [\C[%S]Ready\C-]", Player.PP, FormatTime(Player.PayTimer), PayReadyColor);
    else
        GUILabels.PPLabel->Text = StrParam("PP: %d (%S)", Player.PP, FormatTime(Player.PayTimer));
    
    //-------------------------
    //Inventory
    //-------------------------
    
    GUILabels.ModuleLabel->Text = StrParam("%d", CheckInventory("DRPGModule"));
    GUILabels.TurretPartsLabel->Text = StrParam("%d", CheckInventory("DRPGTurretPart"));
    GUILabels.AugChargeLabel->Text = StrParam("%d%% / %d%%", (int)Player.Augs.Battery, (int)Player.Augs.BatteryMax);
    GUILabels.AugSlotsLabel->Text = StrParam("%d / %d", Player.Augs.SlotsUsed, Player.Augs.Slots);
    GUILabels.AugUpgradesLabel->Text = StrParam("%d / %d", CheckInventory("DRPGAugCanister"), CheckInventory("DRPGAugUpgradeCanister"));
    GUILabels.StimsLabel->Text = StrParam("S: %d\nM: %d\nL: %d\nXL: %d", CheckInventory("DRPGStimSmall"), CheckInventory("DRPGStimMedium"), CheckInventory("DRPGStimLarge"), CheckInventory("DRPGStimXL"));
    GUILabels.ChipsGoldLabel->Text = StrParam("%d", CheckInventory("DRPGChipGold"));
    GUILabels.ChipsPlatLabel->Text = StrParam("%d", CheckInventory("DRPGChipPlatinum"));
    GUILabels.InventoryLabel->Text = StrParam("Inventory: %d / %d\n\CaBullets: %d / %d\n\CiShells: %d / %d\n\CcRockets: %d / %d\n\CdCells: %d / %d",
                                    Player.InvItems, CheckInventoryMax(),
                                    CheckInventory("Clip"), GetAmmoCapacity("Clip"),
                                    CheckInventory("Shell"), GetAmmoCapacity("Shell"),
                                    CheckInventory("RocketAmmo"), GetAmmoCapacity("RocketAmmo"),
                                    CheckInventory("Cell"), GetAmmoCapacity("Cell"));


    //-----------------------------
    //DRLA Inventory
    //
    
    if (CompatMode == COMPAT_DRLA)
    {
        int IsTechnician = (PlayerClass(PlayerNumber()) == 2);
        int Weapons = CheckInventory("RLWeaponLimit");
        int Armors = CheckInventory("RLArmorInInventory");
        int ModPacks = (IsTechnician ? CheckInventory("RLScavengerModLimit") : CheckInventory("RLModLimit"));
        int Skulls = CheckInventory("RLSkullLimit");
        int Devices = CheckInventory("RLPhaseDeviceLimit");
        
        GUILabels.DRLALabel->Text = StrParam("DRLA Inventory:\n%SWeapons: %d / 6\n%SArmor: %d / %d\n%SModpacks: %d / %d\n%SSkulls: %d / %d\n%SDevices: %d / %d",
            (Weapons >= 6 ? "\Cf" : "\Ca"), Weapons,
            (Armors >= DRLA_ARMOR_MAX ? "\Cf" : "\Cd"), Armors, DRLA_ARMOR_MAX,
            (((!IsTechnician && ModPacks >= 4) || (IsTechnician && ModPacks >= 8)) ? "\Cf" : "\Cc"),
            ModPacks, (IsTechnician ? 8 : 4),
            (Skulls >= DRLA_SKULL_MAX ? "\Cf" : "\Cr"), Skulls, DRLA_SKULL_MAX,
            (Devices >= DRLA_DEVICE_MAX ? "\Cf" : "\Ct"), Devices, DRLA_DEVICE_MAX);
    }
//------------------------------------------------------------------------
void CInventory::SetAmmoCount(IEntityClass* pAmmoType, int count)
{
	int capacity=GetAmmoCapacity(pAmmoType);
	CRY_ASSERT(pAmmoType);
	if(pAmmoType)
	{
		if (capacity>0)
			m_stats.ammoInfo[pAmmoType].SetCount(min(count, capacity));
		else
			m_stats.ammoInfo[pAmmoType].SetCount(count);
	}

	TListenerVec::iterator iter = m_listeners.begin();
	m_iteratingListeners = true;
	while (iter != m_listeners.end())
	{
		(*iter)->OnSetAmmoCount(pAmmoType, count);
		++iter;
	}
	m_iteratingListeners = false;
}
void CInventory::Dump() const
{
	struct Dumper
	{
		Dumper(EntityId entityId, const char *desc)
		{
			IEntitySystem *pEntitySystem = gEnv->pEntitySystem;
			IEntity *pEntity = pEntitySystem->GetEntity(entityId);
			CryLogAlways(">> Id: %d [%s] $3%s $5%s", entityId, pEntity?pEntity->GetName():"<unknown>", pEntity?pEntity->GetClass()->GetName():"<unknown>", desc?desc:"");
		}
	};

	int count = GetCount();
	CryLogAlways("-- $3%s$1's Inventory: %d Items --", GetEntity()->GetName(), count);

	if (count)
	{
		for (TInventoryCIt it = m_stats.slots.begin(); it != m_stats.slots.end(); ++it)
			Dumper dump(*it, 0);
	}

	CryLogAlways(">> --");

	Dumper current(m_stats.currentItemId, "Current");
	Dumper last(m_stats.lastItemId, "Last");
	Dumper holstered(m_stats.holsteredItemId, "Holstered");

	CryLogAlways("-- $3%s$1's Inventory: %" PRISIZE_T " Ammo Types --", GetEntity()->GetName(), m_stats.ammoInfo.size());

	if (!m_stats.ammoInfo.empty())
	{
		for (TAmmoInfoMap::const_iterator ait = m_stats.ammoInfo.begin(); ait!=m_stats.ammoInfo.end(); ++ait)
			CryLogAlways(">> [%s] $3%d$1/$3%d", ait->first->GetName(), ait->second.GetCount(), GetAmmoCapacity(ait->first));
	}
}