From a988f7b42951942c22c28d7ee7ef5ffdc719e105 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sun, 15 May 2022 21:05:02 -0300 Subject: [PATCH] Added /keystone and OpenRaidLib update --- Libs/LibOpenRaid/LibOpenRaid.lua | 46 ++++- Libs/LibOpenRaid/ThingsToMantain.lua | 2 + Libs/LibOpenRaid/docs.txt | 1 + boot.lua | 16 ++ functions/profiles.lua | 6 + functions/slash.lua | 249 +++++++++++++++++++++++++++ 6 files changed, 315 insertions(+), 5 deletions(-) diff --git a/Libs/LibOpenRaid/LibOpenRaid.lua b/Libs/LibOpenRaid/LibOpenRaid.lua index 42281b96..8a3e8f35 100644 --- a/Libs/LibOpenRaid/LibOpenRaid.lua +++ b/Libs/LibOpenRaid/LibOpenRaid.lua @@ -45,7 +45,7 @@ if (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE) then end local major = "LibOpenRaid-1.0" -local CONST_LIB_VERSION = 35 +local CONST_LIB_VERSION = 36 LIB_OPEN_RAID_CAN_LOAD = false --declae the library within the LibStub @@ -1978,12 +1978,45 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNFULLLIST_PREFIX, openRai level = 0, mapID = 0, challengeMapID = 0, + classID = 0, + rating = 0, + mythicPlusMapID = 0, } - local updateKeystoneInfo = function(keystoneInfo, level, mapID, challengeMapID) + --search the player backpack to find a mythic keystone + --with the keystone object, it'll attempt to get the mythicPlusMapID to be used with C_ChallengeMode.GetMapUIInfo(mythicPlusMapID) + --ATM we are obligated to do this due to C_MythicPlus.GetOwnedKeystoneMapID() return the same mapID for the two Tazavesh dungeons + local getMythicPlusMapID = function() + for backpackId = 0, 4 do + for slotId = 1, GetContainerNumSlots(backpackId) do + local itemId = GetContainerItemID(backpackId, slotId) + if (itemId == LIB_OPEN_RAID_MYTHICKEYSTONE_ITEMID) then + local itemLink = GetContainerItemLink(backpackId, slotId) + local destroyedItemLink = itemLink:gsub("|", "") + local color, itemID, mythicPlusMapID = strsplit(":", destroyedItemLink) + return tonumber(mythicPlusMapID) + end + end + end + end + + local updateKeystoneInfo = function(keystoneInfo, level, mapID, challengeMapID, classID, rating, mythicPlusMapID) keystoneInfo.level = level or C_MythicPlus.GetOwnedKeystoneLevel() or 0 keystoneInfo.mapID = mapID or C_MythicPlus.GetOwnedKeystoneMapID() or 0 + keystoneInfo.mythicPlusMapID = mythicPlusMapID or 0 + + if (not mythicPlusMapID and not mapID and keystoneInfo.mapID ~= 0) then + keystoneInfo.mythicPlusMapID = getMythicPlusMapID() or 0 + end + keystoneInfo.challengeMapID = challengeMapID or C_MythicPlus.GetOwnedKeystoneChallengeMapID() or 0 + + local _, _, playerClassID = UnitClass("player") + keystoneInfo.classID = classID or playerClassID + + local ratingSummary = C_PlayerInfo.GetPlayerMythicPlusRatingSummary("player") + local currentRating = ratingSummary and ratingSummary.currentSeasonScore or 0 + keystoneInfo.rating = rating or currentRating end function openRaidLib.KeystoneInfoManager.GetAllKeystonesInfo() @@ -2006,7 +2039,7 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNFULLLIST_PREFIX, openRai local getKeystoneInfoToComm = function() local playerName = UnitName("player") local keystoneInfo = openRaidLib.KeystoneInfoManager.GetKeystoneInfo(playerName, true) - local dataToSend = CONST_COMM_KEYSTONE_DATA_PREFIX .. "," .. keystoneInfo.level .. "," .. keystoneInfo.mapID .. "," .. keystoneInfo.challengeMapID + local dataToSend = CONST_COMM_KEYSTONE_DATA_PREFIX .. "," .. keystoneInfo.level .. "," .. keystoneInfo.mapID .. "," .. keystoneInfo.challengeMapID .. "," .. keystoneInfo.classID .. "," .. keystoneInfo.rating .. "," .. keystoneInfo.mythicPlusMapID return dataToSend end @@ -2048,10 +2081,13 @@ openRaidLib.commHandler.RegisterComm(CONST_COMM_COOLDOWNFULLLIST_PREFIX, openRai local level = tonumber(data[1]) local mapID = tonumber(data[2]) local challengeMapID = tonumber(data[3]) + local classID = tonumber(data[4]) + local rating = tonumber(data[5]) + local mythicPlusMapID = tonumber(data[6]) - if (level and mapID and challengeMapID) then + if (level and mapID and challengeMapID and classID and rating and mythicPlusMapID) then local keystoneInfo = openRaidLib.KeystoneInfoManager.GetKeystoneInfo(unitName, true) - updateKeystoneInfo(keystoneInfo, level, mapID, challengeMapID) + updateKeystoneInfo(keystoneInfo, level, mapID, challengeMapID, classID, rating, mythicPlusMapID) --trigger public callback openRaidLib.publicCallback.TriggerCallback("KeystoneUpdate", openRaidLib.GetUnitID(unitName), keystoneInfo, openRaidLib.KeystoneInfoManager.KeystoneData) diff --git a/Libs/LibOpenRaid/ThingsToMantain.lua b/Libs/LibOpenRaid/ThingsToMantain.lua index 0a20ec8b..31fa83de 100644 --- a/Libs/LibOpenRaid/ThingsToMantain.lua +++ b/Libs/LibOpenRaid/ThingsToMantain.lua @@ -78,6 +78,8 @@ elseif (gameLanguage == "zhTW") then L["STRING_CRITICAL_ONLY"] = "致命" end +LIB_OPEN_RAID_MYTHICKEYSTONE_ITEMID = 180653 + LIB_OPEN_RAID_BLOODLUST = { [2825] = true, --bloodlust [32182] = true, --heroism diff --git a/Libs/LibOpenRaid/docs.txt b/Libs/LibOpenRaid/docs.txt index 51b17cbe..f400944f 100644 --- a/Libs/LibOpenRaid/docs.txt +++ b/Libs/LibOpenRaid/docs.txt @@ -109,6 +109,7 @@ keystoneInfo = { .level = number, .mapID = number, .challengeMapID = number, + .classID = number, } --request all online players in the guild to send their keystone information diff --git a/boot.lua b/boot.lua index c7afdf84..212de8d7 100644 --- a/boot.lua +++ b/boot.lua @@ -33,6 +33,22 @@ do local Loc = _G.LibStub("AceLocale-3.0"):GetLocale( "Details" ) local news = { + --[=[ + {"v9.2.0.9814.146", "May 15th, 2022"}, + "Added a second Title Bar (disabled by default), is recomended to make the Skin Color (under Window Body) full transparent while using it.", + "Added Overlay Texture and Color options under Bars: General.", + "Added Wallpaper Alignment 'Full Body', this alignment make the wallpaper fill over the title bar.", + "Added Auto Alignment for 'Aligned Text Columns', this option is enabled by default.", + "Added 'Window Area Border' and 'Row Area Border' under 'Window Body' section in the options panel.", + "Added an option to color the Row Border by player class.", + "Added new automation auto hide option: Arena.", + "Blizzard Death Recap kill ability only shows on Dungeons and Raids now.", + "Fixed an issue where player names was overlapping damage numbers with enbaled 'Aligned Text Columns'.", + "Fixed a bug on 'DeathLog Min Healing' option where it was reseting to 1 on each logon.", + "Fixed several bugs with 'Bar Orientation: Right to Left' (fix by Flamanis).", + "Fixed an error on Vanguard plugin.", + "Fixed Spec Icons 'Specialization Alpha' offseted by 2 pixels to the right.", + --]=] {"v9.2.0.9778.146", "April 26th, 2022"}, --"A cooldown tracker experiment has been added, its options is visible at the Options Panel.", "Added a search box in the '/details scroll' feature.", diff --git a/functions/profiles.lua b/functions/profiles.lua index 04ed16d9..df6d95df 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1282,6 +1282,12 @@ local default_global_data = { scale = 1, font_size = 10, }, + + --> keystone window + keystone_frame = { + scale = 1, + position = {}, + }, --> profile by spec profile_by_spec = {}, diff --git a/functions/slash.lua b/functions/slash.lua index 4d657536..7240561c 100644 --- a/functions/slash.lua +++ b/functions/slash.lua @@ -1951,3 +1951,252 @@ function _detalhes:CreateListPanel() return _detalhes.ListPanel end + + +if (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE) then + SLASH_KEYSTONE1 = "/keystone" + + function SlashCmdList.KEYSTONE(msg, editbox) + local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0") + if (openRaidLib) then + if (not DetailsKeystoneInfoFrame) then + + local CONST_WINDOW_WIDTH = 614 + local CONST_WINDOW_HEIGHT = 700 + local CONST_SCROLL_LINE_HEIGHT = 20 + local CONST_SCROLL_LINE_AMOUNT = 29 + + local backdrop_color = {.2, .2, .2, 0.2} + local backdrop_color_on_enter = {.8, .8, .8, 0.4} + + local f = DetailsFramework:CreateSimplePanel(UIParent, CONST_WINDOW_WIDTH, CONST_WINDOW_HEIGHT, "M+ Keystones", "DetailsKeystoneInfoFrame") + f:SetPoint("center", UIParent, "center", 0, 0) + + f:SetScript("OnMouseDown", nil) --disable framework native moving scripts + f:SetScript("OnMouseUp", nil) --disable framework native moving scripts + + local LibWindow = LibStub("LibWindow-1.1") + LibWindow.RegisterConfig(f, Details.keystone_frame.position) + LibWindow.MakeDraggable(f) + LibWindow.RestorePosition(f) + + local scaleBar = DetailsFramework:CreateScaleBar(f, Details.keystone_frame) + f:SetScale(Details.keystone_frame.scale) + + local statusBar = DetailsFramework:CreateStatusBar(f) + statusBar.text = statusBar:CreateFontString(nil, "overlay", "GameFontNormal") + statusBar.text:SetPoint("left", statusBar, "left", 5, 0) + statusBar.text:SetText("From Details! Damage Meter | Built with Details! Framework | Data from Open Raid Library") + DetailsFramework:SetFontSize(statusBar.text, 11) + DetailsFramework:SetFontColor(statusBar.text, "gray") + + --header + local headerTable = { + {text = "Class", width = 40, canSort = false, dataType = "string", order = "DESC", offset = 0}, + {text = "Player Name", width = 100, canSort = true, dataType = "string", order = "DESC", offset = 0}, + {text = "Keystone Level", width = 100, canSort = true, dataType = "number", order = "DESC", offset = 0, selected = true}, + {text = "Dungeon", width = 120, canSort = true, dataType = "string", order = "DESC", offset = 0}, + {text = "Classic Dungeon", width = 120, canSort = true, dataType = "string", order = "DESC", offset = 0}, + {text = "Mythic+ Rating", width = 100, canSort = true, dataType = "number", order = "DESC", offset = 0}, + } + + local headerOnClickCallback = function(headerFrame, columnHeader) + f.RefreshData() + end + + local headerOptions = { + padding = 1, + header_backdrop_color = {.3, .3, .3, .8}, + header_backdrop_color_selected = {.5, .5, .5, 0.8}, + use_line_separators = true, + line_separator_color = {.1, .1, .1, .5}, + line_separator_width = 1, + line_separator_height = CONST_WINDOW_HEIGHT-30, + line_separator_gap_align = true, + header_click_callback = headerOnClickCallback, + } + + f.Header = DetailsFramework:CreateHeader(f, headerTable, headerOptions, "DetailsKeystoneInfoFrameHeader") + f.Header:SetPoint("topleft", f, "topleft", 5, -25) + + --scroll + local refreshScrollLines = function(self, data, offset, totalLines) + for i = 1, totalLines do + local index = i + offset + local unitTable = data[index] + + if (unitTable) then + local line = self:GetLine(i) + + local unitName, level, mapID, challengeMapID, classID, rating, mythicPlusMapID, classIconTexture, iconTexCoords, mapName, mapNameChallenge = unpack(unitTable) + + line.icon:SetTexture(classIconTexture) + local L, R, T, B = unpack(iconTexCoords) + line.icon:SetTexCoord(L+0.02, R-0.02, T+0.02, B-0.02) + line.playerNameText.text = unitName + line.keystoneLevelText.text = level + line.dungeonNameText.text = mapName + line.classicDungeonNameText.text = mapNameChallenge or "" + line.ratingText.text = rating + end + end + end + + local scrollFrame = DetailsFramework:CreateScrollBox(f, "$parentScroll", refreshScrollLines, {}, CONST_WINDOW_WIDTH-10, CONST_WINDOW_HEIGHT-70, CONST_SCROLL_LINE_AMOUNT, CONST_SCROLL_LINE_HEIGHT) + DetailsFramework:ReskinSlider(scrollFrame) + scrollFrame:SetPoint("topleft", f.Header, "bottomleft", -1, -1) + scrollFrame:SetPoint("topright", f.Header, "bottomright", 0, -1) + + local lineOnEnter = function (self) + self:SetBackdropColor(unpack(backdrop_color_on_enter)) + end + local lineOnLeave = function (self) + self:SetBackdropColor(unpack(backdrop_color)) + end + + local createLineForScroll = function(self, index) + local line = CreateFrame("frame", "$parentLine" .. index, self, "BackdropTemplate") + line:SetPoint("topleft", self, "topleft", 1, -((index-1) * (CONST_SCROLL_LINE_HEIGHT + 1)) - 1) + line:SetSize(scrollFrame:GetWidth() - 2, CONST_SCROLL_LINE_HEIGHT) + + line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) + line:SetBackdropColor(unpack(backdrop_color)) + + DetailsFramework:Mixin(line, DetailsFramework.HeaderFunctions) + + line:SetScript("OnEnter", lineOnEnter) + line:SetScript("OnLeave", lineOnLeave) + + --class icon + local icon = line:CreateTexture("$parentClassIcon", "overlay") + icon:SetSize(CONST_SCROLL_LINE_HEIGHT - 2, CONST_SCROLL_LINE_HEIGHT - 2) + + --player name + local playerNameText = DetailsFramework:CreateLabel(line) + + --keystone level + local keystoneLevelText = DetailsFramework:CreateLabel(line) + + --dungeon name + local dungeonNameText = DetailsFramework:CreateLabel(line) + + --classic dungeon name + local classicDungeonNameText = DetailsFramework:CreateLabel(line) + + --player rating + local ratingText = DetailsFramework:CreateLabel(line) + + line.icon = icon + line.playerNameText = playerNameText + line.keystoneLevelText = keystoneLevelText + line.dungeonNameText = dungeonNameText + line.classicDungeonNameText = classicDungeonNameText + line.ratingText = ratingText + + line:AddFrameToHeaderAlignment(icon) + line:AddFrameToHeaderAlignment(playerNameText) + line:AddFrameToHeaderAlignment(keystoneLevelText) + line:AddFrameToHeaderAlignment(dungeonNameText) + line:AddFrameToHeaderAlignment(classicDungeonNameText) + line:AddFrameToHeaderAlignment(ratingText) + + line:AlignWithHeader(f.Header, "left") + return line + end + + --create lines + for i = 1, CONST_SCROLL_LINE_AMOUNT do + scrollFrame:CreateLine(createLineForScroll) + end + + function f.RefreshData() + local newData = {} + local keystoneData = openRaidLib.GetAllKeystonesInfo() + + if (keystoneData) then + for unitName, keystoneInfo in pairs(keystoneData) do + local classId = keystoneInfo.classID + local classIcon = [[Interface\GLUES\CHARACTERCREATE\UI-CharacterCreate-Classes]] + local coords = CLASS_ICON_TCOORDS + local _, class = GetClassInfo(classId) + + local mapName = C_ChallengeMode.GetMapUIInfo(keystoneInfo.mythicPlusMapID) or "" + + --local mapInfoChallenge = C_Map.GetMapInfo(keystoneInfo.challengeMapID) + --local mapNameChallenge = mapInfoChallenge and mapInfoChallenge.name or "" + + newData[#newData+1] = { + unitName, + keystoneInfo.level, + keystoneInfo.mapID, + keystoneInfo.challengeMapID, + keystoneInfo.classID, + keystoneInfo.rating, + keystoneInfo.mythicPlusMapID, + classIcon, + coords[class], + mapName, + --mapNameChallenge, + } + end + end + + --get which column is currently selected and the sort order + local columnIndex, order = f.Header:GetSelectedColumn() + local sortByIndex = 2 + + --sort by player name + if (columnIndex == 1) then + sortByIndex = 1 + --sort by keystone level + elseif (columnIndex == 3) then + sortByIndex = 2 + --sort by dungeon name + elseif (columnIndex == 4) then + sortByIndex = 3 + --sort by classic dungeon name + elseif (columnIndex == 5) then + sortByIndex = 4 + --sort by mythic+ ranting + elseif (columnIndex == 6) then + sortByIndex = 6 + end + + if (order == "DESC") then + table.sort(newData, function (t1, t2) return t1[sortByIndex] > t2[sortByIndex] end) + else + table.sort(newData, function (t1, t2) return t1[sortByIndex] < t2[sortByIndex] end) + end + + scrollFrame:SetData(newData) + scrollFrame:Refresh() + end + + --open raid lib callbacks + --openRaidLib.RegisterCallback(Details.CooldownTracking, "CooldownListUpdate", "OnReceiveUnitFullCooldownList") + function f.OnKeystoneUpdate(unitId, keystoneInfo, allKeystonesInfo) + if (f:IsShown()) then + f.RefreshData() + end + end + + f:SetScript("OnHide", function() + openRaidLib.UnregisterCallback(DetailsKeystoneInfoFrame, "KeystoneUpdate", "OnKeystoneUpdate") + end) + end + + --show the frame + DetailsKeystoneInfoFrame:Show() + + openRaidLib.RegisterCallback(DetailsKeystoneInfoFrame, "KeystoneUpdate", "OnKeystoneUpdate") + + if (IsInRaid()) then + openRaidLib.RequestKeystoneDataFromRaid() + elseif (IsInGroup()) then + openRaidLib.RequestKeystoneDataFromParty() + end + + openRaidLib.RequestKeystoneDataFromGuild() + end + end +end \ No newline at end of file