Mods\LazyShop Mod

The LazyShop Mod is a fork of the default Shop Mod that uses lazy loading to only generate shop items the first time they're shown, rather than loading everything on game initialization.

Features

lazy shop

Usage Instructions

Compatibility

Due to the nature of the differences between Shop and LazyShop, it may not be fully compatible with games currently using the original shop mod. The main thing to be aware of is that an item's layout (typically gotten with shop.GetItemLayout()) won't exist until the first time the shop is actually opened. You may have to adjust your code such as:

-- updating an item in `shop`
local layout = shop.GetItemLayout("com.wildsky.test.shop.chest01")
layout:Update()

-- updating an item in `lazy_shop`
local layout = shop.GetItemLayout("com.wildsky.test.shop.chest01")
if layout and DCEI.FrameExists(layout.Frame) then
    layout:Update()
end

New Features

ui.shop:Show( options )

ui.shop:Show( table options )

New options parameter. Current options:

Example Usage

-- this will open the shop with only the "gems" section visible
shop.ui:Show({ section_filter = { "gems" }})

shop.InitializeIAP( iap_data )

shop.InitializeIAP( table iap_data )

New rows_to_load_instantly argument in iap_data:

This value should be set to the maximum number of visible rows when the shop is first opened, otherwise shop sections may have the wrong height during the lazy loading animation. For example, this value is set to 3 in the above gif.

Example Usage

shop.InitializeIAP({
  on_purchase_attempt_callback = AttemptAnyItemPurchase,
  on_purchase_success_callback = OnAnyItemPurchase,
  product_list = GetProductList(),
  currency_list = CURRENCIES,
  rows_to_load_instantly = 3, -- instantly create the first 3 rows during lazy loading
})

shop.IsItemQueuedForLazyLoad( product_id )

bool shop.IsItemQueuedForLazyLoad( string product_id )

This function returns true if the given product id is queued to be lazy loaded in the shop.

Example Usage

local layout = shop_mod.GetItemLayout(product_id)
local does_item_belong_to_shop = layout or shop_mod.IsItemQueuedForLazyLoad(product_id)
if does_item_belong_to_shop then
    -- do something that only applies to items that currently or will exist in the shop (but NOT in a popup), such as check if it should contribute to showing a shop pip
end