WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Search/Requests (https://www.wowinterface.com/forums/forumdisplay.php?f=6)
-   -   Jewelcrafting (https://www.wowinterface.com/forums/showthread.php?t=46401)

Tonyleila 05-05-13 12:15 PM

Jewelcrafting
 
Searching for the right gem realy sucks. I always know the stats I need but not the name of the gem. So GemHelper looks like a nice addon but its realy too much for my needs.

Cool woud be a namechange inside the original skill window. Instead of the gem name it shoud show the stats of the gem but the name is still searchable. Anyone know an addon like this or know if this is even possible?
Other idea woud be to show the gem tooltip on mouseover so you don't have to klick each gem to know the stats.

Woud look like the right one:

p3lim 05-05-13 01:41 PM

Code:

local disabled = true
local button

local tip = CreateFrame('GameTooltip', 'GemStatsTip')
local line1 = tip:CreateFontString()
local line2 = tip:CreateFontString()
local line3 = tip:CreateFontString()

tip:AddFontStrings(tip:CreateFontString(), tip:CreateFontString())
tip:AddFontStrings(line1, tip:CreateFontString())
tip:AddFontStrings(line2, tip:CreateFontString())
tip:AddFontStrings(line3, tip:CreateFontString())

local JEWELCRAFTING_S = GetSpellInfo(25229)
local GEM_S = '%+[0-9]+.*'

local match = string.match

local function GetGemStats(id)
        tip:SetOwner(WorldFrame, 'ANCHOR_NONE')
        tip:SetTradeSkillItem(id)

        if(tip:IsShown()) then
                return match(line1:GetText() or '', GEM_S) or match(line2:GetText() or '', GEM_S) or match(line3:GetText() or '', GEM_S)
        end
end

local function Update()
        if(GetTradeSkillLine() ~= JEWELCRAFTING_S) then
                if(button) then
                        button:Hide()
                end

                return
        else
                button:Show()
        end

        if(not IsTradeSkillReady()) then return end
        if(disabled) then return end

        local filterBar = TradeSkillFilterBar:IsShown()
        for index = 1, TRADE_SKILLS_DISPLAYED, 1 do
                local buttonIndex = filterBar and index + 1 or index

                local button = _G['TradeSkillSkill' .. buttonIndex]
                if(button) then
                        local stats = GetGemStats(button:GetID())
                        if(stats) then
                                _G['TradeSkillSkill' .. buttonIndex .. 'Text']:SetText(stats)
                        end
                end
        end
end

local f = CreateFrame('Frame')
f:RegisterEvent('ADDON_LOADED')
f:SetScript('OnEvent', function(self, event, name)
        if(name == 'Blizzard_TradeSkillUI') then
                button = CreateFrame('Button', 'SomeRandomButton123', TradeSkillFrame, 'UIPanelButtonTemplate')
                button:SetPoint('TOPRIGHT', TradeSkillFrameCloseButton, 'TOPLEFT', 4, -6)
                button:SetSize(22, 20)
                button:SetText('J')
                button:SetScript('OnClick', function()
                        disabled = not disabled
                        TradeSkillFrame_Update()
                end)

                hooksecurefunc('TradeSkillFrame_Update', Update)
        end
end)



Keep in mind you have to change JEWELCRAFTING_S to whatever "Jewelcrafting" is in your locale.
And the search function doesn't see this, it still looks for the name.

myrroddin 05-05-13 02:08 PM

Quote:

Originally Posted by p3lim (Post 277606)
Keep in mind you have to change JEWELCRAFTING_S to whatever "Jewelcrafting" is in your locale.

Lua Code:
  1. local jewelcrafting = GetSpellInfo(755)

Tonyleila 05-05-13 02:44 PM

thank you both! But can't get this to work on german client :/
Can anyone post full lua file again?

Phanx 05-05-13 04:40 PM

In p3lim's code, replace this:
Code:

local JEWELCRAFTING_S = 'Jewelcrafting'
with this:
Code:

local JEWELCRAFTING_S = GetSpellInfo(755)
If that still doesn't work, please be more specific about what isn't working in German, and make sure you have BugSack turned on to catch errors.

Tonyleila 05-05-13 05:04 PM

It for me it not changing anything looks as if the addon is not there but is shown in the addon list. So this is the code how i cange it.

EDIT:
This is how the german tooltip looks like - maybe its different?


juwe.toc
Lua Code:
  1. ## Interface: 50200
  2. ## Notes: Jewelcrafting gems stats instead of names
  3. ## Version: 1.0
  4. ## Title: Juwe
  5. ## Author: p3lim
  6. juwe.lua

juwe.lua
Lua Code:
  1. local tip = CreateFrame('GameTooltip', 'GemStatsTip')
  2.     local line1 = tip:CreateFontString()
  3.     local line2 = tip:CreateFontString()
  4.     local line3 = tip:CreateFontString()
  5.      
  6.     tip:AddFontStrings(tip:CreateFontString(), tip:CreateFontString())
  7.     tip:AddFontStrings(line1, tip:CreateFontString())
  8.     tip:AddFontStrings(line2, tip:CreateFontString())
  9.     tip:AddFontStrings(line3, tip:CreateFontString())
  10.      
  11. local JEWELCRAFTING_S = GetSpellInfo(755)
  12.     local GEM_S = '%+[0-9]+.*'
  13.      
  14.     local match = string.match
  15.      
  16.     local function GetGemStats(id)
  17.         tip:SetOwner(WorldFrame, 'ANCHOR_NONE')
  18.         tip:SetTradeSkillItem(id)
  19.      
  20.         if(tip:IsShown()) then
  21.             return match(line1:GetText() or '', GEM_S) or match(line2:GetText() or '', GEM_S) or match(line3:GetText() or '', GEM_S)
  22.         end
  23.     end
  24.      
  25.     local function Update()
  26.         if(GetTradeSkillLine() ~= JEWELCRAFTING_S) then return end
  27.         if(not IsTradeSkillReady()) then return end
  28.      
  29.         local filterBar = TradeSkillFilterBar:IsShown()
  30.         for index = 1, TRADE_SKILLS_DISPLAYED, 1 do
  31.             local buttonIndex = filterBar and index + 1 or index
  32.      
  33.             local stats = GetGemStats(_G['TradeSkillSkill' .. buttonIndex]:GetID())
  34.             if(stats) then
  35.                 _G['TradeSkillSkill' .. buttonIndex .. 'Text']:SetText(stats)
  36.             end
  37.         end
  38.     end
  39.      
  40.     local f = CreateFrame('Frame')
  41.     f:RegisterEvent('ADDON_LOADED')
  42.     f:SetScript('OnEvent', function(self, event, name)
  43.         if(name == 'Blizzard_TradeSkillUI') then
  44.             hooksecurefunc('TradeSkillFrame_Update', Update)
  45.         end
  46.     end)

Phanx 05-05-13 08:33 PM

Read my last post and make the change I suggested. It's not a tooltip issue. Your code is still looking for the English tradeskill name "Jewelcrafting". You need to use GetSpellInfo instead.

Stanzilla 05-05-13 08:37 PM

Quote:

Originally Posted by Phanx (Post 277619)
In p3lim's code, replace this:
Code:

local JEWELCRAFTING_S = 'Jewelcrafting'
with this:
Code:

local JEWELCRAFTING_S = GetSpellInfo(755)
If that still doesn't work, please be more specific about what isn't working in German, and make sure you have BugSack turned on to catch errors.

755 is Health Funnel, though. You want 25229.

Tonyleila 05-05-13 09:01 PM

Quote:

Originally Posted by Stanzilla (Post 277630)
755 is Health Funnel, though. You want 25229.

Ahh that was it, Thanks :)

@ Phanx sorry posted the wrong code xD I made the edit you suggested but with the 755 as spell id :)

