diff --git a/Libs/DF/button.lua b/Libs/DF/button.lua index 4cf3c313..942c43ff 100644 --- a/Libs/DF/button.lua +++ b/Libs/DF/button.lua @@ -211,27 +211,7 @@ detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin) --texture local smember_texture = function(object, value) - if (type(value) == "table") then - local value1, value2, value3, value4 = unpack(value) - if (value1) then - object.button:SetNormalTexture(value1) - end - if (value2) then - object.button:SetHighlightTexture(value2, "ADD") - end - if (value3) then - object.button:SetPushedTexture(value3) - end - if (value4) then - object.button:SetDisabledTexture(value4) - end - else - object.button:SetNormalTexture(value) - object.button:SetHighlightTexture(value, "ADD") - object.button:SetPushedTexture(value) - object.button:SetDisabledTexture(value) - end - return + return detailsFramework:SetButtonTexture(object, value, 0, 1, 0, 1) end --locked @@ -1120,7 +1100,14 @@ end return colorPickButton end - function detailsFramework:SetRegularButtonTexture(button, texture, left, right, top, bottom) + ---set the texture of all 4 textures of a button to the same texture + ---@param button button + ---@param texture textureid|texturepath + ---@param left coordleft|table|nil + ---@param right coordright|nil + ---@param top coordtop|nil + ---@param bottom coordbottom|nil + function detailsFramework:SetButtonTexture(button, texture, left, right, top, bottom) if (type(left) == "table") then left, right, top, bottom = unpack(left) end @@ -1132,23 +1119,54 @@ end local atlas if (type(texture) == "string") then atlas = C_Texture.GetAtlasInfo(texture) - end + end - local normalTexture = button:GetNormalTexture() - local pushedTexture = button:GetPushedTexture() - local highlightTexture = button:GetHightlightTexture() - local disabledTexture = button:GetDisabledTexture() + local normalTexture = button:GetNormalTexture() + local pushedTexture = button:GetPushedTexture() + local highlightTexture = button:GetHightlightTexture() + local disabledTexture = button:GetDisabledTexture() + + if (type(texture) == "table") then + local normalTexturePath, pushedTexturePath, highlightTexturePath, disabledTexturePath = unpack(texture) + ---@cast right number + ---@cast top number + ---@cast bottom number + + if (normalTexturePath) then + normalTexture:SetTexture(normalTexturePath) + normalTexture:SetTexCoord(left, right, top, bottom) + end + + if (pushedTexturePath) then + pushedTexture:SetTexture(pushedTexturePath) + pushedTexture:SetTexCoord(left, right, top, bottom) + end + + if (highlightTexturePath) then + highlightTexture:SetTexture(highlightTexturePath) + highlightTexture:SetTexCoord(left, right, top, bottom) + end + + if (disabledTexturePath) then + disabledTexture:SetTexture(disabledTexturePath) + disabledTexture:SetTexCoord(left, right, top, bottom) + end + + elseif (atlas) then + normalTexture:SetAtlas(atlas) + pushedTexture:SetAtlas(atlas) + highlightTexture:SetAtlas(atlas) + disabledTexture:SetAtlas(atlas) - if (atlas) then - normalTexture:SetAtlas(texture) - pushedTexture:SetAtlas(texture) - highlightTexture:SetAtlas(texture) - disabledTexture:SetAtlas(texture) else normalTexture:SetTexture(texture) pushedTexture:SetTexture(texture) highlightTexture:SetTexture(texture) disabledTexture:SetTexture(texture) + + ---@cast right number + ---@cast top number + ---@cast bottom number normalTexture:SetTexCoord(left, right, top, bottom) pushedTexture:SetTexCoord(left, right, top, bottom) highlightTexture:SetTexCoord(left, right, top, bottom) @@ -1156,17 +1174,23 @@ end end end - function detailsFramework:SetRegularButtonVertexColor(button, ...) - local r, g, b, a = detailsFramework:ParseColor(...) + ---set the vertex color of all 4 textures of a button to the same color + ---@param button button + ---@param red any + ---@param green number|nil + ---@param blue number|nil + ---@param alpha number|nil + function detailsFramework:SetButtonVertexColor(button, red, green, blue, alpha) + red, green, blue, alpha = detailsFramework:ParseColor(red, green, blue, alpha) local normalTexture = button:GetNormalTexture() local pushedTexture = button:GetPushedTexture() local highlightTexture = button:GetHightlightTexture() local disabledTexture = button:GetDisabledTexture() - normalTexture:SetVertexColor(r, g, b, a) - pushedTexture:SetVertexColor(r, g, b, a) - highlightTexture:SetVertexColor(r, g, b, a) - disabledTexture:SetVertexColor(r, g, b, a) + normalTexture:SetVertexColor(red, green, blue, alpha) + pushedTexture:SetVertexColor(red, green, blue, alpha) + highlightTexture:SetVertexColor(red, green, blue, alpha) + disabledTexture:SetVertexColor(red, green, blue, alpha) end @@ -1187,10 +1211,12 @@ end ---@field rightTextureSelectedName string ---@field middleTextureSelectedName string ---@field bIsSelected boolean ----@field SetText fun(self: df_tabbutton, text: string) ----@field SetSelected fun(self: df_tabbutton, selected: boolean) ----@field IsSelected fun(self: df_tabbutton): boolean ----@field Reset fun(self: df_tabbutton) +---@field SetText fun(self: df_tabbutton, text: string) --set the tab text +---@field SetSelected fun(self: df_tabbutton, selected: boolean) --highlight the tab textures to indicate the tab is selected +---@field SetShowCloseButton fun(self: df_tabbutton, show: boolean) --set if the close button can be shown or not +---@field GetFontString fun(self: df_tabbutton) : fontstring --get the fontstring used to display the tab text +---@field IsSelected fun(self: df_tabbutton): boolean --get a boolean representing if the tab is selected +---@field Reset fun(self: df_tabbutton) --set all textures to their default values, set the text to an empty string, set the selected state to false detailsFramework.TabButtonMixin = { ---set the text of the tab button @@ -1214,6 +1240,13 @@ detailsFramework.TabButtonMixin = { self.bIsSelected = selected end, + ---set if the close button can be shown or not + ---@param self df_tabbutton + ---@param show boolean + SetShowCloseButton = function(self, show) + self.CloseButton:SetShown(show) + end, + ---get a boolean representing if the tab is selected ---@param self df_tabbutton ---@return boolean @@ -1232,6 +1265,12 @@ detailsFramework.TabButtonMixin = { self.SelectedTexture:Hide() end, + ---get the fontstring used to display the tab text + ---@param self df_tabbutton + ---@return fontstring + GetFontString = function(self) + return self.Text + end, } ---create a button which can be used as a tab button, has textures for left, right, middle and a text @@ -1255,6 +1294,9 @@ function detailsFramework:CreateTabButton(parent, frameName) tabButton.SelectedTexture:Hide() tabButton.Text = tabButton:CreateFontString(nil, "overlay", "GameFontNormal") tabButton.CloseButton = detailsFramework:CreateCloseButton(tabButton, "$parentCloseButton") + tabButton.CloseButton:SetSize(10, 10) + tabButton.CloseButton:SetAlpha(0.6) + tabButton.CloseButton:Hide() tabButton.Text:SetPoint("center", tabButton, "center", 0, 0) tabButton.CloseButton:SetPoint("topright", tabButton, "topright", 0, 0) @@ -1294,6 +1336,38 @@ function detailsFramework:CreateTabButton(parent, frameName) return tabButton end +--[=[ + --example: + local frame = CreateFrame("frame", "MyTestFrameForTabutton", UIParent) + frame:SetSize(650, 100) + frame:SetPoint("center", UIParent, "center", 0, 0) + DetailsFramework:ApplyStandardBackdrop(frame) + frame.TabButtons = {} + + local tabOnClickCallback = function(self) + for _, tab in ipairs(frame.TabButtons) do + tab:SetSelected(false) + end + self:SetSelected(true) + end + + for i = 1, 5 do + local tabButton = DetailsFramework:CreateTabButton(frame, "$parentTabButton" .. i) + tabButton:SetPoint("bottomleft", frame, "topleft", (i-1) * 130, 0) + tabButton:SetText("Tab " .. i) + tabButton:SetWidth(128) + + table.insert(frame.TabButtons, tabButton) + tabButton:SetScript("OnClick", tabOnClickCallback) + end + + --select a tab to be the default selected (if wanted) + frame.TabButtons[1]:SetSelected(true) + + --set shown state of the close button (if wanted) + frame.TabButtons[2]:SetShowCloseButton(true) +--]=] + ------------------------------------------------------------------------------------------------------------ --close button @@ -1301,9 +1375,11 @@ detailsFramework.CloseButtonMixin = { OnClick = function(self) self:GetParent():Hide() end, + OnEnter = function(self) self:GetNormalTexture():SetVertexColor(1, 0, 0) end, + OnLeave = function(self) self:GetNormalTexture():SetVertexColor(1, 1, 1) end, @@ -1318,7 +1394,7 @@ detailsFramework.CloseButtonMixin = { ---@param parent frame ---@param frameName string|nil ---@return df_closebutton -function detailsFramework:CreateCloseButton(parent, frameName) --make documentation +function detailsFramework:CreateCloseButton(parent, frameName) ---@type df_closebutton local closeButton = CreateFrame("button", frameName, parent, "UIPanelCloseButton") closeButton:SetFrameLevel(parent:GetFrameLevel() + 1) diff --git a/Libs/LibLuaServer/LibLuaServer.lua b/Libs/LibLuaServer/LibLuaServer.lua index 6b5c09a2..b1918907 100644 --- a/Libs/LibLuaServer/LibLuaServer.lua +++ b/Libs/LibLuaServer/LibLuaServer.lua @@ -392,7 +392,7 @@ ---@field RegisterForClicks fun(self: button, button1: nil|buttontype, button2: nil|buttontype, button3: nil|buttontype, button4: nil|buttontype) ---@field GetNormalTexture fun(self: button) : texture ---@field GetPushedTexture fun(self: button) : texture ----@field GetHighlightTexture fun(self: button) : texture +---@field GetHightlightTexture fun(self: button) : texture ---@field GetDisabledTexture fun(self: button) : texture ---@class statusbar : frame @@ -471,7 +471,7 @@ ---@class texture : region ---@field SetDrawLayer fun(self: texture, layer: drawlayer, subLayer: number|nil) ----@field SetTexture fun(self: texture, path: string, horizontalWrap: texturewrap|nil, verticalWrap: texturewrap|nil, filter: texturefilter|nil) +---@field SetTexture fun(self: texture, path: textureid|texturepath, horizontalWrap: texturewrap|nil, verticalWrap: texturewrap|nil, filter: texturefilter|nil) ---@field SetAtlas fun(self: texture, atlas: string) ---@field SetColorTexture fun(self: texture, r: red|number, g: green|number, b: blue|number, a: alpha|number|nil) ---@field SetDesaturated fun(self: texture, desaturate: boolean) diff --git a/core/parser.lua b/core/parser.lua index 99d716d2..956cd760 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -199,6 +199,7 @@ breath_targets = {}, flyaway = {}, flyaway_timer = {}, + shield = {}, } local empower_cache = {} @@ -1257,6 +1258,31 @@ end end + if (spellId == 360828 and augmentation_cache.shield[sourceSerial]) then --shield + ---actor buffed with the shield -> list of evokers whose buffed + ---@type table + local currentlyBuffedWithShield = augmentation_cache.shield[sourceSerial] + + for i, evokerInfo in ipairs(currentlyBuffedWithShield) do + ---@cast evokerInfo evokerinfo + + ---@type serial, actorname, controlflags + local evokerSourceSerial, evokerSourceName, evokerSourceFlags = unpack(evokerInfo) + + ---@type actor + local evokerActor = damage_cache[evokerSourceSerial] + + if (not evokerActor) then + evokerActor = _current_damage_container:PegarCombatente(evokerSourceSerial, evokerSourceName, evokerSourceFlags, true) + end + + if (evokerActor) then + local damageSplitted = amount / #currentlyBuffedWithShield + evokerActor.total_extra = evokerActor.total_extra + damageSplitted + end + end + end + if (spellId == 404908 and augmentation_cache.prescience[sourceSerial]) then --fate mirror ---actor buffed with prescience -> list of evokers whose buffed ---@type table @@ -2610,6 +2636,12 @@ table.insert(breathTargets, eonsBreathInfo) end end + + elseif (spellId == 360827) then + augmentation_cache.shield[targetSerial] = augmentation_cache.shield[targetSerial] or {} + ---@type evokerinfo + local evokerInfo = {sourceSerial, sourceName, sourceFlags, amount} + table.insert(augmentation_cache.shield[targetSerial], evokerInfo) end if (buffs_makeyourown[spellId]) then @@ -3025,6 +3057,16 @@ end end end + + elseif (spellid == 360827) then + if (augmentation_cache.shield[targetSerial]) then + for index, evokerInfo in ipairs(augmentation_cache.shield[targetSerial]) do + if (evokerInfo[1] == sourceSerial) then + table.remove(augmentation_cache.shield[targetSerial], index) + break + end + end + end end if (buffs_makeyourown[spellid]) then @@ -6425,6 +6467,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 Details:Destroy(augmentation_cache.ebon_might) --~roskash Details:Destroy(augmentation_cache.prescience) Details:Destroy(augmentation_cache.breath_targets) + Details:Destroy(augmentation_cache.shield) cacheAnything.track_hunter_frenzy = Details.combat_log.track_hunter_frenzy diff --git a/plugins/Details_EncounterDetails/Libs/DF/.gitignore b/plugins/Details_EncounterDetails/Libs/DF/.gitignore deleted file mode 100644 index df44e95e..00000000 --- a/plugins/Details_EncounterDetails/Libs/DF/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ - -background.blp -border_1.blp -border_2.blp -border_3.blp -cooltip_background.blp -feedback_sites.blp -icons.blp -mail.blp -*.json -CHANGES.txt diff --git a/plugins/Details_EncounterDetails/Libs/DF/DFPixelUtil.lua b/plugins/Details_EncounterDetails/Libs/DF/DFPixelUtil.lua deleted file mode 100644 index e59fe6a2..00000000 --- a/plugins/Details_EncounterDetails/Libs/DF/DFPixelUtil.lua +++ /dev/null @@ -1,66 +0,0 @@ -DFPixelUtil = {}; - -function DFPixelUtil.GetPixelToUIUnitFactor() - local physicalWidth, physicalHeight = GetPhysicalScreenSize(); - return 768.0 / physicalHeight; -end - -function DFPixelUtil.GetNearestPixelSize(uiUnitSize, layoutScale, minPixels) - if uiUnitSize == 0 and (not minPixels or minPixels == 0) then - return 0; - end - - local uiUnitFactor = DFPixelUtil.GetPixelToUIUnitFactor(); - local numPixels = Round((uiUnitSize * layoutScale) / uiUnitFactor); - local rawNumPixels = numPixels; - if minPixels then - if uiUnitSize < 0.0 then - if numPixels > -minPixels then - numPixels = -minPixels; - end - else - if numPixels < minPixels then - numPixels = minPixels; - end - end - end - - return numPixels * uiUnitFactor / layoutScale; -end - -function DFPixelUtil.SetWidth(region, width, minPixels) - region:SetWidth(DFPixelUtil.GetNearestPixelSize(width, region:GetEffectiveScale(), minPixels)); -end - -function DFPixelUtil.SetHeight(region, height, minPixels) - region:SetHeight(DFPixelUtil.GetNearestPixelSize(height, region:GetEffectiveScale(), minPixels)); -end - -function DFPixelUtil.SetSize(region, width, height, minWidthPixels, minHeightPixels) - DFPixelUtil.SetWidth(region, width, minWidthPixels); - DFPixelUtil.SetHeight(region, height, minHeightPixels); -end - -function DFPixelUtil.SetPoint(region, point, relativeTo, relativePoint, offsetX, offsetY, minOffsetXPixels, minOffsetYPixels) - region:SetPoint(point, relativeTo, relativePoint, - DFPixelUtil.GetNearestPixelSize(offsetX, region:GetEffectiveScale(), minOffsetXPixels), - DFPixelUtil.GetNearestPixelSize(offsetY, region:GetEffectiveScale(), minOffsetYPixels) - ); -end - -function DFPixelUtil.SetStatusBarValue(statusBar, value) - local width = statusBar:GetWidth(); - if width and width > 0.0 then - local min, max = statusBar:GetMinMaxValues(); - local percent = ClampedPercentageBetween(value, min, max); - if percent == 0.0 or percent == 1.0 then - statusBar:SetValue(value); - else - local numPixels = DFPixelUtil.GetNearestPixelSize(statusBar:GetWidth() * percent, statusBar:GetEffectiveScale()); - local roundedValue = Lerp(min, max, numPixels / width); - statusBar:SetValue(roundedValue); - end - else - statusBar:SetValue(value); - end -end diff --git a/plugins/Details_EncounterDetails/Libs/DF/LibDFramework-1.0.toc b/plugins/Details_EncounterDetails/Libs/DF/LibDFramework-1.0.toc deleted file mode 100644 index 4c8166cc..00000000 --- a/plugins/Details_EncounterDetails/Libs/DF/LibDFramework-1.0.toc +++ /dev/null @@ -1,5 +0,0 @@ -## Interface: 100100 -## Title: Lib: LibDFramework-1.0 -## Notes: Base Framework for many Addons - -load.xml diff --git a/plugins/Details_EncounterDetails/Libs/DF/addon.lua b/plugins/Details_EncounterDetails/Libs/DF/addon.lua deleted file mode 100644 index d1af8ee0..00000000 --- a/plugins/Details_EncounterDetails/Libs/DF/addon.lua +++ /dev/null @@ -1,132 +0,0 @@ - -local DF = _G ["DetailsFramework"] -local _ - -if (not DF or not DetailsFrameworkCanLoad) then - return -end - ---runs when the addon received addon_loaded -local addonPreLoad = function(addonFrame, event, ...) - --check if the saved variables table is created, if not create one - _G[addonFrame.__savedVarsName] = _G[addonFrame.__savedVarsName] or {} - - if (addonFrame.__savedVarsDefaultTemplate) then - --load saved vars for this character - DF.SavedVars.LoadSavedVarsForPlayer(addonFrame) - end - - if (addonFrame.OnLoad) then - DF:Dispatch(addonFrame.OnLoad, addonFrame, ...) - end -end - ---runs when the addon received player_login -local addonInit = function(addonFrame, event, ...) - if (addonFrame.OnInit) then - DF:Dispatch(addonFrame.OnInit, addonFrame, ...) - end -end - ---when the player logout or reloadUI -local addonUnload = function(addonFrame, event, ...) - --close saved tables - DF.SavedVars.CloseSavedTable(addonFrame.db) -end - -local addonEvents = { - ["ADDON_LOADED"] = addonPreLoad, - ["PLAYER_LOGIN"] = addonInit, - ["PLAYER_LOGOUT"] = addonUnload, -} - -local addonOnEvent = function(addonFrame, event, ...) - local func = addonEvents[event] - if (func) then - func(addonFrame, event, ...) - else - --might be a registered event from the user - if (addonFrame[event]) then - DF:CoreDispatch(addonFrame.__name, addonFrame[event], addonFrame, event, ...) - end - end -end - -local getAddonName = function(addonFrame) - return addonFrame:GetName() -end - -function DF:CreateNewAddOn(addonName, globalSavedVariablesName, savedVarsTemplate) - local newAddon = CreateFrame("frame", addonName, UIParent) - newAddon.__name = addonName - newAddon.__savedVarsName = globalSavedVariablesName - newAddon.__savedVarsDefaultTemplate = savedVarsTemplate - - newAddon.GetAddonName = getAddonName - - newAddon:RegisterEvent("ADDON_LOADED") - newAddon:RegisterEvent("PLAYER_LOGIN") - newAddon:RegisterEvent("PLAYER_LOGOUT") - newAddon:SetScript("OnEvent", addonOnEvent) - - return newAddon -end - - - - ---old create addon -function DF:CreateAddOn (name, global_saved, global_table, options_table, broker) - - local addon = LibStub("AceAddon-3.0"):NewAddon (name, "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "DetailsFramework-1.0", "AceComm-3.0") - _G [name] = addon - addon.__name = name - - function addon:OnInitialize() - - if (global_saved) then - if (broker and broker.Minimap and not global_table.Minimap) then - DF:Msg(name, "broker.Minimap is true but no global.Minimap declared.") - end - self.db = LibStub("AceDB-3.0"):New (global_saved, global_table or {}, true) - end - - if (options_table) then - LibStub("AceConfig-3.0"):RegisterOptionsTable (name, options_table) - addon.OptionsFrame1 = LibStub("AceConfigDialog-3.0"):AddToBlizOptions (name, name) - - LibStub("AceConfig-3.0"):RegisterOptionsTable (name .. "-Profiles", LibStub("AceDBOptions-3.0"):GetOptionsTable (self.db)) - addon.OptionsFrame2 = LibStub("AceConfigDialog-3.0"):AddToBlizOptions (name .. "-Profiles", "Profiles", name) - end - - if (broker) then - local broker_click_function = broker.OnClick - if (not broker_click_function and options_table) then - broker_click_function = function() - InterfaceOptionsFrame_OpenToCategory (name) - InterfaceOptionsFrame_OpenToCategory (name) - end - end - - local databroker = LibStub("LibDataBroker-1.1"):NewDataObject (name, { - type = broker.type or "launcher", - icon = broker.icon or [[Interface\PvPRankBadges\PvPRank15]], - text = broker.text or "", - OnTooltipShow = broker.OnTooltipShow, - OnClick = broker_click_function - }) - - if (databroker and broker.Minimap and global_table.Minimap) then - LibStub("LibDBIcon-1.0"):Register (name, databroker, addon.db.profile.Minimap) - end - end - - if (addon.OnInit) then - xpcall(addon.OnInit, geterrorhandler(), addon) - end - - end - - return addon - -end diff --git a/plugins/Details_EncounterDetails/Libs/DF/auras.lua b/plugins/Details_EncounterDetails/Libs/DF/auras.lua deleted file mode 100644 index 941141b4..00000000 --- a/plugins/Details_EncounterDetails/Libs/DF/auras.lua +++ /dev/null @@ -1,1282 +0,0 @@ - -local DF = _G ["DetailsFramework"] -if (not DF or not DetailsFrameworkCanLoad) then - return -end - -local _ -local tinsert = tinsert -local GetSpellInfo = GetSpellInfo -local lower = string.lower -local GetSpellBookItemInfo = GetSpellBookItemInfo - -local CONST_MAX_SPELLS = 450000 - -function DF:GetAuraByName (unit, spellName, isDebuff) - isDebuff = isDebuff and "HARMFUL|PLAYER" - - for i = 1, 40 do - local name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll = UnitAura (unit, i, isDebuff) - if (not name) then - return - end - - if (name == spellName) then - return name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll - end - end -end - -local default_text_for_aura_frame = { - AUTOMATIC = "Automatic", - MANUAL = "Manual", - METHOD = "Aura Tracking Method:", - BUFFS_IGNORED = "Buffs Ignored", - DEBUFFS_IGNORED = "Debuffs Ignored", - BUFFS_TRACKED = "Buffs Tracked", - DEBUFFS_TRACKED = "Debuffs Tracked", - - AUTOMATIC_DESC = "Auras are being tracked automatically, the addon controls what to show.\nYou may add auras to the blacklist or add extra auras to track.", - MANUAL_DESC = "Auras are being tracked manually, the addon only check for auras you entered below.", - - MANUAL_ADD_BLACKLIST_BUFF = "Add Buff to Blacklist", - MANUAL_ADD_BLACKLIST_DEBUFF = "Add Debuff to Blacklist", - MANUAL_ADD_TRACKLIST_BUFF = "Add Buff to Tracklist", - MANUAL_ADD_TRACKLIST_DEBUFF = "Add Debuff to Tracklist", -} - -function DF:LoadAllSpells (hashMap, indexTable, allSpellsSameName) - - --pre checking which tables to fill to avoid checking if the table exists during the gigantic loop for performance - - if (not DF.LoadingAuraAlertFrame) then - DF.LoadingAuraAlertFrame = CreateFrame("frame", "DetailsFrameworkLoadingAurasAlert", UIParent, "BackdropTemplate") - DF.LoadingAuraAlertFrame:SetSize(340, 75) - DF.LoadingAuraAlertFrame:SetPoint("center") - DF.LoadingAuraAlertFrame:SetFrameStrata("TOOLTIP") - DF:ApplyStandardBackdrop(DF.LoadingAuraAlertFrame) - DF.LoadingAuraAlertFrame:SetBackdropBorderColor(1, 0.8, 0.1) - - DF.LoadingAuraAlertFrame.IsLoadingLabel1 = DF:CreateLabel(DF.LoadingAuraAlertFrame, "We are currently loading spell names and spell IDs") - DF.LoadingAuraAlertFrame.IsLoadingLabel2 = DF:CreateLabel(DF.LoadingAuraAlertFrame, "This may take only a few seconds") - DF.LoadingAuraAlertFrame.IsLoadingImage1 = DF:CreateImage(DF.LoadingAuraAlertFrame, [[Interface\DialogFrame\UI-Dialog-Icon-AlertOther]], 32, 32) - DF.LoadingAuraAlertFrame.IsLoadingLabel1.align = "center" - DF.LoadingAuraAlertFrame.IsLoadingLabel2.align = "center" - - DF.LoadingAuraAlertFrame.IsLoadingLabel1:SetPoint("center", 16, 10) - DF.LoadingAuraAlertFrame.IsLoadingLabel2:SetPoint("center", 16, -5) - DF.LoadingAuraAlertFrame.IsLoadingImage1:SetPoint("left", 10, 0) - end - - DF.LoadingAuraAlertFrame:Show() - - C_Timer.After(0, function() - if (hashMap and not indexTable) then - for i = 1, CONST_MAX_SPELLS do - local spellName = GetSpellInfo(i) - if (spellName) then - hashMap [lower (spellName)] = i - end - end - - elseif (not hashMap and indexTable) then - for i = 1, CONST_MAX_SPELLS do - local spellName = GetSpellInfo(i) - if (spellName) then - indexTable [#indexTable+1] = lower (spellName) - end - end - - elseif (hashMap and indexTable) then - if (allSpellsSameName) then - for i = 1, CONST_MAX_SPELLS do - local spellName = GetSpellInfo(i) - if (spellName) then - spellName = lower (spellName) - indexTable [#indexTable + 1] = spellName - hashMap [spellName] = i - - --same name table - local sameNameTable = allSpellsSameName [spellName] - if (not sameNameTable) then - sameNameTable = {} - allSpellsSameName [spellName] = sameNameTable - end - sameNameTable [#sameNameTable + 1] = i - end - end - else - for i = 1, CONST_MAX_SPELLS do - local spellName = GetSpellInfo(i) - if (spellName) then - spellName = lower (spellName) - indexTable [#indexTable + 1] = spellName - hashMap [spellName] = i - end - end - end - end - - DF.LoadingAuraAlertFrame:Hide() - end) - -end - -local cleanfunction = function() end - -do - local metaPrototype = { - WidgetType = "aura_tracker", - dversion = DF.dversion, - } - - --check if there's a metaPrototype already existing - if (_G[DF.GlobalWidgetControlNames["aura_tracker"]]) then - --get the already existing metaPrototype - local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["aura_tracker"]] - --check if is older - if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then - --the version is older them the currently loading one - --copy the new values into the old metatable - for funcName, _ in pairs(metaPrototype) do - oldMetaPrototype[funcName] = metaPrototype[funcName] - end - end - else - --first time loading the framework - _G[DF.GlobalWidgetControlNames["aura_tracker"]] = metaPrototype - end -end - -local AuraTrackerMetaFunctions = _G[DF.GlobalWidgetControlNames["aura_tracker"]] -DF:Mixin(AuraTrackerMetaFunctions, DF.ScriptHookMixin) - ---create panels -local on_profile_changed = function(self, newdb) - - self.db = newdb - - --automatic - self.buff_ignored:DoSetData (newdb.aura_tracker.buff_banned) - self.debuff_ignored:DoSetData (newdb.aura_tracker.debuff_banned) - self.buff_tracked:DoSetData (newdb.aura_tracker.buff_tracked) - self.debuff_tracked:DoSetData (newdb.aura_tracker.debuff_tracked) - - self.buff_ignored:DoRefresh() - self.debuff_ignored:DoRefresh() - self.buff_tracked:DoRefresh() - self.debuff_tracked:DoRefresh() - - --manual - self.buffs_added:SetData (newdb.aura_tracker.buff) - self.debuffs_added:SetData (newdb.aura_tracker.debuff) - self.buffs_added:Refresh() - self.debuffs_added:Refresh() - - --method - if (newdb.aura_tracker.track_method == 0x1) then - self.f_auto:Show() - self.f_manual:Hide() - - self.AutomaticTrackingCheckbox:SetValue(true) - self.ManualTrackingCheckbox:SetValue(false) - self.desc_label.text = self.LocTexts.AUTOMATIC_DESC - - elseif (newdb.aura_tracker.track_method == 0x2) then - self.f_auto:Hide() - self.f_manual:Show() - - self.AutomaticTrackingCheckbox:SetValue(false) - self.ManualTrackingCheckbox:SetValue(true) - self.desc_label.text = self.LocTexts.MANUAL_DESC - end -end - -local aura_panel_defaultoptions = { - height = 400, - row_height = 18, - width = 230, - button_text_template = "OPTIONS_FONT_TEMPLATE" -} - -function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, texts) - - local options_text_template = DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE") - local options_dropdown_template = DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE") - local options_switch_template = DF:GetTemplate("switch", "OPTIONS_CHECKBOX_TEMPLATE") - local options_slider_template = DF:GetTemplate("slider", "OPTIONS_SLIDER_TEMPLATE") - local options_button_template = DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE") - - local f = CreateFrame("frame", name, parent, "BackdropTemplate") - f.db = db - f.OnProfileChanged = on_profile_changed - f.LocTexts = texts - options = options or {} - self.table.deploy(options, aura_panel_defaultoptions) - - local f_auto = CreateFrame("frame", "$parent_Automatic", f, "BackdropTemplate") - local f_manual = CreateFrame("frame", "$parent_Manual", f, "BackdropTemplate") - f_auto:SetPoint("topleft", f, "topleft", 0, -24) - f_manual:SetPoint("topleft", f, "topleft", 0, -24) - f_auto:SetSize(600, 600) - f_manual:SetSize(600, 600) - f.f_auto = f_auto - f.f_manual = f_manual - - --check if the texts table is valid and also deploy default values into the table in case some value is nil - texts = (type(texts == "table") and texts) or default_text_for_aura_frame - DF.table.deploy(texts, default_text_for_aura_frame) - - ------------- - - local on_switch_tracking_method = function(self) - local method = self.Method - - f.db.aura_tracker.track_method = method - if (change_callback) then - DF:QuickDispatch(change_callback) - end - - if (method == 0x1) then - f_auto:Show() - f_manual:Hide() - f.AutomaticTrackingCheckbox:SetValue(true) - f.ManualTrackingCheckbox:SetValue(false) - f.desc_label.text = texts.AUTOMATIC_DESC - - elseif (method == 0x2) then - f_auto:Hide() - f_manual:Show() - f.AutomaticTrackingCheckbox:SetValue(false) - f.ManualTrackingCheckbox:SetValue(true) - f.desc_label.text = texts.MANUAL_DESC - end - end - - local background_method_selection = CreateFrame("frame", nil, f, "BackdropTemplate") - background_method_selection:SetHeight(82) - background_method_selection:SetPoint("topleft", f, "topleft", 0, 0) - background_method_selection:SetPoint("topright", f, "topright", 0, 0) - DF:ApplyStandardBackdrop(background_method_selection) - - local tracking_method_label = self:CreateLabel(background_method_selection, texts.METHOD, 12, "orange") - tracking_method_label:SetPoint("topleft", background_method_selection, "topleft", 6, -4) - - f.desc_label = self:CreateLabel(background_method_selection, "", 10, "silver") - f.desc_label:SetPoint("left", background_method_selection, "left", 130, 0) - f.desc_label:SetJustifyV ("top") - - local automatic_tracking_checkbox = DF:CreateSwitch(background_method_selection, on_switch_tracking_method, f.db.aura_tracker.track_method == 0x1, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE")) - automatic_tracking_checkbox.Method = 0x1 - automatic_tracking_checkbox:SetAsCheckBox() - automatic_tracking_checkbox:SetSize(24, 24) - f.AutomaticTrackingCheckbox = automatic_tracking_checkbox - - local automatic_tracking_label = DF:CreateLabel(background_method_selection, "Automatic") - automatic_tracking_label:SetPoint("left", automatic_tracking_checkbox, "right", 2, 0) - - local manual_tracking_checkbox = DF:CreateSwitch(background_method_selection, on_switch_tracking_method, f.db.aura_tracker.track_method == 0x2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE")) - manual_tracking_checkbox.Method = 0x2 - manual_tracking_checkbox:SetAsCheckBox() - manual_tracking_checkbox:SetSize(24, 24) - f.ManualTrackingCheckbox = manual_tracking_checkbox - - local manual_tracking_label = DF:CreateLabel(background_method_selection, "Manual") - manual_tracking_label:SetPoint("left", manual_tracking_checkbox, "right", 2, 0) - - automatic_tracking_checkbox:SetPoint("topleft", tracking_method_label, "bottomleft", 0, -6) - manual_tracking_checkbox:SetPoint("topleft", automatic_tracking_checkbox, "bottomleft", 0, -6) - - --------- anchors points - - local y = -110 - --------- automatic - - --manual add the buff and ebuff names - local AllSpellsMap = {} - local AllSpellNames = {} - - --store a table with spell name as key and in the value an index table with spell IDs - local AllSpellsSameName = {} - - local load_all_spells = function(self, capsule) - if (not next (AllSpellsMap)) then - DF:LoadAllSpells (AllSpellsMap, AllSpellNames, AllSpellsSameName) - - f_auto.AddBuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames - f_auto.AddDebuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames - f_auto.AddBuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames - f_auto.AddDebuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames - - f_manual.NewBuffTextBox.SpellAutoCompleteList = AllSpellNames - f_manual.NewDebuffTextBox.SpellAutoCompleteList = AllSpellNames - - -- - - f_auto.AddBuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") - f_auto.AddDebuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") - f_auto.AddBuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") - f_auto.AddDebuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") - - f_manual.NewBuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList") - f_manual.NewDebuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList") - - -- - - f_auto.AddBuffBlacklistTextBox.ShouldOptimizeAutoComplete = true - f_auto.AddDebuffBlacklistTextBox.ShouldOptimizeAutoComplete = true - f_auto.AddBuffTracklistTextBox.ShouldOptimizeAutoComplete = true - f_auto.AddDebuffTracklistTextBox.ShouldOptimizeAutoComplete = true - - f_manual.NewBuffTextBox.ShouldOptimizeAutoComplete = true - f_manual.NewDebuffTextBox.ShouldOptimizeAutoComplete = true - end - end - - --this set the width of the background box, text entry and button - local textEntryWidth = 120 - - --create the background - local background_add_blacklist = CreateFrame("frame", nil, f_auto, "BackdropTemplate") - background_add_blacklist:SetSize(textEntryWidth + 10, 135) - DF:ApplyStandardBackdrop(background_add_blacklist) - background_add_blacklist.__background:SetVertexColor(0.47, 0.27, 0.27) - - local background_add_tracklist = CreateFrame("frame", nil, f_auto, "BackdropTemplate") - background_add_tracklist:SetSize(textEntryWidth + 10, 135) - DF:ApplyStandardBackdrop(background_add_tracklist) - background_add_tracklist.__background:SetVertexColor(0.27, 0.27, 0.47) - - --black list - --create labels - local buff_blacklist_label = self:CreateLabel(background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_BUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) - local debuff_blacklist_label = self:CreateLabel(background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_DEBUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) - - local buff_name_blacklist_entry = self:CreateTextEntry(background_add_blacklist, function()end, textEntryWidth, 20, "AddBuffBlacklistTextBox", _, _, options_dropdown_template) - buff_name_blacklist_entry:SetHook("OnEditFocusGained", load_all_spells) - buff_name_blacklist_entry:SetJustifyH("left") - buff_name_blacklist_entry.tooltip = "Enter the buff name using lower case letters." - f_auto.AddBuffBlacklistTextBox = buff_name_blacklist_entry - - local debuff_name_blacklist_entry = self:CreateTextEntry(background_add_blacklist, function()end, textEntryWidth, 20, "AddDebuffBlacklistTextBox", _, _, options_dropdown_template) - debuff_name_blacklist_entry:SetHook("OnEditFocusGained", load_all_spells) - debuff_name_blacklist_entry:SetJustifyH("left") - debuff_name_blacklist_entry.tooltip = "Enter the debuff name using lower case letters." - f_auto.AddDebuffBlacklistTextBox = debuff_name_blacklist_entry - - local same_name_spells_add = function(spellID, t) - local spellName = GetSpellInfo(spellID) - if (spellName) then - if (not next (AllSpellsMap)) then - load_all_spells() - end - - spellName = lower (spellName) - local spellWithSameName = AllSpellsSameName [spellName] - if (spellWithSameName) then - if (t) then - t [spellName] = DF.table.copy({}, spellWithSameName) - else - db.aura_cache_by_name [spellName] = DF.table.copy({}, spellWithSameName) - end - end - end - end - DF.AddSpellWithSameName = same_name_spells_add - - local get_spellID_from_string = function(text) - --check if the user entered a spell ID - local isSpellID = tonumber(text) - if (isSpellID and isSpellID > 1 and isSpellID < 10000000) then - local isValidSpellID = GetSpellInfo(isSpellID) - if (isValidSpellID) then - return isSpellID - else - return - end - end - - --get the spell ID from the spell name - text = lower (text) - local spellID = AllSpellsMap [text] - if (not spellID) then - return - end - - return spellID - end - - local add_blacklist_buff_button = self:CreateButton(background_add_blacklist, function() - local text = buff_name_blacklist_entry.text - buff_name_blacklist_entry:SetText("") - buff_name_blacklist_entry:ClearFocus() - - if (text ~= "") then - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - --add the spellName to the blacklist - f.db.aura_tracker.buff_banned [spellId] = true - - --refresh the buff blacklist frame - f.buff_ignored:DoRefresh() - - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - - end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - local add_blacklist_buff_button_id = self:CreateButton(background_add_blacklist, function() - local text = buff_name_blacklist_entry.text - buff_name_blacklist_entry:SetText("") - buff_name_blacklist_entry:ClearFocus() - - if (text ~= "") then - if (not tonumber(text)) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") - end - - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - --add the spellId to the blacklist - f.db.aura_tracker.buff_banned [spellId] = false - - --refresh the buff blacklist frame - f.buff_ignored:DoRefresh() - - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - - end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - local add_blacklist_debuff_button = self:CreateButton(background_add_blacklist, function() - local text = debuff_name_blacklist_entry.text - debuff_name_blacklist_entry:SetText("") - debuff_name_blacklist_entry:ClearFocus() - - if (text ~= "") then - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - --add the spellName to the blacklist - f.db.aura_tracker.debuff_banned [spellId] = true - - --refresh the buff blacklist frame - f.debuff_ignored:DoRefresh() - - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - local add_blacklist_debuff_button_id = self:CreateButton(background_add_blacklist, function() - local text = debuff_name_blacklist_entry.text - debuff_name_blacklist_entry:SetText("") - debuff_name_blacklist_entry:ClearFocus() - - if (text ~= "") then - if (not tonumber(text)) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") - end - - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - --add the spellId to the blacklist - f.db.aura_tracker.debuff_banned [spellId] = false - - --refresh the buff blacklist frame - f.debuff_ignored:DoRefresh() - - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - - --track list - local buff_tracklist_label = self:CreateLabel(background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_BUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) - local debuff_tracklist_label = self:CreateLabel(background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_DEBUFF, DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) - - local buff_name_tracklist_entry = self:CreateTextEntry(background_add_tracklist, function()end, textEntryWidth, 20, "AddBuffTracklistTextBox", _, _, options_dropdown_template) - buff_name_tracklist_entry:SetHook("OnEditFocusGained", load_all_spells) - buff_name_tracklist_entry:SetJustifyH("left") - buff_name_tracklist_entry.tooltip = "Enter the buff name using lower case letters." - f_auto.AddBuffTracklistTextBox = buff_name_tracklist_entry - - local debuff_name_tracklist_entry = self:CreateTextEntry(background_add_tracklist, function()end, textEntryWidth, 20, "AddDebuffTracklistTextBox", _, _, options_dropdown_template) - debuff_name_tracklist_entry:SetHook("OnEditFocusGained", load_all_spells) - debuff_name_tracklist_entry:SetJustifyH("left") - debuff_name_tracklist_entry.tooltip = "Enter the debuff name using lower case letters." - f_auto.AddDebuffTracklistTextBox = debuff_name_tracklist_entry - - local add_tracklist_debuff_button = self:CreateButton(background_add_tracklist, function() - local text = debuff_name_tracklist_entry.text - debuff_name_tracklist_entry:SetText("") - debuff_name_tracklist_entry:ClearFocus() - - if (text ~= "") then - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - --add the spellName to the tracklist - f.db.aura_tracker.debuff_tracked [spellId] = true - - --refresh the buff blacklist frame - f.debuff_tracked:DoRefresh() - - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - local add_tracklist_debuff_button_id = self:CreateButton(background_add_tracklist, function() - local text = debuff_name_tracklist_entry.text - debuff_name_tracklist_entry:SetText("") - debuff_name_tracklist_entry:ClearFocus() - - if (text ~= "") then - if (not tonumber(text)) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") - end - - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - f.db.aura_tracker.debuff_tracked [spellId] = false - - --refresh the buff blacklist frame - f.debuff_tracked:DoRefresh() - - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - local add_tracklist_buff_button = self:CreateButton(background_add_tracklist, function() - local text = buff_name_tracklist_entry.text - buff_name_tracklist_entry:SetText("") - buff_name_tracklist_entry:ClearFocus() - - if (text ~= "") then - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - --add the spellName to the tracklist - f.db.aura_tracker.buff_tracked [spellId] = true - - --refresh the buff tracklist frame - f.buff_tracked:DoRefresh() - - --callback the addon - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - - end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - local add_tracklist_buff_button_id = self:CreateButton(background_add_tracklist, function() - local text = buff_name_tracklist_entry.text - buff_name_tracklist_entry:SetText("") - buff_name_tracklist_entry:ClearFocus() - - if (text ~= "") then - if (not tonumber(text)) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") - end - - --get the spellId - local spellId = get_spellID_from_string (text) - if (not spellId) then - DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") - return - end - - --add the spellId to the tracklist - f.db.aura_tracker.buff_tracked [spellId] = false - - --refresh the buff tracklist frame - f.buff_tracked:DoRefresh() - - --callback the addon - DF:QuickDispatch(change_callback) - - --add to spells with the same name cache - same_name_spells_add (spellId) - end - end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate("font", options.button_text_template)) - - --anchors: - background_add_blacklist:SetPoint("topleft", f_auto, "topleft", 0, y) - background_add_tracklist:SetPoint("topleft", background_add_blacklist, "bottomleft", 0, -10) - - --debuff blacklist - debuff_name_blacklist_entry:SetPoint("topleft", background_add_blacklist, "topleft", 5, -20) - debuff_blacklist_label:SetPoint("bottomleft", debuff_name_blacklist_entry, "topleft", 0, 2) - add_blacklist_debuff_button:SetPoint("topleft", debuff_name_blacklist_entry, "bottomleft", 0, -2) - add_blacklist_debuff_button_id:SetPoint("left", add_blacklist_debuff_button, "right", 1, 0) - - --buff blacklist - buff_blacklist_label:SetPoint("topleft", add_blacklist_debuff_button.widget, "bottomleft", 0, -10) - buff_name_blacklist_entry:SetPoint("topleft", buff_blacklist_label, "bottomleft", 0, -2) - add_blacklist_buff_button:SetPoint("topleft", buff_name_blacklist_entry, "bottomleft", 0, -2) - add_blacklist_buff_button_id:SetPoint("left", add_blacklist_buff_button, "right", 1, 0) - - - --debuff tracklist - debuff_name_tracklist_entry:SetPoint("topleft", background_add_tracklist, "topleft", 5, -20) - debuff_tracklist_label:SetPoint("bottomleft", debuff_name_tracklist_entry, "topleft", 0, 2) - add_tracklist_debuff_button:SetPoint("topleft", debuff_name_tracklist_entry, "bottomleft", 0, -2) - add_tracklist_debuff_button_id:SetPoint("left", add_tracklist_debuff_button, "right", 1, 0) - - --buff tracklist - buff_tracklist_label:SetPoint("topleft", add_tracklist_debuff_button.widget, "bottomleft", 0, -10) - buff_name_tracklist_entry:SetPoint("topleft", buff_tracklist_label, "bottomleft", 0, -2) - add_tracklist_buff_button:SetPoint("topleft", buff_name_tracklist_entry, "bottomleft", 0, -2) - add_tracklist_buff_button_id:SetPoint("left", add_tracklist_buff_button, "right", 1, 0) - - local ALL_BUFFS = {} - local ALL_DEBUFFS = {} - - --options passed to the create aura panel - local width, height, row_height = options.width, options.height, options.row_height - - local autoTrackList_LineOnEnter = function(self, capsule, value) - - local flag = self.Flag - value = value or self.SpellID - - if not flag then - GameCooltip2:Preset(2) - GameCooltip2:SetOwner(self, "left", "right", 2, 0) - GameCooltip2:SetOption("TextSize", 10) - - local spellName, _, spellIcon = GetSpellInfo(value) - if (spellName) then - GameCooltip2:AddLine(spellName .. " (" .. value .. ")") - GameCooltip2:AddIcon (spellIcon, 1, 1, 14, 14, .1, .9, .1, .9) - end - GameCooltip2:Show() - else - - local spellName = GetSpellInfo(value) - if (spellName) then - - local spellsWithSameName = db.aura_cache_by_name [lower (spellName)] - if (not spellsWithSameName) then - same_name_spells_add (value) - spellsWithSameName = db.aura_cache_by_name [lower (spellName)] - end - - if (spellsWithSameName) then - GameCooltip2:Preset(2) - GameCooltip2:SetOwner(self, "left", "right", 2, 0) - GameCooltip2:SetOption("TextSize", 10) - - for i, spellID in ipairs(spellsWithSameName) do - local spellName, _, spellIcon = GetSpellInfo(spellID) - if (spellName) then - GameCooltip2:AddLine(spellName .. " (" .. spellID .. ")") - GameCooltip2:AddIcon (spellIcon, 1, 1, 14, 14, .1, .9, .1, .9) - end - end - - GameCooltip2:Show() - end - end - - end - end - - local autoTrackList_LineOnLeave = function() - GameCooltip2:Hide() - end - - local scrollWidth = 208 - local scrollHeight = 343 - local lineAmount = 18 - local lineHeight = 18 - local backdropColor = {.8, .8, .8, 0.2} - local backdropColor_OnEnter = {.8, .8, .8, 0.4} - - local createAuraScrollBox = function(parent, name, member, title, db, removeFunc) - - local updateFunc = function(self, data, offset, totalLines) - for i = 1, totalLines do - local index = i + offset - local auraTable = data [index] - if (auraTable) then - local line = self:GetLine (i) - local spellID, spellName, spellIcon, lowerSpellName, flag = unpack(auraTable) - - line.SpellID = spellID - line.SpellName = spellName - line.SpellNameLower = lowerSpellName - line.SpellIcon = spellIcon - line.Flag = flag - - if flag then - line.name:SetText(spellName) - else - line.name:SetText(spellName .. " (" .. spellID .. ")") - end - line.icon:SetTexture(spellIcon) - line.icon:SetTexCoord(.1, .9, .1, .9) - end - end - end - - local lineOnEnter = function(self) - self:SetBackdropColor(unpack(backdropColor_OnEnter)) - - --GameTooltip:SetOwner(self, "ANCHOR_CURSOR") - --GameTooltip:SetSpellByID(self.SpellID) - --GameTooltip:AddLine(" ") - --GameTooltip:Show() - end - - local lineOnLeave = function(self) - self:SetBackdropColor(unpack(backdropColor)) - --GameTooltip:Hide() - end - - local onRemoveClick = function(self) - local spellID = self:GetParent().SpellID - db [spellID] = nil - db ["".. (spellID or "")] = nil -- cleanup... - parent [member]:DoRefresh() - if (removeFunc) then - DF:QuickDispatch(removeFunc) - end - end - - local createLineFunc = function(self, index) - local line = CreateFrame("button", "$parentLine" .. index, self, "BackdropTemplate") - line:SetPoint("topleft", self, "topleft", 1, - ((index - 1) * (lineHeight + 1)) - 1) - line:SetSize(scrollWidth - 2, lineHeight) - line:SetScript("OnEnter", autoTrackList_LineOnEnter) - line:HookScript ("OnEnter", lineOnEnter) - line:SetScript("OnLeave", autoTrackList_LineOnLeave) - line:HookScript ("OnLeave", lineOnLeave) - - line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) - line:SetBackdropColor(unpack(backdropColor)) - - local icon = line:CreateTexture("$parentIcon", "overlay") - icon:SetSize(lineHeight - 2, lineHeight - 2) - - local name = line:CreateFontString("$parentName", "overlay", "GameFontNormal") - DF:SetFontSize(name, 10) - - local remove_button = CreateFrame("button", "$parentRemoveButton", line, "UIPanelCloseButton") - remove_button:SetSize(16, 16) - remove_button:SetScript("OnClick", onRemoveClick) - remove_button:SetPoint("topright", line, "topright") - remove_button:GetNormalTexture():SetDesaturated(true) - - icon:SetPoint("left", line, "left", 2, 0) - name:SetPoint("left", icon, "right", 3, 0) - - line.icon = icon - line.name = name - line.removebutton = remove_button - - return line - end - - local scroll = DF:CreateScrollBox (parent, name, updateFunc, db, scrollWidth, scrollHeight, lineAmount, lineHeight) - DF:ReskinSlider(scroll) - parent [member] = scroll - scroll.OriginalData = db - - function scroll:DoRefresh() - local t = {} - local added = {} - for spellID, flag in pairs(scroll.OriginalData) do - local spellName, _, spellIcon = GetSpellInfo(spellID) - if (spellName and not added[tonumber(spellID) or 0]) then - local lowerSpellName = spellName:lower() - tinsert(t, {spellID, spellName, spellIcon, lowerSpellName, flag}) - added[tonumber(spellID) or 0] = true - end - end - - table.sort (t, function(t1, t2) return t1[4] < t2[4] end) - - self:SetData (t) - self:Refresh() - end - - function scroll:DoSetData (newDB) - self:SetData (newDB) - scroll.OriginalData = newDB - self:DoRefresh() - end - - local title = DF:CreateLabel(parent, title) - title.textcolor = "silver" - title.textsize = 10 - title:SetPoint("bottomleft", scroll, "topleft", 0, 2) - - for i = 1, lineAmount do - scroll:CreateLine (createLineFunc) - end - - scroll:DoRefresh() - return scroll - end - - local buff_tracked = createAuraScrollBox (f_auto, "$parentBuffTracked", "BuffTrackerScroll", f.LocTexts.BUFFS_TRACKED, f.db.aura_tracker.buff_tracked, function() - if (change_callback) then - DF:QuickDispatch(change_callback) - end - end) - local debuff_tracked = createAuraScrollBox (f_auto, "$parentDebuffTracked", "DebuffTrackerScroll", f.LocTexts.DEBUFFS_TRACKED, f.db.aura_tracker.debuff_tracked, function() - if (change_callback) then - DF:QuickDispatch(change_callback) - end - end) - - local buff_ignored = createAuraScrollBox (f_auto, "$parentBuffIgnored", "BuffIgnoredScroll", f.LocTexts.BUFFS_IGNORED, f.db.aura_tracker.buff_banned, function() - if (change_callback) then - DF:QuickDispatch(change_callback) - end - end) - local debuff_ignored = createAuraScrollBox (f_auto, "$parentDebuffIgnored", "DebuffIgnoredScroll", f.LocTexts.DEBUFFS_IGNORED, f.db.aura_tracker.debuff_banned, function() - if (change_callback) then - DF:QuickDispatch(change_callback) - end - end) - - local xLocation = 140 - scrollWidth = scrollWidth + 20 - - debuff_ignored:SetPoint("topleft", f_auto, "topleft", 0 + xLocation, y) - buff_ignored:SetPoint("topleft", f_auto, "topleft", 8 + scrollWidth + xLocation, y) - debuff_tracked:SetPoint("topleft", f_auto, "topleft", 16 + (scrollWidth * 2) + xLocation, y) - buff_tracked:SetPoint("topleft", f_auto, "topleft", 24 + (scrollWidth * 3) + xLocation, y) - - f.buff_ignored = buff_ignored - f.debuff_ignored = debuff_ignored - f.buff_tracked = buff_tracked - f.debuff_tracked = debuff_tracked - - f_auto:SetScript("OnShow", function() - for i = 1, BUFF_MAX_DISPLAY do - local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HELPFUL") - if (name) then - ALL_BUFFS [spellId] = true - end - local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HARMFUL") - if (name) then - ALL_DEBUFFS [spellId] = true - end - end - - buff_tracked:DoRefresh() - debuff_tracked:DoRefresh() - buff_ignored:DoRefresh() - debuff_ignored:DoRefresh() - - end) - f_auto:SetScript("OnHide", function() - -- - end) - - --show the frame selecton on the f.db - - if (f.db.aura_tracker.track_method == 0x1) then - on_switch_tracking_method (automatic_tracking_checkbox) - elseif (f.db.aura_tracker.track_method == 0x2) then - on_switch_tracking_method (manual_tracking_checkbox) - end - --------manual - - --build the two aura scrolls for buff and debuff - - local scroll_width = width - local scroll_height = height - local scroll_lines = 15 - local scroll_line_height = 20 - - local backdrop_color = {.8, .8, .8, 0.2} - local backdrop_color_on_enter = {.8, .8, .8, 0.4} - - local line_onenter = function(self) - self:SetBackdropColor(unpack(backdrop_color_on_enter)) - local spellid = select(7, GetSpellInfo(self.value)) - if (spellid) then - GameTooltip:SetOwner(self, "ANCHOR_CURSOR") - GameTooltip:SetSpellByID(spellid) - GameTooltip:AddLine(" ") - GameTooltip:Show() - end - end - - local line_onleave = function(self) - self:SetBackdropColor(unpack(backdrop_color)) - GameTooltip:Hide() - end - - local onclick_remove_button = function(self) - local spell = self:GetParent().value - local data = self:GetParent():GetParent():GetData() - - for i = 1, #data do - if (data[i] == spell) then - tremove(data, i) - break - end - end - - self:GetParent():GetParent():Refresh() - end - - local scroll_createline = function(self, index) - local line = CreateFrame("button", "$parentLine" .. index, self, "BackdropTemplate") - line:SetPoint("topleft", self, "topleft", 1, -((index-1)*(scroll_line_height+1)) - 1) - line:SetSize(scroll_width - 2, scroll_line_height) - line:SetScript("OnEnter", line_onenter) - line:SetScript("OnLeave", line_onleave) - - line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) - line:SetBackdropColor(unpack(backdrop_color)) - - local icon = line:CreateTexture("$parentIcon", "overlay") - icon:SetSize(scroll_line_height - 2, scroll_line_height - 2) - - local name = line:CreateFontString("$parentName", "overlay", "GameFontNormal") - - local remove_button = CreateFrame("button", "$parentRemoveButton", line, "UIPanelCloseButton") - remove_button:SetSize(16, 16) - remove_button:SetScript("OnClick", onclick_remove_button) - remove_button:SetPoint("topright", line, "topright") - remove_button:GetNormalTexture():SetDesaturated(true) - - icon:SetPoint("left", line, "left", 2, 0) - name:SetPoint("left", icon, "right", 2, 0) - - line.icon = icon - line.name = name - line.removebutton = remove_button - - return line - end - - local scroll_refresh = function(self, data, offset, total_lines) - for i = 1, total_lines do - local index = i + offset - local aura = data [index] - if (aura) then - local line = self:GetLine (i) - local name, _, icon = GetSpellInfo(aura) - line.value = aura - if (name) then - line.name:SetText(name) - line.icon:SetTexture(icon) - line.icon:SetTexCoord(.1, .9, .1, .9) - else - line.name:SetText(aura) - line.icon:SetTexture([[Interface\InventoryItems\WoWUnknownItem01]]) - end - end - end - end - - local buffs_added = self:CreateScrollBox (f_manual, "$parentBuffsAdded", scroll_refresh, f.db.aura_tracker.buff, scroll_width, scroll_height, scroll_lines, scroll_line_height) - buffs_added:SetPoint("topleft", f_manual, "topleft", 0, y) - DF:ReskinSlider(buffs_added) - - for i = 1, scroll_lines do - buffs_added:CreateLine (scroll_createline) - end - - local debuffs_added = self:CreateScrollBox (f_manual, "$parentDebuffsAdded", scroll_refresh, f.db.aura_tracker.debuff, scroll_width, scroll_height, scroll_lines, scroll_line_height) - debuffs_added:SetPoint("topleft", f_manual, "topleft", width+30, y) - DF:ReskinSlider(debuffs_added) - - for i = 1, scroll_lines do - debuffs_added:CreateLine (scroll_createline) - end - - f.buffs_added = buffs_added - f.debuffs_added = debuffs_added - - local buffs_added_name = DF:CreateLabel(buffs_added, "Buffs", 12, "silver") - buffs_added_name:SetTemplate(DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) - buffs_added_name:SetPoint("bottomleft", buffs_added, "topleft", 0, 2) - buffs_added.Title = buffs_added_name - - local debuffs_added_name = DF:CreateLabel(debuffs_added, "Debuffs", 12, "silver") - debuffs_added_name:SetTemplate(DF:GetTemplate("font", "OPTIONS_FONT_TEMPLATE")) - debuffs_added_name:SetPoint("bottomleft", debuffs_added, "topleft", 0, 2) - debuffs_added.Title = debuffs_added_name - - -- build the text entry to type the spellname - local new_buff_string = self:CreateLabel(f_manual, "Add Buff") - local new_debuff_string = self:CreateLabel(f_manual, "Add Debuff") - local new_buff_entry = self:CreateTextEntry(f_manual, function()end, 200, 20, "NewBuffTextBox", _, _, options_dropdown_template) - local new_debuff_entry = self:CreateTextEntry(f_manual, function()end, 200, 20, "NewDebuffTextBox", _, _, options_dropdown_template) - - new_buff_entry:SetHook("OnEditFocusGained", load_all_spells) - new_debuff_entry:SetHook("OnEditFocusGained", load_all_spells) - new_buff_entry.tooltip = "Enter the buff name using lower case letters.\n\nYou can add several spells at once using |cFFFFFF00;|r to separate each spell name." - new_debuff_entry.tooltip = "Enter the debuff name using lower case letters.\n\nYou can add several spells at once using |cFFFFFF00;|r to separate each spell name." - - new_buff_entry:SetJustifyH("left") - new_debuff_entry:SetJustifyH("left") - - local add_buff_button = self:CreateButton(f_manual, function() - - local text = new_buff_entry.text - new_buff_entry:SetText("") - new_buff_entry:ClearFocus() - - if (text ~= "") then - --check for more than one spellname - if (text:find(";")) then - for _, spellName in ipairs({strsplit(";", text)}) do - spellName = self:trim (spellName) - local spellID = get_spellID_from_string (spellName) - - if (spellID) then - tinsert(f.db.aura_tracker.buff, spellID) - --[[ - if not tonumber(spellName) then - tinsert(f.db.aura_tracker.buff, spellName) - else - tinsert(f.db.aura_tracker.buff, spellID) - end - ]]-- - else - print("spellId not found for spell:", spellName) - end - end - else - --get the spellId - local spellID = get_spellID_from_string (text) - if (not spellID) then - print("spellIs for spell ", text, "not found") - return - end - - tinsert(f.db.aura_tracker.buff, spellID) - --[[ - if not tonumber(text) then - tinsert(f.db.aura_tracker.buff, text) - else - tinsert(f.db.aura_tracker.buff, spellID) - end - ]]-- - end - - buffs_added:Refresh() - end - - end, 100, 20, "Add Buff", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) - - local add_debuff_button = self:CreateButton(f_manual, function() - local text = new_debuff_entry.text - new_debuff_entry:SetText("") - new_debuff_entry:ClearFocus() - if (text ~= "") then - --check for more than one spellname - if (text:find(";")) then - for _, spellName in ipairs({strsplit(";", text)}) do - spellName = self:trim (spellName) - local spellID = get_spellID_from_string (spellName) - - if (spellID) then - tinsert(f.db.aura_tracker.debuff, spellID) - --[[ - if not tonumber(spellName) then - tinsert(f.db.aura_tracker.debuff, spellName) - else - tinsert(f.db.aura_tracker.debuff, spellID) - end - ]]-- - else - print("spellId not found for spell:", spellName) - end - end - else - --get the spellId - local spellID = get_spellID_from_string (text) - if (not spellID) then - print("spellIs for spell ", text, "not found") - return - end - - tinsert(f.db.aura_tracker.debuff, spellID) - --[[ - if not tonumber(text) then - print(text) - tinsert(f.db.aura_tracker.debuff, text) - else - print(spellID) - tinsert(f.db.aura_tracker.debuff, spellID) - end - ]]-- - end - - debuffs_added:Refresh() - end - end, 100, 20, "Add Debuff", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) - - local multiple_spells_label = DF:CreateLabel(buffs_added, "You can add multiple auras at once by separating them with ';'.\nExample: Fireball; Frostbolt; Flamestrike", 10, "gray") - multiple_spells_label:SetSize(350, 24) - multiple_spells_label:SetJustifyV ("top") - - local export_box = self:CreateTextEntry(f_manual, function()end, 242, 20, "ExportAuraTextBox", _, _, options_dropdown_template) - - local export_buff_button = self:CreateButton(f_manual, function() - local str = "" - for _, spellId in ipairs(f.db.aura_tracker.buff) do - local spellName = GetSpellInfo(spellId) - if (spellName) then - str = str .. spellName .. "; " - end - end - export_box.text = str - export_box:SetFocus(true) - export_box:HighlightText() - - end, 120, 20, "Export Buffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) - - local export_debuff_button = self:CreateButton(f_manual, function() - local str = "" - for _, spellId in ipairs(f.db.aura_tracker.debuff) do - local spellName = GetSpellInfo(spellId) - if (spellName) then - str = str .. spellName .. "; " - end - end - - export_box.text = str - export_box:SetFocus(true) - export_box:HighlightText() - - end, 120, 20, "Export Debuffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) - - new_buff_entry:SetPoint("topleft", f_manual, "topleft", 480, y) - new_buff_string:SetPoint("bottomleft", new_buff_entry, "topleft", 0, 2) - add_buff_button:SetPoint("left", new_buff_entry, "right", 2, 0) - add_buff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it." - - new_debuff_string:SetPoint("topleft", new_buff_entry, "bottomleft", 0, -6) - new_debuff_entry:SetPoint("topleft", new_debuff_string, "bottomleft", 0, -2) - add_debuff_button:SetPoint("left", new_debuff_entry, "right", 2, 0) - add_debuff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it." - - multiple_spells_label:SetPoint("topleft", new_debuff_entry, "bottomleft", 0, -6) - - export_buff_button:SetPoint("topleft", multiple_spells_label, "bottomleft", 0, -12) - export_debuff_button:SetPoint("left",export_buff_button, "right", 2, 0) - export_box:SetPoint("topleft", export_buff_button, "bottomleft", 0, -6) - - buffs_added:Refresh() - debuffs_added:Refresh() - - ------------------------ ---------------------------------------------- ---------------------------------------------- ----------------------- - - f:SetScript("OnShow", function() - buffs_added:Refresh() - debuffs_added:Refresh() - end) - - return f -end - - -function DF:GetAllPlayerSpells (include_lower_case) - local playerSpells = {} - local tab, tabTex, offset, numSpells = GetSpellTabInfo (2) - for i = 1, numSpells do - local index = offset + i - local spellType, spellId = GetSpellBookItemInfo (index, "player") - if (spellType == "SPELL") then - local spellName = GetSpellInfo(spellId) - tinsert(playerSpells, spellName) - if (include_lower_case) then - tinsert(playerSpells, lower (spellName)) - end - end - end - return playerSpells -end - -function DF:SetAutoCompleteWithSpells (textentry) - textentry:SetHook("OnEditFocusGained", function() - local playerSpells = DF:GetAllPlayerSpells (true) - textentry.WordList = playerSpells - end) - textentry:SetAsAutoComplete ("WordList") -end - ---check for aura - - --- add aura - - ---handle savedvariables - - ---remove a aura - - - - - ---handle UNIT_AURA event - - diff --git a/plugins/Details_EncounterDetails/Libs/DF/button.lua b/plugins/Details_EncounterDetails/Libs/DF/button.lua deleted file mode 100644 index 7b671f38..00000000 --- a/plugins/Details_EncounterDetails/Libs/DF/button.lua +++ /dev/null @@ -1,1359 +0,0 @@ - -local detailsFramework = _G["DetailsFramework"] - -if (not detailsFramework or not DetailsFrameworkCanLoad) then - return -end - -local _ -local unpack = unpack -local emptyFunction = function() end -local APIButtonFunctions = false - -do - local metaPrototype = { - WidgetType = "button", - dversion = detailsFramework.dversion - } - - --check if there's a metaPrototype already existing - if (_G[detailsFramework.GlobalWidgetControlNames["button"]]) then - --get the already existing metaPrototype - local oldMetaPrototype = _G[detailsFramework.GlobalWidgetControlNames["button"]] - --check if is older - if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < detailsFramework.dversion) ) then - --the version is older them the currently loading one - --copy the new values into the old metatable - for funcName, _ in pairs(metaPrototype) do - oldMetaPrototype[funcName] = metaPrototype[funcName] - end - end - else - --first time loading the framework - _G[detailsFramework.GlobalWidgetControlNames["button"]] = metaPrototype - end -end - -local ButtonMetaFunctions = _G[detailsFramework.GlobalWidgetControlNames["button"]] - -detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.SetPointMixin) -detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.FrameMixin) -detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.TooltipHandlerMixin) -detailsFramework:Mixin(ButtonMetaFunctions, detailsFramework.ScriptHookMixin) - ------------------------------------------------------------------------------------------------------------- ---metatables - - ButtonMetaFunctions.__call = function(self) - local frameWidget = self.widget - detailsFramework:CoreDispatch((frameWidget:GetName() or "Button") .. ":__call()", self.func, frameWidget, "LeftButton", self.param1, self.param2) - end - ------------------------------------------------------------------------------------------------------------- ---members - - --tooltip - local gmember_tooltip = function(object) - return object:GetTooltip() - end - - --shown - local gmember_shown = function(object) - return object:IsShown() - end - --frame width - local gmember_width = function(object) - return object.button:GetWidth() - end - - --frame height - local gmember_height = function(object) - return object.button:GetHeight() - end - - --text - local gmember_text = function(object) - return object.button.text:GetText() - end - - --function - local gmember_function = function(object) - return rawget(object, "func") - end - - --text color - local gmember_textcolor = function(object) - return object.button.text:GetTextColor() - end - - --text font - local gmember_textfont = function(object) - local fontface = object.button.text:GetFont() - return fontface - end - - --text size - local gmember_textsize = function(object) - local _, fontsize = object.button.text:GetFont() - return fontsize - end - - --texture - local gmember_texture = function(object) - return {object.button:GetNormalTexture(), object.button:GetHighlightTexture(), object.button:GetPushedTexture(), object.button:GetDisabledTexture()} - end - - --locked - local gmember_locked = function(object) - return rawget(object, "is_locked") - end - - ButtonMetaFunctions.GetMembers = ButtonMetaFunctions.GetMembers or {} - ButtonMetaFunctions.GetMembers["tooltip"] = gmember_tooltip - ButtonMetaFunctions.GetMembers["shown"] = gmember_shown - ButtonMetaFunctions.GetMembers["width"] = gmember_width - ButtonMetaFunctions.GetMembers["height"] = gmember_height - ButtonMetaFunctions.GetMembers["text"] = gmember_text - ButtonMetaFunctions.GetMembers["clickfunction"] = gmember_function - ButtonMetaFunctions.GetMembers["texture"] = gmember_texture - ButtonMetaFunctions.GetMembers["locked"] = gmember_locked - ButtonMetaFunctions.GetMembers["fontcolor"] = gmember_textcolor - ButtonMetaFunctions.GetMembers["fontface"] = gmember_textfont - ButtonMetaFunctions.GetMembers["fontsize"] = gmember_textsize - ButtonMetaFunctions.GetMembers["textcolor"] = gmember_textcolor --alias - ButtonMetaFunctions.GetMembers["textfont"] = gmember_textfont --alias - ButtonMetaFunctions.GetMembers["textsize"] = gmember_textsize --alias - - ButtonMetaFunctions.__index = function(object, key) - local func = ButtonMetaFunctions.GetMembers[key] - if (func) then - return func(object, key) - end - - local alreadyHaveKey = rawget(object, key) - if (alreadyHaveKey) then - return alreadyHaveKey - end - - return ButtonMetaFunctions[key] - end - -------------------------------------------------------------------------------------------------------------------------------------------------------------------- - - --tooltip - local smember_tooltip = function(object, value) - return object:SetTooltip (value) - end - - --show - local smember_show = function(object, value) - if (value) then - return object:Show() - else - return object:Hide() - end - end - - --hide - local smember_hide = function(object, value) - if (not value) then - return object:Show() - else - return object:Hide() - end - end - - --frame width - local smember_width = function(object, value) - return object.button:SetWidth(value) - end - - --frame height - local smember_height = function(object, value) - return object.button:SetHeight(value) - end - - --text - local smember_text = function(object, value) - return object.button.text:SetText(value) - end - - --function - local smember_function = function(object, value) - return rawset(object, "func", value) - end - - --param1 - local smember_param1 = function(object, value) - return rawset(object, "param1", value) - end - - --param2 - local smember_param2 = function(object, value) - return rawset(object, "param2", value) - end - - --text color - local smember_textcolor = function(object, value) - local value1, value2, value3, value4 = detailsFramework:ParseColors(value) - return object.button.text:SetTextColor(value1, value2, value3, value4) - end - - --text font - local smember_textfont = function(object, value) - return detailsFramework:SetFontFace (object.button.text, value) - end - - --text size - local smember_textsize = function(object, value) - return detailsFramework:SetFontSize(object.button.text, value) - end - - --texture - local smember_texture = function(object, value) - if (type(value) == "table") then - local value1, value2, value3, value4 = unpack(value) - if (value1) then - object.button:SetNormalTexture(value1) - end - if (value2) then - object.button:SetHighlightTexture(value2, "ADD") - end - if (value3) then - object.button:SetPushedTexture(value3) - end - if (value4) then - object.button:SetDisabledTexture(value4) - end - else - object.button:SetNormalTexture(value) - object.button:SetHighlightTexture(value, "ADD") - object.button:SetPushedTexture(value) - object.button:SetDisabledTexture(value) - end - return - end - - --locked - local smember_locked = function(object, value) - if (value) then - object.button:SetMovable(false) - return rawset(object, "is_locked", true) - else - object.button:SetMovable(true) - rawset(object, "is_locked", false) - return - end - end - - --text align - local smember_textalign = function(object, value) - if (value == "left" or value == "<") then - object.button.text:SetPoint("left", object.button, "left", 2, 0) - object.capsule_textalign = "left" - - elseif (value == "center" or value == "|") then - object.button.text:SetPoint("center", object.button, "center", 0, 0) - object.capsule_textalign = "center" - - elseif (value == "right" or value == ">") then - object.button.text:SetPoint("right", object.button, "right", -2, 0) - object.capsule_textalign = "right" - end - end - - ButtonMetaFunctions.SetMembers= ButtonMetaFunctions.SetMembers or {} - ButtonMetaFunctions.SetMembers["tooltip"] = smember_tooltip - ButtonMetaFunctions.SetMembers["show"] = smember_show - ButtonMetaFunctions.SetMembers["hide"] = smember_hide - ButtonMetaFunctions.SetMembers["width"] = smember_width - ButtonMetaFunctions.SetMembers["height"] = smember_height - ButtonMetaFunctions.SetMembers["text"] = smember_text - ButtonMetaFunctions.SetMembers["clickfunction"] = smember_function - ButtonMetaFunctions.SetMembers["param1"] = smember_param1 - ButtonMetaFunctions.SetMembers["param2"] = smember_param2 - ButtonMetaFunctions.SetMembers["textcolor"] = smember_textcolor - ButtonMetaFunctions.SetMembers["textfont"] = smember_textfont - ButtonMetaFunctions.SetMembers["textsize"] = smember_textsize - ButtonMetaFunctions.SetMembers["fontcolor"] = smember_textcolor--alias - ButtonMetaFunctions.SetMembers["fontface"] = smember_textfont--alias - ButtonMetaFunctions.SetMembers["fontsize"] = smember_textsize--alias - ButtonMetaFunctions.SetMembers["texture"] = smember_texture - ButtonMetaFunctions.SetMembers["locked"] = smember_locked - ButtonMetaFunctions.SetMembers["textalign"] = smember_textalign - - ButtonMetaFunctions.__newindex = function(object, key, value) - local func = ButtonMetaFunctions.SetMembers[key] - if (func) then - return func(object, value) - else - return rawset(object, key, value) - end - end - ------------------------------------------------------------------------------------------------------------- ---methods - - ---change the function which will be called when the button is pressed - ---@param func function - ---@param param1 any - ---@param param2 any - ---@param clickType string|nil - function ButtonMetaFunctions:SetClickFunction(func, param1, param2, clickType) - if (not clickType or string.find(string.lower(clickType), "left")) then - if (func) then - rawset(self, "func", func) - else - rawset(self, "func", emptyFunction) - end - - if (param1 ~= nil) then - rawset(self, "param1", param1) - end - if (param2 ~= nil) then - rawset(self, "param2", param2) - end - - elseif (clickType or string.find(string.lower(clickType), "right")) then - if (func) then - rawset(self, "funcright", func) - else - rawset(self, "funcright", emptyFunction) - end - end - end - - ---set the text shown on the button - ---@param text string - function ButtonMetaFunctions:SetText(text) - self.button.text:SetText(text) - end - - ---set the color of the button text - ---@param ... any - function ButtonMetaFunctions:SetTextColor(...) - local red, green, blue, alpha = detailsFramework:ParseColors(...) - self.button.text:SetTextColor(red, green, blue, alpha) - end - ButtonMetaFunctions.SetFontColor = ButtonMetaFunctions.SetTextColor --alias - - ---set the size of the button text - ---@param ... number - function ButtonMetaFunctions:SetFontSize(...) - detailsFramework:SetFontSize(self.button.text, ...) - end - - ---set the font into the button text - ---@param font string - function ButtonMetaFunctions:SetFontFace(font) - detailsFramework:SetFontFace(self.button.text, font) - end - - ---comment - ---@param normalTexture any - ---@param highlightTexture any - ---@param pressedTexture any - ---@param disabledTexture any - function ButtonMetaFunctions:SetTexture(normalTexture, highlightTexture, pressedTexture, disabledTexture) - if (normalTexture) then - self.button:SetNormalTexture(normalTexture) - elseif (type(normalTexture) ~= "boolean") then - self.button:SetNormalTexture("") - end - - if (type(highlightTexture) == "boolean") then - if (highlightTexture and normalTexture and type(normalTexture) ~= "boolean") then - self.button:SetHighlightTexture(normalTexture, "ADD") - end - elseif (highlightTexture == nil) then - self.button:SetHighlightTexture("") - else - self.button:SetHighlightTexture(highlightTexture, "ADD") - end - - if (type(pressedTexture) == "boolean") then - if (pressedTexture and normalTexture and type(normalTexture) ~= "boolean") then - self.button:SetPushedTexture(normalTexture) - end - elseif (pressedTexture == nil) then - self.button:SetPushedTexture("") - else - self.button:SetPushedTexture(pressedTexture, "ADD") - end - - if (type(disabledTexture) == "boolean") then - if (disabledTexture and normalTexture and type(normalTexture) ~= "boolean") then - self.button:SetDisabledTexture(normalTexture) - end - elseif (disabledTexture == nil) then - self.button:SetDisabledTexture("") - else - self.button:SetDisabledTexture(disabledTexture, "ADD") - end - end - - ---return the texture set into the icon with SetIcon() - ---@return number|nil texture - function ButtonMetaFunctions:GetIconTexture() - if (self.icon) then - return self.icon:GetTexture() - end - end - - ---add an icon to the left of the button text - ---@param texture any - ---@param width number|nil - ---@param height number|nil - ---@param layout "background|border|overlay|artwork"|nil - ---@param texcoord table|nil - ---@param overlay any - ---@param textDistance number|nil - ---@param leftPadding number|nil - ---@param textHeight number|nil - ---@param shortMethod any - function ButtonMetaFunctions:SetIcon(texture, width, height, layout, texcoord, overlay, textDistance, leftPadding, textHeight, shortMethod) - if (not self.icon) then - self.icon = self:CreateTexture(nil, "artwork") - self.icon:SetSize(self.height * 0.8, self.height * 0.8) - self.icon:SetPoint("left", self.widget, "left", 4 + (leftPadding or 0), 0) - self.icon.leftPadding = leftPadding or 0 - self.widget.text:ClearAllPoints() - self.widget.text:SetPoint("left", self.icon, "right", textDistance or 2, 0 + (textHeight or 0)) - end - - if (type(texture) == "string") then - local isAtlas = C_Texture.GetAtlasInfo(texture) - if (isAtlas) then - self.icon:SetAtlas(texture) - - elseif (detailsFramework:IsHtmlColor(texture)) then - local r, g, b, a = detailsFramework:ParseColors(texture) - self.icon:SetColorTexture(r, g, b, a) - else - self.icon:SetTexture(texture) - end - elseif (type(texture) == "table") then - local r, g, b, a = detailsFramework:ParseColors(texture) - self.icon:SetColorTexture(r, g, b, a) - else - self.icon:SetTexture(texture) - end - - self.icon:SetSize(width or self.height * 0.8, height or self.height * 0.8) - self.icon:SetDrawLayer(layout or "artwork") - - if (texcoord) then - self.icon:SetTexCoord(unpack(texcoord)) - else - self.icon:SetTexCoord(0, 1, 0, 1) - end - - if (overlay) then - if (type(overlay) == "string") then - local r, g, b, a = detailsFramework:ParseColors(overlay) - self.icon:SetVertexColor(r, g, b, a) - else - self.icon:SetVertexColor(unpack(overlay)) - end - else - self.icon:SetVertexColor(1, 1, 1, 1) - end - - local buttonWidth = self.button:GetWidth() - local iconWidth = self.icon:GetWidth() - local textWidth = self.button.text:GetStringWidth() - if (textWidth > buttonWidth - 15 - iconWidth) then - if (shortMethod == false) then - - elseif (not shortMethod) then - local new_width = textWidth + 15 + iconWidth - self.button:SetWidth(new_width) - - elseif (shortMethod == 1) then - local loop = true - local textSize = 11 - while (loop) do - if (textWidth + 15 + iconWidth < buttonWidth or textSize < 8) then - loop = false - break - else - detailsFramework:SetFontSize(self.button.text, textSize) - textWidth = self.button.text:GetStringWidth() - textSize = textSize - 1 - end - end - end - end - end - - ---query if the button is enabled or not - ---@return boolean - function ButtonMetaFunctions:IsEnabled() - return self.button:IsEnabled() - end - - ---enable the button making it clickable and not grayed out - ---@return unknown - function ButtonMetaFunctions:Enable() - return self.button:Enable() - end - - ---disable the button making it unclickable and grayed out - ---@return unknown - function ButtonMetaFunctions:Disable() - return self.button:Disable() - end - - ---simulate a click on the button - function ButtonMetaFunctions:Exec() - local frameWidget = self.widget - detailsFramework:CoreDispatch((frameWidget:GetName() or "Button") .. ":Exec()", self.func, frameWidget, "LeftButton", self.param1, self.param2) - end - - ---simulate a click on the button, but this function is called with a different name - function ButtonMetaFunctions:Click() - local frameWidget = self.widget - detailsFramework:CoreDispatch((frameWidget:GetName() or "Button") .. ":Click()", self.func, frameWidget, "LeftButton", self.param1, self.param2) - end - - ---simulate a right click on the button - function ButtonMetaFunctions:RightClick() - local frameWidget = self.widget - detailsFramework:CoreDispatch((frameWidget:GetName() or "Button") .. ":RightClick()", self.funcright, frameWidget, "RightButton", self.param1, self.param2) - end - ---custom textures - function ButtonMetaFunctions:InstallCustomTexture() - --function deprecated, now just set a the standard template - self:SetTemplate(detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) - end - ------------------------------------------------------------------------------------------------------------- ---scripts - - local OnEnter = function(button) - local object = button.MyObject - - local kill = object:RunHooksForWidget("OnEnter", button, object) - if (kill) then - return - end - - object.is_mouse_over = true - - if (button.texture) then - if (button.texture.coords) then - button.texture:SetTexCoord(unpack(button.texture.coords.Highlight)) - else - button.texture:SetTexCoord(0, 1, 0.24609375, 0.49609375) - end - end - - if (object.onenter_backdrop_border_color) then - button:SetBackdropBorderColor(unpack(object.onenter_backdrop_border_color)) - end - - if (object.onenter_backdrop) then - button:SetBackdropColor(unpack(object.onenter_backdrop)) - end - - object:ShowTooltip() - end - - local OnLeave = function(button) - local object = button.MyObject - - local kill = object:RunHooksForWidget("OnLeave", button, object) - if (kill) then - return - end - - object.is_mouse_over = false - - if (button.texture and not object.is_mouse_down) then - if (button.texture.coords) then - button.texture:SetTexCoord(unpack(button.texture.coords.Normal)) - else - button.texture:SetTexCoord(0, 1, 0, 0.24609375) - end - end - - if (object.onleave_backdrop_border_color) then - button:SetBackdropBorderColor(unpack(object.onleave_backdrop_border_color)) - end - - if (object.onleave_backdrop) then - button:SetBackdropColor(unpack(object.onleave_backdrop)) - end - - object:HideTooltip() - end - - local OnHide = function(button) - local object = button.MyObject - local kill = object:RunHooksForWidget("OnHide", button, object) - if (kill) then - return - end - end - - local OnShow = function(button) - local object = button.MyObject - local kill = object:RunHooksForWidget("OnShow", button, object) - if (kill) then - return - end - end - - local OnMouseDown = function(button, buttontype) - if (not button:IsEnabled()) then - return - end - - local object = button.MyObject - - local kill = object:RunHooksForWidget("OnMouseDown", button, object) - if (kill) then - return - end - - object.is_mouse_down = true - - if (button.texture) then - if (button.texture.coords) then - button.texture:SetTexCoord(unpack(button.texture.coords.Pushed)) - else - button.texture:SetTexCoord(0, 1, 0.5078125, 0.75) - end - end - - if (object.capsule_textalign) then - if (object.icon) then - object.icon:SetPoint("left", button, "left", 5 + (object.icon.leftpadding or 0), -1) - - elseif (object.capsule_textalign == "left") then - button.text:SetPoint("left", button, "left", 3, -1) - - elseif (object.capsule_textalign == "center") then - button.text:SetPoint("center", button, "center", 1, -1) - - elseif (object.capsule_textalign == "right") then - button.text:SetPoint("right", button, "right", -1, -1) - end - else - if (object.icon) then - object.icon:SetPoint("left", button, "left", 5 + (object.icon.leftpadding or 0), -1) - else - button.text:SetPoint("center", button,"center", 1, -1) - end - end - - button.mouse_down = GetTime() - local x, y = GetCursorPosition() - button.x = math.floor(x) - button.y = math.floor(y) - - if (not object.container.isLocked and object.container:IsMovable()) then - if (not button.isLocked and button:IsMovable()) then - object.container.isMoving = true - object.container:StartMoving() - end - end - - if (object.options.OnGrab) then - if (type(object.options.OnGrab) == "string" and object.options.OnGrab == "PassClick") then - if (buttontype == "LeftButton") then - detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.func, button, buttontype, object.param1, object.param2) - else - detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseDown()", object.funcright, button, buttontype, object.param1, object.param2) - end - end - end - end - - local OnMouseUp = function(button, buttonType) - if (not button:IsEnabled()) then - return - end - - local object = button.MyObject - - local kill = object:RunHooksForWidget("OnMouseUp", button, object) - if (kill) then - return - end - - object.is_mouse_down = false - - if (button.texture) then - if (button.texture.coords) then - if (object.is_mouse_over) then - button.texture:SetTexCoord(unpack(button.texture.coords.Highlight)) - else - button.texture:SetTexCoord(unpack(coords.Normal)) - end - else - if (object.is_mouse_over) then - button.texture:SetTexCoord(0, 1, 0.24609375, 0.49609375) - else - button.texture:SetTexCoord(0, 1, 0, 0.24609375) - end - end - end - - if (object.capsule_textalign) then - if (object.icon) then - object.icon:SetPoint("left", button, "left", 4 + (object.icon.leftpadding or 0), 0) - - elseif (object.capsule_textalign == "left") then - button.text:SetPoint("left", button, "left", 2, 0) - - elseif (object.capsule_textalign == "center") then - button.text:SetPoint("center", button, "center", 0, 0) - - elseif (object.capsule_textalign == "right") then - button.text:SetPoint("right", button, "right", -2, 0) - end - else - if (object.icon) then - object.icon:SetPoint("left", button, "left", 4 + (object.icon.leftpadding or 0), 0) - else - button.text:SetPoint("center", button,"center", 0, 0) - end - end - - if (object.container.isMoving) then - object.container:StopMovingOrSizing() - object.container.isMoving = false - end - - local x, y = GetCursorPosition() - x = math.floor(x) - y = math.floor(y) - - button.mouse_down = button.mouse_down or 0 --avoid issues when the button was pressed while disabled and release when enabled - - if ((x == button.x and y == button.y) or (button.mouse_down + 0.5 > GetTime() and button:IsMouseOver())) then - if (buttonType == "LeftButton") then - detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.func, button, buttonType, object.param1, object.param2) - else - detailsFramework:CoreDispatch((button:GetName() or "Button") .. ":OnMouseUp()", object.funcright, button, buttonType, object.param1, object.param2) - end - end - end - ------------------------------------------------------------------------------------------------------------- - ----receives a table where the keys are settings and the values are the values to set ----this is the list of keys the table support: ----width, height, icon|table, textcolor, textsize, textfont, textalign, backdrop, backdropcolor, backdropbordercolor, onentercolor, onleavecolor, onenterbordercolor, onleavebordercolor ----@param template table -function ButtonMetaFunctions:SetTemplate(template) - if (type(template) == "string") then - template = detailsFramework:GetTemplate("button", template) - end - - if (not template) then - detailsFramework:Error("template not found") - return - end - - if (template.width) then - self:SetWidth(template.width) - end - - if (template.height) then - self:SetHeight(template.height) - end - - if (template.backdrop) then - self:SetBackdrop(template.backdrop) - end - - if (template.backdropcolor) then - local r, g, b, a = detailsFramework:ParseColors(template.backdropcolor) - self:SetBackdropColor(r, g, b, a) - self.onleave_backdrop = {r, g, b, a} - end - - if (template.backdropbordercolor) then - local r, g, b, a = detailsFramework:ParseColors(template.backdropbordercolor) - self:SetBackdropBorderColor(r, g, b, a) - self.onleave_backdrop_border_color = {r, g, b, a} - end - - if (template.onentercolor) then - local r, g, b, a = detailsFramework:ParseColors(template.onentercolor) - self.onenter_backdrop = {r, g, b, a} - end - - if (template.onleavecolor) then - local r, g, b, a = detailsFramework:ParseColors(template.onleavecolor) - self.onleave_backdrop = {r, g, b, a} - end - - if (template.onenterbordercolor) then - local r, g, b, a = detailsFramework:ParseColors(template.onenterbordercolor) - self.onenter_backdrop_border_color = {r, g, b, a} - end - - if (template.onleavebordercolor) then - local r, g, b, a = detailsFramework:ParseColors(template.onleavebordercolor) - self.onleave_backdrop_border_color = {r, g, b, a} - end - - if (template.icon) then - local iconInfo = template.icon - self:SetIcon(iconInfo.texture, iconInfo.width, iconInfo.height, iconInfo.layout, iconInfo.texcoord, iconInfo.color, iconInfo.textdistance, iconInfo.leftpadding) - end - - if (template.textsize) then - self.textsize = template.textsize - end - - if (template.textfont) then - self.textfont = template.textfont - end - - if (template.textcolor) then - self.textcolor = template.textcolor - end - - if (template.textalign) then - self.textalign = template.textalign - end -end - ------------------------------------------------------------------------------------------------------------- ---object constructor - local onDisableFunc = function(self) - self.texture_disabled:Show() - self.texture_disabled:SetVertexColor(0, 0, 0) - self.texture_disabled:SetAlpha(.5) - end - - local onEnableFunc = function(self) - self.texture_disabled:Hide() - end - - local createButtonWidgets = function(self) - self:SetSize(100, 20) - - self.text = self:CreateFontString("$parent_Text", "ARTWORK", "GameFontNormal") - self.text:SetJustifyH("CENTER") - self.text:SetPoint("CENTER", self, "CENTER", 0, 0) - self:SetFontString(self.text) - detailsFramework:SetFontSize(self.text, 10) - - self.texture_disabled = self:CreateTexture("$parent_TextureDisabled", "OVERLAY") - self.texture_disabled:SetAllPoints() - self.texture_disabled:Hide() - self.texture_disabled:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background") - - self:SetScript("OnDisable", onDisableFunc) - self:SetScript("OnEnable", onEnableFunc) - end - - ---@class df_button : button - ---@field widget button - ---@field tooltip string - ---@field shown boolean - ---@field width number - ---@field height number - ---@field text string - ---@field clickfunction function - ---@field texture string - ---@field locked boolean - ---@field fontcolor any - ---@field fontface string - ---@field fontsize number - ---@field textcolor any - ---@field textfont string - ---@field textsize number - ---@field SetTemplate fun(self: df_button, template: table) set the button visual by a template - ---@field RightClick fun(self: df_button) right click the button executing its right click function - ---@field Exec fun(self: df_button) execute the button function for the left button - ---@field Disable fun(self: df_button) disable the button - ---@field Enable fun(self: df_button) enable the button - ---@field IsEnabled fun(self: df_button) : boolean returns true if the button is enabled - ---@field SetIcon fun(self: df_button,texture: string, width: number|nil, height: number|nil, layout: string|nil, texcoord: table|nil, overlay: table|nil, textDistance: number|nil, leftPadding: number|nil, textHeight: number|nil, shortMethod: any|nil) - ---@field GetIconTexture fun(self: df_button) : string returns the texture path of the button icon - ---@field SetTexture fun(self: df_button, normalTexture: string, highlightTexture: string, pressedTexture: string, disabledTexture: string) set the regular button textures - ---@field SetFontFace fun(self: df_button, font: string) set the button font - ---@field SetFontSize fun(self: df_button, size: number) set the button font size - ---@field SetTextColor fun(self: df_button, color: any) set the button text color - ---@field SetText fun(self: df_button, text: string) set the button text - ---@field SetClickFunction fun(self: df_button, func: function, param1: any, param2: any, clickType: "left"|"right"|nil) - - ---create a Details Framework button - ---@param parent table - ---@param func function - ---@param width number - ---@param height number - ---@param text string - ---@param param1 any|nil - ---@param param2 any|nil - ---@param texture any|nil - ---@param member string|nil - ---@param name string|nil - ---@param shortMethod boolean|nil - ---@param buttonTemplate table|nil - ---@param textTemplate table|nil - ---@return df_button - function detailsFramework:CreateButton(parent, func, width, height, text, param1, param2, texture, member, name, shortMethod, buttonTemplate, textTemplate) - return detailsFramework:NewButton(parent, parent, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate) - end - - ---@return df_button - function detailsFramework:NewButton(parent, container, name, member, width, height, func, param1, param2, texture, text, shortMethod, buttonTemplate, textTemplate) - if (not name) then - name = "DetailsFrameworkButtonNumber" .. detailsFramework.ButtonCounter - detailsFramework.ButtonCounter = detailsFramework.ButtonCounter + 1 - - elseif (not parent) then - error("Details! FrameWork: parent not found.", 2) - end - - if (name:find("$parent")) then - local parentName = detailsFramework.GetParentName(parent) - name = name:gsub("$parent", parentName) - end - - local buttonObject = {type = "button", dframework = true} - - if (member) then - parent[member] = buttonObject - end - - if (parent.dframework) then - parent = parent.widget - end - - --container is used to move the 'container' frame when attempt to move the button - buttonObject.container = container or parent - - --default members - buttonObject.is_locked = true - buttonObject.options = {OnGrab = false} - - buttonObject.button = CreateFrame("button", name, parent, "BackdropTemplate") - detailsFramework:Mixin(buttonObject.button, detailsFramework.WidgetFunctions) - - createButtonWidgets(buttonObject.button) - buttonObject.button:SetSize(width or 100, height or 20) - buttonObject.widget = buttonObject.button - buttonObject.button.MyObject = buttonObject - - if (not APIButtonFunctions) then - APIButtonFunctions = true - local idx = getmetatable(buttonObject.button).__index - for funcName, funcAddress in pairs(idx) do - if (not ButtonMetaFunctions[funcName]) then - ButtonMetaFunctions[funcName] = function(object, ...) - local x = loadstring("return _G['"..object.button:GetName().."']:"..funcName.."(...)") - return x(...) - end - end - end - end - - buttonObject.text_overlay = _G[name .. "_Text"] - buttonObject.disabled_overlay = _G[name .. "_TextureDisabled"] - - texture = texture or "" - buttonObject.button:SetNormalTexture(texture) - buttonObject.button:SetPushedTexture(texture) - buttonObject.button:SetDisabledTexture(texture) - buttonObject.button:SetHighlightTexture(texture, "ADD") - - local locTable = text - detailsFramework.Language.SetTextWithLocTableWithDefault(buttonObject.button.text, locTable, text) - - buttonObject.button.text:SetPoint("center", buttonObject.button, "center") - - local textWidth = buttonObject.button.text:GetStringWidth() - if (textWidth > width - 15 and buttonObject.button.text:GetText() ~= "") then - if (shortMethod == false) then --if is false, do not use auto resize - --do nothing - elseif (not shortMethod) then --if the value is omitted, use the default resize - local new_width = textWidth + 15 - buttonObject.button:SetWidth(new_width) - - elseif (shortMethod == 1) then - local loop = true - local textsize = 11 - while (loop) do - if (textWidth + 15 < width or textsize < 8) then - loop = false - break - else - detailsFramework:SetFontSize(buttonObject.button.text, textsize) - textWidth = buttonObject.button.text:GetStringWidth() - textsize = textsize - 1 - end - end - elseif (shortMethod == 2) then - - end - end - - buttonObject.func = func or emptyFunction - buttonObject.funcright = emptyFunction - buttonObject.param1 = param1 - buttonObject.param2 = param2 - buttonObject.short_method = shortMethod - - if (textTemplate) then - if (textTemplate.size) then - detailsFramework:SetFontSize(buttonObject.button.text, textTemplate.size) - end - - if (textTemplate.color) then - local r, g, b, a = detailsFramework:ParseColors(textTemplate.color) - buttonObject.button.text:SetTextColor(r, g, b, a) - end - - if (textTemplate.font) then - local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0") - local font = SharedMedia:Fetch("font", textTemplate.font) - detailsFramework:SetFontFace(buttonObject.button.text, font) - end - end - - --hooks - buttonObject.HookList = { - OnEnter = {}, - OnLeave = {}, - OnHide = {}, - OnShow = {}, - OnMouseDown = {}, - OnMouseUp = {}, - } - - buttonObject.button:SetScript("OnEnter", OnEnter) - buttonObject.button:SetScript("OnLeave", OnLeave) - buttonObject.button:SetScript("OnHide", OnHide) - buttonObject.button:SetScript("OnShow", OnShow) - buttonObject.button:SetScript("OnMouseDown", OnMouseDown) - buttonObject.button:SetScript("OnMouseUp", OnMouseUp) - - setmetatable(buttonObject, ButtonMetaFunctions) - - if (buttonTemplate) then - buttonObject:SetTemplate(buttonTemplate) - end - - return buttonObject - end - ------------------------------------------------------------------------------------------------------------- ---color picker button - local pickcolorCallback = function(self, red, green, blue, alpha, button) - alpha = math.abs(alpha - 1) - button.MyObject.color_texture:SetVertexColor(red, green, blue, alpha) - - --safecall - detailsFramework:CoreDispatch((self:GetName() or "ColorPicker") .. ".pickcolor_callback()", button.MyObject.color_callback, button.MyObject, red, green, blue, alpha) - button.MyObject:RunHooksForWidget("OnColorChanged", button.MyObject, red, green, blue, alpha) - end - - local pickcolor = function(self) - local red, green, blue, alpha = self.MyObject.color_texture:GetVertexColor() - alpha = math.abs(alpha - 1) - detailsFramework:ColorPick(self, red, green, blue, alpha, pickcolorCallback) - end - - local setColorPickColor = function(button, ...) - local red, green, blue, alpha = detailsFramework:ParseColors(...) - button.color_texture:SetVertexColor(red, green, blue, alpha) - end - - local colorpickCancel = function(self) - ColorPickerFrame:Hide() - end - - local getColorPickColor = function(self) - return self.color_texture:GetVertexColor() - end - - ---create a button which opens a color picker when clicked - ---@param parent table - ---@param name string|nil - ---@param member string|nil - ---@param callback function - ---@param alpha number|nil - ---@param buttonTemplate table|nil - ---@return table|nil - function detailsFramework:CreateColorPickButton(parent, name, member, callback, alpha, buttonTemplate) - return detailsFramework:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate) - end - - function detailsFramework:NewColorPickButton(parent, name, member, callback, alpha, buttonTemplate) - --button - local colorPickButton = detailsFramework:NewButton(parent, _, name, member, 16, 16, pickcolor, alpha, "param2", nil, nil, nil, buttonTemplate) - colorPickButton.color_callback = callback - colorPickButton.Cancel = colorpickCancel - colorPickButton.SetColor = setColorPickColor - colorPickButton.GetColor = getColorPickColor - - colorPickButton.HookList.OnColorChanged = {} - - if (not buttonTemplate) then - colorPickButton:SetTemplate(detailsFramework:GetTemplate("button", "OPTIONS_BUTTON_TEMPLATE")) - end - - --background showing a grid to indicate the transparency - local background = colorPickButton:CreateTexture(nil, "background", nil, 2) - background:SetPoint("topleft", colorPickButton.widget, "topleft", 0, 0) - background:SetPoint("bottomright", colorPickButton.widget, "bottomright", 0, 0) - background:SetTexture([[Interface\ITEMSOCKETINGFRAME\UI-EMPTYSOCKET]]) - background:SetTexCoord(3/16, 13/16, 3/16, 13/16) - background:SetAlpha(0.3) - - --texture which shows the texture color - local colorTexture = detailsFramework:NewImage(colorPickButton, nil, 16, 16, nil, nil, "color_texture", "$parentTex") - colorTexture:SetColorTexture(1, 1, 1) - colorTexture:SetPoint("topleft", colorPickButton.widget, "topleft", 0, 0) - colorTexture:SetPoint("bottomright", colorPickButton.widget, "bottomright", 0, 0) - colorTexture:SetDrawLayer("background", 3) - - return colorPickButton - end - - function detailsFramework:SetRegularButtonTexture(button, texture, left, right, top, bottom) - if (type(left) == "table") then - left, right, top, bottom = unpack(left) - end - - if (not left) then - left, right, top, bottom = 0, 1, 0, 1 - end - - local atlas - if (type(texture) == "string") then - atlas = C_Texture.GetAtlasInfo(texture) - end - - local normalTexture = button:GetNormalTexture() - local pushedTexture = button:GetPushedTexture() - local highlightTexture = button:GetHightlightTexture() - local disabledTexture = button:GetDisabledTexture() - - if (atlas) then - normalTexture:SetAtlas(texture) - pushedTexture:SetAtlas(texture) - highlightTexture:SetAtlas(texture) - disabledTexture:SetAtlas(texture) - else - normalTexture:SetTexture(texture) - pushedTexture:SetTexture(texture) - highlightTexture:SetTexture(texture) - disabledTexture:SetTexture(texture) - normalTexture:SetTexCoord(left, right, top, bottom) - pushedTexture:SetTexCoord(left, right, top, bottom) - highlightTexture:SetTexCoord(left, right, top, bottom) - disabledTexture:SetTexCoord(left, right, top, bottom) - end - end - - function detailsFramework:SetRegularButtonVertexColor(button, ...) - local r, g, b, a = detailsFramework:ParseColor(...) - local normalTexture = button:GetNormalTexture() - local pushedTexture = button:GetPushedTexture() - local highlightTexture = button:GetHightlightTexture() - local disabledTexture = button:GetDisabledTexture() - - normalTexture:SetVertexColor(r, g, b, a) - pushedTexture:SetVertexColor(r, g, b, a) - highlightTexture:SetVertexColor(r, g, b, a) - disabledTexture:SetVertexColor(r, g, b, a) - end - - ------------------------------------------------------------------------------------------------------------- ---tab button - ----@class df_tabbutton : button ----@field LeftTexture texture ----@field RightTexture texture ----@field MiddleTexture texture ----@field SelectedTexture texture ----@field Text fontstring ----@field CloseButton df_closebutton ----@field leftTextureName string ----@field rightTextureName string ----@field middleTextureName string ----@field leftTextureSelectedName string ----@field rightTextureSelectedName string ----@field middleTextureSelectedName string ----@field bIsSelected boolean ----@field SetText fun(self: df_tabbutton, text: string) ----@field SetSelected fun(self: df_tabbutton, selected: boolean) ----@field IsSelected fun(self: df_tabbutton): boolean ----@field Reset fun(self: df_tabbutton) - -detailsFramework.TabButtonMixin = { - ---set the text of the tab button - ---@param self df_tabbutton - ---@param text string - SetText = function(self, text) - self.Text:SetText(text) - --adjust the width of the tab button to fit the text - local fontStringLength = self.Text:GetStringWidth() - self:SetWidth(fontStringLength + 20) - end, - - ---highlight the tab textures to indicate the tab is selected - ---@param self df_tabbutton - ---@param selected boolean - SetSelected = function(self, selected) - self.LeftTexture:SetAtlas(selected and self.leftTextureSelectedName or self.leftTextureName) - self.RightTexture:SetAtlas(selected and self.rightTextureSelectedName or self.rightTextureName) - self.MiddleTexture:SetAtlas(selected and self.middleTextureSelectedName or self.middleTextureName) - self.SelectedTexture:SetShown(selected) - self.bIsSelected = selected - end, - - ---get a boolean representing if the tab is selected - ---@param self df_tabbutton - ---@return boolean - IsSelected = function(self) - return self.bIsSelected - end, - - ---set all textures to their default values, set the text to an empty string, set the selected state to false - ---@param self df_tabbutton - Reset = function(self) - self.LeftTexture:SetAtlas(self.leftTextureName) - self.RightTexture:SetAtlas(self.rightTextureName) - self.MiddleTexture:SetAtlas(self.middleTextureName) - self.Text:SetText("") - self.bIsSelected = false - self.SelectedTexture:Hide() - end, - -} - ----create a button which can be used as a tab button, has textures for left, right, middle and a text ----@param parent frame ----@param frameName string|nil ----@return df_tabbutton -function detailsFramework:CreateTabButton(parent, frameName) - ---@type df_tabbutton - local tabButton = CreateFrame("button", frameName, parent) - tabButton:SetSize(50, 20) - tabButton.bIsSelected = false - - detailsFramework:Mixin(tabButton, detailsFramework.TabButtonMixin) - - tabButton.LeftTexture = tabButton:CreateTexture(nil, "artwork") - tabButton.RightTexture = tabButton:CreateTexture(nil, "artwork") - tabButton.MiddleTexture = tabButton:CreateTexture(nil, "artwork") - tabButton.SelectedTexture = tabButton:CreateTexture(nil, "overlay") - tabButton.SelectedTexture:SetBlendMode("ADD") - tabButton.SelectedTexture:SetAlpha(0.5) - tabButton.SelectedTexture:Hide() - tabButton.Text = tabButton:CreateFontString(nil, "overlay", "GameFontNormal") - tabButton.CloseButton = detailsFramework:CreateCloseButton(tabButton, "$parentCloseButton") - - tabButton.Text:SetPoint("center", tabButton, "center", 0, 0) - tabButton.CloseButton:SetPoint("topright", tabButton, "topright", 0, 0) - - tabButton.LeftTexture:SetPoint("bottomleft", tabButton, "bottomleft", 0, 0) - tabButton.LeftTexture:SetPoint("topleft", tabButton, "topleft", 0, 0) - - tabButton.RightTexture:SetPoint("bottomright", tabButton, "bottomright", 0, 0) - tabButton.RightTexture:SetPoint("topright", tabButton, "topright", 0, 0) - - tabButton.MiddleTexture:SetPoint("topleft", tabButton.LeftTexture, "topright", 0, 0) - tabButton.MiddleTexture:SetPoint("topright", tabButton.RightTexture, "topleft", 0, 0) - - tabButton.SelectedTexture:SetAllPoints(tabButton.MiddleTexture) - - tabButton.leftTextureName = "Options_Tab_Left" - tabButton.rightTextureName = "Options_Tab_Right" - tabButton.middleTextureName = "Options_Tab_Middle" - - tabButton.leftTextureSelectedName = "Options_Tab_Active_Left" - tabButton.rightTextureSelectedName = "Options_Tab_Active_Right" - tabButton.middleTextureSelectedName = "Options_Tab_Active_Middle" - - tabButton.LeftTexture:SetAtlas(tabButton.leftTextureName) - tabButton.LeftTexture:SetWidth(2) - - tabButton.RightTexture:SetAtlas(tabButton.rightTextureName) - tabButton.RightTexture:SetWidth(2) - - tabButton.MiddleTexture:SetAtlas(tabButton.middleTextureName) - tabButton.MiddleTexture:SetHeight(20) - - tabButton.SelectedTexture:SetTexture([[Interface\PaperDollInfoFrame\UI-Character-Tab-Highlight-yellow]]) - - tabButton.Text:SetText("") - - return tabButton -end - ------------------------------------------------------------------------------------------------------------- ---close button - -detailsFramework.CloseButtonMixin = { - OnClick = function(self) - self:GetParent():Hide() - end, - OnEnter = function(self) - self:GetNormalTexture():SetVertexColor(1, 0, 0) - end, - OnLeave = function(self) - self:GetNormalTexture():SetVertexColor(1, 1, 1) - end, -} - ----@class df_closebutton : button ----@field OnClick fun(self: df_closebutton) ----@field OnEnter fun(self: df_closebutton) ----@field OnLeave fun(self: df_closebutton) - ----create a close button which when clicked will hide the parent frame ----@param parent frame ----@param frameName string|nil ----@return df_closebutton -function detailsFramework:CreateCloseButton(parent, frameName) --make documentation - ---@type df_closebutton - local closeButton = CreateFrame("button", frameName, parent, "UIPanelCloseButton") - closeButton:SetFrameLevel(parent:GetFrameLevel() + 1) - closeButton:SetSize(16, 16) - - detailsFramework:Mixin(closeButton, detailsFramework.CloseButtonMixin) - - local normalTexture = closeButton:GetNormalTexture() - local pushedTexture = closeButton:GetPushedTexture() - local highlightTexture = closeButton:GetHighlightTexture() - local disabledTexture = closeButton:GetDisabledTexture() - - normalTexture:SetAtlas("RedButton-Exit") - highlightTexture:SetAtlas("RedButton-Highlight") - pushedTexture:SetAtlas("RedButton-exit-pressed") - disabledTexture:SetAtlas("RedButton-Exit-Disabled") - - normalTexture:SetDesaturated(true) - highlightTexture:SetDesaturated(true) - pushedTexture:SetDesaturated(true) - - closeButton:SetAlpha(0.7) - closeButton:SetScript("OnClick", closeButton.OnClick) - closeButton:SetScript("OnEnter", closeButton.OnEnter) - closeButton:SetScript("OnLeave", closeButton.OnLeave) - - return closeButton -end - ---[=[ - --example: - local frame = CreateFrame("frame", "MyTestFrameForCloseButton", UIParent) - frame:SetSize(200, 200) - frame:SetPoint("center", UIParent, "center", 0, 0) - - local closeButton = detailsFramework:CreateCloseButton(frame, "$parentCloseButton") - closeButton:SetPoint("topright", frame, "topright", 0, 0) ---]=] \ No newline at end of file diff --git a/plugins/Details_EncounterDetails/Libs/DF/button.xml b/plugins/Details_EncounterDetails/Libs/DF/button.xml deleted file mode 100644 index aa885f31..00000000 --- a/plugins/Details_EncounterDetails/Libs/DF/button.xml +++ /dev/null @@ -1,3 +0,0 @@ - -