592 lines
25 KiB
Lua
592 lines
25 KiB
Lua
-- Appended inside the original Blizzard_StoreUI secure environment. The parser
|
|
-- and provider above are private locals; no addon-owned tables enter this code.
|
|
local sourceStoreConfirmation, sourceStoreStatus
|
|
local sourceInternalPreview
|
|
local function sourceItemInfo(id)
|
|
if C_Item and C_Item.GetItemInfo then return C_Item.GetItemInfo(id) end
|
|
return GetItemInfo(id)
|
|
end
|
|
-- Accepted Dragon item-render profile: TW_SHOP preview item -> modified appearance.
|
|
local sourceItemAppearances = {
|
|
[23705]=165302,
|
|
[23709]=165303,
|
|
[23710]=165304,
|
|
[41091]=324117,
|
|
[41092]=324118,
|
|
[50038]=319533,
|
|
[50044]=319534,
|
|
[50086]=319535,
|
|
[50091]=319540,
|
|
[50092]=319541,
|
|
[50376]=323322,
|
|
[68070]=324119,
|
|
[69100]=323324,
|
|
[69101]=323325,
|
|
[69102]=323326,
|
|
[69103]=323327,
|
|
[69117]=324120,
|
|
[69118]=324121,
|
|
[69119]=324122,
|
|
[69120]=324123,
|
|
[69121]=324124,
|
|
[69122]=324125,
|
|
[69123]=324126,
|
|
[69124]=324127,
|
|
[69125]=324128,
|
|
[69127]=324129,
|
|
[69128]=324130,
|
|
[69129]=324143,
|
|
[69130]=324131,
|
|
[69131]=324132,
|
|
[69132]=324133,
|
|
[69146]=324134,
|
|
[69147]=324135,
|
|
[69148]=324136,
|
|
[69149]=324137,
|
|
[69150]=324138,
|
|
[69151]=324139,
|
|
[69152]=324140,
|
|
[80310]=320559,
|
|
[80314]=320561,
|
|
[81081]=323344,
|
|
[81082]=323345,
|
|
[81083]=323346,
|
|
[81084]=323347,
|
|
[81085]=323348,
|
|
[81087]=323350,
|
|
[81088]=323351,
|
|
[81203]=323355,
|
|
[81204]=323356,
|
|
[83478]=324141,
|
|
[83479]=324142,
|
|
}
|
|
-- Every shop model_id present in the installed CreatureDisplayInfo (ops/shop_creature_displays.py).
|
|
local sourceCreatureDisplays = {
|
|
[158]=true,
|
|
[207]=true,
|
|
[487]=true,
|
|
[522]=true,
|
|
[1065]=true,
|
|
[1097]=true,
|
|
[1201]=true,
|
|
[1236]=true,
|
|
[1992]=true,
|
|
[2012]=true,
|
|
[2185]=true,
|
|
[2186]=true,
|
|
[2326]=true,
|
|
[2784]=true,
|
|
[4591]=true,
|
|
[4629]=true,
|
|
[4805]=true,
|
|
[4807]=true,
|
|
[5745]=true,
|
|
[6293]=true,
|
|
[6351]=true,
|
|
[6442]=true,
|
|
[6443]=true,
|
|
[6474]=true,
|
|
[6475]=true,
|
|
[6476]=true,
|
|
[6478]=true,
|
|
[6746]=true,
|
|
[6909]=true,
|
|
[7933]=true,
|
|
[7970]=true,
|
|
[7993]=true,
|
|
[8782]=true,
|
|
[9590]=true,
|
|
[9695]=true,
|
|
[9714]=true,
|
|
[9991]=true,
|
|
[10718]=true,
|
|
[10923]=true,
|
|
[10990]=true,
|
|
[10992]=true,
|
|
[11396]=true,
|
|
[11444]=true,
|
|
[12074]=true,
|
|
[12237]=true,
|
|
[12350]=true,
|
|
[14329]=true,
|
|
[14340]=true,
|
|
[14341]=true,
|
|
[14343]=true,
|
|
[14345]=true,
|
|
[14368]=true,
|
|
[14432]=true,
|
|
[15369]=true,
|
|
[16075]=true,
|
|
[16189]=true,
|
|
[18029]=true,
|
|
[18030]=true,
|
|
[18042]=true,
|
|
[18065]=true,
|
|
[18090]=true,
|
|
[18094]=true,
|
|
[18120]=true,
|
|
[18121]=true,
|
|
[18122]=true,
|
|
[18143]=true,
|
|
[18176]=true,
|
|
[18180]=true,
|
|
[18243]=true,
|
|
[18251]=true,
|
|
[18252]=true,
|
|
[18253]=true,
|
|
[18255]=true,
|
|
[18257]=true,
|
|
[18259]=true,
|
|
[18260]=true,
|
|
[18262]=true,
|
|
[18265]=true,
|
|
[18295]=true,
|
|
[18298]=true,
|
|
[18299]=true,
|
|
[18425]=true,
|
|
[18435]=true,
|
|
[18436]=true,
|
|
[18476]=true,
|
|
[18481]=true,
|
|
[18484]=true,
|
|
[18488]=true,
|
|
[18491]=true,
|
|
[18492]=true,
|
|
[18523]=true,
|
|
[18627]=true,
|
|
[18730]=true,
|
|
[18778]=true,
|
|
[18925]=true,
|
|
[18926]=true,
|
|
[18927]=true,
|
|
[18928]=true,
|
|
[19101]=true,
|
|
[19106]=true,
|
|
[19127]=true,
|
|
[19128]=true,
|
|
[19130]=true,
|
|
[19131]=true,
|
|
[19168]=true,
|
|
[19170]=true,
|
|
[20369]=true,
|
|
[20370]=true,
|
|
[20371]=true,
|
|
[20372]=true,
|
|
[20374]=true,
|
|
[20376]=true,
|
|
[20377]=true,
|
|
[20379]=true,
|
|
[20380]=true,
|
|
[20382]=true,
|
|
[20383]=true,
|
|
[20416]=true,
|
|
[20417]=true,
|
|
[20418]=true,
|
|
[20419]=true,
|
|
[20421]=true,
|
|
[20422]=true,
|
|
[20425]=true,
|
|
[20490]=true,
|
|
[20494]=true,
|
|
[20498]=true,
|
|
[20506]=true,
|
|
}
|
|
local function sourcePreview(entry)
|
|
if entry.category == 2 then return {} end
|
|
local appearance = sourceItemAppearances[entry.itemID]
|
|
if appearance then return {{itemModifiedAppearanceIDs={appearance}, modelSceneID=596, sourceEntryID=entry.id}} end
|
|
if (entry.itemID or 0) == 0 and sourceCreatureDisplays[entry.modelID] then
|
|
return {{creatureDisplayInfoID=entry.modelID, modelSceneID=4, sourceEntryID=entry.id}}
|
|
end
|
|
return {}
|
|
end
|
|
local sourceStore = SourceStoreProvider.New(SourceStoreWire, {
|
|
sourceMode=true, cardType=Enum.BattlepayCardType.SmallCard,
|
|
fashionSlotGroups=true, foreverLayout=true,
|
|
foreverLabels={mounts=MOUNTS or "Mounts", pets=PETS or "Pets", transmog="Transmog", services="Services"},
|
|
foreverTextures={mounts="Interface\\Icons\\Ability_Mount_RidingHorse", pets="Interface\\Icons\\INV_Box_PetCarrier_01",
|
|
transmog="Interface\\Icons\\INV_Chest_Cloth_17", services="Interface\\Icons\\INV_Scroll_03"},
|
|
inventoryType=function(itemID)
|
|
if C_Item and C_Item.GetItemInventoryTypeByID then return C_Item.GetItemInventoryTypeByID(itemID) end
|
|
end,
|
|
fashionSlotLabels={all=ALL,head=HEADSLOT,shoulder=SHOULDERSLOT,back=BACKSLOT,chest=CHESTSLOT,
|
|
shirt=SHIRTSLOT,tabard=TABARDSLOT,wrist=WRISTSLOT,hands=HANDSSLOT,waist=WAISTSLOT,
|
|
legs=LEGSSLOT,feet=FEETSLOT,mainhand=MAINHANDSLOT,offhand=SECONDARYHANDSLOT,ranged=RANGEDSLOT,other=OTHER},
|
|
nativeRaceID=function() return select(3,UnitRace("player")) end,
|
|
presentation=function(entry)
|
|
local name, _, _, _, _, _, _, _, _, icon = sourceItemInfo(entry.id)
|
|
return {name=name or entry.name, texture=icon or "Interface\\Icons\\INV_Misc_QuestionMark", cards=sourcePreview(entry)}
|
|
end,
|
|
-- Unknown compatibility stays unknown; the Source server decides Buy.
|
|
categoryTexture=function() return "Interface\\Icons\\WoW_Store" end,
|
|
})
|
|
function SourceStore_IsActive() return not C_Glue.IsOnGlueScreen() end
|
|
function SourceStore_GetEntryInfo(id)
|
|
if SourceStore_IsActive() then return sourceStore:GetEntryInfo(id) end
|
|
return C_StoreSecure.GetEntryInfo(id)
|
|
end
|
|
function SourceStore_GetProducts(id)
|
|
if SourceStore_IsActive() then return sourceStore:GetProducts(id) end
|
|
return C_StoreSecure.GetProducts(id)
|
|
end
|
|
function SourceStore_GetProductGroups()
|
|
if SourceStore_IsActive() then return sourceStore:GetProductGroups() end
|
|
return C_StoreSecure.GetProductGroups()
|
|
end
|
|
function SourceStore_GetProductGroupInfo(id)
|
|
if SourceStore_IsActive() then return sourceStore:GetProductGroupInfo(id) end
|
|
return C_StoreSecure.GetProductGroupInfo(id)
|
|
end
|
|
function SourceStore_CurrencyInfo()
|
|
return {sourceTokens=true, browseNotice="", browseBuyButtonText="Claim"}
|
|
end
|
|
local function sourceHide(frame) if frame then frame:Hide() end end
|
|
function SourceStore_UpdateBuyButton()
|
|
local frame=StoreFrame
|
|
local entry=sourceStore:GetEntryInfo(StoreFrame_GetSelectedEntryID())
|
|
local canBuy=entry and sourceStore:CanPurchase(entry)
|
|
frame.BuyButton:SetText("Claim")
|
|
frame.BuyButton:SetEnabled(not not canBuy)
|
|
frame.BuyButton.PulseAnim:Stop()
|
|
end
|
|
function SourceStore_Refresh()
|
|
if not StoreFrame or not StoreFrame:IsShown() then return end
|
|
local groups=sourceStore:GetProductGroups()
|
|
local selected=StoreFrame_GetSelectedCategoryID()
|
|
if not sourceStore:GetProductGroupInfo(selected) then
|
|
SourceStore_CloseInternalPreview()
|
|
StoreFrame_SetSelectedCategoryID(sourceStore:GetSourceCategoryForGroup(selected) or (groups[1] and groups[1].groupID))
|
|
StoreFrame_SetSelectedPageNum(1)
|
|
end
|
|
StoreFrame.CategoryTreeScrollContainer:UpdateCategories()
|
|
local entries=sourceStore:GetProducts(StoreFrame_GetSelectedCategoryID())
|
|
local selectedEntry=StoreFrame_GetSelectedEntryID()
|
|
local retained=false
|
|
for _,id in ipairs(entries) do if id==selectedEntry then retained=true;break end end
|
|
if selectedEntry and not retained then
|
|
SourceStore_CloseInternalPreview();StoreFrame_SetSelectedEntryID(nil)
|
|
end
|
|
local pages=math.max(1,math.ceil(#entries/8))
|
|
StoreFrame_SetSelectedPageNum(math.min(pages,StoreFrame_GetSelectedPageNum()))
|
|
if not sourceInternalPreview then StoreFrame_SetCategory(true) end
|
|
if #entries==0 then
|
|
StoreFrame.PageText:Hide(); StoreFrame.NextPageButton:Hide(); StoreFrame.PrevPageButton:Hide()
|
|
end
|
|
local balance=sourceStore:GetBalanceTokens()
|
|
StoreFrame.BrowseNotice:SetText("Tokens: "..(balance and tostring(balance) or "—")..(sourceStoreStatus and (" "..sourceStoreStatus) or ""))
|
|
if #groups==0 then StoreFrame_SetAlert(StoreFrame,"OctoShop","Loading catalogue…") else StoreFrame_HideAlert(StoreFrame) end
|
|
SourceStore_UpdateBuyButton()
|
|
StoreFrame_UpdateCoverState()
|
|
end
|
|
function SourceStore_OnLoad(self)
|
|
self.layoutGrid=CreateFromMixins(StoreLayoutGridMixin); self.layoutGrid:Init(2,4)
|
|
self:SetTitle("OctoShop"); self:SetPortraitToAsset("Interface\\Icons\\WoW_Store")
|
|
self:SetPortraitTextureSizeAndOffset(60,-5,7)
|
|
self:SetPoint("CENTER",nil,"CENTER",0,20)
|
|
-- Enlarge the existing native layout/artwork together, within the screen.
|
|
local scale=1.15
|
|
if UIParent and UIParent.GetWidth and UIParent.GetHeight then
|
|
scale=math.min(scale,(UIParent:GetWidth()-32)/800,(UIParent:GetHeight()-32)/537)
|
|
end
|
|
self:SetScale(math.max(0.5,scale))
|
|
StoreDialog:SetPoint("CENTER",nil,"CENTER",0,150)
|
|
self.productCardPoolCollection=CreateFramePoolCollection()
|
|
-- Same original forbidden card pools, preallocated during addon load.
|
|
for template,info in pairs(productCardTemplateData) do
|
|
self.productCardPoolCollection:CreatePool("Button",self,template,nil,true,nil,info.poolSize)
|
|
end
|
|
self.Notice.Description:SetSpacing(5)
|
|
self:RegisterEvent("GET_ITEM_INFO_RECEIVED")
|
|
self.variablesLoaded=true;self.distributionsUpdated=true
|
|
self:SetAttribute("sourceshop",true)
|
|
SourceStore_UpdateBuyButton()
|
|
end
|
|
local sourceCategoryQueue, sourceCategoryWaiting, sourceCategoriesRequested = {}, nil, false
|
|
local function sourceRequestNextCategory()
|
|
sourceCategoryWaiting = table.remove(sourceCategoryQueue, 1)
|
|
if sourceCategoryWaiting then StoreOutbound.SourceShopSend("Entries:"..sourceCategoryWaiting) end
|
|
end
|
|
function SourceStore_OnShow(self)
|
|
self:SetAttribute("isshown",true)
|
|
sourceHide(self.ErrorFrame);sourceHide(self.PurchaseSentFrame)
|
|
local groups = sourceStore:GetSourceProductGroups()
|
|
local complete = #groups > 0
|
|
for _,group in ipairs(groups) do
|
|
if not sourceStore.state.complete[group.groupID] then complete = false end
|
|
end
|
|
if not complete and not sourceCategoriesRequested and not sourceCategoryWaiting then
|
|
sourceCategoriesRequested = true
|
|
StoreOutbound.SourceShopSend("Categories")
|
|
end
|
|
StoreOutbound.SourceShopSend("Balance")
|
|
SourceStore_Refresh()
|
|
StoreOutbound.UpdateMicroButtons()
|
|
PlaySound(SOUNDKIT.UI_IG_STORE_WINDOW_OPEN_BUTTON)
|
|
end
|
|
function SourceStore_OnHide(self)
|
|
SourceStore_CloseInternalPreview()
|
|
self:SetAttribute("isshown",false)
|
|
sourceStoreConfirmation=nil
|
|
sourceHide(StoreConfirmationFrame);sourceHide(StoreTooltip)
|
|
StoreOutbound.HidePreviewFrame();StoreOutbound.UpdateMicroButtons()
|
|
PlaySound(SOUNDKIT.UI_IG_STORE_WINDOW_CLOSE_BUTTON)
|
|
end
|
|
function SourceStore_OnAttribute(self,name,value)
|
|
if name=="sourceshopmessage" and type(value)=="string" and #value<=4096 then
|
|
if value:match("^Categories:") and not sourceCategoriesRequested then return end
|
|
local category = tonumber(value:match("^Entries:(%d+)="))
|
|
if category and category ~= sourceCategoryWaiting then return end
|
|
local accepted,kind=sourceStore:ApplyMessage(value)
|
|
if not accepted then return end
|
|
if kind=="categories" or kind=="start" then SourceStore_CloseInternalPreview() end
|
|
if kind=="categories" then
|
|
sourceCategoriesRequested = false
|
|
sourceCategoryQueue = {}
|
|
for _,group in ipairs(sourceStore:GetSourceProductGroups()) do sourceCategoryQueue[#sourceCategoryQueue+1] = group.groupID end
|
|
sourceRequestNextCategory()
|
|
elseif kind=="end" then
|
|
sourceRequestNextCategory()
|
|
elseif kind=="result" then
|
|
local result=sourceStore:TakePurchaseResult()
|
|
local messages={ok="Purchase confirmed by the server.",notenoughtokens="Not enough tokens.",itemnotinshop="Item unavailable.",bagsfulloralreadyhaveitem="Bags full or item already owned.",unknowndberror="The server could not complete this purchase.",dberrorcantprocess="The server could not process this purchase."}
|
|
sourceStoreStatus=result and (messages[result.value] or "The server returned an unknown purchase result.") or nil
|
|
StoreOutbound.SourceShopSend("Balance")
|
|
end
|
|
if kind~="entry" then SourceStore_Refresh() end
|
|
elseif name=="previewframeshown" then
|
|
StoreFrame_UpdateCoverState()
|
|
elseif name=="action" then
|
|
if value=="Show" then self:Show()
|
|
elseif value=="Hide" then self:Hide()
|
|
elseif value=="EscapePressed" then
|
|
local shown=self:IsShown()
|
|
if StoreConfirmationFrame:IsShown() then sourceStoreConfirmation=nil;StoreConfirmationFrame:Hide()
|
|
elseif sourceInternalPreview then SourceStore_CloseInternalPreview()
|
|
elseif shown then self:Hide() end
|
|
self:SetAttribute("escaperesult",shown)
|
|
end
|
|
end
|
|
end
|
|
local function sourceShowPreview(card, info)
|
|
local cards = info.sharedData.cards
|
|
if #cards == 0 then
|
|
if card.sourcePreviewKey then card.ModelScene:ClearScene();card.sourcePreviewKey=nil end
|
|
return false
|
|
end
|
|
local sceneID = cards[1].modelSceneID
|
|
if not C_ModelInfo.GetModelSceneInfoByID(sceneID) then return false end
|
|
local key=tostring(info.entryID or card:GetID())..":"..tostring(sceneID)..":"..tostring(cards[1].creatureDisplayInfoID or 0)
|
|
..":"..table.concat(cards[1].itemModifiedAppearanceIDs or {},",")..":"..tostring(select(3,UnitRace("player")))..":"..tostring(UnitSex("player"))
|
|
if card.sourcePreviewKey==key then
|
|
local actor
|
|
if cards[1].creatureDisplayInfoID then actor=card.ModelScene:GetActorByTag("unwrapped")
|
|
else actor=card.ModelScene:GetPlayerActor() end
|
|
if actor then card.ModelScene:Show();card:HideIcon();return true end
|
|
card.sourcePreviewKey=nil
|
|
end
|
|
if cards[1].creatureDisplayInfoID then
|
|
local scene = card.ModelScene
|
|
scene:ClearScene()
|
|
scene:SetFromModelSceneID(sceneID, true)
|
|
local actor = scene:GetActorByTag("unwrapped")
|
|
if not actor then scene:Hide();return false end
|
|
for _,tag in ipairs({"wrapped", "player-rider"}) do
|
|
local unused = scene:GetActorByTag(tag)
|
|
if unused then unused:Hide() end
|
|
end
|
|
SetupItemPreviewActor(actor, cards[1].creatureDisplayInfoID)
|
|
scene:Show()
|
|
local camera = scene:GetActiveCamera()
|
|
if camera then camera:ResetDefaultInputModes() end
|
|
card.sourcePreviewKey=key
|
|
card:HideIcon()
|
|
return true
|
|
end
|
|
StoreProductCard_ShowModel(card, info, false, true)
|
|
if card.ModelScene:GetPlayerActor() then
|
|
card.sourcePreviewKey=key
|
|
card:HideIcon()
|
|
return true
|
|
end
|
|
card.ModelScene:Hide()
|
|
return false
|
|
end
|
|
local function sourceGeometry(frame)
|
|
local saved={width=frame:GetWidth(),height=frame:GetHeight(),points={}}
|
|
for index=1,frame:GetNumPoints() do saved.points[index]={frame:GetPoint(index)} end
|
|
return saved
|
|
end
|
|
local function sourceRestoreGeometry(frame,saved)
|
|
frame:ClearAllPoints();frame:SetSize(saved.width,saved.height)
|
|
for _,point in ipairs(saved.points) do frame:SetPoint(unpack(point,1,5)) end
|
|
end
|
|
function SourceStore_CloseInternalPreview()
|
|
local preview=sourceInternalPreview
|
|
if not preview then return false end
|
|
sourceInternalPreview=nil
|
|
sourceRestoreGeometry(preview.card,preview.geometry)
|
|
sourceRestoreGeometry(preview.card.ModelScene,preview.sceneGeometry)
|
|
for _,saved in ipairs(preview.regions) do sourceRestoreGeometry(saved.region,saved.geometry) end
|
|
local scene=preview.card.ModelScene
|
|
if scene.isLeftButtonDown then scene:OnMouseUp("LeftButton") end
|
|
if scene.isRightButtonDown then scene:OnMouseUp("RightButton") end
|
|
scene.OnMouseDown,scene.OnMouseUp,scene.OnMouseWheel=preview.sceneDown,preview.sceneUp,preview.sceneWheel
|
|
scene.isLeftButtonDown,scene.isRightButtonDown=preview.leftDown,preview.rightDown
|
|
preview.card:SetScript("OnMouseWheel",preview.wheelScript)
|
|
preview.card:EnableMouseWheel(preview.wheelEnabled)
|
|
preview.card:EnableMouse(preview.mouseEnabled)
|
|
for _,state in ipairs(preview.cards) do
|
|
state.card:SetShown(state.shown)
|
|
state.card.ModelScene:SetShown(state.sceneShown)
|
|
end
|
|
StoreFrame.NextPageButton:SetShown(preview.nextShown)
|
|
StoreFrame.PrevPageButton:SetShown(preview.prevShown)
|
|
StoreFrame.PageText:SetText(preview.pageText)
|
|
return true
|
|
end
|
|
function SourceStore_ShowInternalPreview(displayInfoEntries)
|
|
-- Store cards deliberately inherit NoCameraControlModelSceneMixin. Use
|
|
-- the original interactive scene methods only for this focused lifetime.
|
|
if not ModelSceneMixin or type(ModelSceneMixin.OnMouseDown)~="function"
|
|
or type(ModelSceneMixin.OnMouseUp)~="function" or type(ModelSceneMixin.OnMouseWheel)~="function" then return false end
|
|
local id=displayInfoEntries and displayInfoEntries[1] and displayInfoEntries[1].sourceEntryID
|
|
local info=id and sourceStore:GetEntryInfo(id)
|
|
if not info or #info.sharedData.cards==0 then return false end
|
|
if sourceInternalPreview and sourceInternalPreview.card:GetID()==id then
|
|
return SourceStore_CloseInternalPreview()
|
|
end
|
|
SourceStore_CloseInternalPreview()
|
|
local selected
|
|
for card in StoreFrame.productCardPoolCollection:EnumerateActive() do
|
|
if card:GetID()==id then selected=card;break end
|
|
end
|
|
if not selected or not sourceShowPreview(selected,info) then return false end
|
|
local preview={card=selected,geometry=sourceGeometry(selected),sceneGeometry=sourceGeometry(selected.ModelScene),cards={},regions={},
|
|
wheelScript=selected:GetScript("OnMouseWheel"),wheelEnabled=selected:IsMouseWheelEnabled(),mouseEnabled=selected:IsMouseEnabled(),
|
|
sceneDown=selected.ModelScene.OnMouseDown,sceneUp=selected.ModelScene.OnMouseUp,sceneWheel=selected.ModelScene.OnMouseWheel,
|
|
leftDown=selected.ModelScene.isLeftButtonDown,rightDown=selected.ModelScene.isRightButtonDown,
|
|
nextShown=StoreFrame.NextPageButton:IsShown(),prevShown=StoreFrame.PrevPageButton:IsShown(),pageText=StoreFrame.PageText:GetText()}
|
|
-- SmallStoreCard.Layout centers fixed-size atlas textures (146x209 for
|
|
-- Card, 140x203 for its overlays); resizing the button does not stretch
|
|
-- them. Retain the exact native art and restore its browse geometry.
|
|
for _,region in ipairs({selected.Card,selected.SelectedTexture,selected.HighlightTexture,selected.ProductName}) do
|
|
preview.regions[#preview.regions+1]={region=region,geometry=sourceGeometry(region)}
|
|
end
|
|
for card in StoreFrame.productCardPoolCollection:EnumerateActive() do
|
|
preview.cards[#preview.cards+1]={card=card,shown=card:IsShown(),sceneShown=card.ModelScene:IsShown()}
|
|
if card~=selected then card.ModelScene:Hide();card:Hide() end
|
|
end
|
|
sourceInternalPreview=preview
|
|
selected:ClearAllPoints()
|
|
selected:SetPoint("TOPLEFT",StoreFrame,"TOPLEFT",216,-65)
|
|
selected:SetPoint("BOTTOMRIGHT",StoreFrame,"BOTTOMRIGHT",-22,70)
|
|
selected.Card:ClearAllPoints();selected.Card:SetAllPoints(selected)
|
|
for _,region in ipairs({selected.SelectedTexture,selected.HighlightTexture}) do
|
|
region:ClearAllPoints()
|
|
region:SetPoint("TOPLEFT",selected,"TOPLEFT",3,-3)
|
|
region:SetPoint("BOTTOMRIGHT",selected,"BOTTOMRIGHT",-3,3)
|
|
end
|
|
selected.ProductName:ClearAllPoints()
|
|
selected.ProductName:SetPoint("BOTTOMLEFT",selected,"BOTTOMLEFT",16,42)
|
|
selected.ProductName:SetPoint("BOTTOMRIGHT",selected,"BOTTOMRIGHT",-16,42)
|
|
selected.ModelScene:ClearAllPoints()
|
|
selected.ModelScene:SetPoint("TOPLEFT",selected,"TOPLEFT",8,-8)
|
|
selected.ModelScene:SetPoint("BOTTOMRIGHT",selected,"BOTTOMRIGHT",-8,65)
|
|
selected:EnableMouseWheel(true)
|
|
selected:EnableMouse(true)
|
|
selected.ModelScene.OnMouseDown=ModelSceneMixin.OnMouseDown
|
|
selected.ModelScene.OnMouseUp=ModelSceneMixin.OnMouseUp
|
|
selected.ModelScene.OnMouseWheel=ModelSceneMixin.OnMouseWheel
|
|
selected:SetScript("OnMouseWheel",function(_,delta) selected.ModelScene:OnMouseWheel(delta) end)
|
|
StoreFrame_SetSelectedEntryID(id)
|
|
StoreFrame.NextPageButton:Hide();StoreFrame.PrevPageButton:Hide()
|
|
StoreFrame.PageText:SetText("Escape to return")
|
|
SourceStore_UpdateBuyButton()
|
|
return true
|
|
end
|
|
function SourceStore_BeforeSetCategory()
|
|
SourceStore_CloseInternalPreview()
|
|
end
|
|
function SourceStore_OnItemInfoReceived(itemID)
|
|
local regrouped=sourceStore:RefreshFashionSlots(itemID)
|
|
if not StoreFrame or not StoreFrame:IsShown() then return end
|
|
if regrouped then SourceStore_Refresh() end
|
|
-- Unrelated world/bag item data must not rebuild eight scenes or reset a
|
|
-- user's preview camera. Update only visible matching catalogue cards.
|
|
for card in StoreFrame.productCardPoolCollection:EnumerateActive() do
|
|
if card:GetID()==itemID then
|
|
local info=sourceStore:GetEntryInfo(itemID)
|
|
if info then
|
|
card.ProductName:SetText(info.sharedData.name)
|
|
if not card.sourcePreviewKey then card:ShowIcon(info.sharedData) end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
function SourceStore_CardUpdate(card,id)
|
|
local info=sourceStore:GetEntryInfo(id)
|
|
if not info then card:Hide();return end
|
|
card:SetID(id)
|
|
for _,key in ipairs({"DiscountMiddle","DiscountLeft","DiscountRight","DiscountText","Checkmark","UpgradeArrow","NormalPrice","SalePrice","Strikethrough","Magnifier","Shadows"}) do sourceHide(card[key]) end
|
|
card.DisabledOverlay:SetShown(info.sharedData.sourceRaceEligible==false)
|
|
sourceHide(card.CurrentMarketPrice)
|
|
card.ProductName:SetText(info.sharedData.name)
|
|
card.CurrentPrice:SetText(tostring(info.sharedData.sourcePriceTokens).." Tokens");card.CurrentPrice:Show()
|
|
card:SetDefaultCardTexture()
|
|
card.ModelScene:Hide()
|
|
if not sourceShowPreview(card, info) then
|
|
card:ShowIcon(info.sharedData)
|
|
card.Icon:SetDesaturated(info.sharedData.sourceRaceEligible==false)
|
|
end
|
|
card:UpdateState()
|
|
end
|
|
function SourceStore_CanPreview(card)
|
|
local info = sourceStore:GetEntryInfo(card:GetID())
|
|
return info ~= nil and #info.sharedData.cards > 0
|
|
end
|
|
function SourceStore_CardClick(card)
|
|
local info = sourceStore:GetEntryInfo(card:GetID())
|
|
if info and #info.sharedData.cards > 0 and IsModifiedClick("DRESSUP") then
|
|
StoreFrame_ShowPreviews(info.sharedData.cards)
|
|
return
|
|
end
|
|
StoreFrame_SetSelectedEntryID(card:GetID())
|
|
StoreProductCard_UpdateAllStates();SourceStore_UpdateBuyButton()
|
|
end
|
|
function SourceStore_CardTooltip(card)
|
|
local info=sourceStore:GetEntryInfo(card:GetID());if not info then return end
|
|
StoreTooltip:ClearAllPoints();StoreTooltip:SetPoint("BOTTOMLEFT",card,"TOPRIGHT",-4,0)
|
|
local description=info.sharedData.description or ""
|
|
if info.sharedData.sourceRaceEligible==false then description=description.."\nAppearance is intended for another race." end
|
|
StoreTooltip_Show(info.sharedData.name,description,false)
|
|
end
|
|
function SourceStore_BeginPurchase(id)
|
|
local entry=sourceStore:GetEntryInfo(id)
|
|
local allowed,reason=sourceStore:CanPurchase(entry)
|
|
if not allowed then sourceStoreStatus=reason;SourceStore_Refresh();return end
|
|
sourceStoreConfirmation=entry
|
|
local frame=StoreConfirmationFrame
|
|
frame.Title:SetText("Confirm claim")
|
|
frame.ProductName:SetText(entry.sharedData.name)
|
|
frame.Icon:SetTexture(entry.sharedData.texture or "Interface\\Icons\\INV_Misc_QuestionMark")
|
|
frame.NoticeFrame.TotalLabel:SetText("Total")
|
|
frame.NoticeFrame.Price:SetText(tostring(entry.sharedData.sourcePriceTokens).." Tokens")
|
|
frame.NoticeFrame.Notice:SetText("Claim this item for the current character?")
|
|
sourceHide(frame.LicenseAcceptText);sourceHide(frame.LicenseAcceptButton)
|
|
sourceHide(frame.PaymentMethod);sourceHide(frame.PaymentMethodName)
|
|
frame.BuyButton:SetText("Claim");frame.BuyButton:Enable();frame:Show()
|
|
end
|
|
function SourceStore_FinalBuy()
|
|
if not sourceStoreConfirmation then return end
|
|
local payload,reason=sourceStore:BeginPurchase(sourceStoreConfirmation)
|
|
sourceStoreConfirmation=nil;StoreConfirmationFrame:Hide()
|
|
if payload then
|
|
StoreOutbound.SourceShopSend(payload)
|
|
sourceStoreStatus="Waiting for server confirmation…"
|
|
else sourceStoreStatus=reason end
|
|
SourceStore_Refresh()
|
|
end
|
|
function SourceStore_CancelConfirmation()
|
|
sourceStoreConfirmation=nil;StoreConfirmationFrame:Hide();StoreFrame_UpdateCoverState()
|
|
end
|