Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Oct 30, 2024
1 parent d8289f0 commit 06aab35
Show file tree
Hide file tree
Showing 51 changed files with 1,586 additions and 1,475 deletions.
3 changes: 2 additions & 1 deletion Details.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 110002
## Interface: 110005
## Interface-Cata: 40400
## Title: Details! Damage Meter
## Notes: Essential tool to impress that chick in your raid.
Expand Down Expand Up @@ -132,6 +132,7 @@ frames\window_statistics.lua
frames\window_aura_tracker.lua
frames\window_debug.lua
frames\window_pro_file.lua
frames\window_nestspells.lua

classes\class_error.lua
classes\class_spelltable.lua
Expand Down
1 change: 1 addition & 0 deletions Details_Cata.toc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ frames\window_statistics.lua
frames\window_aura_tracker.lua
frames\window_debug.lua
frames\window_pro_file.lua
frames\window_nestspells.lua

classes\class_error.lua
classes\class_spelltable.lua
Expand Down
1 change: 1 addition & 0 deletions Details_Classic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ frames\window_classcolor.lua
frames\window_statistics.lua
frames\window_debug.lua
frames\window_pro_file.lua
frames\window_nestspells.lua

classes\class_error.lua
classes\class_spelltable.lua
Expand Down
1 change: 1 addition & 0 deletions Details_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ frames\window_classcolor.lua
frames\window_statistics.lua
frames\window_debug.lua
frames\window_pro_file.lua
frames\window_nestspells.lua

classes\class_error.lua
classes\class_spelltable.lua
Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local GetSpellTabInfo = GetSpellTabInfo or function(tabLine) local skillLine = C
local unpack = unpack
local CreateFrame = CreateFrame
local GameTooltip = GameTooltip
local tremove = tremove
local tremove = table.remove

local CONST_MAX_SPELLS = 500000

