-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Black Market sell UI is laggy #1397
Comments
Forgot to mention ItemPrice = BuyPrice;
ItemRef = BuyPrice.ItemRef;
Price = BuyPrice.Price + BuyPrice.Price * (class'UIUtilities_Strategy'.static.GetBlackMarket().BuyPricePercentIncrease / 100.0f);
Item = GetItem();
ItemTemplate = Item.GetMyTemplate();
ItemCost = class'UIUtilities_Strategy'.static.GetCostQuantity(ItemTemplate.Cost, 'Supplies');
if (ItemCost > 0) // Ensure that the sell price of the item is not more than its cost from engineering
{
Price = Min(Price, ItemCost);
} |
Something that would also help is |
Also in foreach Items(Item)
{
// Don't display if none in your inventory to sell
InventoryItem = XComGameState_Item(`XCOMHISTORY.GetGameStateForObjectID(Item.ItemRef.ObjectID));
if( InventoryItem.Quantity > 0 )
{
Spawn(class'UIBlackMarket_SellItem', List.itemContainer).InitListItem(Item);
if(Item == PrevItem)
List.SetSelectedIndex(List.GetItemCount() - 1);
}
} What should be done instead is that function array<StateObjectReference> GetTradingPostItems()
{
local XComGameStateHistory History;
local XComGameState_Item ItemState;
local array<StateObjectReference> TradingPostItems;
local int idx;
History = `XCOMHISTORY;
TradingPostItems.Length = 0;
for(idx = 0; idx < Inventory.Length; idx++)
{
ItemState = XComGameState_Item(History.GetGameStateForObjectID(Inventory[idx].ObjectID));
if(ItemState != none)
{
if(ItemState.GetMyTemplate().TradingPostValue > 0 && !ItemState.GetMyTemplate().bInfiniteItem && !ItemState.IsNeededForGoldenPath())
{
TradingPostItems.AddItem(ItemState.GetReference());
}
}
}
//<workshop> BLACK_MARKET_FIXES, BET, 2016-04-22
//INS:
class'XComGameState_Item'.static.FilterOutGoldenPathItems(TradingPostItems);
//</workshop>
return TradingPostItems;
} This way it would cut down on fetching the same GameStates from History twice which is slowing down the initial opening of the sell screen and the update after clicking the sell button a lot. |
I have put the changes so far into a mod: |
Related; If you sell your entire inventory off, you can't open the sell screen again until the next month. This is because the main |
UIBlackMarket_Sell
has multiple functions that cause it to fetch GameStates from History too often. This is the main cause of it getting laggy with high number of items.The main culprits are these two functions but there are many other improvements possible as well:
SortByInterest()
is used insidePopulateData()
as the sorting function to sort all sellable items. Due to the array being sorted only containing object references it has to fetch the item states from history.IsInterested()
gets called fromPopulateItemCard()
every time selection changes (which also triggers when you click the +/- buttons) and gets the list of interests again every time which fetches GameStates for all sellable items from history.I had very good results from caching
Interests
as a class variable and using that for both of these functions.CachedInterests
can be fetched inInitScreen()
which will also help with clicking the sell button resulting in another call ofPopulateData()
.The text was updated successfully, but these errors were encountered: