diff --git a/ElvUI_SLE/ElvUI_SLE.toc b/ElvUI_SLE/ElvUI_SLE.toc index 4ff7383..b473275 100755 --- a/ElvUI_SLE/ElvUI_SLE.toc +++ b/ElvUI_SLE/ElvUI_SLE.toc @@ -1,14 +1,16 @@ ## Interface: 50200 ## Title: |cff1784d1ElvUI |rShadow and Light Edit ## Author: Darth Predator, Repooc -## Version: 1.58 +## Version: 1.59 ## Notes: Plugin-edit for |cff1784d1ElvUI|r. -## Notes-ruRU: Плагин-редакция для |cff1784d1ElvUI|r. +## Notes-ruRU: Плагин-редакци? дл? |cff1784d1ElvUI|r. ## eMail: darthpred@gmail.com, repooc@tukui.org ## URL: http://tukui.org/ ## RequiredDeps: ElvUI ## OptionalDeps: iFilger_ConfigUI, BigWigs, Clique, Hermes, xCT+ ## DefaultState: Enabled +## X-Tukui-ProjectID: 42 +## X-Tukui-ProjectFolders: ElvUI_SLE libs\load_libs.xml locales\load_locales.xml diff --git a/ElvUI_SLE/config/profile.lua b/ElvUI_SLE/config/profile.lua index 16706ef..f047bed 100755 --- a/ElvUI_SLE/config/profile.lua +++ b/ElvUI_SLE/config/profile.lua @@ -127,6 +127,25 @@ P['sle'] = { ['width'] = 100, }, }, +--E.db.sle.dt.guild.totals + --DT Options + ['dt'] = { + ['friends'] = { + ['combat'] = false, + ['hideFriends'] = false, + ['sortBN'] = 'TOONNAME', + ['tooltipAutohide'] = 0.2, + ['totals'] = false, + }, + ['guild'] = { + ['combat'] = false, + ['hideGuild'] = false, + ['sortGuild'] = 'TOONNAME', + ['tooltipAutohide'] = 0.2, + ['totals'] = false, + }, + }, + --Error messages ['errors'] = false, diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LICENSE.txt b/ElvUI_SLE/libs/LibQTip-1.0/LICENSE.txt new file mode 100644 index 0000000..54cdb47 --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LICENSE.txt @@ -0,0 +1,29 @@ +Copyright (c) 2008, LibQTip Development Team + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Redistribution of a stand alone version is strictly prohibited without + prior written authorization from the Lead of the LibQTip Development Team. + * Neither the name of the LibQTip Development Team nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibQTip-1.0.lua b/ElvUI_SLE/libs/LibQTip-1.0/LibQTip-1.0.lua new file mode 100644 index 0000000..d83884e --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibQTip-1.0.lua @@ -0,0 +1,1329 @@ +local MAJOR = "LibQTip-1.0" +local MINOR = 38 -- Should be manually increased +assert(LibStub, MAJOR.." requires LibStub") + +local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR) +if not lib then return end -- No upgrade needed + +------------------------------------------------------------------------------ +-- Upvalued globals +------------------------------------------------------------------------------ +local _G = getfenv(0) + +local type = type +local select = select +local error = error +local pairs, ipairs = pairs, ipairs +local tonumber, tostring = tonumber, tostring +local strfind = string.find +local math = math +local min, max = math.min, math.max +local setmetatable = setmetatable +local tinsert, tremove = tinsert, tremove +local wipe = wipe + +local CreateFrame = CreateFrame +local UIParent = UIParent + +------------------------------------------------------------------------------ +-- Tables and locals +------------------------------------------------------------------------------ +lib.frameMetatable = lib.frameMetatable or {__index = CreateFrame("Frame")} + +lib.tipPrototype = lib.tipPrototype or setmetatable({}, lib.frameMetatable) +lib.tipMetatable = lib.tipMetatable or {__index = lib.tipPrototype} + +lib.providerPrototype = lib.providerPrototype or {} +lib.providerMetatable = lib.providerMetatable or {__index = lib.providerPrototype} + +lib.cellPrototype = lib.cellPrototype or setmetatable({}, lib.frameMetatable) +lib.cellMetatable = lib.cellMetatable or { __index = lib.cellPrototype } + +lib.activeTooltips = lib.activeTooltips or {} + +lib.tooltipHeap = lib.tooltipHeap or {} +lib.frameHeap = lib.frameHeap or {} +lib.tableHeap = lib.tableHeap or {} + +local tipPrototype = lib.tipPrototype +local tipMetatable = lib.tipMetatable + +local providerPrototype = lib.providerPrototype +local providerMetatable = lib.providerMetatable + +local cellPrototype = lib.cellPrototype +local cellMetatable = lib.cellMetatable + +local activeTooltips = lib.activeTooltips + +------------------------------------------------------------------------------ +-- Private methods for Caches and Tooltip +------------------------------------------------------------------------------ +local AcquireTooltip, ReleaseTooltip +local AcquireCell, ReleaseCell +local AcquireTable, ReleaseTable + +local InitializeTooltip, SetTooltipSize, ResetTooltipSize, FixCellSizes +local ClearTooltipScripts +local SetFrameScript, ClearFrameScripts + +------------------------------------------------------------------------------ +-- Cache debugging. +------------------------------------------------------------------------------ +--[===[@debug@ +local usedTables, usedFrames, usedTooltips = 0, 0, 0 +--@end-debug@]===] + +------------------------------------------------------------------------------ +-- Internal constants to tweak the layout +------------------------------------------------------------------------------ +local TOOLTIP_PADDING = 10 +local CELL_MARGIN_H = 6 +local CELL_MARGIN_V = 3 + +------------------------------------------------------------------------------ +-- Public library API +------------------------------------------------------------------------------ +--- Create or retrieve the tooltip with the given key. +-- If additional arguments are passed, they are passed to :SetColumnLayout for the acquired tooltip. +-- @name LibQTip:Acquire(key[, numColumns, column1Justification, column2justification, ...]) +-- @param key string or table - the tooltip key. Any value that can be used as a table key is accepted though you should try to provide unique keys to avoid conflicts. +-- Numbers and booleans should be avoided and strings should be carefully chosen to avoid namespace clashes - no "MyTooltip" - you have been warned! +-- @return tooltip Frame object - the acquired tooltip. +-- @usage Acquire a tooltip with at least 5 columns, justification : left, center, left, left, left +-- <pre>local tip = LibStub('LibQTip-1.0'):Acquire('MyFooBarTooltip', 5, "LEFT", "CENTER")</pre> +function lib:Acquire(key, ...) + if key == nil then + error("attempt to use a nil key", 2) + end + local tooltip = activeTooltips[key] + + if not tooltip then + tooltip = AcquireTooltip() + InitializeTooltip(tooltip, key) + activeTooltips[key] = tooltip + end + + if select('#', ...) > 0 then + -- Here we catch any error to properly report it for the calling code + local ok, msg = pcall(tooltip.SetColumnLayout, tooltip, ...) + + if not ok then + error(msg, 2) + end + end + return tooltip +end + +function lib:Release(tooltip) + local key = tooltip and tooltip.key + + if not key or activeTooltips[key] ~= tooltip then + return + end + ReleaseTooltip(tooltip) + activeTooltips[key] = nil +end + +function lib:IsAcquired(key) + if key == nil then + error("attempt to use a nil key", 2) + end + return not not activeTooltips[key] +end + +function lib:IterateTooltips() + return pairs(activeTooltips) +end + +------------------------------------------------------------------------------ +-- Frame cache +------------------------------------------------------------------------------ +local frameHeap = lib.frameHeap + +local function AcquireFrame(parent) + local frame = tremove(frameHeap) or CreateFrame("Frame") + frame:SetParent(parent) + --[===[@debug@ + usedFrames = usedFrames + 1 + --@end-debug@]===] + return frame +end + +local function ReleaseFrame(frame) + frame:Hide() + frame:SetParent(nil) + frame:ClearAllPoints() + frame:SetBackdrop(nil) + ClearFrameScripts(frame) + tinsert(frameHeap, frame) + --[===[@debug@ + usedFrames = usedFrames - 1 + --@end-debug@]===] +end + +------------------------------------------------------------------------------ +-- Dirty layout handler +------------------------------------------------------------------------------ +lib.layoutCleaner = lib.layoutCleaner or CreateFrame('Frame') + +local layoutCleaner = lib.layoutCleaner +layoutCleaner.registry = layoutCleaner.registry or {} + +function layoutCleaner:RegisterForCleanup(tooltip) + self.registry[tooltip] = true + self:Show() +end + +function layoutCleaner:CleanupLayouts() + self:Hide() + for tooltip in pairs(self.registry) do + FixCellSizes(tooltip) + end + wipe(self.registry) +end +layoutCleaner:SetScript('OnUpdate', layoutCleaner.CleanupLayouts) + +------------------------------------------------------------------------------ +-- CellProvider and Cell +------------------------------------------------------------------------------ +function providerPrototype:AcquireCell() + local cell = tremove(self.heap) + if not cell then + cell = setmetatable(CreateFrame("Frame", nil, UIParent), self.cellMetatable) + if type(cell.InitializeCell) == 'function' then + cell:InitializeCell() + end + end + self.cells[cell] = true + return cell +end + +function providerPrototype:ReleaseCell(cell) + if not self.cells[cell] then return end + if type(cell.ReleaseCell) == 'function' then + cell:ReleaseCell() + end + self.cells[cell] = nil + tinsert(self.heap, cell) +end + +function providerPrototype:GetCellPrototype() + return self.cellPrototype, self.cellMetatable +end + +function providerPrototype:IterateCells() + return pairs(self.cells) +end + +function lib:CreateCellProvider(baseProvider) + local cellBaseMetatable, cellBasePrototype + if baseProvider and baseProvider.GetCellPrototype then + cellBasePrototype, cellBaseMetatable = baseProvider:GetCellPrototype() + else + cellBaseMetatable = cellMetatable + end + local cellPrototype = setmetatable({}, cellBaseMetatable) + local cellProvider = setmetatable({}, providerMetatable) + cellProvider.heap = {} + cellProvider.cells = {} + cellProvider.cellPrototype = cellPrototype + cellProvider.cellMetatable = { __index = cellPrototype } + return cellProvider, cellPrototype, cellBasePrototype +end + +------------------------------------------------------------------------------ +-- Basic label provider +------------------------------------------------------------------------------ +if not lib.LabelProvider then + lib.LabelProvider, lib.LabelPrototype = lib:CreateCellProvider() +end + +local labelProvider = lib.LabelProvider +local labelPrototype = lib.LabelPrototype + +function labelPrototype:InitializeCell() + self.fontString = self:CreateFontString() + self.fontString:SetFontObject(GameTooltipText) +end + +function labelPrototype:SetupCell(tooltip, value, justification, font, l_pad, r_pad, max_width, min_width, ...) + local fs = self.fontString + local line = tooltip.lines[self._line] + + -- detatch fs from cell for size calculations + fs:ClearAllPoints() + fs:SetFontObject(font or (line.is_header and tooltip:GetHeaderFont() or tooltip:GetFont())) + fs:SetJustifyH(justification) + fs:SetText(tostring(value)) + + l_pad = l_pad or 0 + r_pad = r_pad or 0 + + local width = fs:GetStringWidth() + l_pad + r_pad + + if max_width and min_width and (max_width < min_width) then + error("maximum width cannot be lower than minimum width: "..tostring(max_width).." < "..tostring(min_width), 2) + end + + if max_width and (max_width < (l_pad + r_pad)) then + error("maximum width cannot be lower than the sum of paddings: "..tostring(max_width).." < "..tostring(l_pad).." + "..tostring(r_pad), 2) + end + + if min_width and width < min_width then + width = min_width + end + + if max_width and max_width < width then + width = max_width + end + fs:SetWidth(width - (l_pad + r_pad)) + -- Use GetHeight() instead of GetStringHeight() so lines which are longer than width will wrap. + local height = fs:GetHeight() + + -- reanchor fs to cell + fs:SetWidth(0) + fs:SetPoint("TOPLEFT", self, "TOPLEFT", l_pad, 0) + fs:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -r_pad, 0) +--~ fs:SetPoint("TOPRIGHT", self, "TOPRIGHT", -r_pad, 0) + + self._paddingL = l_pad + self._paddingR = r_pad + + return width, height +end + +function labelPrototype:getContentHeight() + local fs = self.fontString + fs:SetWidth(self:GetWidth() - (self._paddingL + self._paddingR)) + local height = self.fontString:GetHeight() + fs:SetWidth(0) + return height +end + +function labelPrototype:GetPosition() return self._line, self._column end + +------------------------------------------------------------------------------ +-- Tooltip cache +------------------------------------------------------------------------------ +local tooltipHeap = lib.tooltipHeap + +-- Returns a tooltip +function AcquireTooltip() + local tooltip = tremove(tooltipHeap) + + if not tooltip then + tooltip = CreateFrame("Frame", nil, UIParent) + + local scrollFrame = CreateFrame("ScrollFrame", nil, tooltip) + scrollFrame:SetPoint("TOP", tooltip, "TOP", 0, -TOOLTIP_PADDING) + scrollFrame:SetPoint("BOTTOM", tooltip, "BOTTOM", 0, TOOLTIP_PADDING) + scrollFrame:SetPoint("LEFT", tooltip, "LEFT", TOOLTIP_PADDING, 0) + scrollFrame:SetPoint("RIGHT", tooltip, "RIGHT", -TOOLTIP_PADDING, 0) + tooltip.scrollFrame = scrollFrame + + local scrollChild = CreateFrame("Frame", nil, tooltip.scrollFrame) + scrollFrame:SetScrollChild(scrollChild) + tooltip.scrollChild = scrollChild + setmetatable(tooltip, tipMetatable) + end + --[===[@debug@ + usedTooltips = usedTooltips + 1 + --@end-debug@]===] + return tooltip +end + +-- Cleans the tooltip and stores it in the cache +function ReleaseTooltip(tooltip) + if tooltip.releasing then + return + end + tooltip.releasing = true + + tooltip:Hide() + + if tooltip.OnRelease then + local success, errorMessage = pcall(tooltip.OnRelease, tooltip) + if not success then + geterrorhandler()(errorMessage) + end + tooltip.OnRelease = nil + end + + tooltip.releasing = nil + tooltip.key = nil + tooltip.step = nil + + ClearTooltipScripts(tooltip) + + tooltip:SetAutoHideDelay(nil) + tooltip:ClearAllPoints() + tooltip:Clear() + + if tooltip.slider then + tooltip.slider:SetValue(0) + tooltip.slider:Hide() + tooltip.scrollFrame:SetPoint("RIGHT", tooltip, "RIGHT", -TOOLTIP_PADDING, 0) + tooltip:EnableMouseWheel(false) + end + + for i, column in ipairs(tooltip.columns) do + tooltip.columns[i] = ReleaseFrame(column) + end + tooltip.columns = ReleaseTable(tooltip.columns) + tooltip.lines = ReleaseTable(tooltip.lines) + tooltip.colspans = ReleaseTable(tooltip.colspans) + + layoutCleaner.registry[tooltip] = nil + tinsert(tooltipHeap, tooltip) + --[===[@debug@ + usedTooltips = usedTooltips - 1 + --@end-debug@]===] +end + +------------------------------------------------------------------------------ +-- Cell 'cache' (just a wrapper to the provider's cache) +------------------------------------------------------------------------------ +-- Returns a cell for the given tooltip from the given provider +function AcquireCell(tooltip, provider) + local cell = provider:AcquireCell(tooltip) + + cell:SetParent(tooltip.scrollChild) + cell:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 3) + cell._provider = provider + return cell +end + +-- Cleans the cell hands it to its provider for storing +function ReleaseCell(cell) + cell:Hide() + cell:ClearAllPoints() + cell:SetParent(nil) + cell:SetBackdrop(nil) + ClearFrameScripts(cell) + + cell._font = nil + cell._justification = nil + cell._colSpan = nil + cell._line = nil + cell._column = nil + + cell._provider:ReleaseCell(cell) + cell._provider = nil +end + +------------------------------------------------------------------------------ +-- Table cache +------------------------------------------------------------------------------ +local tableHeap = lib.tableHeap + +-- Returns a table +function AcquireTable() + local tbl = tremove(tableHeap) or {} + --[===[@debug@ + usedTables = usedTables + 1 + --@end-debug@]===] + return tbl +end + +-- Cleans the table and stores it in the cache +function ReleaseTable(table) + wipe(table) + tinsert(tableHeap, table) + --[===[@debug@ + usedTables = usedTables - 1 + --@end-debug@]===] +end + +------------------------------------------------------------------------------ +-- Tooltip prototype +------------------------------------------------------------------------------ +function InitializeTooltip(tooltip, key) + ---------------------------------------------------------------------- + -- (Re)set frame settings + ---------------------------------------------------------------------- + local backdrop = GameTooltip:GetBackdrop() + + tooltip:SetBackdrop(backdrop) + + if backdrop then + tooltip:SetBackdropColor(GameTooltip:GetBackdropColor()) + tooltip:SetBackdropBorderColor(GameTooltip:GetBackdropBorderColor()) + end + tooltip:SetScale(GameTooltip:GetScale()) + tooltip:SetAlpha(1) + tooltip:SetFrameStrata("TOOLTIP") + tooltip:SetClampedToScreen(false) + + ---------------------------------------------------------------------- + -- Internal data. Since it's possible to Acquire twice without calling + -- release, check for pre-existence. + ---------------------------------------------------------------------- + tooltip.key = key + tooltip.columns = tooltip.columns or AcquireTable() + tooltip.lines = tooltip.lines or AcquireTable() + tooltip.colspans = tooltip.colspans or AcquireTable() + tooltip.regularFont = GameTooltipText + tooltip.headerFont = GameTooltipHeaderText + tooltip.labelProvider = labelProvider + tooltip.cell_margin_h = tooltip.cell_margin_h or CELL_MARGIN_H + tooltip.cell_margin_v = tooltip.cell_margin_v or CELL_MARGIN_V + + ---------------------------------------------------------------------- + -- Finishing procedures + ---------------------------------------------------------------------- + tooltip:SetAutoHideDelay(nil) + tooltip:Hide() + ResetTooltipSize(tooltip) +end + +function tipPrototype:SetDefaultProvider(myProvider) + if not myProvider then + return + end + self.labelProvider = myProvider +end + +function tipPrototype:GetDefaultProvider() return self.labelProvider end + +local function checkJustification(justification, level, silent) + if justification ~= "LEFT" and justification ~= "CENTER" and justification ~= "RIGHT" then + if silent then + return false + end + error("invalid justification, must one of LEFT, CENTER or RIGHT, not: "..tostring(justification), level+1) + end + return true +end + +function tipPrototype:SetColumnLayout(numColumns, ...) + if type(numColumns) ~= "number" or numColumns < 1 then + error("number of columns must be a positive number, not: "..tostring(numColumns), 2) + end + + for i = 1, numColumns do + local justification = select(i, ...) or "LEFT" + + checkJustification(justification, 2) + + if self.columns[i] then + self.columns[i].justification = justification + else + self:AddColumn(justification) + end + end +end + +function tipPrototype:AddColumn(justification) + justification = justification or "LEFT" + checkJustification(justification, 2) + + local colNum = #self.columns + 1 + local column = self.columns[colNum] or AcquireFrame(self.scrollChild) + column:SetFrameLevel(self.scrollChild:GetFrameLevel() + 1) + column.justification = justification + column.width = 0 + column:SetWidth(1) + column:SetPoint("TOP", self.scrollChild) + column:SetPoint("BOTTOM", self.scrollChild) + + if colNum > 1 then + local h_margin = self.cell_margin_h or CELL_MARGIN_H + + column:SetPoint("LEFT", self.columns[colNum - 1], "RIGHT", h_margin, 0) + SetTooltipSize(self, self.width + h_margin, self.height) + else + column:SetPoint("LEFT", self.scrollChild) + end + column:Show() + self.columns[colNum] = column + return colNum +end + +------------------------------------------------------------------------------ +-- Convenient methods +------------------------------------------------------------------------------ + +function tipPrototype:Release() + lib:Release(self) +end + +function tipPrototype:IsAcquiredBy(key) + return key ~= nil and self.key == key +end + +------------------------------------------------------------------------------ +-- Script hooks +------------------------------------------------------------------------------ + +local RawSetScript = lib.frameMetatable.__index.SetScript + +function ClearTooltipScripts(tooltip) + if tooltip.scripts then + for scriptType in pairs(tooltip.scripts) do + RawSetScript(tooltip, scriptType, nil) + end + tooltip.scripts = ReleaseTable(tooltip.scripts) + end +end + +function tipPrototype:SetScript(scriptType, handler) + RawSetScript(self, scriptType, handler) + if handler then + if not self.scripts then + self.scripts = AcquireTable() + end + self.scripts[scriptType] = true + elseif self.scripts then + self.scripts[scriptType] = nil + end +end + +-- That might break some addons ; those addons were breaking other +-- addons' tooltip though. +function tipPrototype:HookScript() + geterrorhandler()(":HookScript is not allowed on LibQTip tooltips") +end + +------------------------------------------------------------------------------ +-- Scrollbar data and functions +------------------------------------------------------------------------------ +local sliderBackdrop = { + ["bgFile"] = [[Interface\Buttons\UI-SliderBar-Background]], + ["edgeFile"] = [[Interface\Buttons\UI-SliderBar-Border]], + ["tile"] = true, + ["edgeSize"] = 8, + ["tileSize"] = 8, + ["insets"] = { + ["left"] = 3, + ["right"] = 3, + ["top"] = 3, + ["bottom"] = 3, + }, +} + +local function slider_OnValueChanged(self) + self.scrollFrame:SetVerticalScroll(self:GetValue()) +end + +local function tooltip_OnMouseWheel(self, delta) + local slider = self.slider + local currentValue = slider:GetValue() + local minValue, maxValue = slider:GetMinMaxValues() + local stepValue = self.step or 10 + + if delta < 0 and currentValue < maxValue then + slider:SetValue(min(maxValue, currentValue + stepValue)) + elseif delta > 0 and currentValue > minValue then + slider:SetValue(max(minValue, currentValue - stepValue)) + end +end + +-- Set the step size for the scroll bar +function tipPrototype:SetScrollStep(step) + self.step = step +end + +-- will resize the tooltip to fit the screen and show a scrollbar if needed +function tipPrototype:UpdateScrolling(maxheight) + self:SetClampedToScreen(false) + + -- all data is in the tooltip; fix colspan width and prevent the layout cleaner from messing up the tooltip later + FixCellSizes(self) + layoutCleaner.registry[self] = nil + + local scale = self:GetScale() + local topside = self:GetTop() + local bottomside = self:GetBottom() + local screensize = UIParent:GetHeight() / scale + local tipsize = (topside - bottomside) + + -- if the tooltip would be too high, limit its height and show the slider + if bottomside < 0 or topside > screensize or (maxheight and tipsize > maxheight) then + local shrink = (bottomside < 0 and (5 - bottomside) or 0) + (topside > screensize and (topside - screensize + 5) or 0) + + if maxheight and tipsize - shrink > maxheight then + shrink = tipsize - maxheight + end + self:SetHeight(2 * TOOLTIP_PADDING + self.height - shrink) + self:SetWidth(2 * TOOLTIP_PADDING + self.width + 20) + self.scrollFrame:SetPoint("RIGHT", self, "RIGHT", -(TOOLTIP_PADDING + 20), 0) + + if not self.slider then + local slider = CreateFrame("Slider", nil, self) + + self.slider = slider + + slider:SetOrientation("VERTICAL") + slider:SetPoint("TOPRIGHT", self, "TOPRIGHT", -TOOLTIP_PADDING, -TOOLTIP_PADDING) + slider:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -TOOLTIP_PADDING, TOOLTIP_PADDING) + slider:SetBackdrop(sliderBackdrop) + slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Vertical]]) + slider:SetMinMaxValues(0, 1) + slider:SetValueStep(1) + slider:SetWidth(12) + slider.scrollFrame = self.scrollFrame + slider:SetScript("OnValueChanged", slider_OnValueChanged) + slider:SetValue(0) + end + self.slider:SetMinMaxValues(0, shrink) + self.slider:Show() + self:EnableMouseWheel(true) + self:SetScript("OnMouseWheel", tooltip_OnMouseWheel) + else + self:SetHeight(2 * TOOLTIP_PADDING + self.height) + self:SetWidth(2 * TOOLTIP_PADDING + self.width) + self.scrollFrame:SetPoint("RIGHT", self, "RIGHT", -TOOLTIP_PADDING, 0) + + if self.slider then + self.slider:SetValue(0) + self.slider:Hide() + self:EnableMouseWheel(false) + self:SetScript("OnMouseWheel", nil) + end + end +end + +------------------------------------------------------------------------------ +-- Tooltip methods for changing its contents. +------------------------------------------------------------------------------ +function tipPrototype:Clear() + for i, line in ipairs(self.lines) do + for j, cell in pairs(line.cells) do + if cell then + ReleaseCell(cell) + end + end + ReleaseTable(line.cells) + line.cells = nil + line.is_header = nil + ReleaseFrame(line) + self.lines[i] = nil + end + + for i, column in ipairs(self.columns) do + column.width = 0 + column:SetWidth(1) + end + wipe(self.colspans) + self.cell_margin_h = nil + self.cell_margin_v = nil + ResetTooltipSize(self) +end + +function tipPrototype:SetCellMarginH(size) + if #self.lines > 0 then + error("Unable to set horizontal margin while the tooltip has lines.", 2) + end + + if not size or type(size) ~= "number" or size < 0 then + error("Margin size must be a positive number or zero.", 2) + end + self.cell_margin_h = size +end + +function tipPrototype:SetCellMarginV(size) + if #self.lines > 0 then + error("Unable to set vertical margin while the tooltip has lines.", 2) + end + + if not size or type(size) ~= "number" or size < 0 then + error("Margin size must be a positive number or zero.", 2) + end + self.cell_margin_v = size +end + +function SetTooltipSize(tooltip, width, height) + tooltip:SetHeight(2 * TOOLTIP_PADDING + height) + tooltip.scrollChild:SetHeight(height) + tooltip.height = height + + tooltip:SetWidth(2 * TOOLTIP_PADDING + width) + tooltip.scrollChild:SetWidth(width) + tooltip.width = width +end + +-- Add 2 pixels to height so dangling letters (g, y, p, j, etc) are not clipped. +function ResetTooltipSize(tooltip) + local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H + + SetTooltipSize(tooltip, max(0, (h_margin * (#tooltip.columns - 1)) + (h_margin / 2)), 2) +end + +local function EnlargeColumn(tooltip, column, width) + if width > column.width then + SetTooltipSize(tooltip, tooltip.width + width - column.width, tooltip.height) + + column.width = width + column:SetWidth(width) + end +end + +local function ResizeLine(tooltip, line, height) + SetTooltipSize(tooltip, tooltip.width, tooltip.height + height - line.height) + + line.height = height + line:SetHeight(height) +end + +function FixCellSizes(tooltip) + local columns = tooltip.columns + local colspans = tooltip.colspans + local lines = tooltip.lines + + -- resize columns to make room for the colspans + local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H + while next(colspans) do + local maxNeedCols = nil + local maxNeedWidthPerCol = 0 + -- calculate the colspan with the highest additional width need per column + for colRange, width in pairs(colspans) do + local left, right = colRange:match("^(%d+)%-(%d+)$") + left, right = tonumber(left), tonumber(right) + for col = left, right-1 do + width = width - columns[col].width - h_margin + end + width = width - columns[right].width + if width <=0 then + colspans[colRange] = nil + else + width = width / (right - left + 1) + if width > maxNeedWidthPerCol then + maxNeedCols = colRange + maxNeedWidthPerCol = width + end + end + end + -- resize all columns for that colspan + if maxNeedCols then + local left, right = maxNeedCols:match("^(%d+)%-(%d+)$") + for col = left, right do + EnlargeColumn(tooltip, columns[col], columns[col].width + maxNeedWidthPerCol) + end + colspans[maxNeedCols] = nil + end + end + + --now that the cell width is set, recalculate the rows' height + for _, line in ipairs(lines) do + if #(line.cells) > 0 then + local lineheight = 0 + for _, cell in pairs(line.cells) do + if cell then + lineheight = max(lineheight, cell:getContentHeight()) + end + end + if lineheight > 0 then + ResizeLine(tooltip, line, lineheight) + end + end + end +end + +local function _SetCell(tooltip, lineNum, colNum, value, font, justification, colSpan, provider, ...) + local line = tooltip.lines[lineNum] + local cells = line.cells + + -- Unset: be quick + if value == nil then + local cell = cells[colNum] + + if cell then + for i = colNum, colNum + cell._colSpan - 1 do + cells[i] = nil + end + ReleaseCell(cell) + end + return lineNum, colNum + end + font = font or (line.is_header and tooltip.headerFont or tooltip.regularFont) + + -- Check previous cell + local cell + local prevCell = cells[colNum] + + if prevCell then + -- There is a cell here + justification = justification or prevCell._justification + colSpan = colSpan or prevCell._colSpan + + -- Clear the currently marked colspan + for i = colNum + 1, colNum + prevCell._colSpan - 1 do + cells[i] = nil + end + + if provider == nil or prevCell._provider == provider then + -- Reuse existing cell + cell = prevCell + provider = cell._provider + else + -- A new cell is required + cells[colNum] = ReleaseCell(prevCell) + end + elseif prevCell == nil then + -- Creating a new cell, using meaningful defaults. + provider = provider or tooltip.labelProvider + justification = justification or tooltip.columns[colNum].justification or "LEFT" + colSpan = colSpan or 1 + else + error("overlapping cells at column "..colNum, 3) + end + local tooltipWidth = #tooltip.columns + local rightColNum + + if colSpan > 0 then + rightColNum = colNum + colSpan - 1 + + if rightColNum > tooltipWidth then + error("ColSpan too big, cell extends beyond right-most column", 3) + end + else + -- Zero or negative: count back from right-most columns + rightColNum = max(colNum, tooltipWidth + colSpan) + -- Update colspan to its effective value + colSpan = 1 + rightColNum - colNum + end + + -- Cleanup colspans + for i = colNum + 1, rightColNum do + local cell = cells[i] + + if cell then + ReleaseCell(cell) + elseif cell == false then + error("overlapping cells at column "..i, 3) + end + cells[i] = false + end + + -- Create the cell + if not cell then + cell = AcquireCell(tooltip, provider) + cells[colNum] = cell + end + + -- Anchor the cell + cell:SetPoint("LEFT", tooltip.columns[colNum]) + cell:SetPoint("RIGHT", tooltip.columns[rightColNum]) + cell:SetPoint("TOP", line) + cell:SetPoint("BOTTOM", line) + + -- Store the cell settings directly into the cell + -- That's a bit risky but is really cheap compared to other ways to do it + cell._font, cell._justification, cell._colSpan, cell._line, cell._column = font, justification, colSpan, lineNum, colNum + + -- Setup the cell content + local width, height = cell:SetupCell(tooltip, value, justification, font, ...) + cell:Show() + + if colSpan > 1 then + -- Postpone width changes until the tooltip is shown + local colRange = colNum.."-"..rightColNum + + tooltip.colspans[colRange] = max(tooltip.colspans[colRange] or 0, width) + layoutCleaner:RegisterForCleanup(tooltip) + else + -- Enlarge the column and tooltip if need be + EnlargeColumn(tooltip, tooltip.columns[colNum], width) + end + + -- Enlarge the line and tooltip if need be + if height > line.height then + SetTooltipSize(tooltip, tooltip.width, tooltip.height + height - line.height) + + line.height = height + line:SetHeight(height) + end + + if rightColNum < tooltipWidth then + return lineNum, rightColNum + 1 + else + return lineNum, nil + end +end + +do + local function CreateLine(tooltip, font, ...) + if #tooltip.columns == 0 then + error("column layout should be defined before adding line", 3) + end + local lineNum = #tooltip.lines + 1 + local line = tooltip.lines[lineNum] or AcquireFrame(tooltip.scrollChild) + + line:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 2) + line:SetPoint('LEFT', tooltip.scrollChild) + line:SetPoint('RIGHT', tooltip.scrollChild) + + if lineNum > 1 then + local v_margin = tooltip.cell_margin_v or CELL_MARGIN_V + + line:SetPoint('TOP', tooltip.lines[lineNum-1], 'BOTTOM', 0, -v_margin) + SetTooltipSize(tooltip, tooltip.width, tooltip.height + v_margin) + else + line:SetPoint('TOP', tooltip.scrollChild) + end + tooltip.lines[lineNum] = line + line.cells = line.cells or AcquireTable() + line.height = 0 + line:SetHeight(1) + line:Show() + + local colNum = 1 + + for i = 1, #tooltip.columns do + local value = select(i, ...) + + if value ~= nil then + lineNum, colNum = _SetCell(tooltip, lineNum, i, value, font, nil, 1, tooltip.labelProvider) + end + end + return lineNum, colNum + end + + function tipPrototype:AddLine(...) + return CreateLine(self, self.regularFont, ...) + end + + function tipPrototype:AddHeader(...) + local line, col = CreateLine(self, self.headerFont, ...) + + self.lines[line].is_header = true + return line, col + end +end -- do-block + +local GenericBackdrop = { + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", +} + +function tipPrototype:AddSeparator(height, r, g, b, a) + local lineNum, colNum = self:AddLine() + local line = self.lines[lineNum] + local color = NORMAL_FONT_COLOR + + height = height or 1 + SetTooltipSize(self, self.width, self.height + height) + line.height = height + line:SetHeight(height) + line:SetBackdrop(GenericBackdrop) + line:SetBackdropColor(r or color.r, g or color.g, b or color.b, a or 1) + return lineNum, colNum +end + +function tipPrototype:SetCellColor(lineNum, colNum, r, g, b, a) + local cell = self.lines[lineNum].cells[colNum] + + if cell then + local sr, sg, sb, sa = self:GetBackdropColor() + cell:SetBackdrop(GenericBackdrop) + cell:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) + end +end + +function tipPrototype:SetColumnColor(colNum, r, g, b, a) + local column = self.columns[colNum] + + if column then + local sr, sg, sb, sa = self:GetBackdropColor() + column:SetBackdrop(GenericBackdrop) + column:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) + end +end + +function tipPrototype:SetLineColor(lineNum, r, g, b, a) + local line = self.lines[lineNum] + + if line then + local sr, sg, sb, sa = self:GetBackdropColor() + line:SetBackdrop(GenericBackdrop) + line:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) + end +end + +do + local function checkFont(font, level, silent) + local bad = false + + if not font then + bad = true + elseif type(font) == "string" then + local ref = _G[font] + + if not ref or type(ref) ~= 'table' or type(ref.IsObjectType) ~= 'function' or not ref:IsObjectType("Font") then + bad = true + end + elseif type(font) ~= 'table' or type(font.IsObjectType) ~= 'function' or not font:IsObjectType("Font") then + bad = true + end + + if bad then + if silent then + return false + end + error("font must be a Font instance or a string matching the name of a global Font instance, not: "..tostring(font), level + 1) + end + return true + end + + function tipPrototype:SetFont(font) + local is_string = type(font) == "string" + + checkFont(font, 2) + self.regularFont = is_string and _G[font] or font + end + + function tipPrototype:SetHeaderFont(font) + local is_string = type(font) == "string" + + checkFont(font, 2) + self.headerFont = is_string and _G[font] or font + end + + -- TODO: fixed argument positions / remove checks for performance? + function tipPrototype:SetCell(lineNum, colNum, value, ...) + -- Mandatory argument checking + if type(lineNum) ~= "number" then + error("line number must be a number, not: "..tostring(lineNum), 2) + elseif lineNum < 1 or lineNum > #self.lines then + error("line number out of range: "..tostring(lineNum), 2) + elseif type(colNum) ~= "number" then + error("column number must be a number, not: "..tostring(colNum), 2) + elseif colNum < 1 or colNum > #self.columns then + error("column number out of range: "..tostring(colNum), 2) + end + + -- Variable argument checking + local font, justification, colSpan, provider + local i, arg = 1, ... + + if arg == nil or checkFont(arg, 2, true) then + i, font, arg = 2, ... + end + + if arg == nil or checkJustification(arg, 2, true) then + i, justification, arg = i + 1, select(i, ...) + end + + if arg == nil or type(arg) == 'number' then + i, colSpan, arg = i + 1, select(i, ...) + end + + if arg == nil or type(arg) == 'table' and type(arg.AcquireCell) == 'function' then + i, provider = i + 1, arg + end + + return _SetCell(self, lineNum, colNum, value, font, justification, colSpan, provider, select(i, ...)) + end +end -- do-block + +function tipPrototype:GetFont() + return self.regularFont +end + +function tipPrototype:GetHeaderFont() + return self.headerFont +end + +function tipPrototype:GetLineCount() return #self.lines end + +function tipPrototype:GetColumnCount() return #self.columns end + + +------------------------------------------------------------------------------ +-- Frame Scripts +------------------------------------------------------------------------------ +local highlight = CreateFrame("Frame", nil, UIParent) +highlight:SetFrameStrata("TOOLTIP") +highlight:Hide() + +highlight._texture = highlight:CreateTexture(nil, "OVERLAY") +highlight._texture:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") +highlight._texture:SetBlendMode("ADD") +highlight._texture:SetAllPoints(highlight) + +local scripts = { + OnEnter = function(frame, ...) + highlight:SetParent(frame) + highlight:SetAllPoints(frame) + highlight:Show() + if frame._OnEnter_func then + frame:_OnEnter_func(frame._OnEnter_arg, ...) + end + end, + OnLeave = function(frame, ...) + highlight:Hide() + highlight:ClearAllPoints() + highlight:SetParent(nil) + if frame._OnLeave_func then + frame:_OnLeave_func(frame._OnLeave_arg, ...) + end + end, + OnMouseDown = function(frame, ...) + frame:_OnMouseDown_func(frame._OnMouseDown_arg, ...) + end, + OnMouseUp = function(frame, ...) + frame:_OnMouseUp_func(frame._OnMouseUp_arg, ...) + end, + OnReceiveDrag = function(frame, ...) + frame:_OnReceiveDrag_func(frame._OnReceiveDrag_arg, ...) + end, +} + +function SetFrameScript(frame, script, func, arg) + if not scripts[script] then + return + end + frame["_"..script.."_func"] = func + frame["_"..script.."_arg"] = arg + + if script == "OnMouseDown" or script == "OnMouseUp" or script == "OnReceiveDrag" then + if func then + frame:SetScript(script, scripts[script]) + else + frame:SetScript(script, nil) + end + end + + -- if at least one script is set, set the OnEnter/OnLeave scripts for the highlight + if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then + frame:EnableMouse(true) + frame:SetScript("OnEnter", scripts.OnEnter) + frame:SetScript("OnLeave", scripts.OnLeave) + else + frame:EnableMouse(false) + frame:SetScript("OnEnter", nil) + frame:SetScript("OnLeave", nil) + end +end + +function ClearFrameScripts(frame) + if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then + frame:EnableMouse(false) + frame:SetScript("OnEnter", nil) + frame._OnEnter_func = nil + frame._OnEnter_arg = nil + frame:SetScript("OnLeave", nil) + frame._OnLeave_func = nil + frame._OnLeave_arg = nil + frame:SetScript("OnReceiveDrag", nil) + frame._OnReceiveDrag_func = nil + frame._OnReceiveDrag_arg = nil + frame:SetScript("OnMouseDown", nil) + frame._OnMouseDown_func = nil + frame._OnMouseDown_arg = nil + frame:SetScript("OnMouseUp", nil) + frame._OnMouseUp_func = nil + frame._OnMouseUp_arg = nil + end +end + +function tipPrototype:SetLineScript(lineNum, script, func, arg) + SetFrameScript(self.lines[lineNum], script, func, arg) +end + +function tipPrototype:SetColumnScript(colNum, script, func, arg) + SetFrameScript(self.columns[colNum], script, func, arg) +end + +function tipPrototype:SetCellScript(lineNum, colNum, script, func, arg) + local cell = self.lines[lineNum].cells[colNum] + if cell then + SetFrameScript(cell, script, func, arg) + end +end + +------------------------------------------------------------------------------ +-- Auto-hiding feature +------------------------------------------------------------------------------ + +-- Script of the auto-hiding child frame +local function AutoHideTimerFrame_OnUpdate(self, elapsed) + self.checkElapsed = self.checkElapsed + elapsed + if self.checkElapsed > 0.1 then + if self.parent:IsMouseOver() or (self.alternateFrame and self.alternateFrame:IsMouseOver()) then + self.elapsed = 0 + else + self.elapsed = self.elapsed + self.checkElapsed + if self.elapsed >= self.delay then + lib:Release(self.parent) + end + end + self.checkElapsed = 0 + end +end + +-- Usage: +-- :SetAutoHideDelay(0.25) => hides after 0.25sec outside of the tooltip +-- :SetAutoHideDelay(0.25, someFrame) => hides after 0.25sec outside of both the tooltip and someFrame +-- :SetAutoHideDelay() => disable auto-hiding (default) +function tipPrototype:SetAutoHideDelay(delay, alternateFrame) + local timerFrame = self.autoHideTimerFrame + delay = tonumber(delay) or 0 + + if delay > 0 then + if not timerFrame then + timerFrame = AcquireFrame(self) + timerFrame:SetScript("OnUpdate", AutoHideTimerFrame_OnUpdate) + self.autoHideTimerFrame = timerFrame + end + timerFrame.parent = self + timerFrame.checkElapsed = 0 + timerFrame.elapsed = 0 + timerFrame.delay = delay + timerFrame.alternateFrame = alternateFrame + timerFrame:Show() + elseif timerFrame then + self.autoHideTimerFrame = nil + timerFrame.alternateFrame = nil + timerFrame:SetScript("OnUpdate", nil) + ReleaseFrame(timerFrame) + end +end + +------------------------------------------------------------------------------ +-- "Smart" Anchoring +------------------------------------------------------------------------------ +local function GetTipAnchor(frame) + local x,y = frame:GetCenter() + if not x or not y then return "TOPLEFT", "BOTTOMLEFT" end + local hhalf = (x > UIParent:GetWidth() * 2/3) and "RIGHT" or (x < UIParent:GetWidth() / 3) and "LEFT" or "" + local vhalf = (y > UIParent:GetHeight() / 2) and "TOP" or "BOTTOM" + return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf +end + +function tipPrototype:SmartAnchorTo(frame) + if not frame then + error("Invalid frame provided.", 2) + end + self:ClearAllPoints() + self:SetClampedToScreen(true) + self:SetPoint(GetTipAnchor(frame)) +end + +------------------------------------------------------------------------------ +-- Debug slashcmds +------------------------------------------------------------------------------ +--[===[@debug@ +local print = print +local function PrintStats() + local tipCache = tostring(#tooltipHeap) + local frameCache = tostring(#frameHeap) + local tableCache = tostring(#tableHeap) + local header = false + + print("Tooltips used: "..usedTooltips..", Cached: "..tipCache..", Total: "..tipCache + usedTooltips) + print("Frames used: "..usedFrames..", Cached: "..frameCache..", Total: "..frameCache + usedFrames) + print("Tables used: "..usedTables..", Cached: "..tableCache..", Total: "..tableCache + usedTables) + + for k, v in pairs(activeTooltips) do + if not header then + print("Active tooltips:") + header = true + end + print("- "..k) + end +end + +SLASH_LibQTip1 = "/qtip" +SlashCmdList["LibQTip"] = PrintStats +--@end-debug@]===] diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibQTip-1.0.toc b/ElvUI_SLE/libs/LibQTip-1.0/LibQTip-1.0.toc new file mode 100644 index 0000000..291a8b2 --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibQTip-1.0.toc @@ -0,0 +1,17 @@ +## Interface: 40300 +## Title: Lib: QTip-1.0 +## Notes: Library providing multi-column tooltips. +## Author: Torhal, Adirelle, Elkano, Tristanian +## Version: r154-release +## LoadOnDemand: 1 +## X-Date: 2012-08-17T21:40:16Z +## X-Credits: Kaelten (input on initial design) +## X-Category: Library, Tooltip +## X-License: Ace3 BSD-like license +## X-Curse-Packaged-Version: r154-release +## X-Curse-Project-Name: LibQTip-1.0 +## X-Curse-Project-ID: libqtip-1-0 +## X-Curse-Repository-ID: wow/libqtip-1-0/mainline + +LibStub\LibStub.lua +lib.xml diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibStub/LibStub.lua b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/LibStub.lua new file mode 100644 index 0000000..ae1900e --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/LibStub.lua @@ -0,0 +1,51 @@ +-- $Id: LibStub.lua 76 2007-09-03 01:50:17Z mikk $ +-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info +-- LibStub is hereby placed in the Public Domain +-- Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! +local LibStub = _G[LIBSTUB_MAJOR] + +-- Check to see is this version of the stub is obsolete +if not LibStub or LibStub.minor < LIBSTUB_MINOR then + LibStub = LibStub or {libs = {}, minors = {} } + _G[LIBSTUB_MAJOR] = LibStub + LibStub.minor = LIBSTUB_MINOR + + -- LibStub:NewLibrary(major, minor) + -- major (string) - the major version of the library + -- minor (string or number ) - the minor version of the library + -- + -- returns nil if a newer or same version of the lib is already present + -- returns empty library object or old library object if upgrade is needed + function LibStub:NewLibrary(major, minor) + assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") + minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") + + local oldminor = self.minors[major] + if oldminor and oldminor >= minor then return nil end + self.minors[major], self.libs[major] = minor, self.libs[major] or {} + return self.libs[major], oldminor + end + + -- LibStub:GetLibrary(major, [silent]) + -- major (string) - the major version of the library + -- silent (boolean) - if true, library is optional, silently return nil if its not found + -- + -- throws an error if the library can not be found (except silent is set) + -- returns the library object if found + function LibStub:GetLibrary(major, silent) + if not self.libs[major] and not silent then + error(("Cannot find a library instance of %q."):format(tostring(major)), 2) + end + return self.libs[major], self.minors[major] + end + + -- LibStub:IterateLibraries() + -- + -- Returns an iterator for the currently registered libraries + function LibStub:IterateLibraries() + return pairs(self.libs) + end + + setmetatable(LibStub, { __call = LibStub.GetLibrary }) +end diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibStub/LibStub.toc b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/LibStub.toc new file mode 100644 index 0000000..e39aa26 --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/LibStub.toc @@ -0,0 +1,13 @@ +## Interface: 50001 +## Title: Lib: LibStub +## Notes: Universal Library Stub +## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel +## X-Website: http://www.wowace.com/addons/libstub/ +## X-Category: Library +## X-License: Public Domain +## X-Curse-Packaged-Version: 1.0.3-50001 +## X-Curse-Project-Name: LibStub +## X-Curse-Project-ID: libstub +## X-Curse-Repository-ID: wow/libstub/mainline + +LibStub.lua diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test.lua b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test.lua new file mode 100644 index 0000000..276ddab --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test.lua @@ -0,0 +1,41 @@ +debugstack = debug.traceback +strmatch = string.match + +loadfile("../LibStub.lua")() + +local lib, oldMinor = LibStub:NewLibrary("Pants", 1) -- make a new thingy +assert(lib) -- should return the library table +assert(not oldMinor) -- should not return the old minor, since it didn't exist + +-- the following is to create data and then be able to check if the same data exists after the fact +function lib:MyMethod() +end +local MyMethod = lib.MyMethod +lib.MyTable = {} +local MyTable = lib.MyTable + +local newLib, newOldMinor = LibStub:NewLibrary("Pants", 1) -- try to register a library with the same version, should silently fail +assert(not newLib) -- should not return since out of date + +local newLib, newOldMinor = LibStub:NewLibrary("Pants", 0) -- try to register a library with a previous, should silently fail +assert(not newLib) -- should not return since out of date + +local newLib, newOldMinor = LibStub:NewLibrary("Pants", 2) -- register a new version +assert(newLib) -- library table +assert(rawequal(newLib, lib)) -- should be the same reference as the previous +assert(newOldMinor == 1) -- should return the minor version of the previous version + +assert(rawequal(lib.MyMethod, MyMethod)) -- verify that values were saved +assert(rawequal(lib.MyTable, MyTable)) -- verify that values were saved + +local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 3 Blah") -- register a new version with a string minor version (instead of a number) +assert(newLib) -- library table +assert(newOldMinor == 2) -- previous version was 2 + +local newLib, newOldMinor = LibStub:NewLibrary("Pants", "Blah 4 and please ignore 15 Blah") -- register a new version with a string minor version (instead of a number) +assert(newLib) +assert(newOldMinor == 3) -- previous version was 3 (even though it gave a string) + +local newLib, newOldMinor = LibStub:NewLibrary("Pants", 5) -- register a new library, using a normal number instead of a string +assert(newLib) +assert(newOldMinor == 4) -- previous version was 4 (even though it gave a string) \ No newline at end of file diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test2.lua b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test2.lua new file mode 100644 index 0000000..eae7172 --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test2.lua @@ -0,0 +1,27 @@ +debugstack = debug.traceback +strmatch = string.match + +loadfile("../LibStub.lua")() + +for major, library in LibStub:IterateLibraries() do + -- check that MyLib doesn't exist yet, by iterating through all the libraries + assert(major ~= "MyLib") +end + +assert(not LibStub:GetLibrary("MyLib", true)) -- check that MyLib doesn't exist yet by direct checking +assert(not pcall(LibStub.GetLibrary, LibStub, "MyLib")) -- don't silently fail, thus it should raise an error. +local lib = LibStub:NewLibrary("MyLib", 1) -- create the lib +assert(lib) -- check it exists +assert(rawequal(LibStub:GetLibrary("MyLib"), lib)) -- verify that :GetLibrary("MyLib") properly equals the lib reference + +assert(LibStub:NewLibrary("MyLib", 2)) -- create a new version + +local count=0 +for major, library in LibStub:IterateLibraries() do + -- check that MyLib exists somewhere in the libraries, by iterating through all the libraries + if major == "MyLib" then -- we found it! + count = count +1 + assert(rawequal(library, lib)) -- verify that the references are equal + end +end +assert(count == 1) -- verify that we actually found it, and only once diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test3.lua b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test3.lua new file mode 100644 index 0000000..30f7b94 --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test3.lua @@ -0,0 +1,14 @@ +debugstack = debug.traceback +strmatch = string.match + +loadfile("../LibStub.lua")() + +local proxy = newproxy() -- non-string + +assert(not pcall(LibStub.NewLibrary, LibStub, proxy, 1)) -- should error, proxy is not a string, it's userdata +local success, ret = pcall(LibStub.GetLibrary, proxy, true) +assert(not success or not ret) -- either error because proxy is not a string or because it's not actually registered. + +assert(not pcall(LibStub.NewLibrary, LibStub, "Something", "No number in here")) -- should error, minor has no string in it. + +assert(not LibStub:GetLibrary("Something", true)) -- shouldn't've created it from the above statement \ No newline at end of file diff --git a/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test4.lua b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test4.lua new file mode 100644 index 0000000..43eb338 --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/LibStub/tests/test4.lua @@ -0,0 +1,41 @@ +debugstack = debug.traceback +strmatch = string.match + +loadfile("../LibStub.lua")() + + +-- Pretend like loaded libstub is old and doesn't have :IterateLibraries +assert(LibStub.minor) +LibStub.minor = LibStub.minor - 0.0001 +LibStub.IterateLibraries = nil + +loadfile("../LibStub.lua")() + +assert(type(LibStub.IterateLibraries)=="function") + + +-- Now pretend that we're the same version -- :IterateLibraries should NOT be re-created +LibStub.IterateLibraries = 123 + +loadfile("../LibStub.lua")() + +assert(LibStub.IterateLibraries == 123) + + +-- Now pretend that a newer version is loaded -- :IterateLibraries should NOT be re-created +LibStub.minor = LibStub.minor + 0.0001 + +loadfile("../LibStub.lua")() + +assert(LibStub.IterateLibraries == 123) + + +-- Again with a huge number +LibStub.minor = LibStub.minor + 1234567890 + +loadfile("../LibStub.lua")() + +assert(LibStub.IterateLibraries == 123) + + +print("OK") \ No newline at end of file diff --git a/ElvUI_SLE/libs/LibQTip-1.0/lib.xml b/ElvUI_SLE/libs/LibQTip-1.0/lib.xml new file mode 100644 index 0000000..5531be0 --- /dev/null +++ b/ElvUI_SLE/libs/LibQTip-1.0/lib.xml @@ -0,0 +1,4 @@ +<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ +..\FrameXML\UI.xsd"> + <Script file="LibQTip-1.0.lua"/> +</Ui> \ No newline at end of file diff --git a/ElvUI_SLE/libs/load_libs.xml b/ElvUI_SLE/libs/load_libs.xml index f4873b5..b8027b5 100755 --- a/ElvUI_SLE/libs/load_libs.xml +++ b/ElvUI_SLE/libs/load_libs.xml @@ -1 +1 @@ -<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Include file="LibBabble-SubZone-3.0\lib.xml"/> <Script file="oUF_NecroStrike\oUF_NecroStrike.lua"/> </Ui> \ No newline at end of file +<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Include file="LibBabble-SubZone-3.0\lib.xml"/> <Script file="oUF_NecroStrike\oUF_NecroStrike.lua"/> <Script file="LibQTip-1.0\LibQTip-1.0.lua"/> </Ui> \ No newline at end of file diff --git a/ElvUI_SLE/modules/backgrounds/options.lua b/ElvUI_SLE/modules/backgrounds/options.lua index b0d5f81..1ebd798 100755 --- a/ElvUI_SLE/modules/backgrounds/options.lua +++ b/ElvUI_SLE/modules/backgrounds/options.lua @@ -13,7 +13,7 @@ local drop = { E.Options.args.sle.args.backgrounds = { type = "group", name = L["Backgrounds"], - order = 9, + order = 10, childGroups = "select", args = { header = { diff --git a/ElvUI_SLE/modules/characterframe/options.lua b/ElvUI_SLE/modules/characterframe/options.lua index 01fa5a5..44dc06b 100755 --- a/ElvUI_SLE/modules/characterframe/options.lua +++ b/ElvUI_SLE/modules/characterframe/options.lua @@ -6,7 +6,7 @@ local function configTable() E.Options.args.sle.args.characterframeoptions = { type = "group", name = L["Character Frame"], - order = 2, + order = 12, args = { header = { order = 1, diff --git a/ElvUI_SLE/modules/chat/chat.lua b/ElvUI_SLE/modules/chat/chat.lua index 73c2a59..ae61c8f 100755 --- a/ElvUI_SLE/modules/chat/chat.lua +++ b/ElvUI_SLE/modules/chat/chat.lua @@ -299,4 +299,4 @@ ChatFrame_AddMessageEventFilter("CHAT_MSG_INSTANCE_CHAT_LEADER", SLEfilter) ChatFrame_AddMessageEventFilter("CHAT_MSG_BN_CONVERSATION", SLEfilter) ChatFrame_AddMessageEventFilter("CHAT_MSG_BN_WHISPER", SLEfilter) ChatFrame_AddMessageEventFilter("CHAT_MSG_BN_WHISPER_INFORM", SLEfilter) -ChatFrame_AddMessageEventFilter("CHAT_MSG_BN_INLINE_TOAST_BROADCAST", SLEfilter) +ChatFrame_AddMessageEventFilter("CHAT_MSG_BN_INLINE_TOAST_BROADCAST", SLEfilter) \ No newline at end of file diff --git a/ElvUI_SLE/modules/chat/options.lua b/ElvUI_SLE/modules/chat/options.lua index a2c0680..e785021 100755 --- a/ElvUI_SLE/modules/chat/options.lua +++ b/ElvUI_SLE/modules/chat/options.lua @@ -2,7 +2,7 @@ local function configTable() E.Options.args.sle.args.chat = { - order = 8, + order = 11, type = "group", name = L["Chat"], args = { diff --git a/ElvUI_SLE/modules/datatexts/friends.lua b/ElvUI_SLE/modules/datatexts/friends.lua new file mode 100644 index 0000000..5f7f7f2 --- /dev/null +++ b/ElvUI_SLE/modules/datatexts/friends.lua @@ -0,0 +1,545 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +local LibQTip = LibStub('LibQTip-1.0') +local ACD = LibStub("AceConfigDialog-3.0") +local DT = E:GetModule('DataTexts') +local LDB = LibStub("LibDataBroker-1.1"):NewDataObject("S&L Friends", +{ + type = "data source", + icon = "Interface\\Icons\\INV_Drink_08.png", + label = "S&L Friends", + text = "S&L Friends" +}) +local _G = getfenv(0) +local string = _G.string +local pairs = _G.pairs +local frame = CreateFrame("frame") +local tooltip +local LDB_ANCHOR +--local update_Friends + +local GROUP_CHECKMARK = "|TInterface\\Buttons\\UI-CheckBox-Check:0|t" +local AWAY_ICON = "|TInterface\\FriendsFrame\\StatusIcon-Away:18|t" +local BUSY_ICON = "|TInterface\\FriendsFrame\\StatusIcon-DnD:18|t" +local MOBILE_ICON = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat:18|t" +local MINIMIZE = "|TInterface\\BUTTONS\\UI-PlusButton-Up:0|t" +local BROADCAST_ICON = "|TInterface\\FriendsFrame\\BroadcastIcon:0|t" + +--local FACTION_COLOR_HORDE = RED_FONT_COLOR_CODE +--local FACTION_COLOR_ALLIANCE = "|cff0070dd" + +-- Setup the Title Font. 14 +local ssTitleFont = CreateFont("ssTitleFont") +ssTitleFont:SetTextColor(1,0.823529,0) +ssTitleFont:SetFont(GameTooltipText:GetFont(), 14) + +-- Setup the Header Font. 12 +local ssHeaderFont = CreateFont("ssHeaderFont") +ssHeaderFont:SetTextColor(1,0.823529,0) +ssHeaderFont:SetFont(GameTooltipHeaderText:GetFont(), 12) + +-- Setup the Regular Font. 12 +local ssRegFont = CreateFont("ssRegFont") +ssRegFont:SetTextColor(1,0.823529,0) +ssRegFont:SetFont(GameTooltipText:GetFont(), 12) + +local list_sort = { + TOONNAME = function(a, b) + return a["TOONNAME"] < b["TOONNAME"] + end, + LEVEL = function(a, b) + if a["LEVEL"] < b["LEVEL"] then + return true + elseif a["LEVEL"] > b["LEVEL"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + RANKINDEX = function(a, b) + if a["RANKINDEX"] > b["RANKINDEX"] then + return true + elseif a["RANKINDEX"] < b["RANKINDEX"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + ZONENAME = function(a, b) + if a["ZONENAME"] < b["ZONENAME"] then + return true + elseif a["ZONENAME"] > b["ZONENAME"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + REALMNAME = function(a, b) + if a["REALMNAME"] < b["REALMNAME"] then + return true + elseif a["REALMNAME"] > b["REALMNAME"] then + return false + else -- TOONNAME + return a["ZONENAME"] < b["ZONENAME"] + end + end, + revTOONNAME = function(a, b) + return a["TOONNAME"] > b["TOONNAME"] + end, + revLEVEL = function(a, b) + if a["LEVEL"] > b["LEVEL"] then + return true + elseif a["LEVEL"] < b["LEVEL"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + revRANKINDEX = function(a, b) + if a["RANKINDEX"] < b["RANKINDEX"] then + return true + elseif a["RANKINDEX"] > b["RANKINDEX"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + revZONENAME = function(a, b) + if a["ZONENAME"] > b["ZONENAME"] then + return true + elseif a["ZONENAME"] < b["ZONENAME"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + revREALMNAME = function(a, b) + if a["REALMNAME"] > b["REALMNAME"] then + return true + elseif a["REALMNAME"] < b["REALMNAME"] then + return false + else -- TOONNAME + return a["ZONENAME"] < b["ZONENAME"] + end + end +} + +local function inGroup(name) + if GetNumSubgroupMembers() > 0 and UnitInParty(name) then + return true + elseif GetNumGroupMembers() > 0 and UnitInRaid(name) then + return true + end + + return false +end + +local function nameIndex(name) + local lookupname + + for i = 1, GetNumFriends() do + lookupname = GetFriendInfo(i) + if lookupname == name then + return i + end + end +end + +local function ColoredLevel(level) + if level ~= "" then + local color = GetQuestDifficultyColor(level) + return string.format("|cff%02x%02x%02x%d|r", color.r * 255, color.g * 255, color.b * 255, level) + end +end + +local CLASS_COLORS, color = {} +local classes_female, classes_male = {}, {} + +FillLocalizedClassList(classes_female, true) +FillLocalizedClassList(classes_male, false) + +for token, localizedName in pairs(classes_female) do + color = RAID_CLASS_COLORS[token] + CLASS_COLORS[localizedName] = string.format("%02x%02x%02x", color.r * 255, color.g * 255, color.b * 255) +end + +for token, localizedName in pairs(classes_male) do + color = RAID_CLASS_COLORS[token] + CLASS_COLORS[localizedName] = string.format("%02x%02x%02x", color.r * 255, color.g * 255, color.b * 255) +end + +local function valueColor(totals) + if totals ~= "" then + local color = E.db.general.valuecolor + return string.format("|cff%02x%02x%02x%d|r", color.r * 255, color.g * 255, color.b * 255, totals) + end +end + +function DT:update_Friends() + ShowFriends() + local friendsTotal, friendsOnline = GetNumFriends() + local bnTotal, bnOnline = BNGetNumFriends() + local totalOnline = friendsOnline + bnOnline + local totalFriends = friendsTotal + bnTotal + + if E.db.sle.dt.friends.totals then + LDB.text = "|cffffffffFriends: |r"..valueColor(totalOnline).."/"..valueColor(totalFriends) + else + LDB.text = "|cffffffffFriends: |r"..valueColor(totalOnline) + end +end + +local function Entry_OnMouseUp(frame, info, button) + local i_type, toon_name, full_name, presence_id = string.split(":", info) + + if button == "LeftButton" then + if IsAltKeyDown() then + if i_type == "realid" then + local presenceID, presenceName, battleTag, isBattleTagPresence, toonName, toonID = BNGetFriendInfo(BNGetFriendIndex(presence_id)) + local _, toonName, client, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetFriendToonInfo(BNGetFriendIndex(presence_id), 1) + + InviteUnit(toon_name.."-"..realmName) + return + else + InviteUnit(toon_name) + return + end + end + + if IsShiftKeyDown() then + SetItemRef("player:"..toon_name, "|Hplayer:"..toon_name.."|h["..toon_name.."|h", "LeftButton") + return + end + + if IsControlKeyDown() then + if i_type == "friends" then + FriendsFrame.NotesID = nameIndex(toon_name) + StaticPopup_Show("SET_FRIENDNOTE", GetFriendInfo(FriendsFrame.NotesID)) + return + end + + if i_type == "realid" then + FriendsFrame.NotesID = presence_id + StaticPopup_Show("SET_BNFRIENDNOTE", full_name) + return + end + end + + if i_type == "realid" then + local name = full_name..":"..presence_id + SetItemRef( "BNplayer:"..name, ("|HBNplayer:%1$s|h[%1$s]|h"):format(name), "LeftButton" ) + else + SetItemRef( "player:"..full_name, ("|Hplayer:%1$s|h[%1$s]|h"):format(full_name), "LeftButton" ) + end + elseif button == "RightButton" then + if IsControlKeyDown() then + --if i_type == "guild" and CanEditOfficerNote() then + -- SetGuildRosterSelection(guild_name_to_index(toon_name)) + -- StaticPopup_Show("SET_GUILDOFFICERNOTE") + --end + end + elseif button == "MiddleButton" then + -- Expand RealID Broadcast + E.db.sle.dt.friends.expandBNBroadcast = not E.db.sle.dt.friends.expandBNBroadcast + --E.db.sle.socialstate.expand_realID = not E.db.sle.socialstate.expand_realID + LDB.OnEnter(LDB_ANCHOR) + end +end + +local function HideOnMouseUp(cell, section) + E.db.sle.dt.friends[section] = not E.db.sle.dt.friends[section] + LDB.OnEnter(LDB_ANCHOR) +end + +local function SetRealIDSort(cell, sortsection) + if E.db.sle.dt.friends["sortBN"] == sortsection then + E.db.sle.dt.friends["sortBN"] = "rev" .. sortsection + else + E.db.sle.dt.friends["sortBN"] = sortsection + end + LDB.OnEnter(LDB_ANCHOR) +end + +function LDB:OnClick(button) + if button == "LeftButton" then + ToggleFriendsFrame(1) + end + + if button == "RightButton" then + ElvConfigToggle:Click(); + ACD:SelectGroup("ElvUI", "sle", "sldatatext", "slfriends") + end +end + +function LDB.OnLeave() end + +function LDB.OnEnter(self) + if E.db.sle.dt.friends.combat and InCombatLockdown() then return end + LDB_ANCHOR = self + + if LibQTip:IsAcquired("ShadowLightFriends") then + tooltip:Clear() + else + tooltip = LibQTip:Acquire("ShadowLightFriends", 8, "RIGHT", "RIGHT", "LEFT", "LEFT", "CENTER", "CENTER", "RIGHT") + + tooltip:SetBackdropColor(0,0,0,1) + + tooltip:SetHeaderFont(ssHeaderFont) + tooltip:SetFont(ssRegFont) + + tooltip:SmartAnchorTo(self) + tooltip:SetAutoHideDelay(E.db.sle.dt.friends.tooltipAutohide, self) + tooltip:SetScript("OnShow", function(ttskinself) ttskinself:SetTemplate('Transparent') end) + end + + local line = tooltip:AddLine() + tooltip:SetCell(line, 1, "Shadow & Light Friends", ssTitleFont, "CENTER", 0) + tooltip:AddLine(" ") + + local _, numBNOnline = BNGetNumFriends() + local _, numFriendsOnline = GetNumFriends() + + if (numBNOnline > 0) or (numFriendsOnline > 0) then + line = tooltip:AddLine() + if not E.db.sle.dt.friends.hideFriends then + tooltip:SetCell(line, 1, "|cffffffff" .. _G.FRIENDS .. "|r", "LEFT", 3) + else + tooltip:SetCell(line, 1, "|cffffffff" .. MINIMIZE .. _G.FRIENDS .. "|r", "LEFT", 3) + end + tooltip:SetCellScript(line, 1, "OnMouseUp", HideOnMouseUp, "hideFriends") + + if not E.db.sle.dt.friends.hideFriends then + line = tooltip:AddHeader() + line = tooltip:SetCell(line, 1, " ") + tooltip:SetCellScript(line, 1, "OnMouseUp", SetRealIDSort, "LEVEL") + line = tooltip:SetCell(line, 3, _G.NAME) + tooltip:SetCellScript(line, 3, "OnMouseUp", SetRealIDSort, "TOONNAME") + line = tooltip:SetCell(line, 4, _G.BATTLENET_FRIEND) + tooltip:SetCellScript(line, 4, "OnMouseUp", SetRealIDSort, "REALID") + line = tooltip:SetCell(line, 5, _G.LOCATION_COLON) + tooltip:SetCellScript(line, 5, "OnMouseUp", SetRealIDSort, "ZONENAME") + line = tooltip:SetCell(line, 6, _G.FRIENDS_LIST_REALM) + tooltip:SetCellScript(line, 6, "OnMouseUp", SetRealIDSort, "REALMNAME") + if not E.db.sle.dt.friends.hideFriendsNotes then + line = tooltip:SetCell(line, 7, _G.NOTE_COLON) + else + line = tooltip:SetCell(line, 7, MINIMIZE .. _G.NOTE_COLON) + end + tooltip:SetCellScript(line, 7, "OnMouseUp", HideOnMouseUp, "hideFriendsNotes") + + tooltip:AddSeparator() + + if numBNOnline > 0 then + local realid_table = {} + for i = 1, numBNOnline do + local presenceID, givenName, surname = BNGetFriendInfo(i) + for toonidx = 1, BNGetNumFriendToons(i) do + local fcolor + local status = "" + + local _, _, _, _, _, _, _, isOnline, lastOnline, isAFK, isDND, broadcast, note = BNGetFriendInfoByID(presenceID) + local _, toonName, client, realmName, realmID, faction, race, class, guild, zoneName, level, gameText = BNGetFriendToonInfo(i, toonidx) + + if faction then + if faction == "Horde" then + fcolor = RED_FONT_COLOR_CODE + else + fcolor = "|cff0070dd" + --fcolor = FACTION_COLOR_ALLIANCE + end + end + + if isAFK then + status = AWAY_ICON + end + + if isDND then + status = BUSY_ICON + end + + if note and note ~= "" then note = "|cffff8800{"..note.."}|r" end + + table.insert(realid_table, { + GIVENNAME = givenName, + SURNAME = surname or "", + LEVEL = level, + CLASS = class, + FCOLOR = fcolor, + STATUS = status, + BROADCAST_TEXT = broadcast or "", + TOONNAME = toonName, + CLIENT = client, + ZONENAME = zoneName, + REALMNAME = realmName, + GAMETEXT = gameText, + NOTE = note, + PRESENCEID = presenceID + }) + end + end + + if (E.db.sle.dt.friends["sortBN"] ~= "REALID") and (E.db.sle.dt.friends["sortBN"] ~= "revREALID") then + table.sort(realid_table, list_sort[E.db.sle.dt.friends["sortBN"]]) + + end + + for _, player in ipairs(realid_table) do + local broadcast_flag + if not E.db.sle.dt.friends.expandBNBroadcast and player["BROADCAST_TEXT"] ~= "" then + broadcast_flag = " " .. BROADCAST_ICON + else + broadcast_flag = "" + end + + line = tooltip:AddLine() + line = tooltip:SetCell(line, 1, ColoredLevel(player["LEVEL"])) + line = tooltip:SetCell(line, 2, player["STATUS"]) + line = tooltip:SetCell(line, 3, + string.format("|cff%s%s",CLASS_COLORS[player["CLASS"]] or "B8B8B8", player["TOONNAME"] .. "|r").. + (inGroup(player["TOONNAME"]) and GROUP_CHECKMARK or "")) + line = tooltip:SetCell(line, 4, + "|cff82c5ff" .. player["GIVENNAME"] .. "|r" .. broadcast_flag) + + if player["CLIENT"] == "WoW" then + line = tooltip:SetCell(line, 5, player["ZONENAME"]) + line = tooltip:SetCell(line, 6, player["FCOLOR"] .. player["REALMNAME"] .. "|r") + else + line = tooltip:SetCell(line, 5, player["GAMETEXT"]) + if player["CLIENT"] == "S2" then + line = tooltip:SetCell(line, 6, "|cff82c5ffStarCraft 2|r") + end + + if player["CLIENT"] == "D3" then + line = tooltip:SetCell(line, 6, "|cff82c5ffDiablo 3|r") + end + end + + if not E.db.sle.dt.friends.hideFriendsNotes then + line = tooltip:SetCell(line, 7, player["NOTE"]) + end + + tooltip:SetLineScript(line, "OnMouseUp", Entry_OnMouseUp, string.format("realid:%s:%s:%d", player["TOONNAME"], player["GIVENNAME"], player["PRESENCEID"])) + + if E.db.sle.dt.friends.expandBNBroadcast and player["BROADCAST_TEXT"] ~= "" then + line = tooltip:AddLine() + line = tooltip:SetCell(line, 1, BROADCAST_ICON .. " |cff7b8489" .. player["BROADCAST_TEXT"] .. "|r", "LEFT", 0) + tooltip:SetLineScript(line, "OnMouseUp", Entry_OnMouseUp, string.format("realid:%s:%s:%d", player["TOONNAME"], player["GIVENNAME"], player["PRESENCEID"])) + end + end + tooltip:AddLine(" ") + end + + if numFriendsOnline > 0 then + local friend_table = {} + for i = 1,numFriendsOnline do + local toonName, level, class, zoneName, connected, status, note = GetFriendInfo(i) + + note = note and "|cffff8800{"..note.."}|r" or "" + + if status == CHAT_FLAG_AFK then + status = AWAY_ICON + elseif status == CHAT_FLAG_DND then + status = BUSY_ICON + end + + table.insert(friend_table, { + TOONNAME = toonName, + LEVEL = level, + CLASS = class, + ZONENAME = zoneName, + REALMNAME = "", + STATUS = status, + NOTE = note + }) + end + + if (E.db.sle.dt.friends["sortBN"] ~= "REALID") and (E.db.sle.dt.friends["sortBN"] ~= "revREALID") then + table.sort(friend_table, list_sort[E.db.sle.dt.friends["sortBN"]]) + else + table.sort(friend_table, list_sort["TOONNAME"]) + end + + for _, player in ipairs(friend_table) do + line = tooltip:AddLine() + line = tooltip:SetCell(line, 1, ColoredLevel(player["LEVEL"])) + line = tooltip:SetCell(line, 2, player["STATUS"]) + line = tooltip:SetCell(line, 3, + string.format("|cff%s%s", CLASS_COLORS[player["CLASS"]] or "ffffff", player["TOONNAME"] .. "|r") .. (inGroup(player["TOONNAME"]) and GROUP_CHECKMARK or "")); + line = tooltip:SetCell(line, 5, player["ZONENAME"]) + if not E.db.sle.dt.friends.hideFriendsNotes then + line = tooltip:SetCell(line, 7, player["NOTE"]) + end + + tooltip:SetLineScript(line, "OnMouseUp", Entry_OnMouseUp, string.format("friends:%s:%s", player["TOONNAME"], player["TOONNAME"])) + end + end + end + tooltip:AddLine(" ") + end + + if not E.db.sle.dt.friends.hide_hintline then + line = tooltip:AddLine() + if not E.db.sle.dt.friends.minimize_hintline then + tooltip:SetCell(line, 1, "Hint:", "LEFT", 3) + else + tooltip:SetCell(line, 1, MINIMIZE .. "Hint:", "LEFT", 3) + end + tooltip:SetCellScript(line, 1, "OnMouseUp", HideOnMouseUp, "minimize_hintline") + + if not E.db.sle.dt.friends.minimize_hintline then + --line = tooltip:AddLine() + --tooltip:SetCell(line, 1, "|cffeda55fLeft Click|r to open the friends panel. |cffeda55fRight Click|r to open configuration panel.", "LEFT", 0) + + --line = tooltip:AddLine() + --tooltip:SetCell(line, 1, "|cffeda55fClick|r a line to whisper a player. |cffeda55fShift-Click|r a line to lookup a player.", "LEFT", 0) + + --line = tooltip:AddLine() + --tooltip:SetCell(line, 1, "|cffeda55fCtrl-Click|r a line to edit a note. |cffeda55fCtrl-RightClick|r a line to edit an officer note.", "LEFT", 0) + + --line = tooltip:AddLine() + --tooltip:SetCell(line, 1, "|cffeda55fAlt-Click|r a line to invite. |cffeda55fMiddleClick|r a line to expand RealID.", "LEFT", 0) + + --line = tooltip:AddLine() + --tooltip:SetCell(line, 1, "|cffeda55fClick|r a Header to hide it or sort it.", "LEFT", 0) + + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "", "LEFT", 1) + tooltip:SetCell(line, 2, "|cffeda55fLeft Click|r to open the friends panel.", "LEFT", 3) + tooltip:SetCell(line, 5, "|cffeda55fRight Click|r to open configuration panel.", "LEFT", 3) + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "", "LEFT", 1) + tooltip:SetCell(line, 2, "|cffeda55fLeft Click|r a line to whisper a player.", "LEFT", 3) + tooltip:SetCell(line, 5, "|cffeda55fShift+Left Click|r a line to lookup a player.", "LEFT", 3) + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "", "LEFT", 1) + tooltip:SetCell(line, 2, "|cffeda55fCtrl+Left Click|r a line to edit a note.", "LEFT", 3) + tooltip:SetCell(line, 5, "|cffeda55fMiddleClick|r a line to expand RealID.", "LEFT", 3) + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "", "LEFT", 1) + tooltip:SetCell(line, 2, "|cffeda55fAlt+Left Click|r a line to invite.", "LEFT", 3) + tooltip:SetCell(line, 5, "|cffeda55fLeft Click|r a Header to hide it or sort it.", "LEFT", 3) + end + end + + tooltip:UpdateScrolling() + tooltip:Show() +end + +frame:SetScript("OnEvent", function(self, event, ...) + if self[event] then + return self[event](self, event, ...) + end +end) + +local DELAY = 15 -- Update every 15 seconds +local elapsed = DELAY - 5 + +frame:SetScript("OnUpdate", function (self, elapse) + elapsed = elapsed + elapse + + if elapsed >= DELAY then + elapsed = 0 + DT:update_Friends() + end +end) + +frame:RegisterEvent("PLAYER_LOGIN") \ No newline at end of file diff --git a/ElvUI_SLE/modules/datatexts/guild.lua b/ElvUI_SLE/modules/datatexts/guild.lua new file mode 100644 index 0000000..e022c1b --- /dev/null +++ b/ElvUI_SLE/modules/datatexts/guild.lua @@ -0,0 +1,417 @@ +local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore +local LibQTip = LibStub('LibQTip-1.0') +local ACD = LibStub("AceConfigDialog-3.0") +local DT = E:GetModule('DataTexts') +local LDB = LibStub("LibDataBroker-1.1"):NewDataObject("S&L Guild", +{ + type = "data source", + icon = "Interface\\Icons\\INV_Drink_08.png", + label = "S&L Guild", + text = "S&L Guild" +}) +local _G = getfenv(0) +local string = _G.string +local pairs = _G.pairs + +local frame = CreateFrame("frame") + +local tooltip +local LDB_ANCHOR + +local GROUP_CHECKMARK = "|TInterface\\Buttons\\UI-CheckBox-Check:0|t" +local AWAY_ICON = "|TInterface\\FriendsFrame\\StatusIcon-Away:18|t" +local BUSY_ICON = "|TInterface\\FriendsFrame\\StatusIcon-DnD:18|t" +local MOBILE_ICON = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat:18|t" +local MINIMIZE = "|TInterface\\BUTTONS\\UI-PlusButton-Up:0|t" + +local FACTION_COLOR_HORDE = RED_FONT_COLOR_CODE +local FACTION_COLOR_ALLIANCE = "|cff0070dd" + +-- Setup the Title Font. 14 +local ssTitleFont = CreateFont("ssTitleFont") +ssTitleFont:SetTextColor(1,0.823529,0) +ssTitleFont:SetFont(GameTooltipText:GetFont(), 14) + +-- Setup the Header Font. 12 +local ssHeaderFont = CreateFont("ssHeaderFont") +ssHeaderFont:SetTextColor(1,0.823529,0) +ssHeaderFont:SetFont(GameTooltipHeaderText:GetFont(), 12) + +-- Setup the Regular Font. 12 +local ssRegFont = CreateFont("ssRegFont") +ssRegFont:SetTextColor(1,0.823529,0) +ssRegFont:SetFont(GameTooltipText:GetFont(), 12) + +local list_sort = { + TOONNAME = function(a, b) + return a["TOONNAME"] < b["TOONNAME"] + end, + LEVEL = function(a, b) + if a["LEVEL"] < b["LEVEL"] then + return true + elseif a["LEVEL"] > b["LEVEL"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + RANKINDEX = function(a, b) + if a["RANKINDEX"] > b["RANKINDEX"] then + return true + elseif a["RANKINDEX"] < b["RANKINDEX"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + ZONENAME = function(a, b) + if a["ZONENAME"] < b["ZONENAME"] then + return true + elseif a["ZONENAME"] > b["ZONENAME"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + revTOONNAME = function(a, b) + return a["TOONNAME"] > b["TOONNAME"] + end, + revLEVEL = function(a, b) + if a["LEVEL"] > b["LEVEL"] then + return true + elseif a["LEVEL"] < b["LEVEL"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + revRANKINDEX = function(a, b) + if a["RANKINDEX"] < b["RANKINDEX"] then + return true + elseif a["RANKINDEX"] > b["RANKINDEX"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end, + revZONENAME = function(a, b) + if a["ZONENAME"] > b["ZONENAME"] then + return true + elseif a["ZONENAME"] < b["ZONENAME"] then + return false + else -- TOONNAME + return a["TOONNAME"] < b["TOONNAME"] + end + end +} + +local function inGroup(name) + if GetNumSubgroupMembers() > 0 and UnitInParty(name) then + return true + elseif GetNumGroupMembers() > 0 and UnitInRaid(name) then + return true + end + + return false +end + +local function guild_name_to_index(name) + local lookupname + + for i = 1, GetNumGuildMembers() do + lookupname = GetGuildRosterInfo(i) + + if lookupname == name then + return i + end + end +end + +local function ColoredLevel(level) + if level ~= "" then + local color = GetQuestDifficultyColor(level) + return string.format("|cff%02x%02x%02x%d|r", color.r * 255, color.g * 255, color.b * 255, level) + end +end + +local CLASS_COLORS, color = {} +local classes_female, classes_male = {}, {} + +FillLocalizedClassList(classes_female, true) +FillLocalizedClassList(classes_male, false) + +for token, localizedName in pairs(classes_female) do + color = RAID_CLASS_COLORS[token] + CLASS_COLORS[localizedName] = string.format("%02x%02x%02x", color.r * 255, color.g * 255, color.b * 255) +end + +for token, localizedName in pairs(classes_male) do + color = RAID_CLASS_COLORS[token] + CLASS_COLORS[localizedName] = string.format("%02x%02x%02x", color.r * 255, color.g * 255, color.b * 255) +end + +local function valueColor(totals) + if totals ~= "" then + local color = E.db.general.valuecolor + return string.format("|cff%02x%02x%02x%d|r", color.r * 255, color.g * 255, color.b * 255, totals) + end +end + +function DT:update_Guild() + if IsInGuild() then + GuildRoster() + local guildTotal, online = GetNumGuildMembers() + + if E.db.sle.dt.guild.totals then + LDB.text = --[["|cff82c5ff"]]"|cffffffffGuild: |r"..valueColor(online).."/"..valueColor(guildTotal)--[["|r"]] + else + LDB.text = "|cffffffffGuild: |r"..valueColor(online) + end + else + LDB.text = "|cffffffffNo Guild|r" + end +end + +local function Entry_OnMouseUp(frame, info, button) + local i_type, toon_name, full_name, presence_id = string.split(":", info) + + if button == "LeftButton" then + if IsAltKeyDown() then + InviteUnit(toon_name) + return + end + + if IsShiftKeyDown() then + SetItemRef("player:"..toon_name, "|Hplayer:"..toon_name.."|h["..toon_name.."|h", "LeftButton") + return + end + + if IsControlKeyDown() then + if i_type == "guild" and CanEditPublicNote() then + SetGuildRosterSelection(guild_name_to_index(toon_name)) + StaticPopup_Show("SET_GUILDPLAYERNOTE") + return + end + end + + SetItemRef( "player:"..full_name, ("|Hplayer:%1$s|h[%1$s]|h"):format(full_name), "LeftButton" ) + elseif button == "RightButton" then + if IsControlKeyDown() then + if i_type == "guild" and CanEditOfficerNote() then + SetGuildRosterSelection(guild_name_to_index(toon_name)) + StaticPopup_Show("SET_GUILDOFFICERNOTE") + end + end + --elseif button == "MiddleButton" then + -- Expand RealID Broadcast + -- E.db.sle.socialstate.expand_realID = not E.db.sle.socialstate.expand_realID + -- LDB.OnEnter(LDB_ANCHOR) + end +end + +local function HideOnMouseUp(cell, section) + E.db.sle.dt.guild[section] = not E.db.sle.dt.guild[section] + LDB.OnEnter(LDB_ANCHOR) +end + +local function SetGuildSort(cell, sortsection) + if E.db.sle.dt.guild["sortGuild"] == sortsection then + E.db.sle.dt.guild["sortGuild"] = "rev" .. sortsection + else + E.db.sle.dt.guild["sortGuild"] = sortsection + end + LDB.OnEnter(LDB_ANCHOR) +end + +function LDB:OnClick(button) + if button == "LeftButton" then + ToggleGuildFrame(1) + end + + if button == "RightButton" then + ElvConfigToggle:Click(); + ACD:SelectGroup("ElvUI", "sle", "sldatatext", "slguild") + end +end + +function LDB.OnLeave() end + +function LDB.OnEnter(self) + if E.db.sle.dt.guild.combat and InCombatLockdown() then return end + LDB_ANCHOR = self + + if LibQTip:IsAcquired("ShadowLightGuild") then + tooltip:Clear() + else + tooltip = LibQTip:Acquire("ShadowLightGuild", 8, "RIGHT", "RIGHT", "LEFT", "LEFT", "CENTER", "CENTER", "RIGHT") + + tooltip:SetBackdropColor(0,0,0,1) + + tooltip:SetHeaderFont(ssHeaderFont) + tooltip:SetFont(ssRegFont) + + tooltip:SmartAnchorTo(self) + tooltip:SetAutoHideDelay(E.db.sle.dt.guild.tooltipAutohide, self) + tooltip:SetScript("OnShow", function(ttskinself) ttskinself:SetTemplate('Transparent') end) + end + + local line = tooltip:AddLine() + tooltip:SetCell(line, 1, "Shadow & Light Guild", ssTitleFont, "CENTER", 0) + tooltip:AddLine(" ") + + if IsInGuild() then + local guild_table = {} + if not E.db.sle.dt.guild.hide_gmotd then + line = tooltip:AddLine() + if not E.db.sle.dt.guild.minimize_gmotd then + tooltip:SetCell(line, 1, "|cffffffff" .. _G.CHAT_GUILD_MOTD_SEND .. "|r", "LEFT", 3) + else + tooltip:SetCell(line, 1, "|cffffffff".. MINIMIZE .. _G.CHAT_GUILD_MOTD_SEND .. "|r", "LEFT", 3) + end + tooltip:SetCellScript(line, 1, "OnMouseUp", HideOnMouseUp, "minimize_gmotd") + + if not E.db.sle.dt.guild.minimize_gmotd then + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "|cff00ff00"..GetGuildRosterMOTD().."|r", "LEFT", 0, nil, nil, nil, 100) + end + + tooltip:AddLine(" ") + end + + local ssGuildName + if not E.db.sle.dt.guild.hide_guildname then + ssGuildName = GetGuildInfo("player") + else + ssGuildName = _G.GUILD + end + + line = tooltip:AddLine() + if not E.db.sle.dt.guild.hideGuild then + tooltip:SetCell(line, 1, "|cffffffff" .. ssGuildName .."|r", "LEFT", 3) + else + line = tooltip:SetCell(line, 1, MINIMIZE .. "|cffffffff" .. ssGuildName .. "|r", "LEFT", 3) + end + tooltip:SetCellScript(line, 1, "OnMouseUp", HideOnMouseUp, "hideGuild") + + if not E.db.sle.dt.guild.hideGuild then + line = tooltip:AddHeader() + line = tooltip:SetCell(line, 1, " ") + tooltip:SetCellScript(line, 1, "OnMouseUp", SetGuildSort, "LEVEL") + line = tooltip:SetCell(line, 3, _G.NAME) + tooltip:SetCellScript(line, 3, "OnMouseUp", SetGuildSort, "TOONNAME") + line = tooltip:SetCell(line, 5, _G.ZONE) + tooltip:SetCellScript(line, 5, "OnMouseUp", SetGuildSort, "ZONENAME") + line = tooltip:SetCell(line, 6, _G.RANK) + tooltip:SetCellScript(line, 6, "OnMouseUp", SetGuildSort, "RANKINDEX") + + if not E.db.sle.dt.guild.hide_guild_onotes then + line = tooltip:SetCell(line, 7, _G.NOTE_COLON) + else + line = tooltip:SetCell(line, 7, MINIMIZE .. _G.NOTE_COLON) + end + tooltip:SetCellScript(line, 7, "OnMouseUp", HideOnMouseUp, "hide_guild_onotes") + + tooltip:AddSeparator() + + for i = 1, GetNumGuildMembers() do + local toonName, rank, rankindex, level, class, zoneName, note, onote, connected, status, classFileName, achievementPoints, achievementRank, isMobile = GetGuildRosterInfo(i) + + if connected then + if note and note ~= '' then note="|cff00ff00["..note.."]|r" end + if onote and onote ~= '' then onote = "|cff00ffff["..onote.."]|r" end + + if status == 1 then + status = AWAY_ICON + elseif status == 2 then + status = BUSY_ICON + elseif status == 0 then + status = '' + end + + if isMobile then + status = MOBILE_ICON + zoneName = "Remote Chat" + end + + table.insert(guild_table, { + TOONNAME = toonName, + RANK = rank, + RANKINDEX = rankindex, + LEVEL = level, + CLASS = class, + ZONENAME = zoneName, + NOTE = note, + ONOTE = onote, + STATUS = status + }) + end + end + + table.sort(guild_table, list_sort[E.db.sle.dt.guild["sortGuild"]]) + + for _, player in ipairs(guild_table) do + line = tooltip:AddLine() + line = tooltip:SetCell(line, 1, ColoredLevel(player["LEVEL"])) + line = tooltip:SetCell(line, 2, player["STATUS"]) + line = tooltip:SetCell(line, 3, + string.format("|cff%s%s", CLASS_COLORS[player["CLASS"]] or "ffffff", player["TOONNAME"] .. "|r") .. (inGroup(player["TOONNAME"]) and GROUP_CHECKMARK or "")) + line = tooltip:SetCell(line, 5, player["ZONENAME"] or "???") + line = tooltip:SetCell(line, 6, player["RANK"]) + if not E.db.sle.dt.guild.hide_guild_onotes then + line = tooltip:SetCell(line, 7, player["NOTE"] .. player["ONOTE"]) + end + + tooltip:SetLineScript(line, "OnMouseUp", Entry_OnMouseUp, string.format("guild:%s:%s", player["TOONNAME"], player["TOONNAME"])) + end + end + tooltip:AddLine(" ") + end + + if not E.db.sle.dt.guild.hide_hintline then + line = tooltip:AddLine() + if not E.db.sle.dt.guild.minimize_hintline then + tooltip:SetCell(line, 1, "Hint:", "LEFT", 3) + else + tooltip:SetCell(line, 1, MINIMIZE .. "Hint:", "LEFT", 3) + end + tooltip:SetCellScript(line, 1, "OnMouseUp", HideOnMouseUp, "minimize_hintline") + + if not E.db.sle.dt.guild.minimize_hintline then + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "|cffeda55fClick|r to open the guild panel. |cffeda55fClick|r a Header to hide it or sort it.", "LEFT", 0) + + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "|cffeda55fClick|r a line to whisper a player. |cffeda55fShift-Click|r a line to lookup a player.", "LEFT", 0) + + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "|cffeda55fCtrl-Click|r a line to edit a note. |cffeda55fCtrl-RightClick|r a line to edit an officer note.", "LEFT", 0) + + line = tooltip:AddLine() + tooltip:SetCell(line, 1, "|cffeda55fAlt-Click|r a line to invite.", "LEFT", 0) + + end + end + + tooltip:UpdateScrolling() + tooltip:Show() +end + +frame:SetScript("OnEvent", function(self, event, ...) + if self[event] then + return self[event](self, event, ...) + end +end) + +local DELAY = 15 -- Update every 15 seconds +local elapsed = DELAY - 5 + +frame:SetScript("OnUpdate", function (self, elapse) + elapsed = elapsed + elapse + + if elapsed >= DELAY then + elapsed = 0 + DT:update_Guild() + end +end) + +frame:RegisterEvent("PLAYER_LOGIN") \ No newline at end of file diff --git a/ElvUI_SLE/modules/datatexts/load_datatexts.xml b/ElvUI_SLE/modules/datatexts/load_datatexts.xml index 2c0a83a..ed7e9bd 100755 --- a/ElvUI_SLE/modules/datatexts/load_datatexts.xml +++ b/ElvUI_SLE/modules/datatexts/load_datatexts.xml @@ -5,6 +5,8 @@ <Script file='spirit.lua'/> <Script file='time.lua'/> <Script file='add_panels.lua'/> + <Script file='friends.lua'/> + <Script file='guild.lua'/> <Include file='dashboard\load_dashboard.xml'/> <Script file='options.lua'/> </Ui> \ No newline at end of file diff --git a/ElvUI_SLE/modules/datatexts/options.lua b/ElvUI_SLE/modules/datatexts/options.lua index c795426..e8150ad 100755 --- a/ElvUI_SLE/modules/datatexts/options.lua +++ b/ElvUI_SLE/modules/datatexts/options.lua @@ -24,8 +24,9 @@ local chatT = { --Datatext panels E.Options.args.sle.args.datatext = { type = "group", - name = L["Datatext Panels"], - order = 6, + name = L["Panels & Dashboard"], + order = 1, + childGroups = "select", args = { header = { order = 1, @@ -67,18 +68,11 @@ E.Options.args.sle.args.datatext = { get = function(info) return E.db.sle.datatext.dashboard.width end, set = function(info, value) E.db.sle.datatext.dashboard.width = value; DTP:DashWidth() end, }, - panels = { - order = 7, - type = "group", - name = L["Panels"], - childGroups = "select", - args = { }, - }, }, } for k,v in pairs(drop) do -E.Options.args.sle.args.datatext.args.panels.args[v[1]] = { +E.Options.args.sle.args.datatext.args[v[1]] = { order = v[2], type = "group", name = L[k], @@ -122,7 +116,7 @@ E.Options.args.sle.args.datatext.args.panels.args[v[1]] = { end for k,v in pairs(chatT) do -E.Options.args.sle.args.datatext.args.panels.args[v[1]] = { +E.Options.args.sle.args.datatext.args[v[1]] = { order = v[2], type = "group", name = L[k], @@ -159,57 +153,193 @@ E.Options.args.sle.args.datatext.args.panels.args[v[1]] = { } end ---Time datatext -E.Options.args.sle.args.datatext.args.timedt = { +E.Options.args.sle.args.sldatatext = { type = "group", - name = RAID_FINDER, - order = 6, + name = L["S&L Datatexts"], + order = 2, + childGroups = "select", args = { - lfrshow = { + header = { order = 1, - type = "toggle", - name = L["LFR Lockout"], - desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], - get = function(info) return E.db.sle.lfrshow.enabled end, - set = function(info, value) E.db.sle.lfrshow.enabled = value; end + type = "header", + name = L["Datatext Options"], }, - instances = { + intro = { order = 2, + type = "description", + --name = L["DP_DESC"] + name = L["Some datatexts that Shadow & Light are supplied with have settings that can be modified to alter the displayed information. Please use the dropdown box to select which datatext you would like to configure."] + }, + spacer = { + order = 3, + type = 'description', + name = "", + }, + --['combat'] = false, + --['hideFriends'] = false, + --['sortBN'] = 'TOONNAME', + --['tooltipAutohide'] = '0.25', + --['totals'] = false, + slfriends = { type = "group", - name = L["Loot History"], - guiInline = true, - get = function(info) return E.db.sle.lfrshow[ info[#info] ] end, - set = function(info, value) E.db.sle.lfrshow[ info[#info] ] = value; end, + name = L["S&L Friends"], + order = 1, args = { - ds = { + header = { order = 1, - type = "toggle", - name = GetMapNameByID(824), - desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + type = "description", + name = "These options are for modifing the Shadow & Light Friends datatext.", + }, + hidetotals = { + order = 2, + type = "toggle",--[[ width = "half",]] + name = "Show Totals", + desc = "Show total friends in the datatext.", + get = function(info) return E.db.sle.dt.friends.totals end, + set = function(info, value) E.db.sle.dt.friends.totals = value; DT:update_Friends() end, + }, + hidehintline = { + order = 3, + type = "toggle",--[[ width = "half",]] + name = "Hide Hints", + desc = "Display the hints in the tooltip.", + get = function(info) return E.db.sle.dt.friends.hide_hintline end, + set = function(info, value) E.db.sle.dt.friends.hide_hintline = value; end, + }, + bnbroadcast = { + order = 4, + type = "toggle",--[[ width = "half",]] + name = "Expand RealID", + desc = "Display realid with two lines to view broadcasts.", + get = function(info) return E.db.sle.dt.friends.expandBNBroadcast end, + set = function(info, value) E.db.sle.dt.friends.expandBNBroadcast = value; end, + }, + spacer = { + order = 5, + type = 'description', + name = "", }, - mv = { + tooltipautohide = { + order = 6, + type = "range", + name = "Autohide Delay:", + desc = "Adjust the tooltip autohide delay when mouse is no longer hovering of the datatext.", + min = 0.1, max = 1, step = 0.1, + get = function(info) return E.db.sle.dt.friends.tooltipAutohide end, + set = function(info, value) E.db.sle.dt.friends.tooltipAutohide = value; end, + }, + }, + }, + slguild = { + type = "group", + name = L["S&L Guild"], + order = 2, + args = { + header = { + order = 1, + type = "description", + name = "These options are for modifing the Shadow & Light Guild datatext.", + }, + hidetotals = { order = 2, type = "toggle", - name = GetMapNameByID(896), - desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + name = "Show Totals", + desc = "Show total friends in the datatext.", + get = function(info) return E.db.sle.dt.guild.totals end, + set = function(info, value) E.db.sle.dt.guild.totals = value; DT:update_Guild() end, }, - hof = { + hidehintline = { order = 3, type = "toggle", - name = GetMapNameByID(897), - desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + name = "Hide Hints", + desc = "Display the hints in the tooltip.", + get = function(info) return E.db.sle.dt.guild.hide_hintline end, + set = function(info, value) E.db.sle.dt.guild.hide_hintline = value; end, }, - toes = { + hidemotd = { order = 4, type = "toggle", - name = GetMapNameByID(886), - desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + name = "Hide MOTD", + desc = "Hide the guild's Message of the Day in the tooltip.", + get = function(info) return E.db.sle.dt.guild.hide_gmotd end, + set = function(info, value) E.db.sle.dt.guild.hide_gmotd = value; end, + }, + hideguildname = { + order = 4, + type = "toggle", + name = "Hide Guild Name", + desc = "Hide the guild's name in the tooltip.", + get = function(info) return E.db.sle.dt.guild.hide_guildname end, + set = function(info, value) E.db.sle.dt.guild.hide_guildname = value; end, }, - tot = { + spacer = { order = 5, + type = 'description', + name = "", + }, + tooltipautohide = { + order = 6, + type = "range", + name = "Autohide Delay:", + desc = "Adjust the tooltip autohide delay when mouse is no longer hovering of the datatext.", + min = 0.1, max = 1, step = 0.1, + get = function(info) return E.db.sle.dt.guild.tooltipAutohide end, + set = function(info, value) E.db.sle.dt.guild.tooltipAutohide = value; end, + }, + }, + }, + timedt = { + type = "group", + name = RAID_FINDER, + order = 6, + args = { + lfrshow = { + order = 1, type = "toggle", - name = GetMapNameByID(930), + name = L["LFR Lockout"], desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + get = function(info) return E.db.sle.lfrshow.enabled end, + set = function(info, value) E.db.sle.lfrshow.enabled = value; end + }, + instances = { + order = 2, + type = "group", + name = L["Loot History"], + guiInline = true, + get = function(info) return E.db.sle.lfrshow[ info[#info] ] end, + set = function(info, value) E.db.sle.lfrshow[ info[#info] ] = value; end, + args = { + ds = { + order = 1, + type = "toggle", + name = GetMapNameByID(824), + desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + }, + mv = { + order = 2, + type = "toggle", + name = GetMapNameByID(896), + desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + }, + hof = { + order = 3, + type = "toggle", + name = GetMapNameByID(897), + desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + }, + toes = { + order = 4, + type = "toggle", + name = GetMapNameByID(886), + desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + }, + tot = { + order = 5, + type = "toggle", + name = GetMapNameByID(930), + desc = L["Show/Hide LFR lockdown info in time datatext's tooltip."], + }, + }, }, }, }, diff --git a/ElvUI_SLE/modules/equipmanager/options.lua b/ElvUI_SLE/modules/equipmanager/options.lua index 07b3db6..653815e 100755 --- a/ElvUI_SLE/modules/equipmanager/options.lua +++ b/ElvUI_SLE/modules/equipmanager/options.lua @@ -5,7 +5,7 @@ local function configTable() E.Options.args.sle.args.equipmanager = { type = 'group', - order = 2, + order = 13, name = L['Equipment Manager'], args = { intro = { diff --git a/ElvUI_SLE/modules/farm/options.lua b/ElvUI_SLE/modules/farm/options.lua index f2e6fc2..56dbc57 100755 --- a/ElvUI_SLE/modules/farm/options.lua +++ b/ElvUI_SLE/modules/farm/options.lua @@ -4,7 +4,7 @@ local function configTable() E.Options.args.sle.args.farm = { type = 'group', - order = 7, + order = 14, name = L['Farm'], args = { intro = { diff --git a/ElvUI_SLE/modules/imports/options.lua b/ElvUI_SLE/modules/imports/options.lua index 1784946..3345ce4 100755 --- a/ElvUI_SLE/modules/imports/options.lua +++ b/ElvUI_SLE/modules/imports/options.lua @@ -484,7 +484,7 @@ local function configTable() E.Options.args.sle.args.importing = { type = 'group', name = L['Import Options'], - order = 199, + order = 300, args = { header = { order = 1, diff --git a/ElvUI_SLE/modules/loot/options.lua b/ElvUI_SLE/modules/loot/options.lua index 0a9994d..75d9a09 100755 --- a/ElvUI_SLE/modules/loot/options.lua +++ b/ElvUI_SLE/modules/loot/options.lua @@ -4,7 +4,7 @@ local function configTable() --Main options group E.Options.args.sle.args.loot = { - order = 5, + order = 80, type = "group", name = L['Loot Announcer'], args = { diff --git a/ElvUI_SLE/modules/marks/options.lua b/ElvUI_SLE/modules/marks/options.lua index 898ef20..b067e60 100755 --- a/ElvUI_SLE/modules/marks/options.lua +++ b/ElvUI_SLE/modules/marks/options.lua @@ -4,7 +4,7 @@ local function configTable() --Main options group E.Options.args.sle.args.marks = { - order = 5, + order = 90, type = "group", name = L["Raid Marks"], args = { diff --git a/ElvUI_SLE/modules/minimap/options.lua b/ElvUI_SLE/modules/minimap/options.lua index f583297..caea59a 100755 --- a/ElvUI_SLE/modules/minimap/options.lua +++ b/ElvUI_SLE/modules/minimap/options.lua @@ -4,7 +4,7 @@ local function configTable() E.Options.args.sle.args.minimap = { type = "group", name = MINIMAP_LABEL, - order = 2, + order = 81, args = { header = { order = 1, diff --git a/ElvUI_SLE/modules/options.lua b/ElvUI_SLE/modules/options.lua index 54c3ce7..573eb5e 100755 --- a/ElvUI_SLE/modules/options.lua +++ b/ElvUI_SLE/modules/options.lua @@ -73,7 +73,7 @@ E.Options.args.sle = { --Credits E.Options.args.sle.args.credits = { - order = 200, + order = 400, type = 'group', name = L["Credits"], args = { diff --git a/ElvUI_SLE/modules/uibuttons/options.lua b/ElvUI_SLE/modules/uibuttons/options.lua index e1a31fa..675d84a 100755 --- a/ElvUI_SLE/modules/uibuttons/options.lua +++ b/ElvUI_SLE/modules/uibuttons/options.lua @@ -6,7 +6,7 @@ local function configTable() E.Options.args.sle.args.uibuttons = { type = "group", name = L["UI Buttons"], - order = 3, + order = 99, args = { header = { order = 1, diff --git a/ElvUI_SLE/modules/unitframes/options.lua b/ElvUI_SLE/modules/unitframes/options.lua index 01d0c08..a65dbea 100755 --- a/ElvUI_SLE/modules/unitframes/options.lua +++ b/ElvUI_SLE/modules/unitframes/options.lua @@ -19,7 +19,7 @@ local positionValues = { E.Options.args.sle.args.unitframes = { type = "group", name = L["UnitFrames"], - order = 1, + order = 100, args = { header = { order = 1,