Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
funkydude committed Dec 11, 2020
1 parent 58785e9 commit e3d0760
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 56 deletions.
32 changes: 32 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,49 @@ globals = {
"C_Texture",
"C_Timer",
"C_UIWidgetManager",
"CombatLogGetCurrentEventInfo",
"CompleteQuest",
"CreateFrame",
"EnableAddOn",
"GetBattlefieldEstimatedWaitTime",
"GetBattlefieldPortExpiration",
"GetBattlefieldStatus",
"GetBattlefieldTimeWaited",
"GetBattlegroundInfo",
"GetInstanceInfo",
"GetItemCount",
"GetLocale",
"GetNumBattlegroundTypes",
"GetPOITextureCoords",
"GetQuestReward",
"GetRealmName",
"GetSpellInfo",
"GetTime",
"IsAltKeyDown",
"IsControlKeyDown",
"IsInGroup",
"IsQuestCompletable",
"IsShiftKeyDown",
"LoadAddOn",
"PlaySound",
"RaidNotice_AddMessage",
"RaidWarningFrame_OnEvent",
"ReloadUI",
"RequestBattlefieldScoreData",
"SendChatMessage",
"StopSound",
"strmatch",
"strsplit",
"UnitGUID",
"UnitHealth",
"UnitHealthMax",
"UnitName",
"UnitPosition",

-- WoW (global tables)
"RaidBossEmoteFrame",
"SlashCmdList",
"TimerTracker",
"UIParent",

-- WoW (global strings)
Expand Down
1 change: 0 additions & 1 deletion Capping.toc
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@
embeds.xml
locales.xml
modules.xml

13 changes: 6 additions & 7 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local addonName, mod = ...
local frame = CreateFrame("Frame", "CappingFrame", UIParent)
local L = mod.L

local format, type = format, type
local format, type = string.format, type
local db, core
local zoneIds = {}

Expand Down Expand Up @@ -63,9 +63,8 @@ do
return a.remaining < b.remaining
end
end
local tmp = {}
RearrangeBars = function()
wipe(tmp)
local tmp = {}
for bar in next, activeBars do
tmp[#tmp + 1] = bar
end
Expand Down Expand Up @@ -335,11 +334,11 @@ do
bar:Pause()
bar.candyBarBar:SetValue(hp)
bar.candyBarDuration:SetFormattedText("%.1f%%", hp)
bar:Set("capping:customchat", function(bar)
bar:Set("capping:customchat", function(candyBar)
if tbl[1] ~= tbl[2] then
return tbl[2] .."/".. tbl[1] .." - ".. bar.candyBarDuration:GetText()
return tbl[2] .."/".. tbl[1] .." - ".. candyBar.candyBarDuration:GetText()
else
return tbl[1] .." - ".. bar.candyBarDuration:GetText()
return tbl[1] .." - ".. candyBar.candyBarDuration:GetText()
end
end)
bar:Set("capping:hpdata", tbl)
Expand Down Expand Up @@ -409,7 +408,7 @@ do
end

local GetDoubleStatusBarWidgetVisualizationInfo = C_UIWidgetManager.GetDoubleStatusBarWidgetVisualizationInfo
local ceil, floor = ceil, floor
local ceil, floor = math.ceil, math.floor
local function ScorePredictor(widgetInfo)
if widgetInfo and (widgetInfo.widgetID == 1671 or widgetInfo.widgetID == 2074) then -- The 1671 widget is used for all BGs with score predictors, but DG uses 2074
local dataTbl = GetDoubleStatusBarWidgetVisualizationInfo(widgetInfo.widgetID)
Expand Down
4 changes: 2 additions & 2 deletions Modules/AlteracValley.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ do
end

local NewTicker = C_Timer.NewTicker
local hereFromTheStart, hasData, hasPrinted = true, true, false
local hereFromTheStart, hasData = true, true
local stopTimer = nil
local function allow() hereFromTheStart = false end
local function stop() hereFromTheStart = true hasData = true stopTimer = nil end
Expand Down Expand Up @@ -111,7 +111,7 @@ do
for bar in next, CappingFrame.bars do
local poiId = bar:Get("capping:poiid")
if poiId then
str = format("%s%d-%d~", str, poiId, floor(bar.remaining))
str = string.format("%s%d-%d~", str, poiId, math.floor(bar.remaining))
end
end

Expand Down
4 changes: 2 additions & 2 deletions Modules/ArathiBasin.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

local mod, L
local mod
do
local _, core = ...
mod, L = core:NewMod()
mod = core:NewMod()
end

local instanceIdToMapId = {
Expand Down
4 changes: 2 additions & 2 deletions Modules/DeepwindGorge.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

local mod, L
local mod
do
local _, core = ...
mod, L = core:NewMod()
mod = core:NewMod()
end

function mod:EnterZone()
Expand Down
6 changes: 2 additions & 4 deletions Modules/EyeOfTheStorm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ do
local function StartNextGravTimer()
local _, _, _, _, _, _, _, id = GetInstanceInfo()
if id == 566 then -- Check the game isn't over
local name = GetSpellInfo(44224) -- Gravity Lapse
local icon = GetSpellTexture(44224)
local name, _, icon = GetSpellInfo(44224) -- Gravity Lapse
mod:StartBar(name, 55, icon, "colorOther")
ticker1 = NewTicker(55, StartNextGravTimer, 1) -- Compensate for being dead (you don't get the message)
ticker2 = NewTicker(50, PrintExtraMessage, 1)
Expand All @@ -43,8 +42,7 @@ do
if not extraMsg then
extraMsg = msg:gsub("1", "")
end
local name = GetSpellInfo(44224) -- Gravity Lapse
local icon = GetSpellTexture(44224)
local name, _, icon = GetSpellInfo(44224) -- Gravity Lapse
self:StartBar(name, 15, icon, "colorOther")
self:Timer(15, StartNextGravTimer)
self:Timer(10, PrintExtraMessage)
Expand Down
4 changes: 2 additions & 2 deletions Modules/Gilneas.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

local mod, L
local mod
do
local _, core = ...
mod, L = core:NewMod()
mod = core:NewMod()
end

function mod:EnterZone()
Expand Down
28 changes: 13 additions & 15 deletions Modules/IsleOfConquest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ do
local function SendIoCGates()
timer = nil
if IsInGroup(2) then -- We've not just ragequit
local msg = format(
local msg = string.format(
"195494:%d:195495:%d:195496:%d:195698:%d:195699:%d:195700:%d",
hordeGates["195494"], hordeGates["195495"], hordeGates["195496"],
allianceGates["195698"], allianceGates["195699"], allianceGates["195700"]
Expand Down Expand Up @@ -184,33 +184,31 @@ do
allianceGates["195699"] = aGate2
allianceGates["195700"] = aGate3

local bar = hordeGateBar
if bar then
if hordeGateBar then
local hp = lowestHordeHp / baseGateHealth * 100
if hp < 1 then
bar:Stop()
hordeGateBar:Stop()
else
bar.candyBarBar:SetValue(hp)
bar.candyBarDuration:SetFormattedText("%.1f%%", hp)
hordeGateBar.candyBarBar:SetValue(hp)
hordeGateBar.candyBarDuration:SetFormattedText("%.1f%%", hp)
if lowestHordeHp ~= baseGateHealth then
local gate = lowestHordeHp == hGate1 and h1 or lowestHordeHp == hGate2 and h2 or h3
bar.candyBarLabel:SetFormattedText(L.gatePosition, L.hordeGate, gate == h1 and L.front or gate == h2 and L.west or L.east)
bar:Set("capping:englishprint", englishNames[gate])
hordeGateBar.candyBarLabel:SetFormattedText(L.gatePosition, L.hordeGate, gate == h1 and L.front or gate == h2 and L.west or L.east)
hordeGateBar:Set("capping:englishprint", englishNames[gate])
end
end
end
local bar = allianceGateBar
if bar then
if allianceGateBar then
local hp = lowestAllianceHp / baseGateHealth * 100
if hp < 1 then
bar:Stop()
allianceGateBar:Stop()
else
bar.candyBarBar:SetValue(hp)
bar.candyBarDuration:SetFormattedText("%.1f%%", hp)
allianceGateBar.candyBarBar:SetValue(hp)
allianceGateBar.candyBarDuration:SetFormattedText("%.1f%%", hp)
if lowestAllianceHp ~= baseGateHealth then
local gate = lowestAllianceHp == aGate1 and a1 or lowestAllianceHp == aGate2 and a2 or a3
bar.candyBarLabel:SetFormattedText(L.gatePosition, L.allianceGate, gate == a1 and L.front or gate == a2 and L.west or L.east)
bar:Set("capping:englishprint", englishNames[gate])
allianceGateBar.candyBarLabel:SetFormattedText(L.gatePosition, L.allianceGate, gate == a1 and L.front or gate == a2 and L.west or L.east)
allianceGateBar:Set("capping:englishprint", englishNames[gate])
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions Modules/QueueTimers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end
Timer.lua line 2
TIMER_TYPE_PVP = 1;
TIMER_TYPE_CHALLENGE_MODE = 2;
TIMER_TYPE_PLAYER_COUNTDOWN = 3;
TIMER_TYPE_PLAYER_COUNTDOWN = 3;
]]
function mod:START_TIMER(timerType, timeSeconds)
if timerType == 3 then return end
Expand All @@ -20,7 +20,7 @@ function mod:START_TIMER(timerType, timeSeconds)

local bar = self:GetBar(L.battleBegins)
if not bar or timeSeconds > bar.remaining+1 or timeSeconds < bar.remaining-1 then -- Don't restart bars for subtle changes +/- 1s
bar = self:StartBar(L.battleBegins, timeSeconds, 618859, "colorOther") -- 618859 = Interface/Icons/achievement_challengemode_platinum
self:StartBar(L.battleBegins, timeSeconds, 618859, "colorOther") -- 618859 = Interface/Icons/achievement_challengemode_platinum
end
end
mod:RegisterEvent("START_TIMER")
Expand All @@ -41,7 +41,7 @@ do -- estimated wait timer and port timer
local status, mapName, _, _, _, queueType, gameType = GetBattlefieldStatus(queueId)

if queueType == "ARENASKIRMISH" then
mapName = format("%s (%d)", ARENA, queueId) -- No size or name distinction given for casual arena 2v2/3v3, separate them manually. Messy :(
mapName = string.format("%s (%d)", ARENA, queueId) -- No size or name distinction given for casual arena 2v2/3v3, separate them manually. Messy :(
end

if status == "confirm" then -- BG has popped, time until cancelled
Expand Down
22 changes: 10 additions & 12 deletions Modules/Wintergrasp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ local poiWallNames = { -- wall section locations
[6056] = L.southGate, [6027] = L.mainEntrance, -- front gate and fortress door
}
local baseTowerHealth, mainEntranceHealth, wallHealth, defenseTowerHealth = 130000, 91000, 301000, 81000
local westHp, midHp, eastHp = baseTowerHealth, baseTowerHealth, baseTowerHealth
local towers, onDemandTrackers = {}, {}
local towerNames = {
["308062"] = L.westTower, -- Shadowsight Tower (West)
Expand Down Expand Up @@ -70,11 +69,11 @@ local function StartNewBar(self, name, english, icon)
bar:Pause()
bar.candyBarBar:SetValue(100)
bar.candyBarDuration:SetText("100%")
bar:Set("capping:customchat", function(bar)
bar:Set("capping:customchat", function(candyBar)
if name ~= english then
return english .."/".. name .." - ".. bar.candyBarDuration:GetText()
return english .."/".. name .." - ".. candyBar.candyBarDuration:GetText()
else
return name .." - ".. bar.candyBarDuration:GetText()
return name .." - ".. candyBar.candyBarDuration:GetText()
end
end)
return bar
Expand Down Expand Up @@ -179,11 +178,11 @@ do
local textureIndex = tbl.textureIndex
if tbl and ((ti and ti ~= textureIndex) or (not ti and poiWallNames[POI])) then
if intactTextures[ti] and damaged[textureIndex] then -- intact before, damaged now
local msg = format(L.damaged, poiWallNames[POI])
local msg = string.format(L.damaged, poiWallNames[POI])
RaidWarningFrame_OnEvent(RaidBossEmoteFrame, "CHAT_MSG_RAID_WARNING", msg)
print(msg)
elseif damaged[ti] and destroyed[textureIndex] then -- damaged before, destroyed now
local msg = format(L.destroyed, poiWallNames[POI])
local msg = string.format(L.destroyed, poiWallNames[POI])
RaidWarningFrame_OnEvent(RaidBossEmoteFrame, "CHAT_MSG_RAID_WARNING", msg)
print(msg)
end
Expand Down Expand Up @@ -212,11 +211,11 @@ do
bar:Pause()
bar.candyBarBar:SetValue(100)
bar.candyBarDuration:SetText("100%")
bar:Set("capping:customchat", function(bar)
bar:Set("capping:customchat", function(candyBar)
if towerName ~= towerNamesEnglish[towerId] then
return towerNamesEnglish[towerId] .. "/".. towerName .." - ".. bar.candyBarDuration:GetText()
return towerNamesEnglish[towerId] .. "/".. towerName .." - ".. candyBar.candyBarDuration:GetText()
else
return towerName .." - ".. bar.candyBarDuration:GetText()
return towerName .." - ".. candyBar.candyBarDuration:GetText()
end
end)
end
Expand Down Expand Up @@ -251,7 +250,7 @@ do
local function SendWGTowers()
timer = nil
if IsInGroup(2) then -- We've not just ragequit
local msg1 = format(
local msg1 = string.format(
"w:%d:m:%d:e:%d:ne:%d:se:%d:sw:%d:nw:%d",
towers["308062"], towers["308013"], towers["307935"], -- West, Mid, East
onDemandTrackers["307877"] or defenseTowerHealth, -- North-East
Expand All @@ -263,7 +262,7 @@ do
for k, v in next, onDemandTrackers do
if not defensiveTowers[k] then
k = k:sub(3) -- Trim first 2 numbers
msg2 = format("%s%s-%d~", msg2, k, v)
msg2 = string.format("%s%s-%d~", msg2, k, v)
end
end
if msg2 ~= "z:" and string.len(msg2) < 251 then
Expand Down Expand Up @@ -407,7 +406,6 @@ do
end
end

westHp, midHp, eastHp = baseTowerHealth, baseTowerHealth, baseTowerHealth
towers = {
["308062"] = baseTowerHealth, -- Shadowsight Tower (West)
["308013"] = baseTowerHealth, -- Winter's Edge Tower (Mid)
Expand Down
2 changes: 1 addition & 1 deletion Options/Locales/itIT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local _, mod = ...
local L = mod.L

-- Options
--L.general = "General"
L.general = "General"
--L.test = "Test"
--L.lock = "Lock"
--L.barIcon = "Bar Icon"
Expand Down
2 changes: 1 addition & 1 deletion Options/Locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ L.altClick = "Alt + клик"
L.sayChat = "Общий (/s) чат"
L.raidChat = "Группой чат"
L.clickableBars = "Полоски, реагирующие на клик"
L.loudQueue = "Звук очереди" -- loud, посмотреть на проде // spellcheck on live
L.loudQueue = "Звук очереди" -- loud, посмотреть на проде // spellcheck on live
L.loudQueueDesc = "Когда наступит очередь, звуковое оповещение будет принудительно направлено через основной звуковой канал" -- посмотреть на проде // spellcheck on live // "When the queue is ready the sound notification will be forced to play over the 'Master' sound channel."
1 change: 0 additions & 1 deletion Options/embeds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
<Include file="Libs\AceDBOptions-3.0\AceDBOptions-3.0.xml"/>

</Ui>

1 change: 0 additions & 1 deletion Options/locales.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@
<Script file="Locales\itIT.lua"/>

</Ui>

1 change: 0 additions & 1 deletion embeds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
@end-non-debug@-->

</Ui>

1 change: 0 additions & 1 deletion locales.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@
<Script file="Locales\itIT.lua"/>

</Ui>

0 comments on commit e3d0760

Please sign in to comment.