View Single Post
09-16-12, 02:30 AM   #6
jostor
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 10
Originally Posted by Dridzt View Post
Code:
local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton_OnClick
QueueStatusMinimapButton_OnClick = function(...)
  local _, instanceType = IsInInstance()
  local _, button = ...
  if instanceType == "pvp" and button == "LeftButton" then
    local shown = WorldStateScoreFrame:IsVisible() and WorldStateScoreFrame:Hide() or WorldStateScoreFrame:Show()
  else
    QueueStatusMinimapButton_OnClick_orig(...)
  end
end
Warning: drycoded

Alternative version of the same thing in case the button is using 'new style' <OnShow function='blah'/> handler.
Code:
local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton:GetScript("OnClick")
QueueStatusMinimapButton:SetScript("OnClick", function(...)
  local _, instanceType = IsInInstance()
  local _, button = ...
  if instanceType == "pvp" and button == "LeftButton" then
    local shown = WorldStateScoreFrame:IsVisible() and WorldStateScoreFrame:Hide() or WorldStateScoreFrame:Show()
  else
    QueueStatusMinimapButton_OnClick_orig(...)
  end
end)
Thank you, saving the original function was the part I was missing.

Final code (seems to be working fine as far as my testing goes):
Lua Code:
  1. local QueueStatusMinimapButton_OnClick_orig = QueueStatusMinimapButton:GetScript("OnClick")
  2. QueueStatusMinimapButton:SetScript("OnClick", function(...)
  3.     local isInstance, instanceType = IsInInstance()
  4.     local _, button = ...
  5.        
  6.     if isInstance and instanceType == "pvp" and button == "LeftButton" then
  7.         if WorldStateScoreFrame:IsVisible() then
  8.             WorldStateScoreFrame:Hide()
  9.         else
  10.             WorldStateScoreFrame:Show()
  11.         end
  12.     else
  13.         QueueStatusMinimapButton_OnClick_orig(...)
  14.     end
  15.  
  16. end)
  Reply With Quote