From 061a313264176fd4a2d1f6489e03f4fd2f490b07 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sun, 3 Nov 2024 11:19:29 -0300 Subject: [PATCH] Updated GetChallengeCompletionInfo --- Libs/DF/definitions.lua | 2 ++ Libs/DF/fw.lua | 11 ++++++ Libs/DF/mixins.lua | 3 ++ Libs/DF/picture.lua | 3 +- core/parser.lua | 29 +++++++-------- .../window_mythicplus/window_end_of_run.lua | 21 ----------- functions/mythicdungeon/mythicdungeon.lua | 16 ++++++++- functions/storage.lua | 3 +- luaserver.lua | 36 +++++++++++-------- 9 files changed, 71 insertions(+), 53 deletions(-) diff --git a/Libs/DF/definitions.lua b/Libs/DF/definitions.lua index de0960166..1bdf6e82b 100644 --- a/Libs/DF/definitions.lua +++ b/Libs/DF/definitions.lua @@ -265,6 +265,7 @@ ---@field CreateNewAddOn fun(self:table, addonName:string, globalSavedVariablesName:string, savedVarsTemplate:table) : table ---@field CreateBossScrollSelectorForInstance fun(self:table, instanceId:any, parent:uiobject, name:string?, options:df_bossscrollselector_options?, callback:function?, ...) : df_bossscrollselector ---@field CreateTimeLineFrame fun(self:table, parent:frame, name:string, timelineOptions:df_timeline_options, elapsedtimeOptions:df_elapsedtime_options) : df_timeline +---@field CreateTitleBar fun(self:table, parent:frame, titleText:string) : df_titlebar ---@field CreateElapsedTimeFrame fun(self:table, parent:frame, name:string?, options:df_elapsedtime_options?) : df_elapsedtime ---@field ConvertAnchorPointToInside fun(self:table, anchorPoint:anchorid) : anchorid ---@field ExpansionHasAugEvoker fun():boolean @@ -277,6 +278,7 @@ ---@field GetCurrentSpecId fun(self:table):number? return the specId of the current spec, retuns nil if the expansion the player is playing does not support specs ---@field GetClassSpecIds fun(self:table, engClass:string):number[] ---@field GetClassSpecIDs fun(self:table, engClass:string):number[] +---@field GetTextWidth fun(self:table, text:string, fontSize:number?) : number return the width of a text string ---@field IsValidSpecId fun(self:table, specId:number):boolean check if the passed specId is valid for the player class, also return false for tutorial specs ---@field GetDragonlightTalentString fun(self:table):string return the talent config string ---@field GetClassList fun(self:table):{ID:number, Name:string, FileString:string, Texture:string, TexCoord:number[]}[] diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index 812954a79..df26239bd 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1289,6 +1289,17 @@ end local dummyFontString = UIParent:CreateFontString(nil, "background", "GameFontNormal") local defaultFontFile = dummyFontString:GetFont() +function DF:GetTextWidth(text, size) + if (size) then + DF:SetFontSize(dummyFontString, size) + else + DF:SetFontSize(dummyFontString, 12) + end + + dummyFontString:SetText(text) + return dummyFontString:GetStringWidth() +end + ---get the UIObject of type 'FontString' and set the default game font into it ---@param self table ---@param fontString fontstring diff --git a/Libs/DF/mixins.lua b/Libs/DF/mixins.lua index f66dc7efe..4dca03178 100644 --- a/Libs/DF/mixins.lua +++ b/Libs/DF/mixins.lua @@ -192,6 +192,7 @@ local doublePoint = { ---@class df_setpoint : table ---@field SetPoint fun(self: table, anchorName1: anchor_name, anchorObject: table?, anchorName2: string?, xOffset: number?, yOffset: number?) +---@field SetPoints fun(self: table, anchorName1: anchor_name, anchorObject: table?, anchorName2: string?, xOffset: number?, yOffset: number?) detailsFramework.SetPointMixin = { SetPoint = function(object, anchorName1, anchorObject, anchorName2, xOffset, yOffset) @@ -273,6 +274,8 @@ detailsFramework.SetPointMixin = { end, } +detailsFramework.SetPointMixin.SetPoints = detailsFramework.SetPointMixin.SetPoint + ---mixin for options ---@class df_optionsmixin ---@field options table diff --git a/Libs/DF/picture.lua b/Libs/DF/picture.lua index 418af7cd7..c80ae7ef0 100644 --- a/Libs/DF/picture.lua +++ b/Libs/DF/picture.lua @@ -243,8 +243,9 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin) ------------------------------------------------------------------------------------------------------------ --object constructor - ---@class df_image : texture, df_widgets, df_setpoint + ---@class df_image : df_setpoint, texture, df_widgets ---@field SetGradient fun(gradientType: "vertical"|"horizontal", fromColor: table, toColor: table) + ---@field SetPoint fun(self: table, anchorName1: anchor_name, anchorObject: table?, anchorName2: string?, xOffset: number?, yOffset: number?) ---@field image texture ---@class df_gradienttable : table diff --git a/core/parser.lua b/core/parser.lua index 7dd13b29b..1bfb770f3 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -6002,20 +6002,21 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 --wait until the keystone is updated and send it to the party saveGroupMembersKeystoneAndRatingLevel() - ---@type number mapID - ---@type number level - ---@type number time - ---@type boolean onTime - ---@type number keystoneUpgradeLevels - ---@type boolean practiceRun - ---@type number oldDungeonScore - ---@type number newDungeonScore - ---@type boolean isMapRecord - ---@type boolean isAffixRecord - ---@type number primaryAffix - ---@type boolean isEligibleForScore - ---@type table upgradeMembers - local mapID, level, time, onTime, keystoneUpgradeLevels, practiceRun, oldDungeonScore, newDungeonScore, isAffixRecord, isMapRecord, primaryAffix, isEligibleForScore, upgradeMembers = C_ChallengeMode.GetCompletionInfo() + local completionInfo = C_ChallengeMode.GetChallengeCompletionInfo() + + local primaryAffix = 0 + local mapID = C_ChallengeMode.GetActiveChallengeMapID() + local upgradeMembers = completionInfo.members + local level = completionInfo.level + local time = completionInfo.time + local onTime = completionInfo.onTime + local keystoneUpgradeLevels = completionInfo.keystoneUpgradeLevels + local practiceRun = completionInfo.practiceRun + local isAffixRecord = completionInfo.isAffixRecord + local isMapRecord = completionInfo.isMapRecord + local isEligibleForScore = completionInfo.isEligibleForScore + local oldDungeonScore = completionInfo.oldOverallDungeonScore + local newDungeonScore = completionInfo.newOverallDungeonScore Details222.MythicPlus.MapID = mapID Details222.MythicPlus.Level = level --level of the key just finished diff --git a/frames/window_mythicplus/window_end_of_run.lua b/frames/window_mythicplus/window_end_of_run.lua index 0f02c0ad2..05736c040 100644 --- a/frames/window_mythicplus/window_end_of_run.lua +++ b/frames/window_mythicplus/window_end_of_run.lua @@ -1528,24 +1528,3 @@ end Details222.MythicPlus.IsMythicPlus = function() return C_ChallengeMode and C_ChallengeMode.GetActiveKeystoneInfo() and true or false end - - - --[=[ - Details222.MythicPlus.MapID = mapID - Details222.MythicPlus.Level = level --level of the key just finished - Details222.MythicPlus.OnTime = onTime - Details222.MythicPlus.KeystoneUpgradeLevels = keystoneUpgradeLevels - Details222.MythicPlus.PracticeRun = practiceRun - Details222.MythicPlus.OldDungeonScore = oldDungeonScore - Details222.MythicPlus.NewDungeonScore = newDungeonScore - Details222.MythicPlus.IsAffixRecord = isAffixRecord - Details222.MythicPlus.IsMapRecord = isMapRecord - Details222.MythicPlus.PrimaryAffix = primaryAffix - Details222.MythicPlus.IsEligibleForScore = isEligibleForScore - Details222.MythicPlus.UpgradeMembers = upgradeMembers - Details222.MythicPlus.DungeonName = dungeonName - Details222.MythicPlus.DungeonID = id - Details222.MythicPlus.TimeLimit = timeLimit - Details222.MythicPlus.Texture = texture - Details222.MythicPlus.BackgroundTexture = backgroundTexture - --]=] \ No newline at end of file diff --git a/functions/mythicdungeon/mythicdungeon.lua b/functions/mythicdungeon/mythicdungeon.lua index 934d75c94..ca9c540f5 100644 --- a/functions/mythicdungeon/mythicdungeon.lua +++ b/functions/mythicdungeon/mythicdungeon.lua @@ -398,7 +398,21 @@ end) ---@param combatObject combat function DetailsMythicPlusFrame.SaveMythicPlusStats(combatObject) - local mapChallengeModeID, mythicLevel, time, onTime, keystoneUpgradeLevels, practiceRun, oldOverallDungeonScore, newOverallDungeonScore, IsMapRecord, IsAffixRecord, PrimaryAffix, isEligibleForScore, members = C_ChallengeMode.GetChallengeCompletionInfo() + local completionInfo = C_ChallengeMode.GetChallengeCompletionInfo() + local mapChallengeModeID = C_ChallengeMode.GetActiveChallengeMapID() + local PrimaryAffix = 0 + local upgradeMembers = completionInfo.members + local mythicLevel = completionInfo.level + local time = completionInfo.time + local onTime = completionInfo.onTime + local keystoneUpgradeLevels = completionInfo.keystoneUpgradeLevels + local practiceRun = completionInfo.practiceRun + local isAffixRecord = completionInfo.isAffixRecord + local isMapRecord = completionInfo.isMapRecord + local isEligibleForScore = completionInfo.isEligibleForScore + local oldDungeonScore = completionInfo.oldOverallDungeonScore + local newDungeonScore = completionInfo.newOverallDungeonScore + if (mapChallengeModeID) then local statName = "mythicdungeoncompletedDF2" diff --git a/functions/storage.lua b/functions/storage.lua index 5b3ab9486..ab5a90358 100644 --- a/functions/storage.lua +++ b/functions/storage.lua @@ -1030,7 +1030,8 @@ function Details.Database.StoreEncounter(combat) if (diffName == "mythicdungeon") then local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo() - local mapChallengeModeID = C_ChallengeMode.GetChallengeCompletionInfo() + local mapChallengeModeID = C_ChallengeMode.GetActiveChallengeMapID() + if (not mythicLevel and not mapChallengeModeID) then return end diff --git a/luaserver.lua b/luaserver.lua index d0d612245..1f13ad3f8 100644 --- a/luaserver.lua +++ b/luaserver.lua @@ -359,6 +359,25 @@ CLASS_ICON_TCOORDS = {} ---@field tilesHorizontally boolean? ---@field tilesVertically boolean? +---@class challengecompletioninfo : table +---@field mapChallengeModeID number +---@field level number +---@field time number +---@field onTime boolean +---@field keystoneUpgradeLevels number +---@field practiceRun boolean +---@field oldOverallDungeonScore number? +---@field newOverallDungeonScore number? +---@field isMapRecord boolean +---@field isAffixRecord boolean +---@field isEligibleForScore boolean +---@field members table + +---@class challengemodecompletionmemberinfo : table +---@field memberGUID guid +---@field name string + + ---@alias spellid number integer each spell in the game has a unique spell id, this id can be used to identify a spell. ---@alias unitname string name of a unit ---@alias unitguid string unique id of a unit (GUID) @@ -1427,21 +1446,8 @@ function C_ChallengeMode.GetActiveChallengeMapID() return 0 end ---@return boolean wasActive Whether the keystone was active. function C_ChallengeMode.GetActiveKeystoneInfo() return 0, {}, true end ----return the completion information for the current challenge mode. ----@return number mapChallengeModeID The map id of the challenge mode. ----@return number level The keystone level of the challenge mode. ----@return number time The time taken to complete the challenge mode. ----@return boolean onTime Whether the challenge mode was completed within the time limit. ----@return number keystoneUpgradeLevels The number of keystone upgrade levels. ----@return boolean practiceRun Whether the challenge mode was a practice run. ----@return number oldOverallDungeonScore The old overall dungeon score. ----@return number newOverallDungeonScore The new overall dungeon score. ----@return boolean isMapRecord Whether the completion is a map record. ----@return boolean isAffixRecord Whether the completion is an affix record. ----@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.GetChallengeCompletionInfo() return 0, 0, 0, true, 0, true, 0, 0, true, true, 0, true, {} end +---@return challengecompletioninfo +function C_ChallengeMode.GetChallengeCompletionInfo() return {} end ---return the death count for the current challenge mode. ---@return number numDeaths The number of deaths.