From 847478800f76d12c5027aff08111bab29ea5f350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tekkub=20=CA=95=20=C2=B4=E1=B4=A5=60=20=CA=94?= Date: Sat, 10 Sep 2016 03:36:41 -0600 Subject: [PATCH] Make OnClick handler easier to read --- frames/MerchantItem.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/frames/MerchantItem.lua b/frames/MerchantItem.lua index 3a49bbf..e3f165b 100644 --- a/frames/MerchantItem.lua +++ b/frames/MerchantItem.lua @@ -8,16 +8,23 @@ local ICONSIZE = 17 local function OnClick(self, button) - if IsAltKeyDown() and not self.AltCurrency:IsShown() then + local id = self:GetID() + local hasaltcurrency = (GetMerchantItemCostInfo(id) > 0) + + if IsAltKeyDown() and not hasaltcurrency then self:BuyItem(true) + elseif IsModifiedClick() then - HandleModifiedItemClick(GetMerchantItemLink(self:GetID())) - elseif self.AltCurrency:IsShown() then - local id = self:GetID() + HandleModifiedItemClick(GetMerchantItemLink(id)) + + elseif hasaltcurrency then local link = GetMerchantItemLink(id) self.link, self.texture = GetMerchantItemLink(id), self.icon:GetTexture() MerchantFrame_ConfirmExtendedItemCost(self) - else self:BuyItem() end + + else + self:BuyItem() + end end