npcstore.swf
The NPC vendor shop window shown when a player interacts with an in-game merchant. Displays a paginated grid of purchasable products with currency balance, deal timers, and purchase confirmation flow, supporting both mouse and controller input.
Document/main class: NPCStore (extends _kiwi.Core.UIComponent)
SWF-specific classes: 8 (excluding button/skin stubs)
Main class: NPCStore
Root window component. Manages the wallet display, pagination, multi-currency stacked wallet, time-remaining banner, and pending-transaction overlay. Delegates product grid management to TileViewSimple. Constructor sets up frame scripts (frames 1 and 11 — the latter sends productsView to its Console frame), initialises the StackList-based wallet and registers ExternalInterface callbacks in configUI().
Public methods
setBalance(balance:int, currencyIcon:String, currencyName:String, currencyDesc:String) : void— updateswallet.priceDisplay.pricetext with digit-delimited balance, loads the currency icon into anObjectPreview(35×35 for cubit/credit, 40×40 for others), hides legacycreditBalance/cubitBalanceMCs, stores name/desc for tooltip, propagates balance toproductsView.setBalance.showPurchaseApproved(success:Boolean) : void— if true, playswallet.gotoAndPlay("shine")and fires sound eventPlay_ui_shop_purchase_successviaExternalInterface.call("POST_SOUND_EVENT", ...). It carries only the flag, not which product was bought; the engine sends it right after refreshing the shown products.ResetInternalWallet() : *— clears thewalletStackListand hides the "show all currencies" icon. The engine sends it, followed by oneAddInternalWalletper currency, in answer toOnUpdateWalletBalanceDisplay, i.e. again on every tile hover, carrying the hovered product's currencies.AddInternalWallet(balance:int, textureName:String) : *— appends aWalletInternalrow to the stacked wallet, adjusts the list's Y position upward and resizeswalletStackBackgroundto fit all rows.ToggleInternalWalletDisplay() : *— toggles stacked wallet visibility (used by controller input).toggleCurrencyTooltip() : *— toggles the positioned name/description tooltip for the wallet currency icon; mutually exclusive with the stacked wallet panel.setPendingTransaction(message:String, visible:Boolean) : *— shows/hidesdisplayProgressoverlay with a status message (e.g. "Processing...").
Key fields
productsView : TileViewSimple— the scrollable 4-column product tile grid.wallet : MovieClip— wallet bar containingpriceDisplay,currencyIcon,creditBalance,cubitBalancesub-clips.walletStackList : StackList— vertical stack ofWalletInternalrows for multi-currency display.walletStackBackground : MovieClip— background panel that resizes to match stacked wallet height.currentBalance_image : ObjectPreview— 40×40 (or 35×35) icon shown in the wallet.header : WindowHeader— window title, set to translate key$NPCStore_WinTitle.prevPage / nextPage : BaseButton— pagination arrows; click callsExternalInterface.call("ChangePage", ±1).m_pageLabel : TextField— page indicator. Nothing in the SWF writes it; the engine sets itstextto"{page} / {count}"by property when the store opens and on every page change.firstPage / lastPage : MovieClip— jump-to-first/last buttons; labels$Store_First/$Store_Last; callExternalInterface.call("ChangePageExtreme", 0/1).displayProgress : MovieClip— blocking spinner overlay withstatusMessagechild.timeLeft : MovieClip— time-remaining banner, hidden untilSetTimeRemainingis called; childtimeRemainingTxtlabel is$NPCSTORE_TIME_REMAINING.m_currencyName / m_currencyDesc : String— stored currency tooltip strings.m_tooltipVisible : Boolean— tracks whether the currency tooltip is currently shown.
Frame scripts / timeline
- Frame 1:
stop()— default PC layout. - Frame 11:
stop()thenproductsView.gotoAndPlay("Console")— console layout variant. - Stage 1034×805 at 30 fps.
Runtime dependencies & integration
ExternalInterface.addCallbackregistrations:setBalance,showPurchaseApproved,productsView.UpdateProductCount,toggleCurrencyTooltip,setPendingTransaction,ResetInternalWallet,AddInternalWallet,ToggleInternalWalletDisplay,timeremaining.- Outbound
ExternalInterface.call:ChangePage(±1),ChangePageExtreme(0/1),TOOLTIP.SHOW(x, y, name, desc),TOOLTIP.HIDE(),POST_SOUND_EVENT("Play_ui_shop_purchase_success"). IggyFunctions.translate:$NPCSTORE_TIME_REMAINING.KiwiTextUtil.addDigitDelimiters— formats balance numbers.KiwiTextUtil.resizeFont— auto-shrinks font on first/last page buttons and time-remaining text.- translate keys:
$Store_First,$Store_Last,$NPCStore_WinTitle,$NPCSTORE_TIME_REMAINING,$Store_Buy,$Store_Unlock.
Other game-specific classes
TileViewSimple(extends_kiwi.Controls.ScrollableTileView, embedssymbol161) — 4-column scrollable tile grid. Constants:TILES_PER_ROW=4,ROWS_BEFORE_SCROLL=2,SCROLL_TILE_PEEK=0.33. Manages product list viaaddProduct/updateProduct/setPrice/setCanBuy. Highlights tiles with a goldGlowFilter. On console shows aconsoleTooltipafter 500ms on highlight. Calls outOnPurchase(index, currencyId, productName),OnConfigured(4, count)(fromUpdateProductCount),OnUpdateWalletBalanceDisplay(index),OnUpdateHoveredTile(index, 1/0)on tile roll-over/out; the engine answers a hover by sendinghighlightTile.- Two index spaces. Every inbound product callback (
updateProduct,setPrice,setCanBuy,UpdateDealExpiration,ApplySaleSticker,highlightTile,unhighlightTile,purchaseItem) addressesitemList[n], the tile's list position inaddProductcall order. Every outbound call sends the tile'sindex, the first argumentaddProductwas given. setPrice(n, currencyName, currencyDesc, currencyId, price)callsaddPrice(price, currencyId, currencyName, currencyDesc): the fourth argument is the currency and the fifth the amount.currencyIdis the currency's texture path, the same string its balance arrives with.addProduct(index, name, info, qty, icon, restock, failure)ignores its seventh argument.updateProduct(same arguments, by list position) uses it: a non-empty failure text hides the art, quantity, info and restock buttons and shows the text inhiddenFailureText, and the nextsetCanBuythen shows the locked display unless the status is owned.
- Two index spaces. Every inbound product callback (
ProductTileSimple(extends_kiwi.Core.UIComponent, embedssymbol62) — single store item tile. Holds a 175×175ObjectPreviewfor item art, 40×40 icon for currency,PurchasePanel, quantity text, info/restock popup buttons. Buy states (setCanBuy(status, text)):CANBUY=0,CANTBUY_LOCKED=1,CANTBUY_OWNED=2,CANTBUY_WILLRESET=3(showstextas the note),CANTBUY_OTHER=4(any other value leaves the button visible and disabled). Has aCountdownTimerfor deal expiry andpulseAnimTimer.PurchasePanel(embedssymbol29) — child ofProductTileSimple. ContainspurchaseButton(btnGreenIcon_small, default label$Store_Buy),ownedTextDisplay,lockedTextDisplay,resetTextDisplay,currencyIcon,creditIcon,points.WalletInternal(extendsUIComponent, embedssymbol15) — one row in the stacked multi-currency wallet. Constructor takes(balance:int, textureName:String); same 35/40px icon sizing logic asNPCStore. 20-frame animation.dummy— embeds/_assets/1_dummy.png(48×48) as aBitmapDataplaceholder.- Button stubs (6):
BtnGreen(symbol72),btnGreen_small(symbol82),btnGreenIcon_small(symbol25),btnPageExtreme(symbol85),btnArrowLeft(symbol94),btnArrowRight(symbol103) — all extendLabelButtonorBaseButton, 4-state frame stops only. - Skin stubs (8): scroll arrow and thumb skins,
focusRectSkin— bareMovieClipembeds. NPCStore_flatimeline clips (8):BlockingStatus_26(spinner overlay with Console frame),InfoPopup_57(2-frame popup text),btn_console_LT/RT(3-state controller trigger buttons),walletPriceDisplay_31,timer_pulse_anim_47,btnInfo2_56,btnRestock2_58.
Notable logic
- Multi-currency stacked wallet:
AddInternalWalletappends rows upward (negative Y shift per row) and expands the background panel height. Mouse-over/out orToggleInternalWalletDisplayshows/hides the stack. If a currency tooltip is open, toggling the wallet hides it, and vice versa. - Currency icon sizing: cubit.png and credit.png get a 35×35
ObjectPreview; all other currencies use 40×40. This sizing logic is duplicated in bothNPCStore.setBalanceandWalletInternal. - Tooltip positioning:
mouseOverCurrencyresolves the correct sourceDisplayObject(wallet icon vs. per-product icon), callslocalToGlobalto get stage coordinates, then firesTOOLTIP.SHOWwith a 5px extra offset for Cubits/Credits. - Purchase sound:
showPurchaseApprovedfiresPOST_SOUND_EVENT("Play_ui_shop_purchase_success")only whenparam1is true. - Page navigation: pagination buttons call
ChangePage(±1)orChangePageExtreme(0/1); both go to the engine's page setter, which does nothing when the page would not change or does not exist. The page label (m_pageLabel) is written by the engine. No inbound callback reports a page or page count. - What the engine sends: a rebuild (on open, page change and store events) is
clearProducts, thenaddProduct+setPriceper product, then a refresh, thenproductsView.UpdateProductCount. A refresh isupdateProduct,setPrice,setCanBuyand sometimesUpdateDealExpirationper shown product, withsetCanBuyalways followingupdateProductfor the same tile; it runs on a purchase result (followed byshowPurchaseApproved), on the purchase confirm dialog's OK (straight after the purchase is sent, before the server answers) and when a watched inventory item changes. The buy status is worked out from the engine's state at that moment and nothing re-sends it when other state lands later, so a club fixture bought just before the club update arrives can stay buyable until the window is reopened. - One listing per currency: some merchants list the same item once per currency they accept (the Delve merchant sells for cubits and for flux), and the grid draws each listing as a separate tile.
- Test/preview mode: when not in Iggy,
configUIinserts 12 dummy products directly intoproductsView.