More code cleanup and framework update
This commit is contained in:
+1
-1
@@ -1841,7 +1841,7 @@ function DF:CreateCoolTip()
|
||||
end
|
||||
|
||||
--~inicio ~start ~tooltip
|
||||
function gameCooltip:BuildTooltip()
|
||||
function gameCooltip:BuildTooltip() --~refresh
|
||||
--hide select bar
|
||||
gameCooltip:HideSelectedTexture(frame1)
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
local dversion = 442
|
||||
local dversion = 443
|
||||
local major, minor = "DetailsFramework-1.0", dversion
|
||||
local DF, oldminor = LibStub:NewLibrary(major, minor)
|
||||
|
||||
|
||||
+1
-1
@@ -4359,7 +4359,7 @@ function detailsFramework:ApplyStandardBackdrop(frame, bUseSolidColor, alphaScal
|
||||
end
|
||||
|
||||
if (not frame.__background) then
|
||||
frame.__background = frame:CreateTexture(nil, "background")
|
||||
frame.__background = frame:CreateTexture(nil, "border", nil, -6)
|
||||
frame.__background:SetColorTexture(red, green, blue)
|
||||
frame.__background:SetAllPoints()
|
||||
end
|
||||
|
||||
@@ -235,10 +235,33 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.ScriptHookMixin)
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
--object constructor
|
||||
|
||||
---@class df_image : texture
|
||||
---@field SetGradient fun(gradientType: "vertical"|"horizontal", fromColor: table, toColor: table)
|
||||
|
||||
---create an object that encapsulates a texture and add additional methods to it
|
||||
---@param parent frame
|
||||
---@param texture texturepath|textureid
|
||||
---@param width number
|
||||
---@param height number
|
||||
---@param layer drawlayer
|
||||
---@param coords {key1: number, key2: number, key3: number, key4: number}
|
||||
---@param member string
|
||||
---@param name string
|
||||
---@return table|nil
|
||||
function detailsFramework:CreateTexture(parent, texture, width, height, layer, coords, member, name)
|
||||
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
|
||||
end
|
||||
|
||||
---create an object that encapsulates a texture and add additional methods to it
|
||||
---@param parent frame
|
||||
---@param texture texturepath|textureid
|
||||
---@param width number
|
||||
---@param height number
|
||||
---@param layer drawlayer
|
||||
---@param coords {key1: number, key2: number, key3: number, key4: number}
|
||||
---@param member string
|
||||
---@param name string
|
||||
---@return table|nil
|
||||
function detailsFramework:CreateImage(parent, texture, width, height, layer, coords, member, name)
|
||||
return detailsFramework:NewImage(parent, texture, width, height, layer, coords, member, name)
|
||||
end
|
||||
|
||||
@@ -114,6 +114,7 @@
|
||||
---@alias textureid number each texture from the game client has an id.
|
||||
---@alias texturepath string access textures from addons.
|
||||
---@alias unixtime number
|
||||
---@alias valueamount number used to represent a value, such as a damage amount, a healing amount, or a resource amount.
|
||||
|
||||
---@class _G
|
||||
---@field RegisterAttributeDriver fun(statedriver: frame, attribute: string, conditional: string)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
--[[global]] DETAILS_SEGMENTTYPE_RAID_TRASH = 7
|
||||
--[[global]] DETAILS_SEGMENTTYPE_RAID_BOSS = 8
|
||||
|
||||
--[[global]] DETAILS_SEGMENTTYPE_MYTHICDUNGEON = 100
|
||||
--[[global]] DETAILS_SEGMENTTYPE_MYTHICDUNGEON_GENERIC = 10
|
||||
--[[global]] DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH = 11
|
||||
--[[global]] DETAILS_SEGMENTTYPE_MYTHICDUNGEON_OVERALL = 12
|
||||
@@ -295,22 +296,22 @@
|
||||
if (isMythicDungeon) then
|
||||
local isMythicDungeonTrash = self.is_mythic_dungeon_trash
|
||||
if (isMythicDungeonTrash) then
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
|
||||
else
|
||||
local isMythicDungeonOverall = self.is_mythic_dungeon and self.is_mythic_dungeon.OverallSegment
|
||||
local isMythicDungeonTrashOverall = self.is_mythic_dungeon and self.is_mythic_dungeon.TrashOverallSegment
|
||||
if (isMythicDungeonOverall) then
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_OVERALL
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_OVERALL, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
|
||||
elseif (isMythicDungeonTrashOverall) then
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASHOVERALL
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASHOVERALL, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
|
||||
end
|
||||
|
||||
local bossEncounter = self.is_boss
|
||||
if (bossEncounter) then
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSS
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSS, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
|
||||
end
|
||||
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_GENERIC
|
||||
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_GENERIC, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -18,6 +18,24 @@
|
||||
local CONST_PLUGINWINDOW_WIDTH = 925
|
||||
local CONST_PLUGINWINDOW_HEIGHT = 600
|
||||
|
||||
---default cooltip appearance for plugin tooltips
|
||||
function Details:SetCooltipForPlugins()
|
||||
local gameCooltip = GameCooltip
|
||||
gameCooltip:Preset(2)
|
||||
gameCooltip:SetOption("TextSize", Details.font_sizes.menus)
|
||||
gameCooltip:SetOption("TextFont", Details.font_faces.menus)
|
||||
gameCooltip:SetOption("LineHeightSizeOffset", 0)
|
||||
gameCooltip:SetOption("LineYOffset", 0)
|
||||
gameCooltip:SetOption("LinePadding", -1)
|
||||
gameCooltip:SetOption("FrameHeightSizeOffset", 0)
|
||||
gameCooltip:SetOption("FixedWidth", 280)
|
||||
gameCooltip:SetOption("StatusBarTexture", [[Interface\AddOns\Details\images\bar_serenity]])
|
||||
gameCooltip:SetOption("LeftTextWidth", 280 - 22 - 90)
|
||||
gameCooltip:SetOption("LeftTextHeight", 14)
|
||||
Details:SetTooltipMinWidth()
|
||||
end
|
||||
|
||||
|
||||
---comment
|
||||
---@param pluginAbsoluteName string
|
||||
---@return unknown
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
|
||||
|
||||
local Details = _G.Details
|
||||
local DF = _G.DetailsFramework
|
||||
local detailsFramework = _G.DetailsFramework
|
||||
local Loc = LibStub("AceLocale-3.0"):GetLocale("Details")
|
||||
|
||||
--row text editor
|
||||
|
||||
local windowWidth = 950
|
||||
local scrollWidth = 825
|
||||
|
||||
local panel = Details:CreateWelcomePanel ("DetailsWindowOptionsBarTextEditor", nil, windowWidth, 600, true)
|
||||
local panel = Details:CreateWelcomePanel("DetailsWindowOptionsBarTextEditor", nil, windowWidth, 600, true)
|
||||
panel:SetPoint("center", UIParent, "center")
|
||||
panel:Hide()
|
||||
panel:SetFrameStrata("FULLSCREEN")
|
||||
DF:ApplyStandardBackdrop(panel)
|
||||
DF:CreateTitleBar (panel, "Details! Custom Line Text Editor")
|
||||
detailsFramework:ApplyStandardBackdrop(panel)
|
||||
detailsFramework:CreateTitleBar(panel, "Details! Custom Line Text Editor")
|
||||
|
||||
function panel:Open (text, callback, host, default)
|
||||
function panel:Open(text, callback, host, default)
|
||||
if (host) then
|
||||
panel:ClearAllPoints()
|
||||
panel:SetPoint("center", host, "center")
|
||||
end
|
||||
|
||||
|
||||
text = text:gsub("||", "|")
|
||||
panel.default_text = text
|
||||
panel.editbox:SetText(text)
|
||||
@@ -31,47 +28,46 @@ function panel:Open (text, callback, host, default)
|
||||
end
|
||||
|
||||
local y = -32
|
||||
local buttonTemplate = DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")
|
||||
local buttonTemplate = detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")
|
||||
|
||||
local textentry = DF:NewSpecialLuaEditorEntry(panel, scrollWidth, 555, "editbox", "$parentEntry")
|
||||
textentry:SetPoint("topleft", panel, "topleft", 10, y)
|
||||
DF:ApplyStandardBackdrop(textentry)
|
||||
DF:SetFontSize(textentry.editbox, 14)
|
||||
DF:ReskinSlider(textentry.scroll)
|
||||
local codeEditor = detailsFramework:NewSpecialLuaEditorEntry(panel, scrollWidth, 555, "editbox", "$parentEntry")
|
||||
codeEditor:SetPoint("topleft", panel, "topleft", 10, y)
|
||||
detailsFramework:ApplyStandardBackdrop(codeEditor)
|
||||
detailsFramework:SetFontSize(codeEditor.editbox, 14)
|
||||
detailsFramework:ReskinSlider(codeEditor.scroll)
|
||||
|
||||
local arg1_button = DF:NewButton(panel, nil, "$parentButton1", nil, 80, 20, function() textentry.editbox:Insert ("{data1}") end, nil, nil, nil, string.format(Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "1"), 1)
|
||||
local arg2_button = DF:NewButton(panel, nil, "$parentButton2", nil, 80, 20, function() textentry.editbox:Insert ("{data2}") end, nil, nil, nil, string.format(Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "2"), 1)
|
||||
local arg3_button = DF:NewButton(panel, nil, "$parentButton3", nil, 80, 20, function() textentry.editbox:Insert ("{data3}") end, nil, nil, nil, string.format(Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "3"), 1)
|
||||
arg1_button:SetPoint("topright", panel, "topright", -12, y)
|
||||
arg2_button:SetPoint("topright", panel, "topright", -12, y - (20*1))
|
||||
arg3_button:SetPoint("topright", panel, "topright", -12, y - (20*2))
|
||||
arg1_button:SetTemplate(buttonTemplate)
|
||||
arg2_button:SetTemplate(buttonTemplate)
|
||||
arg3_button:SetTemplate(buttonTemplate)
|
||||
|
||||
arg1_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
|
||||
arg2_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
|
||||
arg3_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
|
||||
local arg1Button = detailsFramework:NewButton(panel, nil, "$parentButton1", nil, 80, 20, function() codeEditor.editbox:Insert("{data1}") end, nil, nil, nil, string.format(Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "1"), 1)
|
||||
local arg2Button = detailsFramework:NewButton(panel, nil, "$parentButton2", nil, 80, 20, function() codeEditor.editbox:Insert("{data2}") end, nil, nil, nil, string.format(Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "2"), 1)
|
||||
local arg3Button = detailsFramework:NewButton(panel, nil, "$parentButton3", nil, 80, 20, function() codeEditor.editbox:Insert("{data3}") end, nil, nil, nil, string.format(Loc ["STRING_OPTIONS_TEXTEDITOR_DATA"], "3"), 1)
|
||||
arg1Button:SetPoint("topright", panel, "topright", -12, y)
|
||||
arg2Button:SetPoint("topright", panel, "topright", -12, y -(20*1))
|
||||
arg3Button:SetPoint("topright", panel, "topright", -12, y -(20*2))
|
||||
arg1Button:SetTemplate(buttonTemplate)
|
||||
arg2Button:SetTemplate(buttonTemplate)
|
||||
arg3Button:SetTemplate(buttonTemplate)
|
||||
arg1Button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
|
||||
arg2Button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
|
||||
arg3Button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DATA_TOOLTIP"]
|
||||
|
||||
-- code author Saiket from http://www.wowinterface.com/forums/showpost.php?p=245759&postcount=6
|
||||
--- @return StartPos, EndPos of highlight in this editbox.
|
||||
local function GetTextHighlight ( self )
|
||||
local function GetTextHighlight( self )
|
||||
local Text, Cursor = self:GetText(), self:GetCursorPosition();
|
||||
self:Insert( "" ); -- Delete selected text
|
||||
local TextNew, CursorNew = self:GetText(), self:GetCursorPosition();
|
||||
-- Restore previous text
|
||||
self:SetText( Text );
|
||||
self:SetCursorPosition( Cursor );
|
||||
local Start, End = CursorNew, #Text - ( #TextNew - CursorNew );
|
||||
local Start, End = CursorNew, #Text -( #TextNew - CursorNew );
|
||||
self:HighlightText( Start, End );
|
||||
return Start, End;
|
||||
end
|
||||
|
||||
|
||||
local StripColors;
|
||||
do
|
||||
local CursorPosition, CursorDelta;
|
||||
--- Callback for gsub to remove unescaped codes.
|
||||
local function StripCodeGsub ( Escapes, Code, End )
|
||||
local function StripCodeGsub( Escapes, Code, End )
|
||||
if ( #Escapes % 2 == 0 ) then -- Doesn't escape Code
|
||||
if ( CursorPosition and CursorPosition >= End - 1 ) then
|
||||
CursorDelta = CursorDelta - #Code;
|
||||
@@ -80,14 +76,14 @@ do
|
||||
end
|
||||
end
|
||||
--- Removes a single escape sequence.
|
||||
local function StripCode ( Pattern, Text, OldCursor )
|
||||
local function StripCode( Pattern, Text, OldCursor )
|
||||
CursorPosition, CursorDelta = OldCursor, 0;
|
||||
return Text:gsub( Pattern, StripCodeGsub ), OldCursor and CursorPosition + CursorDelta;
|
||||
end
|
||||
--- Strips Text of all color escape sequences.
|
||||
-- @param Cursor Optional cursor position to keep track of.
|
||||
-- @return Stripped text, and the updated cursor position if Cursor was given.
|
||||
function StripColors ( Text, Cursor )
|
||||
function StripColors( Text, Cursor )
|
||||
Text, Cursor = StripCode( "(|*)(|c%x%x%x%x%x%x%x%x)()", Text, Cursor );
|
||||
return StripCode( "(|*)(|r)()", Text, Cursor );
|
||||
end
|
||||
@@ -95,7 +91,7 @@ end
|
||||
|
||||
local COLOR_END = "|r";
|
||||
--- Wraps this editbox's selected text with the given color.
|
||||
local function ColorSelection ( self, ColorCode )
|
||||
local function ColorSelection( self, ColorCode )
|
||||
local Start, End = GetTextHighlight( self );
|
||||
local Text, Cursor = self:GetText(), self:GetCursorPosition();
|
||||
if ( Start == End ) then -- Nothing selected
|
||||
@@ -107,7 +103,7 @@ local function ColorSelection ( self, ColorCode )
|
||||
if ( End < #Text ) then -- There is text to color after the selection
|
||||
local ActiveEnd;
|
||||
local CodeEnd, _, Escapes, Color = 0;
|
||||
while ( true ) do
|
||||
while( true ) do
|
||||
_, CodeEnd, Escapes, Color = Text:find( "(|*)(|c%x%x%x%x%x%x%x%x)", CodeEnd + 1 );
|
||||
if ( not CodeEnd or CodeEnd > End ) then
|
||||
break;
|
||||
@@ -116,11 +112,11 @@ local function ColorSelection ( self, ColorCode )
|
||||
ActiveColor, ActiveEnd = Color, CodeEnd;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if ( ActiveColor ) then
|
||||
-- Check if color gets terminated before selection ends
|
||||
CodeEnd = 0;
|
||||
while ( true ) do
|
||||
while( true ) do
|
||||
_, CodeEnd, Escapes = Text:find( "(|*)|r", CodeEnd + 1 );
|
||||
if ( not CodeEnd or CodeEnd > End ) then
|
||||
break;
|
||||
@@ -132,17 +128,17 @@ local function ColorSelection ( self, ColorCode )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local Selection = Text:sub( Start + 1, End );
|
||||
-- Remove color codes from the selection
|
||||
local Replacement, CursorReplacement = StripColors( Selection, Cursor - Start );
|
||||
|
||||
self:SetText( ( "" ):join(
|
||||
|
||||
self:SetText(( "" ):join(
|
||||
Text:sub( 1, Start ),
|
||||
ColorCode, Replacement, COLOR_END,
|
||||
ActiveColor or "", Text:sub( End + 1 )
|
||||
) );
|
||||
|
||||
|
||||
-- Restore cursor and highlight, adjusting for wrapper text
|
||||
Cursor = Start + CursorReplacement;
|
||||
if ( CursorReplacement > 0 ) then -- Cursor beyond start of color code
|
||||
@@ -151,48 +147,48 @@ local function ColorSelection ( self, ColorCode )
|
||||
if ( CursorReplacement >= #Replacement ) then -- Cursor beyond end of color
|
||||
Cursor = Cursor + #COLOR_END;
|
||||
end
|
||||
|
||||
|
||||
self:SetCursorPosition( Cursor );
|
||||
-- Highlight selection and wrapper
|
||||
self:HighlightText( Start, #ColorCode + ( #Replacement - #Selection ) + #COLOR_END + End );
|
||||
end
|
||||
|
||||
local color_func = function(_, r, g, b, a)
|
||||
local hex = Details:hex (a*255)..Details:hex (r*255)..Details:hex (g*255)..Details:hex (b*255)
|
||||
ColorSelection ( textentry.editbox, "|c" .. hex)
|
||||
local colorFunc = function(_, r, g, b, a)
|
||||
local hex = Details:hex(a * 255) .. Details:hex(r * 255) .. Details:hex(g * 255) .. Details:hex(b * 255)
|
||||
ColorSelection(codeEditor.editbox, "|c" .. hex)
|
||||
end
|
||||
|
||||
local func_button = DF:NewButton(panel, nil, "$parentButton4", nil, 80, 20, function() textentry.editbox:Insert ("{func local player, combat = ...; return 0;}") end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_FUNC"], 1)
|
||||
local color_button = DF:NewColorPickButton (panel, "$parentButton5", nil, color_func)
|
||||
color_button:SetSize(80, 20)
|
||||
color_button:SetTemplate(buttonTemplate)
|
||||
local funcButton = detailsFramework:NewButton(panel, nil, "$parentButton4", nil, 80, 20, function() codeEditor.editbox:Insert("{func local player, combat = ...; return 0;}") end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_FUNC"], 1)
|
||||
local colorButton = detailsFramework:NewColorPickButton(panel, "$parentButton5", nil, colorFunc)
|
||||
colorButton:SetSize(80, 20)
|
||||
colorButton:SetTemplate(buttonTemplate)
|
||||
|
||||
func_button:SetPoint("topright", panel, "topright", -12, y - (20*3))
|
||||
func_button:SetTemplate(buttonTemplate)
|
||||
funcButton:SetPoint("topright", panel, "topright", -12, y -(20*3))
|
||||
funcButton:SetTemplate(buttonTemplate)
|
||||
|
||||
color_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_COLOR_TOOLTIP"]
|
||||
func_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_FUNC_TOOLTIP"]
|
||||
colorButton.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_COLOR_TOOLTIP"]
|
||||
funcButton.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_FUNC_TOOLTIP"]
|
||||
local done = function()
|
||||
local text = panel.editbox:GetText()
|
||||
panel.callback (text)
|
||||
panel.callback(text)
|
||||
panel:Hide()
|
||||
end
|
||||
|
||||
local apply_button = DF:NewButton(panel, nil, "$parentApply", nil, 80, 20, function() panel.callback(panel.editbox:GetText()) end, nil, nil, nil, "Apply", 1) --localize-me
|
||||
apply_button:SetTemplate(buttonTemplate)
|
||||
apply_button:SetPoint("topright", panel, "topright", -14, -128)
|
||||
local applyButton = detailsFramework:NewButton(panel, nil, "$parentApply", nil, 80, 20, function() panel.callback(panel.editbox:GetText()) end, nil, nil, nil, "Apply", 1) --localize-me
|
||||
applyButton:SetTemplate(buttonTemplate)
|
||||
applyButton:SetPoint("topright", panel, "topright", -14, -128)
|
||||
|
||||
local ok_button = DF:NewButton(panel, nil, "$parentButtonOk", nil, 80, 20, done, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_DONE"], 1)
|
||||
ok_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DONE_TOOLTIP"]
|
||||
ok_button:SetTemplate(buttonTemplate)
|
||||
ok_button:SetPoint("topright", panel, "topright", -14, -194)
|
||||
local okButton = detailsFramework:NewButton(panel, nil, "$parentButtonOk", nil, 80, 20, done, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_DONE"], 1)
|
||||
okButton.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_DONE_TOOLTIP"]
|
||||
okButton:SetTemplate(buttonTemplate)
|
||||
okButton:SetPoint("topright", panel, "topright", -14, -194)
|
||||
|
||||
local reset_button = DF:NewButton(panel, nil, "$parentDefaultOk", nil, 80, 20, function() textentry.editbox:SetText(panel.default); panel.callback(panel.editbox:GetText()) end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_RESET"], 1)
|
||||
reset_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_RESET_TOOLTIP"]
|
||||
reset_button:SetTemplate(buttonTemplate)
|
||||
reset_button:SetPoint("topright", panel, "topright", -14, -150)
|
||||
local resetButton = detailsFramework:NewButton(panel, nil, "$parentDefaultOk", nil, 80, 20, function() codeEditor.editbox:SetText(panel.default); panel.callback(panel.editbox:GetText()) end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_RESET"], 1)
|
||||
resetButton.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_RESET_TOOLTIP"]
|
||||
resetButton:SetTemplate(buttonTemplate)
|
||||
resetButton:SetPoint("topright", panel, "topright", -14, -150)
|
||||
|
||||
local cancel_button = DF:NewButton(panel, nil, "$parentDefaultCancel", nil, 80, 20, function() textentry.editbox:SetText(panel.default_text); done(); end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL"], 1)
|
||||
cancel_button.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL_TOOLTIP"]
|
||||
cancel_button:SetTemplate(buttonTemplate)
|
||||
cancel_button:SetPoint("topright", panel, "topright", -14, -172)
|
||||
local cancelButton = detailsFramework:NewButton(panel, nil, "$parentDefaultCancel", nil, 80, 20, function() codeEditor.editbox:SetText(panel.default_text); done(); end, nil, nil, nil, Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL"], 1)
|
||||
cancelButton.tooltip = Loc ["STRING_OPTIONS_TEXTEDITOR_CANCEL_TOOLTIP"]
|
||||
cancelButton:SetTemplate(buttonTemplate)
|
||||
cancelButton:SetPoint("topright", panel, "topright", -14, -172)
|
||||
+83
-100
@@ -1,13 +1,11 @@
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
local _detalhes = _G.Details
|
||||
local Details = _G.Details
|
||||
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
|
||||
local _
|
||||
local addonName, Details222 = ...
|
||||
|
||||
--Event types:
|
||||
_detalhes.RegistredEvents = {
|
||||
Details.RegistredEvents = {
|
||||
--instances
|
||||
["DETAILS_INSTANCE_OPEN"] = {},
|
||||
["DETAILS_INSTANCE_CLOSE"] = {},
|
||||
@@ -69,10 +67,10 @@
|
||||
["COMM_EVENT_SENT"] = {}, --added on core 129
|
||||
}
|
||||
|
||||
local function AlreadyRegistred (_tables, _object)
|
||||
local function isAlreadyRegistred(_tables, _object)
|
||||
for index, _this_object in ipairs(_tables) do
|
||||
if (_this_object.__eventtable) then
|
||||
if (_this_object [1] == _object) then
|
||||
if (_this_object[1] == _object) then
|
||||
return index
|
||||
end
|
||||
elseif (_this_object == _object) then
|
||||
@@ -131,23 +129,22 @@ local common_events = {
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--register a event
|
||||
|
||||
function _detalhes:RegisterEvent(object, event, func)
|
||||
|
||||
if (not _detalhes.RegistredEvents [event]) then
|
||||
function Details:RegisterEvent(object, event, func)
|
||||
if (not Details.RegistredEvents[event]) then
|
||||
if (object.Msg) then
|
||||
object:DelayMsg ("[debug] unknown event:", event, object.__name)
|
||||
object:DelayMsg("[debug] unknown event:", event, object.__name)
|
||||
else
|
||||
_detalhes:DelayMsg ("[debug] unknown event:", event, object.__name)
|
||||
Details:DelayMsg("[debug] unknown event:", event, object.__name)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if (common_events [event]) then
|
||||
if (not AlreadyRegistred (_detalhes.RegistredEvents [event], object)) then
|
||||
if (common_events[event]) then
|
||||
if (not isAlreadyRegistred(Details.RegistredEvents[event], object)) then
|
||||
if (func) then
|
||||
tinsert(_detalhes.RegistredEvents [event], {object, func, __eventtable = true})
|
||||
table.insert(Details.RegistredEvents[event], {object, func, __eventtable = true})
|
||||
else
|
||||
tinsert(_detalhes.RegistredEvents [event], object)
|
||||
table.insert(Details.RegistredEvents[event], object)
|
||||
end
|
||||
return true
|
||||
else
|
||||
@@ -155,29 +152,29 @@ local common_events = {
|
||||
end
|
||||
else
|
||||
if (event == "BUFF_UPDATE") then
|
||||
if (not AlreadyRegistred (_detalhes.RegistredEvents ["BUFF_UPDATE"], object)) then
|
||||
if (not isAlreadyRegistred(Details.RegistredEvents["BUFF_UPDATE"], object)) then
|
||||
if (func) then
|
||||
tinsert(_detalhes.RegistredEvents ["BUFF_UPDATE"], {object, func, __eventtable = true})
|
||||
table.insert(Details.RegistredEvents["BUFF_UPDATE"], {object, func, __eventtable = true})
|
||||
else
|
||||
tinsert(_detalhes.RegistredEvents ["BUFF_UPDATE"], object)
|
||||
table.insert(Details.RegistredEvents["BUFF_UPDATE"], object)
|
||||
end
|
||||
_detalhes.Buffs:CatchBuffs()
|
||||
_detalhes.RecordPlayerSelfBuffs = true
|
||||
_detalhes:UpdateParserGears()
|
||||
Details.Buffs:CatchBuffs()
|
||||
Details.RecordPlayerSelfBuffs = true
|
||||
Details:UpdateParserGears()
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
elseif (event == "BUFF_UPDATE_DEBUFFPOWER") then
|
||||
if (not AlreadyRegistred (_detalhes.RegistredEvents ["BUFF_UPDATE_DEBUFFPOWER"], object)) then
|
||||
if (not isAlreadyRegistred(Details.RegistredEvents["BUFF_UPDATE_DEBUFFPOWER"], object)) then
|
||||
if (func) then
|
||||
tinsert(_detalhes.RegistredEvents ["BUFF_UPDATE_DEBUFFPOWER"], {object, func, __eventtable = true})
|
||||
table.insert(Details.RegistredEvents["BUFF_UPDATE_DEBUFFPOWER"], {object, func, __eventtable = true})
|
||||
else
|
||||
tinsert(_detalhes.RegistredEvents ["BUFF_UPDATE_DEBUFFPOWER"], object)
|
||||
table.insert(Details.RegistredEvents["BUFF_UPDATE_DEBUFFPOWER"], object)
|
||||
end
|
||||
_detalhes.RecordPlayerAbilityWithBuffs = true
|
||||
_detalhes:UpdateParserGears()
|
||||
Details.RecordPlayerAbilityWithBuffs = true
|
||||
Details:UpdateParserGears()
|
||||
return true
|
||||
else
|
||||
return false
|
||||
@@ -189,33 +186,32 @@ local common_events = {
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--Unregister a Event
|
||||
|
||||
function _detalhes:UnregisterEvent (object, event)
|
||||
|
||||
if (not _detalhes.RegistredEvents [event]) then
|
||||
function Details:UnregisterEvent(object, event)
|
||||
if (not Details.RegistredEvents[event]) then
|
||||
if (object.Msg) then
|
||||
object:Msg("(debug) unknown event", event)
|
||||
else
|
||||
_detalhes:Msg("(debug) unknown event", event)
|
||||
Details:Msg("(debug) unknown event", event)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if (common_events [event]) then
|
||||
local index = AlreadyRegistred (_detalhes.RegistredEvents [event], object)
|
||||
if (common_events[event]) then
|
||||
local index = isAlreadyRegistred(Details.RegistredEvents[event], object)
|
||||
if (index) then
|
||||
table.remove (_detalhes.RegistredEvents [event], index)
|
||||
table.remove(Details.RegistredEvents[event], index)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
if (event == "BUFF_UPDATE") then
|
||||
local index = AlreadyRegistred (_detalhes.RegistredEvents ["BUFF_UPDATE"], object)
|
||||
local index = isAlreadyRegistred(Details.RegistredEvents["BUFF_UPDATE"], object)
|
||||
if (index) then
|
||||
table.remove (_detalhes.RegistredEvents ["BUFF_UPDATE"], index)
|
||||
if (#_detalhes.RegistredEvents ["BUFF_UPDATE"] < 1) then
|
||||
_detalhes.RecordPlayerSelfBuffs = true
|
||||
_detalhes:UpdateParserGears()
|
||||
table.remove(Details.RegistredEvents["BUFF_UPDATE"], index)
|
||||
if (#Details.RegistredEvents["BUFF_UPDATE"] < 1) then
|
||||
Details.RecordPlayerSelfBuffs = true
|
||||
Details:UpdateParserGears()
|
||||
end
|
||||
return true
|
||||
else
|
||||
@@ -223,12 +219,12 @@ local common_events = {
|
||||
end
|
||||
|
||||
elseif (event == "BUFF_UPDATE_DEBUFFPOWER") then
|
||||
local index = AlreadyRegistred (_detalhes.RegistredEvents ["BUFF_UPDATE_DEBUFFPOWER"], object)
|
||||
local index = isAlreadyRegistred(Details.RegistredEvents["BUFF_UPDATE_DEBUFFPOWER"], object)
|
||||
if (index) then
|
||||
table.remove (_detalhes.RegistredEvents ["BUFF_UPDATE_DEBUFFPOWER"], index)
|
||||
if (#_detalhes.RegistredEvents ["BUFF_UPDATE_DEBUFFPOWER"] < 1) then
|
||||
_detalhes.RecordPlayerAbilityWithBuffs = false
|
||||
_detalhes:UpdateParserGears()
|
||||
table.remove(Details.RegistredEvents["BUFF_UPDATE_DEBUFFPOWER"], index)
|
||||
if (#Details.RegistredEvents["BUFF_UPDATE_DEBUFFPOWER"] < 1) then
|
||||
Details.RecordPlayerAbilityWithBuffs = false
|
||||
Details:UpdateParserGears()
|
||||
end
|
||||
return true
|
||||
else
|
||||
@@ -242,11 +238,11 @@ local common_events = {
|
||||
--internal functions
|
||||
|
||||
local dispatch_error = function(name, errortext)
|
||||
_detalhes:Msg((name or "<no context>"), " |cFFFF9900error|r: ", errortext)
|
||||
Details:Msg((name or "<no context>"), " |cFFFF9900error|r: ", errortext)
|
||||
end
|
||||
|
||||
--safe call an external func with payload and without telling who is calling
|
||||
function _detalhes:QuickDispatchEvent (func, event, ...)
|
||||
function Details:QuickDispatchEvent(func, event, ...)
|
||||
if (type(func) ~= "function") then
|
||||
return
|
||||
elseif (type(event) ~= "string") then
|
||||
@@ -257,7 +253,7 @@ local common_events = {
|
||||
|
||||
if (not okay) then
|
||||
--trigger an error msg
|
||||
dispatch_error (_, errortext)
|
||||
dispatch_error(_, errortext)
|
||||
|
||||
return
|
||||
end
|
||||
@@ -266,11 +262,13 @@ local common_events = {
|
||||
end
|
||||
|
||||
--quick dispatch with context, send the caller object within the payload
|
||||
function _detalhes:QuickDispatchEventWithContext (context, func, event, ...)
|
||||
function Details:QuickDispatchEventWithContext(context, func, event, ...)
|
||||
if (type(context) ~= "table") then
|
||||
return
|
||||
|
||||
elseif (type(func) ~= "function") then
|
||||
return
|
||||
|
||||
elseif (type(event) ~= "string") then
|
||||
return
|
||||
end
|
||||
@@ -281,8 +279,7 @@ local common_events = {
|
||||
--attempt to get the context name
|
||||
local objectName = context.__name or context._name or context.name or context.Name
|
||||
--trigger an error msg
|
||||
dispatch_error (objectName, errortext)
|
||||
|
||||
dispatch_error(objectName, errortext)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -290,119 +287,105 @@ local common_events = {
|
||||
end
|
||||
|
||||
--Send Event
|
||||
function _detalhes:SendEvent(event, object, ...)
|
||||
|
||||
function Details:SendEvent(event, object, ...)
|
||||
--send event to all registred plugins
|
||||
|
||||
if (event == "PLUGIN_DISABLED" or event == "PLUGIN_ENABLED") then
|
||||
return object:OnDetailsEvent (event, ...)
|
||||
return object:OnDetailsEvent(event, ...)
|
||||
|
||||
elseif (not object) then
|
||||
--iterate among all plugins which registered a function for this event
|
||||
for _, PluginObject in ipairs(_detalhes.RegistredEvents[event]) do
|
||||
|
||||
for _, PluginObject in ipairs(Details.RegistredEvents[event]) do
|
||||
--when __eventtable is true, the plugin registered a function or method name to callback
|
||||
--if is false, we call OnDetailsEvent method on the plugin
|
||||
if (PluginObject.__eventtable) then
|
||||
|
||||
local pluginTable = PluginObject [1]
|
||||
local pluginTable = PluginObject[1]
|
||||
|
||||
--check if the plugin is enabled
|
||||
if (pluginTable.Enabled and pluginTable.__enabled) then
|
||||
|
||||
--check if fegistered a function
|
||||
if (type(PluginObject [2]) == "function") then
|
||||
local func = PluginObject [2]
|
||||
_detalhes:QuickDispatchEvent (func, event, ...)
|
||||
--PluginObject [2] (event, ...)
|
||||
|
||||
if (type(PluginObject[2]) == "function") then
|
||||
local func = PluginObject[2]
|
||||
Details:QuickDispatchEvent(func, event, ...)
|
||||
--if not it must be a method name
|
||||
else
|
||||
local methodName = PluginObject [2]
|
||||
local func = pluginTable [methodName]
|
||||
|
||||
_detalhes:QuickDispatchEventWithContext (pluginTable, func, event, ...)
|
||||
--PluginObject [1] [PluginObject [2]] (PluginObject, event, ...)
|
||||
local methodName = PluginObject[2]
|
||||
local func = pluginTable[methodName]
|
||||
Details:QuickDispatchEventWithContext(pluginTable, func, event, ...)
|
||||
end
|
||||
end
|
||||
|
||||
--if no function(only registred the event) sent the event to OnDetailsEvent
|
||||
else
|
||||
if (PluginObject.Enabled and PluginObject.__enabled) then
|
||||
_detalhes:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event, ...)
|
||||
--PluginObject:OnDetailsEvent (event, ...)
|
||||
Details:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--plugin notifications (does not send to listeners)
|
||||
elseif (type(object) == "string" and object == "SEND_TO_ALL") then
|
||||
|
||||
for _, PluginObject in ipairs(_detalhes.RaidTables.Plugins) do
|
||||
for _, PluginObject in ipairs(Details.RaidTables.Plugins) do
|
||||
if (PluginObject.__enabled) then
|
||||
_detalhes:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event)
|
||||
--PluginObject:OnDetailsEvent (event)
|
||||
Details:QuickDispatchEventWithContext(PluginObject, PluginObject.OnDetailsEvent, event)
|
||||
end
|
||||
end
|
||||
|
||||
for _, PluginObject in ipairs(_detalhes.SoloTables.Plugins) do
|
||||
for _, PluginObject in ipairs(Details.SoloTables.Plugins) do
|
||||
if (PluginObject.__enabled) then
|
||||
_detalhes:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event)
|
||||
--PluginObject:OnDetailsEvent (event)
|
||||
Details:QuickDispatchEventWithContext(PluginObject, PluginObject.OnDetailsEvent, event)
|
||||
end
|
||||
end
|
||||
|
||||
for _, PluginObject in ipairs(_detalhes.ToolBar.Plugins) do
|
||||
for _, PluginObject in ipairs(Details.ToolBar.Plugins) do
|
||||
if (PluginObject.__enabled) then
|
||||
_detalhes:QuickDispatchEventWithContext (PluginObject, PluginObject.OnDetailsEvent, event)
|
||||
--PluginObject:OnDetailsEvent (event)
|
||||
Details:QuickDispatchEventWithContext(PluginObject, PluginObject.OnDetailsEvent, event)
|
||||
end
|
||||
end
|
||||
else
|
||||
--send the event only for requested plugin
|
||||
if (object.Enabled and object.__enabled) then
|
||||
return _detalhes:QuickDispatchEventWithContext (object, object.OnDetailsEvent, event, ...)
|
||||
--return object:OnDetailsEvent (event, ...)
|
||||
return Details:QuickDispatchEventWithContext(object, object.OnDetailsEvent, event, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--special cases
|
||||
function _detalhes:SendOptionsModifiedEvent (instance)
|
||||
|
||||
_detalhes.last_options_modified = _detalhes.last_options_modified or (GetTime() - 5)
|
||||
|
||||
if (_detalhes.last_options_modified + 0.3 < GetTime()) then
|
||||
_detalhes:SendEvent("DETAILS_OPTIONS_MODIFIED", nil, instance)
|
||||
_detalhes.last_options_modified = GetTime()
|
||||
if (_detalhes.last_options_modified_schedule) then
|
||||
_detalhes:CancelTimer(_detalhes.last_options_modified_schedule)
|
||||
_detalhes.last_options_modified_schedule = nil
|
||||
function Details:SendOptionsModifiedEvent(instance)
|
||||
Details.last_options_modified = Details.last_options_modified or (GetTime() - 5)
|
||||
if (Details.last_options_modified + 0.3 < GetTime()) then
|
||||
Details:SendEvent("DETAILS_OPTIONS_MODIFIED", nil, instance)
|
||||
Details.last_options_modified = GetTime()
|
||||
if (Details.last_options_modified_schedule) then
|
||||
Details:CancelTimer(Details.last_options_modified_schedule)
|
||||
Details.last_options_modified_schedule = nil
|
||||
end
|
||||
else
|
||||
if (_detalhes.last_options_modified_schedule) then
|
||||
_detalhes:CancelTimer(_detalhes.last_options_modified_schedule)
|
||||
if (Details.last_options_modified_schedule) then
|
||||
Details:CancelTimer(Details.last_options_modified_schedule)
|
||||
end
|
||||
_detalhes.last_options_modified_schedule = _detalhes:ScheduleTimer("SendOptionsModifiedEvent", 0.31, instance)
|
||||
Details.last_options_modified_schedule = Details:ScheduleTimer("SendOptionsModifiedEvent", 0.31, instance)
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--listeners
|
||||
|
||||
local listener_meta = setmetatable({}, _detalhes)
|
||||
local listener_meta = setmetatable({}, Details)
|
||||
listener_meta.__index = listener_meta
|
||||
|
||||
function listener_meta:RegisterEvent(event, func)
|
||||
return _detalhes:RegisterEvent(self, event, func)
|
||||
end
|
||||
function listener_meta:UnregisterEvent (event)
|
||||
return _detalhes:UnregisterEvent (self, event)
|
||||
return Details:RegisterEvent(self, event, func)
|
||||
end
|
||||
|
||||
function _detalhes:CreateEventListener()
|
||||
function listener_meta:UnregisterEvent(event)
|
||||
return Details:UnregisterEvent(self, event)
|
||||
end
|
||||
|
||||
function Details:CreateEventListener()
|
||||
local new = {Enabled = true, __enabled = true}
|
||||
setmetatable(new, listener_meta)
|
||||
return new
|
||||
end
|
||||
end
|
||||
+183
-160
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user