Skip to content

Commit

Permalink
Fixed GetCompletionInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed Nov 2, 2024
1 parent 06aab35 commit 69eda66
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Libs/DF/definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
---@field RoundedCornerPanelMixin df_roundedcornermixin
---@field Schedules df_schedule
---@field HeaderFunctions df_headerfunctions
---@field RoleTypes roleinfo[]
---@field Language df_language
---@field Ejc df_ejc
---@field KeybindMixin df_keybindmixin
Expand All @@ -160,6 +161,7 @@
---@field alias_text_colors table<string, number[]>
---@field ClassFileNameToIndex table<string, number> engClass -> classIndex
---@field ClientLanguage string
---@field ClassIndexToFileName table<classid, class> classIndex -> engClass
---@field dropdown_templates table<df_templatename, df_template>
---@field switch_templates table<df_templatename, df_template>
---@field button_templates table<df_templatename, df_template>
Expand Down Expand Up @@ -367,7 +369,7 @@
---@field AddRoleIconToText fun(self:table, text:string, role:string, size:number?) : string add a role icon to a text using escape codes
---@field GetRoleTCoordsAndTexture fun(self:table, roleID:number) : number, number, number, number, string
---@field AddColorToText fun(self:table, text:string, color:any) : string wrap text with a color
---@field AddClassColorToText fun(self:table, text:string, className:class) : string wrap text with a class color
---@field AddClassColorToText fun(self:table, text:string, className:class|number) : string wrap text with a class color
---@field MakeDraggable fun(self:table, frame:frame) : nil
---@field GetClassTCoordsAndTexture fun(self:table, class:string) : number, number, number, number, string return the class icon texture coordinates and texture file path
---@field GetClassColorByClassId fun(self:table, classId:number) : number, number, number return the class color by classId
Expand Down
19 changes: 19 additions & 0 deletions Libs/DF/dropdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,23 @@ function DetailsFrameworkDropDownOptionOnLeave(frame)
frame:GetParent().mouseover:Hide()
end

---@class dropdownoption : table
---@field value any
---@field label string text shown in the dropdown option
---@field onclick fun(dropdownObject:table, fixedValue:any, value:any)? function to call when the option is selected
---@field icon string|number? texture
---@field color any any color format
---@field font string?
---@field texcoord number[]? left, right, top, bottom
---@field iconcolor any any color format
---@field iconsize number[]? width, height
---@field languageId string?
---@field rightbutton function? function to call on right click
---@field statusbar string|number? statusbar texture
---@field statusbarcolor any any color format
---@field rightTexture string|number? texture
---@field centerTexture string|number? texture

--@button is the raw button frame, object is the button capsule
--click on the main dropdown frame (not the menu options popup)
function DetailsFrameworkDropDownOnMouseDown(button, buttontype)
Expand Down Expand Up @@ -736,6 +753,8 @@ function DetailsFrameworkDropDownOnMouseDown(button, buttontype)
for tindex, thisOption in ipairs(optionsTable) do
local bIsOptionVisible = isOptionVisible(button, thisOption)

---@cast thisOption dropdownoption

if (bIsOptionVisible) then
local thisOptionFrame = object.menus[i]
showing = showing + 1
Expand Down
18 changes: 16 additions & 2 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


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

Expand Down Expand Up @@ -1384,6 +1384,10 @@ end
---@param className class
---@return string
function DF:AddClassColorToText(text, className)
if (type(className) == "number") then
className = DF.ClassIndexToFileName[className]
end

if (type(className) ~= "string") then
return DF:RemoveRealName(text)

Expand Down Expand Up @@ -4993,11 +4997,21 @@ function DF:GetGroupTypes()
return DF.GroupTypes
end

