From 6ad0a8da8a5360efb57ebf10400f84d84691af79 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Tue, 29 Sep 2015 19:31:22 +0200 Subject: [PATCH] working on more detailed tooltips --- buy.lua | 16 ++++++++-------- core.lua | 13 ++++++++++--- info.lua | 49 +++++++++++++++++++++++++++++++------------------ 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/buy.lua b/buy.lua index c41d9a9..b0e8f13 100644 --- a/buy.lua +++ b/buy.lua @@ -159,9 +159,8 @@ end ----------------------------------------- function AuxBuyEntry_OnClick() - local entryIndex = this:GetID() - - local entry = entries[entryIndex] + local i = this:GetID() + local entry = entries[i] if Aux_SetContains(selectedEntries, entry) then Aux_RemoveFromSet(selectedEntries, entry) @@ -175,13 +174,14 @@ function AuxBuyEntry_OnClick() end function AuxBuyEntry_OnEnter() - local entryIndex = this:GetID() - local entry = entries[entryIndex] + local i = this:GetID() + local entry = entries[i] - local _, _, itemString = strfind(entry.hyperlink, "^|%x+|H(.+)|h%[.+%]") - if itemString then + -- Aux.info.set_game_tooltip(this, entry.tooltip) + local _, _, item_string = strfind(entry.hyperlink, "^|%x+|H(.+)|h%[.+%]") + if item_string then GameTooltip:SetOwner(this, "ANCHOR_RIGHT") - GameTooltip:SetHyperlink(itemString) + GameTooltip:SetHyperlink(item_string) GameTooltip:Show() if(EnhTooltip ~= nil) then diff --git a/core.lua b/core.lua index 1f13e3f..5ed42cd 100644 --- a/core.lua +++ b/core.lua @@ -505,8 +505,15 @@ end function Aux.auction_key(tooltip, stack_size, buyout_price) local key = '' - for i, entry in ipairs(tooltip) do - key = key .. (i == 1 and '' or '_') + for i, line in ipairs(tooltip) do + local left_text = line[1].text + local right_text = line[2].text + if left_text then + key = key .. left_text .. (i == 1 and '' or '_') + end + if right_text then + key = key .. right_text .. '_' + end end - return key .. '_' .. stack_size .. '_' .. buyout_price + return key .. stack_size .. '_' .. buyout_price end \ No newline at end of file diff --git a/info.lua b/info.lua index 03a5a77..c7e6ca8 100644 --- a/info.lua +++ b/info.lua @@ -76,10 +76,22 @@ function Aux.info.auction_item(index) return auction_item end +function Aux.info.set_game_tooltip(owner, tooltip) + GameTooltip:SetOwner(owner, "ANCHOR_RIGHT") + for i, line in ipairs(tooltip) do + snipe.log(line[1].text) + getglobal('GameTooltipTextLeft'..i):SetText(line[1].text) + getglobal('GameTooltipTextLeft'..i):SetTextColor(line[1].color[1], line[1].color[2], line[1].color[3], line[1].color[4]) + getglobal('GameTooltipTextRight'..i):SetText(line[2].text) + getglobal('GameTooltipTextRight'..i):SetTextColor(line[2].color[1], line[2].color[2], line[2].color[3], line[2].color[4]) + end + GameTooltip:Show() +end + function Aux.info.tooltip(setter) - for j = 1, 30 do - leftEntry = getglobal('AuxInfoTooltipTextLeft'..j):SetText() - rightEntry = getglobal('AuxInfoTooltipTextRight'..j):SetText() + for i = 1, 30 do + getglobal('AuxInfoTooltipTextLeft'..i):SetText() + getglobal('AuxInfoTooltipTextRight'..i):SetText() end AuxInfoTooltip:SetOwner(UIParent, "ANCHOR_NONE") @@ -87,29 +99,30 @@ function Aux.info.tooltip(setter) AuxInfoTooltip:Show() local tooltip = {} - for j = 1, 30 do - local leftEntry = getglobal('AuxInfoTooltipTextLeft'..j):GetText() - if leftEntry then - tinsert(tooltip, leftEntry) - end - local rightEntry = getglobal('AuxInfoTooltipTextRight'..j):GetText() - if rightEntry then - tinsert(tooltip, rightEntry) - end + for i = 1, 30 do + local left_text = getglobal('AuxInfoTooltipTextLeft'..i):GetText() + local left_color = { getglobal('AuxInfoTooltipTextLeft'..i):GetTextColor() } + local right_text = getglobal('AuxInfoTooltipTextRight'..i):GetText() + local right_color = { getglobal('AuxInfoTooltipTextRight'..i):GetTextColor() } + + tinsert(tooltip, {{ text=left_text, color=left_color }, { text=right_text, color=right_color }}) end - for j = 1, 30 do - leftEntry = getglobal('AuxInfoTooltipTextLeft'..j):SetText() - rightEntry = getglobal('AuxInfoTooltipTextRight'..j):SetText() + for i = 1, 30 do + getglobal('AuxInfoTooltipTextLeft'..i):SetText() + getglobal('AuxInfoTooltipTextRight'..i):SetText() end return tooltip end function item_charges(tooltip) - for _, entry in ipairs(tooltip) do - local _, _, charges_string = strfind(entry, "(%d+) Charges") - local charges = tonumber(charges_string) + for _, line in ipairs(tooltip) do + local left_text = line[1].text or '' + local right_text = line[2].text or '' + local _, _, left_charges_string = strfind(left_text, "^(%d+) Charges") + local _, _, right_charges_string = strfind(right_text, "^(%d+) Charges$") + local charges = tonumber(left_charges_string) or tonumber(right_charges_string) if charges then return charges end