From 0c8de8a6f5e08a6f610a03c39d5d215153dd03ff Mon Sep 17 00:00:00 2001 From: Darthpred Date: Sat, 28 Jun 2014 02:04:12 +0400 Subject: [PATCH] Marks --- ElvUI_SLE/modules/marks/flares.lua | 75 ++++++++++++++++++------------- ElvUI_SLE/modules/marks/marks.lua | 83 ++++++++++++++++++++++++----------- ElvUI_SLE/modules/marks/options.lua | 45 +++++++++++-------- 3 files changed, 129 insertions(+), 74 deletions(-) diff --git a/ElvUI_SLE/modules/marks/flares.lua b/ElvUI_SLE/modules/marks/flares.lua index 2191531..4c887d1 100644 --- a/ElvUI_SLE/modules/marks/flares.lua +++ b/ElvUI_SLE/modules/marks/flares.lua @@ -1,5 +1,6 @@ local E, L, V, P, G, _ = unpack(ElvUI); -local RF = E:NewModule('RaidFlares', 'AceHook-3.0', 'AceEvent-3.0'); +local RF = E:NewModule('SLE_RaidFlares', 'AceHook-3.0', 'AceEvent-3.0'); +local template = "SecureActionButtonTemplate" BINDING_HEADER_SHADOWLIGHT_WORLDMARKER = "|cff1784d1Shadow & Light|r" _G["BINDING_NAME_CLICK SquareFlareMarker:LeftButton"] = L["Square Flare"]; @@ -8,25 +9,28 @@ _G["BINDING_NAME_CLICK DiamondFlareMarker:LeftButton"] = L["Diamond Flare"]; _G["BINDING_NAME_CLICK CrossFlareMarker:LeftButton"] = L["Cross Flare"]; _G["BINDING_NAME_CLICK StarFlareMarker:LeftButton"] = L["Star Flare"]; -local mainFlares = CreateFrame("Frame", "Main_Flares", E.UIParent) -local f1 = CreateFrame("Button", "SquareFlareMarker", Main_Flares, "SecureActionButtonTemplate") -local f2 = CreateFrame("Button", "TriangleFlareMarker", Main_Flares, "SecureActionButtonTemplate") -local f3 = CreateFrame("Button", "DiamondFlareMarker", Main_Flares, "SecureActionButtonTemplate") -local f4 = CreateFrame("Button", "CrossFlareMarker", Main_Flares, "SecureActionButtonTemplate") -local f5 = CreateFrame("Button", "StarFlareMarker", Main_Flares, "SecureActionButtonTemplate") -local f6 = CreateFrame("Button", "ClearFlaresMarker", Main_Flares, "SecureActionButtonTemplate") - -local FlareB = {f1,f2,f3,f4,f5,f6} +local mainFlares, f1, f2, f3, f4, f5, f6, FlareB function RF:CreateFrame() + mainFlares = CreateFrame("Frame", "Main_Flares", E.UIParent) mainFlares:Point("CENTER", E.UIParent, "CENTER", 0, 40); mainFlares:SetFrameStrata('LOW'); mainFlares:CreateBackdrop(); mainFlares.backdrop:SetAllPoints(); mainFlares:Hide(); + + f1 = CreateFrame("Button", "SquareFlareMarker", Main_Flares, template) + f2 = CreateFrame("Button", "TriangleFlareMarker", Main_Flares, template) + f3 = CreateFrame("Button", "DiamondFlareMarker", Main_Flares, template) + f4 = CreateFrame("Button", "CrossFlareMarker", Main_Flares, template) + f5 = CreateFrame("Button", "StarFlareMarker", Main_Flares, template) + f6 = CreateFrame("Button", "ClearFlaresMarker", Main_Flares, template) + + FlareB = {f1,f2,f3,f4,f5,f6} end function RF:SetupButton(button, flare) + if not mainFlares then return end button:CreateBackdrop() button.backdrop:SetAllPoints() button:SetAttribute("type", "macro") @@ -64,6 +68,7 @@ function RF:SetupButton(button, flare) end function RF:CreateButtons() + if not mainFlares then return end RF:SetupButton(f1, "/clearworldmarker 1\n/worldmarker 1") RF:SetupButton(f2, "/clearworldmarker 2\n/worldmarker 2") RF:SetupButton(f3, "/clearworldmarker 3\n/worldmarker 3") @@ -73,12 +78,14 @@ function RF:CreateButtons() end function RF:FrameButtonsSize() + if not mainFlares then return end for i = 1, 6 do FlareB[i]:Size(E.db.sle.flares.size) end end function RF:FrameButtonsGrowth() + if not mainFlares then return end local db = E.db.sle.flares local size = db.size local width, height, x, y, anchor, point @@ -110,26 +117,30 @@ function RF:FrameButtonsGrowth() end function RF:UpdateVisibility() + if not mainFlares then return end local inInstance, instanceType = IsInInstance() local db = E.db.sle.flares - if db.enabled then - if (inInstance and instanceType ~= "pvp") and db.showinside then - E.FrameLocks['Main_Flares'] = true - mainFlares:Show() - elseif not inInstance and db.showinside then - E.FrameLocks['Main_Flares'] = nil - mainFlares:Hide() - elseif not db.showinside then - E.FrameLocks['Main_Flares'] = true - mainFlares:Show() - end - else + local show = false + + if (inInstance and instanceType ~= "pvp") and db.showinside then + show = true + elseif not inInstance and db.showinside then + show = false + elseif not db.showinside then + show = true + end + + if show then E.FrameLocks['Main_Flares'] = true + mainFlares:Show() + else + E.FrameLocks['Main_Flares'] = nil mainFlares:Hide() end end function RF:Backdrop() + if not mainFlares then return end if E.db.sle.flares.backdrop then mainFlares.backdrop:Show() else @@ -138,19 +149,21 @@ function RF:Backdrop() end function RF:Update() - RF:FrameButtonsSize() - RF:FrameButtonsGrowth() - RF:UpdateVisibility() - RF:Backdrop() + if not mainFlares then return end + RF:FrameButtonsSize() + RF:FrameButtonsGrowth() + RF:UpdateVisibility() + RF:Backdrop() end function RF:Initialize() - RF:CreateFrame() - RF:Update() - RF:CreateButtons() - self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateVisibility"); + if not E.private.sle.marks.flares then return end + RF:CreateFrame() + RF:Update() + RF:CreateButtons() + self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateVisibility"); - E:CreateMover(mainFlares, "FlareMover", "RF", nil, nil, nil, "ALL,S&L,S&L MISC") + E:CreateMover(mainFlares, "FlareMover", "RF", nil, nil, nil, "ALL,S&L,S&L MISC") end E:RegisterModule(RF:GetName()) \ No newline at end of file diff --git a/ElvUI_SLE/modules/marks/marks.lua b/ElvUI_SLE/modules/marks/marks.lua index 3897795..402c7c1 100755 --- a/ElvUI_SLE/modules/marks/marks.lua +++ b/ElvUI_SLE/modules/marks/marks.lua @@ -1,28 +1,30 @@ --Raid mark bar. Similar to quickmark which just semms to be impossible to skin local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore -local RM = E:NewModule('RaidMarks', 'AceHook-3.0', 'AceEvent-3.0'); +local RM = E:NewModule('SLE_RaidMarks', 'AceHook-3.0', 'AceEvent-3.0'); local Mtemplate = "SecureActionButtonTemplate" - -local mark_menu = CreateFrame("Frame", "Mark_Menu", E.UIParent) -local m1 = CreateFrame("Button", "M1", Mark_Menu, Mtemplate) -local m2 = CreateFrame("Button", "M2", Mark_Menu, Mtemplate) -local m3 = CreateFrame("Button", "M3", Mark_Menu, Mtemplate) -local m4 = CreateFrame("Button", "M4", Mark_Menu, Mtemplate) -local m5 = CreateFrame("Button", "M5", Mark_Menu, Mtemplate) -local m6 = CreateFrame("Button", "M6", Mark_Menu, Mtemplate) -local m7 = CreateFrame("Button", "M7", Mark_Menu, Mtemplate) -local m8 = CreateFrame("Button", "M8", Mark_Menu, Mtemplate) - -local MarkB = {m1,m2,m3,m4,m5,m6,m7,m8} - +local IsInInstance = IsInInstance +local UnitExists = UnitExists +local mark_menu, m1, m2, m3, m4, m5, m6, m7, m8, MarkB --Main frame function RM:CreateFrame() + mark_menu = CreateFrame("Frame", "Mark_Menu", E.UIParent) mark_menu:Point("BOTTOMRIGHT", RightChatTab, "TOPRIGHT", 2, 3) --Default positon mark_menu:SetFrameStrata('LOW'); mark_menu:CreateBackdrop(); mark_menu.backdrop:SetAllPoints(); + m1 = CreateFrame("Button", "M1", Mark_Menu, Mtemplate) + m2 = CreateFrame("Button", "M2", Mark_Menu, Mtemplate) + m3 = CreateFrame("Button", "M3", Mark_Menu, Mtemplate) + m4 = CreateFrame("Button", "M4", Mark_Menu, Mtemplate) + m5 = CreateFrame("Button", "M5", Mark_Menu, Mtemplate) + m6 = CreateFrame("Button", "M6", Mark_Menu, Mtemplate) + m7 = CreateFrame("Button", "M7", Mark_Menu, Mtemplate) + m8 = CreateFrame("Button", "M8", Mark_Menu, Mtemplate) + + MarkB = {m1,m2,m3,m4,m5,m6,m7,m8} + mark_menu:Hide() end @@ -40,6 +42,7 @@ end --Buttons creation function RM:CreateButtons() + if not mark_menu then return end for i = 1, 8 do RM:SetupButton(MarkB[i], 9 - i) end @@ -47,6 +50,7 @@ end --Setting/updating buttons' size function RM:FrameButtonsSize() + if not mark_menu then return end for i = 1, 8 do MarkB[i]:Size(E.db.sle.marks.size) end @@ -54,6 +58,7 @@ end --Setting growth direction for buttons function RM:FrameButtonsGrowth() + if not mark_menu then return end local db = E.db.sle.marks local size = db.size local width, height, x, y, anchor, point @@ -86,26 +91,51 @@ end --Visibility/enable check function RM:UpdateVisibility() + if not mark_menu then return end local inInstance, instanceType = IsInInstance() local db = E.db.sle.marks - if db.enabled then - if (inInstance and instanceType ~= "pvp") and db.showinside then - E.FrameLocks['Mark_Menu'] = true -- Because theyre thinking of adding battle pets to raids - mark_menu:Show() - elseif not inInstance and db.showinside then - E.FrameLocks['Mark_Menu'] = nil - mark_menu:Hide() - elseif not db.showinside then - E.FrameLocks['Mark_Menu'] = true - mark_menu:Show() + local show = false + if (inInstance and instanceType ~= "pvp") and db.showinside then + if db.target and UnitExists("target") then + show = true + elseif db.target and not UnitExists("target") then + show = false + else + show = true end - else + elseif not inInstance and db.showinside then + show = false + elseif not db.showinside then + if db.target and UnitExists("target") then + show = true + elseif db.target and not UnitExists("target") then + show = false + else + show = true + end + end + + if show then E.FrameLocks['Mark_Menu'] = true + mark_menu:Show() + else + E.FrameLocks['Mark_Menu'] = nil mark_menu:Hide() end end +function RM:Target() + if not mark_menu then return end + local db = E.db.sle.marks + if db.target then + self:RegisterEvent("PLAYER_TARGET_CHANGED", "UpdateVisibility"); + else + self:UnregisterEvent("PLAYER_TARGET_CHANGED"); + end +end + function RM:Backdrop() + if not mark_menu then return end if E.db.sle.marks.backdrop then mark_menu.backdrop:Show() else @@ -114,6 +144,7 @@ function RM:Backdrop() end function RM:Update() + if not mark_menu then return end RM:FrameButtonsSize() RM:FrameButtonsGrowth() RM:UpdateVisibility() @@ -121,10 +152,12 @@ function RM:Update() end function RM:Initialize() + if not E.private.sle.marks.marks then return end RM:CreateFrame() RM:Update() RM:CreateButtons() self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateVisibility"); + RM:Target() E:CreateMover(mark_menu, "MarkMover", "RM", nil, nil, nil, "ALL,S&L,S&L MISC") end diff --git a/ElvUI_SLE/modules/marks/options.lua b/ElvUI_SLE/modules/marks/options.lua index 9a15de0..e92d261 100755 --- a/ElvUI_SLE/modules/marks/options.lua +++ b/ElvUI_SLE/modules/marks/options.lua @@ -1,6 +1,6 @@ local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore -local RM = E:GetModule('RaidMarks') -local RF = E:GetModule('RaidFlares') +local RM = E:GetModule('SLE_RaidMarks') +local RF = E:GetModule('SLE_RaidFlares') local function configTable() --Main options group @@ -29,14 +29,14 @@ E.Options.args.sle.args.options.args.marks = { type = "toggle", name = L["Enable"], desc = L["Show/Hide raid marks."], - get = function(info) return E.db.sle.marks.enabled end, - set = function(info, value) E.db.sle.marks.enabled = value; RM:UpdateVisibility() end + get = function(info) return E.private.sle.marks.marks end, + set = function(info, value) E.private.sle.marks.marks = value; E:StaticPopup_Show("PRIVATE_RL") end }, backdrop = { order = 3, type = "toggle", name = L["Backdrop"], - disabled = function() return not E.db.sle.marks.enabled end, + disabled = function() return not E.private.sle.marks.marks end, get = function(info) return E.db.sle.marks.backdrop end, set = function(info, value) E.db.sle.marks.backdrop = value; RM:Backdrop() end }, @@ -45,7 +45,7 @@ E.Options.args.sle.args.options.args.marks = { type = 'execute', name = L['Restore Defaults'], desc = L["Reset these options to defaults"], - disabled = function() return not E.db.sle.marks.enabled end, + disabled = function() return not E.private.sle.marks.marks end, func = function() E:GetModule('SLE'):Reset(nil, nil, nil, nil, true) end, }, spacer = { @@ -58,26 +58,35 @@ E.Options.args.sle.args.options.args.marks = { type = "toggle", name = L["Show only in instances"], desc = L["Selecting this option will have the Raid Markers appear only while in a raid or dungeon."], - disabled = function() return not E.db.sle.marks.enabled end, + disabled = function() return not E.private.sle.marks.marks end, get = function(info) return E.db.sle.marks.showinside end, set = function(info, value) E.db.sle.marks.showinside = value; RM:UpdateVisibility() end }, - size = { + target = { order = 7, + type = "toggle", + name = L["Target Exists"], + desc = L["Selecting this option will have the Raid Markers appear only when you have a target."], + disabled = function() return not E.private.sle.marks.marks end, + get = function(info) return E.db.sle.marks.target end, + set = function(info, value) E.db.sle.marks.target = value; RM:Target(); RM:UpdateVisibility() end + }, + size = { + order = 8, type = "range", name = L['Size'], desc = L["Sets size of buttons"], - disabled = function() return not E.db.sle.marks.enabled end, + disabled = function() return not E.private.sle.marks.marks end, min = 15, max = 30, step = 1, get = function(info) return E.db.sle.marks.size end, set = function(info, value) E.db.sle.marks.size = value; RM:FrameButtonsGrowth(); RM:FrameButtonsSize() end, }, growth = { - order = 8, + order = 9, type = "select", name = L["Direction"], desc = L["Change the direction of buttons growth from the skull marker"], - disabled = function() return not E.db.sle.marks.enabled end, + disabled = function() return not E.private.sle.marks.marks end, get = function(info) return E.db.sle.marks.growth end, set = function(info, value) E.db.sle.marks.growth = value; RM:FrameButtonsGrowth() end, values = { @@ -104,14 +113,14 @@ E.Options.args.sle.args.options.args.marks = { type = "toggle", name = L["Enable"], desc = L["Show/Hide Raid Flares."], - get = function(info) return E.db.sle.flares.enabled end, - set = function(info, value) E.db.sle.flares.enabled = value; RF:UpdateVisibility() end + get = function(info) return E.private.sle.marks.flares end, + set = function(info, value) E.private.sle.marks.flares = value; E:StaticPopup_Show("PRIVATE_RL") end }, backdrop = { order = 3, type = "toggle", name = L["Backdrop"], - disabled = function() return not E.db.sle.flares.enabled end, + disabled = function() return not E.private.sle.marks.flares end, get = function(info) return E.db.sle.flares.backdrop end, set = function(info, value) E.db.sle.flares.backdrop = value; RF:Backdrop() end }, @@ -125,7 +134,7 @@ E.Options.args.sle.args.options.args.marks = { type = "toggle", name = L["Show only in instances"], desc = L["Selecting this option will have the Raid Flares appear only while in a raid or dungeon."], - disabled = function() return not E.db.sle.flares.enabled end, + disabled = function() return not E.private.sle.marks.flares end, get = function(info) return E.db.sle.flares.showinside end, set = function(info, value) E.db.sle.flares.showinside = value; RF:UpdateVisibility() end }, @@ -133,7 +142,7 @@ E.Options.args.sle.args.options.args.marks = { order = 7, type = "toggle", name = L["Show Tooltip"], - disabled = function() return not E.db.sle.flares.enabled end, + disabled = function() return not E.private.sle.marks.flares end, get = function(info) return E.db.sle.flares.tooltips end, set = function(info, value) E.db.sle.flares.tooltips = value; end }, @@ -142,7 +151,7 @@ E.Options.args.sle.args.options.args.marks = { type = "range", name = L['Size'], desc = L["Sets size of buttons"], - disabled = function() return not E.db.sle.flares.enabled end, + disabled = function() return not E.private.sle.marks.flares end, min = 15, max = 30, step = 1, get = function(info) return E.db.sle.flares.size end, set = function(info, value) E.db.sle.flares.size = value; RF:FrameButtonsGrowth(); RF:FrameButtonsSize() end, @@ -152,7 +161,7 @@ E.Options.args.sle.args.options.args.marks = { type = "select", name = L["Direction"], desc = L["Change the direction of buttons growth from the square marker"], - disabled = function() return not E.db.sle.flares.enabled end, + disabled = function() return not E.private.sle.marks.flares end, get = function(info) return E.db.sle.flares.growth end, set = function(info, value) E.db.sle.flares.growth = value; RF:FrameButtonsGrowth() end, values = { -- 1.7.9.5