Thread: the _G changes.
View Single Post
09-18-10, 12:53 AM   #14
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
For the item border code you need to make a similar change to the UpdateItemQualityBorders function:
lua Code:
  1. local function UpdateItemQualityBorders(frame, _, unit)
  2.     if frame.unit ~= unit then return end
  3.     local border = borders[frame]
  4.     for id = 1, #slots do
  5.         local link = GetInventoryItemLink(unit, id)                                         -- GetInventoryItemQuality doesn't work for InspectFrame
  6.         if link then
  7.             local color = qualityColor[link:match("|[Cc][Ff][Ff](%x%x%x%x%x%x)")]
  8.             border[id]:SetVertexColor(color[1], color[2], color[3])
  9.             border[id]:Show()
  10.         else
  11.             border[id]:Hide()
  12.         end
  13.     end
  14. end

For the notes code the OnAccept function should be:
lua Code:
  1. OnAccept = function(self)
  2.     addNoteFromPopup(_G[self:GetName() .. "EditBox"]:GetText())
  3. end,

Also, both EditBox functions have "_G[self:GetParent():GetName() .. 'EditBox']:GetText()" which is the same as "self:GetText()" so you may want to change that. However, I think that whole section of code could use some cleaning up:
lua Code:
  1. StaticPopupDialogs["GTipNotes"] = {
  2.     button1 = SET,
  3.     button2 = CANCEL,
  4.     hasEditBox = true,
  5.     hideOnEscape = true,
  6.     text = POPUP_TEXT,
  7.     timeout = 0,
  8.     whileDead = true,
  9.     EditBoxOnEnterPressed = function(self, data)
  10.         local note = self:GetText():trim()
  11.         if note == "" then
  12.             note = nil
  13.         end
  14.         GTipNotesDB[data] = note
  15.         self:GetParent():Hide()
  16.     end,
  17.     EditBoxOnEscapePressed = function(self)
  18.         self:GetParent():Hide()
  19.     end,
  20.     OnAccept = function(self, data)
  21.         local note = _G[self:GetName() .. 'EditBox']:GetText():trim()
  22.         if note == "" then
  23.             note = nil
  24.         end
  25.         GTipNotesDB[data] = note
  26.     end
  27. }
  28.  
  29. SlashCmdList["GTIPNOTES_SHORTHAND"] = function(note)
  30.     if UnitExists('target') then
  31.         local name = UnitName('target')
  32.         note = note:trim()
  33.         if note == "" then
  34.             note = GTipNotesDB[name]
  35.         end
  36.         StaticPopup_Show("GTipNotes", name, nil, name)
  37.         if note then
  38.             name = StaticPopup_Visible("GTipNotes")
  39.             if name then
  40.                 _G[name .. 'EditBox']:SetText(note)
  41.             end
  42.         end
  43.     else
  44.         print(TARGET_ERROR)
  45.     end
  46. end