diff --git a/Events.lua b/Events.lua index 39d7bfd..02e357b 100644 --- a/Events.lua +++ b/Events.lua @@ -7,7 +7,9 @@ local callbacks = {} local wowEvents, events -- Called when any registered WoW event fires. -function ns:OnEvent(event, ...) wowEvents[event](self, ...) end +function ns:OnEvent(event, ...) + wowEvents[event](self, ...) +end -- Registers all events. function ns:RegisterAllEvents(_eventFrame) @@ -15,11 +17,7 @@ function ns:RegisterAllEvents(_eventFrame) eventFrame = _eventFrame eventFrame:SetScript("OnEvent", ns.OnEvent) events = {} - wowEvents = { - ADDON_LOADED = ns.OnAddonLoaded, - PLAYER_ENTERING_WORLD = ns.OnPlayerEnteringWorld, - RAID_INSTANCE_WELCOME = ns.OnRaidInstanceWelcome - } + wowEvents = {ADDON_LOADED = ns.OnAddonLoaded, PLAYER_ENTERING_WORLD = ns.OnPlayerEnteringWorld, RAID_INSTANCE_WELCOME = ns.OnRaidInstanceWelcome} for event, callback in pairs(wowEvents) do eventFrame:RegisterEvent(event, callback) end @@ -49,11 +47,15 @@ function ns:RegisterEvent(event, callback) end -- Unregister for the given event. -function ns:UnregisterEvent(event) callbacks[event] = nil end +function ns:UnregisterEvent(event) + callbacks[event] = nil +end -- Call this to fire an event. function ns:Fire(event, ...) if callbacks[event] and #callbacks[event] > 0 then - for i = 1, #callbacks[event] do callbacks[event][i](self, ...) end + for i = 1, #callbacks[event] do + callbacks[event][i](self, ...) + end end end diff --git a/Init.lua b/Init.lua index 6db0fc1..775e356 100644 --- a/Init.lua +++ b/Init.lua @@ -12,8 +12,7 @@ local function ToggleMinimapButton() ALCOptions.minimapTable.hide = not ALCOptions.minimapTable.hide if ALCOptions.minimapTable.hide then minimapButton:Hide("AutoLoggerClassic") - print( - "|cFFFFFF00AutoLoggerClassic:|r Minimap button hidden. Type /alc minimap to show it again.") + print("|cFFFFFF00AutoLoggerClassic:|r Minimap button hidden. Type /alc minimap to show it again.") else minimapButton:Show("AutoLoggerClassic") end @@ -21,27 +20,28 @@ end -- Initializes the minimap button. local function InitMinimapButton() - local obj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject( - "AutoLoggerClassic", { - type = "launcher", - text = "AutoLoggerClassic", - icon = "Interface/ICONS/Trade_Engineering", - OnClick = function(self, button) - if button == "LeftButton" then - ns:ToggleFrame() - elseif button == "RightButton" then - ToggleMinimapButton() - end - end, - OnEnter = function(self) - GameTooltip:SetOwner(self, "ANCHOR_LEFT") - GameTooltip:AddLine("|cFFFFFFFFAutoLoggerClassic|r") - GameTooltip:AddLine("Left click to open options.") - GameTooltip:AddLine("Right click to hide this minimap button.") - GameTooltip:Show() - end, - OnLeave = function(self) GameTooltip:Hide() end - }) + local obj = LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject("AutoLoggerClassic", { + type = "launcher", + text = "AutoLoggerClassic", + icon = "Interface/ICONS/Trade_Engineering", + OnClick = function(self, button) + if button == "LeftButton" then + ns:ToggleFrame() + elseif button == "RightButton" then + ToggleMinimapButton() + end + end, + OnEnter = function(self) + GameTooltip:SetOwner(self, "ANCHOR_LEFT") + GameTooltip:AddLine("|cFFFFFFFFAutoLoggerClassic|r") + GameTooltip:AddLine("Left click to open options.") + GameTooltip:AddLine("Right click to hide this minimap button.") + GameTooltip:Show() + end, + OnLeave = function(self) + GameTooltip:Hide() + end, + }) minimapButton:Register("AutoLoggerClassic", obj, ALCOptions.minimapTable) end @@ -87,10 +87,14 @@ function ns:ToggleLogging() end -- Called when entering a raid. -function ns:OnRaidInstanceWelcome() ns:ToggleLogging() end +function ns:OnRaidInstanceWelcome() + ns:ToggleLogging() +end -- Called when most game data is available. -function ns:OnPlayerEnteringWorld() ns:ToggleLogging() end +function ns:OnPlayerEnteringWorld() + ns:ToggleLogging() +end -- Called on ADDON_LOADED. function ns:OnAddonLoaded(addonName) diff --git a/Instances.lua b/Instances.lua index fffc786..e905174 100644 --- a/Instances.lua +++ b/Instances.lua @@ -8,9 +8,12 @@ if ns:IsClassic() then [409] = "Molten Core", [533] = "Naxxramas", [249] = "Onyxia's Lair", - [309] = "Zul'Gurub" + [309] = "Zul'Gurub", } - if ns:IsSoD() then ns.RAIDS[48] = "Blackfathom Deeps" end + if ns:IsSoD() then + ns.RAIDS[48] = "Blackfathom Deeps" + ns.RAIDS[90] = "Gnomeregan" + end elseif ns:IsTBC() then ns.RAIDS = { [509] = "AQ20", @@ -28,7 +31,7 @@ elseif ns:IsTBC() then [534] = "Battle for Mount Hyjal", [564] = "Black Temple", [568] = "Zul'Aman", - [580] = "Sunwell Plateau" + [580] = "Sunwell Plateau", } ns.DUNGEONS = { [269] = "The Black Morass", @@ -46,7 +49,7 @@ elseif ns:IsTBC() then [557] = "Mana-Tombs", [558] = "Auchenai Crypts", [560] = "Old Hillsbrad Foothills", - [585] = "Magisters' Terrace" + [585] = "Magisters' Terrace", } elseif ns:IsWOTLK() then ns.RAIDS = { @@ -72,7 +75,7 @@ elseif ns:IsWOTLK() then [649] = "Trial of the Crusader", [249] = "Onyxia's Lair", [631] = "Icecrown Citadel", - [724] = "Ruby Sanctum" + [724] = "Ruby Sanctum", } ns.DUNGEONS = { [269] = "The Black Morass", @@ -106,6 +109,6 @@ elseif ns:IsWOTLK() then [632] = "The Forge of Souls", [650] = "Trial of the Champion", [658] = "Pit of Saron", - [668] = "Halls of Reflection" + [668] = "Halls of Reflection", } end diff --git a/Interface/Main.lua b/Interface/Main.lua index e48f006..7c86b21 100644 --- a/Interface/Main.lua +++ b/Interface/Main.lua @@ -24,25 +24,34 @@ end -- Called when a check button is clicked. local function CheckButton_OnClick(self) - ALCOptions.instances[self.instance] = - not ALCOptions.instances[self.instance] + ALCOptions.instances[self.instance] = not ALCOptions.instances[self.instance] ns:ToggleLogging() end -- Called when the close button is clicked. -local function CloseButton_OnClick() ns:ToggleFrame() end +local function CloseButton_OnClick() + ns:ToggleFrame() +end -- Called when the mouse is down on the frame. -local function MainFrame_OnMouseDown(self) mainFrame:StartMoving() end +local function MainFrame_OnMouseDown(self) + mainFrame:StartMoving() +end -- Called when the mouse has been released from the frame. -local function MainFrame_OnMouseUp(self) mainFrame:StopMovingOrSizing() end +local function MainFrame_OnMouseUp(self) + mainFrame:StopMovingOrSizing() +end -- Called when the main frame hides. -local function MainFrame_OnHide(self) PlaySound(SOUNDKIT.IG_MAINMENU_CLOSE) end +local function MainFrame_OnHide(self) + PlaySound(SOUNDKIT.IG_MAINMENU_CLOSE) +end -- Called when the main frame shows. -local function MainFrame_OnShow(self) PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB) end +local function MainFrame_OnShow(self) + PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB) +end -- Initializes all checkboxes. local function InitCheckButtons() @@ -54,10 +63,7 @@ local function InitCheckButtons() local index = 1 for instanceID, instanceName in pairs(instanceTable) do -- Checkbuttons. - local checkButton = CUI:CreateCheckButton(mainFrame, - "AutoLoggerClassicCheckButton" .. - index, - {CheckButton_OnClick}, + local checkButton = CUI:CreateCheckButton(mainFrame, "AutoLoggerClassicCheckButton" .. index, {CheckButton_OnClick}, "Interface/Addons/AutoLoggerClassic/Media/CheckMark") local x = X_START + X_SPACING * ((index - 1) % BUTTONS_PER_ROW) local y = yStart - Y_SPACING * math.ceil(index / BUTTONS_PER_ROW) @@ -66,8 +72,7 @@ local function InitCheckButtons() checkButton:SetChecked(ALCOptions.instances[instanceID]) buttons[#buttons + 1] = checkButton -- Strings. - local string = mainFrame:CreateFontString(nil, "ARTWORK", - fontInstance:GetName()) + local string = mainFrame:CreateFontString(nil, "ARTWORK", fontInstance:GetName()) string:SetPoint("LEFT", checkButton, "RIGHT", 5, 0) string:SetText(instanceName) index = index + 1 @@ -77,17 +82,14 @@ local function InitCheckButtons() end do - local raidString = mainFrame:CreateFontString(nil, "ARTWORK", - CUI:GetFontBig():GetName()) + local raidString = mainFrame:CreateFontString(nil, "ARTWORK", CUI:GetFontBig():GetName()) raidString:SetText("RAIDS") raidString:SetPoint("TOPLEFT", 3, Y_START - 20) placeButtons(ns.RAIDS, Y_START - 20) end if (ns.DUNGEONS) then - local dungeonString = mainFrame:CreateFontString(nil, "ARTWORK", - CUI:GetFontBig() - :GetName()) + local dungeonString = mainFrame:CreateFontString(nil, "ARTWORK", CUI:GetFontBig():GetName()) dungeonString:SetText("DUNGEONS") dungeonString:SetPoint("TOPLEFT", 3, yNext - DUNGEON_RAID_SPACING) placeButtons(ns.DUNGEONS, yNext - DUNGEON_RAID_SPACING) @@ -112,7 +114,7 @@ function ns:InitMainFrame() if ns:IsClassic() then if ns:IsSoD() then - mainFrame:SetSize(540, 112) + mainFrame:SetSize(556, 112) else mainFrame:SetSize(540, 112) end @@ -121,8 +123,7 @@ function ns:InitMainFrame() end -- Title mainFrame. - local titleFrame = CreateFrame("Frame", "AutoLoggerClassicTitleFrame", - mainFrame) + local titleFrame = CreateFrame("Frame", "AutoLoggerClassicTitleFrame", mainFrame) titleFrame:SetPoint("TOPLEFT") titleFrame:SetPoint("TOPRIGHT") titleFrame:SetSize(1, 20) @@ -132,15 +133,13 @@ function ns:InitMainFrame() fontInstance:SetJustifyH("LEFT") -- Title text. - local title = titleFrame:CreateFontString(nil, "BACKGROUND", - fontInstance:GetName()) + local title = titleFrame:CreateFontString(nil, "BACKGROUND", fontInstance:GetName()) title:SetText("AutoLoggerClassic") title:SetPoint("LEFT", 4, 0) titleFrame.title = title -- Close button. - local closeButton = CreateFrame("Button", "AutoLoggerClassicCloseButton", - titleFrame) + local closeButton = CreateFrame("Button", "AutoLoggerClassicCloseButton", titleFrame) CUI:ApplyTemplate(closeButton, CUI.templates.HighlightFrameTemplate) CUI:ApplyTemplate(closeButton, CUI.templates.PushableFrameTemplate) CUI:ApplyTemplate(closeButton, CUI.templates.BorderedFrameTemplate) diff --git a/Util.lua b/Util.lua index 245c0a4..22d9571 100644 --- a/Util.lua +++ b/Util.lua @@ -1,13 +1,19 @@ local _, ns = ... -- Returns true if the game version is classic, false otherwise. -function ns:IsClassic() return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC end +function ns:IsClassic() + return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC +end -- Returns true if the game version is TBC, false otherwise. -function ns:IsTBC() return WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC end +function ns:IsTBC() + return WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC +end -- Returns true if the game version is WotLK, false otherwise. -function ns:IsWOTLK() return WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC end +function ns:IsWOTLK() + return WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC +end -- Returns true if the game version is Season of Dicovery. function ns:IsSoD()