Looks realy cool now!
however now had this lua error :D

Code:

21x Juwe-1.0\juwe-1.0.lua:33: attempt to index field "?" (a nil value)
Juwe-1.0\juwe-1.0.lua:33: in function <Juwe\juwe.lua:25>
<in C code>
FrameXML\UIPanelTemplates.lua:354: in function "FauxScrollFrame_OnVerticalScroll"
<string>:"*:OnVerticalScroll":1: in function <string>:"*:OnVerticalScroll":1
<in C code>
<string>:"*:OnValueChanged":1: in function <string>:"*:OnValueChanged":1
<in C code>
Blizzard_TradeSkillUI\Blizzard_TradeSkillUI.lua:820: in function "TradeSkillUpdateFilterBar"
Blizzard_TradeSkillUI\Blizzard_TradeSkillUI.lua:861: in function "func"
FrameXML\UIDropDownMenu.lua:710: in function "UIDropDownMenuButton_OnClick"
<string>:"*:OnClick":1: in function <string>:"*:OnClick":1

Locals:
(*temporary) = <func> =[C]:-1
 = <func> =[C]:-1
 = <func> @Juwe\juwe.lua:25


Phanx 05-05-13 10:20 PM

Wrong spell ID was Myrroddin's fault. :p

As for the error, assuming the code you edited into your last post is your current actual code, that means that this line is causing the problem:

