flickerstreak@28: --[[ flickerstreak@28: Name: Dewdrop-2.0 flickerstreak@28: Revision: $Rev: 48630 $ flickerstreak@28: Author(s): ckknight (ckknight@gmail.com) flickerstreak@28: Website: http://ckknight.wowinterface.com/ flickerstreak@28: Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0 flickerstreak@28: SVN: http://svn.wowace.com/root/trunk/DewdropLib/Dewdrop-2.0 flickerstreak@28: Description: A library to provide a clean dropdown menu interface. flickerstreak@28: Dependencies: AceLibrary flickerstreak@28: License: LGPL v2.1 flickerstreak@28: ]] flickerstreak@28: flickerstreak@28: local MAJOR_VERSION = "Dewdrop-2.0" flickerstreak@28: local MINOR_VERSION = "$Revision: 48630 $" flickerstreak@28: flickerstreak@28: if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end flickerstreak@28: if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end flickerstreak@28: flickerstreak@28: local Dewdrop = {} flickerstreak@28: flickerstreak@28: local SharedMedia flickerstreak@28: flickerstreak@28: local CLOSE = "Close" flickerstreak@28: local CLOSE_DESC = "Close the menu." flickerstreak@28: local VALIDATION_ERROR = "Validation error." flickerstreak@28: local USAGE_TOOLTIP = "Usage: %s." flickerstreak@28: local RANGE_TOOLTIP = "Note that you can scroll your mouse wheel while over the slider to step by one." flickerstreak@28: local RESET_KEYBINDING_DESC = "Hit escape to clear the keybinding." flickerstreak@28: local KEY_BUTTON1 = "Left Mouse" flickerstreak@28: local KEY_BUTTON2 = "Right Mouse" flickerstreak@28: local DISABLED = "Disabled" flickerstreak@28: local DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?" flickerstreak@28: flickerstreak@28: if GetLocale() == "deDE" then flickerstreak@28: CLOSE = "Schlie\195\159en" flickerstreak@28: CLOSE_DESC = "Men\195\188 schlie\195\159en." flickerstreak@28: VALIDATION_ERROR = "Validierungsfehler." flickerstreak@28: USAGE_TOOLTIP = "Benutzung: %s." flickerstreak@28: RANGE_TOOLTIP = "Beachte das du mit dem Mausrad scrollen kannst solange du \195\188ber dem Schieberegler bist, um 10er Spr\195\188nge zu machen." flickerstreak@28: RESET_KEYBINDING_DESC = "Escape dr\195\188cken, um die Tastenbelegung zu l\195\182schen." flickerstreak@28: KEY_BUTTON1 = "Linke Maustaste" flickerstreak@28: KEY_BUTTON2 = "Rechte Maustaste" flickerstreak@28: DISABLED = "Deaktiviert" flickerstreak@28: DEFAULT_CONFIRM_MESSAGE = "Bist du sicher das du `%s' machen willst?" flickerstreak@28: elseif GetLocale() == "koKR" then flickerstreak@28: CLOSE = "닫기" flickerstreak@28: CLOSE_DESC = "메뉴를 닫습니다." flickerstreak@28: VALIDATION_ERROR = "오류 확인." flickerstreak@28: USAGE_TOOLTIP = "사용법: %s." flickerstreak@28: RANGE_TOOLTIP = "알림 : 슬라이더 위에서 마우스 휠을 사용하면 한단계씩 조절할 수 있습니다." flickerstreak@28: RESET_KEYBINDING_DESC = "단축키를 해제하려면 ESC키를 누르세요." flickerstreak@28: KEY_BUTTON1 = "왼쪽 마우스" flickerstreak@28: KEY_BUTTON2 = "오른쪽 마우스" flickerstreak@28: DISABLED = "비활성화됨" flickerstreak@28: DEFAULT_CONFIRM_MESSAGE = "정말로 `%s' 실행을 하시겠습니까 ?" flickerstreak@28: elseif GetLocale() == "frFR" then flickerstreak@28: CLOSE = "Fermer" flickerstreak@28: CLOSE_DESC = "Ferme le menu." flickerstreak@28: VALIDATION_ERROR = "Erreur de validation." flickerstreak@28: USAGE_TOOLTIP = "Utilisation : %s." flickerstreak@28: RANGE_TOOLTIP = "Vous pouvez aussi utiliser la molette de la souris pour pour modifier progressivement." flickerstreak@28: RESET_KEYBINDING_DESC = "Appuyez sur la touche Echappement pour effacer le raccourci." flickerstreak@28: KEY_BUTTON1 = "Clic gauche" flickerstreak@28: KEY_BUTTON2 = "Clic droit" flickerstreak@28: DISABLED = "D\195\169sactiv\195\169" flickerstreak@28: DEFAULT_CONFIRM_MESSAGE = "\195\138tes-vous s\195\187r de vouloir effectuer '%s' ?" flickerstreak@28: elseif GetLocale() == "esES" then flickerstreak@28: CLOSE = "Cerrar" flickerstreak@28: CLOSE_DESC = "Cierra el menú." flickerstreak@28: VALIDATION_ERROR = "Error de validación." flickerstreak@28: USAGE_TOOLTIP = "Uso: %s." flickerstreak@28: RANGE_TOOLTIP = "Puedes desplazarte verticalmente con la rueda del ratón sobre el desplazador." flickerstreak@28: RESET_KEYBINDING_DESC = "Pulsa Escape para borrar la asignación de tecla." flickerstreak@28: KEY_BUTTON1 = "Clic Izquierdo" flickerstreak@28: KEY_BUTTON2 = "Clic Derecho" flickerstreak@28: DISABLED = "Desactivado" flickerstreak@28: DEFAULT_CONFIRM_MESSAGE = "¿Estás seguro de querer realizar `%s'?" flickerstreak@28: elseif GetLocale() == "zhTW" then flickerstreak@28: CLOSE = "關閉" flickerstreak@28: CLOSE_DESC = "關閉選單。" flickerstreak@28: VALIDATION_ERROR = "驗證錯誤。" flickerstreak@28: USAGE_TOOLTIP = "用法: %s。" flickerstreak@28: RANGE_TOOLTIP = "你可以在捲動條上使用滑鼠滾輪來捲動。" flickerstreak@28: RESET_KEYBINDING_DESC = "按Esc鍵清除快捷鍵。" flickerstreak@28: KEY_BUTTON1 = "滑鼠左鍵" flickerstreak@28: KEY_BUTTON2 = "滑鼠右鍵" flickerstreak@28: DISABLED = "停用" flickerstreak@28: DEFAULT_CONFIRM_MESSAGE = "是否執行「%s」?" flickerstreak@28: elseif GetLocale() == "zhCN" then flickerstreak@28: CLOSE = "关闭" flickerstreak@28: CLOSE_DESC = "关闭菜单" flickerstreak@28: VALIDATION_ERROR = "验证错误." flickerstreak@28: USAGE_TOOLTIP = "用法: %s." flickerstreak@28: RANGE_TOOLTIP = "你可以在滚动条上使用鼠标滚轮来翻页." flickerstreak@28: RESET_KEYBINDING_DESC = "按ESC键清除按键绑定" flickerstreak@28: KEY_BUTTON1 = "鼠标左键" flickerstreak@28: KEY_BUTTON2 = "鼠标右键" flickerstreak@28: DISABLED = "禁用" flickerstreak@28: DEFAULT_CONFIRM_MESSAGE = "是否执行'%s'?" flickerstreak@28: end flickerstreak@28: flickerstreak@28: Dewdrop.KEY_BUTTON1 = KEY_BUTTON1 flickerstreak@28: Dewdrop.KEY_BUTTON2 = KEY_BUTTON2 flickerstreak@28: flickerstreak@28: local function new(...) flickerstreak@28: local t = {} flickerstreak@28: for i = 1, select('#', ...), 2 do flickerstreak@28: local k = select(i, ...) flickerstreak@28: if k then flickerstreak@28: t[k] = select(i+1, ...) flickerstreak@28: else flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: return t flickerstreak@28: end flickerstreak@28: flickerstreak@28: local tmp flickerstreak@28: do flickerstreak@28: local t = {} flickerstreak@28: function tmp(...) flickerstreak@28: for k in pairs(t) do flickerstreak@28: t[k] = nil flickerstreak@28: end flickerstreak@28: for i = 1, select('#', ...), 2 do flickerstreak@28: local k = select(i, ...) flickerstreak@28: if k then flickerstreak@28: t[k] = select(i+1, ...) flickerstreak@28: else flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: return t flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local tmp2 flickerstreak@28: do flickerstreak@28: local t = {} flickerstreak@28: function tmp2(...) flickerstreak@28: for k in pairs(t) do flickerstreak@28: t[k] = nil flickerstreak@28: end flickerstreak@28: for i = 1, select('#', ...), 2 do flickerstreak@28: local k = select(i, ...) flickerstreak@28: if k then flickerstreak@28: t[k] = select(i+1, ...) flickerstreak@28: else flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: return t flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local levels flickerstreak@28: local buttons flickerstreak@28: flickerstreak@28: flickerstreak@28: -- Secure frame handling: flickerstreak@28: -- Rather than using secure buttons in the menu (has problems), we have one flickerstreak@28: -- master secureframe that we pop onto menu items on mouseover. This requires flickerstreak@28: -- some dark magic with OnLeave etc, but it's not too bad. flickerstreak@28: flickerstreak@28: local secureFrame = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate") flickerstreak@28: secureFrame:Hide() flickerstreak@28: flickerstreak@28: local function secureFrame_Show(self) flickerstreak@28: local owner = self.owner flickerstreak@28: flickerstreak@28: if self.secure then -- Leftovers from previos owner, clean up! ("Shouldn't" happen but does..) flickerstreak@28: for k,v in pairs(self.secure) do flickerstreak@28: self:SetAttribute(k, nil) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: self.secure = owner.secure; -- Grab hold of new secure data flickerstreak@28: flickerstreak@28: local scale = owner:GetEffectiveScale() flickerstreak@28: flickerstreak@28: self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", owner:GetLeft() * scale, owner:GetTop() * scale) flickerstreak@28: self:SetPoint("BOTTOMRIGHT", nil, "BOTTOMLEFT", owner:GetRight() * scale, owner:GetBottom() * scale) flickerstreak@28: self:EnableMouse(true) flickerstreak@28: for k,v in pairs(self.secure) do flickerstreak@28: self:SetAttribute(k, v) flickerstreak@28: end flickerstreak@28: flickerstreak@28: secureFrame:SetFrameStrata(owner:GetFrameStrata()) flickerstreak@28: secureFrame:SetFrameLevel(owner:GetFrameLevel()+1) flickerstreak@28: flickerstreak@28: self:Show() flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function secureFrame_Hide(self) flickerstreak@28: self:Hide() flickerstreak@28: if self.secure then flickerstreak@28: for k,v in pairs(self.secure) do flickerstreak@28: self:SetAttribute(k, nil) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: self.secure = nil flickerstreak@28: end flickerstreak@28: flickerstreak@28: secureFrame:SetScript("OnEvent", flickerstreak@28: function() flickerstreak@28: if event=="PLAYER_REGEN_ENABLED" then flickerstreak@28: this.combat = false flickerstreak@28: if not this:IsShown() and this.owner then flickerstreak@28: secureFrame_Show(this) flickerstreak@28: end flickerstreak@28: elseif event=="PLAYER_REGEN_DISABLED" then flickerstreak@28: this.combat = true flickerstreak@28: if this:IsShown() then flickerstreak@28: secureFrame_Hide(this) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: ) flickerstreak@28: secureFrame:RegisterEvent("PLAYER_REGEN_ENABLED") flickerstreak@28: secureFrame:RegisterEvent("PLAYER_REGEN_DISABLED") flickerstreak@28: flickerstreak@28: secureFrame:SetScript("OnLeave", flickerstreak@28: function() flickerstreak@28: local owner=this.owner flickerstreak@28: this:Deactivate() flickerstreak@28: owner:GetScript("OnLeave")() flickerstreak@28: end flickerstreak@28: ) flickerstreak@28: flickerstreak@28: secureFrame:HookScript("OnClick", flickerstreak@28: function() flickerstreak@28: local realthis = this flickerstreak@28: this = this.owner flickerstreak@28: this:GetScript("OnClick")() flickerstreak@28: end flickerstreak@28: ) flickerstreak@28: flickerstreak@28: function secureFrame:IsOwnedBy(frame) flickerstreak@28: return self.owner == frame flickerstreak@28: end flickerstreak@28: flickerstreak@28: function secureFrame:Activate(owner) flickerstreak@28: if self.owner then -- "Shouldn't" happen but apparently it does and I cba to troubleshoot... flickerstreak@28: if not self.combat then flickerstreak@28: secureFrame_Hide(self) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: self.owner = owner flickerstreak@28: if not self.combat then flickerstreak@28: secureFrame_Show(self) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: function secureFrame:Deactivate() flickerstreak@28: if not self.combat then flickerstreak@28: secureFrame_Hide(self) flickerstreak@28: end flickerstreak@28: self.owner = nil flickerstreak@28: end flickerstreak@28: flickerstreak@28: -- END secure frame utilities flickerstreak@28: flickerstreak@28: flickerstreak@28: -- Underline on mouseover - use a single global underline that we move around, no point in creating lots of copies flickerstreak@28: local underlineFrame = CreateFrame("Frame", nil) flickerstreak@28: underlineFrame.tx = underlineFrame:CreateTexture() flickerstreak@28: underlineFrame.tx:SetTexture(1,1,0.5,0.75) flickerstreak@28: underlineFrame:SetScript("OnHide", function(this) this:Hide(); end) flickerstreak@28: underlineFrame:SetScript("OnShow", function(this) -- change sizing on the fly to catch runtime uiscale changes flickerstreak@28: underlineFrame.tx:SetPoint("TOPLEFT", -1, -2/this:GetEffectiveScale()) flickerstreak@28: underlineFrame.tx:SetPoint("RIGHT", 1,0) flickerstreak@28: underlineFrame.tx:SetHeight(0.6 / this:GetEffectiveScale()); flickerstreak@28: end) flickerstreak@28: underlineFrame:SetHeight(1) flickerstreak@28: flickerstreak@28: -- END underline on mouseover flickerstreak@28: flickerstreak@28: flickerstreak@28: local function GetScaledCursorPosition() flickerstreak@28: local x, y = GetCursorPosition() flickerstreak@28: local scale = UIParent:GetEffectiveScale() flickerstreak@28: return x / scale, y / scale flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function StartCounting(self, level) flickerstreak@28: for i = level, 1, -1 do flickerstreak@28: if levels[i] then flickerstreak@28: levels[i].count = 3 flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function StopCounting(self, level) flickerstreak@28: for i = level, 1, -1 do flickerstreak@28: if levels[i] then flickerstreak@28: levels[i].count = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function OnUpdate(self, elapsed) flickerstreak@28: for _,level in ipairs(levels) do flickerstreak@28: local count = level.count flickerstreak@28: if count then flickerstreak@28: count = count - elapsed flickerstreak@28: if count < 0 then flickerstreak@28: level.count = nil flickerstreak@28: self:Close(level.num) flickerstreak@28: else flickerstreak@28: level.count = count flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function CheckDualMonitor(self, frame) flickerstreak@28: local ratio = GetScreenWidth() / GetScreenHeight() flickerstreak@28: if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then flickerstreak@28: local offsetx flickerstreak@28: if GetCursorPosition() / GetScreenHeight() * 768 < GetScreenWidth() / 2 then flickerstreak@28: offsetx = GetScreenWidth() / 2 - frame:GetRight() flickerstreak@28: else flickerstreak@28: offsetx = GetScreenWidth() / 2 - frame:GetLeft() flickerstreak@28: end flickerstreak@28: local point, parent, relativePoint, x, y = frame:GetPoint(1) flickerstreak@28: frame:SetPoint(point, parent, relativePoint, (x or 0) + offsetx, y or 0) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function CheckSize(self, level) flickerstreak@28: if not level.buttons then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: local height = 20 flickerstreak@28: for _, button in ipairs(level.buttons) do flickerstreak@28: height = height + button:GetHeight() flickerstreak@28: end flickerstreak@28: level:SetHeight(height) flickerstreak@28: local width = 160 flickerstreak@28: for _, button in ipairs(level.buttons) do flickerstreak@28: local extra = 1 flickerstreak@28: if button.hasArrow or button.hasColorSwatch then flickerstreak@28: extra = extra + 16 flickerstreak@28: end flickerstreak@28: if not button.notCheckable then flickerstreak@28: extra = extra + 24 flickerstreak@28: end flickerstreak@28: button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight) flickerstreak@28: if button.text:GetWidth() + extra > width then flickerstreak@28: width = button.text:GetWidth() + extra flickerstreak@28: end flickerstreak@28: end flickerstreak@28: level:SetWidth(width + 20) flickerstreak@28: 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@28: level:ClearAllPoints() flickerstreak@28: local parent = level.parent or level:GetParent() flickerstreak@28: if type(parent) ~= "table" then flickerstreak@28: parent = UIParent flickerstreak@28: end flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@28: else flickerstreak@28: level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@28: else flickerstreak@28: level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local dirty = false flickerstreak@28: if not level:GetRight() then flickerstreak@28: self:Close() flickerstreak@28: return flickerstreak@28: end flickerstreak@28: if level:GetRight() > GetScreenWidth() and level.lastDirection == "RIGHT" then flickerstreak@28: level.lastDirection = "LEFT" flickerstreak@28: dirty = true flickerstreak@28: elseif level:GetLeft() < 0 and level.lastDirection == "LEFT" then flickerstreak@28: level.lastDirection = "RIGHT" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: if level:GetTop() > GetScreenHeight() and level.lastVDirection == "UP" then flickerstreak@28: level.lastVDirection = "DOWN" flickerstreak@28: dirty = true flickerstreak@28: elseif level:GetBottom() < 0 and level.lastVDirection == "DOWN" then flickerstreak@28: level.lastVDirection = "UP" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: if dirty then flickerstreak@28: level:ClearAllPoints() flickerstreak@28: local parent = level.parent or level:GetParent() flickerstreak@28: if type(parent) ~= "table" then flickerstreak@28: parent = UIParent flickerstreak@28: end flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@28: else flickerstreak@28: level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@28: else flickerstreak@28: level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if level:GetTop() > GetScreenHeight() then flickerstreak@28: local top = level:GetTop() flickerstreak@28: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@28: level:ClearAllPoints() flickerstreak@28: level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) + GetScreenHeight() - top) flickerstreak@28: elseif level:GetBottom() < 0 then flickerstreak@28: local bottom = level:GetBottom() flickerstreak@28: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@28: level:ClearAllPoints() flickerstreak@28: level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) - bottom) flickerstreak@28: end flickerstreak@28: CheckDualMonitor(self, level) flickerstreak@28: if mod(level.num, 5) == 0 then flickerstreak@28: local left, bottom = level:GetLeft(), level:GetBottom() flickerstreak@28: level:ClearAllPoints() flickerstreak@28: level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local Open flickerstreak@28: local OpenSlider flickerstreak@28: local OpenEditBox flickerstreak@28: local Refresh flickerstreak@28: local Clear flickerstreak@28: local function ReleaseButton(self, level, index) flickerstreak@28: if not level.buttons then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: if not level.buttons[index] then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: local button = level.buttons[index] flickerstreak@28: button:Hide() flickerstreak@28: if button.highlight then flickerstreak@28: button.highlight:Hide() flickerstreak@28: end flickerstreak@28: -- button.arrow:SetVertexColor(1, 1, 1) flickerstreak@28: -- button.arrow:SetHeight(16) flickerstreak@28: -- button.arrow:SetWidth(16) flickerstreak@28: table.remove(level.buttons, index) flickerstreak@28: table.insert(buttons, button) flickerstreak@28: for k in pairs(button) do flickerstreak@28: if k ~= 0 and k ~= "text" and k ~= "check" and k ~= "arrow" and k ~= "colorSwatch" and k ~= "highlight" and k ~= "radioHighlight" then flickerstreak@28: button[k] = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: return true flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function Scroll(self, level, down) flickerstreak@28: if down then flickerstreak@28: if level:GetBottom() < 0 then flickerstreak@28: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@28: level:SetPoint(point, parent, relativePoint, x, y + 50) flickerstreak@28: if level:GetBottom() > 0 then flickerstreak@28: level:SetPoint(point, parent, relativePoint, x, y + 50 - level:GetBottom()) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level:GetTop() > GetScreenHeight() then flickerstreak@28: local point, parent, relativePoint, x, y = level:GetPoint(1) flickerstreak@28: level:SetPoint(point, parent, relativePoint, x, y - 50) flickerstreak@28: if level:GetTop() < GetScreenHeight() then flickerstreak@28: level:SetPoint(point, parent, relativePoint, x, y - 50 + GetScreenHeight() - level:GetTop()) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function getArgs(t, str, num, ...) flickerstreak@28: local x = t[str .. num] flickerstreak@28: if x == nil then flickerstreak@28: return ... flickerstreak@28: else flickerstreak@28: return x, getArgs(t, str, num + 1, ...) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local sliderFrame flickerstreak@28: local editBoxFrame flickerstreak@28: flickerstreak@28: local normalFont flickerstreak@28: local lastSetFont flickerstreak@28: local justSetFont = false flickerstreak@28: local regionTmp = {} flickerstreak@28: local function fillRegionTmp(...) flickerstreak@28: for i = 1, select('#', ...) do flickerstreak@28: regionTmp[i] = select(i, ...) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function showGameTooltip(this) flickerstreak@28: if this.tooltipTitle or this.tooltipText then flickerstreak@28: GameTooltip_SetDefaultAnchor(GameTooltip, this) flickerstreak@28: local disabled = not this.isTitle and this.disabled flickerstreak@28: local font flickerstreak@28: if this.tooltipTitle then flickerstreak@28: if SharedMedia and SharedMedia:IsValid("font", this.tooltipTitle) then flickerstreak@28: font = SharedMedia:Fetch("font", this.tooltipTitle) flickerstreak@28: end flickerstreak@28: if disabled then flickerstreak@28: GameTooltip:SetText(this.tooltipTitle, 0.5, 0.5, 0.5, 1) flickerstreak@28: else flickerstreak@28: GameTooltip:SetText(this.tooltipTitle, 1, 1, 1, 1) flickerstreak@28: end flickerstreak@28: if this.tooltipText then flickerstreak@28: if not font and SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then flickerstreak@28: font = SharedMedia:Fetch("font", this.tooltipText) flickerstreak@28: end flickerstreak@28: if disabled then flickerstreak@28: 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@28: else flickerstreak@28: GameTooltip:AddLine(this.tooltipText, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then flickerstreak@28: font = SharedMedia:Fetch("font", this.tooltipText) flickerstreak@28: end flickerstreak@28: if disabled then flickerstreak@28: GameTooltip:SetText(this.tooltipText, 0.5, 0.5, 0.5, 1) flickerstreak@28: else flickerstreak@28: GameTooltip:SetText(this.tooltipText, 1, 1, 1, 1) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if font then flickerstreak@28: fillRegionTmp(GameTooltip:GetRegions()) flickerstreak@28: lastSetFont = font flickerstreak@28: justSetFont = true flickerstreak@28: for i,v in ipairs(regionTmp) do flickerstreak@28: if v.SetFont then flickerstreak@28: local norm,size,outline = v:GetFont() flickerstreak@28: v:SetFont(font, size, outline) flickerstreak@28: if not normalFont then flickerstreak@28: normalFont = norm flickerstreak@28: end flickerstreak@28: end flickerstreak@28: regionTmp[i] = nil flickerstreak@28: end flickerstreak@28: elseif not normalFont then flickerstreak@28: fillRegionTmp(GameTooltip:GetRegions()) flickerstreak@28: for i,v in ipairs(regionTmp) do flickerstreak@28: if v.GetFont and not normalFont then flickerstreak@28: normalFont = v:GetFont() flickerstreak@28: end flickerstreak@28: regionTmp[i] = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: GameTooltip:Show() flickerstreak@28: end flickerstreak@28: if this.tooltipFunc then flickerstreak@28: GameTooltip:SetOwner(this, "ANCHOR_NONE") flickerstreak@28: GameTooltip:SetPoint("TOPLEFT", this, "TOPRIGHT", 5, 0) flickerstreak@28: this.tooltipFunc(getArgs(this, 'tooltipArg', 1)) flickerstreak@28: GameTooltip:Show() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local tmpt = setmetatable({}, {mode='v'}) flickerstreak@28: local numButtons = 0 flickerstreak@28: local function AcquireButton(self, level) flickerstreak@28: if not levels[level] then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: level = levels[level] flickerstreak@28: if not level.buttons then flickerstreak@28: level.buttons = {} flickerstreak@28: end flickerstreak@28: local button flickerstreak@28: if #buttons == 0 then flickerstreak@28: numButtons = numButtons + 1 flickerstreak@28: button = CreateFrame("Button", "Dewdrop20Button" .. numButtons, nil) flickerstreak@28: button:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@28: button:SetHeight(16) flickerstreak@28: local highlight = button:CreateTexture(nil, "BACKGROUND") flickerstreak@28: highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") flickerstreak@28: button.highlight = highlight flickerstreak@28: highlight:SetBlendMode("ADD") flickerstreak@28: highlight:SetAllPoints(button) flickerstreak@28: highlight:Hide() flickerstreak@28: local check = button:CreateTexture(nil, "ARTWORK") flickerstreak@28: button.check = check flickerstreak@28: check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") flickerstreak@28: check:SetPoint("CENTER", button, "LEFT", 12, 0) flickerstreak@28: check:SetWidth(24) flickerstreak@28: check:SetHeight(24) flickerstreak@28: local radioHighlight = button:CreateTexture(nil, "ARTWORK") flickerstreak@28: button.radioHighlight = radioHighlight flickerstreak@28: radioHighlight:SetTexture("Interface\\Buttons\\UI-RadioButton") flickerstreak@28: radioHighlight:SetAllPoints(check) flickerstreak@28: radioHighlight:SetBlendMode("ADD") flickerstreak@28: radioHighlight:SetTexCoord(0.5, 0.75, 0, 1) flickerstreak@28: radioHighlight:Hide() flickerstreak@28: button:SetScript("OnEnter", function() flickerstreak@28: 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@28: for i = 1, this.level.num do flickerstreak@28: Refresh(self, levels[i]) flickerstreak@28: end flickerstreak@28: return flickerstreak@28: end flickerstreak@28: self:Close(this.level.num + 1) flickerstreak@28: if not this.disabled then flickerstreak@28: if this.secure then flickerstreak@28: secureFrame:Activate(this) flickerstreak@28: elseif this.hasSlider then flickerstreak@28: OpenSlider(self, this) flickerstreak@28: elseif this.hasEditBox then flickerstreak@28: OpenEditBox(self, this) flickerstreak@28: elseif this.hasArrow then flickerstreak@28: Open(self, this, nil, this.level.num + 1, this.value) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if not this.level then -- button reclaimed flickerstreak@28: return flickerstreak@28: end flickerstreak@28: StopCounting(self, this.level.num + 1) flickerstreak@28: if not this.disabled then flickerstreak@28: highlight:Show() flickerstreak@28: if this.isRadio then flickerstreak@28: button.radioHighlight:Show() flickerstreak@28: end flickerstreak@28: if this.mouseoverUnderline then flickerstreak@28: underlineFrame:SetParent(this) flickerstreak@28: underlineFrame:SetPoint("BOTTOMLEFT",this.text,0,0) flickerstreak@28: underlineFrame:SetWidth(this.text:GetWidth()) flickerstreak@28: underlineFrame:Show() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: showGameTooltip(this) flickerstreak@28: end) flickerstreak@28: button:SetScript("OnHide", function() flickerstreak@28: if this.secure and secureFrame:IsOwnedBy(this) then flickerstreak@28: secureFrame:Deactivate() flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: button:SetScript("OnLeave", function() flickerstreak@28: if this.secure and secureFrame:IsShown() then flickerstreak@28: return; -- it's ok, we didn't actually mouse out of the button, only onto the secure frame on top of it flickerstreak@28: end flickerstreak@28: underlineFrame:Hide() flickerstreak@28: if not this.selected then flickerstreak@28: highlight:Hide() flickerstreak@28: end flickerstreak@28: button.radioHighlight:Hide() flickerstreak@28: if this.level then flickerstreak@28: StartCounting(self, this.level.num) flickerstreak@28: end flickerstreak@28: GameTooltip:Hide() flickerstreak@28: end) flickerstreak@28: local first = true flickerstreak@28: button:SetScript("OnClick", function() flickerstreak@28: if not this.disabled then flickerstreak@28: if this.hasColorSwatch then flickerstreak@28: local func = button.colorFunc flickerstreak@28: local hasOpacity = this.hasOpacity flickerstreak@28: local this = this flickerstreak@28: for k in pairs(tmpt) do flickerstreak@28: tmpt[k] = nil flickerstreak@28: end flickerstreak@28: for i = 1, 1000 do flickerstreak@28: local x = this['colorArg'..i] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: else flickerstreak@28: tmpt[i] = x flickerstreak@28: end flickerstreak@28: end flickerstreak@28: ColorPickerFrame.func = function() flickerstreak@28: if func then flickerstreak@28: local r,g,b = ColorPickerFrame:GetColorRGB() flickerstreak@28: local a = hasOpacity and 1 - OpacitySliderFrame:GetValue() or nil flickerstreak@28: local n = #tmpt flickerstreak@28: tmpt[n+1] = r flickerstreak@28: tmpt[n+2] = g flickerstreak@28: tmpt[n+3] = b flickerstreak@28: tmpt[n+4] = a flickerstreak@28: func(unpack(tmpt)) flickerstreak@28: tmpt[n+1] = nil flickerstreak@28: tmpt[n+2] = nil flickerstreak@28: tmpt[n+3] = nil flickerstreak@28: tmpt[n+4] = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: ColorPickerFrame.hasOpacity = this.hasOpacity flickerstreak@28: ColorPickerFrame.opacityFunc = ColorPickerFrame.func flickerstreak@28: ColorPickerFrame.opacity = 1 - this.opacity flickerstreak@28: ColorPickerFrame:SetColorRGB(this.r, this.g, this.b) flickerstreak@28: local r, g, b, a = this.r, this.g, this.b, this.opacity flickerstreak@28: ColorPickerFrame.cancelFunc = function() flickerstreak@28: if func then flickerstreak@28: local n = #tmpt flickerstreak@28: tmpt[n+1] = r flickerstreak@28: tmpt[n+2] = g flickerstreak@28: tmpt[n+3] = b flickerstreak@28: tmpt[n+4] = a flickerstreak@28: func(unpack(tmpt)) flickerstreak@28: for i = 1, n+4 do flickerstreak@28: tmpt[i] = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: self:Close(1) flickerstreak@28: ShowUIPanel(ColorPickerFrame) flickerstreak@28: elseif this.func then flickerstreak@28: local level = this.level flickerstreak@28: if type(this.func) == "string" then flickerstreak@28: if type(this.arg1[this.func]) ~= "function" then flickerstreak@28: self:error("Cannot call method %q", this.func) flickerstreak@28: end flickerstreak@28: this.arg1[this.func](this.arg1, getArgs(this, 'arg', 2)) flickerstreak@28: else flickerstreak@28: this.func(getArgs(this, 'arg', 1)) flickerstreak@28: end flickerstreak@28: if this.closeWhenClicked then flickerstreak@28: self:Close() flickerstreak@28: elseif level:IsShown() then flickerstreak@28: for i = 1, level.num do flickerstreak@28: Refresh(self, levels[i]) flickerstreak@28: end flickerstreak@28: local value = levels[level.num].value flickerstreak@28: for i = level.num-1, 1, -1 do flickerstreak@28: local level = levels[i] flickerstreak@28: local good = false flickerstreak@28: for _,button in ipairs(level.buttons) do flickerstreak@28: if button.value == value then flickerstreak@28: good = true flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if not good then flickerstreak@28: Dewdrop:Close(i+1) flickerstreak@28: end flickerstreak@28: value = levels[i].value flickerstreak@28: end flickerstreak@28: end flickerstreak@28: elseif this.closeWhenClicked then flickerstreak@28: self:Close() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: local text = button:CreateFontString(nil, "ARTWORK") flickerstreak@28: button.text = text flickerstreak@28: text:SetFontObject(GameFontHighlightSmall) flickerstreak@28: button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT) flickerstreak@28: button:SetScript("OnMouseDown", function() flickerstreak@28: if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then flickerstreak@28: text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1) flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: button:SetScript("OnMouseUp", function() flickerstreak@28: if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then flickerstreak@28: text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0) flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: local arrow = button:CreateTexture(nil, "ARTWORK") flickerstreak@28: button.arrow = arrow flickerstreak@28: arrow:SetPoint("LEFT", button, "RIGHT", -16, 0) flickerstreak@28: arrow:SetWidth(16) flickerstreak@28: arrow:SetHeight(16) flickerstreak@28: arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow") flickerstreak@28: local colorSwatch = button:CreateTexture(nil, "ARTWORK") flickerstreak@28: button.colorSwatch = colorSwatch flickerstreak@28: colorSwatch:SetWidth(20) flickerstreak@28: colorSwatch:SetHeight(20) flickerstreak@28: colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") flickerstreak@28: local texture = button:CreateTexture(nil, "OVERLAY") flickerstreak@28: colorSwatch.texture = texture flickerstreak@28: texture:SetTexture("Interface\\Buttons\\WHITE8X8") flickerstreak@28: texture:SetWidth(11.5) flickerstreak@28: texture:SetHeight(11.5) flickerstreak@28: texture:Show() flickerstreak@28: texture:SetPoint("CENTER", colorSwatch, "CENTER") flickerstreak@28: colorSwatch:SetPoint("RIGHT", button, "RIGHT", 0, 0) flickerstreak@28: else flickerstreak@28: button = table.remove(buttons) flickerstreak@28: end flickerstreak@28: button:ClearAllPoints() flickerstreak@28: button:SetParent(level) flickerstreak@28: button:SetFrameStrata(level:GetFrameStrata()) flickerstreak@28: button:SetFrameLevel(level:GetFrameLevel() + 1) flickerstreak@28: button:SetPoint("LEFT", level, "LEFT", 10, 0) flickerstreak@28: button:SetPoint("RIGHT", level, "RIGHT", -10, 0) flickerstreak@28: if #level.buttons == 0 then flickerstreak@28: button:SetPoint("TOP", level, "TOP", 0, -10) flickerstreak@28: else flickerstreak@28: button:SetPoint("TOP", level.buttons[#level.buttons], "BOTTOM", 0, 0) flickerstreak@28: end flickerstreak@28: button.text:SetPoint("LEFT", button, "LEFT", 24, 0) flickerstreak@28: button:Show() flickerstreak@28: button.level = level flickerstreak@28: table.insert(level.buttons, button) flickerstreak@28: if not level.parented then flickerstreak@28: level.parented = true flickerstreak@28: level:ClearAllPoints() flickerstreak@28: if level.num == 1 then flickerstreak@28: if level.parent ~= UIParent and type(level.parent) == "table" then flickerstreak@28: level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT") flickerstreak@28: else flickerstreak@28: level:SetPoint("CENTER", UIParent, "CENTER") flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: level:SetPoint("TOPLEFT", level.parent, "TOPRIGHT", 5, 10) flickerstreak@28: else flickerstreak@28: level:SetPoint("BOTTOMLEFT", level.parent, "BOTTOMRIGHT", 5, -10) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT", -5, 10) flickerstreak@28: else flickerstreak@28: level:SetPoint("BOTTOMRIGHT", level.parent, "BOTTOMLEFT", -5, -10) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: level:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@28: end flickerstreak@28: button:SetAlpha(1) flickerstreak@28: return button flickerstreak@28: end flickerstreak@28: flickerstreak@28: local numLevels = 0 flickerstreak@28: local function AcquireLevel(self, level) flickerstreak@28: if not levels[level] then flickerstreak@28: for i = #levels + 1, level, -1 do flickerstreak@28: local i = i flickerstreak@28: numLevels = numLevels + 1 flickerstreak@28: local frame = CreateFrame("Button", "Dewdrop20Level" .. numLevels, nil) flickerstreak@28: if i == 1 then flickerstreak@28: local old_CloseSpecialWindows = CloseSpecialWindows flickerstreak@28: function CloseSpecialWindows() flickerstreak@28: local found = old_CloseSpecialWindows() flickerstreak@28: if levels[1]:IsShown() then flickerstreak@28: self:Close() flickerstreak@28: return 1 flickerstreak@28: end flickerstreak@28: return found flickerstreak@28: end flickerstreak@28: end flickerstreak@28: levels[i] = frame flickerstreak@28: frame.num = i flickerstreak@28: frame:SetParent(UIParent) flickerstreak@28: frame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@28: frame:Hide() flickerstreak@28: frame:SetWidth(180) flickerstreak@28: frame:SetHeight(10) flickerstreak@28: frame:SetFrameLevel(i * 3) flickerstreak@28: frame:SetScript("OnHide", function() flickerstreak@28: self:Close(level + 1) flickerstreak@28: end) flickerstreak@28: if frame.SetTopLevel then flickerstreak@28: frame:SetTopLevel(true) flickerstreak@28: end flickerstreak@28: frame:EnableMouse(true) flickerstreak@28: frame:EnableMouseWheel(true) flickerstreak@28: local backdrop = CreateFrame("Frame", nil, frame) flickerstreak@28: backdrop:SetAllPoints(frame) flickerstreak@28: backdrop:SetBackdrop(tmp( flickerstreak@28: 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background", flickerstreak@28: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@28: 'tile', true, flickerstreak@28: 'insets', tmp2( flickerstreak@28: 'left', 5, flickerstreak@28: 'right', 5, flickerstreak@28: 'top', 5, flickerstreak@28: 'bottom', 5 flickerstreak@28: ), flickerstreak@28: 'tileSize', 16, flickerstreak@28: 'edgeSize', 16 flickerstreak@28: )) flickerstreak@28: backdrop:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) flickerstreak@28: backdrop:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) flickerstreak@28: frame:SetScript("OnClick", function() flickerstreak@28: self:Close(i) flickerstreak@28: end) flickerstreak@28: frame:SetScript("OnEnter", function() flickerstreak@28: StopCounting(self, i) flickerstreak@28: end) flickerstreak@28: frame:SetScript("OnLeave", function() flickerstreak@28: StartCounting(self, i) flickerstreak@28: end) flickerstreak@28: frame:SetScript("OnMouseWheel", function() flickerstreak@28: Scroll(self, frame, arg1 < 0) flickerstreak@28: end) flickerstreak@28: if i == 1 then flickerstreak@28: frame:SetScript("OnUpdate", function(this, arg1) flickerstreak@28: OnUpdate(self, arg1) flickerstreak@28: end) flickerstreak@28: levels[1].lastDirection = "RIGHT" flickerstreak@28: levels[1].lastVDirection = "DOWN" flickerstreak@28: else flickerstreak@28: levels[i].lastDirection = levels[i - 1].lastDirection flickerstreak@28: levels[i].lastVDirection = levels[i - 1].lastVDirection flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local fullscreenFrame = GetUIPanel("fullscreen") flickerstreak@28: local l = levels[level] flickerstreak@28: local strata, framelevel = l:GetFrameStrata(), l:GetFrameLevel() flickerstreak@28: if fullscreenFrame then flickerstreak@28: l:SetParent(fullscreenFrame) flickerstreak@28: else flickerstreak@28: l:SetParent(UIParent) flickerstreak@28: end flickerstreak@28: l:SetFrameStrata(strata) flickerstreak@28: l:SetFrameLevel(framelevel) flickerstreak@28: l:SetAlpha(1) flickerstreak@28: return l flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function validateOptions(options, position, baseOptions, fromPass) flickerstreak@28: if not baseOptions then flickerstreak@28: baseOptions = options flickerstreak@28: end flickerstreak@28: if type(options) ~= "table" then flickerstreak@28: return "Options must be a table.", position flickerstreak@28: end flickerstreak@28: local kind = options.type flickerstreak@28: if type(kind) ~= "string" then flickerstreak@28: return '"type" must be a string.', position flickerstreak@28: elseif kind ~= "group" and kind ~= "range" and kind ~= "text" and kind ~= "execute" and kind ~= "toggle" and kind ~= "color" and kind ~= "dragLink" and kind ~= "header" then flickerstreak@28: return '"type" must either be "range", "text", "group", "toggle", "execute", "color", "dragLink", or "header".', position flickerstreak@28: end flickerstreak@28: if options.aliases then flickerstreak@28: if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then flickerstreak@28: return '"alias" must be a table or string', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if not fromPass then flickerstreak@28: if kind == "execute" then flickerstreak@28: if type(options.func) ~= "string" and type(options.func) ~= "function" then flickerstreak@28: return '"func" must be a string or function', position flickerstreak@28: end flickerstreak@28: elseif kind == "range" or kind == "text" or kind == "toggle" then flickerstreak@28: if type(options.set) ~= "string" and type(options.set) ~= "function" then flickerstreak@28: return '"set" must be a string or function', position flickerstreak@28: end flickerstreak@28: if kind == "text" and options.get == false then flickerstreak@28: elseif type(options.get) ~= "string" and type(options.get) ~= "function" then flickerstreak@28: return '"get" must be a string or function', position flickerstreak@28: end flickerstreak@28: elseif kind == "group" and options.pass then flickerstreak@28: if options.pass ~= true then flickerstreak@28: return '"pass" must be either nil, true, or false', position flickerstreak@28: end flickerstreak@28: if not options.func then flickerstreak@28: if type(options.set) ~= "string" and type(options.set) ~= "function" then flickerstreak@28: return '"set" must be a string or function', position flickerstreak@28: end flickerstreak@28: if type(options.get) ~= "string" and type(options.get) ~= "function" then flickerstreak@28: return '"get" must be a string or function', position flickerstreak@28: end flickerstreak@28: elseif type(options.func) ~= "string" and type(options.func) ~= "function" then flickerstreak@28: return '"func" must be a string or function', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options ~= baseOptions then flickerstreak@28: if kind == "header" then flickerstreak@28: elseif type(options.desc) ~= "string" then flickerstreak@28: return '"desc" must be a string', position flickerstreak@28: elseif options.desc:len() == 0 then flickerstreak@28: return '"desc" cannot be a 0-length string', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options ~= baseOptions or kind == "range" or kind == "text" or kind == "toggle" or kind == "color" then flickerstreak@28: if options.type == "header" and not options.cmdName and not options.name then flickerstreak@28: elseif options.cmdName then flickerstreak@28: if type(options.cmdName) ~= "string" then flickerstreak@28: return '"cmdName" must be a string or nil', position flickerstreak@28: elseif options.cmdName:len() == 0 then flickerstreak@28: return '"cmdName" cannot be a 0-length string', position flickerstreak@28: end flickerstreak@28: if type(options.guiName) ~= "string" then flickerstreak@28: if not options.guiNameIsMap then flickerstreak@28: return '"guiName" must be a string or nil', position flickerstreak@28: end flickerstreak@28: elseif options.guiName:len() == 0 then flickerstreak@28: return '"guiName" cannot be a 0-length string', position flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if type(options.name) ~= "string" then flickerstreak@28: return '"name" must be a string', position flickerstreak@28: elseif options.name:len() == 0 then flickerstreak@28: return '"name" cannot be a 0-length string', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.guiNameIsMap then flickerstreak@28: if type(options.guiNameIsMap) ~= "boolean" then flickerstreak@28: return '"guiNameIsMap" must be a boolean or nil', position flickerstreak@28: elseif options.type ~= "toggle" then flickerstreak@28: return 'if "guiNameIsMap" is true, then "type" must be set to \'toggle\'', position flickerstreak@28: elseif type(options.map) ~= "table" then flickerstreak@28: return '"map" must be a table', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.message and type(options.message) ~= "string" then flickerstreak@28: return '"message" must be a string or nil', position flickerstreak@28: end flickerstreak@28: if options.error and type(options.error) ~= "string" then flickerstreak@28: return '"error" must be a string or nil', position flickerstreak@28: end flickerstreak@28: if options.current and type(options.current) ~= "string" then flickerstreak@28: return '"current" must be a string or nil', position flickerstreak@28: end flickerstreak@28: if options.order then flickerstreak@28: if type(options.order) ~= "number" or (-1 < options.order and options.order < 0.999) then flickerstreak@28: return '"order" must be a non-zero number or nil', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.disabled then flickerstreak@28: if type(options.disabled) ~= "function" and type(options.disabled) ~= "string" and options.disabled ~= true then flickerstreak@28: return '"disabled" must be a function, string, or boolean', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.cmdHidden then flickerstreak@28: if type(options.cmdHidden) ~= "function" and type(options.cmdHidden) ~= "string" and options.cmdHidden ~= true then flickerstreak@28: return '"cmdHidden" must be a function, string, or boolean', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.guiHidden then flickerstreak@28: if type(options.guiHidden) ~= "function" and type(options.guiHidden) ~= "string" and options.guiHidden ~= true then flickerstreak@28: return '"guiHidden" must be a function, string, or boolean', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.hidden then flickerstreak@28: if type(options.hidden) ~= "function" and type(options.hidden) ~= "string" and options.hidden ~= true then flickerstreak@28: return '"hidden" must be a function, string, or boolean', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if kind == "text" then flickerstreak@28: if type(options.validate) == "table" then flickerstreak@28: local t = options.validate flickerstreak@28: local iTable = nil flickerstreak@28: for k,v in pairs(t) do flickerstreak@28: if type(k) == "number" then flickerstreak@28: if iTable == nil then flickerstreak@28: iTable = true flickerstreak@28: elseif not iTable then flickerstreak@28: return '"validate" must either have all keys be indexed numbers or strings', position flickerstreak@28: elseif k < 1 or k > #t then flickerstreak@28: return '"validate" numeric keys must be indexed properly. >= 1 and <= #t', position flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if iTable == nil then flickerstreak@28: iTable = false flickerstreak@28: elseif iTable then flickerstreak@28: return '"validate" must either have all keys be indexed numbers or strings', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if type(v) ~= "string" then flickerstreak@28: return '"validate" values must all be strings', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.multiToggle and options.multiToggle ~= true then flickerstreak@28: return '"multiToggle" must be a boolean or nil if "validate" is a table', position flickerstreak@28: end flickerstreak@28: elseif options.validate == "keybinding" then flickerstreak@28: -- no other checks flickerstreak@28: else flickerstreak@28: if type(options.usage) ~= "string" then flickerstreak@28: return '"usage" must be a string', position flickerstreak@28: elseif options.validate and type(options.validate) ~= "string" and type(options.validate) ~= "function" then flickerstreak@28: return '"validate" must be a string, function, or table', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.multiToggle and type(options.validate) ~= "table" then flickerstreak@28: return '"validate" must be a table if "multiToggle" is true', position flickerstreak@28: end flickerstreak@28: elseif kind == "range" then flickerstreak@28: if options.min or options.max then flickerstreak@28: if type(options.min) ~= "number" then flickerstreak@28: return '"min" must be a number', position flickerstreak@28: elseif type(options.max) ~= "number" then flickerstreak@28: return '"max" must be a number', position flickerstreak@28: elseif options.min >= options.max then flickerstreak@28: return '"min" must be less than "max"', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.step then flickerstreak@28: if type(options.step) ~= "number" then flickerstreak@28: return '"step" must be a number', position flickerstreak@28: elseif options.step < 0 then flickerstreak@28: return '"step" must be nonnegative', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.bigStep then flickerstreak@28: if type(options.bigStep) ~= "number" then flickerstreak@28: return '"bigStep" must be a number', position flickerstreak@28: elseif options.bigStep < 0 then flickerstreak@28: return '"bigStep" must be nonnegative', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.isPercent and options.isPercent ~= true then flickerstreak@28: return '"isPercent" must either be nil, true, or false', position flickerstreak@28: end flickerstreak@28: elseif kind == "toggle" then flickerstreak@28: if options.map then flickerstreak@28: if type(options.map) ~= "table" then flickerstreak@28: return '"map" must be a table', position flickerstreak@28: elseif type(options.map[true]) ~= "string" then flickerstreak@28: return '"map[true]" must be a string', position flickerstreak@28: elseif type(options.map[false]) ~= "string" then flickerstreak@28: return '"map[false]" must be a string', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: elseif kind == "color" then flickerstreak@28: if options.hasAlpha and options.hasAlpha ~= true then flickerstreak@28: return '"hasAlpha" must be nil, true, or false', position flickerstreak@28: end flickerstreak@28: elseif kind == "group" then flickerstreak@28: if options.pass and options.pass ~= true then flickerstreak@28: return '"pass" must be nil, true, or false', position flickerstreak@28: end flickerstreak@28: if type(options.args) ~= "table" then flickerstreak@28: return '"args" must be a table', position flickerstreak@28: end flickerstreak@28: for k,v in pairs(options.args) do flickerstreak@28: if type(k) ~= "number" then flickerstreak@28: if type(k) ~= "string" then flickerstreak@28: return '"args" keys must be strings or numbers', position flickerstreak@28: elseif k:len() == 0 then flickerstreak@28: return '"args" keys must not be 0-length strings.', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if type(v) ~= "table" then flickerstreak@28: return '"args" values must be tables', position and position .. "." .. k or k flickerstreak@28: end flickerstreak@28: local newposition flickerstreak@28: if position then flickerstreak@28: newposition = position .. ".args." .. k flickerstreak@28: else flickerstreak@28: newposition = "args." .. k flickerstreak@28: end flickerstreak@28: local err, pos = validateOptions(v, newposition, baseOptions, options.pass) flickerstreak@28: if err then flickerstreak@28: return err, pos flickerstreak@28: end flickerstreak@28: end flickerstreak@28: elseif kind == "execute" then flickerstreak@28: if type(options.confirm) ~= "string" and type(options.confirm) ~= "boolean" and type(options.confirm) ~= "nil" then flickerstreak@28: return '"confirm" must be a string, boolean, or nil', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.icon and type(options.icon) ~= "string" then flickerstreak@28: return'"icon" must be a string', position flickerstreak@28: end flickerstreak@28: if options.iconWidth or options.iconHeight then flickerstreak@28: if type(options.iconWidth) ~= "number" or type(options.iconHeight) ~= "number" then flickerstreak@28: return '"iconHeight" and "iconWidth" must be numbers', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if options.iconCoordLeft or options.iconCoordRight or options.iconCoordTop or options.iconCoordBottom then flickerstreak@28: if type(options.iconCoordLeft) ~= "number" or type(options.iconCoordRight) ~= "number" or type(options.iconCoordTop) ~= "number" or type(options.iconCoordBottom) ~= "number" then flickerstreak@28: return '"iconCoordLeft", "iconCoordRight", "iconCoordTop", and "iconCoordBottom" must be numbers', position flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local validatedOptions flickerstreak@28: flickerstreak@28: local values flickerstreak@28: local mysort_args flickerstreak@28: local mysort flickerstreak@28: local othersort flickerstreak@28: local othersort_validate flickerstreak@28: flickerstreak@28: local baseFunc, currentLevel flickerstreak@28: flickerstreak@28: local function confirmPopup(message, func, ...) flickerstreak@28: if not StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] then flickerstreak@28: StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] = {} flickerstreak@28: end flickerstreak@28: local t = StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] flickerstreak@28: for k in pairs(t) do flickerstreak@28: t[k] = nil flickerstreak@28: end flickerstreak@28: t.text = message flickerstreak@28: t.button1 = ACCEPT or "Accept" flickerstreak@28: t.button2 = CANCEL or "Cancel" flickerstreak@28: t.OnAccept = function() flickerstreak@28: func(unpack(t)) flickerstreak@28: end flickerstreak@28: for i = 1, select('#', ...) do flickerstreak@28: t[i] = select(i, ...) flickerstreak@28: end flickerstreak@28: t.timeout = 0 flickerstreak@28: t.whileDead = 1 flickerstreak@28: t.hideOnEscape = 1 flickerstreak@28: flickerstreak@28: Dewdrop:Close() flickerstreak@28: StaticPopup_Show("DEWDROP20_CONFIRM_DIALOG") flickerstreak@28: end flickerstreak@28: flickerstreak@28: flickerstreak@28: local function getMethod(settingname, handler, v, methodName, ...) -- "..." is simply returned straight out cause you can't do "a,b,c = 111,f(),222" flickerstreak@28: assert(v and type(v)=="table") flickerstreak@28: assert(methodName and type(methodName)=="string") flickerstreak@28: flickerstreak@28: local method = v[methodName] flickerstreak@28: if type(method)=="function" then flickerstreak@28: return method, ... flickerstreak@28: elseif type(method)=="string" then flickerstreak@28: if not handler then flickerstreak@28: Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method) flickerstreak@28: elseif not handler[method] then flickerstreak@28: Dewdrop:error("[%s] 'handler' method %q not defined", tostring(settingname), method) flickerstreak@28: end flickerstreak@28: return handler[method], handler, ... flickerstreak@28: end flickerstreak@28: flickerstreak@28: Dewdrop:error("[%s] Missing %q directive", tostring(settingname), methodName) flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function callMethod(settingname, handler, v, methodName, ...) flickerstreak@28: assert(v and type(v)=="table") flickerstreak@28: assert(methodName and type(methodName)=="string") flickerstreak@28: flickerstreak@28: local method = v[methodName] flickerstreak@28: if type(method)=="function" then flickerstreak@28: local success, ret,ret2,ret3,ret4 = pcall(v[methodName], ...) flickerstreak@28: if not success then flickerstreak@28: geterrorhandler()(ret) flickerstreak@28: return nil flickerstreak@28: end flickerstreak@28: return ret,ret2,ret3,ret4 flickerstreak@28: flickerstreak@28: elseif type(method)=="string" then flickerstreak@28: flickerstreak@28: local neg = method:match("^~(.-)$") flickerstreak@28: if neg then flickerstreak@28: method = neg flickerstreak@28: end flickerstreak@28: if not handler then flickerstreak@28: Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method) flickerstreak@28: elseif not handler[method] then flickerstreak@28: Dewdrop:error("[%s] 'handler' (%q) method %q not defined", tostring(settingname), handler.name or "(unnamed)", method) flickerstreak@28: end flickerstreak@28: local success, ret,ret2,ret3,ret4 = pcall(handler[method], handler, ...) flickerstreak@28: if not success then flickerstreak@28: geterrorhandler()(ret) flickerstreak@28: return nil flickerstreak@28: end flickerstreak@28: if neg then flickerstreak@28: return not ret flickerstreak@28: end flickerstreak@28: return ret,ret2,ret3,ret4 flickerstreak@28: elseif method == false then flickerstreak@28: return nil flickerstreak@28: end flickerstreak@28: flickerstreak@28: Dewdrop:error("[%s] Missing %q directive in %q", tostring(settingname), methodName, v.name or "(unnamed)") flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function skip1Nil(...) flickerstreak@28: if select(1,...)==nil then flickerstreak@28: return select(2,...) flickerstreak@28: end flickerstreak@28: return ... flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:FeedAceOptionsTable(options, difference) flickerstreak@28: self:argCheck(options, 2, "table") flickerstreak@28: self:argCheck(difference, 3, "nil", "number") flickerstreak@28: if not currentLevel then flickerstreak@28: self:error("Cannot call `FeedAceOptionsTable' outside of a Dewdrop declaration") flickerstreak@28: end flickerstreak@28: if not difference then flickerstreak@28: difference = 0 flickerstreak@28: end flickerstreak@28: if not validatedOptions then flickerstreak@28: validatedOptions = {} flickerstreak@28: end flickerstreak@28: if not validatedOptions[options] then flickerstreak@28: local err, position = validateOptions(options) flickerstreak@28: flickerstreak@28: if err then flickerstreak@28: if position then flickerstreak@28: Dewdrop:error(position .. ": " .. err) flickerstreak@28: else flickerstreak@28: Dewdrop:error(err) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: validatedOptions[options] = true flickerstreak@28: end flickerstreak@28: local level = levels[currentLevel] flickerstreak@28: if not level then flickerstreak@28: self:error("Improper level given") flickerstreak@28: end flickerstreak@28: if not values then flickerstreak@28: values = {} flickerstreak@28: else flickerstreak@28: for k,v in pairs(values) do flickerstreak@28: values[k] = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local current = level flickerstreak@28: while current do -- this traverses from higher level numbers to lower, building "values" with leaf nodes first and trunk nodes later flickerstreak@28: if current.num == difference + 1 then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: table.insert(values, current.value) flickerstreak@28: current = levels[current.num - 1] flickerstreak@28: end flickerstreak@28: flickerstreak@28: local realOptions = options flickerstreak@28: local handler = options.handler flickerstreak@28: local passTable flickerstreak@28: local passValue flickerstreak@28: while #values > 0 do -- This loop traverses values from the END (trunk nodes first, then onto leaf nodes) flickerstreak@28: if options.pass then flickerstreak@28: if options.get and options.set then flickerstreak@28: passTable = options flickerstreak@28: elseif not passTable then flickerstreak@28: passTable = options flickerstreak@28: end flickerstreak@28: else flickerstreak@28: passTable = nil flickerstreak@28: end flickerstreak@28: local value = table.remove(values) flickerstreak@28: options = options.args and options.args[value] flickerstreak@28: if not options then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: handler = options.handler or handler flickerstreak@28: passValue = passTable and value or nil flickerstreak@28: end flickerstreak@28: flickerstreak@28: if options.type == "group" then flickerstreak@28: local hidden = options.hidden flickerstreak@28: if type(hidden) == "function" or type(hidden) == "string" then flickerstreak@28: hidden = callMethod(options.name or "(options root)", handler, options, "hidden", options.passValue) or false flickerstreak@28: end flickerstreak@28: if hidden then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: local disabled = options.disabled flickerstreak@28: if type(disabled) == "function" or type(disabled) == "string" then flickerstreak@28: disabled = callMethod(options.name or "(options root)", handler, options, "disabled", options.passValue) or false flickerstreak@28: end flickerstreak@28: if disabled then flickerstreak@28: self:AddLine( flickerstreak@28: 'text', DISABLED, flickerstreak@28: 'disabled', true flickerstreak@28: ) flickerstreak@28: return flickerstreak@28: end flickerstreak@28: for k in pairs(options.args) do flickerstreak@28: table.insert(values, k) flickerstreak@28: end flickerstreak@28: if options.pass then flickerstreak@28: if options.get and options.set then flickerstreak@28: passTable = options flickerstreak@28: elseif not passTable then flickerstreak@28: passTable = options flickerstreak@28: end flickerstreak@28: else flickerstreak@28: passTable = nil flickerstreak@28: end flickerstreak@28: if not mysort then flickerstreak@28: mysort = function(a, b) flickerstreak@28: local alpha, bravo = mysort_args[a], mysort_args[b] flickerstreak@28: local alpha_order = alpha.order or 100 flickerstreak@28: local bravo_order = bravo.order or 100 flickerstreak@28: local alpha_name = alpha.guiName or alpha.name flickerstreak@28: local bravo_name = bravo.guiName or bravo.name flickerstreak@28: if alpha_order == bravo_order then flickerstreak@28: if not alpha_name then flickerstreak@28: return bravo_name flickerstreak@28: elseif not bravo_name then flickerstreak@28: return false flickerstreak@28: else flickerstreak@28: return alpha_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < bravo_name:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if alpha_order < 0 then flickerstreak@28: if bravo_order > 0 then flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if bravo_order < 0 then flickerstreak@28: return true flickerstreak@28: end flickerstreak@28: end flickerstreak@28: return alpha_order < bravo_order flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: mysort_args = options.args flickerstreak@28: table.sort(values, mysort) flickerstreak@28: mysort_args = nil flickerstreak@28: local hasBoth = #values >= 1 and (options.args[values[1]].order or 100) > 0 and (options.args[values[#values]].order or 100) < 0 flickerstreak@28: local last_order = 1 flickerstreak@28: for _,k in ipairs(values) do flickerstreak@28: local v = options.args[k] flickerstreak@28: local handler = v.handler or handler flickerstreak@28: if hasBoth and last_order > 0 and (v.order or 100) < 0 then flickerstreak@28: hasBoth = false flickerstreak@28: self:AddLine() flickerstreak@28: end flickerstreak@28: local hidden, disabled = v.guiHidden or v.hidden, v.disabled flickerstreak@28: flickerstreak@28: if type(hidden) == "function" or type(hidden) == "string" then flickerstreak@28: hidden = callMethod(k, handler, v, "hidden", v.passValue) or false flickerstreak@28: end flickerstreak@28: if not hidden then flickerstreak@28: if type(disabled) == "function" or type(disabled) == "string" then flickerstreak@28: disabled = callMethod(k, handler, v, "disabled", v.passValue) or false flickerstreak@28: end flickerstreak@28: local name = (v.guiIconOnly and v.icon) and "" or (v.guiName or v.name) flickerstreak@28: local desc = v.guiDesc or v.desc flickerstreak@28: local iconHeight = v.iconHeight or 16 flickerstreak@28: local iconWidth = v.iconWidth or 16 flickerstreak@28: local iconCoordLeft = v.iconCoordLeft flickerstreak@28: local iconCoordRight = v.iconCoordRight flickerstreak@28: local iconCoordBottom = v.iconCoordBottom flickerstreak@28: local iconCoordTop = v.iconCoordTop flickerstreak@28: local tooltipTitle, tooltipText flickerstreak@28: tooltipTitle = name flickerstreak@28: if name ~= desc then flickerstreak@28: tooltipText = desc flickerstreak@28: end flickerstreak@28: if type(v.usage) == "string" and v.usage:trim():len() > 0 then flickerstreak@28: if tooltipText then flickerstreak@28: tooltipText = tooltipText .. "\n\n" .. USAGE_TOOLTIP:format(v.usage) flickerstreak@28: else flickerstreak@28: tooltipText = USAGE_TOOLTIP:format(v.usage) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local v_p = passTable flickerstreak@28: if not v_p or (v.type ~= "execute" and v.get and v.set) or (v.type == "execute" and v.func) then flickerstreak@28: v_p = v flickerstreak@28: end flickerstreak@28: local passValue = v.passValue or (v_p~=v and k) or nil flickerstreak@28: if v.type == "toggle" then flickerstreak@28: local checked = callMethod(name, handler, v_p, "get", passValue) or false flickerstreak@28: local checked_arg = checked flickerstreak@28: if type(v_p.get)=="string" and v_p.get:match("^~") then flickerstreak@28: checked_arg = not checked flickerstreak@28: end flickerstreak@28: local func, arg1, arg2, arg3 = getMethod(name, handler, v_p, "set", skip1Nil(passValue, not checked_arg)) flickerstreak@28: if v.guiNameIsMap then flickerstreak@28: checked = checked and true or false flickerstreak@28: name = tostring(v.map and v.map[checked]):gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1") flickerstreak@28: tooltipTitle = name flickerstreak@28: checked = true--nil flickerstreak@28: end flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'checked', checked, flickerstreak@28: 'isRadio', v.isRadio, flickerstreak@28: 'func', func, flickerstreak@28: 'arg1', arg1, flickerstreak@28: 'arg2', arg2, flickerstreak@28: 'arg3', arg3, flickerstreak@28: 'disabled', disabled, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText flickerstreak@28: ) flickerstreak@28: elseif v.type == "execute" then flickerstreak@28: local func, arg1, arg2, arg3, arg4 flickerstreak@28: local confirm = v.confirm flickerstreak@28: if confirm == true then flickerstreak@28: confirm = DEFAULT_CONFIRM_MESSAGE:format(tooltipText or tooltipTitle) flickerstreak@28: func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue) flickerstreak@28: elseif type(confirm) == "string" then flickerstreak@28: func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue) flickerstreak@28: else flickerstreak@28: func,arg1,arg2 = getMethod(name, handler, v_p, "func", passValue) flickerstreak@28: end flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'checked', checked, flickerstreak@28: 'func', func, flickerstreak@28: 'arg1', arg1, flickerstreak@28: 'arg2', arg2, flickerstreak@28: 'arg3', arg3, flickerstreak@28: 'arg4', arg4, flickerstreak@28: 'disabled', disabled, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText, flickerstreak@28: 'icon', v.icon, flickerstreak@28: 'iconHeight', iconHeight, flickerstreak@28: 'iconWidth', iconWidth, flickerstreak@28: 'iconCoordLeft', iconCoordLeft, flickerstreak@28: 'iconCoordRight', iconCoordRight, flickerstreak@28: 'iconCoordTop', iconCoordTop, flickerstreak@28: 'iconCoordBottom', iconCoordBottom flickerstreak@28: ) flickerstreak@28: elseif v.type == "range" then flickerstreak@28: local sliderValue flickerstreak@28: sliderValue = callMethod(name, handler, v_p, "get", passValue) or 0 flickerstreak@28: local sliderFunc, sliderArg1, sliderArg2 = getMethod(name, handler, v_p, "set", passValue) flickerstreak@28: if tooltipText then flickerstreak@28: tooltipText = format("%s\n\n%s", tooltipText, RANGE_TOOLTIP) flickerstreak@28: else flickerstreak@28: tooltipText = RANGE_TOOLTIP flickerstreak@28: end flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'hasArrow', true, flickerstreak@28: 'hasSlider', true, flickerstreak@28: 'sliderMin', v.min or 0, flickerstreak@28: 'sliderMax', v.max or 1, flickerstreak@28: 'sliderStep', v.step or 0, flickerstreak@28: 'sliderBigStep', v.bigStep or nil, flickerstreak@28: 'sliderIsPercent', v.isPercent or false, flickerstreak@28: 'sliderValue', sliderValue, flickerstreak@28: 'sliderFunc', sliderFunc, flickerstreak@28: 'sliderArg1', sliderArg1, flickerstreak@28: 'sliderArg2', sliderArg2, flickerstreak@28: 'fromAceOptions', true, flickerstreak@28: 'disabled', disabled, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText, flickerstreak@28: 'icon', v.icon, flickerstreak@28: 'iconHeight', iconHeight, flickerstreak@28: 'iconWidth', iconWidth, flickerstreak@28: 'iconCoordLeft', iconCoordLeft, flickerstreak@28: 'iconCoordRight', iconCoordRight, flickerstreak@28: 'iconCoordTop', iconCoordTop, flickerstreak@28: 'iconCoordBottom', iconCoordBottom flickerstreak@28: ) flickerstreak@28: elseif v.type == "color" then flickerstreak@28: local r,g,b,a = callMethod(name, handler, v_p, "get", passValue) flickerstreak@28: if not r then flickerstreak@28: r,g,b,a = 0,0,0,0 flickerstreak@28: end flickerstreak@28: local colorFunc, colorArg1, colorArg2 = getMethod(name, handler, v_p, "set", passValue) flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'hasArrow', true, flickerstreak@28: 'hasColorSwatch', true, flickerstreak@28: 'r', r, flickerstreak@28: 'g', g, flickerstreak@28: 'b', b, flickerstreak@28: 'opacity', v.hasAlpha and a or nil, flickerstreak@28: 'hasOpacity', v.hasAlpha, flickerstreak@28: 'colorFunc', colorFunc, flickerstreak@28: 'colorArg1', colorArg1, flickerstreak@28: 'colorArg2', colorArg2, flickerstreak@28: 'disabled', disabled, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText flickerstreak@28: ) flickerstreak@28: elseif v.type == "text" then flickerstreak@28: if type(v.validate) == "table" then flickerstreak@28: local func,arg1,arg2 flickerstreak@28: if v.onClick then flickerstreak@28: func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue) flickerstreak@28: end flickerstreak@28: local checked flickerstreak@28: if v.isChecked then flickerstreak@28: checked = callMethod(name, handler, v, "isChecked", passValue) or false flickerstreak@28: end flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'hasArrow', true, flickerstreak@28: 'value', k, flickerstreak@28: 'func', func, flickerstreak@28: 'arg1', arg1, flickerstreak@28: 'arg2', arg2, flickerstreak@28: 'mouseoverUnderline', func and true or nil, flickerstreak@28: 'disabled', disabled, flickerstreak@28: 'checked', checked, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText, flickerstreak@28: 'icon', v.icon, flickerstreak@28: 'iconHeight', iconHeight, flickerstreak@28: 'iconWidth', iconWidth, flickerstreak@28: 'iconCoordLeft', iconCoordLeft, flickerstreak@28: 'iconCoordRight', iconCoordRight, flickerstreak@28: 'iconCoordTop', iconCoordTop, flickerstreak@28: 'iconCoordBottom', iconCoordBottom flickerstreak@28: ) flickerstreak@28: else flickerstreak@28: local editBoxText flickerstreak@28: editBoxText = callMethod(name, handler, v_p, "get", passValue) or "" flickerstreak@28: local editBoxFunc, editBoxArg1, editBoxArg2 = getMethod(name, handler, v_p, "set", passValue) flickerstreak@28: flickerstreak@28: local editBoxValidateFunc, editBoxValidateArg1 flickerstreak@28: flickerstreak@28: if v.validate and v.validate ~= "keybinding" then flickerstreak@28: if v.validate == "keybinding" then flickerstreak@28: if tooltipText then flickerstreak@28: tooltipText = format("%s\n\n%s", tooltipText, RESET_KEYBINDING_DESC) flickerstreak@28: else flickerstreak@28: tooltipText = RESET_KEYBINDING_DESC flickerstreak@28: end flickerstreak@28: else flickerstreak@28: editBoxValidateFunc, editBoxValidateArg1 = getMethod(name, handler, v, "validate") -- no passvalue! flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'hasArrow', true, flickerstreak@28: 'icon', v.icon, flickerstreak@28: 'iconHeight', iconHeight, flickerstreak@28: 'iconWidth', iconWidth, flickerstreak@28: 'iconCoordLeft', iconCoordLeft, flickerstreak@28: 'iconCoordRight', iconCoordRight, flickerstreak@28: 'iconCoordTop', iconCoordTop, flickerstreak@28: 'iconCoordBottom', iconCoordBottom, flickerstreak@28: 'hasEditBox', true, flickerstreak@28: 'editBoxText', editBoxText, flickerstreak@28: 'editBoxFunc', editBoxFunc, flickerstreak@28: 'editBoxArg1', editBoxArg1, flickerstreak@28: 'editBoxArg2', editBoxArg2, flickerstreak@28: 'editBoxValidateFunc', editBoxValidateFunc, flickerstreak@28: 'editBoxValidateArg1', editBoxValidateArg1, flickerstreak@28: 'editBoxIsKeybinding', v.validate == "keybinding", flickerstreak@28: 'editBoxKeybindingOnly', v.keybindingOnly, flickerstreak@28: 'editBoxKeybindingExcept', v.keybindingExcept, flickerstreak@28: 'disabled', disabled, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText flickerstreak@28: ) flickerstreak@28: end flickerstreak@28: elseif v.type == "group" then flickerstreak@28: local func,arg1,arg2 flickerstreak@28: if v.onClick then flickerstreak@28: func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue) flickerstreak@28: end flickerstreak@28: local checked flickerstreak@28: if v.isChecked then flickerstreak@28: checked = callMethod(name, handler, v, "isChecked", passValue) or false flickerstreak@28: end flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'hasArrow', true, flickerstreak@28: 'value', k, flickerstreak@28: 'func', func, flickerstreak@28: 'arg1', arg1, flickerstreak@28: 'arg2', arg2, flickerstreak@28: 'mouseoverUnderline', func and true or nil, flickerstreak@28: 'disabled', disabled, flickerstreak@28: 'checked', checked, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText, flickerstreak@28: 'icon', v.icon, flickerstreak@28: 'iconHeight', iconHeight, flickerstreak@28: 'iconWidth', iconWidth, flickerstreak@28: 'iconCoordLeft', iconCoordLeft, flickerstreak@28: 'iconCoordRight', iconCoordRight, flickerstreak@28: 'iconCoordTop', iconCoordTop, flickerstreak@28: 'iconCoordBottom', iconCoordBottom flickerstreak@28: ) flickerstreak@28: elseif v.type == "header" then flickerstreak@28: if name == "" or not name then flickerstreak@28: self:AddLine( flickerstreak@28: 'isTitle', true, flickerstreak@28: 'icon', v.icon, flickerstreak@28: 'iconHeight', iconHeight, flickerstreak@28: 'iconWidth', iconWidth, flickerstreak@28: 'iconCoordLeft', iconCoordLeft, flickerstreak@28: 'iconCoordRight', iconCoordRight, flickerstreak@28: 'iconCoordTop', iconCoordTop, flickerstreak@28: 'iconCoordBottom', iconCoordBottom flickerstreak@28: ) flickerstreak@28: else flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'isTitle', true, flickerstreak@28: 'icon', v.icon, flickerstreak@28: 'iconHeight', iconHeight, flickerstreak@28: 'iconWidth', iconWidth, flickerstreak@28: 'iconCoordLeft', iconCoordLeft, flickerstreak@28: 'iconCoordRight', iconCoordRight, flickerstreak@28: 'iconCoordTop', iconCoordTop, flickerstreak@28: 'iconCoordBottom', iconCoordBottom flickerstreak@28: ) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: last_order = v.order or 100 flickerstreak@28: end flickerstreak@28: elseif options.type == "text" and type(options.validate) == "table" then flickerstreak@28: local current flickerstreak@28: local options_p = passTable flickerstreak@28: if not options_p or (options.get and options.set) then flickerstreak@28: options_p = options flickerstreak@28: passTable = nil flickerstreak@28: passValue = nil flickerstreak@28: end flickerstreak@28: local multiToggle = options.multiToggle flickerstreak@28: local passValue = options.passValue or passValue flickerstreak@28: if not multiToggle then flickerstreak@28: current = callMethod(k, handler, options_p, "get", passValue) flickerstreak@28: end flickerstreak@28: local indexed = true flickerstreak@28: for k,v in pairs(options.validate) do flickerstreak@28: if type(k) ~= "number" then flickerstreak@28: indexed = false flickerstreak@28: end flickerstreak@28: table.insert(values, k) flickerstreak@28: end flickerstreak@28: if not indexed then flickerstreak@28: if not othersort then flickerstreak@28: othersort = function(alpha, bravo) flickerstreak@28: return othersort_validate[alpha]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() < othersort_validate[bravo]:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):upper() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: othersort_validate = options.validate flickerstreak@28: table.sort(values, othersort) flickerstreak@28: othersort_validate = nil flickerstreak@28: end flickerstreak@28: for _,k in ipairs(values) do flickerstreak@28: local v = options.validate[k] flickerstreak@28: if type(k) == "number" then flickerstreak@28: k = v flickerstreak@28: end flickerstreak@28: local func, arg1, arg2, arg3, arg4 = getMethod(k, handler, options_p, "set", skip1Nil(passValue, k)) flickerstreak@28: local checked flickerstreak@28: if multiToggle then flickerstreak@28: checked = callMethod(k, handler, options_p, "get", skip1Nil(passValue, k)) or false flickerstreak@28: if arg2 == nil then flickerstreak@28: arg2 = not checked flickerstreak@28: elseif arg3 == nil then flickerstreak@28: arg3 = not checked flickerstreak@28: else flickerstreak@28: arg4 = not checked flickerstreak@28: end flickerstreak@28: else flickerstreak@28: checked = (k == current or (type(k) == "string" and type(current) == "string" and k:lower() == current:lower())) flickerstreak@28: if checked then flickerstreak@28: func, arg1, arg2, arg3, arg4 = nil, nil, nil, nil, nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local tooltipTitle flickerstreak@28: local tooltipText flickerstreak@28: if options.validateDesc then flickerstreak@28: tooltipTitle = v flickerstreak@28: tooltipText = options.validateDesc[k] flickerstreak@28: else flickerstreak@28: tooltipTitle = options.guiName or options.name flickerstreak@28: tooltipText = v flickerstreak@28: end flickerstreak@28: self:AddLine( flickerstreak@28: 'text', v, flickerstreak@28: 'func', func, flickerstreak@28: 'arg1', arg1, flickerstreak@28: 'arg2', arg2, flickerstreak@28: 'arg3', arg3, flickerstreak@28: 'arg4', arg4, flickerstreak@28: 'isRadio', not multiToggle, flickerstreak@28: 'checked', checked, flickerstreak@28: 'tooltipTitle', tooltipTitle, flickerstreak@28: 'tooltipText', tooltipText flickerstreak@28: ) flickerstreak@28: end flickerstreak@28: for k in pairs(values) do flickerstreak@28: values[k] = nil flickerstreak@28: end flickerstreak@28: else flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: return true flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:FeedTable(s, difference) flickerstreak@28: self:argCheck(s, 2, "table") flickerstreak@28: self:argCheck(difference, 3, "nil", "number") flickerstreak@28: if not currentLevel then flickerstreak@28: self:error("Cannot call `FeedTable' outside of a Dewdrop declaration") flickerstreak@28: end flickerstreak@28: if not difference then flickerstreak@28: difference = 0 flickerstreak@28: end flickerstreak@28: local level = levels[currentLevel] flickerstreak@28: if not level then flickerstreak@28: self:error("Improper level given") flickerstreak@28: end flickerstreak@28: if not values then flickerstreak@28: values = {} flickerstreak@28: else flickerstreak@28: for k,v in pairs(values) do flickerstreak@28: values[k] = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local t = s.subMenu and s or {subMenu = s} flickerstreak@28: local current = level flickerstreak@28: while current do flickerstreak@28: if current.num == difference + 1 then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: table.insert(values, current.value) flickerstreak@28: current = levels[current.num - 1] flickerstreak@28: end flickerstreak@28: flickerstreak@28: while #values > 0 do flickerstreak@28: local value = table.remove(values) flickerstreak@28: t = t.subMenu and t.subMenu[value] flickerstreak@28: if not t then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: if t.subMenu or current.num == 1 then flickerstreak@28: for k in pairs(t.subMenu) do flickerstreak@28: table.insert(values, k) flickerstreak@28: end flickerstreak@28: table.sort(values) flickerstreak@28: for _,k in ipairs(values) do flickerstreak@28: local argTable = {"value", k} flickerstreak@28: for key, val in pairs(t.subMenu[k]) do flickerstreak@28: table.insert(argTable, key) flickerstreak@28: table.insert(argTable, val) flickerstreak@28: end flickerstreak@28: self:AddLine(unpack(argTable)) flickerstreak@28: end flickerstreak@28: for k in pairs(values) do flickerstreak@28: values[k] = nil flickerstreak@28: end flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: return true flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Refresh(self, level) flickerstreak@28: if type(level) == "number" then flickerstreak@28: level = levels[level] flickerstreak@28: end flickerstreak@28: if not level then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: if baseFunc then flickerstreak@28: Clear(self, level) flickerstreak@28: currentLevel = level.num flickerstreak@28: if type(baseFunc) == "table" then flickerstreak@28: if currentLevel == 1 then flickerstreak@28: local handler = baseFunc.handler flickerstreak@28: if handler then flickerstreak@28: local name = tostring(handler) flickerstreak@28: if not name:find('^table:') and not handler.hideMenuTitle then flickerstreak@28: name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1") flickerstreak@28: self:AddLine( flickerstreak@28: 'text', name, flickerstreak@28: 'isTitle', true flickerstreak@28: ) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: -- elseif level.parentText then flickerstreak@28: -- self:AddLine( flickerstreak@28: -- 'text', level.parentText, flickerstreak@28: -- 'tooltipTitle', level.parentTooltipTitle, flickerstreak@28: -- 'tooltipText', level.parentTooltipText, flickerstreak@28: -- 'tooltipFunc', level.parentTooltipFunc, flickerstreak@28: -- 'isTitle', true flickerstreak@28: -- ) flickerstreak@28: end flickerstreak@28: self:FeedAceOptionsTable(baseFunc) flickerstreak@28: if currentLevel == 1 then flickerstreak@28: self:AddLine( flickerstreak@28: 'text', CLOSE, flickerstreak@28: 'tooltipTitle', CLOSE, flickerstreak@28: 'tooltipText', CLOSE_DESC, flickerstreak@28: 'closeWhenClicked', true flickerstreak@28: ) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: -- if level.parentText then flickerstreak@28: -- self:AddLine( flickerstreak@28: -- 'text', level.parentText, flickerstreak@28: -- 'tooltipTitle', level.parentTooltipTitle, flickerstreak@28: -- 'tooltipText', level.parentTooltipText, flickerstreak@28: -- 'tooltipFunc', level.parentTooltipFunc, flickerstreak@28: -- 'isTitle', true flickerstreak@28: -- ) flickerstreak@28: -- end flickerstreak@28: 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@28: end flickerstreak@28: currentLevel = nil flickerstreak@28: CheckSize(self, level) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:Refresh(level) flickerstreak@28: self:argCheck(level, 2, "number", "nil") flickerstreak@28: if not level then flickerstreak@28: for k,v in pairs(levels) do flickerstreak@28: Refresh(self, v) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: Refresh(self, levels[level]) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: function OpenSlider(self, parent) flickerstreak@28: if not sliderFrame then flickerstreak@28: sliderFrame = CreateFrame("Frame", nil, nil) flickerstreak@28: sliderFrame:SetWidth(100) flickerstreak@28: sliderFrame:SetHeight(170) flickerstreak@28: sliderFrame:SetScale(UIParent:GetScale()) flickerstreak@28: sliderFrame:SetBackdrop(tmp( flickerstreak@28: 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background", flickerstreak@28: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@28: 'tile', true, flickerstreak@28: 'insets', tmp2( flickerstreak@28: 'left', 5, flickerstreak@28: 'right', 5, flickerstreak@28: 'top', 5, flickerstreak@28: 'bottom', 5 flickerstreak@28: ), flickerstreak@28: 'tileSize', 16, flickerstreak@28: 'edgeSize', 16 flickerstreak@28: )) flickerstreak@28: sliderFrame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@28: if sliderFrame.SetTopLevel then flickerstreak@28: sliderFrame:SetTopLevel(true) flickerstreak@28: end flickerstreak@28: sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) flickerstreak@28: sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) flickerstreak@28: sliderFrame:EnableMouse(true) flickerstreak@28: sliderFrame:EnableMouseWheel(true) flickerstreak@28: sliderFrame:Hide() flickerstreak@28: sliderFrame:SetPoint("CENTER", UIParent, "CENTER") flickerstreak@28: local slider = CreateFrame("Slider", nil, sliderFrame) flickerstreak@28: sliderFrame.slider = slider flickerstreak@28: slider:SetOrientation("VERTICAL") flickerstreak@28: slider:SetMinMaxValues(0, 1) flickerstreak@28: slider:SetValueStep(0.000000001) flickerstreak@28: slider:SetValue(0.5) flickerstreak@28: slider:SetWidth(16) flickerstreak@28: slider:SetHeight(128) flickerstreak@28: slider:SetPoint("LEFT", sliderFrame, "LEFT", 15, 0) flickerstreak@28: slider:SetBackdrop(tmp( flickerstreak@28: 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background", flickerstreak@28: 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border", flickerstreak@28: 'tile', true, flickerstreak@28: 'edgeSize', 8, flickerstreak@28: 'tileSize', 8, flickerstreak@28: 'insets', tmp2( flickerstreak@28: 'left', 3, flickerstreak@28: 'right', 3, flickerstreak@28: 'top', 3, flickerstreak@28: 'bottom', 3 flickerstreak@28: ) flickerstreak@28: )) flickerstreak@28: local texture = slider:CreateTexture() flickerstreak@28: slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical") flickerstreak@28: local text = slider:CreateFontString(nil, "ARTWORK") flickerstreak@28: sliderFrame.topText = text flickerstreak@28: text:SetFontObject(GameFontGreenSmall) flickerstreak@28: text:SetText("100%") flickerstreak@28: text:SetPoint("BOTTOM", slider, "TOP") flickerstreak@28: local text = slider:CreateFontString(nil, "ARTWORK") flickerstreak@28: sliderFrame.bottomText = text flickerstreak@28: text:SetFontObject(GameFontGreenSmall) flickerstreak@28: text:SetText("0%") flickerstreak@28: text:SetPoint("TOP", slider, "BOTTOM") flickerstreak@28: local editBox = CreateFrame("EditBox", nil, sliderFrame) flickerstreak@28: sliderFrame.currentText = editBox flickerstreak@28: editBox:SetFontObject(ChatFontNormal) flickerstreak@28: editBox:SetHeight(13) flickerstreak@28: editBox:SetPoint("RIGHT", sliderFrame, "RIGHT", -16, 0) flickerstreak@28: editBox:SetPoint("LEFT", slider, "RIGHT", 12, 0) flickerstreak@28: editBox:SetText("50%") flickerstreak@28: editBox:SetJustifyH("CENTER") flickerstreak@28: flickerstreak@28: local width = editBox:GetWidth()/2 + 10 flickerstreak@28: local left = editBox:CreateTexture(nil, "BACKGROUND") flickerstreak@28: left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left") flickerstreak@28: left:SetTexCoord(0, width / 256, 0, 1) flickerstreak@28: left:SetWidth(width) flickerstreak@28: left:SetHeight(32) flickerstreak@28: left:SetPoint("LEFT", editBox, "LEFT", -10, 0) flickerstreak@28: local right = editBox:CreateTexture(nil, "BACKGROUND") flickerstreak@28: right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right") flickerstreak@28: right:SetTexCoord(1 - width / 256, 1, 0, 1) flickerstreak@28: right:SetWidth(width) flickerstreak@28: right:SetHeight(32) flickerstreak@28: right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0) flickerstreak@28: flickerstreak@28: local changed = false flickerstreak@28: local inside = false flickerstreak@28: slider:SetScript("OnValueChanged", function() flickerstreak@28: if sliderFrame.changing then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: changed = true flickerstreak@28: local done = false flickerstreak@28: if sliderFrame.parent and sliderFrame.parent.sliderFunc then flickerstreak@28: local min = sliderFrame.parent.sliderMin or 0 flickerstreak@28: local max = sliderFrame.parent.sliderMax or 1 flickerstreak@28: local step flickerstreak@28: if sliderFrame.fineStep then flickerstreak@28: step = sliderFrame.parent.sliderStep or (max - min) / 100 flickerstreak@28: else flickerstreak@28: step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100 flickerstreak@28: end flickerstreak@28: local value = (1 - slider:GetValue()) * (max - min) + min flickerstreak@28: if step > 0 then flickerstreak@28: value = math.floor((value - min) / step + 0.5) * step + min flickerstreak@28: if value > max then flickerstreak@28: value = max flickerstreak@28: elseif value < min then flickerstreak@28: value = min flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if value == sliderFrame.lastValue then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: sliderFrame.lastValue = value flickerstreak@28: local text = sliderFrame.parent.sliderFunc(getArgs(sliderFrame.parent, 'sliderArg', 1, value)) flickerstreak@28: if sliderFrame.parent.fromAceOptions then flickerstreak@28: text = nil flickerstreak@28: elseif type(text) == "string" or type(text) == "number" then flickerstreak@28: sliderFrame.currentText:SetText(text) flickerstreak@28: done = true flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if not done then flickerstreak@28: local min = sliderFrame.parent.sliderMin or 0 flickerstreak@28: local max = sliderFrame.parent.sliderMax or 1 flickerstreak@28: local step flickerstreak@28: if sliderFrame.fineStep then flickerstreak@28: step = sliderFrame.parent.sliderStep or (max - min) / 100 flickerstreak@28: else flickerstreak@28: step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100 flickerstreak@28: end flickerstreak@28: local value = (1 - slider:GetValue()) * (max - min) + min flickerstreak@28: if step > 0 then flickerstreak@28: value = math.floor((value - min) / step + 0.5) * step + min flickerstreak@28: if value > max then flickerstreak@28: value = max flickerstreak@28: elseif value < min then flickerstreak@28: value = min flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if sliderFrame.parent.sliderIsPercent then flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.0f%%", value * 100)) flickerstreak@28: else flickerstreak@28: if step < 0.1 then flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.2f", value)) flickerstreak@28: elseif step < 1 then flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.1f", value)) flickerstreak@28: else flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.0f", value)) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: local function onEnter() flickerstreak@28: StopCounting(self, sliderFrame.level) flickerstreak@28: showGameTooltip(sliderFrame.parent) flickerstreak@28: end flickerstreak@28: local function onLeave() flickerstreak@28: GameTooltip:Hide() flickerstreak@28: end flickerstreak@28: sliderFrame:SetScript("OnEnter", onEnter) flickerstreak@28: sliderFrame:SetScript("OnLeave", function() flickerstreak@28: GameTooltip:Hide() flickerstreak@28: if changed then flickerstreak@28: local parent = sliderFrame.parent flickerstreak@28: local sliderFunc = parent.sliderFunc flickerstreak@28: for i = 1, sliderFrame.level - 1 do flickerstreak@28: Refresh(self, levels[i]) flickerstreak@28: end flickerstreak@28: local newParent flickerstreak@28: for _,button in ipairs(levels[sliderFrame.level-1].buttons) do flickerstreak@28: if button.sliderFunc == sliderFunc then flickerstreak@28: newParent = button flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if newParent then flickerstreak@28: OpenSlider(self, newParent) flickerstreak@28: else flickerstreak@28: sliderFrame:Hide() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: editBox:SetScript("OnEnter", onEnter) flickerstreak@28: editBox:SetScript("OnLeave", onLeave) flickerstreak@28: slider:SetScript("OnMouseDown", function() flickerstreak@28: sliderFrame.mouseDown = true flickerstreak@28: GameTooltip:Hide() flickerstreak@28: end) flickerstreak@28: slider:SetScript("OnMouseUp", function() flickerstreak@28: sliderFrame.mouseDown = false flickerstreak@28: if changed--[[ and not inside]] then flickerstreak@28: local parent = sliderFrame.parent flickerstreak@28: local sliderFunc = parent.sliderFunc flickerstreak@28: for i = 1, sliderFrame.level - 1 do flickerstreak@28: Refresh(self, levels[i]) flickerstreak@28: end flickerstreak@28: local newParent flickerstreak@28: for _,button in ipairs(levels[sliderFrame.level-1].buttons) do flickerstreak@28: if button.sliderFunc == sliderFunc then flickerstreak@28: newParent = button flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if newParent then flickerstreak@28: OpenSlider(self, newParent) flickerstreak@28: else flickerstreak@28: sliderFrame:Hide() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if inside then flickerstreak@28: showGameTooltip(sliderFrame.parent) flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: slider:SetScript("OnEnter", function() flickerstreak@28: inside = true flickerstreak@28: StopCounting(self, sliderFrame.level) flickerstreak@28: showGameTooltip(sliderFrame.parent) flickerstreak@28: end) flickerstreak@28: slider:SetScript("OnLeave", function() flickerstreak@28: inside = false flickerstreak@28: GameTooltip:Hide() flickerstreak@28: if changed and not sliderFrame.mouseDown then flickerstreak@28: local parent = sliderFrame.parent flickerstreak@28: local sliderFunc = parent.sliderFunc flickerstreak@28: for i = 1, sliderFrame.level - 1 do flickerstreak@28: Refresh(self, levels[i]) flickerstreak@28: end flickerstreak@28: local newParent flickerstreak@28: for _,button in ipairs(levels[sliderFrame.level-1].buttons) do flickerstreak@28: if button.sliderFunc == sliderFunc then flickerstreak@28: newParent = button flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if newParent then flickerstreak@28: OpenSlider(self, newParent) flickerstreak@28: else flickerstreak@28: sliderFrame:Hide() flickerstreak@28: end flickerstreak@28: flickerstreak@28: changed = false flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: sliderFrame:SetScript("OnMouseWheel", function(t, a1) flickerstreak@28: local arg1 = a1 or arg1 flickerstreak@28: local up = arg1 > 0 flickerstreak@28: flickerstreak@28: local min = sliderFrame.parent.sliderMin or 0 flickerstreak@28: local max = sliderFrame.parent.sliderMax or 1 flickerstreak@28: local step = sliderFrame.parent.sliderStep or (max - min) / 100 flickerstreak@28: if step <= 0 then flickerstreak@28: step = (max - min) / 100 flickerstreak@28: end flickerstreak@28: flickerstreak@28: local value = (1 - slider:GetValue()) * (max - min) + min flickerstreak@28: if up then flickerstreak@28: value = value + step flickerstreak@28: else flickerstreak@28: value = value - step flickerstreak@28: end flickerstreak@28: if value > max then flickerstreak@28: value = max flickerstreak@28: elseif value < min then flickerstreak@28: value = min flickerstreak@28: end flickerstreak@28: sliderFrame.fineStep = true flickerstreak@28: if max<=min then flickerstreak@28: slider:SetValue(0) flickerstreak@28: else flickerstreak@28: slider:SetValue(1 - (value - min) / (max - min)) flickerstreak@28: end flickerstreak@28: sliderFrame.fineStep = nil flickerstreak@28: end) flickerstreak@28: slider:SetScript("OnMouseWheel", sliderFrame:GetScript("OnMouseWheel")) flickerstreak@28: editBox:SetScript("OnEnterPressed", function(t, a1) flickerstreak@28: local value = editBox:GetNumber() flickerstreak@28: flickerstreak@28: if sliderFrame.parent.sliderIsPercent then flickerstreak@28: value = value / 100 flickerstreak@28: end flickerstreak@28: flickerstreak@28: local min = sliderFrame.parent.sliderMin or 0 flickerstreak@28: local max = sliderFrame.parent.sliderMax or 1 flickerstreak@28: flickerstreak@28: if value > max then flickerstreak@28: value = max flickerstreak@28: elseif value < min then flickerstreak@28: value = min flickerstreak@28: end flickerstreak@28: sliderFrame.fineStep = true flickerstreak@28: if max <= min then flickerstreak@28: slider:SetValue(0) flickerstreak@28: else flickerstreak@28: slider:SetValue(1 - (value - min) / (max - min)) flickerstreak@28: end flickerstreak@28: sliderFrame.fineStep = nil flickerstreak@28: flickerstreak@28: StartCounting(self, sliderFrame.level) flickerstreak@28: end) flickerstreak@28: editBox:SetScript("OnEscapePressed", function() flickerstreak@28: self:Close(sliderFrame.level) flickerstreak@28: StartCounting(self, sliderFrame.level) flickerstreak@28: end) flickerstreak@28: editBox:SetAutoFocus(false) flickerstreak@28: end flickerstreak@28: sliderFrame.parent = parent flickerstreak@28: sliderFrame.level = parent.level.num + 1 flickerstreak@28: sliderFrame.parentValue = parent.level.value flickerstreak@28: sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3) flickerstreak@28: sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1) flickerstreak@28: sliderFrame.currentText:SetFrameLevel(sliderFrame:GetFrameLevel() + 1) flickerstreak@28: sliderFrame.currentText:ClearFocus() flickerstreak@28: sliderFrame.changing = true flickerstreak@28: if not parent.sliderMin or not parent.sliderMax then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: flickerstreak@28: if parent.arrow then flickerstreak@28: -- parent.arrow:SetVertexColor(0.2, 0.6, 0) flickerstreak@28: -- parent.arrow:SetHeight(24) flickerstreak@28: -- parent.arrow:SetWidth(24) flickerstreak@28: parent.selected = true flickerstreak@28: parent.highlight:Show() flickerstreak@28: end flickerstreak@28: flickerstreak@28: sliderFrame:SetClampedToScreen(false) flickerstreak@28: if not parent.sliderValue then flickerstreak@28: parent.sliderValue = (parent.sliderMin + parent.sliderMax) / 2 flickerstreak@28: end flickerstreak@28: if parent.sliderMax <= parent.sliderMin then flickerstreak@28: sliderFrame.slider:SetValue(0) flickerstreak@28: else flickerstreak@28: sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin)) flickerstreak@28: end flickerstreak@28: sliderFrame.changing = false flickerstreak@28: sliderFrame.bottomText:SetText(parent.sliderMinText or "0") flickerstreak@28: sliderFrame.topText:SetText(parent.sliderMaxText or "1") flickerstreak@28: local text flickerstreak@28: if parent.sliderFunc and not parent.fromAceOptions then flickerstreak@28: text = parent.sliderFunc(getArgs(parent, 'sliderArg', 1, parent.sliderValue)) flickerstreak@28: end flickerstreak@28: if type(text) == "number" or type(text) == "string" then flickerstreak@28: sliderFrame.currentText:SetText(text) flickerstreak@28: elseif parent.sliderIsPercent then flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.0f%%", parent.sliderValue * 100)) flickerstreak@28: else flickerstreak@28: if parent.sliderStep < 0.1 then flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.2f", parent.sliderValue)) flickerstreak@28: elseif parent.sliderStep < 1 then flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.1f", parent.sliderValue)) flickerstreak@28: else flickerstreak@28: sliderFrame.currentText:SetText(string.format("%.0f", parent.sliderValue)) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: flickerstreak@28: sliderFrame.lastValue = parent.sliderValue flickerstreak@28: flickerstreak@28: local level = parent.level flickerstreak@28: sliderFrame:Show() flickerstreak@28: sliderFrame:ClearAllPoints() flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@28: else flickerstreak@28: sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@28: else flickerstreak@28: sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local dirty flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if sliderFrame:GetRight() > GetScreenWidth() then flickerstreak@28: level.lastDirection = "LEFT" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: elseif sliderFrame:GetLeft() < 0 then flickerstreak@28: level.lastDirection = "RIGHT" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: if sliderFrame:GetBottom() < 0 then flickerstreak@28: level.lastVDirection = "UP" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: elseif sliderFrame:GetTop() > GetScreenWidth() then flickerstreak@28: level.lastVDirection = "DOWN" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: if dirty then flickerstreak@28: sliderFrame:ClearAllPoints() flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@28: else flickerstreak@28: sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@28: else flickerstreak@28: sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local left, bottom = sliderFrame:GetLeft(), sliderFrame:GetBottom() flickerstreak@28: sliderFrame:ClearAllPoints() flickerstreak@28: sliderFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@28: if mod(level.num, 5) == 0 then flickerstreak@28: local left, bottom = level:GetLeft(), level:GetBottom() flickerstreak@28: level:ClearAllPoints() flickerstreak@28: level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@28: end flickerstreak@28: sliderFrame:SetClampedToScreen(true) flickerstreak@28: end flickerstreak@28: flickerstreak@28: function OpenEditBox(self, parent) flickerstreak@28: if not editBoxFrame then flickerstreak@28: editBoxFrame = CreateFrame("Frame", nil, nil) flickerstreak@28: editBoxFrame:SetWidth(200) flickerstreak@28: editBoxFrame:SetHeight(40) flickerstreak@28: editBoxFrame:SetScale(UIParent:GetScale()) flickerstreak@28: editBoxFrame:SetBackdrop(tmp( flickerstreak@28: 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background", flickerstreak@28: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@28: 'tile', true, flickerstreak@28: 'insets', tmp2( flickerstreak@28: 'left', 5, flickerstreak@28: 'right', 5, flickerstreak@28: 'top', 5, flickerstreak@28: 'bottom', 5 flickerstreak@28: ), flickerstreak@28: 'tileSize', 16, flickerstreak@28: 'edgeSize', 16 flickerstreak@28: )) flickerstreak@28: editBoxFrame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@28: if editBoxFrame.SetTopLevel then flickerstreak@28: editBoxFrame:SetTopLevel(true) flickerstreak@28: end flickerstreak@28: editBoxFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) flickerstreak@28: editBoxFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) flickerstreak@28: editBoxFrame:EnableMouse(true) flickerstreak@28: editBoxFrame:EnableMouseWheel(true) flickerstreak@28: editBoxFrame:Hide() flickerstreak@28: editBoxFrame:SetPoint("CENTER", UIParent, "CENTER") flickerstreak@28: flickerstreak@28: local editBox = CreateFrame("EditBox", nil, editBoxFrame) flickerstreak@28: editBoxFrame.editBox = editBox flickerstreak@28: editBox:SetFontObject(ChatFontNormal) flickerstreak@28: editBox:SetWidth(160) flickerstreak@28: editBox:SetHeight(13) flickerstreak@28: editBox:SetPoint("CENTER", editBoxFrame, "CENTER", 0, 0) flickerstreak@28: flickerstreak@28: local left = editBox:CreateTexture(nil, "BACKGROUND") flickerstreak@28: left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left") flickerstreak@28: left:SetTexCoord(0, 100 / 256, 0, 1) flickerstreak@28: left:SetWidth(100) flickerstreak@28: left:SetHeight(32) flickerstreak@28: left:SetPoint("LEFT", editBox, "LEFT", -10, 0) flickerstreak@28: local right = editBox:CreateTexture(nil, "BACKGROUND") flickerstreak@28: right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right") flickerstreak@28: right:SetTexCoord(156/256, 1, 0, 1) flickerstreak@28: right:SetWidth(100) flickerstreak@28: right:SetHeight(32) flickerstreak@28: right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0) flickerstreak@28: flickerstreak@28: editBox:SetScript("OnEnterPressed", function() flickerstreak@28: if editBoxFrame.parent and editBoxFrame.parent.editBoxValidateFunc then flickerstreak@28: local t = editBox.realText or editBox:GetText() or "" flickerstreak@28: local result = editBoxFrame.parent.editBoxValidateFunc(getArgs(editBoxFrame.parent, 'editBoxValidateArg', 1, t)) flickerstreak@28: if not result then flickerstreak@28: UIErrorsFrame:AddMessage(VALIDATION_ERROR, 1, 0, 0) flickerstreak@28: return flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if editBoxFrame.parent and editBoxFrame.parent.editBoxFunc then flickerstreak@28: local t flickerstreak@28: if editBox.realText ~= "NONE" then flickerstreak@28: t = editBox.realText or editBox:GetText() or "" flickerstreak@28: end flickerstreak@28: editBoxFrame.parent.editBoxFunc(getArgs(editBoxFrame.parent, 'editBoxArg', 1, t)) flickerstreak@28: end flickerstreak@28: self:Close(editBoxFrame.level) flickerstreak@28: for i = 1, editBoxFrame.level - 1 do flickerstreak@28: Refresh(self, levels[i]) flickerstreak@28: end flickerstreak@28: StartCounting(self, editBoxFrame.level-1) flickerstreak@28: end) flickerstreak@28: editBox:SetScript("OnEscapePressed", function() flickerstreak@28: self:Close(editBoxFrame.level) flickerstreak@28: StartCounting(self, editBoxFrame.level-1) flickerstreak@28: end) flickerstreak@28: editBox:SetScript("OnReceiveDrag", function(this) flickerstreak@28: if GetCursorInfo then flickerstreak@28: local type, alpha, bravo = GetCursorInfo() flickerstreak@28: local text flickerstreak@28: if type == "spell" then flickerstreak@28: text = GetSpellName(alpha, bravo) flickerstreak@28: elseif type == "item" then flickerstreak@28: text = bravo flickerstreak@28: end flickerstreak@28: if not text then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: ClearCursor() flickerstreak@28: editBox:SetText(text) flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: local changing = false flickerstreak@28: local skipNext = false flickerstreak@28: flickerstreak@28: function editBox:SpecialSetText(text) flickerstreak@28: local oldText = editBox:GetText() or "" flickerstreak@28: if not text then flickerstreak@28: text = "" flickerstreak@28: end flickerstreak@28: if text ~= oldText then flickerstreak@28: changing = true flickerstreak@28: self:SetText(tostring(text)) flickerstreak@28: changing = false flickerstreak@28: skipNext = true flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: editBox:SetScript("OnTextChanged", function() flickerstreak@28: if skipNext then flickerstreak@28: skipNext = false flickerstreak@28: elseif not changing and editBoxFrame.parent and editBoxFrame.parent.editBoxChangeFunc then flickerstreak@28: local t flickerstreak@28: if editBox.realText ~= "NONE" then flickerstreak@28: t = editBox.realText or editBox:GetText() or "" flickerstreak@28: end flickerstreak@28: local text = editBoxFrame.parent.editBoxChangeFunc(getArgs(editBoxFrame.parent, 'editBoxChangeArg', 1, t)) flickerstreak@28: if text then flickerstreak@28: editBox:SpecialSetText(text) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: editBoxFrame:SetScript("OnEnter", function() flickerstreak@28: StopCounting(self, editBoxFrame.level) flickerstreak@28: showGameTooltip(editBoxFrame.parent) flickerstreak@28: end) flickerstreak@28: editBoxFrame:SetScript("OnLeave", function() flickerstreak@28: GameTooltip:Hide() flickerstreak@28: end) flickerstreak@28: editBox:SetScript("OnEnter", function() flickerstreak@28: StopCounting(self, editBoxFrame.level) flickerstreak@28: showGameTooltip(editBoxFrame.parent) flickerstreak@28: end) flickerstreak@28: editBox:SetScript("OnLeave", function() flickerstreak@28: GameTooltip:Hide() flickerstreak@28: end) flickerstreak@28: editBoxFrame:SetScript("OnKeyDown", function(this, a1) flickerstreak@28: if not editBox.keybinding then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: local arg1 = a1 or arg1 flickerstreak@28: local screenshotKey = GetBindingKey("SCREENSHOT") flickerstreak@28: if screenshotKey and arg1 == screenshotKey then flickerstreak@28: Screenshot() flickerstreak@28: return flickerstreak@28: end flickerstreak@28: flickerstreak@28: if arg1 == "LeftButton" then flickerstreak@28: arg1 = "BUTTON1" flickerstreak@28: elseif arg1 == "RightButton" then flickerstreak@28: arg1 = "BUTTON2" flickerstreak@28: elseif arg1 == "MiddleButton" then flickerstreak@28: arg1 = "BUTTON3" flickerstreak@28: elseif arg1 == "Button4" then flickerstreak@28: arg1 = "BUTTON4" flickerstreak@28: elseif arg1 == "Button5" then flickerstreak@28: arg1 = "BUTTON5" flickerstreak@28: end flickerstreak@28: if arg1 == "UNKNOWN" then flickerstreak@28: return flickerstreak@28: elseif arg1 == "SHIFT" or arg1 == "CTRL" or arg1 == "ALT" then flickerstreak@28: return flickerstreak@28: elseif arg1 == "ENTER" then flickerstreak@28: if editBox.keybindingOnly and not editBox.keybindingOnly[editBox.realText] then flickerstreak@28: return editBox:GetScript("OnEscapePressed")() flickerstreak@28: elseif editBox.keybindingExcept and editBox.keybindingExcept[editBox.realText] then flickerstreak@28: return editBox:GetScript("OnEscapePressed")() flickerstreak@28: else flickerstreak@28: return editBox:GetScript("OnEnterPressed")() flickerstreak@28: end flickerstreak@28: elseif arg1 == "ESCAPE" then flickerstreak@28: if editBox.realText == "NONE" then flickerstreak@28: return editBox:GetScript("OnEscapePressed")() flickerstreak@28: else flickerstreak@28: editBox:SpecialSetText(NONE or "NONE") flickerstreak@28: editBox.realText = "NONE" flickerstreak@28: return flickerstreak@28: end flickerstreak@28: elseif editBox.keybindingOnly and not editBox.keybindingOnly[arg1] then flickerstreak@28: return flickerstreak@28: elseif editBox.keybindingExcept and editBox.keybindingExcept[arg1] then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: local s = GetBindingText(arg1, "KEY_") flickerstreak@28: if s == "BUTTON1" then flickerstreak@28: s = KEY_BUTTON1 flickerstreak@28: elseif s == "BUTTON2" then flickerstreak@28: s = KEY_BUTTON2 flickerstreak@28: end flickerstreak@28: local real = arg1 flickerstreak@28: if IsShiftKeyDown() then flickerstreak@28: s = "Shift-" .. s flickerstreak@28: real = "SHIFT-" .. real flickerstreak@28: end flickerstreak@28: if IsControlKeyDown() then flickerstreak@28: s = "Ctrl-" .. s flickerstreak@28: real = "CTRL-" .. real flickerstreak@28: end flickerstreak@28: if IsAltKeyDown() then flickerstreak@28: s = "Alt-" .. s flickerstreak@28: real = "ALT-" .. real flickerstreak@28: end flickerstreak@28: if editBox:GetText() ~= s then flickerstreak@28: editBox:SpecialSetText("-") flickerstreak@28: editBox:SpecialSetText(s) flickerstreak@28: editBox.realText = real flickerstreak@28: return editBox:GetScript("OnTextChanged")() flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: editBoxFrame:SetScript("OnMouseDown", editBoxFrame:GetScript("OnKeyDown")) flickerstreak@28: editBox:SetScript("OnMouseDown", function(this, ...) flickerstreak@28: if GetCursorInfo and (CursorHasItem() or CursorHasSpell()) then flickerstreak@28: return editBox:GetScript("OnReceiveDrag")(this, ...) flickerstreak@28: end flickerstreak@28: return editBoxFrame:GetScript("OnKeyDown")(this, ...) flickerstreak@28: end) flickerstreak@28: editBoxFrame:SetScript("OnMouseWheel", function(t, a1) flickerstreak@28: local arg1 = a1 or arg1 flickerstreak@28: local up = arg1 > 0 flickerstreak@28: arg1 = up and "MOUSEWHEELUP" or "MOUSEWHEELDOWN" flickerstreak@28: return editBoxFrame:GetScript("OnKeyDown")(t or this, arg1) flickerstreak@28: end) flickerstreak@28: editBox:SetScript("OnMouseWheel", editBoxFrame:GetScript("OnMouseWheel")) flickerstreak@28: end flickerstreak@28: editBoxFrame.parent = parent flickerstreak@28: editBoxFrame.level = parent.level.num + 1 flickerstreak@28: editBoxFrame.parentValue = parent.level.value flickerstreak@28: editBoxFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3) flickerstreak@28: editBoxFrame.editBox:SetFrameLevel(editBoxFrame:GetFrameLevel() + 1) flickerstreak@28: editBoxFrame.editBox.realText = nil flickerstreak@28: editBoxFrame:SetClampedToScreen(false) flickerstreak@28: flickerstreak@28: editBoxFrame.editBox:SpecialSetText("") flickerstreak@28: if parent.editBoxIsKeybinding then flickerstreak@28: local s = parent.editBoxText flickerstreak@28: if s == "" then flickerstreak@28: s = "NONE" flickerstreak@28: end flickerstreak@28: editBoxFrame.editBox.realText = s flickerstreak@28: if s and s ~= "NONE" then flickerstreak@28: local alpha,bravo = s:match("^(.+)%-(.+)$") flickerstreak@28: if not bravo then flickerstreak@28: alpha = nil flickerstreak@28: bravo = s flickerstreak@28: end flickerstreak@28: bravo = GetBindingText(bravo, "KEY_") flickerstreak@28: if alpha then flickerstreak@28: editBoxFrame.editBox:SpecialSetText(alpha:upper() .. "-" .. bravo) flickerstreak@28: else flickerstreak@28: editBoxFrame.editBox:SpecialSetText(bravo) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: editBoxFrame.editBox:SpecialSetText(NONE or "NONE") flickerstreak@28: end flickerstreak@28: else flickerstreak@28: editBoxFrame.editBox:SpecialSetText(parent.editBoxText) flickerstreak@28: end flickerstreak@28: flickerstreak@28: editBoxFrame.editBox.keybinding = parent.editBoxIsKeybinding flickerstreak@28: editBoxFrame.editBox.keybindingOnly = parent.editBoxKeybindingOnly flickerstreak@28: editBoxFrame.editBox.keybindingExcept = parent.editBoxKeybindingExcept flickerstreak@28: editBoxFrame.editBox:EnableKeyboard(not parent.editBoxIsKeybinding) flickerstreak@28: editBoxFrame:EnableKeyboard(parent.editBoxIsKeybinding) flickerstreak@28: flickerstreak@28: if parent.arrow then flickerstreak@28: -- parent.arrow:SetVertexColor(0.2, 0.6, 0) flickerstreak@28: -- parent.arrow:SetHeight(24) flickerstreak@28: -- parent.arrow:SetWidth(24) flickerstreak@28: parent.selected = true flickerstreak@28: parent.highlight:Show() flickerstreak@28: end flickerstreak@28: flickerstreak@28: local level = parent.level flickerstreak@28: editBoxFrame:Show() flickerstreak@28: editBoxFrame:ClearAllPoints() flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@28: else flickerstreak@28: editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@28: else flickerstreak@28: editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local dirty flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if editBoxFrame:GetRight() > GetScreenWidth() then flickerstreak@28: level.lastDirection = "LEFT" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: elseif editBoxFrame:GetLeft() < 0 then flickerstreak@28: level.lastDirection = "RIGHT" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: if editBoxFrame:GetBottom() < 0 then flickerstreak@28: level.lastVDirection = "UP" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: elseif editBoxFrame:GetTop() > GetScreenWidth() then flickerstreak@28: level.lastVDirection = "DOWN" flickerstreak@28: dirty = true flickerstreak@28: end flickerstreak@28: if dirty then flickerstreak@28: editBoxFrame:ClearAllPoints() flickerstreak@28: if level.lastDirection == "RIGHT" then flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10) flickerstreak@28: else flickerstreak@28: editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: if level.lastVDirection == "DOWN" then flickerstreak@28: editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10) flickerstreak@28: else flickerstreak@28: editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local left, bottom = editBoxFrame:GetLeft(), editBoxFrame:GetBottom() flickerstreak@28: editBoxFrame:ClearAllPoints() flickerstreak@28: editBoxFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@28: if mod(level.num, 5) == 0 then flickerstreak@28: local left, bottom = level:GetLeft(), level:GetBottom() flickerstreak@28: level:ClearAllPoints() flickerstreak@28: level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom) flickerstreak@28: end flickerstreak@28: editBoxFrame:SetClampedToScreen(true) flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:EncodeKeybinding(text) flickerstreak@28: if text == nil or text == "NONE" then flickerstreak@28: return nil flickerstreak@28: end flickerstreak@28: text = tostring(text):upper() flickerstreak@28: local shift, ctrl, alt flickerstreak@28: local modifier flickerstreak@28: while true do flickerstreak@28: if text == "-" then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: modifier, text = strsplit('-', text, 2) flickerstreak@28: if text then flickerstreak@28: if modifier ~= "SHIFT" and modifier ~= "CTRL" and modifier ~= "ALT" then flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: if modifier == "SHIFT" then flickerstreak@28: if shift then flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: shift = true flickerstreak@28: end flickerstreak@28: if modifier == "CTRL" then flickerstreak@28: if ctrl then flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: ctrl = true flickerstreak@28: end flickerstreak@28: if modifier == "ALT" then flickerstreak@28: if alt then flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: alt = true flickerstreak@28: end flickerstreak@28: else flickerstreak@28: text = modifier flickerstreak@28: break flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if not text:find("^F%d+$") and text ~= "CAPSLOCK" and text:len() ~= 1 and (text:len() == 0 or text:byte() < 128 or text:len() > 4) and not _G["KEY_" .. text] and text ~= "BUTTON1" and text ~= "BUTTON2" then flickerstreak@28: return false flickerstreak@28: end flickerstreak@28: local s = GetBindingText(text, "KEY_") flickerstreak@28: if s == "BUTTON1" then flickerstreak@28: s = KEY_BUTTON1 flickerstreak@28: elseif s == "BUTTON2" then flickerstreak@28: s = KEY_BUTTON2 flickerstreak@28: end flickerstreak@28: if shift then flickerstreak@28: s = "Shift-" .. s flickerstreak@28: end flickerstreak@28: if ctrl then flickerstreak@28: s = "Ctrl-" .. s flickerstreak@28: end flickerstreak@28: if alt then flickerstreak@28: s = "Alt-" .. s flickerstreak@28: end flickerstreak@28: return s flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:IsOpen(parent) flickerstreak@28: self:argCheck(parent, 2, "table", "string", "nil") flickerstreak@28: return levels[1] and levels[1]:IsShown() and (not parent or parent == levels[1].parent or parent == levels[1]:GetParent()) flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:GetOpenedParent() flickerstreak@28: return (levels[1] and levels[1]:IsShown()) and (levels[1].parent or levels[1]:GetParent()) flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Open(self, parent, func, level, value, point, relativePoint, cursorX, cursorY) flickerstreak@28: self:Close(level) flickerstreak@28: if DewdropLib then flickerstreak@28: local d = DewdropLib:GetInstance('1.0') flickerstreak@28: local ret, val = pcall(d, IsOpen, d) flickerstreak@28: if ret and val then flickerstreak@28: DewdropLib:GetInstance('1.0'):Close() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if type(parent) == "table" then flickerstreak@28: parent:GetCenter() flickerstreak@28: end flickerstreak@28: local frame = AcquireLevel(self, level) flickerstreak@28: if level == 1 then flickerstreak@28: frame.lastDirection = "RIGHT" flickerstreak@28: frame.lastVDirection = "DOWN" flickerstreak@28: else flickerstreak@28: frame.lastDirection = levels[level - 1].lastDirection flickerstreak@28: frame.lastVDirection = levels[level - 1].lastVDirection flickerstreak@28: end flickerstreak@28: frame:SetFrameStrata("FULLSCREEN_DIALOG") flickerstreak@28: frame:ClearAllPoints() flickerstreak@28: frame.parent = parent flickerstreak@28: frame:SetPoint("LEFT", UIParent, "RIGHT", 10000, 0) flickerstreak@28: frame:Show() flickerstreak@28: if level == 1 then flickerstreak@28: baseFunc = func flickerstreak@28: end flickerstreak@28: levels[level].value = value flickerstreak@28: -- levels[level].parentText = parent.text and parent.text:GetText() or nil flickerstreak@28: -- levels[level].parentTooltipTitle = parent.tooltipTitle flickerstreak@28: -- levels[level].parentTooltipText = parent.tooltipText flickerstreak@28: -- levels[level].parentTooltipFunc = parent.tooltipFunc flickerstreak@28: if type(parent) == "table" and parent.arrow then flickerstreak@28: -- parent.arrow:SetVertexColor(0.2, 0.6, 0) flickerstreak@28: -- parent.arrow:SetHeight(24) flickerstreak@28: -- parent.arrow:SetWidth(24) flickerstreak@28: parent.selected = true flickerstreak@28: parent.highlight:Show() flickerstreak@28: end flickerstreak@28: relativePoint = relativePoint or point flickerstreak@28: Refresh(self, levels[level]) flickerstreak@28: if point or (cursorX and cursorY) then flickerstreak@28: frame:ClearAllPoints() flickerstreak@28: if cursorX and cursorY then flickerstreak@28: local curX, curY = GetScaledCursorPosition() flickerstreak@28: if curY < GetScreenHeight() / 2 then flickerstreak@28: point, relativePoint = "BOTTOM", "BOTTOM" flickerstreak@28: else flickerstreak@28: point, relativePoint = "TOP", "TOP" flickerstreak@28: end flickerstreak@28: if curX < GetScreenWidth() / 2 then flickerstreak@28: point, relativePoint = point .. "LEFT", relativePoint .. "RIGHT" flickerstreak@28: else flickerstreak@28: point, relativePoint = point .. "RIGHT", relativePoint .. "LEFT" flickerstreak@28: end flickerstreak@28: end flickerstreak@28: frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint) flickerstreak@28: if cursorX and cursorY then flickerstreak@28: local left = frame:GetLeft() flickerstreak@28: local width = frame:GetWidth() flickerstreak@28: local bottom = frame:GetBottom() flickerstreak@28: local height = frame:GetHeight() flickerstreak@28: local curX, curY = GetScaledCursorPosition() flickerstreak@28: frame:ClearAllPoints() flickerstreak@28: relativePoint = relativePoint or point flickerstreak@28: if point == "BOTTOM" or point == "TOP" then flickerstreak@28: if curX < GetScreenWidth() / 2 then flickerstreak@28: point = point .. "LEFT" flickerstreak@28: else flickerstreak@28: point = point .. "RIGHT" flickerstreak@28: end flickerstreak@28: elseif point == "CENTER" then flickerstreak@28: if curX < GetScreenWidth() / 2 then flickerstreak@28: point = "LEFT" flickerstreak@28: else flickerstreak@28: point = "RIGHT" flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local xOffset, yOffset = 0, 0 flickerstreak@28: if curY > GetScreenHeight() / 2 then flickerstreak@28: yOffset = -height flickerstreak@28: end flickerstreak@28: if curX > GetScreenWidth() / 2 then flickerstreak@28: xOffset = -width flickerstreak@28: end flickerstreak@28: frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left + xOffset, curY - bottom + yOffset) flickerstreak@28: if level == 1 then flickerstreak@28: frame.lastDirection = "RIGHT" flickerstreak@28: end flickerstreak@28: elseif cursorX then flickerstreak@28: local left = frame:GetLeft() flickerstreak@28: local width = frame:GetWidth() flickerstreak@28: local curX, curY = GetScaledCursorPosition() flickerstreak@28: frame:ClearAllPoints() flickerstreak@28: relativePoint = relativePoint or point flickerstreak@28: if point == "BOTTOM" or point == "TOP" then flickerstreak@28: if curX < GetScreenWidth() / 2 then flickerstreak@28: point = point .. "LEFT" flickerstreak@28: else flickerstreak@28: point = point .. "RIGHT" flickerstreak@28: end flickerstreak@28: elseif point == "CENTER" then flickerstreak@28: if curX < GetScreenWidth() / 2 then flickerstreak@28: point = "LEFT" flickerstreak@28: else flickerstreak@28: point = "RIGHT" flickerstreak@28: end flickerstreak@28: end flickerstreak@28: frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left - width / 2, 0) flickerstreak@28: if level == 1 then flickerstreak@28: frame.lastDirection = "RIGHT" flickerstreak@28: end flickerstreak@28: elseif cursorY then flickerstreak@28: local bottom = frame:GetBottom() flickerstreak@28: local height = frame:GetHeight() flickerstreak@28: local curX, curY = GetScaledCursorPosition() flickerstreak@28: frame:ClearAllPoints() flickerstreak@28: relativePoint = relativePoint or point flickerstreak@28: if point == "LEFT" or point == "RIGHT" then flickerstreak@28: if curX < GetScreenHeight() / 2 then flickerstreak@28: point = point .. "BOTTOM" flickerstreak@28: else flickerstreak@28: point = point .. "TOP" flickerstreak@28: end flickerstreak@28: elseif point == "CENTER" then flickerstreak@28: if curX < GetScreenHeight() / 2 then flickerstreak@28: point = "BOTTOM" flickerstreak@28: else flickerstreak@28: point = "TOP" flickerstreak@28: end flickerstreak@28: end flickerstreak@28: frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, 0, curY - bottom - height / 2) flickerstreak@28: if level == 1 then flickerstreak@28: frame.lastDirection = "DOWN" flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if (strsub(point, 1, 3) ~= strsub(relativePoint, 1, 3)) then flickerstreak@28: if frame:GetBottom() < 0 then flickerstreak@28: local point, parent, relativePoint, x, y = frame:GetPoint(1) flickerstreak@28: local change = GetScreenHeight() - frame:GetTop() flickerstreak@28: local otherChange = -frame:GetBottom() flickerstreak@28: if otherChange < change then flickerstreak@28: change = otherChange flickerstreak@28: end flickerstreak@28: frame:SetPoint(point, parent, relativePoint, x, y + change) flickerstreak@28: elseif frame:GetTop() > GetScreenHeight() then flickerstreak@28: local point, parent, relativePoint, x, y = frame:GetPoint(1) flickerstreak@28: local change = GetScreenHeight() - frame:GetTop() flickerstreak@28: local otherChange = -frame:GetBottom() flickerstreak@28: if otherChange < change then flickerstreak@28: change = otherChange flickerstreak@28: end flickerstreak@28: frame:SetPoint(point, parent, relativePoint, x, y + change) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: CheckDualMonitor(self, frame) flickerstreak@28: frame:SetClampedToScreen(true) flickerstreak@28: frame:SetClampedToScreen(false) flickerstreak@28: StartCounting(self, level) flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:IsRegistered(parent) flickerstreak@28: self:argCheck(parent, 2, "table", "string") flickerstreak@28: return not not self.registry[parent] flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:Register(parent, ...) flickerstreak@28: self:argCheck(parent, 2, "table", "string") flickerstreak@28: if self.registry[parent] then flickerstreak@28: self:Unregister(parent) flickerstreak@28: end flickerstreak@28: local info = new(...) flickerstreak@28: if type(info.children) == "table" then flickerstreak@28: local err, position = validateOptions(info.children) flickerstreak@28: flickerstreak@28: if err then flickerstreak@28: if position then flickerstreak@28: Dewdrop:error(position .. ": " .. err) flickerstreak@28: else flickerstreak@28: Dewdrop:error(err) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: self.registry[parent] = info flickerstreak@28: if not info.dontHook and not self.onceRegistered[parent] and type(parent) == "table" then flickerstreak@28: if parent:HasScript("OnMouseUp") then flickerstreak@28: local script = parent:GetScript("OnMouseUp") flickerstreak@28: parent:SetScript("OnMouseUp", function(this, ...) flickerstreak@28: if script then flickerstreak@28: script(this, ...) flickerstreak@28: end flickerstreak@28: if arg1 == "RightButton" and self.registry[parent] then flickerstreak@28: if self:IsOpen(parent) then flickerstreak@28: self:Close() flickerstreak@28: else flickerstreak@28: self:Open(parent) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: end flickerstreak@28: if parent:HasScript("OnMouseDown") then flickerstreak@28: local script = parent:GetScript("OnMouseDown") flickerstreak@28: parent:SetScript("OnMouseDown", function(this, ...) flickerstreak@28: if script then flickerstreak@28: script(this, ...) flickerstreak@28: end flickerstreak@28: if self.registry[parent] then flickerstreak@28: self:Close() flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: self.onceRegistered[parent] = true flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:Unregister(parent) flickerstreak@28: self:argCheck(parent, 2, "table", "string") flickerstreak@28: self.registry[parent] = nil flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:Open(parent, ...) flickerstreak@28: self:argCheck(parent, 2, "table", "string") flickerstreak@28: local info flickerstreak@28: local k1 = ... flickerstreak@28: if type(k1) == "table" and k1[0] and k1.IsFrameType and self.registry[k1] then flickerstreak@28: info = tmp(select(2, ...)) flickerstreak@28: for k,v in pairs(self.registry[k1]) do flickerstreak@28: if info[k] == nil then flickerstreak@28: info[k] = v flickerstreak@28: end flickerstreak@28: end flickerstreak@28: else flickerstreak@28: info = tmp(...) flickerstreak@28: if self.registry[parent] then flickerstreak@28: for k,v in pairs(self.registry[parent]) do flickerstreak@28: if info[k] == nil then flickerstreak@28: info[k] = v flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local point = info.point flickerstreak@28: local relativePoint = info.relativePoint flickerstreak@28: local cursorX = info.cursorX flickerstreak@28: local cursorY = info.cursorY flickerstreak@28: if type(point) == "function" then flickerstreak@28: local b flickerstreak@28: point, b = point(parent) flickerstreak@28: if b then flickerstreak@28: relativePoint = b flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if type(relativePoint) == "function" then flickerstreak@28: relativePoint = relativePoint(parent) flickerstreak@28: end flickerstreak@28: Open(self, parent, info.children, 1, nil, point, relativePoint, cursorX, cursorY) flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Clear(self, level) flickerstreak@28: if level then flickerstreak@28: if level.buttons then flickerstreak@28: for i = #level.buttons, 1, -1 do flickerstreak@28: ReleaseButton(self, level, i) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:Close(level) flickerstreak@28: if DropDownList1:IsShown() then flickerstreak@28: DropDownList1:Hide() flickerstreak@28: end flickerstreak@28: if DewdropLib then flickerstreak@28: local d = DewdropLib:GetInstance('1.0') flickerstreak@28: local ret, val = pcall(d, IsOpen, d) flickerstreak@28: if ret and val then flickerstreak@28: DewdropLib:GetInstance('1.0'):Close() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: self:argCheck(level, 2, "number", "nil") flickerstreak@28: if not level then flickerstreak@28: level = 1 flickerstreak@28: end flickerstreak@28: if level == 1 and levels[level] then flickerstreak@28: levels[level].parented = false flickerstreak@28: end flickerstreak@28: if level > 1 and levels[level-1].buttons then flickerstreak@28: local buttons = levels[level-1].buttons flickerstreak@28: for _,button in ipairs(buttons) do flickerstreak@28: -- button.arrow:SetWidth(16) flickerstreak@28: -- button.arrow:SetHeight(16) flickerstreak@28: button.selected = nil flickerstreak@28: button.highlight:Hide() flickerstreak@28: -- button.arrow:SetVertexColor(1, 1, 1) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if sliderFrame and sliderFrame.level >= level then flickerstreak@28: sliderFrame:Hide() flickerstreak@28: end flickerstreak@28: if editBoxFrame and editBoxFrame.level >= level then flickerstreak@28: editBoxFrame:Hide() flickerstreak@28: end flickerstreak@28: for i = level, #levels do flickerstreak@28: Clear(self, levels[level]) flickerstreak@28: levels[i]:Hide() flickerstreak@28: levels[i]:ClearAllPoints() flickerstreak@28: levels[i]:SetPoint("CENTER", UIParent, "CENTER") flickerstreak@28: levels[i].value = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:AddSeparator(level) flickerstreak@28: level = levels[level or currentLevel] flickerstreak@28: if not level or not level.buttons then return; end flickerstreak@28: flickerstreak@28: local prevbutton = level.buttons[#level.buttons] flickerstreak@28: if not prevbutton then return; end flickerstreak@28: flickerstreak@28: if prevbutton.disabled and prevbutton.text:GetText() == "" then flickerstreak@28: return flickerstreak@28: end flickerstreak@28: self:AddLine("text", "", "disabled", true) flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:AddLine(...) flickerstreak@28: local info = tmp(...) flickerstreak@28: local level = info.level or currentLevel flickerstreak@28: info.level = nil flickerstreak@28: local button = AcquireButton(self, level) flickerstreak@28: if not next(info) then flickerstreak@28: info.disabled = true flickerstreak@28: end flickerstreak@28: button.disabled = info.isTitle or info.notClickable or info.disabled or (self.combat and info.secure) flickerstreak@28: button.isTitle = info.isTitle flickerstreak@28: button.notClickable = info.notClickable flickerstreak@28: if button.isTitle then flickerstreak@28: button.text:SetFontObject(GameFontNormalSmall) flickerstreak@28: elseif button.notClickable then flickerstreak@28: button.text:SetFontObject(GameFontHighlightSmall) flickerstreak@28: elseif button.disabled then flickerstreak@28: button.text:SetFontObject(GameFontDisableSmall) flickerstreak@28: else flickerstreak@28: button.text:SetFontObject(GameFontHighlightSmall) flickerstreak@28: end flickerstreak@28: if info.disabled then flickerstreak@28: button.arrow:SetDesaturated(true) flickerstreak@28: button.check:SetDesaturated(true) flickerstreak@28: else flickerstreak@28: button.arrow:SetDesaturated(false) flickerstreak@28: button.check:SetDesaturated(false) flickerstreak@28: end flickerstreak@28: if info.textR and info.textG and info.textB then flickerstreak@28: button.textR = info.textR flickerstreak@28: button.textG = info.textG flickerstreak@28: button.textB = info.textB flickerstreak@28: button.text:SetTextColor(button.textR, button.textG, button.textB) flickerstreak@28: else flickerstreak@28: button.text:SetTextColor(button.text:GetFontObject():GetTextColor()) flickerstreak@28: end flickerstreak@28: button.notCheckable = info.notCheckable flickerstreak@28: button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0) flickerstreak@28: button.checked = not info.notCheckable and info.checked flickerstreak@28: button.mouseoverUnderline = info.mouseoverUnderline flickerstreak@28: button.isRadio = not info.notCheckable and info.isRadio flickerstreak@28: if info.isRadio then flickerstreak@28: button.check:Show() flickerstreak@28: button.check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton") flickerstreak@28: if button.checked then flickerstreak@28: button.check:SetTexCoord(0.25, 0.5, 0, 1) flickerstreak@28: button.check:SetVertexColor(1, 1, 1, 1) flickerstreak@28: else flickerstreak@28: button.check:SetTexCoord(0, 0.25, 0, 1) flickerstreak@28: button.check:SetVertexColor(1, 1, 1, 0.5) flickerstreak@28: end flickerstreak@28: button.radioHighlight:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton") flickerstreak@28: button.check:SetWidth(16) flickerstreak@28: button.check:SetHeight(16) flickerstreak@28: elseif info.icon then flickerstreak@28: button.check:Show() flickerstreak@28: button.check:SetTexture(info.icon) flickerstreak@28: if info.iconWidth and info.iconHeight then flickerstreak@28: button.check:SetWidth(info.iconWidth) flickerstreak@28: button.check:SetHeight(info.iconHeight) flickerstreak@28: else flickerstreak@28: button.check:SetWidth(16) flickerstreak@28: button.check:SetHeight(16) flickerstreak@28: end flickerstreak@28: if info.iconCoordLeft and info.iconCoordRight and info.iconCoordTop and info.iconCoordBottom then flickerstreak@28: button.check:SetTexCoord(info.iconCoordLeft, info.iconCoordRight, info.iconCoordTop, info.iconCoordBottom) flickerstreak@28: elseif info.icon:find("^Interface\\Icons\\") then flickerstreak@28: button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95) flickerstreak@28: else flickerstreak@28: button.check:SetTexCoord(0, 1, 0, 1) flickerstreak@28: end flickerstreak@28: button.check:SetVertexColor(1, 1, 1, 1) flickerstreak@28: else flickerstreak@28: if button.checked then flickerstreak@28: if info.checkIcon then flickerstreak@28: button.check:SetWidth(16) flickerstreak@28: button.check:SetHeight(16) flickerstreak@28: button.check:SetTexture(info.checkIcon) flickerstreak@28: if info.checkIcon:find("^Interface\\Icons\\") then flickerstreak@28: button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95) flickerstreak@28: else flickerstreak@28: button.check:SetTexCoord(0, 1, 0, 1) flickerstreak@28: end flickerstreak@28: else flickerstreak@28: button.check:SetWidth(24) flickerstreak@28: button.check:SetHeight(24) flickerstreak@28: button.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") flickerstreak@28: button.check:SetTexCoord(0, 1, 0, 1) flickerstreak@28: end flickerstreak@28: button.check:SetVertexColor(1, 1, 1, 1) flickerstreak@28: else flickerstreak@28: button.check:SetVertexColor(1, 1, 1, 0) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: if not button.disabled then flickerstreak@28: button.func = info.func flickerstreak@28: button.secure = info.secure flickerstreak@28: end flickerstreak@28: button.hasColorSwatch = info.hasColorSwatch flickerstreak@28: if button.hasColorSwatch then flickerstreak@28: button.colorSwatch:Show() flickerstreak@28: button.colorSwatch.texture:Show() flickerstreak@28: button.r = info.r or 1 flickerstreak@28: button.g = info.g or 1 flickerstreak@28: button.b = info.b or 1 flickerstreak@28: button.colorSwatch.texture:SetVertexColor(button.r, button.g, button.b) flickerstreak@28: button.checked = false flickerstreak@28: button.func = nil flickerstreak@28: button.colorFunc = info.colorFunc flickerstreak@28: local i = 1 flickerstreak@28: while true do flickerstreak@28: local k = "colorArg" .. i flickerstreak@28: local x = info[k] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: button[k] = x flickerstreak@28: i = i + 1 flickerstreak@28: end flickerstreak@28: button.hasOpacity = info.hasOpacity flickerstreak@28: button.opacity = info.opacity or 1 flickerstreak@28: else flickerstreak@28: button.colorSwatch:Hide() flickerstreak@28: button.colorSwatch.texture:Hide() flickerstreak@28: end flickerstreak@28: button.hasArrow = not button.hasColorSwatch and (info.value or info.hasSlider or info.hasEditBox) and info.hasArrow flickerstreak@28: if button.hasArrow then flickerstreak@28: button.arrow:SetAlpha(1) flickerstreak@28: if info.hasSlider then flickerstreak@28: button.hasSlider = true flickerstreak@28: button.sliderMin = info.sliderMin or 0 flickerstreak@28: button.sliderMax = info.sliderMax or 1 flickerstreak@28: button.sliderStep = info.sliderStep or 0 flickerstreak@28: button.sliderBigStep = info.sliderBigStep or button.sliderStep flickerstreak@28: if button.sliderBigStep < button.sliderStep then flickerstreak@28: button.sliderBigStep = button.sliderStep flickerstreak@28: end flickerstreak@28: button.sliderIsPercent = info.sliderIsPercent and true or false flickerstreak@28: button.sliderMinText = info.sliderMinText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMin * 100) or button.sliderMin flickerstreak@28: button.sliderMaxText = info.sliderMaxText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMax * 100) or button.sliderMax flickerstreak@28: button.sliderFunc = info.sliderFunc flickerstreak@28: button.sliderValue = info.sliderValue flickerstreak@28: button.fromAceOptions = info.fromAceOptions flickerstreak@28: local i = 1 flickerstreak@28: while true do flickerstreak@28: local k = "sliderArg" .. i flickerstreak@28: local x = info[k] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: button[k] = x flickerstreak@28: i = i + 1 flickerstreak@28: end flickerstreak@28: elseif info.hasEditBox then flickerstreak@28: button.hasEditBox = true flickerstreak@28: button.editBoxText = info.editBoxText or "" flickerstreak@28: button.editBoxFunc = info.editBoxFunc flickerstreak@28: local i = 1 flickerstreak@28: while true do flickerstreak@28: local k = "editBoxArg" .. i flickerstreak@28: local x = info[k] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: button[k] = x flickerstreak@28: i = i + 1 flickerstreak@28: end flickerstreak@28: button.editBoxChangeFunc = info.editBoxChangeFunc flickerstreak@28: local i = 1 flickerstreak@28: while true do flickerstreak@28: local k = "editBoxChangeArg" .. i flickerstreak@28: local x = info[k] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: button[k] = x flickerstreak@28: i = i + 1 flickerstreak@28: end flickerstreak@28: button.editBoxValidateFunc = info.editBoxValidateFunc flickerstreak@28: local i = 1 flickerstreak@28: while true do flickerstreak@28: local k = "editBoxValidateArg" .. i flickerstreak@28: local x = info[k] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: button[k] = x flickerstreak@28: i = i + 1 flickerstreak@28: end flickerstreak@28: button.editBoxIsKeybinding = info.editBoxIsKeybinding flickerstreak@28: button.editBoxKeybindingOnly = info.editBoxKeybindingOnly flickerstreak@28: button.editBoxKeybindingExcept = info.editBoxKeybindingExcept flickerstreak@28: else flickerstreak@28: button.value = info.value flickerstreak@28: local l = levels[level+1] flickerstreak@28: if l and info.value == l.value then flickerstreak@28: -- button.arrow:SetWidth(24) flickerstreak@28: -- button.arrow:SetHeight(24) flickerstreak@28: button.selected = true flickerstreak@28: button.highlight:Show() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: else flickerstreak@28: button.arrow:SetAlpha(0) flickerstreak@28: end flickerstreak@28: local i = 1 flickerstreak@28: while true do flickerstreak@28: local k = "arg" .. i flickerstreak@28: local x = info[k] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: button[k] = x flickerstreak@28: i = i + 1 flickerstreak@28: end flickerstreak@28: button.closeWhenClicked = info.closeWhenClicked flickerstreak@28: button.textHeight = info.textHeight or UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT or 10 flickerstreak@28: local font,_ = button.text:GetFont() flickerstreak@28: button.text:SetFont(STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF", button.textHeight) flickerstreak@28: button:SetHeight(button.textHeight + 6) flickerstreak@28: button.text:SetPoint("RIGHT", button.arrow, (button.hasColorSwatch or button.hasArrow) and "LEFT" or "RIGHT") flickerstreak@28: button.text:SetJustifyH(info.justifyH or "LEFT") flickerstreak@28: button.text:SetText(info.text) flickerstreak@28: button.tooltipTitle = info.tooltipTitle flickerstreak@28: button.tooltipText = info.tooltipText flickerstreak@28: button.tooltipFunc = info.tooltipFunc flickerstreak@28: local i = 1 flickerstreak@28: while true do flickerstreak@28: local k = "tooltipArg" .. i flickerstreak@28: local x = info[k] flickerstreak@28: if x == nil then flickerstreak@28: break flickerstreak@28: end flickerstreak@28: button[k] = x flickerstreak@28: i = i + 1 flickerstreak@28: end flickerstreak@28: if not button.tooltipTitle and not button.tooltipText and not button.tooltipFunc and not info.isTitle then flickerstreak@28: button.tooltipTitle = info.text flickerstreak@28: end flickerstreak@28: if type(button.func) == "string" then flickerstreak@28: if type(button.arg1) ~= "table" then flickerstreak@28: self:error("Cannot call method %q on a non-table", button.func) flickerstreak@28: end flickerstreak@28: if type(button.arg1[button.func]) ~= "function" then flickerstreak@28: self:error("Method %q nonexistant.", button.func) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:InjectAceOptionsTable(handler, options) flickerstreak@28: self:argCheck(handler, 2, "table") flickerstreak@28: self:argCheck(options, 3, "table") flickerstreak@28: if tostring(options.type):lower() ~= "group" then flickerstreak@28: self:error('Cannot inject into options table argument #3 if its type is not "group"') flickerstreak@28: end flickerstreak@28: if options.handler ~= nil and options.handler ~= handler then flickerstreak@28: self:error("Cannot inject into options table argument #3 if it has a different handler than argument #2") flickerstreak@28: end flickerstreak@28: options.handler = handler flickerstreak@28: local class = handler.class flickerstreak@28: if not AceLibrary:HasInstance("AceOO-2.0") or not class then flickerstreak@28: if Rock then flickerstreak@28: -- possible Rock object flickerstreak@28: for mixin in Rock:IterateObjectMixins(handler) do flickerstreak@28: if type(mixin.GetAceOptionsDataTable) == "function" then flickerstreak@28: local t = mixin:GetAceOptionsDataTable(handler) flickerstreak@28: for k,v in pairs(t) do flickerstreak@28: if type(options.args) ~= "table" then flickerstreak@28: options.args = {} flickerstreak@28: end flickerstreak@28: if options.args[k] == nil then flickerstreak@28: options.args[k] = v flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: else flickerstreak@28: -- Ace2 object flickerstreak@28: while class and class ~= AceLibrary("AceOO-2.0").Class do flickerstreak@28: if type(class.GetAceOptionsDataTable) == "function" then flickerstreak@28: local t = class:GetAceOptionsDataTable(handler) flickerstreak@28: for k,v in pairs(t) do flickerstreak@28: if type(options.args) ~= "table" then flickerstreak@28: options.args = {} flickerstreak@28: end flickerstreak@28: if options.args[k] == nil then flickerstreak@28: options.args[k] = v flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: local mixins = class.mixins flickerstreak@28: if mixins then flickerstreak@28: for mixin in pairs(mixins) do flickerstreak@28: if type(mixin.GetAceOptionsDataTable) == "function" then flickerstreak@28: local t = mixin:GetAceOptionsDataTable(handler) flickerstreak@28: for k,v in pairs(t) do flickerstreak@28: if type(options.args) ~= "table" then flickerstreak@28: options.args = {} flickerstreak@28: end flickerstreak@28: if options.args[k] == nil then flickerstreak@28: options.args[k] = v flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end flickerstreak@28: class = class.super flickerstreak@28: end flickerstreak@28: end flickerstreak@28: return options flickerstreak@28: end flickerstreak@28: flickerstreak@28: function Dewdrop:OnTooltipHide() flickerstreak@28: if lastSetFont then flickerstreak@28: if lastSetFont == normalFont then flickerstreak@28: lastSetFont = nil flickerstreak@28: return flickerstreak@28: end flickerstreak@28: fillRegionTmp(GameTooltip:GetRegions()) flickerstreak@28: for i,v in ipairs(regionTmp) do flickerstreak@28: if v.GetFont then flickerstreak@28: local font,size,outline = v:GetFont() flickerstreak@28: if font == lastSetFont then flickerstreak@28: v:SetFont(normalFont, size, outline) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: regionTmp[i] = nil flickerstreak@28: end flickerstreak@28: lastSetFont = nil flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function activate(self, oldLib, oldDeactivate) flickerstreak@28: Dewdrop = self flickerstreak@28: if oldLib and oldLib.registry then flickerstreak@28: self.registry = oldLib.registry flickerstreak@28: self.onceRegistered = oldLib.onceRegistered flickerstreak@28: else flickerstreak@28: self.registry = {} flickerstreak@28: self.onceRegistered = {} flickerstreak@28: flickerstreak@28: local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown") flickerstreak@28: local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp") flickerstreak@28: local oldX, oldY, clickTime flickerstreak@28: WorldFrame:SetScript("OnMouseDown", function(this, ...) flickerstreak@28: oldX,oldY = GetCursorPosition() flickerstreak@28: clickTime = GetTime() flickerstreak@28: if WorldFrame_OnMouseDown then flickerstreak@28: WorldFrame_OnMouseDown(this, ...) flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: flickerstreak@28: WorldFrame:SetScript("OnMouseUp", function(this, ...) flickerstreak@28: local x,y = GetCursorPosition() flickerstreak@28: if not oldX or not oldY or not x or not y or not clickTime then flickerstreak@28: self:Close() flickerstreak@28: if WorldFrame_OnMouseUp then flickerstreak@28: WorldFrame_OnMouseUp(this, ...) flickerstreak@28: end flickerstreak@28: return flickerstreak@28: end flickerstreak@28: local d = math.abs(x - oldX) + math.abs(y - oldY) flickerstreak@28: if d <= 5 and GetTime() - clickTime < 0.5 then flickerstreak@28: self:Close() flickerstreak@28: end flickerstreak@28: if WorldFrame_OnMouseUp then flickerstreak@28: WorldFrame_OnMouseUp(this, ...) flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: flickerstreak@28: hooksecurefunc(DropDownList1, "Show", function() flickerstreak@28: if levels[1] and levels[1]:IsVisible() then flickerstreak@28: self:Close() flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: flickerstreak@28: hooksecurefunc("HideDropDownMenu", function() flickerstreak@28: if levels[1] and levels[1]:IsVisible() then flickerstreak@28: self:Close() flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: flickerstreak@28: hooksecurefunc("CloseDropDownMenus", function() flickerstreak@28: if levels[1] and levels[1]:IsVisible() then flickerstreak@28: local stack = debugstack() flickerstreak@28: if not stack:find("`TargetFrame_OnHide'") then flickerstreak@28: self:Close() flickerstreak@28: end flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: end flickerstreak@28: self.frame = oldLib and oldLib.frame or CreateFrame("Frame") flickerstreak@28: self.frame:UnregisterAllEvents() flickerstreak@28: self.frame:RegisterEvent("PLAYER_REGEN_ENABLED") flickerstreak@28: self.frame:RegisterEvent("PLAYER_REGEN_DISABLED") flickerstreak@28: self.frame:Hide() flickerstreak@28: self.frame:SetScript("OnEvent", function(this, event) flickerstreak@28: this:Show() flickerstreak@28: if event=="PLAYER_REGEN_ENABLED" then -- track combat state for secure frame operations flickerstreak@28: self.combat = false flickerstreak@28: elseif event=="PLAYER_REGEN_DISABLED" then flickerstreak@28: self.combat = true flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: self.frame:SetScript("OnUpdate", function(this) flickerstreak@28: this:Hide() flickerstreak@28: self:Refresh(1) flickerstreak@28: end) flickerstreak@28: self.hookedTooltip = true flickerstreak@28: if not oldLib or not oldLib.hookedTooltip then flickerstreak@28: local OnTooltipHide = GameTooltip:GetScript("OnHide") flickerstreak@28: GameTooltip:SetScript("OnHide", function(this, ...) flickerstreak@28: if OnTooltipHide then flickerstreak@28: OnTooltipHide(this, ...) flickerstreak@28: end flickerstreak@28: if type(self.OnTooltipHide) == "function" then flickerstreak@28: self:OnTooltipHide() flickerstreak@28: end flickerstreak@28: end) flickerstreak@28: end flickerstreak@28: levels = {} flickerstreak@28: buttons = {} flickerstreak@28: flickerstreak@28: if oldDeactivate then flickerstreak@28: oldDeactivate(oldLib) flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: local function external(lib, major, instance) flickerstreak@28: if major == "SharedMedia-1.0" then flickerstreak@28: SharedMedia = instance flickerstreak@28: end flickerstreak@28: end flickerstreak@28: flickerstreak@28: AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)