Expand Down
150 changes: 82 additions & 68 deletions Libs/DF/definitions.lua

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion Libs/DF/elapsedtime.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ detailsFramework.TimeLineElapsedTimeFunctions = {
end
end,

SetScrollChild = function(self, scrollChild)
self.scrollChild = scrollChild
end,

Refresh = function(self, elapsedTime, scale)
if (not elapsedTime) then
--invalid data passed
Expand Down Expand Up @@ -118,7 +122,7 @@ detailsFramework.TimeLineElapsedTimeFunctions = {
label:SetText(detailsFramework:IntegerToTimer(floor(secondsOfTime)))

if (label.line:IsShown()) then
label.line:SetHeight(parent:GetParent():GetHeight())
label.line:SetHeight(self.scrollChild:GetHeight())
end

label:Show()
Expand All @@ -128,13 +132,15 @@ detailsFramework.TimeLineElapsedTimeFunctions = {

---@class df_elapsedtime : frame, df_elapsedtime_mixin, df_optionsmixin
---@field labels table<number, df_elapsedtime_label>
---@field scrollChild frame

---creates a frame to show the elapsed time in a row
---@param parent frame
---@param name string?
---@param options df_elapsedtime_options?
---@return df_elapsedtime
function detailsFramework:CreateElapsedTimeFrame(parent, name, options)
---@type df_elapsedtime
local elapsedTimeFrame = CreateFrame("frame", name, parent, "BackdropTemplate")

detailsFramework:Mixin(elapsedTimeFrame, detailsFramework.OptionsFunctions)
Expand All @@ -146,6 +152,8 @@ function detailsFramework:CreateElapsedTimeFrame(parent, name, options)
elapsedTimeFrame:SetBackdrop(elapsedTimeFrame.options.backdrop)
elapsedTimeFrame:SetBackdropColor(unpack(elapsedTimeFrame.options.backdrop_color))

elapsedTimeFrame.scrollChild = parent

elapsedTimeFrame.labels = {}

return elapsedTimeFrame
Expand Down
45 changes: 23 additions & 22 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 575
local dversion = 577
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down Expand Up @@ -1365,6 +1365,19 @@ function DF:AddColorToText(text, color) --wrap text with a color
return text
end

function DF:GetClassColorByClassId(classId)
local classInfo = C_CreatureInfo.GetClassInfo(classId)
if (classInfo) then
local color = RAID_CLASS_COLORS[classInfo.classFile]
if (color) then
return color.r, color.g, color.b
else
return 1, 1, 1
end
end
return 1, 1, 1
end

---receives a string 'text' and a class name and return the string wrapped with the class color using |c and |r scape codes
---@param self table
---@param text string
Expand Down Expand Up @@ -3155,7 +3168,7 @@ function DF:ParseTemplate(templateCategory, template)
if (objectType == "label") then
templateCategory = "font"

elseif (objectType == "dropdown") then
elseif (objectType == "dropdown" or objectType == "textentry") then
templateCategory = "dropdown"

elseif (objectType == "button") then
Expand Down Expand Up @@ -4739,6 +4752,7 @@ DF.ClassIndexToFileName = {
[13] = "EVOKER",
}

--GetNumClasses()

DF.ClassFileNameToIndex = {
["WARRIOR"] = 1,
Expand Down Expand Up @@ -5708,34 +5722,21 @@ local sendTimeBarNotification = function(token, barType, id, msg, timer, icon, s
end

local createBossModsCallback = function()
if (false and _G.DBM) then
if (_G.DBM) then
local DBM = _G.DBM

--phase change
local phaseChangeCallback = function(event, mod, modId, phase, encounterId, stageTotal)
sendPhaseNotification(phase)
local phaseChangeCallback = function(event, mod, modId, phase, encounterId, stageTotal, arg1, arg2)
end
--DBM:RegisterCallback("DBM_SetStage", phaseChangeCallback)
DBM:RegisterCallback("DBM_SetStage", phaseChangeCallback)

--time bars
local timerChangeCallback = function(bar_type, id, msg, timer, icon, bartype, spellId, colorId, modid)
local currentCombat = Details:GetCurrentCombat()
if (not currentCombat.__destroyed) then --async events, need to check for combat destruction
---@type combattime
local combatTime = currentCombat:GetCombatTime()
table.insert(currentCombat.bossTimers, {"dbm", combatTime, bar_type, id, msg, timer, icon, bartype, spellId, colorId, modid})
--print("dbm event", bar_type, id, msg, timer, icon, bartype, spellId, colorId, modid)

local spell = tostring(spellId)
if (spell and not current_table_dbm[spell]) then
current_table_dbm[spell] = {spell, id, msg, timer, icon, bartype, spellId, colorId, modid}
end
end
local timerChangeCallback = function(bar_type, id, msg, timer, icon, bartype, spellId, colorId, modid, arg1, arg2)
end

--DBM:RegisterCallback("DBM_TimerStart", timerChangeCallback)
DBM:RegisterCallback("DBM_TimerStart", timerChangeCallback)
end

--[=
local BigWigsLoader = BigWigsLoader

if (BigWigsLoader) then -- and not _G.DBM
Expand Down Expand Up @@ -5786,10 +5787,10 @@ local createBossModsCallback = function()
--self:RegisterMessage("BigWigs_StopBars", "StopModuleBars")
end
end
--]=]
end



detailsFramework.OnLoginSchedules[#detailsFramework.OnLoginSchedules+1] = createBossModsCallback


Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ local default_header_options = {
function detailsFramework:CreateHeader(parent, headerTable, options, frameName)
---create the header frame which is returned by this function
---@type df_headerframe
local newHeader = CreateFrame("frame", frameName or "$parentHeaderLine", parent, "BackdropTemplate")
local newHeader = CreateFrame("frame", frameName or ("$parentHeaderLine" .. math.random(100000000)), parent, "BackdropTemplate")

detailsFramework:Mixin(newHeader, detailsFramework.OptionsFunctions)
detailsFramework:Mixin(newHeader, detailsFramework.HeaderMixin)
Expand Down
52 changes: 52 additions & 0 deletions Libs/DF/label.lua
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,56 @@ function detailsFramework:NewLabel(parent, container, name, member, text, font,
end

return labelObject
end

---@class df_errorlabel : df_label
---@field ShowErrorMsg fun(self: df_errorlabel, msg: string) show an error message to the user
---@field fadeInAnimationHub animationgroup
---@field fadeOutAnimationHub animationgroup
---@field shake df_frameshake

local showErrorMsg = function(self, text)
if (self.HideTimer) then
return
end

self.fadeInAnimationHub:Play()
if (text) then
self:SetText(text)
end
self:PlayFrameShake(self.shake)

self.HideTimer = C_Timer.NewTimer(4, function()
self.fadeOutAnimationHub:Play()
self.HideTimer = nil
end)
end

---error msg fontstring, this text is used to show errors to the user, its color is red, size 13 and it is placed centered and below the buttons above
---it also has an animation to fade out after 5 seconds, and a shake animation when it's shown
function detailsFramework:CreateErrorLabel(parent, text, size, color, layer, name)
---@type df_errorlabel
local errorMsg = detailsFramework:CreateLabel(parent, text or "", size or 13, color or "orangered", nil, nil, name, layer or "overlay")
if (errorMsg) then
errorMsg:SetJustifyH("center")
errorMsg:SetAlpha(0)

--fade out animation
local fadeOutAnimationHub = detailsFramework:CreateAnimationHub(errorMsg, function()end, function() errorMsg:SetAlpha(0) end)
detailsFramework:CreateAnimation(fadeOutAnimationHub, "Alpha", 1, 2, 1, 0)
errorMsg.fadeOutAnimationHub = fadeOutAnimationHub

--fade in animation
local fadeInAnimationHub = detailsFramework:CreateAnimationHub(errorMsg, function() errorMsg:SetAlpha(0) end, function() errorMsg:SetAlpha(1) end)
detailsFramework:CreateAnimation(fadeInAnimationHub, "Alpha", 1, 0.1, 0, 1)
errorMsg.fadeInAnimationHub = fadeInAnimationHub

--shake animation
local shake = detailsFramework:CreateFrameShake(errorMsg, 0.4, 6, 20, false, true, 0, 1, 0, 0.3)
errorMsg.shake = shake

errorMsg.ShowErrorMsg = showErrorMsg

return errorMsg
end
end
2 changes: 1 addition & 1 deletion Libs/DF/languages.lua
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ function DF.Language.UnregisterCallback(addonId, callback)
for i = 1, #addonNamespaceTable.callbacks do
local callbackTable = addonNamespaceTable.callbacks[i]
if (callbackTable.callback == callback) then
tremove(addonNamespaceTable.callbacks, i)
table.remove(addonNamespaceTable.callbacks, i)
return true
end
end
Expand Down
1 change: 1 addition & 0 deletions Libs/DF/line_indicator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ end
---@field lineIndicatorLineHeight number
---@field lineIndicatorLineWidth number
---@field lineIndicatorPixelPerSecond number
---@field lineIndicatorMouseEnabled boolean
---@field lineIndicatorColor any
---@field lineIndicatorValueFontString fontstring
---@field LineIndicatorConstructor fun(self:df_lineindicator)
Expand Down
7 changes: 7 additions & 0 deletions Libs/DF/math.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ DF.Math = {}
---@field GetNinePoints fun(object: uiobject) : df_ninepoints
---@field GetClosestPoint fun(ninePoints: df_ninepoints, coordinate: df_coordinate) : anchorid
---@field GetVectorLength fun(vectorX: number, vectorY: number, vectorZ: number?) : number return the magnitude of a vector
---@field GetSortFractionFromString fun(str: string) : number return a fraction based on the string first two leters, useful for sorting cases where the number repeats

---@class df_coordinate : table
---@field x number
Expand Down Expand Up @@ -124,6 +125,12 @@ function DF.Math.GetNinePoints(object)
return ninePoints
end

function DF.Math.GetSortFractionFromString(str)
local name = string.upper(str) .. "ZZ"
local byte1 = abs(string.byte(name, 2)-91) / 1000000
return byte1 + abs(string.byte(name, 1)-91) / 10000
end

function DF.Math.GetVectorLength(vectorX, vectorY, vectorZ)
if (not vectorZ) then
return (vectorX * vectorX + vectorY * vectorY) ^ 0.5
Expand Down
79 changes: 78 additions & 1 deletion Libs/DF/packtable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end
---merge multiple tables into a single one and pack it into a string separating values with commas where the first index tells the table length
---can pack strings and numbers, example:
---passed table: { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
---result string: "9,1,2,3,4,5,6,7,8,9" > 9 indicating the total size of the subtables following by the indexes of the subtables
---result string: "9,1,2,3,4,5,6,7,8,9", 9 indicating the total size of the subtables following by the indexes of the subtables
---@param table table
---@return string
function detailsFramework.table.packsubmerge(table)
Expand All @@ -64,6 +64,39 @@ function detailsFramework.table.packsubmerge(table)
return newString
end

---merge a key-value table into a single string separating values with commas, where the first index is the key and the second index is the value
---example: {key1 = value1, key2 = value2, key3 = value3}
---returned string: "key1,value1,key2,value2,key3,value3"
---use unpackhash to rebuild the table
function detailsFramework.table.packhash(table)
local newString = ""
for key, value in pairs(table) do
newString = newString .. key .. "," .. value .. ","
end

newString = newString:gsub(",$", "")
return newString
end

---pack a hash table where the value of the key is a numerical table
---example: {key1 = {1, 2, 3}, key2 = {4, 6}, key3 = {7}}
---returned string: "key1,3,1,2,3,key2,2,4,6,key3,1,7"
---use unpackhashsubtable to rebuild the table
---@param table table
---@return string
function detailsFramework.table.packhashsubtable(table)
local newString = ""
for key, value in pairs(table) do
newString = newString .. key .. "," .. #value .. ","
for i = 1, #value do
newString = newString .. value[i] .. ","
end
end

newString = newString:gsub(",$", "")
return newString
end

---unpack a string and an array of data into a indexed table, starting from the startIndex also returns the next index to start reading
---expected data: "3,1,2,3,4,5,6,7,8" or {3,1,2,3,4,5,6,7,8}, with the example the returned table is: {1, 2, 3} and the next index to read is 5
---@param data string|table
Expand Down Expand Up @@ -133,5 +166,49 @@ function detailsFramework.table.unpacksub(data, startIndex)
end
end

return result
end

function detailsFramework.table.unpackhash(data)
local splittedTable = {}
for value in data:gmatch("[^,]+") do
splittedTable[#splittedTable+1] = value
end

local result = {}
for i = 1, #splittedTable, 2 do
result[splittedTable[i]] = splittedTable[i+1]
end

return result
end

---unpack a packhashsubtable string into a hash table where the value of the key is a numerical table
---expected data: "key1,3,1,2,3,key2,2,4,6,key3,1,7"
---returned table: {key1 = {1, 2, 3}, key2 = {4, 6}, key3 = {7}}
function detailsFramework.table.unpackhashsubtable(data)
local splittedTable = {}
for value in data:gmatch("[^,]+") do
splittedTable[#splittedTable+1] = value
end

local result = {}
local currentIndex = 1
while (splittedTable[currentIndex]) do
local key = splittedTable[currentIndex]
local tableSize = tonumber(splittedTable[currentIndex+1])
if (not tableSize) then
error("Details! Framework: table.unpackhashsubtable: invalid table size.")
end

local subTable = {}
for i = 1, tableSize do
subTable[#subTable+1] = splittedTable[currentIndex+1+i]
end

result[key] = subTable
currentIndex = currentIndex + tableSize + 2
end

return result
end
Loading

0 comments on commit 06aab35

Please sign in to comment.