DF.RoleTypes = {
---@class roleinfo : table
---@field Name string
---@field ID string
---@field Texture string

---@type roleinfo[]
local roles = {
{Name = _G.DAMAGER, ID = "DAMAGER", Texture = _G.INLINE_DAMAGER_ICON},
{Name = _G.HEALER, ID = "HEALER", Texture = _G.INLINE_HEALER_ICON},
{Name = _G.TANK, ID = "TANK", Texture = _G.INLINE_TANK_ICON},
{Name = _G.NONE, ID = "NONE", Texture = _G.INLINE_DAMAGER_ICON},
}

DF.RoleTypes = roles

function DF:GetRoleTypes()
return DF.RoleTypes
end
Expand Down
5 changes: 5 additions & 0 deletions Libs/DF/mixins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ local doublePoint = {
["left-right"] = true,
}

---@alias anchor_name "lefts" | "rights" | "tops" | "bottoms" | "left-left" | "right-right" | "top-top" | "bottom-bottom" | "bottom-top" | "top-bottom" | "right-left" | "left-right" | "topleft" | "topright" | "bottomleft" | "bottomright" | "left" | "right" | "top" | "bottom" | "center"

---@class df_setpoint : table
---@field SetPoint fun(self: table, anchorName1: anchor_name, anchorObject: table?, anchorName2: string?, xOffset: number?, yOffset: number?)

detailsFramework.SetPointMixin = {
SetPoint = function(object, anchorName1, anchorObject, anchorName2, xOffset, yOffset)
if (doublePoint[anchorName1]) then
Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/picture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
------------------------------------------------------------------------------------------------------------
--object constructor

---@class df_image : texture, df_widgets
---@class df_image : texture, df_widgets, df_setpoint
---@field SetGradient fun(gradientType: "vertical"|"horizontal", fromColor: table, toColor: table)
---@field image texture

Expand Down
21 changes: 17 additions & 4 deletions Libs/DF/timeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ detailsFramework.TimeLine_LineMixin = {
block.info.customIcon = customIcon --nil set to nil if not exists
block.info.customName = customName

block.text:SetText(customName or "")

if (useIconOnBlock) then
local iconTexture = lineData.icon
if (customIcon) then
Expand Down Expand Up @@ -434,7 +436,7 @@ detailsFramework.TimeLine_LineMixin = {
local background = block:CreateTexture(nil, "background")
background:SetColorTexture(1, 1, 1, 1)
local icon = block:CreateTexture(nil, "artwork")
local text = block:CreateFontString(nil, "artwork")
local text = block:CreateFontString(nil, "artwork", "GameFontNormal")

detailsFramework.TimeLine_LineMixin.CreateAuraLength(block)

Expand All @@ -449,7 +451,8 @@ detailsFramework.TimeLine_LineMixin = {

background:SetAllPoints()
icon:SetPoint("left")
text:SetPoint("left", icon, "left", 2, 0)
text:SetPoint("left", icon, "right", 2, 0)
detailsFramework:SetFontOutline(text, "OUTLINE")

block.icon = icon
block.text = text
Expand Down Expand Up @@ -635,11 +638,22 @@ detailsFramework.TimeLineMixin = {
lineHeader = CreateFrame("frame", nil, self.headerBody, "BackdropTemplate")
lineHeader:SetSize(detachedHeaderFrame:GetWidth(), self.options.line_height)
lineHeader:SetPoint("topleft", self.headerBody, "topleft", 0, xPosition)
detailsFramework:CreateHighlightTexture(lineHeader, "HighlightTexture")
lineHeader.HighlightTexture:SetDrawLayer("overlay", 1)
lineHeader.HighlightTexture:Hide()
lineHeader:EnableMouse(true)
lineHeader:SetScript("OnEnter", function() self.options.on_enter(line) lineHeader.HighlightTexture:Show() end)
lineHeader:SetScript("OnLeave", function() self.options.on_leave(line) lineHeader.HighlightTexture:Hide() end)
line:SetScript("OnEnter", function() self.options.on_enter(line) lineHeader.HighlightTexture:Show() end)
line:SetScript("OnLeave", function() self.options.on_leave(line) lineHeader.HighlightTexture:Hide() end)

lineHeader.Line = line
else
lineHeader = CreateFrame("frame", nil, line, "BackdropTemplate")
lineHeader:SetPoint("topleft", line, "topleft", 0, 0)
lineHeader:SetPoint("bottomleft", line, "bottomleft", 0, 0)
line:SetScript("OnEnter", self.options.on_enter)
line:SetScript("OnLeave", self.options.on_leave)
end
--lineHeader:SetScript("OnEnter", self.options.header_on_enter)
--lineHeader:SetScript("OnLeave", self.options.header_on_leave)
Expand All @@ -649,8 +663,6 @@ detailsFramework.TimeLineMixin = {
--store the individual textures that shows the timeline information
line.blocks = {}

line:SetScript("OnEnter", self.options.on_enter)
line:SetScript("OnLeave", self.options.on_leave)
line:SetMouseClickEnabled(false)

line:SetBackdrop(self.options.backdrop)
Expand Down Expand Up @@ -804,6 +816,7 @@ detailsFramework.TimeLineMixin = {
local linePadding = self.options.line_padding

local bodyHeight = (lineHeight + linePadding) * #self.data.lines
bodyHeight = bodyHeight + 40
self.body:SetHeight(bodyHeight)
self.verticalSlider:SetMinMaxValues(0, max(bodyHeight - self:GetHeight(), 0))
self.verticalSlider:SetValue(0)
Expand Down
2 changes: 1 addition & 1 deletion functions/mythicdungeon/mythicdungeon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ end)

---@param combatObject combat
function DetailsMythicPlusFrame.SaveMythicPlusStats(combatObject)
local mapChallengeModeID, mythicLevel, time, onTime, keystoneUpgradeLevels, practiceRun, oldOverallDungeonScore, newOverallDungeonScore, IsMapRecord, IsAffixRecord, PrimaryAffix, isEligibleForScore, members = C_ChallengeMode.GetCompletionInfo()
local mapChallengeModeID, mythicLevel, time, onTime, keystoneUpgradeLevels, practiceRun, oldOverallDungeonScore, newOverallDungeonScore, IsMapRecord, IsAffixRecord, PrimaryAffix, isEligibleForScore, members = C_ChallengeMode.GetChallengeCompletionInfo()
if (mapChallengeModeID) then
local statName = "mythicdungeoncompletedDF2"

Expand Down
4 changes: 2 additions & 2 deletions functions/mythicdungeon/segments.lua
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,15 @@ function DetailsMythicPlusFrame.MergeSegmentsOnEnd() --~merge
if (type(Details222.MythicPlus.time) == "number") then
newCombat.run_time = Details222.MythicPlus.time
newCombat.elapsed_time = Details222.MythicPlus.ElapsedTime
Details222.MythicPlus.LogStep("GetCompletionInfo() Found, Time: " .. Details222.MythicPlus.time)
Details222.MythicPlus.LogStep("GetChallengeCompletionInfo() Found, Time: " .. Details222.MythicPlus.time)

elseif (newCombat.is_mythic_dungeon.WorldStateTimerEnd and newCombat.is_mythic_dungeon.WorldStateTimerStart) then
local runTime = newCombat.is_mythic_dungeon.WorldStateTimerEnd - newCombat.is_mythic_dungeon.WorldStateTimerStart
newCombat.run_time = Details222.MythicPlus.time
Details222.MythicPlus.LogStep("World State Timers is Available, Run Time: " .. runTime .. "| start:" .. newCombat.is_mythic_dungeon.WorldStateTimerStart .. "| end:" .. newCombat.is_mythic_dungeon.WorldStateTimerEnd)
else
newCombat.run_time = timeInCombat
Details222.MythicPlus.LogStep("GetCompletionInfo() and World State Timers not Found, Activity Time: " .. timeInCombat)
Details222.MythicPlus.LogStep("GetChallengeCompletionInfo() and World State Timers not Found, Activity Time: " .. timeInCombat)
end

newCombat:SetStartTime(GetTime() - timeInCombat)
Expand Down
1 change: 0 additions & 1 deletion functions/pack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ local tonumber = _G.tonumber
local select = _G.select
local strsplit = _G.strsplit
local floor = _G.floor
local tremove = _G["table.remove"]
local UnitName = _G.UnitName
local tinsert = tinsert
local IsInRaid = _G.IsInRaid
Expand Down
2 changes: 1 addition & 1 deletion functions/storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ function Details.Database.StoreEncounter(combat)

if (diffName == "mythicdungeon") then
local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo()
local mapChallengeModeID = C_ChallengeMode.GetCompletionInfo()
local mapChallengeModeID = C_ChallengeMode.GetChallengeCompletionInfo()
if (not mythicLevel and not mapChallengeModeID) then
return
end
Expand Down
4 changes: 3 additions & 1 deletion luaserver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ CLASS_ICON_TCOORDS = {}
---@alias petname string refers to a pet's name
---@alias ownername string refers to the pet's owner name
---@alias spellname string name of a spell
---@alias classid number the ID of a class
---@alias spellschool number each spell in the game has a school, such as fire, frost, shadow and many others. This value can be used to identify the school of a spell.
---@alias actorid string unique id of a unit (GUID)
---@alias serial string unique id of a unit (GUID)
Expand Down Expand Up @@ -802,6 +803,7 @@ BackdropTemplateMixin = {}
---@field SetFont fun(self: editbox, font: string, size: number, flags: string)
---@field SetFontObject fun(self: editbox, fontString: fontstring)
---@field GetFont fun(self: editbox) : string, number, string
---@field ClearFocus fun(self:editbox) clear the editing focus
---@field SetTextColor fun(self: editbox, r: red|number, g: green|number, b: blue|number, a: alpha|number?)
---@field SetJustifyH fun(self:editbox, alignment:string)
---@field SetTextInsets fun(self:editbox, left:number, right:number, top:number, bottom:number)
Expand Down Expand Up @@ -1439,7 +1441,7 @@ function C_ChallengeMode.GetActiveKeystoneInfo() return 0, {}, true end
---@return number primaryAffix The primary affix id.
---@return boolean isEligibleForScore Whether the completion is eligible for a score.
---@return ChallengeModeCompletionMemberInfo[] members The members of the group.
function C_ChallengeMode.GetCompletionInfo() return 0, 0, 0, true, 0, true, 0, 0, true, true, 0, true, {} end
function C_ChallengeMode.GetChallengeCompletionInfo() return 0, 0, 0, true, 0, true, 0, 0, true, true, 0, true, {} end

---return the death count for the current challenge mode.
---@return number numDeaths The number of deaths.
Expand Down

0 comments on commit 69eda66

Please sign in to comment.