From 299fb53df3bf28610eb9c7bc9e489b07ebdc834e Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Mon, 17 Feb 2020 16:47:28 -0300 Subject: [PATCH] ToC 8.3, framework update --- FlashTaskBar.toc | 2 +- libs/DF/auras.lua | 2 +- libs/DF/fw.lua | 269 ++++++++++++++++++++++++++++++++++++---- libs/DF/panel.lua | 132 ++++++++++++++++++-- libs/DF/pictureedit.lua | 141 ++++++++++++--------- libs/DF/slider.lua | 12 ++ libs/DF/spells.lua | 52 +++++++- libs/DF/textentry.lua | 88 ++++++++++--- 8 files changed, 589 insertions(+), 109 deletions(-) diff --git a/FlashTaskBar.toc b/FlashTaskBar.toc index 1162392..998cc57 100644 --- a/FlashTaskBar.toc +++ b/FlashTaskBar.toc @@ -1,4 +1,4 @@ -## Interface: 80205 +## Interface: 80300 ## Title: Flash Task Bar ## Notes: Flashes the taskbar when you are alt-tabbed and queue for raid finder, battleground pops up. ## SavedVariables: FlashTaskbarDB diff --git a/libs/DF/auras.lua b/libs/DF/auras.lua index 345ede7..9adf115 100644 --- a/libs/DF/auras.lua +++ b/libs/DF/auras.lua @@ -10,7 +10,7 @@ local GetSpellInfo = GetSpellInfo local lower = string.lower local GetSpellBookItemInfo = GetSpellBookItemInfo -local CONST_MAX_SPELLS = 300000 +local CONST_MAX_SPELLS = 400000 function DF:GetAuraByName (unit, spellName, isDebuff) isDebuff = isDebuff and "HARMFUL|PLAYER" diff --git a/libs/DF/fw.lua b/libs/DF/fw.lua index 22ebb26..b7f5b19 100644 --- a/libs/DF/fw.lua +++ b/libs/DF/fw.lua @@ -1,5 +1,5 @@ -local dversion = 161 +local dversion = 170 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) @@ -18,6 +18,9 @@ local _unpack = unpack local upper = string.upper local string_match = string.match +local UnitPlayerControlled = UnitPlayerControlled +local UnitIsTapDenied = UnitIsTapDenied + SMALL_NUMBER = 0.000001 ALPHA_BLEND_AMOUNT = 0.8400251 @@ -131,6 +134,8 @@ DF.SplitBarCounter = DF.SplitBarCounter or init_counter DF.FRAMELEVEL_OVERLAY = 750 DF.FRAMELEVEL_BACKGROUND = 150 +--/dump DetailsFramework:PrintVersion() + DF.FrameWorkVersion = tostring (dversion) function DF:PrintVersion() print ("Details! Framework Version:", DF.FrameWorkVersion) @@ -314,6 +319,22 @@ function DF.table.copy (t1, t2) return t1 end +--> copy from table2 to table1 overwriting values but do not copy data that cannot be compressed +function DF.table.copytocompress (t1, t2) + for key, value in pairs (t2) do + print (key, value) + if (key ~= "__index" and type(value) ~= "function") then + if (type (value) == "table") then + t1 [key] = t1 [key] or {} + DF.table.copytocompress (t1 [key], t2 [key]) + else + t1 [key] = value + end + end + end + return t1 +end + --> copy values that does exist on table2 but not on table1 function DF.table.deploy (t1, t2) for key, value in pairs (t2) do @@ -942,6 +963,10 @@ end label:SetPoint (cur_x, cur_y) tinsert (parent.widget_list, label) line_widgets_created = line_widgets_created + 1 + + if (widget_table.id) then + parent.widgetids [widget_table.id] = label + end elseif (widget_table.type == "select" or widget_table.type == "dropdown") then local dropdown = DF:NewDropDown (parent, nil, "$parentWidget" .. index, nil, 140, 18, widget_table.values, widget_table.get(), dropdown_template) @@ -963,6 +988,10 @@ end dropdown:SetHook (hookName, hookFunc) end end + + if (widget_table.id) then + parent.widgetids [widget_table.id] = dropdown + end local size = label.widget:GetStringWidth() + 140 + 4 if (size > max_x) then @@ -996,8 +1025,17 @@ end end local label = DF:NewLabel (parent, nil, "$parentLabel" .. index, nil, widget_table.name .. (use_two_points and ": " or ""), "GameFontNormal", widget_table.text_template or text_template or 12) - switch:SetPoint ("left", label, "right", 2) - label:SetPoint (cur_x, cur_y) + if (widget_table.boxfirst) then + switch:SetPoint (cur_x, cur_y) + label:SetPoint ("left", switch, "right", 2) + else + label:SetPoint (cur_x, cur_y) + switch:SetPoint ("left", label, "right", 2) + end + + if (widget_table.id) then + parent.widgetids [widget_table.id] = switch + end local size = label.widget:GetStringWidth() + 60 + 4 if (size > max_x) then @@ -1037,6 +1075,10 @@ end slider:SetPoint ("left", label, "right", 2) label:SetPoint (cur_x, cur_y) + if (widget_table.id) then + parent.widgetids [widget_table.id] = slider + end + local size = label.widget:GetStringWidth() + 140 + 6 if (size > max_x) then max_x = size @@ -1074,6 +1116,10 @@ end colorpick:SetPoint ("left", label, "right", 2) label:SetPoint (cur_x, cur_y) + if (widget_table.id) then + parent.widgetids [widget_table.id] = colorpick + end + local size = label.widget:GetStringWidth() + 60 + 4 if (size > max_x) then max_x = size @@ -1102,6 +1148,10 @@ end button:SetHook (hookName, hookFunc) end end + + if (widget_table.id) then + parent.widgetids [widget_table.id] = button + end local size = button:GetWidth() + 4 if (size > max_x) then @@ -1133,6 +1183,10 @@ end textentry:SetHook (hookName, hookFunc) end end + + if (widget_table.id) then + parent.widgetids [widget_table.id] = textentry + end local size = label.widget:GetStringWidth() + 60 + 4 if (size > max_x) then @@ -1296,9 +1350,15 @@ end end end + local get_frame_by_id = function (self, id) + return self.widgetids [id] + end + function DF:SetAsOptionsPanel (frame) frame.RefreshOptions = refresh_options frame.widget_list = {} + frame.widgetids = {} + frame.GetWidgetById = get_frame_by_id end function DF:CreateOptionsFrame (name, title, template) @@ -2504,28 +2564,31 @@ function DF:ReskinSlider (slider, heightOffset) else --up button + + local offset = 1 --space between the scrollbox and the scrollar + do local normalTexture = slider.ScrollBar.ScrollUpButton.Normal normalTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Up]]) normalTexture:SetTexCoord (0, 1, .2, 1) - normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0) - normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0) + normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", offset, 0) + normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", offset, 0) local pushedTexture = slider.ScrollBar.ScrollUpButton.Pushed pushedTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Down]]) pushedTexture:SetTexCoord (0, 1, .2, 1) - pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0) - pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0) + pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", offset, 0) + pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", offset, 0) local disabledTexture = slider.ScrollBar.ScrollUpButton.Disabled disabledTexture:SetTexture ([[Interface\Buttons\Arrow-Up-Disabled]]) disabledTexture:SetTexCoord (0, 1, .2, 1) disabledTexture:SetAlpha (.5) - disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", 1, 0) - disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", 1, 0) + disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollUpButton, "topleft", offset, 0) + disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollUpButton, "bottomright", offset, 0) slider.ScrollBar.ScrollUpButton:SetSize (16, 16) slider.ScrollBar.ScrollUpButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"}) @@ -2542,23 +2605,23 @@ function DF:ReskinSlider (slider, heightOffset) normalTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Up]]) normalTexture:SetTexCoord (0, 1, 0, .8) - normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4) - normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4) + normalTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", offset, -4) + normalTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", offset, -4) local pushedTexture = slider.ScrollBar.ScrollDownButton.Pushed pushedTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Down]]) pushedTexture:SetTexCoord (0, 1, 0, .8) - pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4) - pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4) + pushedTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", offset, -4) + pushedTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", offset, -4) local disabledTexture = slider.ScrollBar.ScrollDownButton.Disabled disabledTexture:SetTexture ([[Interface\Buttons\Arrow-Down-Disabled]]) disabledTexture:SetTexCoord (0, 1, 0, .8) disabledTexture:SetAlpha (.5) - disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", 1, -4) - disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", 1, -4) + disabledTexture:SetPoint ("topleft", slider.ScrollBar.ScrollDownButton, "topleft", offset, -4) + disabledTexture:SetPoint ("bottomright", slider.ScrollBar.ScrollDownButton, "bottomright", offset, -4) slider.ScrollBar.ScrollDownButton:SetSize (16, 16) slider.ScrollBar.ScrollDownButton:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = "Interface\\Tooltips\\UI-Tooltip-Background"}) @@ -2569,11 +2632,16 @@ function DF:ReskinSlider (slider, heightOffset) --slider.ScrollBar.ScrollDownButton:SetPoint ("top", slider.ScrollBar, "bottom", 0, 0) end - -- - - slider.ScrollBar:SetPoint ("TOPLEFT", slider, "TOPRIGHT", 6, -16) - slider.ScrollBar:SetPoint ("BOTTOMLEFT", slider, "BOTTOMRIGHT", 6, 16 + (heightOffset and heightOffset*-1 or 0)) - + --if the parent has a editbox, this is a code editor + if (slider:GetParent().editbox) then + slider.ScrollBar:SetPoint ("TOPLEFT", slider, "TOPRIGHT", 12 + offset, -6) + slider.ScrollBar:SetPoint ("BOTTOMLEFT", slider, "BOTTOMRIGHT", 12 + offset, 6 + (heightOffset and heightOffset*-1 or 0)) + + else + slider.ScrollBar:SetPoint ("TOPLEFT", slider, "TOPRIGHT", 6, -16) + slider.ScrollBar:SetPoint ("BOTTOMLEFT", slider, "BOTTOMRIGHT", 6, 16 + (heightOffset and heightOffset*-1 or 0)) + end + slider.ScrollBar.ThumbTexture:SetColorTexture (.5, .5, .5, .3) slider.ScrollBar.ThumbTexture:SetSize (12, 8) @@ -2886,6 +2954,157 @@ function DF:GetCLEncounterIDs() return DF.CLEncounterID end +DF.ClassSpecs = { + ["DEMONHUNTER"] = { + [577] = true, + [581] = true, + }, + ["DEATHKNIGHT"] = { + [250] = true, + [251] = true, + [252] = true, + }, + ["WARRIOR"] = { + [71] = true, + [72] = true, + [73] = true, + }, + ["MAGE"] = { + [62] = true, + [63] = true, + [64] = true, + }, + ["ROGUE"] = { + [259] = true, + [260] = true, + [261] = true, + }, + ["DRUID"] = { + [102] = true, + [103] = true, + [104] = true, + [105] = true, + }, + ["HUNTER"] = { + [253] = true, + [254] = true, + [255] = true, + }, + ["SHAMAN"] = { + [262] = true, + [263] = true, + [264] = true, + }, + ["PRIEST"] = { + [256] = true, + [257] = true, + [258] = true, + }, + ["WARLOCK"] = { + [265] = true, + [266] = true, + [267] = true, + }, + ["PALADIN"] = { + [65] = true, + [66] = true, + [70] = true, + }, + ["MONK"] = { + [268] = true, + [269] = true, + [270] = true, + }, +} + +DF.SpecListByClass = { + ["DEMONHUNTER"] = { + 577, + 581, + }, + ["DEATHKNIGHT"] = { + 250, + 251, + 252, + }, + ["WARRIOR"] = { + 71, + 72, + 73, + }, + ["MAGE"] = { + 62, + 63, + 64, + }, + ["ROGUE"] = { + 259, + 260, + 261, + }, + ["DRUID"] = { + 102, + 103, + 104, + 105, + }, + ["HUNTER"] = { + 253, + 254, + 255, + }, + ["SHAMAN"] = { + 262, + 263, + 264, + }, + ["PRIEST"] = { + 256, + 257, + 258, + }, + ["WARLOCK"] = { + 265, + 266, + 267, + }, + ["PALADIN"] = { + 65, + 66, + 70, + }, + ["MONK"] = { + 268, + 269, + 270, + }, +} + +--given a class and a specId, return if the specId is a spec from the class passed +function DF:IsSpecFromClass(class, specId) + return DF.ClassSpecs[class] and DF.ClassSpecs[class][specId] +end + +--return a has table where specid is the key and 'true' is the value +function DF:GetClassSpecs(class) + return DF.ClassSpecs [class] +end + +--return a numeric table with spec ids +function DF:GetSpecListFromClass(class) + return DF.SpecListByClass [class] +end + +--return a list with specIds as keys and spellId as value +function DF:GetSpellsForRangeCheck() + return SpellRangeCheckListBySpec +end + +--return a list with specIds as keys and spellId as value +function DF:GetRangeCheckSpellForSpec(specId) + return SpellRangeCheckListBySpec[specId] +end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --> delta seconds reader @@ -2995,5 +3214,11 @@ DF.DebugMixin = { } ---doo elsee ---was doing double loops due to not enought height +----------------------------------------------------------------------------------------------------------------------------------------------------------- + +--> returns if the unit is tapped (gray health color when another player hit the unit first) +function DF:IsUnitTapDenied (unitId) + return unitId and not UnitPlayerControlled (unitId) and UnitIsTapDenied (unitId) +end + + diff --git a/libs/DF/panel.lua b/libs/DF/panel.lua index 177e793..b384ea7 100644 --- a/libs/DF/panel.lua +++ b/libs/DF/panel.lua @@ -5009,11 +5009,18 @@ DF.IconRowFunctions = { cooldownFrame:SetFrameLevel (newIconFrame:GetFrameLevel()+1) newIconFrame.CountdownText = cooldownFrame:CreateFontString (nil, "overlay", "GameFontNormal") - newIconFrame.CountdownText:SetPoint ("center") + --newIconFrame.CountdownText:SetPoint ("center") + newIconFrame.CountdownText:SetPoint (self.options.text_anchor or "center", newIconFrame, self.options.text_rel_anchor or "center", self.options.text_x_offset or 0, self.options.text_y_offset or 0) newIconFrame.CountdownText:Hide() + newIconFrame.StackText = cooldownFrame:CreateFontString (nil, "overlay", "GameFontNormal") + --newIconFrame.StackText:SetPoint ("bottomright") + newIconFrame.StackText:SetPoint (self.options.stack_text_anchor or "center", newIconFrame, self.options.stack_text_rel_anchor or "bottomright", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0) + newIconFrame.StackText:Hide() + newIconFrame.Desc = newIconFrame:CreateFontString (nil, "overlay", "GameFontNormal") - newIconFrame.Desc:SetPoint ("bottom", newIconFrame, "top", 0, 2) + --newIconFrame.Desc:SetPoint ("bottom", newIconFrame, "top", 0, 2) + newIconFrame.Desc:SetPoint(self.options.desc_text_anchor or "bottom", newIconFrame, self.options.desc_text_rel_anchor or "top", self.options.desc_text_x_offset or 0, self.options.desc_text_y_offset or 2) newIconFrame.Desc:Hide() newIconFrame.Cooldown = cooldownFrame @@ -5051,7 +5058,7 @@ DF.IconRowFunctions = { return iconFrame end, - SetIcon = function (self, spellId, borderColor, startTime, duration, forceTexture, descText) + SetIcon = function (self, spellId, borderColor, startTime, duration, forceTexture, descText, count, debuffType, caster, canStealOrPurge) local spellName, _, spellIcon @@ -5090,6 +5097,8 @@ DF.IconRowFunctions = { formattedTime = floor (formattedTime) end + iconFrame.CountdownText:SetPoint (self.options.text_anchor or "center", iconFrame, self.options.text_rel_anchor or "center", self.options.text_x_offset or 0, self.options.text_y_offset or 0) + DF:SetFontSize (iconFrame.CountdownText, self.options.text_size) iconFrame.CountdownText:SetText (formattedTime) iconFrame.Cooldown:SetHideCountdownNumbers (true) else @@ -5104,11 +5113,22 @@ DF.IconRowFunctions = { iconFrame.Desc:Show() iconFrame.Desc:SetText (descText.text) iconFrame.Desc:SetTextColor (DF:ParseColors (descText.text_color or self.options.desc_text_color)) + iconFrame.Desc:SetPoint(self.options.desc_text_anchor or "bottom", iconFrame, self.options.desc_text_rel_anchor or "top", self.options.desc_text_x_offset or 0, self.options.desc_text_y_offset or 2) DF:SetFontSize (iconFrame.Desc, descText.text_size or self.options.desc_text_size) else iconFrame.Desc:Hide() end + if (count and count > 1 and self.options.stack_text) then + iconFrame.StackText:Show() + iconFrame.StackText:SetText (count) + iconFrame.StackText:SetTextColor (DF:ParseColors (self.options.desc_text_color)) + iconFrame.StackText:SetPoint (self.options.stack_text_anchor or "center", iconFrame, self.options.stack_text_rel_anchor or "bottomright", self.options.stack_text_x_offset or 0, self.options.stack_text_y_offset or 0) + DF:SetFontSize (iconFrame.StackText, self.options.stack_text_size) + else + iconFrame.StackText:Hide() + end + PixelUtil.SetSize (iconFrame, self.options.icon_width, self.options.icon_height) iconFrame:Show() @@ -5116,6 +5136,15 @@ DF.IconRowFunctions = { self:SetWidth ((self.options.left_padding * 2) + (self.options.icon_padding * (self.NextIcon-2)) + (self.options.icon_width * (self.NextIcon - 1))) self:SetHeight (self.options.icon_height + (self.options.top_padding * 2)) + --> make information available + iconFrame.spellId = spellId + iconFrame.startTime = startTime + iconFrame.duration = duration + iconFrame.count = count + iconFrame.debuffType = debuffType + iconFrame.caster = caster + iconFrame.canStealOrPurge = canStealOrPurge + --> show the frame self:Show() @@ -5175,9 +5204,25 @@ local default_icon_row_options = { texcoord = {.1, .9, .1, .9}, show_text = true, text_color = {1, 1, 1, 1}, + text_size = 12, + text_anchor = "center", + text_rel_anchor = "center", + text_x_offset = 0, + text_y_offset = 0, desc_text = true, desc_text_color = {1, 1, 1, 1}, desc_text_size = 7, + desc_text_anchor = "bottom", + desc_text_rel_anchor = "top", + desc_text_x_offset = 0, + desc_text_y_offset = 2, + stack_text = true, + stack_text_color = {1, 1, 1, 1}, + stack_text_size = 10, + stack_text_anchor = "center", + stack_text_rel_anchor = "bottomright", + stack_text_x_offset = 0, + stack_text_y_offset = 0, left_padding = 1, --distance between right and left top_padding = 1, --distance between top and bottom icon_padding = 1, --distance between each icon @@ -6808,6 +6853,33 @@ function DF:BuildStatusbarAuthorInfo (f, addonBy, authorsNameString) end +local statusbar_default_options = { + attach = "bottom", --bottomleft from statusbar attach to bottomleft of the frame | other option is "top": topleft attach to bottomleft +} + +function DF:CreateStatusBar(f, options) + local statusBar = CreateFrame ("frame", nil, f) + + DF:Mixin (statusBar, DF.OptionsFunctions) + DF:Mixin (statusBar, DF.LayoutFrame) + + statusBar:BuildOptionsTable (statusbar_default_options, options) + + if (statusBar.options.attach == "bottom") then + statusBar:SetPoint ("bottomleft", f, "bottomleft") + statusBar:SetPoint ("bottomright", f, "bottomright") + + else + statusBar:SetPoint ("topleft", f, "bottomleft") + statusBar:SetPoint ("topright", f, "bottomright") + end + + statusBar:SetHeight (20) + DF:ApplyStandardBackdrop (statusBar) + statusBar:SetAlpha (0.8) + + return statusBar +end ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -9276,7 +9348,7 @@ DF.TimeLineBlockFunctions = { if (isAura) then block.auraLength:Show() block.auraLength:SetWidth (pixelPerSecond * isAura) - block:SetWidth (pixelPerSecond * isAura) + block:SetWidth (max (pixelPerSecond * isAura, 16)) else block.auraLength:Hide() end @@ -9284,7 +9356,7 @@ DF.TimeLineBlockFunctions = { block.background:SetVertexColor (0, 0, 0, 0) else block.background:SetVertexColor (unpack (color)) - PixelUtil.SetSize (block, width, self:GetHeight()) + PixelUtil.SetSize (block, max (width, 16), self:GetHeight()) block.auraLength:Hide() end end @@ -9521,7 +9593,12 @@ function DF:CreateTimeLineFrame (parent, name, options, timelineOptions) horizontalSlider:SetMinMaxValues (0, scrollWidth) horizontalSlider:SetValue (0) horizontalSlider:SetScript ("OnValueChanged", function (self) - frameCanvas:SetHorizontalScroll (self:GetValue()) + local _, maxValue = horizontalSlider:GetMinMaxValues() + local stepValue = ceil (ceil(self:GetValue() * maxValue)/maxValue) + if (stepValue ~= horizontalSlider.currentValue) then + horizontalSlider.currentValue = stepValue + frameCanvas:SetHorizontalScroll (stepValue) + end end) frameCanvas.horizontalSlider = horizontalSlider @@ -9552,9 +9629,12 @@ function DF:CreateTimeLineFrame (parent, name, options, timelineOptions) scaleSlider:SetValue (DF:GetRangeValue (frameCanvas.options.scale_min, frameCanvas.options.scale_max, 0.5)) scaleSlider:SetScript ("OnValueChanged", function (self) - local current = scaleSlider:GetValue() - frameCanvas.currentScale = current - frameCanvas:RefreshTimeLine() + local stepValue = ceil(self:GetValue() * 100)/100 + if (stepValue ~= frameCanvas.currentScale) then + local current = stepValue + frameCanvas.currentScale = stepValue + frameCanvas:RefreshTimeLine() + end end) --create vertical slider @@ -9734,6 +9814,38 @@ function DF:ShowErrorMessage (errorMessage, titleText) DF.ErrorMessagePanel.FlashAnimation:Play() end +--[[ + DF:SetPointOffsets(frame, xOffset, yOffset) + + Set an offset into the already existing offset of the frame + If passed xOffset:1 and yOffset:1 and the frame has 1 -1, the new offset will be 2 -2 + This function is great to create a 1 knob for distance + + @frame: a frame to have the offsets changed + @xOffset: the amount to apply into the x offset + @yOffset: the amount to apply into the y offset +--]] +function DF:SetPointOffsets(frame, xOffset, yOffset) + for i = 1, frame:GetNumPoints() do + local anchor1, anchorTo, anchor2, x, y = frame:GetPoint(i) + x = x or 0 + y = y or 0 + + if (x >= 0) then + xOffset = x + xOffset + elseif (x < 0) then + xOffset = x - xOffset + end + + if (y >= 0) then + yOffset = y + yOffset + + elseif (y < 0) then + yOffset = y - yOffset + end + + frame:SetPoint(anchor1, anchorTo, anchor2, xOffset, yOffset) + end +end ---functionn falsee truee breakk elsea endz diff --git a/libs/DF/pictureedit.lua b/libs/DF/pictureedit.lua index 9f97819..956f4c3 100644 --- a/libs/DF/pictureedit.lua +++ b/libs/DF/pictureedit.lua @@ -5,29 +5,36 @@ if (not DF or not DetailsFrameworkCanLoad) then end local _ +local ttexcoord - local window = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEdit", nil, 100, 100, false) +local CreateImageEditorFrame = function() + + local window = DF:NewPanel (UIParent, nil, "DetailsFrameworkImageEdit", nil, 650, 500, false) window:SetPoint ("center", UIParent, "center") window:SetResizable (true) window:SetMovable (true) window:SetClampedToScreen (true) tinsert (UISpecialFrames, "DetailsFrameworkImageEdit") window:SetFrameStrata ("TOOLTIP") - window:SetMaxResize (650, 500) + window:SetMaxResize (500, 500) + + _G.DetailsFrameworkImageEditTable = window window.hooks = {} - local background = DF:NewImage (window, nil, nil, nil, "background", nil, nil, "$parentBackground") + local background = DF:NewImage (window, nil, nil, nil, "background", nil, "background", "$parentBackground") background:SetAllPoints() background:SetTexture (0, 0, 0, .8) - local edit_texture = DF:NewImage (window, nil, 650, 500, "artwork", nil, nil, "$parentImage") + local edit_texture = DF:NewImage (window, nil, 500, 500, "artwork", nil, "edit_texture", "$parentImage") edit_texture:SetAllPoints() + _G.DetailsFrameworkImageEdit_EditTexture = edit_texture local background_frame = CreateFrame ("frame", "DetailsFrameworkImageEditBackground", DetailsFrameworkImageEdit) - background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 12) - background_frame:SetFrameStrata ("DIALOG") - background_frame:SetSize (800, 540) + background_frame:SetPoint ("topleft", DetailsFrameworkImageEdit, "topleft", -10, 30) + background_frame:SetFrameStrata ("TOOLTIP") + background_frame:SetFrameLevel (window:GetFrameLevel()) + background_frame:SetSize (790, 560) background_frame:SetResizable (true) background_frame:SetMovable (true) @@ -38,11 +45,15 @@ local _ background_frame:SetScript ("OnMouseUp", function() window:StopMovingOrSizing() end) - + + DF:CreateTitleBar (background_frame, "Image Editor") + DF:ApplyStandardBackdrop (background_frame, false, 0.98) + DF:CreateStatusBar(background_frame) + background_frame:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) background_frame:SetBackdropColor (0, 0, 0, 0.9) background_frame:SetBackdropBorderColor (0, 0, 0, 1) - + local haveHFlip = false local haveVFlip = false @@ -223,22 +234,27 @@ local _ window [side.."Slider"]:Show() end + local yMod = -10 + local leftTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentLeftTexButton", nil, 100, 20, enableTexEdit, "left", nil, nil, "Crop Left", 1) - leftTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -10) + leftTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -10 + yMod) + leftTexCoordButton:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local rightTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentRightTexButton", nil, 100, 20, enableTexEdit, "right", nil, nil, "Crop Right", 1) - rightTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -30) + rightTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -30 + yMod) + rightTexCoordButton:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local topTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentTopTexButton", nil, 100, 20, enableTexEdit, "top", nil, nil, "Crop Top", 1) - topTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -50) + topTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -50 + yMod) + topTexCoordButton:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local bottomTexCoordButton = DF:NewButton (buttonsBackground, nil, "$parentBottomTexButton", nil, 100, 20, enableTexEdit, "bottom", nil, nil, "Crop Bottom", 1) - bottomTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -70) - leftTexCoordButton:InstallCustomTexture() - rightTexCoordButton:InstallCustomTexture() - topTexCoordButton:InstallCustomTexture() - bottomTexCoordButton:InstallCustomTexture() + bottomTexCoordButton:SetPoint ("topright", buttonsBackground, "topright", -8, -70 + yMod) + bottomTexCoordButton:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) local Alpha = DF:NewButton (buttonsBackground, nil, "$parentBottomAlphaButton", nil, 100, 20, alpha, nil, nil, nil, "Alpha", 1) - Alpha:SetPoint ("topright", buttonsBackground, "topright", -8, -115) - Alpha:InstallCustomTexture() + Alpha:SetPoint ("topright", buttonsBackground, "topright", -8, -115 + yMod) + Alpha:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) --> overlay color local selectedColor = function (default) @@ -288,8 +304,8 @@ local _ end local changeColorButton = DF:NewButton (buttonsBackground, nil, "$parentOverlayColorButton", nil, 100, 20, changeColor, nil, nil, nil, "Color", 1) - changeColorButton:SetPoint ("topright", buttonsBackground, "topright", -8, -95) - changeColorButton:InstallCustomTexture() + changeColorButton:SetPoint ("topright", buttonsBackground, "topright", -8, -95 + yMod) + changeColorButton:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) alphaFrame = DF:NewPanel (buttonsBackground, nil, "DetailsFrameworkImageEditAlphaBg", nil, 40, 225) alphaFrame:SetPoint ("topleft", buttonsBackground, "topright", 2, 0) @@ -397,8 +413,8 @@ local _ end local flipButtonH = DF:NewButton (buttonsBackground, nil, "$parentFlipButton", nil, 100, 20, flip, 1, nil, nil, "Flip H", 1) - flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140) - flipButtonH:InstallCustomTexture() + flipButtonH:SetPoint ("topright", buttonsBackground, "topright", -8, -140 + yMod) + flipButtonH:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) -- @@ -527,43 +543,8 @@ local _ local acceptButton = DF:NewButton (buttonsBackground, nil, "$parentAcceptButton", nil, 100, 20, window.accept, nil, nil, nil, "Done", 1) acceptButton:SetPoint ("topright", buttonsBackground, "topright", -8, -200) - acceptButton:InstallCustomTexture() - - - -window:Hide() -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - - local ttexcoord - function DF:ImageEditor (callback, texture, texcoord, colors, width, height, extraParam, alpha, maximize) - - texcoord = texcoord or {0, 1, 0, 1} - ttexcoord = texcoord - - colors = colors or {1, 1, 1, 1} - - alpha = alpha or 1 - - edit_texture:SetTexture (texture) - edit_texture.width = width - edit_texture.height = height - edit_texture.maximize = maximize - - edit_texture:SetVertexColor (colors [1], colors [2], colors [3]) - - edit_texture:SetAlpha (alpha) + acceptButton:SetTemplate (DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) - DF:ScheduleTimer ("RefreshImageEditor", 0.2) - - window:Show() - window.callback_func = callback - window.extra_param = extraParam - buttonsBackground:Show() - buttonsBackground.widget:SetBackdrop (nil) - - table.wipe (window.hooks) - end - function DF:RefreshImageEditor() if (edit_texture.maximize) then @@ -598,5 +579,47 @@ window:Hide() window.accept (nil, nil, true) end + end + + window:Hide() + + end +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + + function DF:ImageEditor (callback, texture, texcoord, colors, width, height, extraParam, alpha, maximize) + + if (not _G.DetailsFrameworkImageEdit) then + CreateImageEditorFrame() + end + + local window = _G.DetailsFrameworkImageEditTable + + texcoord = texcoord or {0, 1, 0, 1} + ttexcoord = texcoord + + colors = colors or {1, 1, 1, 1} + + alpha = alpha or 1 + + _G.DetailsFrameworkImageEdit_EditTexture:SetTexture (texture) + _G.DetailsFrameworkImageEdit_EditTexture.width = width + _G.DetailsFrameworkImageEdit_EditTexture.height = height + _G.DetailsFrameworkImageEdit_EditTexture.maximize = maximize + + _G.DetailsFrameworkImageEdit_EditTexture:SetVertexColor (colors [1], colors [2], colors [3]) + _G.DetailsFrameworkImageEdit_EditTexture:SetAlpha (alpha) + + DF:ScheduleTimer ("RefreshImageEditor", 0.2) + + window:Show() + window.callback_func = callback + window.extra_param = extraParam + DetailsFrameworkImageEditButtonsBg:Show() + DetailsFrameworkImageEditButtonsBg:SetBackdrop (nil) + + table.wipe (window.hooks) end + + diff --git a/libs/DF/slider.lua b/libs/DF/slider.lua index 4ed8636..345eee2 100644 --- a/libs/DF/slider.lua +++ b/libs/DF/slider.lua @@ -286,6 +286,17 @@ local DFSliderMetaFunctions = _G [DF.GlobalWidgetControlNames ["slider"]] end end +-- clear focus + function DFSliderMetaFunctions:ClearFocus() + local editbox = DFSliderMetaFunctions.editbox_typevalue + if editbox and self.typing_value then + editbox:ClearFocus() + editbox:Hide() + editbox:GetParent().MyObject.typing_value = false + editbox:GetParent().MyObject.value = self.typing_value_started + end + end + -- enabled function DFSliderMetaFunctions:IsEnabled() return not _rawget (self, "lockdown") @@ -312,6 +323,7 @@ local DFSliderMetaFunctions = _G [DF.GlobalWidgetControlNames ["slider"]] function DFSliderMetaFunctions:Disable() + self:ClearFocus() self.slider:Disable() self.slider.amt:Hide() self:SetAlpha (.4) diff --git a/libs/DF/spells.lua b/libs/DF/spells.lua index 9290736..393f296 100644 --- a/libs/DF/spells.lua +++ b/libs/DF/spells.lua @@ -918,7 +918,57 @@ function DF:GetSpellsForEncounterFromJournal (instanceEJID, encounterEJID) return spellIDs end - +--default spells to use in the range check +DF.SpellRangeCheckListBySpec = { + -- 185245 spellID for Torment, it is always failing to check range with IsSpellInRange() + [577] = 278326, --> havoc demon hunter - Consume Magic + [581] = 278326, --> vengeance demon hunter - Consume Magic + + [250] = 56222, --> blood dk - dark command + [251] = 56222, --> frost dk - dark command + [252] = 56222, --> unholy dk - dark command + + [102] = 8921, --> druid balance - Moonfire (45 yards) + [103] = 8921, --> druid feral - Moonfire (40 yards) + [104] = 6795, --> druid guardian - Growl + [105] = 8921, --> druid resto - Moonfire (40 yards) + + [253] = 193455, --> hunter bm - Cobra Shot + [254] = 19434, --> hunter marks - Aimed Shot + [255] = 271788, --> hunter survivor - Serpent Sting + + [62] = 227170, --> mage arcane - arcane blast + [63] = 133, --> mage fire - fireball + [64] = 228597, --> mage frost - frostbolt + + [268] = 115546 , --> monk bm - Provoke + [269] = 117952, --> monk ww - Crackling Jade Lightning (40 yards) + [270] = 117952, --> monk mw - Crackling Jade Lightning (40 yards) + + [65] = 20473, --> paladin holy - Holy Shock (40 yards) + [66] = 62124, --> paladin protect - Hand of Reckoning + [70] = 62124, --> paladin ret - Hand of Reckoning + + [256] = 585, --> priest disc - Smite + [257] = 585, --> priest holy - Smite + [258] = 8092, --> priest shadow - Mind Blast + + [259] = 185565, --> rogue assassination - Poisoned Knife (30 yards) + [260] = 185763, --> rogue outlaw - Pistol Shot (20 yards) + [261] = 114014, --> rogue sub - Shuriken Toss (30 yards) + + [262] = 188196, --> shaman elemental - Lightning Bolt + [263] = 187837, --> shaman enhancement - Lightning Bolt (instance cast) + [264] = 403, --> shaman resto - Lightning Bolt + + [265] = 686, --> warlock aff - Shadow Bolt + [266] = 686, --> warlock demo - Shadow Bolt + [267] = 116858, --> warlock destro - Chaos Bolt + + [71] = 355, --> warrior arms - Taunt + [72] = 355, --> warrior fury - Taunt + [73] = 355, --> warrior protect - Taunt +} diff --git a/libs/DF/textentry.lua b/libs/DF/textentry.lua index f532ead..5105ad8 100644 --- a/libs/DF/textentry.lua +++ b/libs/DF/textentry.lua @@ -1072,8 +1072,15 @@ function TextEntryMetaFunctions:SetAsAutoComplete (poolName, poolTable, shouldOp end -function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent) - +local set_speciallua_editor_font_size = function(borderFrame, newSize) + local file, size, flags = borderFrame.editbox:GetFont() + borderFrame.editbox:SetFont (file, newSize, flags) + + borderFrame.editboxlines:SetFont (file, newSize, flags) +end + +function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent, showLineNumbers) + if (name:find ("$parent")) then local parentName = DF.GetParentName (parent) name = name:gsub ("$parent", parentName) @@ -1087,32 +1094,82 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent) end local scrollframe = CreateFrame ("ScrollFrame", name, borderframe, "UIPanelScrollFrameTemplate") - scrollframe:SetSize (232, 20) + local scrollframeNumberLines = CreateFrame ("ScrollFrame", name .. "NumberLines", borderframe, "UIPanelScrollFrameTemplate") + scrollframe.editbox = CreateFrame ("editbox", "$parentEditBox", scrollframe) scrollframe.editbox:SetMultiLine (true) scrollframe.editbox:SetAutoFocus (false) - scrollframe.editbox:SetSize (232, 20) - scrollframe.editbox:SetAllPoints() - scrollframe.editbox:SetScript ("OnCursorChanged", _G.ScrollingEdit_OnCursorChanged) scrollframe.editbox:SetScript ("OnEscapePressed", _G.EditBox_ClearFocus) scrollframe.editbox:SetFontObject ("GameFontHighlightSmall") - scrollframe:SetScrollChild (scrollframe.editbox) - - --letters="255" - --countInvisibleLetters="true" + --line number + if (showLineNumbers) then + scrollframeNumberLines.editbox = CreateFrame ("editbox", "$parentLineNumbers", scrollframeNumberLines) + scrollframeNumberLines.editbox:SetMultiLine (true) + scrollframeNumberLines.editbox:SetAutoFocus (false) + scrollframeNumberLines.editbox:SetFontObject ("GameFontHighlightSmall") + scrollframeNumberLines.editbox:SetJustifyH ("left") + scrollframeNumberLines.editbox:SetJustifyV ("top") + scrollframeNumberLines.editbox:SetTextColor(.3, .3, .3, .5) + scrollframeNumberLines.editbox:SetPoint ("topleft", borderframe, "topleft", 10, -10) + scrollframeNumberLines.editbox:SetPoint ("bottomright", borderframe, "bottomright", -30, 10) + + scrollframeNumberLines:SetScrollChild (scrollframeNumberLines.editbox) + + for i = 1, 1000 do + scrollframeNumberLines.editbox:Insert (i .. "\n") + end + + --place the lua code field 20 pixels to the right to make run to the lines scroll + scrollframe:SetPoint ("topleft", borderframe, "topleft", 30, -10) + scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -10, 10) + + --when the lua code field scrolls, make the lua field scroll too + scrollframe:SetScript ("OnVerticalScroll", function (self, offset) + scrollframeNumberLines:SetVerticalScroll(scrollframe:GetVerticalScroll()) + scrollframeNumberLines.ScrollBar:Hide() + end) + + --place the number lines scroll in the begining of the editing code space + scrollframeNumberLines:SetPoint ("topleft", borderframe, "topleft", 10, -10) + scrollframeNumberLines:SetPoint ("bottomright", borderframe, "bottomright", -10, 10) + + scrollframeNumberLines.editbox:SetJustifyH ("left") + scrollframeNumberLines.editbox:SetJustifyV ("top") + + scrollframeNumberLines:SetScript ("OnSizeChanged", function (self) + scrollframeNumberLines.editbox:SetSize (self:GetSize()) + scrollframeNumberLines.ScrollBar:Hide() + end) + + scrollframeNumberLines.ScrollBar:HookScript("OnShow", function(self) + self:Hide() + end) + + borderframe.scrollnumberlines = scrollframeNumberLines + borderframe.editboxlines = scrollframeNumberLines.editbox + borderframe.editboxlines.borderframe = borderframe + + scrollframeNumberLines.ScrollBar:Hide() + scrollframeNumberLines:SetBackdrop(nil) + scrollframeNumberLines.editbox:SetBackdrop(nil) + + else + scrollframe:SetPoint ("topleft", borderframe, "topleft", 10, -10) + scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -10, 10) + scrollframeNumberLines:SetPoint ("topleft", borderframe, "topleft", 10, -10) + scrollframeNumberLines:SetPoint ("bottomright", borderframe, "bottomright", -10, 10) + scrollframeNumberLines:Hide() + end +--16:40 borderframe.SetAsAutoComplete = TextEntryMetaFunctions.SetAsAutoComplete scrollframe:SetScript ("OnSizeChanged", function (self) scrollframe.editbox:SetSize (self:GetSize()) end) - scrollframe:SetPoint ("topleft", borderframe, "topleft", 10, -10) - scrollframe:SetPoint ("bottomright", borderframe, "bottomright", -30, 10) - - scrollframe.editbox:SetMultiLine (true) scrollframe.editbox:SetJustifyH ("left") scrollframe.editbox:SetJustifyV ("top") scrollframe.editbox:SetMaxBytes (1024000) @@ -1122,6 +1179,7 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent) borderframe.SetText = function_settext borderframe.ClearFocus = function_clearfocus borderframe.SetFocus = function_setfocus + borderframe.SetTextSize = set_speciallua_editor_font_size borderframe.Enable = TextEntryMetaFunctions.Enable borderframe.Disable = TextEntryMetaFunctions.Disable @@ -1131,7 +1189,7 @@ function DF:NewSpecialLuaEditorEntry (parent, w, h, member, name, nointent) if (not nointent) then IndentationLib.enable (scrollframe.editbox, nil, 4) end - + borderframe:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], tile = 1, tileSize = 16, edgeSize = 16, insets = {left = 5, right = 5, top = 5, bottom = 5}})