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