from retail
This commit is contained in:
@@ -1715,6 +1715,171 @@ function OptionsPrivate.OpenTriggerTemplate(data, targetId)
|
||||
end
|
||||
end
|
||||
|
||||
OptionsPrivate.currentDynamicTextInput = false;
|
||||
|
||||
local BaseDynamicTextCodes = {
|
||||
trigger = {
|
||||
{type = "mini", name = "p", desc = L["Progress - The remaining time of a timer, or a non-timer value"]},
|
||||
{type = "mini", name = "t", desc = L["Total - The maximum duration of a timer, or a maximum non-timer value"]},
|
||||
{type = "mini", name = "n", desc = L["Name - The name of the display (usually an aura name), or the display's ID if there is no dynamic name"]},
|
||||
{type = "mini", name = "i", desc = L["Icon - The icon associated with the display"]},
|
||||
{type = "mini", name = "s", desc = L["Stacks - The number of stacks of an aura (usually)"]},
|
||||
},
|
||||
global = {
|
||||
{type = "mini", name = "c", desc = L["Custom - Allows you to define a custom Lua function that returns a list of string values. %c1 will be replaced by the first value returned, %c2 by the second, etc."]},
|
||||
{type = "mini", name = "%", desc = L["% - To show a percent sign"]},
|
||||
}
|
||||
}
|
||||
|
||||
function OptionsPrivate.UpdateTextReplacements(frame, data)
|
||||
frame.scrollList:ReleaseChildren()
|
||||
|
||||
local props = OptionsPrivate.Private.GetAdditionalProperties(data)
|
||||
local sortedProps = {}
|
||||
|
||||
-- Add global header and markers
|
||||
table.insert(sortedProps, {type = "header", triggerNum = 0, name = "Global Properties"})
|
||||
for index, icon in ipairs(ICON_LIST) do
|
||||
table.insert(sortedProps, {type = "marker", triggerNum = 0, name = "{rt"..index.."}", desc = icon..":0|t", widthFraction = #ICON_LIST})
|
||||
end
|
||||
|
||||
-- Add base dynamic text codes
|
||||
local globalProps = {}
|
||||
tAppendAll(globalProps, CopyTable(BaseDynamicTextCodes.trigger))
|
||||
tAppendAll(globalProps, CopyTable(BaseDynamicTextCodes.global))
|
||||
for _, prop in ipairs(globalProps) do
|
||||
prop.widthFraction = #globalProps
|
||||
prop.triggerNum = 0
|
||||
table.insert(sortedProps, prop)
|
||||
end
|
||||
|
||||
-- Process each trigger's properties
|
||||
for triggerNum, triggerProps in pairs(props) do
|
||||
if next(triggerProps) then
|
||||
-- Create a temporary table for this trigger's properties
|
||||
local tempProps = {}
|
||||
|
||||
-- Add the properties to the temporary table
|
||||
for name, desc in pairs(triggerProps) do
|
||||
table.insert(tempProps, {triggerNum = triggerNum, name = name, desc = desc})
|
||||
end
|
||||
|
||||
-- Sort the temporary table by name
|
||||
table.sort(tempProps, function(a, b)
|
||||
return a.name < b.name
|
||||
end)
|
||||
|
||||
-- Add a header for the trigger
|
||||
table.insert(sortedProps, {type = "header", triggerNum = triggerNum, name = OptionsPrivate.GetTriggerTitle(data, triggerNum)})
|
||||
|
||||
-- Add the base properties for the trigger
|
||||
for _, v in ipairs(BaseDynamicTextCodes.trigger) do
|
||||
local prop = CopyTable(v)
|
||||
prop.widthFraction = #BaseDynamicTextCodes.trigger
|
||||
prop.triggerNum = triggerNum
|
||||
table.insert(sortedProps, prop)
|
||||
end
|
||||
|
||||
-- Add the sorted properties to the sortedProps table
|
||||
for _, prop in ipairs(tempProps) do
|
||||
table.insert(sortedProps, prop)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Create a modified WeakAurasSnippetButton for each property and add it to ScrollList
|
||||
local lastType, miniGroup
|
||||
for i, prop in ipairs(sortedProps) do
|
||||
if prop.type == "header" then
|
||||
local heading = AceGUI:Create("Heading")
|
||||
heading:SetText(prop.name)
|
||||
heading:SetRelativeWidth(1)
|
||||
heading.label:SetFontObject(GameFontNormalSmall)
|
||||
frame.scrollList:AddChild(heading)
|
||||
else
|
||||
if ((prop.type == "mini" or prop.type == "marker") and prop.type ~= lastType)
|
||||
then
|
||||
miniGroup = AceGUI:Create("SimpleGroup")
|
||||
miniGroup:SetLayout("Flow")
|
||||
miniGroup:SetAutoAdjustHeight(true)
|
||||
miniGroup:SetRelativeWidth(1)
|
||||
frame.scrollList:AddChild(miniGroup)
|
||||
end
|
||||
local button = AceGUI:Create("WeakAurasSnippetButton")
|
||||
local propIndex = prop.triggerNum > 0 and ("%s"):format(prop.triggerNum) or ""
|
||||
local propPrefix = prop.triggerNum > 0 and ("%%%s."):format(propIndex) or "%"
|
||||
if prop.type == "marker" then
|
||||
button:SetTitle(prop.desc)
|
||||
else
|
||||
button:SetTitle(string.format("|cFFFFCC00%s|r%s", propPrefix, prop.name))
|
||||
end
|
||||
if prop.type == "mini" or prop.type == "marker" then
|
||||
button:SetRelativeWidth((1/prop.widthFraction) - 1e-10)
|
||||
else
|
||||
button:SetRelativeWidth(1)
|
||||
end
|
||||
button.title:SetFontObject(GameFontNormal)
|
||||
button.frame:SetHeight(28)
|
||||
button:SetDynamicTextStyle()
|
||||
|
||||
-- Set Tooltip
|
||||
if prop.type ~= "marker" then
|
||||
button.frame:SetScript("OnEnter", function(frame)
|
||||
local tooltip = GameTooltip
|
||||
tooltip:SetWidth(300)
|
||||
tooltip:SetOwner(frame, "ANCHOR_RIGHT")
|
||||
tooltip:ClearLines()
|
||||
tooltip:AddLine(("%s%s"):format(propPrefix, prop.name))
|
||||
tooltip:AddLine(prop.desc, 1, 1, 1, true)
|
||||
if prop.name ~= "c" and prop.name ~= "%" then
|
||||
tooltip:AddLine("\n")
|
||||
tooltip:AddLine(
|
||||
prop.triggerNum > 0
|
||||
and L["The trigger number is optional. When no trigger number is specified, the trigger selected via dynamic information will be used."]
|
||||
or L["By default this shows the information from the trigger selected via dynamic information. The information from a specific trigger can be shown via e.g. %2.p."],
|
||||
0.8, 0.8, 0.8,
|
||||
true)
|
||||
end
|
||||
tooltip:Show()
|
||||
frame.obj:Fire("OnEnter")
|
||||
end)
|
||||
else
|
||||
button.frame:SetScript("OnEnter", nil)
|
||||
end
|
||||
|
||||
-- Insert dynamic text property on click
|
||||
button:SetCallback("OnClick", function()
|
||||
local insertProp
|
||||
if prop.type == "marker" then
|
||||
insertProp = prop.name
|
||||
else
|
||||
if IsShiftKeyDown() then
|
||||
insertProp = prop.name == "%" and "%%" or ("%%{%s}"):format(prop.name)
|
||||
if prop.triggerNum > 0 then
|
||||
insertProp = string.format("%%{%d.%s}", propIndex, prop.name)
|
||||
end
|
||||
else
|
||||
insertProp = prop.name == "%" and "%%" or ("%%%s"):format(prop.name)
|
||||
if prop.triggerNum > 0 then
|
||||
insertProp = string.format("%%%d.%s", propIndex, prop.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
OptionsPrivate.currentDynamicTextInput.editbox:Insert(insertProp)
|
||||
OptionsPrivate.currentDynamicTextInput.editbox:SetFocus()
|
||||
end)
|
||||
|
||||
if prop.type == "mini" or prop.type == "marker" then
|
||||
miniGroup:AddChild(button)
|
||||
else
|
||||
frame.scrollList:AddChild(button)
|
||||
end
|
||||
end
|
||||
lastType = prop.type
|
||||
end
|
||||
end
|
||||
|
||||
function OptionsPrivate.ResetMoverSizer()
|
||||
if(frame and frame.mover and frame.moversizer and frame.mover.moving.region and frame.mover.moving.data) then
|
||||
frame.moversizer:SetToRegion(frame.mover.moving.region, frame.mover.moving.data);
|
||||
|
||||
Reference in New Issue
Block a user