Added /keystone and OpenRaidLib update
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user