Page MenuHomeFeedback Tracker

Incorrect display of QuantityBar, if varQuantityMax exceeds varStackMax (possible fix incl.)
Assigned, NormalPublic

Description

As I mentioned in the Title, the config in Steps To Reproduce would result in a faulty display of the quantityBar.

The following change adds the ability to use Items with a quantityBar to be stackable in Slots with different (higher) varStackMax sizes.

Use cases:
Instead of having Stacks with Numbers like Ammo/Nails -> quantityBar could be used (total amount could still be displayed via stackedUnit = "pc."; inside the Tooltip).
The same could be done for the Damage too.

In the end, it would clean up the UI from the usage of normal numbers, resulting in a more unified look for the Client.
Additionally not having the potential Overlay/Cut-off text by larger numbers (>100) and also a clear indicator if the Client can put more Items on an existing stack, which is imho a big plus in terms of UX.

Edit: Rewording*

Edit #2: Additional Info regarding Vanilla Items compatibility (for Items with 100 Item Stack Size) - All in all, these changes should be added directly when creating the model configs themselves.

Edit #3: Code update, to be (hopefully) fully compatible with Vanilla Items (multiple Items like WaterBottle, CarBattery, etc checked)

Details

Severity
Tweak
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Item:

quantityBar = 1;
stackedUnit = "pc.";
varQuantityInit = 0;
varQuantityMin = 0;
varQuantityMax = 500;
varStackMax = 100.0;

CfgSlots:

class Slot_MyFancySlot
{
    name = "MyFancySlot";
    displayName = "My Fancy Slot";
    selection = "MyFancySlot";
    ghostIcon = "Sloths";
    stackMax = 500;
};

Alternative (see notes above in "Edit #2"):
Adding varStackMax to the Inventory_Base class:

class cfgVehicles
{
	class Static;
	class Inventory_Base: Static
	{
		varStackMax = 100.0;
	};
};
Additional Information

Possible fix
I ran a bunch of tests and haven't found any issues so far, with the following changes:
(changes start at Line 41):

modded class SlotsIcon
{
	override void SetQuantity()
	{
		if( m_Item && m_CurrQuantity != GetQuantity() )
		{
			m_CurrQuantity = GetQuantity();
			int has_quantity = QuantityConversions.HasItemQuantity( m_Item );
			
			if( has_quantity == QUANTITY_COUNT )
			{
				string q_text = QuantityConversions.GetItemQuantityText( m_Item , true);
				if( q_text == "" )
				{
					m_QuantityStack.Show( false );
					m_QuantityProgress.Show( false );
				}
				else
				{
					m_QuantityItem.SetText( q_text );
					m_QuantityStack.Show( true );
					m_QuantityProgress.Show( false );
				}
			}
			else if( has_quantity == QUANTITY_PROGRESS )
			{
				//float progress_max = m_QuantityProgress.GetMax();	// <-- Not used anywhere?!
				int max = m_Item.ConfigGetInt( "varStackMax" );	// instead of "varQuantityMax"
				
				int count = m_Item.ConfigGetInt( "count" );
				float quantity = QuantityConversions.GetItemQuantity( m_Item );
				
				if( count > 0 )
				{
					max = count;
				}
				else
				{
					if ( m_SlotParent )
					{
						max = InventorySlots.GetStackMaxForSlotId(m_SlotID);
					}
					if ( max == 0)
					{
						max = m_Item.ConfigGetInt( "varQuantityMax" );
					};
					
					float value = Math.Round( ( quantity / max ) * 100 );
					m_QuantityProgress.SetCurrent( value );
				}
				m_QuantityStack.Show( false );
				m_QuantityProgress.Show( true );
			}
		}
	}
}

Event Timeline

Dscha created this task.Apr 26 2021, 6:12 PM
Dscha updated the task description. (Show Details)Apr 26 2021, 10:46 PM
Geez changed the task status from New to Assigned.Apr 27 2021, 6:24 PM
Dscha updated the task description. (Show Details)May 7 2021, 12:13 AM
Dscha edited Steps To Reproduce. (Show Details)
Dscha updated the task description. (Show Details)May 7 2021, 12:23 AM
Dscha edited Steps To Reproduce. (Show Details)
Dscha updated the task description. (Show Details)May 7 2021, 7:00 PM
Dscha edited Additional Information. (Show Details)