Skip to content

Commit

Permalink
Add Gnomeregan to raids in SoD
Browse files Browse the repository at this point in the history
Formatted lua files also
  • Loading branch information
cloudbells committed Feb 14, 2024
1 parent dc2fed6 commit ff63ea7
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 67 deletions.
18 changes: 10 additions & 8 deletions Events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ 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)
if not hasRegistered then
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
Expand Down Expand Up @@ -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
54 changes: 29 additions & 25 deletions Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ 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
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

Expand Down Expand Up @@ -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)
Expand Down
15 changes: 9 additions & 6 deletions Instances.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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 = {
Expand All @@ -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",
Expand Down Expand Up @@ -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
49 changes: 24 additions & 25 deletions Interface/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions Util.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit ff63ea7

Please sign in to comment.