Code:

local stats = GetGemStats(_G['TradeSkillSkill' .. buttonIndex]:GetID())
Specifically, "TradeSkillSkillX", where X is the value of buttonIndex, could not be found in the global namespace. I don't have time right now to look into it in any greater detail or try it in-game, though.

Tonyleila 05-05-13 10:39 PM

Hmm I was not able to reproduce the error after it first appears but it I think it happend while show only skilling gems + only one frame was expended... I'll comment again if I see the error again

Tonyleila 05-06-13 09:42 AM

OK just found out how to reproduce the error.
Make shure you don't have raw Jewelcrafting gems in your bag.
Look into guild roster and klick on "show all" at the Jewelcrafting.
Filter to only show gems where you have the mats, now if it shows nothing because you don't have mats the error will pop up:

Code:

10x Juwe-1.0\juwe-1.0.lua:33: attempt to index field "?" (a nil value)
Juwe-1.0\juwe-1.0.lua:33: in function <Juwe\juwe.lua:25>
<in C code>
Blizzard_TradeSkillUI\Blizzard_TradeSkillUI.lua:140: in function <Blizzard_TradeSkillUI\Blizzard_TradeSkillUI.lua:128>
<in C code>
<string>:"*:OnClick":1: in function <string>:"*:OnClick":1

Locals:
(*temporary) = <func> =[C]:-1
 = <func> =[C]:-1
 = <func> @Juwe\juwe.lua:25

Also Woud be cool to have a small button on the top left of the tradeskill window where I can disable the addon ingame without reloading - this woud e.g. help to search gems that you need for the Jewelcrafting quests.

ravagernl 05-06-13 10:55 AM

This is kind of interesting. Is there any way to make this work for Skillet or ATSW?

Oh wait.... searches in skillets files... finds:

lua Code:
  1. --
  2. -- A hook to get text to append to the name of the recipe in the scrolling list of recipes
  3. -- If you hook this method, make sure to include any text you get from calling the hooked method.
  4. -- This will allow more than one mod to use the hook.
  5. --
  6. -- This will be called for both crafts and tradeskills, you can use Skillet:IsCraft()
  7. -- to determine if it's a craft. This avoid having to localize the tradeskill name just to
  8. -- see if it is a craft or a tradeskill.
  9. --
  10. -- Refer to the notes at the top of this file for how to hook this method.
  11. --
  12. -- @param tradeskill name of the currently selected tradeskill
  13. -- @param skill_index the index of the currently selected recipe
  14. --
  15. function Skillet:GetRecipeNameSuffix(tradeskill, skill_index)
  16. end
How can I find the item id using the profession skill index?

EDIT:
Found it, GameTooltip:SetHyperlink and GetTradeSkillItemLink

Tonyleila 05-07-13 05:47 AM

Any news on how to fix the error / add a button to disable addon ingame? Please woud love to update this with my UI!

p3lim 05-07-13 08:22 AM

Edited my original post, try that.

Tonyleila 05-07-13 11:20 AM

Quote:

Originally Posted by p3lim (Post 277713)
Edited my original post, try that.

Thanks that fixed the error! Only epic gems still show the normal names but thats OK for me.
Is there a button to disable addon if needed? Can't see it. Just the letter "J" on the top right next to the X button woud be perfect.

p3lim 05-07-13 01:50 PM

Updated code

Tonyleila 05-07-13 03:24 PM

Quote:

Originally Posted by p3lim (Post 277727)
Updated code

Thank you p3lim thats just perfect!
Just changed this a bit:
Code:

        button:SetPoint('TOPRIGHT', TradeSkillFrameCloseButton, 'TOPLEFT', -4, -1)
        button:SetSize(15, 15)

Will you upload it as addon here on wowUI? Or woud you mind if I upload it for you with you as the author credit?

p3lim 05-07-13 04:16 PM

Do what ever you want with it.

Tonyleila 05-07-13 06:05 PM

Quote:

Originally Posted by p3lim (Post 277732)
Do what ever you want with it.

Thanks uploaded!
http://www.wowinterface.com/download...adofNames.html


All times are GMT -6. The time now is 05:54 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI