General fixes

This commit is contained in:
Tercio Jose
2021-01-21 17:52:08 -03:00
parent 778e02b583
commit af14e08106
6 changed files with 227 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
local dversion = 230
local dversion = 232
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
+209
View File
@@ -10030,3 +10030,212 @@ function DF:SetPointOffsets(frame, xOffset, yOffset)
end
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> list box
DF.ListboxFunctions = {
scrollRefresh = function(self, data, offset, totalLines)
for i = 1, totalLines do
local index = i + offset
local lineData = data[index] --what is shown in the textentries, array
if (lineData) then
local line = self:GetLine(i)
line.dataIndex = index
line.deleteButton:SetClickFunction(DF.ListboxFunctions.deleteEntry, data, index)
local amountEntries = #lineData
for o = 1, amountEntries do
local textEntry = line.widgets[o]
textEntry.dataTable = lineData
textEntry.dataTableIndex = o
local text = lineData[o]
textEntry:SetText(text)
end
end
end
end,
addEntry = function(self)
local frameCanvas = self:GetParent()
local data = frameCanvas.data
local newEntry = {}
for i = 1, frameCanvas.headerLength do
tinsert(newEntry, "")
end
tinsert(data, newEntry)
frameCanvas.scrollBox:Refresh()
end,
deleteEntry = function(self, button, data, index)
tremove(data, index)
--get the line, get the scrollframe
self:GetParent():GetParent():Refresh()
end,
createScrollLine = function(self, index)
local listBox = self:GetParent()
local line = CreateFrame("frame", self:GetName().. "line_" .. index, self, "BackdropTemplate")
line:SetPoint("topleft", self, "topleft", 1, -((index-1)*(self.lineHeight+1)) - 1)
line:SetSize(self:GetWidth() - 28, self.lineHeight) -- -28 space for the scrollbar
local options = listBox.options
line:SetBackdrop(options.line_backdrop)
line:SetBackdropColor(unpack(options.line_backdrop_color))
DF:Mixin(line, DF.HeaderFunctions)
line.widgets = {}
for i = 1, (listBox.headerLength+1) do --+1 to add the delete button
local headerColumn = listBox.headerTable[i]
if (headerColumn.isDelete) then
local deleteButton = DF:CreateButton(line, DF.ListboxFunctions.deleteEntry, 20, self.lineHeight, "X", listBox.data, index, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", "ORANGE_FONT_TEMPLATE"))
line.deleteButton = deleteButton
line:AddFrameToHeaderAlignment(deleteButton)
elseif (headerColumn.text) then
local template = DF.table.copy({}, DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE"))
template.backdropcolor = {0.1, 0.1, 0.1, .7}
local textEntry = DF:CreateTextEntry(line, function()end, headerColumn.width, self.lineHeight, nil, nil, nil, template)
textEntry:SetHook("OnEditFocusGained", function() textEntry:HighlightText(0) end)
textEntry:SetHook("OnEditFocusLost", function()
textEntry:HighlightText(0, 0)
local text = textEntry.text
local dataTable = textEntry.dataTable
dataTable[textEntry.dataTableIndex] = text
end)
tinsert(line.widgets, textEntry)
line:AddFrameToHeaderAlignment(textEntry)
end
end
line:AlignWithHeader(listBox.header, "left")
return line
end,
}
local listbox_options = {
width = 800,
height = 600,
auto_width = true,
line_height = 16,
line_backdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
line_backdrop_color = {.3, .3, .3, .8},
}
--@parent: parent frame
--@name: name of the frame to be created
--@data: table with current data to fill the column, this table are also used for values changed or added
--@options: table with options to overwrite the default setting from 'listbox_options'
--@header: a table to create a header widget
--@header_options: a table with options to overwrite the default header options
function DF:CreateListBox(parent, name, data, options, headerTable, headerOptions)
options = options or {}
name = name or "ListboxUnamed_" .. (math.random(100000, 1000000))
--canvas
local frameCanvas = CreateFrame("scrollframe", name, parent, "BackdropTemplate")
DF:Mixin(frameCanvas, DF.ListboxFunctions)
DF:Mixin(frameCanvas, DF.OptionsFunctions)
DF:Mixin(frameCanvas, DF.LayoutFrame)
frameCanvas.headerTable = headerTable
if (not data or type(data) ~= "table") then
error("CreateListBox() parameter 3 'data' must be a table.")
end
frameCanvas.data = data
frameCanvas.lines = {}
DF:ApplyStandardBackdrop(frameCanvas)
frameCanvas:BuildOptionsTable(listbox_options, options)
--> header
--check for default values in the header
headerTable = headerTable or {
{text = "Spell Name", width = 70},
{text = "Spell Id", width = 70},
}
headerOptions = headerOptions or {
padding = 2,
}
--each header is an entry in the data, if the header has 4 indexes the data has sub tables with 4 indexes as well
frameCanvas.headerLength = #headerTable
--add the detele line column into the header frame
tinsert(headerTable, {text = "Delete", width = 50, isDelete = true}) --isDelete signals the createScrollLine() to make the delete button for the line
local header = DF:CreateHeader(frameCanvas, headerTable, headerOptions)
--set the header point
header:SetPoint("topleft", frameCanvas, "topleft", 5, -5)
frameCanvas.header = header
--> auto size
if (frameCanvas.options.auto_width) then
local width = 10 --padding 5 on each side
width = width + 20 --scrollbar reserved space
local headerPadding = headerOptions.padding or 0
for _, header in pairs(headerTable) do
if (header.width) then
width = width + header.width + headerPadding
end
end
frameCanvas.options.width = width
frameCanvas:SetWidth(width)
end
local width = frameCanvas.options.width
local height = frameCanvas.options.height
frameCanvas:SetSize(frameCanvas.options.width, height)
--> scroll frame
local lineHeight = frameCanvas.options.line_height
local lineAmount = floor(height / lineHeight)
-- -12 is padding: 5 on top, 7 bottom, 2 header scrollbar blank space | -24 to leave space to the add button
local scrollBox = DF:CreateScrollBox(frameCanvas, "$parentScrollbox", frameCanvas.scrollRefresh, data, width-4, height - header:GetHeight() - 12 - 24, lineAmount, lineHeight)
scrollBox:SetPoint("topleft", header, "bottomleft", 0, -2)
scrollBox:SetPoint("topright", header, "bottomright", 0, -2) -- -20 for the scrollbar
DF:ReskinSlider(scrollBox)
scrollBox.lineHeight = lineHeight
scrollBox.lineAmount = lineAmount
frameCanvas.scrollBox = scrollBox
for i = 1, lineAmount do
scrollBox:CreateLine(frameCanvas.createScrollLine)
end
scrollBox:Refresh()
--> add line button
local addLineButton = DF:CreateButton(frameCanvas, DF.ListboxFunctions.addEntry, 80, 20, "Add", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", "ORANGE_FONT_TEMPLATE"))
addLineButton:SetPoint("topleft", scrollBox, "bottomleft", 0, -4)
return frameCanvas
end
--[=[ -- test case
local pframe = ListBoxTest or CreateFrame("frame", "ListBoxTest", UIParent)
pframe:SetSize(900, 700)
pframe:SetPoint("left")
local data = {{254154, "spell name 1", 45}, {299154, "spell name 2", 05}, {354154, "spell name 3", 99}}
local headerTable = {
{text = "spell id", width = 120},
{text = "spell name", width = 180},
{text = "number", width = 90},
}
local listbox = DetailsFramework:CreateListBox(pframe, "$parentlistbox", data, nil, headerTable, nil)
listbox:SetPoint("topleft", pframe, "topleft", 10, -10)
--]=]
+5
View File
@@ -948,6 +948,11 @@ DF.FoodIDs = {
[308419] = 1, -- (periodicaly damage) Smothered Shank
[327715] = 1, -- (speed) Fried Bonefish
--feasts
[327706] = 2, --strength +20
[327707] = 2, --stamina +20
[327708] = 2, --intellect +20
[327709] = 2, --agility +20
}
DF.PotionIDs = {
+6 -2
View File
@@ -4,8 +4,8 @@
_ = nil
_detalhes = LibStub("AceAddon-3.0"):NewAddon("_detalhes", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "NickTag-1.0")
_detalhes.build_counter = 8154
_detalhes.alpha_build_counter = 8154 --if this is higher than the regular counter, use it instead
_detalhes.build_counter = 8156
_detalhes.alpha_build_counter = 8156 --if this is higher than the regular counter, use it instead
_detalhes.game_version = "v9.0.2"
_detalhes.userversion = "v9.0.2." .. _detalhes.build_counter
_detalhes.realversion = 144 --core version, this is used to check API version for scripts and plugins (see alias below)
@@ -28,6 +28,10 @@ do
local Loc = _G.LibStub("AceLocale-3.0"):GetLocale( "Details" )
local news = {
{"v9.0.2.8156.144", "January 21th, 2021"},
"Added more foods into the Ready Check plugin.",
"Fixed some issues with the coach fearure.",
{"v9.0.2.8154.144", "January 14th, 2021"},
"Added total damage bars into the player list in the Breakdown window.",
"Added 'Square' or 'Roll' mode to Details! Streamer plugin, to change the statusbar mode to Squares, visit the options panel for the plugin.",
+1 -1
View File
@@ -539,7 +539,7 @@ function Details.Coach.WelcomePanel()
hasAssistantsTexture:SetTexCoord(0, 0.5, 0, 0.5)
end
local isInCorrectGroup = false
local isInCorrectGroup = true --debug
for i = 1, numRaidMembers do
local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
if (name == playerName) then
+5 -3
View File
@@ -461,9 +461,11 @@ function Details.packFunctions.PackDamage(combatObject)
local allPlayerNames = {}
for i = 1, 20 do
local name, _, subgroup = GetRaidRosterInfo(i)
name = Ambiguate(name, "none")
if (name and subgroup <= 4) then
tinsert(allPlayerNames, name)
if (name) then --maybe the group has less than 20 players
name = Ambiguate(name, "none")
if (name and subgroup <= 4) then
tinsert(allPlayerNames, name)
end
end
end
table.sort(allPlayerNames, function(t1, t2) return t1 < t2 end)