Advertisement
Guest User

Untitled

a guest
Sep 15th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.47 KB | None | 0 0
  1. ----------------------------------------
  2. -- Credits
  3. ----------------------------------------
  4. -- Wowwiki
  5. -- Kouri
  6. -- Kollektiv
  7. -- Lyn
  8. -- haste
  9. -- evl
  10. -- Blizzard AND ANYONE ELSE THAT ADDED CODE TO sARENA ( :P)
  11. local trinkets = {}
  12. local wotfs = {}
  13. local events = CreateFrame("Frame")
  14. JaxFramesData = {}
  15.  
  16. function events:ADDON_LOADED(addonName)
  17.     if addonName ~= "Blizzard_ArenaUI" then return end
  18.     if JaxFramesData["Frame_scale"] then
  19.         ArenaEnemyFrames:SetScale(JaxFramesData["Frame_scale"])
  20.         ArenaPrepFrames:SetScale(JaxFramesData["Frame_scale"])
  21.     else
  22.         ArenaEnemyFrames:SetScale(1.3)
  23.         ArenaPrepFrames:SetScale(1.3)
  24.     end
  25.  
  26.     ArenaEnemyFrame1:ClearAllPoints()
  27.     ArenaPrepFrame1:ClearAllPoints()
  28.     local arenaFrame, trinket
  29.     if JaxFramesData["Frame_point"] then
  30.         framez = CreateFrame("Frame", WorldFrame, UIParent)
  31.         framez:SetPoint("Center", WorldFrame, "Center");
  32.         framez:SetWidth(150); framez:SetHeight(310);
  33.         framez:SetPoint(JaxFramesData["Frame_point"], JaxFramesData["Frame_relativeTo"], JaxFramesData["Frame_relativePoint"], JaxFramesData["Frame_xOfs"], JaxFramesData["Frame_yOfs"])
  34.         texy = framez:CreateTexture("ARTWORK");
  35.         texy:SetAllPoints();
  36.         texy:SetTexture(1.0, 0, 0); texy:SetAlpha(0.5);
  37.         texy:Hide()
  38.     end
  39.     for i = 1, MAX_ARENA_ENEMIES do
  40.         arenaFrame = "ArenaEnemyFrame"..i
  41.         faction    = UnitFactionGroup("arena"..i)
  42.         _, race    = UnitRace("arena"..i)
  43.         _G[arenaFrame]:ClearAllPoints()
  44.         if framez then
  45.             point, relativeTo, relativePoint, xOfs, yOfs = texy:GetPoint()
  46.             _G[arenaFrame]:SetPoint(point, relativeTo, relativePoint, xOfs, yOfs-(52*(i-1)))
  47.             _G["ArenaPrepFrame"..i]:SetPoint(point, relativeTo, relativePoint, xOfs, yOfs-(52*(i-1)))
  48.         else
  49.             _G[arenaFrame]:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -187, -200-(52*(i-1)))
  50.             _G["ArenaPrepFrame"..i]:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -187, -200-(52*(i-1)))
  51.         end
  52.         trinket = CreateFrame("Cooldown", arenaFrame.."Trinket", nil)
  53.         trinket:SetPoint("TOPRIGHT", arenaFrame, 32, -6)
  54.         trinket:SetSize(24, 24)
  55.         trinket.icon = trinket:CreateTexture(nil, "BACKGROUND")
  56.         trinket.icon:SetAllPoints()
  57.         -- determine faction and assign appropriate trinket icon
  58.         if(faction == "Alliance") then
  59.             if(race == "HUMAN") then
  60.                 trinket.icon:SetTexture("Interface\\Icons\\spell_shadow_charm") --alliance
  61.             else
  62.                 trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_01") --alliance
  63.             end
  64.         else
  65.             trinket.icon:SetTexture("Interface\\Icons\\inv_jewelry_trinketpvp_02") --horde
  66.         end
  67.         trinket:Hide()
  68.         trinkets["arena"..i] = trinket
  69.         trinkets["arena"..i.."usedTime"] = 0
  70.         -- if enemy is undead, create a frame next to the trinket frame for will of the forsaken
  71.         if(race == "UNDEAD") then
  72.             wotf = CreateFrame("Cooldown", arenaFrame.."WOTF", nil)
  73.             wotf:SetPoint("TOPRIGHT", trinket, 32, 0)
  74.             wotf:SetSize(24, 24)
  75.             wotf.icon = wotf:CreateTexture(nil, "BACKGROUND")
  76.             wotf.icon:SetAllPoints()
  77.             wotf.icon:SetTexture("Interface\\Icons\\spell_shadow_raisedead") --wotf(UD)
  78.             wotf:Hide()
  79.             wotfs["arena"..i] = wotf
  80.             wotfs["arena"..i.."usedTime"] = 0
  81.         end
  82.     end
  83.     self:UnregisterEvent("ADDON_LOADED")
  84. end
  85.  
  86. function events:UNIT_SPELLCAST_SUCCEEDED(unitID, spell, rank, lineID, spellID)
  87.     if not trinkets[unitID] then return end
  88.     if spellID == 59752 or spellID == 42292 then
  89.         CooldownFrame_SetTimer(trinkets[unitID], GetTime(), 120, 1)
  90.         trinkets[unitID.."usedTime"] = GetTime()
  91.         SendChatMessage("Trinket used by: "..GetUnitName(unitID, true), "PARTY")
  92.         if((_, race = UnitRace(unitID)) == "UNDEAD") then
  93.             if GetTime()-wotfs[unitID.."usedTime"] > 90 then
  94.                 CooldownFrame_SetTimer(wotfs[unitID], GetTime(), 30, 1)
  95.             elseif wotfs[unitID.."usedTime"] == 0 then
  96.                 CooldownFrame_SetTimer(wotfs[unitID], GetTime(), 30, 1)
  97.             end
  98.             CooldownFrame_SetTimer(wotfs[unitID], GetTime(), 30, 1) -- wotf frame
  99.         end
  100.     elseif spellID == 7744 then
  101.         if GetTime()-trinkets[unitID.."usedTime"] > 90 then
  102.             CooldownFrame_SetTimer(trinkets[unitID], GetTime(), 30, 1)
  103.         elseif trinkets[unitID.."usedTime"] == 0 then
  104.             CooldownFrame_SetTimer(trinkets[unitID], GetTime(), 30, 1)
  105.         end
  106.         CooldownFrame_SetTimer(wotfs[unitID], GetTime(), 120, 1) -- wotf frame
  107.         SendChatMessage("WotF used by: "..GetUnitName(unitID, true), "PARTY")
  108.     end
  109. end
  110.  
  111. function events:PLAYER_ENTERING_WORLD()
  112.     local _, instanceType = IsInInstance()
  113.     if instanceType == "arena" then
  114.         ArenaEnemyFrame1.SetPoint = function() end
  115.         ArenaEnemyFrame2.SetPoint = function() end
  116.         ArenaEnemyFrame3.SetPoint = function() end
  117.         ArenaEnemyFrame4.SetPoint = function() end
  118.         ArenaEnemyFrame5.SetPoint = function() end
  119.         self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  120.     elseif self:IsEventRegistered("UNIT_SPELLCAST_SUCCEEDED") then
  121.         self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
  122.         for i = 1, 5 do
  123.             trinkets["arena"..i]:Hide()
  124.         end
  125.     end
  126. end
  127.  
  128. SLASH_JaxFrames1 = "/testarena"
  129. SlashCmdList["JaxFrames"] = function(msg, editBox)
  130.     if editBox:GetText() == "/testarena" then
  131.         testFrames()
  132.     end
  133. end
  134.  
  135. function testFrames()
  136.     if not IsAddOnLoaded("Blizzard_ArenaUI") then
  137.         LoadAddOn("Blizzard_ArenaUI")
  138.     end
  139.     ArenaEnemyFrames:Show()
  140.     local arenaFrame
  141.     for i = 1, MAX_ARENA_ENEMIES do
  142.         arenaFrame = _G["ArenaEnemyFrame"..i]
  143.         arenaFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  144.         arenaFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["ROGUE"]))
  145.         arenaFrame.name:SetText("Jax")
  146.         arenaFrame:Show()
  147.         CooldownFrame_SetTimer(trinkets["arena"..i], GetTime(), 120, 1)
  148.     end
  149. end
  150. ----------------------------------------
  151. -- Options Panel Declarations
  152. ----------------------------------------
  153. local O = "JaxFramesOptionsPanel"
  154. panel = CreateFrame( "Frame", O, UIParent );
  155. panel.name = "JaxFrames";
  156.  
  157. local TitleLabel = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
  158. TitleLabel:SetText("JaxFrames Configuration GUI")
  159. TitleLabel:SetPoint("TOPLEFT", 16, -16)
  160.  
  161. TestMode = CreateFrame("CheckButton", O.."TestMode", panel, "OptionsCheckButtonTemplate")
  162.  
  163. TestMode:SetPoint("TOPLEFT", TitleLabel, "BOTTOMLEFT", 0, -16)
  164. _G[O.."TestModeText"]:SetText("Show Arena Frames (Enable to change scale)")
  165.  
  166. function TestMode:OnClick()
  167.     if self:GetChecked() then
  168.         testFrames()   
  169.         FrameScaleSlider:Enable()
  170.  
  171.     else
  172.         if instanceType ~= "arena" then
  173.             if ArenaEnemyFrames then ArenaEnemyFrames:Hide() end
  174.         end
  175.         FrameScaleSlider:Disable()
  176.          for i = 1, MAX_ARENA_ENEMIES do
  177.             trinkets["arena"..i]:SetCooldown(0, 0)
  178.             trinkets["arena"..i]:Hide()
  179.          end
  180.     end
  181. end
  182.  
  183. TestMode:SetScript("OnClick", TestMode.OnClick)
  184.  
  185. Unlock = CreateFrame("CheckButton", O.."Unlock", panel, "OptionsCheckButtonTemplate")
  186.  
  187. Unlock:SetPoint("TOPLEFT", TitleLabel, "BOTTOMLEFT", 0, -40)
  188. _G[O.."UnlockText"]:SetText("Unlock Arena Frames (Disable to change scale)")
  189.  
  190. function Unlock:OnClick()
  191.     if self:GetChecked() then
  192.         TestMode:Disable()
  193.         FrameScaleSlider:Disable()
  194.         frame = CreateFrame("Frame", WorldFrame, UIParent)
  195.         frame:SetMovable(true)
  196.         frame:EnableMouse(true)
  197.         frame:RegisterForDrag("LeftButton")
  198.         frame:SetScript("OnMouseDown", function(self, button)
  199.           if button == "LeftButton" and not self.isMoving then
  200.            self:StartMoving();
  201.            self.isMoving = true;
  202.           end
  203.         end)
  204.         frame:SetScript("OnMouseUp", function(self, button)
  205.           if button == "LeftButton" and self.isMoving then
  206.            self:StopMovingOrSizing();
  207.            self.isMoving = false;
  208.           end
  209.         end)
  210.         frame:SetScript("OnUpdate", function(self, button)
  211.         if self.isMoving then
  212.             for i = 1, MAX_ARENA_ENEMIES do
  213.                 point, relativeTo, relativePoint, xOfs, yOfs = tex:GetPoint()
  214.                 arenaFrame = _G["ArenaEnemyFrame"..i]
  215.                 arenaFrame:ClearAllPoints()
  216.                 arenaFrame:SetPoint(point, relativeTo, relativePoint, xOfs, yOfs-(52*(i-1)))
  217.                 p, rt, rp, x, y = frame:GetPoint()
  218.                 JaxFramesData["Frame_point"] = p
  219.                 JaxFramesData["Frame_relativeTo"] = rt
  220.                 JaxFramesData["Frame_relativePoint"] = rp
  221.                 JaxFramesData["Frame_xOfs"] = x
  222.                 JaxFramesData["Frame_yOfs"] = y
  223.             end
  224.         end
  225.         end)
  226.         if JaxFramesData["Frame_point"] then
  227.             frame:SetPoint("Center", WorldFrame, "Center");
  228.             frame:SetWidth(150);
  229.             frame:SetHeight(310);
  230.             frame:SetPoint(JaxFramesData["Frame_point"], JaxFramesData["Frame_relativeTo"], JaxFramesData["Frame_relativePoint"], JaxFramesData["Frame_xOfs"], JaxFramesData["Frame_yOfs"])
  231.         else
  232.             frame:SetPoint("Center", WorldFrame, "Center");
  233.             frame:SetWidth(150); frame:SetHeight(310);
  234.         end
  235.         tex = frame:CreateTexture("ARTWORK");
  236.         tex:SetAllPoints();
  237.         tex:SetTexture(1.0, 0, 0); tex:SetAlpha(0.5);
  238.         if not JaxFramesData["Frame_point"] then
  239.             for i = 1, MAX_ARENA_ENEMIES do
  240.                 point, relativeTo, relativePoint, xOfs, yOfs = tex:GetPoint()
  241.                 arenaFrame = _G["ArenaEnemyFrame"..i]
  242.                 arenaFrame:ClearAllPoints()
  243.                 arenaFrame:SetPoint(point, relativeTo, relativePoint, xOfs, yOfs-(52*(i-1)))
  244.             end
  245.         end
  246.        
  247.     else
  248.         TestMode:Enable()
  249.         FrameScaleSlider:Enable()
  250.         frame:Hide()
  251.     end
  252. end
  253.  
  254. Unlock:SetScript("OnClick", Unlock.OnClick)
  255.  
  256. ----------------------------------------
  257. -- Slider helper function, thanks to Kollektiv
  258. ----------------------------------------
  259. local function CreateSlider(text, parent, low, high, step)
  260.     local name = parent:GetName() .. text
  261.     local slider = CreateFrame("Slider", name, parent, "OptionsSliderTemplate")
  262.     slider:SetWidth(160)
  263.     slider:SetMinMaxValues(low, high)
  264.     slider:SetValueStep(step)
  265.     --_G[name .. "Text"]:SetText(text)
  266.     _G[name .. "Low"]:SetText(low)
  267.     _G[name .. "High"]:SetText(high)
  268.     return slider
  269. end
  270.  
  271. ----------------------------------------
  272. -- Frame Scale Slider
  273. ----------------------------------------
  274. FrameScaleSlider = CreateSlider("FrameScaleSlider", panel, 0.5, 3.0, 0.1)
  275. FrameScaleSlider:SetScript("OnValueChanged", function(self, value)
  276.     if IsAddOnLoaded("Blizzard_ArenaUI") then
  277.         _G[self:GetName() .. "Text"]:SetText("Scale: " .. " (" .. tonumber(string.format("%." .. 1 .. "f", value)) .. ")")
  278.         ArenaEnemyFrames:SetScale(value)
  279.         ArenaPrepFrames:SetScale(value)
  280.         JaxFramesData["Frame_scale"] = value       
  281.     end
  282.    
  283. end)
  284.  
  285. local FramesLabel = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
  286. FramesLabel:SetText("Arena Frames Options")
  287. FramesLabel:SetPoint("TOPLEFT", TestMode, "BOTTOMLEFT", 0, -30)
  288. FrameScaleSlider:SetPoint("TOPLEFT", FramesLabel, "BOTTOMLEFT", 2, -24)
  289. FrameScaleSlider:SetScript("OnEnable", function(self, button)
  290.     _G[self:GetName() .. "Text"]:SetTextColor(1, 1, 1, 1)
  291.     if JaxFramesData["Frame_scale"] then
  292.         _G[self:GetName() .. "Text"]:SetText("Scale: " .. " (" .. tonumber(string.format("%." .. 1 .. "f", JaxFramesData["Frame_scale"])) .. ")")
  293.     else
  294.         _G[self:GetName() .. "Text"]:SetText("Scale: " .. " (" .. tonumber(string.format("%." .. 1 .. "f", 1.3)) .. ")")
  295.     end
  296. end)
  297. FrameScaleSlider:SetScript("OnDisable", function(self, button)
  298.     _G[self:GetName() .. "Text"]:SetTextColor(0.50, 0.50, 0.50, 1)
  299.     _G[self:GetName() .. "Text"]:SetText("Scale: (Disabled)")
  300. end)
  301. FrameScaleSlider:Disable()
  302.  
  303. panel.refresh = function()
  304.     if JaxFramesData["Frame_scale"] then
  305.         FrameScaleSlider:SetValue(JaxFramesData["Frame_scale"])
  306.     else
  307.         FrameScaleSlider:SetValue(1.3)
  308.     end
  309. end
  310.  
  311. InterfaceOptions_AddCategory(panel);
  312.  
  313.  
  314.  
  315.  
  316. events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
  317. events:RegisterEvent("ADDON_LOADED")
  318. events:RegisterEvent("PLAYER_ENTERING_WORLD")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement