Skip to content

Commit

Permalink
Merge pull request #15 from prowley/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
prowley authored Sep 26, 2020
2 parents e292274 + 81e5664 commit d11ad3f
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 85 deletions.
2 changes: 1 addition & 1 deletion SteaSummon.toc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Libs\embeds.xml

debug.lua
util.lua
wordlist.lua
buffs.lua
settings.lua
optionsgui.lua
raid.lua
Expand Down
102 changes: 102 additions & 0 deletions buffs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
local addonName, addonData = ...

City = {
"WarChief's Blessing",
"Rallying Cry of the Dragonslayer",
"Spirit of Zandalar",
}

DarkMoon = {
"Sayge's Dark Fortune of Damage",
"Sayge's Dark Fortune of Resistance",
"Sayge's Dark Fortune of Armor",
"Sayge's Dark Fortune of Intelligence",
"Sayge's Dark Fortune of Spirit",
"Sayge's Dark Fortune of Stamina",
"Sayge's Dark Fortune of Strength",
"Sayge's Dark Fortune of Agility",
}

DireMaul = {
"Mol'dar's Moxie",
"Fengus' Ferocity",
"Slip'kik's Savvy",
}

Felwood = {
"Songflower Serenade",
"Windblossom Berries",
"Whipper Root Tuber",
"Night Dragon's Breath",
}

BlastedLands = {
"R.O.I.D.S.",
"Ground Scorpak Assay",
"Lung Juice Cocktail",
"Cerebral Cortex Compound",
"Gizzard Gum",
}

Winterspring = {
"Juju Might",
"Juju Power",
"Juju Flurry",
"Juju Gulie",
"Juju Escape",
"Juju Chill",
"Juju Ember"
}

TimeSensitive = {
City,
DarkMoon,
DireMaul,
Felwood
}

buffs = {
buffs = {},

init = function(self)
addonData.debug:registerCategory("buffs")
-- build the buff table
for _, set in pairs(TimeSensitive) do
for _, b in pairs(set) do
db("registering buff", b)
self.buffs[b] = 1
end
end
end,

report = function(self, player)
local out, index = {}, 1

while true do
local name, rank, icon, count, debuffType, duration,
expirationTime, unitCaster, isStealable,
shouldConsolidate, spellId
= UnitBuff(player, index)

index = index + 1

if name == nil then
break
end

db("buffs", player, "has buff", name)
if self.buffs[name] then
db("buffs", name, "is of interest")
out[index] = {name, icon, (GetTime() - expirationTime) / 60}
end
end

if #out == 0 then
out = nil
end

return out
end,
}

