flickerstreak@1: --[[ flickerstreak@1: Name: Dewdrop-2.0 flickerstreak@1: Revision: $Rev: 19976 $ flickerstreak@1: Author(s): ckknight (ckknight@gmail.com) flickerstreak@1: Website: http://ckknight.wowinterface.com/ flickerstreak@1: Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0 flickerstreak@1: SVN: http://svn.wowace.com/root/trunk/DewdropLib/Dewdrop-2.0 flickerstreak@1: Description: A library to provide a clean dropdown menu interface. flickerstreak@1: Dependencies: AceLibrary flickerstreak@1: ]] flickerstreak@1: flickerstreak@1: local MAJOR_VERSION = "Dewdrop-2.0" flickerstreak@1: local MINOR_VERSION = "$Revision: 19976 $" flickerstreak@1: flickerstreak@1: if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end flickerstreak@1: if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end flickerstreak@1: flickerstreak@1: local Dewdrop = {} flickerstreak@1: flickerstreak@1: local CLOSE = "Close" flickerstreak@1: local CLOSE_DESC = "Close the menu." flickerstreak@1: local VALIDATION_ERROR = "Validation error." flickerstreak@1: local RESET_KEYBINDING_DESC = "Hit escape to clear the keybinding." flickerstreak@1: flickerstreak@1: if GetLocale() == "deDE" then flickerstreak@1: -- VALIDATION_ERROR = "some message here..." flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function new(...) flickerstreak@1: local t = {} flickerstreak@1: for i = 1, select('#', ...), 2 do flickerstreak@1: local k = select(i, ...) flickerstreak@1: if k then flickerstreak@1: t[k] = select(i+1, ...) flickerstreak@1: else flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return t flickerstreak@1: end flickerstreak@1: flickerstreak@1: local tmp flickerstreak@1: do flickerstreak@1: local t = {} flickerstreak@1: function tmp(...) flickerstreak@1: for k in pairs(t) do flickerstreak@1: t[k] = nil flickerstreak@1: end flickerstreak@1: for i = 1, select('#', ...), 2 do flickerstreak@1: local k = select(i, ...) flickerstreak@1: if k then flickerstreak@1: t[k] = select(i+1, ...) flickerstreak@1: else flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return t flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local tmp2 flickerstreak@1: do flickerstreak@1: local t = {} flickerstreak@1: function tmp2(...) flickerstreak@1: for k in pairs(t) do flickerstreak@1: t[k] = nil flickerstreak@1: end flickerstreak@1: for i = 1, select('#', ...), 2 do flickerstreak@1: local k = select(i, ...) flickerstreak@1: if k then flickerstreak@1: t[k] = select(i+1, ...) flickerstreak@1: else flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return t flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local levels flickerstreak@1: local buttons flickerstreak@1: flickerstreak@1: local function GetScaledCursorPosition() flickerstreak@1: local x, y = GetCursorPosition() flickerstreak@1: local scale = UIParent:GetEffectiveScale() flickerstreak@1: return x / scale, y / scale flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function StartCounting(self, levelNum) flickerstreak@1: for i = levelNum, #levels do flickerstreak@1: if levels[i] then flickerstreak@1: levels[i].count = 3 flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function StopCounting(self, level) flickerstreak@1: for i = level, 1, -1 do flickerstreak@1: if levels[i] then flickerstreak@1: levels[i].count = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function OnUpdate(self, arg1) flickerstreak@1: for _,level in ipairs(levels) do flickerstreak@1: if level.count then flickerstreak@1: level.count = level.count - arg1 flickerstreak@1: if level.count < 0 then flickerstreak@1: level.count = nil flickerstreak@1: self:Close(level.num) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function CheckDualMonitor(self, frame) flickerstreak@1: local ratio = GetScreenWidth() / GetScreenHeight() flickerstreak@1: if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then flickerstreak@1: local offsetx flickerstreak@1: if GetCursorPosition() / GetScreenHeight() * 768 < GetScreenWidth() / 2 then flickerstreak@1: offsetx = GetScreenWidth() / 2 - frame:GetRight() flickerstreak@1: else flickerstreak@1: offsetx = GetScreenWidth() / 2 - frame:GetLeft() flickerstreak@1: end flickerstreak@1: local point, parent, relativePoint, x, y = frame:GetPoint(1) flickerstreak@1: frame:SetPoint(point, parent, relativePoint, (x or 0) + offsetx, y or 0) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function CheckSize(self, level) flickerstreak@1: if not level.buttons then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: local height = 20 flickerstreak@1: for _, button in ipairs(level.buttons) do flickerstreak@1: height = height + button:GetHeight() flickerstreak@1: end flickerstreak@1: level:SetHeight(height) flickerstreak@1: local width = 160 flickerstreak@1: for _, button in ipairs(level.buttons) do flickerstreak@1: local extra = 1 flickerstreak@1: if button.hasArrow or button.hasColorSwatch then flickerstreak@1: extra = extra + 16 flickerstreak@1: end flickerstreak@1: if not button.notCheckable then flickerstreak@1: extra = extra + 24 flickerstreak@1: end flickerstreak@1: button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight) flickerstreak@1: if button.text:GetWidth() + extra > width then flickerstreak@1: width = button.text:GetWidth() + extra flickerstreak@1: end flickerstreak@1: end flickerstreak@1: level:SetWidth(width + 20) flickerstreak@1: if level:GetLeft() and level:GetRight() and level:GetTop() and level:GetBottom() and (level:GetLeft() < 0 or level:GetRight() > GetScreenWidth() or level:GetTop() > GetScreenHeight() or level:GetBottom() < 0) then flickerstreak@1: level:ClearAllPoints() flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: level:SetPoint("TOPLEFT", level.parent or level:GetParent(), "TOPRIGHT", 5, 10) flickerstreak@1: else flickerstreak@1: level:SetPoint("BOTTOMLEFT", level.parent or level:GetParent(), "BOTTOMRIGHT", 5, -10) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: level:SetPoint("TOPRIGHT", level.parent or level:GetParent(), "TOPLEFT", -5, 10) flickerstreak@1: else flickerstreak@1: level:SetPoint("BOTTOMRIGHT", level.parent or level:GetParent(), "BOTTOMLEFT", -5, -10) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local dirty = false flickerstreak@1: if not level:GetRight() then flickerstreak@1: self:Close() flickerstreak@1: return flickerstreak@1: end flickerstreak@1: if level:GetRight() > GetScreenWidth() and level.lastDirection == "RIGHT" then flickerstreak@1: level.lastDirection = "LEFT" flickerstreak@1: dirty = true flickerstreak@1: elseif level:GetLeft() < 0 and level.lastDirection == "LEFT" then flickerstreak@1: level.lastDirection = "RIGHT" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: if level:GetTop() > GetScreenHeight() and level.lastVDirection == "UP" then flickerstreak@1: level.lastVDirection = "DOWN" flickerstreak@1: dirty = true flickerstreak@1: elseif level:GetBottom() < 0 and level.lastVDirection == "DOWN" then flickerstreak@1: level.lastVDirection = "UP" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: if dirty then flickerstreak@1: level:ClearAllPoints() flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: level:SetPoint("TOPLEFT", level.parent or level:GetParent(), "TOPRIGHT", 5, 10) flickerstreak@1: else flickerstreak@1: level:SetPoint("BOTTOMLEFT", level.parent or level:GetParent(), "BOTTOMRIGHT", 5, -10) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: level:SetPoint("TOPRIGHT", level.parent or level:GetParent(), "TOPLEFT", -5, 10) flickerstreak@1: else flickerstreak@1: level:SetPoint("BOTTOMRIGHT", level.parent or level:GetParent(), "BOTTOMLEFT", -5, -10) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if level:GetTop() > GetScreenHeight() then flickerstreak@1: local top = level:GetTop() flickerstreak@1: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@1: level:ClearAllPoints() flickerstreak@1: level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) + GetScreenHeight() - top) flickerstreak@1: elseif level:GetBottom() < 0 then flickerstreak@1: local bottom = level:GetBottom() flickerstreak@1: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@1: level:ClearAllPoints() flickerstreak@1: level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) - bottom) flickerstreak@1: end flickerstreak@1: CheckDualMonitor(self, level) flickerstreak@1: if mod(level.num, 5) == 0 then flickerstreak@1: local left, bottom = level:GetLeft(), level:GetBottom() flickerstreak@1: level:ClearAllPoints() flickerstreak@1: level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local Open flickerstreak@1: local OpenSlider flickerstreak@1: local OpenEditBox flickerstreak@1: local Refresh flickerstreak@1: local Clear flickerstreak@1: local function ReleaseButton(self, level, index) flickerstreak@1: if not level.buttons then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: if not level.buttons[index] then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: local button = level.buttons[index] flickerstreak@1: button:Hide() flickerstreak@1: if button.highlight then flickerstreak@1: button.highlight:Hide() flickerstreak@1: end flickerstreak@1: -- button.arrow:SetVertexColor(1, 1, 1) flickerstreak@1: -- button.arrow:SetHeight(16) flickerstreak@1: -- button.arrow:SetWidth(16) flickerstreak@1: table.remove(level.buttons, index) flickerstreak@1: table.insert(buttons, button) flickerstreak@1: for k in pairs(button) do flickerstreak@1: if k ~= 0 and k ~= "text" and k ~= "check" and k ~= "arrow" and k ~= "colorSwatch" and k ~= "highlight" and k ~= "radioHighlight" then flickerstreak@1: button[k] = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return true flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function Scroll(self, level, down) flickerstreak@1: if down then flickerstreak@1: if level:GetBottom() < 0 then flickerstreak@1: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@1: level:SetPoint(point, parent, relativePoint, x, y + 50) flickerstreak@1: if level:GetBottom() > 0 then flickerstreak@1: level:SetPoint(point, parent, relativePoint, x, y + 50 - level:GetBottom()) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level:GetTop() > GetScreenHeight() then flickerstreak@1: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@1: level:SetPoint(point, parent, relativePoint, x, y - 50) flickerstreak@1: if level:GetTop() < GetScreenHeight() then flickerstreak@1: level:SetPoint(point, parent, relativePoint, x, y - 50 + GetScreenHeight() - level:GetTop()) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local sliderFrame flickerstreak@1: local editBoxFrame flickerstreak@1: flickerstreak@1: local function showGameTooltip(this) flickerstreak@1: if this.tooltipTitle or this.tooltipText then flickerstreak@1: GameTooltip_SetDefaultAnchor(GameTooltip, this) flickerstreak@1: local disabled = not this.isTitle and this.disabled flickerstreak@1: if this.tooltipTitle then flickerstreak@1: if disabled then flickerstreak@1: GameTooltip:SetText(this.tooltipTitle, 0.5, 0.5, 0.5, 1) flickerstreak@1: else flickerstreak@1: GameTooltip:SetText(this.tooltipTitle, 1, 1, 1, 1) flickerstreak@1: end flickerstreak@1: if this.tooltipText then flickerstreak@1: if disabled then flickerstreak@1: GameTooltip:AddLine(this.tooltipText, (NORMAL_FONT_COLOR.r + 0.5) / 2, (NORMAL_FONT_COLOR.g + 0.5) / 2, (NORMAL_FONT_COLOR.b + 0.5) / 2, 1) flickerstreak@1: else flickerstreak@1: GameTooltip:AddLine(this.tooltipText, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if disabled then flickerstreak@1: GameTooltip:SetText(this.tooltipText, 0.5, 0.5, 0.5, 1) flickerstreak@1: else flickerstreak@1: GameTooltip:SetText(this.tooltipText, 1, 1, 1, 1) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: GameTooltip:Show() flickerstreak@1: end flickerstreak@1: if this.tooltipFunc then flickerstreak@1: GameTooltip:SetOwner(this, "ANCHOR_NONE") flickerstreak@1: GameTooltip:SetPoint("TOPLEFT", this, "TOPRIGHT", 5, 0) flickerstreak@1: this.tooltipFunc(this.tooltipArg1, this.tooltipArg2, this.tooltipArg3, this.tooltipArg4) flickerstreak@1: GameTooltip:Show() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local numButtons = 0 flickerstreak@1: local function AcquireButton(self, level) flickerstreak@1: if not levels[level] then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: level = levels[level] flickerstreak@1: if not level.buttons then flickerstreak@1: level.buttons = {} flickerstreak@1: end flickerstreak@1: local button flickerstreak@1: if #buttons == 0 then flickerstreak@1: numButtons = numButtons + 1 flickerstreak@1: button = CreateFrame("Button", "Dewdrop20Button" .. numButtons, nil) flickerstreak@1: button:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@1: button:SetHeight(16) flickerstreak@1: local highlight = button:CreateTexture(nil, "BACKGROUND") flickerstreak@1: highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") flickerstreak@1: button.highlight = highlight flickerstreak@1: highlight:SetBlendMode("ADD") flickerstreak@1: highlight:SetAllPoints(button) flickerstreak@1: highlight:Hide() flickerstreak@1: local check = button:CreateTexture(nil, "ARTWORK") flickerstreak@1: button.check = check flickerstreak@1: check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") flickerstreak@1: check:SetPoint("CENTER", button, "LEFT", 12, 0) flickerstreak@1: check:SetWidth(24) flickerstreak@1: check:SetHeight(24) flickerstreak@1: local radioHighlight = button:CreateTexture(nil, "ARTWORK") flickerstreak@1: button.radioHighlight = radioHighlight flickerstreak@1: radioHighlight:SetTexture("Interface\\Buttons\\UI-RadioButton") flickerstreak@1: radioHighlight:SetAllPoints(check) flickerstreak@1: radioHighlight:SetBlendMode("ADD") flickerstreak@1: radioHighlight:SetTexCoord(0.5, 0.75, 0, 1) flickerstreak@1: radioHighlight:Hide() flickerstreak@1: button:SetScript("OnEnter", function() flickerstreak@1: if (sliderFrame and sliderFrame:IsShown() and sliderFrame.mouseDown and sliderFrame.level == this.level.num + 1) or (editBoxFrame and editBoxFrame:IsShown() and editBoxFrame.mouseDown and editBoxFrame.level == this.level.num + 1) then flickerstreak@1: for i = 1, this.level.num do flickerstreak@1: Refresh(self, levels[i]) flickerstreak@1: end flickerstreak@1: return flickerstreak@1: end flickerstreak@1: self:Close(this.level.num + 1) flickerstreak@1: if not this.disabled then flickerstreak@1: if this.hasSlider then flickerstreak@1: OpenSlider(self, this) flickerstreak@1: elseif this.hasEditBox then flickerstreak@1: OpenEditBox(self, this) flickerstreak@1: elseif this.hasArrow then flickerstreak@1: Open(self, this, nil, this.level.num + 1, this.value) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not this.level then -- button reclaimed flickerstreak@1: return flickerstreak@1: end flickerstreak@1: StopCounting(self, this.level.num + 1) flickerstreak@1: if not this.disabled then flickerstreak@1: highlight:Show() flickerstreak@1: if this.isRadio then flickerstreak@1: button.radioHighlight:Show() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: showGameTooltip(this) flickerstreak@1: end) flickerstreak@1: button:SetScript("OnLeave", function() flickerstreak@1: if not this.selected then flickerstreak@1: highlight:Hide() flickerstreak@1: end flickerstreak@1: button.radioHighlight:Hide() flickerstreak@1: if this.level then flickerstreak@1: StartCounting(self, this.level.num) flickerstreak@1: end flickerstreak@1: GameTooltip:Hide() flickerstreak@1: end) flickerstreak@1: button:SetScript("OnClick", function() flickerstreak@1: if not this.disabled then flickerstreak@1: if this.hasColorSwatch then flickerstreak@1: local func = button.colorFunc flickerstreak@1: local a1,a2,a3,a4 = button.colorArg1, button.colorArg2, button.colorArg3, button.colorArg4 flickerstreak@1: local hasOpacity = this.hasOpacity flickerstreak@1: ColorPickerFrame.func = function() flickerstreak@1: if func then flickerstreak@1: local r,g,b = ColorPickerFrame:GetColorRGB() flickerstreak@1: local a = hasOpacity and 1 - OpacitySliderFrame:GetValue() or nil flickerstreak@1: if a1 == nil then flickerstreak@1: func(r, g, b, a) flickerstreak@1: elseif a2 == nil then flickerstreak@1: func(a1, r, g, b, a) flickerstreak@1: elseif a3 == nil then flickerstreak@1: func(a1, a2, r, g, b, a) flickerstreak@1: elseif a4 == nil then flickerstreak@1: func(a1, a2, a3, r, g, b, a) flickerstreak@1: else flickerstreak@1: func(a1, a2, a3, a4, r, g, b, a) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: ColorPickerFrame.hasOpacity = this.hasOpacity flickerstreak@1: ColorPickerFrame.opacityFunc = ColorPickerFrame.func flickerstreak@1: ColorPickerFrame.opacity = 1 - this.opacity flickerstreak@1: ColorPickerFrame:SetColorRGB(this.r, this.g, this.b) flickerstreak@1: local r, g, b, a = this.r, this.g, this.b, this.opacity flickerstreak@1: ColorPickerFrame.cancelFunc = function() flickerstreak@1: if a1 == nil then flickerstreak@1: func(r, g, b, a) flickerstreak@1: elseif a2 == nil then flickerstreak@1: func(a1, r, g, b, a) flickerstreak@1: elseif a3 == nil then flickerstreak@1: func(a1, a2, r, g, b, a) flickerstreak@1: else flickerstreak@1: func(a1, a2, a3, r, g, b, a) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self:Close(1) flickerstreak@1: ShowUIPanel(ColorPickerFrame) flickerstreak@1: elseif this.func then flickerstreak@1: local level = button.level flickerstreak@1: if type(this.func) == "string" then flickerstreak@1: self:assert(type(this.arg1[this.func]) == "function", "Cannot call method " .. this.func) flickerstreak@1: this.arg1[this.func](this.arg1, this.arg2, this.arg3, this.arg4) flickerstreak@1: else flickerstreak@1: this.func(this.arg1, this.arg2, this.arg3, this.arg4) flickerstreak@1: end flickerstreak@1: if this.closeWhenClicked then flickerstreak@1: self:Close() flickerstreak@1: elseif level:IsShown() then flickerstreak@1: for i = 1, level.num do flickerstreak@1: Refresh(self, levels[i]) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif this.closeWhenClicked then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: local text = button:CreateFontString(nil, "ARTWORK") flickerstreak@1: button.text = text flickerstreak@1: text:SetFontObject(GameFontHighlightSmall) flickerstreak@1: button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT) flickerstreak@1: button:SetScript("OnMouseDown", function() flickerstreak@1: if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then flickerstreak@1: text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1) flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: button:SetScript("OnMouseUp", function() flickerstreak@1: if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then flickerstreak@1: text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0) flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: local arrow = button:CreateTexture(nil, "ARTWORK") flickerstreak@1: button.arrow = arrow flickerstreak@1: arrow:SetPoint("LEFT", button, "RIGHT", -16, 0) flickerstreak@1: arrow:SetWidth(16) flickerstreak@1: arrow:SetHeight(16) flickerstreak@1: arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow") flickerstreak@1: local colorSwatch = button:CreateTexture(nil, "OVERLAY") flickerstreak@1: button.colorSwatch = colorSwatch flickerstreak@1: colorSwatch:SetWidth(20) flickerstreak@1: colorSwatch:SetHeight(20) flickerstreak@1: colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") flickerstreak@1: local texture = button:CreateTexture(nil, "OVERLAY") flickerstreak@1: colorSwatch.texture = texture flickerstreak@1: texture:SetTexture(1, 1, 1) flickerstreak@1: texture:SetWidth(11.5) flickerstreak@1: texture:SetHeight(11.5) flickerstreak@1: texture:Show() flickerstreak@1: texture:SetPoint("CENTER", colorSwatch, "CENTER") flickerstreak@1: colorSwatch:SetPoint("RIGHT", button, "RIGHT", 0, 0) flickerstreak@1: else flickerstreak@1: button = table.remove(buttons) flickerstreak@1: end flickerstreak@1: button:ClearAllPoints() flickerstreak@1: button:SetParent(level) flickerstreak@1: button:SetFrameStrata(level:GetFrameStrata()) flickerstreak@1: button:SetFrameLevel(level:GetFrameLevel() + 1) flickerstreak@1: button:SetPoint("LEFT", level, "LEFT", 10, 0) flickerstreak@1: button:SetPoint("RIGHT", level, "RIGHT", -10, 0) flickerstreak@1: if #level.buttons == 0 then flickerstreak@1: button:SetPoint("TOP", level, "TOP", 0, -10) flickerstreak@1: else flickerstreak@1: button:SetPoint("TOP", level.buttons[#level.buttons], "BOTTOM", 0, 0) flickerstreak@1: end flickerstreak@1: button.text:SetPoint("LEFT", button, "LEFT", 24, 0) flickerstreak@1: button:Show() flickerstreak@1: button.level = level flickerstreak@1: table.insert(level.buttons, button) flickerstreak@1: if not level.parented then flickerstreak@1: level.parented = true flickerstreak@1: level:ClearAllPoints() flickerstreak@1: if level.num == 1 then flickerstreak@1: if level.parent ~= UIParent then flickerstreak@1: level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT") flickerstreak@1: else flickerstreak@1: level:SetPoint("CENTER", level.parent, "CENTER") flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: level:SetPoint("TOPLEFT", level.parent, "TOPRIGHT", 5, 10) flickerstreak@1: else flickerstreak@1: level:SetPoint("BOTTOMLEFT", level.parent, "BOTTOMRIGHT", 5, -10) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT", -5, 10) flickerstreak@1: else flickerstreak@1: level:SetPoint("BOTTOMRIGHT", level.parent, "BOTTOMLEFT", -5, -10) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: level:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@1: end flickerstreak@1: button:SetAlpha(1) flickerstreak@1: return button flickerstreak@1: end flickerstreak@1: flickerstreak@1: local numLevels = 0 flickerstreak@1: local function AcquireLevel(self, level) flickerstreak@1: if not levels[level] then flickerstreak@1: for i = #levels + 1, level, -1 do flickerstreak@1: local i = i flickerstreak@1: numLevels = numLevels + 1 flickerstreak@1: local frame = CreateFrame("Button", "Dewdrop20Level" .. numLevels, nil) flickerstreak@1: if i == 1 then flickerstreak@1: local old_CloseSpecialWindows = CloseSpecialWindows flickerstreak@1: function CloseSpecialWindows() flickerstreak@1: local found = old_CloseSpecialWindows() flickerstreak@1: if levels[1]:IsShown() then flickerstreak@1: self:Close() flickerstreak@1: return 1 flickerstreak@1: end flickerstreak@1: return found flickerstreak@1: end flickerstreak@1: end flickerstreak@1: levels[i] = frame flickerstreak@1: frame.num = i flickerstreak@1: frame:SetParent(UIParent) flickerstreak@1: frame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@1: frame:Hide() flickerstreak@1: frame:SetWidth(180) flickerstreak@1: frame:SetHeight(10) flickerstreak@1: frame:SetFrameLevel(i * 3) flickerstreak@1: frame:SetScript("OnHide", function() flickerstreak@1: self:Close(level + 1) flickerstreak@1: end) flickerstreak@1: if frame.SetTopLevel then flickerstreak@1: frame:SetTopLevel(true) flickerstreak@1: end flickerstreak@1: frame:EnableMouse(true) flickerstreak@1: frame:EnableMouseWheel(true) flickerstreak@1: local backdrop = CreateFrame("Frame", nil, frame) flickerstreak@1: backdrop:SetAllPoints(frame) flickerstreak@1: backdrop:SetBackdrop(tmp( flickerstreak@1: 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background", flickerstreak@1: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@1: 'tile', true, flickerstreak@1: 'insets', tmp2( flickerstreak@1: 'left', 5, flickerstreak@1: 'right', 5, flickerstreak@1: 'top', 5, flickerstreak@1: 'bottom', 5 flickerstreak@1: ), flickerstreak@1: 'tileSize', 16, flickerstreak@1: 'edgeSize', 16 flickerstreak@1: )) flickerstreak@1: backdrop:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) flickerstreak@1: backdrop:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) flickerstreak@1: frame:SetScript("OnClick", function() flickerstreak@1: self:Close(i) flickerstreak@1: end) flickerstreak@1: frame:SetScript("OnEnter", function() flickerstreak@1: StopCounting(self, i) flickerstreak@1: end) flickerstreak@1: frame:SetScript("OnLeave", function() flickerstreak@1: StartCounting(self, i) flickerstreak@1: end) flickerstreak@1: frame:SetScript("OnMouseWheel", function() flickerstreak@1: Scroll(self, frame, arg1 < 0) flickerstreak@1: end) flickerstreak@1: if i == 1 then flickerstreak@1: frame:SetScript("OnUpdate", function() flickerstreak@1: OnUpdate(self, arg1) flickerstreak@1: end) flickerstreak@1: levels[1].lastDirection = "RIGHT" flickerstreak@1: levels[1].lastVDirection = "DOWN" flickerstreak@1: else flickerstreak@1: levels[i].lastDirection = levels[i - 1].lastDirection flickerstreak@1: levels[i].lastVDirection = levels[i - 1].lastVDirection flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local fullscreenFrame = GetFullScreenFrame() flickerstreak@1: local l = levels[level] flickerstreak@1: local strata, framelevel = l:GetFrameStrata(), l:GetFrameLevel() flickerstreak@1: if fullscreenFrame then flickerstreak@1: l:SetParent(fullscreenFrame) flickerstreak@1: else flickerstreak@1: l:SetParent(UIParent) flickerstreak@1: end flickerstreak@1: l:SetFrameStrata(strata) flickerstreak@1: l:SetFrameLevel(framelevel) flickerstreak@1: l:SetAlpha(1) flickerstreak@1: return l flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function checkValidate(validateFunc, func, arg1, arg2, arg3) flickerstreak@1: local text flickerstreak@1: if arg3 ~= nil then flickerstreak@1: text = arg3 flickerstreak@1: elseif arg2 ~= nil then flickerstreak@1: text = arg2 flickerstreak@1: else flickerstreak@1: text = arg1 flickerstreak@1: end flickerstreak@1: if not validateFunc(text) then flickerstreak@1: DEFAULT_CHAT_FRAME:AddMessage("|cffffff7fValidation error: [|r" .. tostring(text) .. "|cffffff7f]|r") flickerstreak@1: else flickerstreak@1: func(arg1, arg2, arg3) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function validateOptions(options, position, baseOptions, fromPass) flickerstreak@1: if not baseOptions then flickerstreak@1: baseOptions = options flickerstreak@1: end flickerstreak@1: if type(options) ~= "table" then flickerstreak@1: return "Options must be a table.", position flickerstreak@1: end flickerstreak@1: local kind = options.type flickerstreak@1: if type(kind) ~= "string" then flickerstreak@1: return '"type" must be a string.', position flickerstreak@1: elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "header" then flickerstreak@1: return '"type" must either be "range", "text", "group", "toggle", "execute", "color", or "header".', position flickerstreak@1: end flickerstreak@1: if options.aliases then flickerstreak@1: if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then flickerstreak@1: return '"alias" must be a table or string', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not fromPass then flickerstreak@1: if kind == "execute" then flickerstreak@1: if type(options.func) ~= "string" and type(options.func) ~= "function" then flickerstreak@1: return '"func" must be a string or function', position flickerstreak@1: end flickerstreak@1: elseif kind == "range" or kind == "text" or kind == "toggle" then flickerstreak@1: if type(options.set) ~= "string" and type(options.set) ~= "function" then flickerstreak@1: return '"set" must be a string or function', position flickerstreak@1: end flickerstreak@1: if kind == "text" and options.get == false then flickerstreak@1: elseif type(options.get) ~= "string" and type(options.get) ~= "function" then flickerstreak@1: return '"get" must be a string or function', position flickerstreak@1: end flickerstreak@1: elseif kind == "group" and options.pass then flickerstreak@1: if options.pass ~= true then flickerstreak@1: return '"pass" must be either nil, true, or false', position flickerstreak@1: end flickerstreak@1: if not options.func then flickerstreak@1: if type(options.set) ~= "string" and type(options.set) ~= "function" then flickerstreak@1: return '"set" must be a string or function', position flickerstreak@1: end flickerstreak@1: if type(options.get) ~= "string" and type(options.get) ~= "function" then flickerstreak@1: return '"get" must be a string or function', position flickerstreak@1: end flickerstreak@1: elseif type(options.func) ~= "string" and type(options.func) ~= "function" then flickerstreak@1: return '"func" must be a string or function', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if kind == "group" then flickerstreak@1: return 'cannot have "type" = "group" as a subgroup of a passing group', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options ~= baseOptions then flickerstreak@1: if kind == "header" then flickerstreak@1: elseif type(options.desc) ~= "string" then flickerstreak@1: return '"desc" must be a string', position flickerstreak@1: elseif options.desc:len() == 0 then flickerstreak@1: return '"desc" cannot be a 0-length string', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options ~= baseOptions or kind == "range" or kind == "text" or kind == "toggle" or kind == "color" then flickerstreak@1: if options.type == "header" and not options.cmdName and not options.name then flickerstreak@1: elseif options.cmdName then flickerstreak@1: if type(options.cmdName) ~= "string" then flickerstreak@1: return '"cmdName" must be a string or nil', position flickerstreak@1: elseif options.cmdName:len() == 0 then flickerstreak@1: return '"cmdName" cannot be a 0-length string', position flickerstreak@1: end flickerstreak@1: if type(options.guiName) ~= "string" then flickerstreak@1: if not options.guiNameIsMap then flickerstreak@1: return '"guiName" must be a string or nil', position flickerstreak@1: end flickerstreak@1: elseif options.guiName:len() == 0 then flickerstreak@1: return '"guiName" cannot be a 0-length string', position flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if type(options.name) ~= "string" then flickerstreak@1: return '"name" must be a string', position flickerstreak@1: elseif options.name:len() == 0 then flickerstreak@1: return '"name" cannot be a 0-length string', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.guiNameIsMap then flickerstreak@1: if type(options.guiNameIsMap) ~= "boolean" then flickerstreak@1: return '"guiNameIsMap" must be a boolean or nil', position flickerstreak@1: elseif options.type ~= "toggle" then flickerstreak@1: return 'if "guiNameIsMap" is true, then "type" must be set to \'toggle\'', position flickerstreak@1: elseif type(options.map) ~= "table" then flickerstreak@1: return '"map" must be a table', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.message and type(options.message) ~= "string" then flickerstreak@1: return '"message" must be a string or nil', position flickerstreak@1: end flickerstreak@1: if options.error and type(options.error) ~= "string" then flickerstreak@1: return '"error" must be a string or nil', position flickerstreak@1: end flickerstreak@1: if options.current and type(options.current) ~= "string" then flickerstreak@1: return '"current" must be a string or nil', position flickerstreak@1: end flickerstreak@1: if options.order then flickerstreak@1: if type(options.order) ~= "number" or (-1 < options.order and options.order < 0.999) then flickerstreak@1: return '"order" must be a non-zero number or nil', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.disabled then flickerstreak@1: if type(options.disabled) ~= "function" and type(options.disabled) ~= "string" and options.disabled ~= true then flickerstreak@1: return '"disabled" must be a function, string, or boolean', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.cmdHidden then flickerstreak@1: if type(options.cmdHidden) ~= "function" and type(options.cmdHidden) ~= "string" and options.cmdHidden ~= true then flickerstreak@1: return '"cmdHidden" must be a function, string, or boolean', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.guiHidden then flickerstreak@1: if type(options.guiHidden) ~= "function" and type(options.guiHidden) ~= "string" and options.guiHidden ~= true then flickerstreak@1: return '"guiHidden" must be a function, string, or boolean', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.hidden then flickerstreak@1: if type(options.hidden) ~= "function" and type(options.hidden) ~= "string" and options.hidden ~= true then flickerstreak@1: return '"hidden" must be a function, string, or boolean', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if kind == "text" then flickerstreak@1: if type(options.validate) == "table" then flickerstreak@1: local t = options.validate flickerstreak@1: local iTable = nil flickerstreak@1: for k,v in pairs(t) do flickerstreak@1: if type(k) == "number" then flickerstreak@1: if iTable == nil then flickerstreak@1: iTable = true flickerstreak@1: elseif not iTable then flickerstreak@1: return '"validate" must either have all keys be indexed numbers or strings', position flickerstreak@1: elseif k < 1 or k > #t then flickerstreak@1: return '"validate" numeric keys must be indexed properly. >= 1 and <= #t', position flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if iTable == nil then flickerstreak@1: iTable = false flickerstreak@1: elseif iTable then flickerstreak@1: return '"validate" must either have all keys be indexed numbers or strings', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if type(v) ~= "string" then flickerstreak@1: return '"validate" values must all be strings', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif options.validate == "keybinding" then flickerstreak@1: -- no other checks flickerstreak@1: else flickerstreak@1: if type(options.usage) ~= "string" then flickerstreak@1: return '"usage" must be a string', position flickerstreak@1: elseif options.validate and type(options.validate) ~= "string" and type(options.validate) ~= "function" then flickerstreak@1: return '"validate" must be a string, function, or table', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif kind == "range" then flickerstreak@1: if options.min or options.max then flickerstreak@1: if type(options.min) ~= "number" then flickerstreak@1: return '"min" must be a number', position flickerstreak@1: elseif type(options.max) ~= "number" then flickerstreak@1: return '"max" must be a number', position flickerstreak@1: elseif options.min >= options.max then flickerstreak@1: return '"min" must be less than "max"', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.step then flickerstreak@1: if type(options.step) ~= "number" then flickerstreak@1: return '"step" must be a number', position flickerstreak@1: elseif options.step < 0 then flickerstreak@1: return '"step" must be nonnegative', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.isPercent and options.isPercent ~= true then flickerstreak@1: return '"isPercent" must either be nil, true, or false', position flickerstreak@1: end flickerstreak@1: elseif kind == "toggle" then flickerstreak@1: if options.map then flickerstreak@1: if type(options.map) ~= "table" then flickerstreak@1: return '"map" must be a table', position flickerstreak@1: elseif type(options.map[true]) ~= "string" then flickerstreak@1: return '"map[true]" must be a string', position flickerstreak@1: elseif type(options.map[false]) ~= "string" then flickerstreak@1: return '"map[false]" must be a string', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif kind == "color" then flickerstreak@1: if options.hasAlpha and options.hasAlpha ~= true then flickerstreak@1: return '"hasAlpha" must be nil, true, or false', position flickerstreak@1: end flickerstreak@1: elseif kind == "group" then flickerstreak@1: if options.pass and options.pass ~= true then flickerstreak@1: return '"pass" must be nil, true, or false', position flickerstreak@1: end flickerstreak@1: if type(options.args) ~= "table" then flickerstreak@1: return '"args" must be a table', position flickerstreak@1: end flickerstreak@1: for k,v in pairs(options.args) do flickerstreak@1: if type(k) ~= "string" then flickerstreak@1: return '"args" keys must be strings', position flickerstreak@1: elseif k:find("%s") then flickerstreak@1: return string.format('"args" keys must not include spaces. %q is not appropriate.', k), position flickerstreak@1: elseif k:len() == 0 then flickerstreak@1: return '"args" keys must not be 0-length strings.', position flickerstreak@1: end flickerstreak@1: if type(v) ~= "table" then flickerstreak@1: return '"args" values must be tables', position and position .. "." .. k or k flickerstreak@1: end flickerstreak@1: local newposition flickerstreak@1: if position then flickerstreak@1: newposition = position .. ".args." .. k flickerstreak@1: else flickerstreak@1: newposition = "args." .. k flickerstreak@1: end flickerstreak@1: local err, pos = validateOptions(v, newposition, baseOptions, options.pass) flickerstreak@1: if err then flickerstreak@1: return err, pos flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.icon and type(options.icon) ~= "string" then flickerstreak@1: return'"icon" must be a string', position flickerstreak@1: end flickerstreak@1: if options.iconWidth or options.iconHeight then flickerstreak@1: if type(options.iconWidth) ~= "number" or type(options.iconHeight) ~= "number" then flickerstreak@1: return '"iconHeight" and "iconWidth" must be numbers', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if options.iconCoordLeft or options.iconCoordRight or options.iconCoordTop or options.iconCoordBottom then flickerstreak@1: if type(options.iconCoordLeft) ~= "number" or type(options.iconCoordRight) ~= "number" or type(options.iconCoordTop) ~= "number" or type(options.iconCoordBottom) ~= "number" then flickerstreak@1: return '"iconCoordLeft", "iconCoordRight", "iconCoordTop", and "iconCoordBottom" must be numbers', position flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local validatedOptions flickerstreak@1: flickerstreak@1: local values flickerstreak@1: local mysort_args flickerstreak@1: local mysort flickerstreak@1: local othersort flickerstreak@1: local othersort_validate flickerstreak@1: flickerstreak@1: local baseFunc, currentLevel flickerstreak@1: flickerstreak@1: function Dewdrop:FeedAceOptionsTable(options, difference) flickerstreak@1: self:argCheck(options, 2, "table") flickerstreak@1: self:argCheck(difference, 3, "nil", "number") flickerstreak@1: self:assert(currentLevel, "Cannot call `FeedAceOptionsTable' outside of a Dewdrop declaration") flickerstreak@1: if not difference then flickerstreak@1: difference = 0 flickerstreak@1: end flickerstreak@1: if not validatedOptions then flickerstreak@1: validatedOptions = {} flickerstreak@1: end flickerstreak@1: if not validatedOptions[options] then flickerstreak@1: local err, position = validateOptions(options) flickerstreak@1: flickerstreak@1: if err then flickerstreak@1: if position then flickerstreak@1: Dewdrop:error(position .. ": " .. err) flickerstreak@1: else flickerstreak@1: Dewdrop:error(err) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: validatedOptions[options] = true flickerstreak@1: end flickerstreak@1: local level = levels[currentLevel] flickerstreak@1: self:assert(level, "Improper level given") flickerstreak@1: if not values then flickerstreak@1: values = {} flickerstreak@1: else flickerstreak@1: for k,v in pairs(values) do flickerstreak@1: values[k] = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local current = level flickerstreak@1: while current do flickerstreak@1: if current.num == difference + 1 then flickerstreak@1: break flickerstreak@1: end flickerstreak@1: table.insert(values, current.value) flickerstreak@1: current = levels[current.num - 1] flickerstreak@1: end flickerstreak@1: flickerstreak@1: local realOptions = options flickerstreak@1: local handler = options.handler flickerstreak@1: local passTable flickerstreak@1: local passValue flickerstreak@1: while #values > 0 do flickerstreak@1: passTable = options.pass and current or nil flickerstreak@1: local value = table.remove(values) flickerstreak@1: options = options.args and options.args[value] flickerstreak@1: if not options then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: handler = options.handler or handler flickerstreak@1: passValue = passTable and value or nil flickerstreak@1: end flickerstreak@1: flickerstreak@1: if options.type == "group" then flickerstreak@1: for k in pairs(options.args) do flickerstreak@1: table.insert(values, k) flickerstreak@1: end flickerstreak@1: if not mysort then flickerstreak@1: mysort = function(a, b) flickerstreak@1: local alpha, bravo = mysort_args[a], mysort_args[b] flickerstreak@1: local alpha_order = alpha.order or 100 flickerstreak@1: local bravo_order = bravo.order or 100 flickerstreak@1: local alpha_name = alpha.guiName or alpha.name flickerstreak@1: local bravo_name = bravo.guiName or bravo.name flickerstreak@1: if alpha_order == bravo_order then flickerstreak@1: if not alpha_name then flickerstreak@1: return true flickerstreak@1: elseif not bravo_name then flickerstreak@1: return false flickerstreak@1: else flickerstreak@1: return alpha_name:upper() < bravo_name:upper() flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if alpha_order < 0 then flickerstreak@1: if bravo_order > 0 then flickerstreak@1: return false flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if bravo_order < 0 then flickerstreak@1: return true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return alpha_order < bravo_order flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: mysort_args = options.args flickerstreak@1: table.sort(values, mysort) flickerstreak@1: mysort_args = nil flickerstreak@1: local hasBoth = #values >= 1 and (options.args[values[1]].order or 100) > 0 and (options.args[values[#values]].order or 100) < 0 flickerstreak@1: local last_order = 1 flickerstreak@1: for _,k in ipairs(values) do flickerstreak@1: local v = options.args[k] flickerstreak@1: local handler = v.handler or handler flickerstreak@1: if hasBoth and last_order > 0 and (v.order or 100) < 0 then flickerstreak@1: hasBoth = false flickerstreak@1: self:AddLine() flickerstreak@1: end flickerstreak@1: local hidden, disabled = v.guiHidden or v.hidden, v.disabled flickerstreak@1: if type(hidden) == "function" then flickerstreak@1: hidden = hidden() flickerstreak@1: elseif type(hidden) == "string" then flickerstreak@1: local f = hidden flickerstreak@1: local neg = f:match("^~(.-)$") flickerstreak@1: if neg then flickerstreak@1: f = neg flickerstreak@1: end flickerstreak@1: hidden = handler[f](handler) flickerstreak@1: if neg then flickerstreak@1: hidden = not hidden flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not hidden then flickerstreak@1: if type(disabled) == "function" then flickerstreak@1: disabled = disabled() flickerstreak@1: elseif type(disabled) == "string" then flickerstreak@1: local f = disabled flickerstreak@1: local neg = f:match("^~(.-)$") flickerstreak@1: if neg then flickerstreak@1: f = neg flickerstreak@1: end flickerstreak@1: disabled = handler[f](handler) flickerstreak@1: if neg then flickerstreak@1: disabled = not disabled flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local name = (v.guiIconOnly and v.icon) and "" or (v.guiName or v.name) flickerstreak@1: local desc = v.desc flickerstreak@1: local iconHeight = v.iconHeight or 16 flickerstreak@1: local iconWidth = v.iconWidth or 16 flickerstreak@1: local iconCoordLeft = v.iconCoordLeft flickerstreak@1: local iconCoordRight = v.iconCoordRight flickerstreak@1: local iconCoordBottom = v.iconCoordBottom flickerstreak@1: local iconCoordTop = v.iconCoordTop flickerstreak@1: local tooltipTitle, tooltipText flickerstreak@1: tooltipTitle = name flickerstreak@1: if name ~= desc then flickerstreak@1: tooltipText = desc flickerstreak@1: end flickerstreak@1: if v.type == "toggle" then flickerstreak@1: local checked flickerstreak@1: local checked_arg flickerstreak@1: if type(v.get) == "function" then flickerstreak@1: checked = v.get(passValue) flickerstreak@1: checked_arg = checked flickerstreak@1: else flickerstreak@1: local f = v.get flickerstreak@1: local neg = f:match("^~(.-)$") flickerstreak@1: if neg then flickerstreak@1: f = neg flickerstreak@1: end flickerstreak@1: if not handler[f] then flickerstreak@1: Dewdrop:error("Handler %q not available", f) flickerstreak@1: end flickerstreak@1: checked = handler[f](handler, passValue) flickerstreak@1: checked_arg = checked flickerstreak@1: if neg then flickerstreak@1: checked = not checked flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local func, arg1, arg2, arg3 flickerstreak@1: if type(v.set) == "function" then flickerstreak@1: func = v.set flickerstreak@1: if passValue ~= nil then flickerstreak@1: arg1 = passValue flickerstreak@1: arg2 = not checked_arg flickerstreak@1: else flickerstreak@1: arg1 = not checked_arg flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if not handler[v.set] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.set) flickerstreak@1: end flickerstreak@1: func = handler[v.set] flickerstreak@1: arg1 = handler flickerstreak@1: if passValue ~= nil then flickerstreak@1: arg2 = passValue flickerstreak@1: arg3 = not checked_arg flickerstreak@1: else flickerstreak@1: arg2 = not checked_arg flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if v.guiNameIsMap then flickerstreak@1: checked = checked and true or false flickerstreak@1: name = tostring(v.map and v.map[checked]):gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1") flickerstreak@1: checked = nil flickerstreak@1: end flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'checked', checked, flickerstreak@1: 'isRadio', v.isRadio, flickerstreak@1: 'func', func, flickerstreak@1: 'arg1', arg1, flickerstreak@1: 'arg2', arg2, flickerstreak@1: 'arg3', arg3, flickerstreak@1: 'disabled', disabled, flickerstreak@1: 'tooltipTitle', tooltipTitle, flickerstreak@1: 'tooltipText', tooltipText flickerstreak@1: ) flickerstreak@1: elseif v.type == "execute" then flickerstreak@1: local func, arg1, arg2 flickerstreak@1: if type(v.func) == "function" then flickerstreak@1: func = v.func flickerstreak@1: arg1 = passValue flickerstreak@1: else flickerstreak@1: if not handler[v.func] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.func) flickerstreak@1: end flickerstreak@1: func = handler[v.func] flickerstreak@1: arg1 = handler flickerstreak@1: arg2 = passValue flickerstreak@1: end flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'checked', checked, flickerstreak@1: 'func', func, flickerstreak@1: 'arg1', arg1, flickerstreak@1: 'arg2', arg2, flickerstreak@1: 'disabled', disabled, flickerstreak@1: 'tooltipTitle', tooltipTitle, flickerstreak@1: 'tooltipText', tooltipText, flickerstreak@1: 'icon', v.icon, flickerstreak@1: 'iconHeight', iconHeight, flickerstreak@1: 'iconWidth', iconWidth, flickerstreak@1: 'iconCoordLeft', iconCoordLeft, flickerstreak@1: 'iconCoordRight', iconCoordRight, flickerstreak@1: 'iconCoordTop', iconCoordTop, flickerstreak@1: 'iconCoordBottom', iconCoordBottom flickerstreak@1: ) flickerstreak@1: elseif v.type == "range" then flickerstreak@1: local sliderValue flickerstreak@1: if type(v.get) == "function" then flickerstreak@1: sliderValue = v.get(passValue) flickerstreak@1: else flickerstreak@1: if not handler[v.get] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.get) flickerstreak@1: end flickerstreak@1: sliderValue = handler[v.get](handler, passValue) flickerstreak@1: end flickerstreak@1: local sliderFunc, sliderArg1, sliderArg2 flickerstreak@1: if type(v.set) == "function" then flickerstreak@1: sliderFunc = v.set flickerstreak@1: sliderArg1 = passValue flickerstreak@1: else flickerstreak@1: if not handler[v.set] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.set) flickerstreak@1: end flickerstreak@1: sliderFunc = handler[v.set] flickerstreak@1: sliderArg1 = handler flickerstreak@1: sliderArg2 = passValue flickerstreak@1: end flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'hasArrow', true, flickerstreak@1: 'hasSlider', true, flickerstreak@1: 'sliderMin', v.min or 0, flickerstreak@1: 'sliderMax', v.max or 1, flickerstreak@1: 'sliderStep', v.step or 0, flickerstreak@1: 'sliderIsPercent', v.isPercent or false, flickerstreak@1: 'sliderValue', sliderValue, flickerstreak@1: 'sliderFunc', sliderFunc, flickerstreak@1: 'sliderArg1', sliderArg1, flickerstreak@1: 'sliderArg2', sliderArg2, flickerstreak@1: 'disabled', disabled, flickerstreak@1: 'tooltipTitle', tooltipTitle, flickerstreak@1: 'tooltipText', tooltipText, flickerstreak@1: 'icon', v.icon, flickerstreak@1: 'iconHeight', iconHeight, flickerstreak@1: 'iconWidth', iconWidth, flickerstreak@1: 'iconCoordLeft', iconCoordLeft, flickerstreak@1: 'iconCoordRight', iconCoordRight, flickerstreak@1: 'iconCoordTop', iconCoordTop, flickerstreak@1: 'iconCoordBottom', iconCoordBottom flickerstreak@1: ) flickerstreak@1: elseif v.type == "color" then flickerstreak@1: local r,g,b,a flickerstreak@1: if type(v.get) == "function" then flickerstreak@1: r,g,b,a = v.get(passValue) flickerstreak@1: else flickerstreak@1: if not handler[v.get] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.get) flickerstreak@1: end flickerstreak@1: r,g,b,a = handler[v.get](handler, passValue) flickerstreak@1: end flickerstreak@1: local colorFunc, colorArg1, colorArg2 flickerstreak@1: if type(v.set) == "function" then flickerstreak@1: colorFunc = v.set flickerstreak@1: colorArg1 = passValue flickerstreak@1: else flickerstreak@1: if not handler[v.set] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.set) flickerstreak@1: end flickerstreak@1: colorFunc = handler[v.set] flickerstreak@1: colorArg1 = handler flickerstreak@1: colorArg2 = passValue flickerstreak@1: end flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'hasArrow', true, flickerstreak@1: 'hasColorSwatch', true, flickerstreak@1: 'r', r, flickerstreak@1: 'g', g, flickerstreak@1: 'b', b, flickerstreak@1: 'opacity', v.hasAlpha and a or nil, flickerstreak@1: 'hasOpacity', v.hasAlpha, flickerstreak@1: 'colorFunc', colorFunc, flickerstreak@1: 'colorArg1', colorArg1, flickerstreak@1: 'colorArg2', colorArg2, flickerstreak@1: 'disabled', disabled, flickerstreak@1: 'tooltipTitle', tooltipTitle, flickerstreak@1: 'tooltipText', tooltipText flickerstreak@1: ) flickerstreak@1: elseif v.type == "text" then flickerstreak@1: if type(v.validate) == "table" then flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'hasArrow', true, flickerstreak@1: 'value', k, flickerstreak@1: 'disabled', disabled, flickerstreak@1: 'tooltipTitle', tooltipTitle, flickerstreak@1: 'tooltipText', tooltipText, flickerstreak@1: 'icon', v.icon, flickerstreak@1: 'iconHeight', iconHeight, flickerstreak@1: 'iconWidth', iconWidth, flickerstreak@1: 'iconCoordLeft', iconCoordLeft, flickerstreak@1: 'iconCoordRight', iconCoordRight, flickerstreak@1: 'iconCoordTop', iconCoordTop, flickerstreak@1: 'iconCoordBottom', iconCoordBottom flickerstreak@1: ) flickerstreak@1: else flickerstreak@1: local editBoxText flickerstreak@1: if type(v.get) == "function" then flickerstreak@1: editBoxText = v.get(passValue) flickerstreak@1: elseif v.get == false then flickerstreak@1: editBoxText = nil flickerstreak@1: else flickerstreak@1: if not handler[v.get] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.get) flickerstreak@1: end flickerstreak@1: editBoxText = handler[v.get](handler, passValue) flickerstreak@1: end flickerstreak@1: local editBoxFunc, editBoxArg1, editBoxArg2 flickerstreak@1: if type(v.set) == "function" then flickerstreak@1: editBoxFunc = v.set flickerstreak@1: editBoxArg1 = passValue flickerstreak@1: else flickerstreak@1: if not handler[v.set] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.set) flickerstreak@1: end flickerstreak@1: editBoxFunc = handler[v.set] flickerstreak@1: editBoxArg1 = handler flickerstreak@1: editBoxArg2 = passValue flickerstreak@1: end flickerstreak@1: flickerstreak@1: local editBoxValidateFunc, editBoxValidateArg1 flickerstreak@1: flickerstreak@1: if v.validate and v.validate ~= "keybinding" then flickerstreak@1: if type(v.validate) == "function" then flickerstreak@1: editBoxValidateFunc = v.validate flickerstreak@1: else flickerstreak@1: if not handler[v.validate] then flickerstreak@1: Dewdrop:error("Handler %q not available", v.validate) flickerstreak@1: end flickerstreak@1: editBoxValidateFunc = handler[v.validate] flickerstreak@1: editBoxValidateArg1 = handler flickerstreak@1: end flickerstreak@1: elseif v.validate then flickerstreak@1: if tooltipText then flickerstreak@1: tooltipText = tooltipText .. "\n\n" .. RESET_KEYBINDING_DESC flickerstreak@1: else flickerstreak@1: tooltipText = RESET_KEYBINDING_DESC flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'hasArrow', true, flickerstreak@1: 'icon', v.icon, flickerstreak@1: 'iconHeight', iconHeight, flickerstreak@1: 'iconWidth', iconWidth, flickerstreak@1: 'iconCoordLeft', iconCoordLeft, flickerstreak@1: 'iconCoordRight', iconCoordRight, flickerstreak@1: 'iconCoordTop', iconCoordTop, flickerstreak@1: 'iconCoordBottom', iconCoordBottom, flickerstreak@1: 'hasEditBox', true, flickerstreak@1: 'editBoxText', editBoxText, flickerstreak@1: 'editBoxFunc', editBoxFunc, flickerstreak@1: 'editBoxArg1', editBoxArg1, flickerstreak@1: 'editBoxArg2', editBoxArg2, flickerstreak@1: 'editBoxValidateFunc', editBoxValidateFunc, flickerstreak@1: 'editBoxValidateArg1', editBoxValidateArg1, flickerstreak@1: 'editBoxIsKeybinding', v.validate == "keybinding", flickerstreak@1: 'disabled', disabled, flickerstreak@1: 'tooltipTitle', tooltipTitle, flickerstreak@1: 'tooltipText', tooltipText flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: elseif v.type == "group" then flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'hasArrow', true, flickerstreak@1: 'value', k, flickerstreak@1: 'disabled', disabled, flickerstreak@1: 'tooltipTitle', tooltipTitle, flickerstreak@1: 'tooltipText', tooltipText, flickerstreak@1: 'icon', v.icon, flickerstreak@1: 'iconHeight', iconHeight, flickerstreak@1: 'iconWidth', iconWidth, flickerstreak@1: 'iconCoordLeft', iconCoordLeft, flickerstreak@1: 'iconCoordRight', iconCoordRight, flickerstreak@1: 'iconCoordTop', iconCoordTop, flickerstreak@1: 'iconCoordBottom', iconCoordBottom flickerstreak@1: ) flickerstreak@1: elseif v.type == "header" then flickerstreak@1: if name == "" or not name then flickerstreak@1: self:AddLine( flickerstreak@1: 'isTitle', true, flickerstreak@1: 'icon', v.icon, flickerstreak@1: 'iconHeight', iconHeight, flickerstreak@1: 'iconWidth', iconWidth, flickerstreak@1: 'iconCoordLeft', iconCoordLeft, flickerstreak@1: 'iconCoordRight', iconCoordRight, flickerstreak@1: 'iconCoordTop', iconCoordTop, flickerstreak@1: 'iconCoordBottom', iconCoordBottom flickerstreak@1: ) flickerstreak@1: else flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'isTitle', true, flickerstreak@1: 'icon', v.icon, flickerstreak@1: 'iconHeight', iconHeight, flickerstreak@1: 'iconWidth', iconWidth, flickerstreak@1: 'iconCoordLeft', iconCoordLeft, flickerstreak@1: 'iconCoordRight', iconCoordRight, flickerstreak@1: 'iconCoordTop', iconCoordTop, flickerstreak@1: 'iconCoordBottom', iconCoordBottom flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: last_order = v.order or 100 flickerstreak@1: end flickerstreak@1: elseif options.type == "text" and type(options.validate) == "table" then flickerstreak@1: local current flickerstreak@1: if type(options.get) == "function" then flickerstreak@1: current = options.get(passValue) flickerstreak@1: elseif options.get ~= false then flickerstreak@1: if not handler[options.get] then flickerstreak@1: Dewdrop:error("Handler %q not available", options.get) flickerstreak@1: end flickerstreak@1: current = handler[options.get](handler, passValue) flickerstreak@1: end flickerstreak@1: local indexed = true flickerstreak@1: for k,v in pairs(options.validate) do flickerstreak@1: if type(k) ~= "number" then flickerstreak@1: indexed = false flickerstreak@1: end flickerstreak@1: table.insert(values, k) flickerstreak@1: end flickerstreak@1: if not indexed then flickerstreak@1: if not othersort then flickerstreak@1: othersort = function(alpha, bravo) flickerstreak@1: return othersort_validate[alpha] < othersort_validate[bravo] flickerstreak@1: end flickerstreak@1: end flickerstreak@1: othersort_validate = options.validate flickerstreak@1: table.sort(values, othersort) flickerstreak@1: othersort_validate = nil flickerstreak@1: end flickerstreak@1: for _,k in ipairs(values) do flickerstreak@1: local v = options.validate[k] flickerstreak@1: if type(k) == "number" then flickerstreak@1: k = v flickerstreak@1: end flickerstreak@1: local func, arg1, arg2 flickerstreak@1: if type(options.set) == "function" then flickerstreak@1: func = options.set flickerstreak@1: if passValue ~= nil then flickerstreak@1: arg1 = passValue flickerstreak@1: arg2 = k flickerstreak@1: else flickerstreak@1: arg1 = k flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if not handler[options.set] then flickerstreak@1: Dewdrop:error("Handler %q not available", options.set) flickerstreak@1: end flickerstreak@1: func = handler[options.set] flickerstreak@1: arg1 = handler flickerstreak@1: if passValue ~= nil then flickerstreak@1: arg2 = passValue flickerstreak@1: arg3 = k flickerstreak@1: else flickerstreak@1: arg2 = k flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local checked = (k == current or (type(k) == "string" and type(current) == "string" and k:lower() == current:lower())) flickerstreak@1: self:AddLine( flickerstreak@1: 'text', v, flickerstreak@1: 'func', not checked and func or nil, flickerstreak@1: 'arg1', not checked and arg1 or nil, flickerstreak@1: 'arg2', not checked and arg2 or nil, flickerstreak@1: 'arg3', not checked and arg3 or nil, flickerstreak@1: 'isRadio', true, flickerstreak@1: 'checked', checked, flickerstreak@1: 'tooltipTitle', options.guiName or options.name, flickerstreak@1: 'tooltipText', v flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: for k in pairs(values) do flickerstreak@1: values[k] = nil flickerstreak@1: end flickerstreak@1: else flickerstreak@1: return false flickerstreak@1: end flickerstreak@1: return true flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Refresh(self, level) flickerstreak@1: if type(level) == "number" then flickerstreak@1: level = levels[level] flickerstreak@1: end flickerstreak@1: if not level then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: if baseFunc then flickerstreak@1: Clear(self, level) flickerstreak@1: currentLevel = level.num flickerstreak@1: if type(baseFunc) == "table" then flickerstreak@1: if currentLevel == 1 then flickerstreak@1: local handler = baseFunc.handler flickerstreak@1: if handler then flickerstreak@1: local name = tostring(handler) flickerstreak@1: if not name:find('^table:') then flickerstreak@1: name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1") flickerstreak@1: self:AddLine( flickerstreak@1: 'text', name, flickerstreak@1: 'isTitle', true flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: -- elseif level.parentText then flickerstreak@1: -- self:AddLine( flickerstreak@1: -- 'text', level.parentText, flickerstreak@1: -- 'tooltipTitle', level.parentTooltipTitle, flickerstreak@1: -- 'tooltipText', level.parentTooltipText, flickerstreak@1: -- 'tooltipFunc', level.parentTooltipFunc, flickerstreak@1: -- 'isTitle', true flickerstreak@1: -- ) flickerstreak@1: end flickerstreak@1: self:FeedAceOptionsTable(baseFunc) flickerstreak@1: if currentLevel == 1 then flickerstreak@1: self:AddLine( flickerstreak@1: 'text', CLOSE, flickerstreak@1: 'tooltipTitle', CLOSE, flickerstreak@1: 'tooltipText', CLOSE_DESC, flickerstreak@1: 'closeWhenClicked', true flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: -- if level.parentText then flickerstreak@1: -- self:AddLine( flickerstreak@1: -- 'text', level.parentText, flickerstreak@1: -- 'tooltipTitle', level.parentTooltipTitle, flickerstreak@1: -- 'tooltipText', level.parentTooltipText, flickerstreak@1: -- 'tooltipFunc', level.parentTooltipFunc, flickerstreak@1: -- 'isTitle', true flickerstreak@1: -- ) flickerstreak@1: -- end flickerstreak@1: baseFunc(currentLevel, level.value, levels[level.num - 1] and levels[level.num - 1].value, levels[level.num - 2] and levels[level.num - 2].value, levels[level.num - 3] and levels[level.num - 3].value, levels[level.num - 4] and levels[level.num - 4].value) flickerstreak@1: end flickerstreak@1: currentLevel = nil flickerstreak@1: CheckSize(self, level) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:Refresh(level) flickerstreak@1: self:argCheck(level, 2, "number") flickerstreak@1: Refresh(self, levels[level]) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function OpenSlider(self, parent) flickerstreak@1: if not sliderFrame then flickerstreak@1: sliderFrame = CreateFrame("Frame", nil, nil) flickerstreak@1: sliderFrame:SetWidth(80) flickerstreak@1: sliderFrame:SetHeight(170) flickerstreak@1: sliderFrame:SetScale(UIParent:GetScale()) flickerstreak@1: sliderFrame:SetBackdrop(tmp( flickerstreak@1: 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background", flickerstreak@1: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@1: 'tile', true, flickerstreak@1: 'insets', tmp2( flickerstreak@1: 'left', 5, flickerstreak@1: 'right', 5, flickerstreak@1: 'top', 5, flickerstreak@1: 'bottom', 5 flickerstreak@1: ), flickerstreak@1: 'tileSize', 16, flickerstreak@1: 'edgeSize', 16 flickerstreak@1: )) flickerstreak@1: sliderFrame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@1: if sliderFrame.SetTopLevel then flickerstreak@1: sliderFrame:SetTopLevel(true) flickerstreak@1: end flickerstreak@1: sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) flickerstreak@1: sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) flickerstreak@1: sliderFrame:EnableMouse(true) flickerstreak@1: sliderFrame:Hide() flickerstreak@1: sliderFrame:SetPoint("CENTER", UIParent, "CENTER") flickerstreak@1: local slider = CreateFrame("Slider", nil, sliderFrame) flickerstreak@1: sliderFrame.slider = slider flickerstreak@1: slider:SetOrientation("VERTICAL") flickerstreak@1: slider:SetMinMaxValues(0, 1) flickerstreak@1: slider:SetValueStep(0.01) flickerstreak@1: slider:SetValue(0.5) flickerstreak@1: slider:SetWidth(16) flickerstreak@1: slider:SetHeight(128) flickerstreak@1: slider:SetPoint("LEFT", sliderFrame, "LEFT", 15, 0) flickerstreak@1: slider:SetBackdrop(tmp( flickerstreak@1: 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background", flickerstreak@1: 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border", flickerstreak@1: 'tile', true, flickerstreak@1: 'edgeSize', 8, flickerstreak@1: 'tileSize', 8, flickerstreak@1: 'insets', tmp2( flickerstreak@1: 'left', 3, flickerstreak@1: 'right', 3, flickerstreak@1: 'top', 3, flickerstreak@1: 'bottom', 3 flickerstreak@1: ) flickerstreak@1: )) flickerstreak@1: local texture = slider:CreateTexture() flickerstreak@1: slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical") flickerstreak@1: local text = slider:CreateFontString(nil, "ARTWORK") flickerstreak@1: sliderFrame.topText = text flickerstreak@1: text:SetFontObject(GameFontGreenSmall) flickerstreak@1: text:SetText("100%") flickerstreak@1: text:SetPoint("BOTTOM", slider, "TOP") flickerstreak@1: local text = slider:CreateFontString(nil, "ARTWORK") flickerstreak@1: sliderFrame.bottomText = text flickerstreak@1: text:SetFontObject(GameFontGreenSmall) flickerstreak@1: text:SetText("0%") flickerstreak@1: text:SetPoint("TOP", slider, "BOTTOM") flickerstreak@1: local text = slider:CreateFontString(nil, "ARTWORK") flickerstreak@1: sliderFrame.currentText = text flickerstreak@1: text:SetFontObject(GameFontHighlightSmall) flickerstreak@1: text:SetText("50%") flickerstreak@1: text:SetPoint("LEFT", slider, "RIGHT") flickerstreak@1: text:SetPoint("RIGHT", sliderFrame, "RIGHT", -6, 0) flickerstreak@1: text:SetJustifyH("CENTER") flickerstreak@1: local changed = false flickerstreak@1: local inside = false flickerstreak@1: slider:SetScript("OnValueChanged", function() flickerstreak@1: if sliderFrame.changing then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: changed = true flickerstreak@1: local done = false flickerstreak@1: if sliderFrame.parent and sliderFrame.parent.sliderFunc then flickerstreak@1: local min = sliderFrame.parent.sliderMin or 0 flickerstreak@1: local max = sliderFrame.parent.sliderMax or 1 flickerstreak@1: local step = sliderFrame.parent.sliderStep or (max - min) / 100 flickerstreak@1: local a1,a2,a3,a4 = sliderFrame.parent.sliderArg1, sliderFrame.parent.sliderArg2, sliderFrame.parent.sliderArg3, sliderFrame.parent.sliderArg4 flickerstreak@1: local value = (1 - slider:GetValue()) * (max - min) + min flickerstreak@1: if step > 0 then flickerstreak@1: value = math.floor((value - min) / step + 0.5) * step + min flickerstreak@1: if value > max then flickerstreak@1: value = max flickerstreak@1: elseif value < min then flickerstreak@1: value = min flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if value == sliderFrame.lastValue then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: sliderFrame.lastValue = value flickerstreak@1: local text flickerstreak@1: if a1 == nil then flickerstreak@1: text = sliderFrame.parent.sliderFunc(value) flickerstreak@1: elseif a2 == nil then flickerstreak@1: text = sliderFrame.parent.sliderFunc(a1, value) flickerstreak@1: elseif a3 == nil then flickerstreak@1: text = sliderFrame.parent.sliderFunc(a1, a2, value) flickerstreak@1: elseif a4 == nil then flickerstreak@1: text = sliderFrame.parent.sliderFunc(a1, a2, a3, value) flickerstreak@1: else flickerstreak@1: text = sliderFrame.parent.sliderFunc(a1, a2, a3, a4, value) flickerstreak@1: end flickerstreak@1: if text then flickerstreak@1: sliderFrame.currentText:SetText(text) flickerstreak@1: done = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not done then flickerstreak@1: local min = sliderFrame.parent.sliderMin or 0 flickerstreak@1: local max = sliderFrame.parent.sliderMax or 1 flickerstreak@1: local step = sliderFrame.parent.sliderStep or (max - min) / 100 flickerstreak@1: local value = (1 - slider:GetValue()) * (max - min) + min flickerstreak@1: if step > 0 then flickerstreak@1: value = math.floor((value - min) / step + 0.5) * step + min flickerstreak@1: if value > max then flickerstreak@1: value = max flickerstreak@1: elseif value < min then flickerstreak@1: value = min flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if sliderFrame.parent.sliderIsPercent then flickerstreak@1: sliderFrame.currentText:SetText(string.format("%.0f%%", value * 100)) flickerstreak@1: else flickerstreak@1: if step < 0.1 then flickerstreak@1: sliderFrame.currentText:SetText(string.format("%.2f", value)) flickerstreak@1: elseif step < 1 then flickerstreak@1: sliderFrame.currentText:SetText(string.format("%.1f", value)) flickerstreak@1: else flickerstreak@1: sliderFrame.currentText:SetText(string.format("%.0f", value)) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: sliderFrame:SetScript("OnEnter", function() flickerstreak@1: StopCounting(self, sliderFrame.level) flickerstreak@1: showGameTooltip(sliderFrame.parent) flickerstreak@1: end) flickerstreak@1: sliderFrame:SetScript("OnLeave", function() flickerstreak@1: StartCounting(self, sliderFrame.level) flickerstreak@1: GameTooltip:Hide() flickerstreak@1: end) flickerstreak@1: slider:SetScript("OnMouseDown", function() flickerstreak@1: sliderFrame.mouseDown = true flickerstreak@1: GameTooltip:Hide() flickerstreak@1: end) flickerstreak@1: slider:SetScript("OnMouseUp", function() flickerstreak@1: sliderFrame.mouseDown = false flickerstreak@1: if changed--[[ and not inside]] then flickerstreak@1: local parent = sliderFrame.parent flickerstreak@1: local sliderFunc = parent.sliderFunc flickerstreak@1: for i = 1, sliderFrame.level - 1 do flickerstreak@1: Refresh(self, levels[i]) flickerstreak@1: end flickerstreak@1: local newParent flickerstreak@1: for _,button in ipairs(levels[sliderFrame.level-1].buttons) do flickerstreak@1: if button.sliderFunc == sliderFunc then flickerstreak@1: newParent = button flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if newParent then flickerstreak@1: OpenSlider(self, newParent) flickerstreak@1: else flickerstreak@1: sliderFrame:Hide() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if inside then flickerstreak@1: showGameTooltip(sliderFrame.parent) flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: slider:SetScript("OnEnter", function() flickerstreak@1: inside = true flickerstreak@1: StopCounting(self, sliderFrame.level) flickerstreak@1: showGameTooltip(sliderFrame.parent) flickerstreak@1: end) flickerstreak@1: slider:SetScript("OnLeave", function() flickerstreak@1: inside = false flickerstreak@1: StartCounting(self, sliderFrame.level) flickerstreak@1: GameTooltip:Hide() flickerstreak@1: if changed and not sliderFrame.mouseDown then flickerstreak@1: local parent = sliderFrame.parent flickerstreak@1: local sliderFunc = parent.sliderFunc flickerstreak@1: for i = 1, sliderFrame.level - 1 do flickerstreak@1: Refresh(self, levels[i]) flickerstreak@1: end flickerstreak@1: local newParent flickerstreak@1: for _,button in ipairs(levels[sliderFrame.level-1].buttons) do flickerstreak@1: if button.sliderFunc == sliderFunc then flickerstreak@1: newParent = button flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if newParent then flickerstreak@1: OpenSlider(self, newParent) flickerstreak@1: else flickerstreak@1: sliderFrame:Hide() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: end flickerstreak@1: sliderFrame.parent = parent flickerstreak@1: sliderFrame.level = parent.level.num + 1 flickerstreak@1: sliderFrame.parentValue = parent.level.value flickerstreak@1: sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3) flickerstreak@1: sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1) flickerstreak@1: sliderFrame.changing = true flickerstreak@1: if not parent.sliderMin or not parent.sliderMax then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: flickerstreak@1: if parent.arrow then flickerstreak@1: -- parent.arrow:SetVertexColor(0.2, 0.6, 0) flickerstreak@1: -- parent.arrow:SetHeight(24) flickerstreak@1: -- parent.arrow:SetWidth(24) flickerstreak@1: parent.selected = true flickerstreak@1: parent.highlight:Show() flickerstreak@1: end flickerstreak@1: flickerstreak@1: sliderFrame:SetClampedToScreen(false) flickerstreak@1: if not parent.sliderValue then flickerstreak@1: parent.sliderValue = (parent.sliderMin + parent.sliderMax) / 2 flickerstreak@1: end flickerstreak@1: sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin)) flickerstreak@1: sliderFrame.changing = false flickerstreak@1: sliderFrame.bottomText:SetText(parent.sliderMinText or "0") flickerstreak@1: sliderFrame.topText:SetText(parent.sliderMaxText or "1") flickerstreak@1: local text flickerstreak@1: if parent.sliderFunc then flickerstreak@1: local a1,a2,a3,a4 = parent.sliderArg1, parent.sliderArg2, parent.sliderArg3, parent.sliderArg4 flickerstreak@1: if a1 == nil then flickerstreak@1: text = parent.sliderFunc(parent.sliderValue) flickerstreak@1: elseif a2 == nil then flickerstreak@1: text = parent.sliderFunc(a1, parent.sliderValue) flickerstreak@1: elseif a3 == nil then flickerstreak@1: text = parent.sliderFunc(a1, a2, parent.sliderValue) flickerstreak@1: elseif a4 == nil then flickerstreak@1: text = parent.sliderFunc(a1, a2, a3, parent.sliderValue) flickerstreak@1: else flickerstreak@1: text = parent.sliderFunc(a1, a2, a3, a4, parent.sliderValue) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if text then flickerstreak@1: sliderFrame.currentText:SetText(text) flickerstreak@1: elseif parent.sliderIsPercent then flickerstreak@1: sliderFrame.currentText:SetText(string.format("%.0f%%", parent.sliderValue * 100)) flickerstreak@1: else flickerstreak@1: sliderFrame.currentText:SetText(parent.sliderValue) flickerstreak@1: end flickerstreak@1: flickerstreak@1: sliderFrame.lastValue = parent.sliderValue flickerstreak@1: flickerstreak@1: local level = parent.level flickerstreak@1: sliderFrame:Show() flickerstreak@1: sliderFrame:ClearAllPoints() flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@1: else flickerstreak@1: sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@1: else flickerstreak@1: sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local dirty flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if sliderFrame:GetRight() > GetScreenWidth() then flickerstreak@1: level.lastDirection = "LEFT" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: elseif sliderFrame:GetLeft() < 0 then flickerstreak@1: level.lastDirection = "RIGHT" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: if sliderFrame:GetBottom() < 0 then flickerstreak@1: level.lastVDirection = "UP" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: elseif sliderFrame:GetTop() > GetScreenWidth() then flickerstreak@1: level.lastVDirection = "DOWN" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: if dirty then flickerstreak@1: sliderFrame:ClearAllPoints() flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@1: else flickerstreak@1: sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@1: else flickerstreak@1: sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local left, bottom = sliderFrame:GetLeft(), sliderFrame:GetBottom() flickerstreak@1: sliderFrame:ClearAllPoints() flickerstreak@1: sliderFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@1: if mod(level.num, 5) == 0 then flickerstreak@1: local left, bottom = level:GetLeft(), level:GetBottom() flickerstreak@1: level:ClearAllPoints() flickerstreak@1: level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@1: end flickerstreak@1: sliderFrame:SetClampedToScreen(true) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function OpenEditBox(self, parent) flickerstreak@1: if not editBoxFrame then flickerstreak@1: editBoxFrame = CreateFrame("Frame", nil, nil) flickerstreak@1: editBoxFrame:SetWidth(200) flickerstreak@1: editBoxFrame:SetHeight(40) flickerstreak@1: editBoxFrame:SetScale(UIParent:GetScale()) flickerstreak@1: editBoxFrame:SetBackdrop(tmp( flickerstreak@1: 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background", flickerstreak@1: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@1: 'tile', true, flickerstreak@1: 'insets', tmp2( flickerstreak@1: 'left', 5, flickerstreak@1: 'right', 5, flickerstreak@1: 'top', 5, flickerstreak@1: 'bottom', 5 flickerstreak@1: ), flickerstreak@1: 'tileSize', 16, flickerstreak@1: 'edgeSize', 16 flickerstreak@1: )) flickerstreak@1: editBoxFrame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@1: if editBoxFrame.SetTopLevel then flickerstreak@1: editBoxFrame:SetTopLevel(true) flickerstreak@1: end flickerstreak@1: editBoxFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) flickerstreak@1: editBoxFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) flickerstreak@1: editBoxFrame:EnableMouse(true) flickerstreak@1: editBoxFrame:Hide() flickerstreak@1: editBoxFrame:SetPoint("CENTER", UIParent, "CENTER") flickerstreak@1: flickerstreak@1: local editBox = CreateFrame("EditBox", nil, editBoxFrame) flickerstreak@1: editBoxFrame.editBox = editBox flickerstreak@1: editBox:SetFontObject(ChatFontNormal) flickerstreak@1: editBox:SetWidth(160) flickerstreak@1: editBox:SetHeight(13) flickerstreak@1: editBox:SetPoint("CENTER", editBoxFrame, "CENTER", 0, 0) flickerstreak@1: flickerstreak@1: local left = editBox:CreateTexture(nil, "BACKGROUND") flickerstreak@1: left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left") flickerstreak@1: left:SetTexCoord(0, 100 / 256, 0, 1) flickerstreak@1: left:SetWidth(100) flickerstreak@1: left:SetHeight(32) flickerstreak@1: left:SetPoint("LEFT", editBox, "LEFT", -10, 0) flickerstreak@1: local right = editBox:CreateTexture(nil, "BACKGROUND") flickerstreak@1: right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right") flickerstreak@1: right:SetTexCoord(156/256, 1, 0, 1) flickerstreak@1: right:SetWidth(100) flickerstreak@1: right:SetHeight(32) flickerstreak@1: right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0) flickerstreak@1: flickerstreak@1: editBox:SetScript("OnEnterPressed", function() flickerstreak@1: if editBoxFrame.parent and editBoxFrame.parent.editBoxValidateFunc then flickerstreak@1: local a1,a2,a3,a4 = editBoxFrame.parent.editBoxValidateArg1, editBoxFrame.parent.editBoxValidateArg2, editBoxFrame.parent.editBoxValidateArg3, editBoxFrame.parent.editBoxValidateArg4 flickerstreak@1: flickerstreak@1: local t = editBox.realText or editBox:GetText() or "" flickerstreak@1: local result flickerstreak@1: if a1 == nil then flickerstreak@1: result = editBoxFrame.parent.editBoxValidateFunc(t) flickerstreak@1: elseif a2 == nil then flickerstreak@1: result = editBoxFrame.parent.editBoxValidateFunc(a1, t) flickerstreak@1: elseif a3 == nil then flickerstreak@1: result = editBoxFrame.parent.editBoxValidateFunc(a1, a2, t) flickerstreak@1: elseif a4 == nil then flickerstreak@1: result = editBoxFrame.parent.editBoxValidateFunc(a1, a2, a3, t) flickerstreak@1: else flickerstreak@1: result = editBoxFrame.parent.editBoxValidateFunc(a1, a2, a3, a4, t) flickerstreak@1: end flickerstreak@1: if not result then flickerstreak@1: UIErrorsFrame:AddMessage(VALIDATION_ERROR, 1, 0, 0) flickerstreak@1: return flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if editBoxFrame.parent and editBoxFrame.parent.editBoxFunc then flickerstreak@1: local a1,a2,a3,a4 = editBoxFrame.parent.editBoxArg1, editBoxFrame.parent.editBoxArg2, editBoxFrame.parent.editBoxArg3, editBoxFrame.parent.editBoxArg4 flickerstreak@1: local t flickerstreak@1: if editBox.realText ~= "NONE" then flickerstreak@1: t = editBox.realText or editBox:GetText() or "" flickerstreak@1: end flickerstreak@1: if a1 == nil then flickerstreak@1: editBoxFrame.parent.editBoxFunc(t) flickerstreak@1: elseif a2 == nil then flickerstreak@1: editBoxFrame.parent.editBoxFunc(a1, t) flickerstreak@1: elseif a3 == nil then flickerstreak@1: editBoxFrame.parent.editBoxFunc(a1, a2, t) flickerstreak@1: elseif a4 == nil then flickerstreak@1: editBoxFrame.parent.editBoxFunc(a1, a2, a3, t) flickerstreak@1: else flickerstreak@1: editBoxFrame.parent.editBoxFunc(a1, a2, a3, a4, t) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self:Close(editBoxFrame.level) flickerstreak@1: for i = 1, editBoxFrame.level - 1 do flickerstreak@1: Refresh(self, levels[i]) flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: editBox:SetScript("OnEscapePressed", function() flickerstreak@1: self:Close(editBoxFrame.level) flickerstreak@1: end) flickerstreak@1: local changing = false flickerstreak@1: local skipNext = false flickerstreak@1: flickerstreak@1: function editBox:SpecialSetText(text) flickerstreak@1: local oldText = editBox:GetText() or "" flickerstreak@1: if not text then flickerstreak@1: text = "" flickerstreak@1: end flickerstreak@1: if text ~= oldText then flickerstreak@1: changing = true flickerstreak@1: self:SetText(text) flickerstreak@1: changing = false flickerstreak@1: skipNext = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: editBox:SetScript("OnTextChanged", function() flickerstreak@1: if skipNext then flickerstreak@1: skipNext = false flickerstreak@1: elseif not changing and editBoxFrame.parent and editBoxFrame.parent.editBoxChangeFunc then flickerstreak@1: local a1,a2,a3,a4 = editBoxFrame.parent.editBoxChangeArg1, editBoxFrame.parent.editBoxChangeArg2, editBoxFrame.parent.editBoxChangeArg3, editBoxFrame.parent.editBoxChangeArg4 flickerstreak@1: local t flickerstreak@1: if editBox.realText ~= "NONE" then flickerstreak@1: t = editBox.realText or editBox:GetText() or "" flickerstreak@1: end flickerstreak@1: local text flickerstreak@1: if a1 == nil then flickerstreak@1: text = editBoxFrame.parent.editBoxChangeFunc(t) flickerstreak@1: elseif a2 == nil then flickerstreak@1: text = editBoxFrame.parent.editBoxChangeFunc(a1, t) flickerstreak@1: elseif a3 == nil then flickerstreak@1: text = editBoxFrame.parent.editBoxChangeFunc(a1, a2, t) flickerstreak@1: elseif a4 == nil then flickerstreak@1: text = editBoxFrame.parent.editBoxChangeFunc(a1, a2, a3, t) flickerstreak@1: else flickerstreak@1: text = editBoxFrame.parent.editBoxChangeFunc(a1, a2, a3, a4, t) flickerstreak@1: end flickerstreak@1: if text then flickerstreak@1: editBox:SpecialSetText(text) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: editBoxFrame:SetScript("OnEnter", function() flickerstreak@1: StopCounting(self, editBoxFrame.level) flickerstreak@1: showGameTooltip(editBoxFrame.parent) flickerstreak@1: end) flickerstreak@1: editBoxFrame:SetScript("OnLeave", function() flickerstreak@1: StartCounting(self, editBoxFrame.level) flickerstreak@1: GameTooltip:Hide() flickerstreak@1: end) flickerstreak@1: editBox:SetScript("OnEnter", function() flickerstreak@1: StopCounting(self, editBoxFrame.level) flickerstreak@1: showGameTooltip(editBoxFrame.parent) flickerstreak@1: end) flickerstreak@1: editBox:SetScript("OnLeave", function() flickerstreak@1: StartCounting(self, editBoxFrame.level) flickerstreak@1: GameTooltip:Hide() flickerstreak@1: end) flickerstreak@1: editBoxFrame:SetScript("OnKeyDown", function() flickerstreak@1: if not editBox.keybinding then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: local arg1 = arg1 flickerstreak@1: local screenshotKey = GetBindingKey("SCREENSHOT") flickerstreak@1: if screenshotKey and arg1 == screenshotKey then flickerstreak@1: Screenshot() flickerstreak@1: return flickerstreak@1: end flickerstreak@1: flickerstreak@1: if arg1 == "LeftButton" then flickerstreak@1: arg1 = "BUTTON1" flickerstreak@1: elseif arg1 == "RightButton" then flickerstreak@1: arg1 = "BUTTON2" flickerstreak@1: elseif arg1 == "MiddleButton" then flickerstreak@1: arg1 = "BUTTON3" flickerstreak@1: elseif arg1 == "Button4" then flickerstreak@1: arg1 = "BUTTON4" flickerstreak@1: elseif arg1 == "Button5" then flickerstreak@1: arg1 = "BUTTON5" flickerstreak@1: end flickerstreak@1: if arg1 == "BUTTON1" or arg1 == "BUTTON2" or arg1 == "UNKNOWN" then flickerstreak@1: return flickerstreak@1: elseif arg1 == "SHIFT" or arg1 == "CTRL" or arg1 == "ALT" then flickerstreak@1: return flickerstreak@1: elseif arg1 == "ENTER" then flickerstreak@1: return editBox:GetScript("OnEnterPressed")() flickerstreak@1: elseif arg1 == "ESCAPE" then flickerstreak@1: if editBox.realText == "NONE" then flickerstreak@1: return editBox:GetScript("OnEscapePressed")() flickerstreak@1: else flickerstreak@1: editBox:SpecialSetText(NONE or "NONE") flickerstreak@1: editBox.realText = "NONE" flickerstreak@1: return flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local s = GetBindingText(arg1, "KEY_") flickerstreak@1: local real = arg1 flickerstreak@1: if IsShiftKeyDown() then flickerstreak@1: s = "SHIFT-" .. s flickerstreak@1: real = "SHIFT-" .. real flickerstreak@1: end flickerstreak@1: if IsControlKeyDown() then flickerstreak@1: s = "CTRL-" .. s flickerstreak@1: real = "CTRL-" .. real flickerstreak@1: end flickerstreak@1: if IsAltKeyDown() then flickerstreak@1: s = "ALT-" .. s flickerstreak@1: real = "ALT-" .. real flickerstreak@1: end flickerstreak@1: if editBox:GetText() ~= s then flickerstreak@1: editBox:SpecialSetText(s) flickerstreak@1: editBox.realText = real flickerstreak@1: return editBox:GetScript("OnTextChanged")() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: editBoxFrame:SetScript("OnMouseDown", editBoxFrame:GetScript("OnKeyDown")) flickerstreak@1: editBox:SetScript("OnMouseDown", editBoxFrame:GetScript("OnKeyDown")) flickerstreak@1: end flickerstreak@1: editBoxFrame.parent = parent flickerstreak@1: editBoxFrame.level = parent.level.num + 1 flickerstreak@1: editBoxFrame.parentValue = parent.level.value flickerstreak@1: editBoxFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3) flickerstreak@1: editBoxFrame.editBox:SetFrameLevel(editBoxFrame:GetFrameLevel() + 1) flickerstreak@1: editBoxFrame.editBox.realText = nil flickerstreak@1: editBoxFrame:SetClampedToScreen(false) flickerstreak@1: flickerstreak@1: if parent.editBoxIsKeybinding then flickerstreak@1: local s = parent.editBoxText flickerstreak@1: editBoxFrame.editBox.realText = s flickerstreak@1: if s and s ~= "" then flickerstreak@1: local alpha,bravo = s:match("^(.+)%-(.+)$") flickerstreak@1: if not bravo then flickerstreak@1: alpha = nil flickerstreak@1: bravo = s flickerstreak@1: end flickerstreak@1: bravo = GetBindingText(bravo, "KEY_") flickerstreak@1: if alpha then flickerstreak@1: editBoxFrame.editBox:SpecialSetText(alpha:upper() .. "-" .. bravo) flickerstreak@1: else flickerstreak@1: editBoxFrame.editBox:SpecialSetText(bravo) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: editBoxFrame.editBox:SpecialSetText(NONE or "NONE") flickerstreak@1: end flickerstreak@1: else flickerstreak@1: editBoxFrame.editBox:SpecialSetText(parent.editBoxText) flickerstreak@1: end flickerstreak@1: flickerstreak@1: editBoxFrame.editBox.keybinding = parent.editBoxIsKeybinding flickerstreak@1: editBoxFrame.editBox:EnableKeyboard(not parent.editBoxIsKeybinding) flickerstreak@1: editBoxFrame:EnableKeyboard(parent.editBoxIsKeybinding) flickerstreak@1: flickerstreak@1: if parent.arrow then flickerstreak@1: -- parent.arrow:SetVertexColor(0.2, 0.6, 0) flickerstreak@1: -- parent.arrow:SetHeight(24) flickerstreak@1: -- parent.arrow:SetWidth(24) flickerstreak@1: parent.selected = true flickerstreak@1: parent.highlight:Show() flickerstreak@1: end flickerstreak@1: flickerstreak@1: local level = parent.level flickerstreak@1: editBoxFrame:Show() flickerstreak@1: editBoxFrame:ClearAllPoints() flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@1: else flickerstreak@1: editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@1: else flickerstreak@1: editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local dirty flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if editBoxFrame:GetRight() > GetScreenWidth() then flickerstreak@1: level.lastDirection = "LEFT" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: elseif editBoxFrame:GetLeft() < 0 then flickerstreak@1: level.lastDirection = "RIGHT" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: if editBoxFrame:GetBottom() < 0 then flickerstreak@1: level.lastVDirection = "UP" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: elseif editBoxFrame:GetTop() > GetScreenWidth() then flickerstreak@1: level.lastVDirection = "DOWN" flickerstreak@1: dirty = true flickerstreak@1: end flickerstreak@1: if dirty then flickerstreak@1: editBoxFrame:ClearAllPoints() flickerstreak@1: if level.lastDirection == "RIGHT" then flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@1: else flickerstreak@1: editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if level.lastVDirection == "DOWN" then flickerstreak@1: editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@1: else flickerstreak@1: editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local left, bottom = editBoxFrame:GetLeft(), editBoxFrame:GetBottom() flickerstreak@1: editBoxFrame:ClearAllPoints() flickerstreak@1: editBoxFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@1: if mod(level.num, 5) == 0 then flickerstreak@1: local left, bottom = level:GetLeft(), level:GetBottom() flickerstreak@1: level:ClearAllPoints() flickerstreak@1: level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@1: end flickerstreak@1: editBoxFrame:SetClampedToScreen(true) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:IsOpen(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "nil") flickerstreak@1: return levels[1] and levels[1]:IsShown() and (not parent or parent == levels[1].parent or parent == levels[1]:GetParent()) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:GetOpenedParent() flickerstreak@1: return (levels[1] and levels[1]:IsShown()) and (levels[1].parent or levels[1]:GetParent()) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Open(self, parent, func, level, value, point, relativePoint, cursorX, cursorY) flickerstreak@1: self:Close(level) flickerstreak@1: if DewdropLib then flickerstreak@1: local d = DewdropLib:GetInstance('1.0') flickerstreak@1: local ret, val = pcall(d, IsOpen, d) flickerstreak@1: if ret and val then flickerstreak@1: DewdropLib:GetInstance('1.0'):Close() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: parent:GetCenter() flickerstreak@1: local frame = AcquireLevel(self, level) flickerstreak@1: if level == 1 then flickerstreak@1: frame.lastDirection = "RIGHT" flickerstreak@1: frame.lastVDirection = "DOWN" flickerstreak@1: else flickerstreak@1: frame.lastDirection = levels[level - 1].lastDirection flickerstreak@1: frame.lastVDirection = levels[level - 1].lastVDirection flickerstreak@1: end flickerstreak@1: frame:SetClampedToScreen(false) flickerstreak@1: frame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@1: frame:ClearAllPoints() flickerstreak@1: frame.parent = parent flickerstreak@1: frame:SetPoint("LEFT", UIParent, "RIGHT", 10000, 0) flickerstreak@1: frame:Show() flickerstreak@1: if level == 1 then flickerstreak@1: baseFunc = func flickerstreak@1: end flickerstreak@1: levels[level].value = value flickerstreak@1: -- levels[level].parentText = parent.text and parent.text:GetText() or nil flickerstreak@1: -- levels[level].parentTooltipTitle = parent.tooltipTitle flickerstreak@1: -- levels[level].parentTooltipText = parent.tooltipText flickerstreak@1: -- levels[level].parentTooltipFunc = parent.tooltipFunc flickerstreak@1: if parent.arrow then flickerstreak@1: -- parent.arrow:SetVertexColor(0.2, 0.6, 0) flickerstreak@1: -- parent.arrow:SetHeight(24) flickerstreak@1: -- parent.arrow:SetWidth(24) flickerstreak@1: parent.selected = true flickerstreak@1: parent.highlight:Show() flickerstreak@1: end flickerstreak@1: relativePoint = relativePoint or point flickerstreak@1: Refresh(self, levels[level]) flickerstreak@1: if point or (cursorX and cursorY) then flickerstreak@1: frame:ClearAllPoints() flickerstreak@1: if cursorX and cursorY then flickerstreak@1: local curX, curY = GetScaledCursorPosition() flickerstreak@1: if curY < GetScreenHeight() / 2 then flickerstreak@1: point, relativePoint = "BOTTOM", "BOTTOM" flickerstreak@1: else flickerstreak@1: point, relativePoint = "TOP", "TOP" flickerstreak@1: end flickerstreak@1: if curX < GetScreenWidth() / 2 then flickerstreak@1: point, relativePoint = point .. "LEFT", relativePoint .. "RIGHT" flickerstreak@1: else flickerstreak@1: point, relativePoint = point .. "RIGHT", relativePoint .. "LEFT" flickerstreak@1: end flickerstreak@1: end flickerstreak@1: frame:SetPoint(point, parent, relativePoint) flickerstreak@1: if cursorX and cursorY then flickerstreak@1: local left = frame:GetLeft() flickerstreak@1: local width = frame:GetWidth() flickerstreak@1: local bottom = frame:GetBottom() flickerstreak@1: local height = frame:GetHeight() flickerstreak@1: local curX, curY = GetScaledCursorPosition() flickerstreak@1: frame:ClearAllPoints() flickerstreak@1: relativePoint = relativePoint or point flickerstreak@1: if point == "BOTTOM" or point == "TOP" then flickerstreak@1: if curX < GetScreenWidth() / 2 then flickerstreak@1: point = point .. "LEFT" flickerstreak@1: else flickerstreak@1: point = point .. "RIGHT" flickerstreak@1: end flickerstreak@1: elseif point == "CENTER" then flickerstreak@1: if curX < GetScreenWidth() / 2 then flickerstreak@1: point = "LEFT" flickerstreak@1: else flickerstreak@1: point = "RIGHT" flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local xOffset, yOffset = 0, 0 flickerstreak@1: if curY > GetScreenHeight() / 2 then flickerstreak@1: yOffset = -height flickerstreak@1: end flickerstreak@1: if curX > GetScreenWidth() / 2 then flickerstreak@1: xOffset = -width flickerstreak@1: end flickerstreak@1: frame:SetPoint(point, parent, relativePoint, curX - left + xOffset, curY - bottom + yOffset) flickerstreak@1: if level == 1 then flickerstreak@1: frame.lastDirection = "RIGHT" flickerstreak@1: end flickerstreak@1: elseif cursorX then flickerstreak@1: local left = frame:GetLeft() flickerstreak@1: local width = frame:GetWidth() flickerstreak@1: local curX, curY = GetScaledCursorPosition() flickerstreak@1: frame:ClearAllPoints() flickerstreak@1: relativePoint = relativePoint or point flickerstreak@1: if point == "BOTTOM" or point == "TOP" then flickerstreak@1: if curX < GetScreenWidth() / 2 then flickerstreak@1: point = point .. "LEFT" flickerstreak@1: else flickerstreak@1: point = point .. "RIGHT" flickerstreak@1: end flickerstreak@1: elseif point == "CENTER" then flickerstreak@1: if curX < GetScreenWidth() / 2 then flickerstreak@1: point = "LEFT" flickerstreak@1: else flickerstreak@1: point = "RIGHT" flickerstreak@1: end flickerstreak@1: end flickerstreak@1: frame:SetPoint(point, parent, relativePoint, curX - left - width / 2, 0) flickerstreak@1: if level == 1 then flickerstreak@1: frame.lastDirection = "RIGHT" flickerstreak@1: end flickerstreak@1: elseif cursorY then flickerstreak@1: local bottom = frame:GetBottom() flickerstreak@1: local height = frame:GetHeight() flickerstreak@1: local curX, curY = GetScaledCursorPosition() flickerstreak@1: frame:ClearAllPoints() flickerstreak@1: relativePoint = relativePoint or point flickerstreak@1: if point == "LEFT" or point == "RIGHT" then flickerstreak@1: if curX < GetScreenHeight() / 2 then flickerstreak@1: point = point .. "BOTTOM" flickerstreak@1: else flickerstreak@1: point = point .. "TOP" flickerstreak@1: end flickerstreak@1: elseif point == "CENTER" then flickerstreak@1: if curX < GetScreenHeight() / 2 then flickerstreak@1: point = "BOTTOM" flickerstreak@1: else flickerstreak@1: point = "TOP" flickerstreak@1: end flickerstreak@1: end flickerstreak@1: frame:SetPoint(point, parent, relativePoint, 0, curY - bottom - height / 2) flickerstreak@1: if level == 1 then flickerstreak@1: frame.lastDirection = "DOWN" flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if (strsub(point, 1, 3) ~= strsub(relativePoint, 1, 3)) then flickerstreak@1: if frame:GetBottom() < 0 then flickerstreak@1: local point, parent, relativePoint, x, y = frame:GetPoint(1) flickerstreak@1: local change = GetScreenHeight() - frame:GetTop() flickerstreak@1: local otherChange = -frame:GetBottom() flickerstreak@1: if otherChange < change then flickerstreak@1: change = otherChange flickerstreak@1: end flickerstreak@1: frame:SetPoint(point, parent, relativePoint, x, y + change) flickerstreak@1: elseif frame:GetTop() > GetScreenHeight() then flickerstreak@1: local point, parent, relativePoint, x, y = frame:GetPoint(1) flickerstreak@1: local change = GetScreenHeight() - frame:GetTop() flickerstreak@1: local otherChange = -frame:GetBottom() flickerstreak@1: if otherChange < change then flickerstreak@1: change = otherChange flickerstreak@1: end flickerstreak@1: frame:SetPoint(point, parent, relativePoint, x, y + change) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: CheckDualMonitor(self, frame) flickerstreak@1: frame:SetClampedToScreen(true) flickerstreak@1: StartCounting(self, level) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:IsRegistered(parent) flickerstreak@1: self:argCheck(parent, 2, "table") flickerstreak@1: return not not self.registry[parent] flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:Register(parent, ...) flickerstreak@1: self:argCheck(parent, 2, "table") flickerstreak@1: if self.registry[parent] then flickerstreak@1: self:Unregister(parent) flickerstreak@1: end flickerstreak@1: local info = new(...) flickerstreak@1: if type(info.children) == "table" then flickerstreak@1: local err, position = validateOptions(info.children) flickerstreak@1: flickerstreak@1: if err then flickerstreak@1: if position then flickerstreak@1: Dewdrop:error(position .. ": " .. err) flickerstreak@1: else flickerstreak@1: Dewdrop:error(err) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self.registry[parent] = info flickerstreak@1: if not info.dontHook and not self.onceRegistered[parent] then flickerstreak@1: if parent:HasScript("OnMouseUp") then flickerstreak@1: local script = parent:GetScript("OnMouseUp") flickerstreak@1: parent:SetScript("OnMouseUp", function() flickerstreak@1: if script then flickerstreak@1: script() flickerstreak@1: end flickerstreak@1: if arg1 == "RightButton" and self.registry[parent] then flickerstreak@1: if self:IsOpen(parent) then flickerstreak@1: self:Close() flickerstreak@1: else flickerstreak@1: self:Open(parent) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: end flickerstreak@1: if parent:HasScript("OnMouseDown") then flickerstreak@1: local script = parent:GetScript("OnMouseDown") flickerstreak@1: parent:SetScript("OnMouseDown", function() flickerstreak@1: if script then flickerstreak@1: script() flickerstreak@1: end flickerstreak@1: if self.registry[parent] then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self.onceRegistered[parent] = true flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:Unregister(parent) flickerstreak@1: self:argCheck(parent, 2, "table") flickerstreak@1: self.registry[parent] = nil flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:Open(parent, ...) flickerstreak@1: self:argCheck(parent, 2, "table") flickerstreak@1: local info flickerstreak@1: local k1 = ... flickerstreak@1: if type(k1) == "table" and k1[0] and k1.IsFrameType and self.registry[k1] then flickerstreak@1: info = tmp() flickerstreak@1: for k,v in pairs(self.registry[k1]) do flickerstreak@1: info[k] = v flickerstreak@1: end flickerstreak@1: else flickerstreak@1: info = tmp(...) flickerstreak@1: if self.registry[parent] then flickerstreak@1: for k,v in pairs(self.registry[parent]) do flickerstreak@1: if info[k] == nil then flickerstreak@1: info[k] = v flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local point = info.point flickerstreak@1: local relativePoint = info.relativePoint flickerstreak@1: local cursorX = info.cursorX flickerstreak@1: local cursorY = info.cursorY flickerstreak@1: if type(point) == "function" then flickerstreak@1: local b flickerstreak@1: point, b = point(parent) flickerstreak@1: if b then flickerstreak@1: relativePoint = b flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if type(relativePoint) == "function" then flickerstreak@1: relativePoint = relativePoint(parent) flickerstreak@1: end flickerstreak@1: Open(self, parent, info.children, 1, nil, point, relativePoint, cursorX, cursorY) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Clear(self, level) flickerstreak@1: if level then flickerstreak@1: if level.buttons then flickerstreak@1: for i = #level.buttons, 1, -1 do flickerstreak@1: ReleaseButton(self, level, i) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:Close(level) flickerstreak@1: if DropDownList1:IsShown() then flickerstreak@1: DropDownList1:Hide() flickerstreak@1: end flickerstreak@1: if DewdropLib then flickerstreak@1: local d = DewdropLib:GetInstance('1.0') flickerstreak@1: local ret, val = pcall(d, IsOpen, d) flickerstreak@1: if ret and val then flickerstreak@1: DewdropLib:GetInstance('1.0'):Close() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self:argCheck(level, 2, "number", "nil") flickerstreak@1: if not level then flickerstreak@1: level = 1 flickerstreak@1: end flickerstreak@1: if level == 1 and levels[level] then flickerstreak@1: levels[level].parented = false flickerstreak@1: end flickerstreak@1: if level > 1 and levels[level-1].buttons then flickerstreak@1: local buttons = levels[level-1].buttons flickerstreak@1: for _,button in ipairs(buttons) do flickerstreak@1: -- button.arrow:SetWidth(16) flickerstreak@1: -- button.arrow:SetHeight(16) flickerstreak@1: button.selected = nil flickerstreak@1: button.highlight:Hide() flickerstreak@1: -- button.arrow:SetVertexColor(1, 1, 1) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if sliderFrame and sliderFrame.level >= level then flickerstreak@1: sliderFrame:Hide() flickerstreak@1: end flickerstreak@1: if editBoxFrame and editBoxFrame.level >= level then flickerstreak@1: editBoxFrame:Hide() flickerstreak@1: end flickerstreak@1: for i = level, #levels do flickerstreak@1: Clear(self, levels[level]) flickerstreak@1: levels[i]:Hide() flickerstreak@1: levels[i]:ClearAllPoints() flickerstreak@1: levels[i]:SetPoint("CENTER", UIParent, "CENTER") flickerstreak@1: levels[i].value = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:AddLine(...) flickerstreak@1: local info = tmp(...) flickerstreak@1: local level = info.level or currentLevel flickerstreak@1: info.level = nil flickerstreak@1: local button = AcquireButton(self, level) flickerstreak@1: if not next(info) then flickerstreak@1: info.disabled = true flickerstreak@1: end flickerstreak@1: button.disabled = info.isTitle or info.notClickable or info.disabled flickerstreak@1: button.isTitle = info.isTitle flickerstreak@1: button.notClickable = info.notClickable flickerstreak@1: if button.isTitle then flickerstreak@1: button.text:SetFontObject(GameFontNormalSmall) flickerstreak@1: elseif button.notClickable then flickerstreak@1: button.text:SetFontObject(GameFontHighlightSmall) flickerstreak@1: elseif button.disabled then flickerstreak@1: button.text:SetFontObject(GameFontDisableSmall) flickerstreak@1: else flickerstreak@1: button.text:SetFontObject(GameFontHighlightSmall) flickerstreak@1: end flickerstreak@1: if info.disabled then flickerstreak@1: button.arrow:SetDesaturated(true) flickerstreak@1: button.check:SetDesaturated(true) flickerstreak@1: else flickerstreak@1: button.arrow:SetDesaturated(false) flickerstreak@1: button.check:SetDesaturated(false) flickerstreak@1: end flickerstreak@1: if info.textR and info.textG and info.textB then flickerstreak@1: button.textR = info.textR flickerstreak@1: button.textG = info.textG flickerstreak@1: button.textB = info.textB flickerstreak@1: button.text:SetTextColor(button.textR, button.textG, button.textB) flickerstreak@1: else flickerstreak@1: button.text:SetTextColor(button.text:GetFontObject():GetTextColor()) flickerstreak@1: end flickerstreak@1: button.notCheckable = info.notCheckable flickerstreak@1: button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0) flickerstreak@1: button.checked = not info.notCheckable and info.checked flickerstreak@1: button.isRadio = not info.notCheckable and info.isRadio flickerstreak@1: if info.isRadio then flickerstreak@1: button.check:Show() flickerstreak@1: button.check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton") flickerstreak@1: if button.checked then flickerstreak@1: button.check:SetTexCoord(0.25, 0.5, 0, 1) flickerstreak@1: button.check:SetVertexColor(1, 1, 1, 1) flickerstreak@1: else flickerstreak@1: button.check:SetTexCoord(0, 0.25, 0, 1) flickerstreak@1: button.check:SetVertexColor(1, 1, 1, 0.5) flickerstreak@1: end flickerstreak@1: button.radioHighlight:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton") flickerstreak@1: button.check:SetWidth(16) flickerstreak@1: button.check:SetHeight(16) flickerstreak@1: elseif info.icon then flickerstreak@1: button.check:Show() flickerstreak@1: button.check:SetTexture(info.icon) flickerstreak@1: if info.iconWidth and info.iconHeight then flickerstreak@1: button.check:SetWidth(info.iconWidth) flickerstreak@1: button.check:SetHeight(info.iconHeight) flickerstreak@1: else flickerstreak@1: button.check:SetWidth(16) flickerstreak@1: button.check:SetHeight(16) flickerstreak@1: end flickerstreak@1: if info.iconCoordLeft and info.iconCoordRight and info.iconCoordTop and info.iconCoordBottom then flickerstreak@1: button.check:SetTexCoord(info.iconCoordLeft, info.iconCoordRight, info.iconCoordTop, info.iconCoordBottom) flickerstreak@1: elseif info.icon:find("^Interface\\Icons\\") then flickerstreak@1: button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95) flickerstreak@1: else flickerstreak@1: button.check:SetTexCoord(0, 1, 0, 1) flickerstreak@1: end flickerstreak@1: button.check:SetVertexColor(1, 1, 1, 1) flickerstreak@1: else flickerstreak@1: if button.checked then flickerstreak@1: if info.checkIcon then flickerstreak@1: button.check:SetWidth(16) flickerstreak@1: button.check:SetHeight(16) flickerstreak@1: button.check:SetTexture(info.checkIcon) flickerstreak@1: if info.checkIcon:find("^Interface\\Icons\\") then flickerstreak@1: button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95) flickerstreak@1: else flickerstreak@1: button.check:SetTexCoord(0, 1, 0, 1) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: button.check:SetWidth(24) flickerstreak@1: button.check:SetHeight(24) flickerstreak@1: button.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") flickerstreak@1: button.check:SetTexCoord(0, 1, 0, 1) flickerstreak@1: end flickerstreak@1: button.check:SetVertexColor(1, 1, 1, 1) flickerstreak@1: else flickerstreak@1: button.check:SetVertexColor(1, 1, 1, 0) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not button.disabled then flickerstreak@1: button.func = info.func flickerstreak@1: end flickerstreak@1: button.hasColorSwatch = info.hasColorSwatch flickerstreak@1: if button.hasColorSwatch then flickerstreak@1: button.colorSwatch:Show() flickerstreak@1: button.colorSwatch.texture:Show() flickerstreak@1: button.r = info.r or 1 flickerstreak@1: button.g = info.g or 1 flickerstreak@1: button.b = info.b or 1 flickerstreak@1: button.colorSwatch.texture:SetTexture(button.r, button.g, button.b) flickerstreak@1: button.checked = false flickerstreak@1: button.func = nil flickerstreak@1: button.colorFunc = info.colorFunc flickerstreak@1: button.colorArg1 = info.colorArg1 flickerstreak@1: button.colorArg2 = info.colorArg2 flickerstreak@1: button.colorArg3 = info.colorArg3 flickerstreak@1: button.colorArg4 = info.colorArg4 flickerstreak@1: button.hasOpacity = info.hasOpacity flickerstreak@1: button.opacity = info.opacity or 1 flickerstreak@1: else flickerstreak@1: button.colorSwatch:Hide() flickerstreak@1: button.colorSwatch.texture:Hide() flickerstreak@1: end flickerstreak@1: button.hasArrow = not button.hasColorSwatch and (info.value or info.hasSlider or info.hasEditBox) and info.hasArrow flickerstreak@1: if button.hasArrow then flickerstreak@1: button.arrow:SetAlpha(1) flickerstreak@1: if info.hasSlider then flickerstreak@1: button.hasSlider = true flickerstreak@1: button.sliderMin = info.sliderMin or 0 flickerstreak@1: button.sliderMax = info.sliderMax or 1 flickerstreak@1: button.sliderStep = info.sliderStep or 0 flickerstreak@1: button.sliderIsPercent = info.sliderIsPercent and true or false flickerstreak@1: button.sliderMinText = info.sliderMinText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMin * 100) or button.sliderMin flickerstreak@1: button.sliderMaxText = info.sliderMaxText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMax * 100) or button.sliderMax flickerstreak@1: button.sliderFunc = info.sliderFunc flickerstreak@1: button.sliderValue = info.sliderValue flickerstreak@1: button.sliderArg1 = info.sliderArg1 flickerstreak@1: button.sliderArg2 = info.sliderArg2 flickerstreak@1: button.sliderArg3 = info.sliderArg3 flickerstreak@1: button.sliderArg4 = info.sliderArg4 flickerstreak@1: elseif info.hasEditBox then flickerstreak@1: button.hasEditBox = true flickerstreak@1: button.editBoxText = info.editBoxText or "" flickerstreak@1: button.editBoxFunc = info.editBoxFunc flickerstreak@1: button.editBoxArg1 = info.editBoxArg1 flickerstreak@1: button.editBoxArg2 = info.editBoxArg2 flickerstreak@1: button.editBoxArg3 = info.editBoxArg3 flickerstreak@1: button.editBoxArg4 = info.editBoxArg4 flickerstreak@1: button.editBoxChangeFunc = info.editBoxChangeFunc flickerstreak@1: button.editBoxChangeArg1 = info.editBoxChangeArg1 flickerstreak@1: button.editBoxChangeArg2 = info.editBoxChangeArg2 flickerstreak@1: button.editBoxChangeArg3 = info.editBoxChangeArg3 flickerstreak@1: button.editBoxChangeArg4 = info.editBoxChangeArg4 flickerstreak@1: button.editBoxValidateFunc = info.editBoxValidateFunc flickerstreak@1: button.editBoxValidateArg1 = info.editBoxValidateArg1 flickerstreak@1: button.editBoxValidateArg2 = info.editBoxValidateArg2 flickerstreak@1: button.editBoxValidateArg3 = info.editBoxValidateArg3 flickerstreak@1: button.editBoxValidateArg4 = info.editBoxValidateArg4 flickerstreak@1: button.editBoxIsKeybinding = info.editBoxIsKeybinding flickerstreak@1: else flickerstreak@1: button.value = info.value flickerstreak@1: local l = levels[level+1] flickerstreak@1: if l and info.value == l.value then flickerstreak@1: -- button.arrow:SetWidth(24) flickerstreak@1: -- button.arrow:SetHeight(24) flickerstreak@1: button.selected = true flickerstreak@1: button.highlight:Show() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: button.arrow:SetAlpha(0) flickerstreak@1: end flickerstreak@1: button.arg1 = info.arg1 flickerstreak@1: button.arg2 = info.arg2 flickerstreak@1: button.arg3 = info.arg3 flickerstreak@1: button.arg4 = info.arg4 flickerstreak@1: button.closeWhenClicked = info.closeWhenClicked flickerstreak@1: button.textHeight = info.textHeight or UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT or 10 flickerstreak@1: local font,_ = button.text:GetFont() flickerstreak@1: button.text:SetFont(STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF", button.textHeight) flickerstreak@1: button:SetHeight(button.textHeight + 6) flickerstreak@1: button.text:SetPoint("RIGHT", button.arrow, (button.hasColorSwatch or button.hasArrow) and "LEFT" or "RIGHT") flickerstreak@1: button.text:SetJustifyH(info.justifyH or "LEFT") flickerstreak@1: button.text:SetText(info.text) flickerstreak@1: button.tooltipTitle = info.tooltipTitle flickerstreak@1: button.tooltipText = info.tooltipText flickerstreak@1: button.tooltipFunc = info.tooltipFunc flickerstreak@1: button.tooltipArg1 = info.tooltipArg1 flickerstreak@1: button.tooltipArg2 = info.tooltipArg2 flickerstreak@1: button.tooltipArg3 = info.tooltipArg3 flickerstreak@1: button.tooltipArg4 = info.tooltipArg4 flickerstreak@1: if not button.tooltipTitle and not button.tooltipText and not button.tooltipFunc and not info.isTitle then flickerstreak@1: button.tooltipTitle = info.text flickerstreak@1: end flickerstreak@1: if type(button.func) == "string" then flickerstreak@1: self:assert(type(button.arg1) == "table", "Cannot call method " .. button.func .. " on a non-table") flickerstreak@1: self:assert(type(button.arg1[button.func]) == "function", "Method " .. button.func .. " nonexistant.") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Dewdrop:InjectAceOptionsTable(handler, options) flickerstreak@1: self:argCheck(handler, 2, "table") flickerstreak@1: self:argCheck(options, 3, "table") flickerstreak@1: if tostring(options.type):lower() ~= "group" then flickerstreak@1: self:error('Cannot inject into options table argument #3 if its type is not "group"') flickerstreak@1: end flickerstreak@1: if options.handler ~= nil and options.handler ~= handler then flickerstreak@1: self:error("Cannot inject into options table argument #3 if it has a different handler than argument #2") flickerstreak@1: end flickerstreak@1: options.handler = handler flickerstreak@1: local class = handler.class flickerstreak@1: if not AceLibrary:HasInstance("AceOO-2.0") or not class then flickerstreak@1: self:error("Cannot retrieve AceOptions tables from a non-object argument #2") flickerstreak@1: end flickerstreak@1: while class and class ~= AceLibrary("AceOO-2.0").Class do flickerstreak@1: if type(class.GetAceOptionsDataTable) == "function" then flickerstreak@1: local t = class:GetAceOptionsDataTable(handler) flickerstreak@1: for k,v in pairs(t) do flickerstreak@1: if type(options.args) ~= "table" then flickerstreak@1: options.args = {} flickerstreak@1: end flickerstreak@1: if options.args[k] == nil then flickerstreak@1: options.args[k] = v flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local mixins = class.mixins flickerstreak@1: if mixins then flickerstreak@1: for mixin in pairs(mixins) do flickerstreak@1: if type(mixin.GetAceOptionsDataTable) == "function" then flickerstreak@1: local t = mixin:GetAceOptionsDataTable(handler) flickerstreak@1: for k,v in pairs(t) do flickerstreak@1: if type(options.args) ~= "table" then flickerstreak@1: options.args = {} flickerstreak@1: end flickerstreak@1: if options.args[k] == nil then flickerstreak@1: options.args[k] = v flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: class = class.super flickerstreak@1: end flickerstreak@1: return options flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function activate(self, oldLib, oldDeactivate) flickerstreak@1: Dewdrop = self flickerstreak@1: if oldLib and oldLib.registry then flickerstreak@1: self.registry = oldLib.registry flickerstreak@1: self.onceRegistered = oldLib.onceRegistered flickerstreak@1: else flickerstreak@1: self.registry = {} flickerstreak@1: self.onceRegistered = {} flickerstreak@1: flickerstreak@1: local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown") flickerstreak@1: local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp") flickerstreak@1: local oldX, oldY, clickTime flickerstreak@1: WorldFrame:SetScript("OnMouseDown", function() flickerstreak@1: oldX,oldY = GetCursorPosition() flickerstreak@1: clickTime = GetTime() flickerstreak@1: if WorldFrame_OnMouseDown then flickerstreak@1: WorldFrame_OnMouseDown() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: flickerstreak@1: WorldFrame:SetScript("OnMouseUp", function() flickerstreak@1: local x,y = GetCursorPosition() flickerstreak@1: if not oldX or not oldY or not x or not y or not clickTime then flickerstreak@1: self:Close() flickerstreak@1: if WorldFrame_OnMouseUp then flickerstreak@1: WorldFrame_OnMouseUp() flickerstreak@1: end flickerstreak@1: return flickerstreak@1: end flickerstreak@1: local d = math.abs(x - oldX) + math.abs(y - oldY) flickerstreak@1: if d <= 5 and GetTime() - clickTime < 0.5 then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: if WorldFrame_OnMouseUp then flickerstreak@1: WorldFrame_OnMouseUp() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: flickerstreak@1: if hooksecurefunc then flickerstreak@1: hooksecurefunc(DropDownList1, "Show", function() flickerstreak@1: if levels[1] and levels[1]:IsVisible() then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: else flickerstreak@1: local DropDownList1_Show = DropDownList1.Show flickerstreak@1: function DropDownList1.Show(DropDownList1) flickerstreak@1: if levels[1] and levels[1]:IsVisible() then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: DropDownList1_Show(DropDownList1) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: if hooksecurefunc then flickerstreak@1: hooksecurefunc("HideDropDownMenu", function() flickerstreak@1: if levels[1] and levels[1]:IsVisible() then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: else flickerstreak@1: local old_HideDropDownMenu = HideDropDownMenu flickerstreak@1: function HideDropDownMenu(num) flickerstreak@1: if levels[1] and levels[1]:IsVisible() then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: old_HideDropDownMenu(num) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: if hooksecurefunc then flickerstreak@1: hooksecurefunc("CloseDropDownMenus", function() flickerstreak@1: if levels[1] and levels[1]:IsVisible() then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: else flickerstreak@1: local old_CloseDropDownMenus = CloseDropDownMenus flickerstreak@1: function CloseDropDownMenus(num) flickerstreak@1: if levels[1] and levels[1]:IsVisible() then flickerstreak@1: self:Close() flickerstreak@1: end flickerstreak@1: old_CloseDropDownMenus(num) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: levels = {} flickerstreak@1: buttons = {} flickerstreak@1: flickerstreak@1: if oldDeactivate then flickerstreak@1: oldDeactivate(oldLib) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate)