From 8c0208a04c855653914b799074a89e2c4b142b3a Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Fri, 15 Jul 2016 14:29:15 +0200 Subject: [PATCH] refactoring --- core.lua | 1 - modules/tooltip.lua | 33 ++++++++++++++++----------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/core.lua b/core.lua index 50233be..3543e85 100644 --- a/core.lua +++ b/core.lua @@ -102,7 +102,6 @@ function Aux.on_load() end end - Aux.tooltip.on_load() Aux.search_frame.on_load() Aux.post_frame.on_load() Aux.auctions_frame.on_load() diff --git a/modules/tooltip.lua b/modules/tooltip.lua index 0e02c2b..1d09812 100644 --- a/modules/tooltip.lua +++ b/modules/tooltip.lua @@ -1,5 +1,4 @@ -local private, public = {}, {} -Aux.tooltip = public +local m, private, public = Aux:module'tooltip' aux_tooltip_value = true @@ -7,7 +6,7 @@ local game_tooltip_hooks = {} local hooked_setter local game_tooltip_money -function public.on_load() +function public.LOAD() for func, hook in game_tooltip_hooks do local func, hook = func, hook Aux.hook( @@ -30,7 +29,7 @@ function public.on_load() if not IsShiftKeyDown() and not IsControlKeyDown() and name then local _, _, _, hex = GetItemQualityColor(quality) local link = hex.. '|H'..arg[1]..'|h['..name..']|h|r' - private.extend_tooltip(ItemRefTooltip, link, 1) + m.extend_tooltip(ItemRefTooltip, link, 1) end return result end @@ -133,7 +132,7 @@ function game_tooltip_hooks:SetHyperlink(itemstring) if name then local _, _, _, hex = GetItemQualityColor(quality) local link = hex.. '|H'..itemstring..'|h['..name..']|h|r' - private.extend_tooltip(GameTooltip, link, 1) + m.extend_tooltip(GameTooltip, link, 1) end end @@ -141,7 +140,7 @@ function game_tooltip_hooks:SetAuctionItem(type, index) local link = GetAuctionItemLink(type, index) if link then local _, _, quantity = GetAuctionItemInfo(type, index) - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end @@ -149,7 +148,7 @@ function game_tooltip_hooks:SetLootItem(slot) local link = GetLootSlotLink(slot) if link then local _, _, quantity = GetLootSlotInfo(slot) - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end @@ -157,7 +156,7 @@ function game_tooltip_hooks:SetQuestItem(qtype, slot) local link = GetQuestItemLink(qtype, slot) if link then local _, _, quantity = GetQuestItemInfo(qtype, slot) - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end @@ -165,7 +164,7 @@ function game_tooltip_hooks:SetQuestLogItem(qtype, slot) local link = GetQuestLogItemLink(qtype, slot) if link then local _, _, quantity = GetQuestLogRewardInfo(slot) - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end @@ -173,7 +172,7 @@ function game_tooltip_hooks:SetBagItem(bag, slot) local link = GetContainerItemLink(bag, slot) if link then local _, quantity = GetContainerItemInfo(bag, slot) - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end @@ -185,14 +184,14 @@ function game_tooltip_hooks:SetInboxItem(index) local _, itemstring, quality = GetItemInfo(id) local _, _, _, hex = GetItemQualityColor(tonumber(quality)) local link = hex.. '|H'..itemstring..'|h['..name..']|h|r' - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end function game_tooltip_hooks:SetInventoryItem(unit, slot) local link = GetInventoryItemLink(unit, slot) if link then - private.extend_tooltip(GameTooltip, link, 1) + m.extend_tooltip(GameTooltip, link, 1) end end @@ -200,7 +199,7 @@ function game_tooltip_hooks:SetMerchantItem(slot) local link = GetMerchantItemLink(slot) if link then local _, _, _, quantity = GetMerchantItemInfo(slot) - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end @@ -214,14 +213,14 @@ function game_tooltip_hooks:SetCraftItem(skill, slot) quantity = 1 end if link then - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end function game_tooltip_hooks:SetCraftSpell(slot) local link = GetCraftItemLink(slot) if link then - private.extend_tooltip(GameTooltip, link, 1) + m.extend_tooltip(GameTooltip, link, 1) end end @@ -235,7 +234,7 @@ function game_tooltip_hooks:SetTradeSkillItem(skill, slot) quantity = 1 end if link then - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) end end @@ -245,7 +244,7 @@ function game_tooltip_hooks:SetAuctionSellItem() for slot in Aux.util.inventory() do local link = GetContainerItemLink(unpack(slot)) if link and ({Aux.info.parse_hyperlink(link)})[5] == name then - private.extend_tooltip(GameTooltip, link, quantity) + m.extend_tooltip(GameTooltip, link, quantity) return end end