addonData.buffs = buffs
16 changes: 11 additions & 5 deletions chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local chat = {
return
end

db("testing chat for keywords")
db("chat", "testing chat for keywords")

if player == me then
if msg and msg:find("!SS") == 1 then
Expand All @@ -25,7 +25,7 @@ local chat = {
if args == nil then args = "" end
cmd = string.lower(cmd)

db("Received command : " .. cmd .. " " .. args)
db("chat","Received command : " .. cmd .. " " .. args)
if cmd == "list" then
local waitlist = addonData.summon:getWaiting()
cprint("Summon wait list")
Expand Down Expand Up @@ -61,10 +61,16 @@ local chat = {
if msg and addonData.settings:findSummonWord(msg) then
-- someone wants a summon
name, server = strsplit("-", servername)
db("adding ", name, "to summon list")
db("chat","adding ", name, "to summon list")

addonData.summon:addWaiting(name)
end
if IsInGroup(player) or player == me then
addonData.summon:addWaiting(name)
end

if event == "CHAT_MSG_WHISPER" then

end
end
end,

raid = function(self, msg, player)
Expand Down
108 changes: 79 additions & 29 deletions debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
-- later, it might be about directing that output to another frame

-- categories can be dot delimited into sub categories e.g. "example.subexample"
-- so that any request to view category example will also list example.subexample (example need never actually be logged
-- and probably shouldn't be because it would be impossible to just view the category example alone)
-- so that any request to view category example will also list example.subexample (example need never actually be
-- logged or displayed)
-- when registering a child category before its parent, all ancestors are also registered with the same log flag
-- if you want to create gaps in what is logged in a category tree, take care with how you register categories
-- e.g.
-- registerCategory("example.subexample") -- example and subexample logged
-- registerCategory("example.subexample.notofinterest", false) -- example.subexample.notofinterest not logged
-- registerCategory("example.subexample.notofinterest.butthisis") example.subexample.notofinterest.butthisis logged

local addonName, addonData = ...
local aboveLogLevel = 1000001
Expand All @@ -18,17 +24,26 @@ local debug = {
l_logAbove = -1,
l_printAbove = -1,
l_printBelow = aboveLogLevel,
chat = true,
chatcat = nil,
chatFlag = true,
chatCats = {},
category = {},
categoryLog = {},
categoryRev = {},
categoryChildren = {},

init = function(self)
if not SteaDEBUG or not SteaDEBUG.log then
self:reset()
end

-- wow does auto placement of moveable frames, cool
-- what is not cool is that this placement/sizing happens at some undetermined time after creation
-- and specifically leaves all the sizing for children at the point of creation
-- when the window was a different size. I don't know of any event that can be listened to for this.
-- So.. we have to build the main frame here without content,
-- later when we come to want to see it, build all the children, from that point on
-- we can keep things properly sized - see the buildContent() for the rest
--- if anyone knows a better or simpler fix for this, please let me know

local f = CreateFrame("Frame", "DBFrame", UIParent, "AnimatedShineTemplate")
f:SetPoint("CENTER")
f:SetSize(300, 250)
Expand Down Expand Up @@ -64,14 +79,6 @@ local debug = {
f:SetResizable(true)
f:SetMinResize(150, 100)
f:Hide()

-- wow does auto placement of a moveable frames, cool
-- what is not cool is that this happens at some undetermined time after creation
-- and specifically leaves all the sizing for children at the point of creation
-- when the window was a different size. So.. we have to build the main frame here,
-- later when we come to want to see it, build all the children, from that point on
-- we can keep things properly sized - see the buildContent() for the rest
--- if anyone knows a better, simpler fix for this, please let me know
end,

buildContent = function(self)
Expand Down Expand Up @@ -181,19 +188,38 @@ local debug = {
end
end,

chat = function(self, chatBool, cat)
debug.chat = chatBool
chatCatSwitch = function(self, chatBool)
self.chatFlag = chatBool

if debug.chat then
db(debug.loglevel, "Debug out to chat on")
if self.chatFlag then
local cats = "{"
local first = true
for k,_ in pairs(self.chatCats) do
if not first then
cats = cats .. ", "
end
first = false
cats = cats .. k
end
cats = cats .. "}"
db(self.loglevel, "Debug out to chat is set to ON for categories: ", cats)
else
db(debug.loglevel, "Debug out to chat off")
db(self.loglevel, "Debug out to chat is set to OFF - why is this here?")
end
end,

if cat ~= nil then
db(debug.loglevel, "category", chat, "set as chat output")
debug.chatcat = cat
chatCat = function(self, cat)
ret = false
if self.category[cat] then
db(self.loglevel, "Added debug category", cat, "to debug out")
self.chatCats[cat] = 1
for k,_ in pairs(self.categoryChildren[cat]) do
self:chatCat(k)
end
else
db(self.loglevel, "Debug category", cat, "has not been registered")
end
return ret
end,

printAbove = function(self, above)
Expand All @@ -218,24 +244,47 @@ local debug = {

registerCategory = function(self, category_in, log)
local cat = category_in
local child = nil
local last = nil

while not self.category[cat] do
self.categoryChildren[cat] = {}
self.category[cat] = 1
table.insert(self.categoryRev, cat)
if log == nil or log then
self.categoryLog[cat] = 1
end
db(self.loglevel, "registered debug category:", cat)

-- sub cats
child = cat
doti = cat.find(cat, "%.[^%.]*$") -- last dot

if doti ~= nil then
cat = string.sub(cat, 1, doti - 1)
end

local parent
if cat ~= child then
parent = cat
end

-- link parent
if parent and self.categoryChildren[parent] then
db(self.loglevel, "added child:", child,"for", parent)
self.categoryChildren[parent][child] = 1
end

-- find children
-- the parent may be created after the first child
-- if this is the parent node of a child we created in last loop it won't be linked yet
if last ~= nil then
self.categoryChildren[child][last] = 1
db(self.loglevel, "added child:", last,"for", child)
end

last = child
end
table.sort(self.categoryRev)
end
end,
}

-- global
Expand All @@ -247,7 +296,7 @@ function db(target, ...)
if type(target) == "number" then
-- chat
if target > debug.l_printAbove and target < debug.l_printBelow then
if debug.chat then
if debug.chatFlag then
prePrint = target
end
end
Expand All @@ -258,13 +307,14 @@ function db(target, ...)
end
else -- category string
-- chat
if debug.chatcat ~= nil then
top = string.substr(target, 1, #debug.chatcat)
if debug.chat and top == debug.chatcat then
if #debug.chatCats then
if debug.chatFlag and debug.chatCats[target] then
prePrint = target
end
else
prePrint = target
if debug.chatFlag then
prePrint = target
end
end

-- logging
Expand Down
14 changes: 11 additions & 3 deletions events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function start()
call["CHAT_MSG_RAID_LEADER"] = addonData.chat.callback
call["CHAT_MSG_ADDON"] = addonData.gossip.callback
call["CHAT_MSG_SAY"] = addonData.chat.callback
call["CHAT_MSG_WHISPER"] = addonData.chat.callback
call["PARTY_LEADER_CHANGED"] = addonData.gossip.callback
call["GROUP_ROSTER_UPDATE"] = addonData.raid.callback
call["RAID_ROSTER_UPDATE"] = addonData.raid.callback
Expand Down Expand Up @@ -65,9 +66,9 @@ function loaded(self, event, ...)
addonData.debug:printBelow(addonData.debug.loglevel + 1) -- I want to see the debug module debug
addonData.debug:logBelow(addonData.debug.loglevel + 1) -- also want it logged

addonData.debug:registerCategory("event")
db("event", "------------- NEW SESSION -------------")
db("event", "loaded", event, ...)
addonData.debug:registerCategory("event.event")
db("event.event", "------------- NEW SESSION -------------")
db("event.event", "loaded", event, ...)

-- init modules
addonData.settings:init()
Expand All @@ -78,6 +79,13 @@ function loaded(self, event, ...)
addonData.chat:init()
addonData.monitor:init()
addonData.util:init()
addonData.buffs:init()

-- wait to set up debug categories until all categories are registered
-- otherwise the category or its children may not be registered for chat debug messages
addonData.debug:chatCat("raid")
addonData.debug:chatCat("buffs")
addonData.debug:chatCatSwitch(true)

-- register addon comms channel
addonData.channel = "SteaSummon"
Expand Down
Loading

0 comments on commit d11ad3f

Please sign in to comment.