annotate lib/Dewdrop-2.0/Dewdrop-2.0.lua @ 22:1b9323256a1b

Merging in 1.0 dev tree
author Flick <flickerstreak@gmail.com>
date Fri, 07 Mar 2008 22:10:55 +0000
parents libs/Dewdrop-2.0/Dewdrop-2.0.lua@c11ca1d8ed91
children
rev   line source
flickerstreak@22 1 --[[
flickerstreak@1 2 Name: Dewdrop-2.0
flickerstreak@22 3 Revision: $Rev: 48630 $
flickerstreak@1 4 Author(s): ckknight (ckknight@gmail.com)
flickerstreak@1 5 Website: http://ckknight.wowinterface.com/
flickerstreak@1 6 Documentation: http://wiki.wowace.com/index.php/Dewdrop-2.0
flickerstreak@1 7 SVN: http://svn.wowace.com/root/trunk/DewdropLib/Dewdrop-2.0
flickerstreak@1 8 Description: A library to provide a clean dropdown menu interface.
flickerstreak@1 9 Dependencies: AceLibrary
flickerstreak@22 10 License: LGPL v2.1
flickerstreak@1 11 ]]
flickerstreak@1 12
flickerstreak@1 13 local MAJOR_VERSION = "Dewdrop-2.0"
flickerstreak@22 14 local MINOR_VERSION = "$Revision: 48630 $"
flickerstreak@1 15
flickerstreak@1 16 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
flickerstreak@1 17 if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
flickerstreak@1 18
flickerstreak@1 19 local Dewdrop = {}
flickerstreak@1 20
flickerstreak@22 21 local SharedMedia
flickerstreak@22 22
flickerstreak@1 23 local CLOSE = "Close"
flickerstreak@1 24 local CLOSE_DESC = "Close the menu."
flickerstreak@1 25 local VALIDATION_ERROR = "Validation error."
flickerstreak@22 26 local USAGE_TOOLTIP = "Usage: %s."
flickerstreak@22 27 local RANGE_TOOLTIP = "Note that you can scroll your mouse wheel while over the slider to step by one."
flickerstreak@1 28 local RESET_KEYBINDING_DESC = "Hit escape to clear the keybinding."
flickerstreak@22 29 local KEY_BUTTON1 = "Left Mouse"
flickerstreak@22 30 local KEY_BUTTON2 = "Right Mouse"
flickerstreak@22 31 local DISABLED = "Disabled"
flickerstreak@22 32 local DEFAULT_CONFIRM_MESSAGE = "Are you sure you want to perform `%s'?"
flickerstreak@1 33
flickerstreak@1 34 if GetLocale() == "deDE" then
flickerstreak@22 35 CLOSE = "Schlie\195\159en"
flickerstreak@22 36 CLOSE_DESC = "Men\195\188 schlie\195\159en."
flickerstreak@22 37 VALIDATION_ERROR = "Validierungsfehler."
flickerstreak@22 38 USAGE_TOOLTIP = "Benutzung: %s."
flickerstreak@22 39 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@22 40 RESET_KEYBINDING_DESC = "Escape dr\195\188cken, um die Tastenbelegung zu l\195\182schen."
flickerstreak@22 41 KEY_BUTTON1 = "Linke Maustaste"
flickerstreak@22 42 KEY_BUTTON2 = "Rechte Maustaste"
flickerstreak@22 43 DISABLED = "Deaktiviert"
flickerstreak@22 44 DEFAULT_CONFIRM_MESSAGE = "Bist du sicher das du `%s' machen willst?"
flickerstreak@22 45 elseif GetLocale() == "koKR" then
flickerstreak@22 46 CLOSE = "닫기"
flickerstreak@22 47 CLOSE_DESC = "메뉴를 닫습니다."
flickerstreak@22 48 VALIDATION_ERROR = "오류 확인."
flickerstreak@22 49 USAGE_TOOLTIP = "사용법: %s."
flickerstreak@22 50 RANGE_TOOLTIP = "알림 : 슬라이더 위에서 마우스 휠을 사용하면 한단계씩 조절할 수 있습니다."
flickerstreak@22 51 RESET_KEYBINDING_DESC = "단축키를 해제하려면 ESC키를 누르세요."
flickerstreak@22 52 KEY_BUTTON1 = "왼쪽 마우스"
flickerstreak@22 53 KEY_BUTTON2 = "오른쪽 마우스"
flickerstreak@22 54 DISABLED = "비활성화됨"
flickerstreak@22 55 DEFAULT_CONFIRM_MESSAGE = "정말로 `%s' 실행을 하시겠습니까 ?"
flickerstreak@22 56 elseif GetLocale() == "frFR" then
flickerstreak@22 57 CLOSE = "Fermer"
flickerstreak@22 58 CLOSE_DESC = "Ferme le menu."
flickerstreak@22 59 VALIDATION_ERROR = "Erreur de validation."
flickerstreak@22 60 USAGE_TOOLTIP = "Utilisation : %s."
flickerstreak@22 61 RANGE_TOOLTIP = "Vous pouvez aussi utiliser la molette de la souris pour pour modifier progressivement."
flickerstreak@22 62 RESET_KEYBINDING_DESC = "Appuyez sur la touche Echappement pour effacer le raccourci."
flickerstreak@22 63 KEY_BUTTON1 = "Clic gauche"
flickerstreak@22 64 KEY_BUTTON2 = "Clic droit"
flickerstreak@22 65 DISABLED = "D\195\169sactiv\195\169"
flickerstreak@22 66 DEFAULT_CONFIRM_MESSAGE = "\195\138tes-vous s\195\187r de vouloir effectuer '%s' ?"
flickerstreak@22 67 elseif GetLocale() == "esES" then
flickerstreak@22 68 CLOSE = "Cerrar"
flickerstreak@22 69 CLOSE_DESC = "Cierra el menú."
flickerstreak@22 70 VALIDATION_ERROR = "Error de validación."
flickerstreak@22 71 USAGE_TOOLTIP = "Uso: %s."
flickerstreak@22 72 RANGE_TOOLTIP = "Puedes desplazarte verticalmente con la rueda del ratón sobre el desplazador."
flickerstreak@22 73 RESET_KEYBINDING_DESC = "Pulsa Escape para borrar la asignación de tecla."
flickerstreak@22 74 KEY_BUTTON1 = "Clic Izquierdo"
flickerstreak@22 75 KEY_BUTTON2 = "Clic Derecho"
flickerstreak@22 76 DISABLED = "Desactivado"
flickerstreak@22 77 DEFAULT_CONFIRM_MESSAGE = "¿Estás seguro de querer realizar `%s'?"
flickerstreak@22 78 elseif GetLocale() == "zhTW" then
flickerstreak@22 79 CLOSE = "關閉"
flickerstreak@22 80 CLOSE_DESC = "關閉選單。"
flickerstreak@22 81 VALIDATION_ERROR = "驗證錯誤。"
flickerstreak@22 82 USAGE_TOOLTIP = "用法: %s。"
flickerstreak@22 83 RANGE_TOOLTIP = "你可以在捲動條上使用滑鼠滾輪來捲動。"
flickerstreak@22 84 RESET_KEYBINDING_DESC = "按Esc鍵清除快捷鍵。"
flickerstreak@22 85 KEY_BUTTON1 = "滑鼠左鍵"
flickerstreak@22 86 KEY_BUTTON2 = "滑鼠右鍵"
flickerstreak@22 87 DISABLED = "停用"
flickerstreak@22 88 DEFAULT_CONFIRM_MESSAGE = "是否執行「%s」?"
flickerstreak@22 89 elseif GetLocale() == "zhCN" then
flickerstreak@22 90 CLOSE = "关闭"
flickerstreak@22 91 CLOSE_DESC = "关闭菜单"
flickerstreak@22 92 VALIDATION_ERROR = "验证错误."
flickerstreak@22 93 USAGE_TOOLTIP = "用法: %s."
flickerstreak@22 94 RANGE_TOOLTIP = "你可以在滚动条上使用鼠标滚轮来翻页."
flickerstreak@22 95 RESET_KEYBINDING_DESC = "按ESC键清除按键绑定"
flickerstreak@22 96 KEY_BUTTON1 = "鼠标左键"
flickerstreak@22 97 KEY_BUTTON2 = "鼠标右键"
flickerstreak@22 98 DISABLED = "禁用"
flickerstreak@22 99 DEFAULT_CONFIRM_MESSAGE = "是否执行'%s'?"
flickerstreak@1 100 end
flickerstreak@1 101
flickerstreak@22 102 Dewdrop.KEY_BUTTON1 = KEY_BUTTON1
flickerstreak@22 103 Dewdrop.KEY_BUTTON2 = KEY_BUTTON2
flickerstreak@22 104
flickerstreak@1 105 local function new(...)
flickerstreak@1 106 local t = {}
flickerstreak@1 107 for i = 1, select('#', ...), 2 do
flickerstreak@1 108 local k = select(i, ...)
flickerstreak@1 109 if k then
flickerstreak@1 110 t[k] = select(i+1, ...)
flickerstreak@1 111 else
flickerstreak@1 112 break
flickerstreak@1 113 end
flickerstreak@1 114 end
flickerstreak@1 115 return t
flickerstreak@1 116 end
flickerstreak@1 117
flickerstreak@1 118 local tmp
flickerstreak@1 119 do
flickerstreak@1 120 local t = {}
flickerstreak@1 121 function tmp(...)
flickerstreak@1 122 for k in pairs(t) do
flickerstreak@1 123 t[k] = nil
flickerstreak@1 124 end
flickerstreak@1 125 for i = 1, select('#', ...), 2 do
flickerstreak@1 126 local k = select(i, ...)
flickerstreak@1 127 if k then
flickerstreak@1 128 t[k] = select(i+1, ...)
flickerstreak@1 129 else
flickerstreak@1 130 break
flickerstreak@1 131 end
flickerstreak@1 132 end
flickerstreak@1 133 return t
flickerstreak@1 134 end
flickerstreak@1 135 end
flickerstreak@1 136 local tmp2
flickerstreak@1 137 do
flickerstreak@1 138 local t = {}
flickerstreak@1 139 function tmp2(...)
flickerstreak@1 140 for k in pairs(t) do
flickerstreak@1 141 t[k] = nil
flickerstreak@1 142 end
flickerstreak@1 143 for i = 1, select('#', ...), 2 do
flickerstreak@1 144 local k = select(i, ...)
flickerstreak@1 145 if k then
flickerstreak@1 146 t[k] = select(i+1, ...)
flickerstreak@1 147 else
flickerstreak@1 148 break
flickerstreak@1 149 end
flickerstreak@1 150 end
flickerstreak@1 151 return t
flickerstreak@1 152 end
flickerstreak@1 153 end
flickerstreak@1 154 local levels
flickerstreak@1 155 local buttons
flickerstreak@1 156
flickerstreak@22 157
flickerstreak@22 158 -- Secure frame handling:
flickerstreak@22 159 -- Rather than using secure buttons in the menu (has problems), we have one
flickerstreak@22 160 -- master secureframe that we pop onto menu items on mouseover. This requires
flickerstreak@22 161 -- some dark magic with OnLeave etc, but it's not too bad.
flickerstreak@22 162
flickerstreak@22 163 local secureFrame = CreateFrame("Button", nil, nil, "SecureActionButtonTemplate")
flickerstreak@22 164 secureFrame:Hide()
flickerstreak@22 165
flickerstreak@22 166 local function secureFrame_Show(self)
flickerstreak@22 167 local owner = self.owner
flickerstreak@22 168
flickerstreak@22 169 if self.secure then -- Leftovers from previos owner, clean up! ("Shouldn't" happen but does..)
flickerstreak@22 170 for k,v in pairs(self.secure) do
flickerstreak@22 171 self:SetAttribute(k, nil)
flickerstreak@22 172 end
flickerstreak@22 173 end
flickerstreak@22 174 self.secure = owner.secure; -- Grab hold of new secure data
flickerstreak@22 175
flickerstreak@22 176 local scale = owner:GetEffectiveScale()
flickerstreak@22 177
flickerstreak@22 178 self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", owner:GetLeft() * scale, owner:GetTop() * scale)
flickerstreak@22 179 self:SetPoint("BOTTOMRIGHT", nil, "BOTTOMLEFT", owner:GetRight() * scale, owner:GetBottom() * scale)
flickerstreak@22 180 self:EnableMouse(true)
flickerstreak@22 181 for k,v in pairs(self.secure) do
flickerstreak@22 182 self:SetAttribute(k, v)
flickerstreak@22 183 end
flickerstreak@22 184
flickerstreak@22 185 secureFrame:SetFrameStrata(owner:GetFrameStrata())
flickerstreak@22 186 secureFrame:SetFrameLevel(owner:GetFrameLevel()+1)
flickerstreak@22 187
flickerstreak@22 188 self:Show()
flickerstreak@22 189 end
flickerstreak@22 190
flickerstreak@22 191 local function secureFrame_Hide(self)
flickerstreak@22 192 self:Hide()
flickerstreak@22 193 if self.secure then
flickerstreak@22 194 for k,v in pairs(self.secure) do
flickerstreak@22 195 self:SetAttribute(k, nil)
flickerstreak@22 196 end
flickerstreak@22 197 end
flickerstreak@22 198 self.secure = nil
flickerstreak@22 199 end
flickerstreak@22 200
flickerstreak@22 201 secureFrame:SetScript("OnEvent",
flickerstreak@22 202 function()
flickerstreak@22 203 if event=="PLAYER_REGEN_ENABLED" then
flickerstreak@22 204 this.combat = false
flickerstreak@22 205 if not this:IsShown() and this.owner then
flickerstreak@22 206 secureFrame_Show(this)
flickerstreak@22 207 end
flickerstreak@22 208 elseif event=="PLAYER_REGEN_DISABLED" then
flickerstreak@22 209 this.combat = true
flickerstreak@22 210 if this:IsShown() then
flickerstreak@22 211 secureFrame_Hide(this)
flickerstreak@22 212 end
flickerstreak@22 213 end
flickerstreak@22 214 end
flickerstreak@22 215 )
flickerstreak@22 216 secureFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
flickerstreak@22 217 secureFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
flickerstreak@22 218
flickerstreak@22 219 secureFrame:SetScript("OnLeave",
flickerstreak@22 220 function()
flickerstreak@22 221 local owner=this.owner
flickerstreak@22 222 this:Deactivate()
flickerstreak@22 223 owner:GetScript("OnLeave")()
flickerstreak@22 224 end
flickerstreak@22 225 )
flickerstreak@22 226
flickerstreak@22 227 secureFrame:HookScript("OnClick",
flickerstreak@22 228 function()
flickerstreak@22 229 local realthis = this
flickerstreak@22 230 this = this.owner
flickerstreak@22 231 this:GetScript("OnClick")()
flickerstreak@22 232 end
flickerstreak@22 233 )
flickerstreak@22 234
flickerstreak@22 235 function secureFrame:IsOwnedBy(frame)
flickerstreak@22 236 return self.owner == frame
flickerstreak@22 237 end
flickerstreak@22 238
flickerstreak@22 239 function secureFrame:Activate(owner)
flickerstreak@22 240 if self.owner then -- "Shouldn't" happen but apparently it does and I cba to troubleshoot...
flickerstreak@22 241 if not self.combat then
flickerstreak@22 242 secureFrame_Hide(self)
flickerstreak@22 243 end
flickerstreak@22 244 end
flickerstreak@22 245 self.owner = owner
flickerstreak@22 246 if not self.combat then
flickerstreak@22 247 secureFrame_Show(self)
flickerstreak@22 248 end
flickerstreak@22 249 end
flickerstreak@22 250
flickerstreak@22 251 function secureFrame:Deactivate()
flickerstreak@22 252 if not self.combat then
flickerstreak@22 253 secureFrame_Hide(self)
flickerstreak@22 254 end
flickerstreak@22 255 self.owner = nil
flickerstreak@22 256 end
flickerstreak@22 257
flickerstreak@22 258 -- END secure frame utilities
flickerstreak@22 259
flickerstreak@22 260
flickerstreak@22 261 -- Underline on mouseover - use a single global underline that we move around, no point in creating lots of copies
flickerstreak@22 262 local underlineFrame = CreateFrame("Frame", nil)
flickerstreak@22 263 underlineFrame.tx = underlineFrame:CreateTexture()
flickerstreak@22 264 underlineFrame.tx:SetTexture(1,1,0.5,0.75)
flickerstreak@22 265 underlineFrame:SetScript("OnHide", function(this) this:Hide(); end)
flickerstreak@22 266 underlineFrame:SetScript("OnShow", function(this) -- change sizing on the fly to catch runtime uiscale changes
flickerstreak@22 267 underlineFrame.tx:SetPoint("TOPLEFT", -1, -2/this:GetEffectiveScale())
flickerstreak@22 268 underlineFrame.tx:SetPoint("RIGHT", 1,0)
flickerstreak@22 269 underlineFrame.tx:SetHeight(0.6 / this:GetEffectiveScale());
flickerstreak@22 270 end)
flickerstreak@22 271 underlineFrame:SetHeight(1)
flickerstreak@22 272
flickerstreak@22 273 -- END underline on mouseover
flickerstreak@22 274
flickerstreak@22 275
flickerstreak@1 276 local function GetScaledCursorPosition()
flickerstreak@1 277 local x, y = GetCursorPosition()
flickerstreak@1 278 local scale = UIParent:GetEffectiveScale()
flickerstreak@1 279 return x / scale, y / scale
flickerstreak@1 280 end
flickerstreak@1 281
flickerstreak@22 282 local function StartCounting(self, level)
flickerstreak@22 283 for i = level, 1, -1 do
flickerstreak@1 284 if levels[i] then
flickerstreak@1 285 levels[i].count = 3
flickerstreak@1 286 end
flickerstreak@1 287 end
flickerstreak@1 288 end
flickerstreak@1 289
flickerstreak@1 290 local function StopCounting(self, level)
flickerstreak@1 291 for i = level, 1, -1 do
flickerstreak@1 292 if levels[i] then
flickerstreak@1 293 levels[i].count = nil
flickerstreak@1 294 end
flickerstreak@1 295 end
flickerstreak@1 296 end
flickerstreak@1 297
flickerstreak@22 298 local function OnUpdate(self, elapsed)
flickerstreak@1 299 for _,level in ipairs(levels) do
flickerstreak@22 300 local count = level.count
flickerstreak@22 301 if count then
flickerstreak@22 302 count = count - elapsed
flickerstreak@22 303 if count < 0 then
flickerstreak@1 304 level.count = nil
flickerstreak@1 305 self:Close(level.num)
flickerstreak@22 306 else
flickerstreak@22 307 level.count = count
flickerstreak@1 308 end
flickerstreak@1 309 end
flickerstreak@1 310 end
flickerstreak@1 311 end
flickerstreak@1 312
flickerstreak@1 313 local function CheckDualMonitor(self, frame)
flickerstreak@1 314 local ratio = GetScreenWidth() / GetScreenHeight()
flickerstreak@1 315 if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then
flickerstreak@1 316 local offsetx
flickerstreak@1 317 if GetCursorPosition() / GetScreenHeight() * 768 < GetScreenWidth() / 2 then
flickerstreak@1 318 offsetx = GetScreenWidth() / 2 - frame:GetRight()
flickerstreak@1 319 else
flickerstreak@1 320 offsetx = GetScreenWidth() / 2 - frame:GetLeft()
flickerstreak@1 321 end
flickerstreak@1 322 local point, parent, relativePoint, x, y = frame:GetPoint(1)
flickerstreak@1 323 frame:SetPoint(point, parent, relativePoint, (x or 0) + offsetx, y or 0)
flickerstreak@1 324 end
flickerstreak@1 325 end
flickerstreak@1 326
flickerstreak@1 327 local function CheckSize(self, level)
flickerstreak@1 328 if not level.buttons then
flickerstreak@1 329 return
flickerstreak@1 330 end
flickerstreak@1 331 local height = 20
flickerstreak@1 332 for _, button in ipairs(level.buttons) do
flickerstreak@1 333 height = height + button:GetHeight()
flickerstreak@1 334 end
flickerstreak@1 335 level:SetHeight(height)
flickerstreak@1 336 local width = 160
flickerstreak@1 337 for _, button in ipairs(level.buttons) do
flickerstreak@1 338 local extra = 1
flickerstreak@1 339 if button.hasArrow or button.hasColorSwatch then
flickerstreak@1 340 extra = extra + 16
flickerstreak@1 341 end
flickerstreak@1 342 if not button.notCheckable then
flickerstreak@1 343 extra = extra + 24
flickerstreak@1 344 end
flickerstreak@1 345 button.text:SetFont(STANDARD_TEXT_FONT, button.textHeight)
flickerstreak@1 346 if button.text:GetWidth() + extra > width then
flickerstreak@1 347 width = button.text:GetWidth() + extra
flickerstreak@1 348 end
flickerstreak@1 349 end
flickerstreak@1 350 level:SetWidth(width + 20)
flickerstreak@1 351 if level:GetLeft() and level:GetRight() and level:GetTop() and level:GetBottom() and (level:GetLeft() < 0 or level:GetRight() > GetScreenWidth() or level:GetTop() > GetScreenHeight() or level:GetBottom() < 0) then
flickerstreak@1 352 level:ClearAllPoints()
flickerstreak@22 353 local parent = level.parent or level:GetParent()
flickerstreak@22 354 if type(parent) ~= "table" then
flickerstreak@22 355 parent = UIParent
flickerstreak@22 356 end
flickerstreak@1 357 if level.lastDirection == "RIGHT" then
flickerstreak@1 358 if level.lastVDirection == "DOWN" then
flickerstreak@22 359 level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
flickerstreak@1 360 else
flickerstreak@22 361 level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
flickerstreak@1 362 end
flickerstreak@1 363 else
flickerstreak@1 364 if level.lastVDirection == "DOWN" then
flickerstreak@22 365 level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
flickerstreak@1 366 else
flickerstreak@22 367 level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
flickerstreak@1 368 end
flickerstreak@1 369 end
flickerstreak@1 370 end
flickerstreak@1 371 local dirty = false
flickerstreak@1 372 if not level:GetRight() then
flickerstreak@1 373 self:Close()
flickerstreak@1 374 return
flickerstreak@1 375 end
flickerstreak@1 376 if level:GetRight() > GetScreenWidth() and level.lastDirection == "RIGHT" then
flickerstreak@1 377 level.lastDirection = "LEFT"
flickerstreak@1 378 dirty = true
flickerstreak@1 379 elseif level:GetLeft() < 0 and level.lastDirection == "LEFT" then
flickerstreak@1 380 level.lastDirection = "RIGHT"
flickerstreak@1 381 dirty = true
flickerstreak@1 382 end
flickerstreak@1 383 if level:GetTop() > GetScreenHeight() and level.lastVDirection == "UP" then
flickerstreak@1 384 level.lastVDirection = "DOWN"
flickerstreak@1 385 dirty = true
flickerstreak@1 386 elseif level:GetBottom() < 0 and level.lastVDirection == "DOWN" then
flickerstreak@1 387 level.lastVDirection = "UP"
flickerstreak@1 388 dirty = true
flickerstreak@1 389 end
flickerstreak@1 390 if dirty then
flickerstreak@1 391 level:ClearAllPoints()
flickerstreak@22 392 local parent = level.parent or level:GetParent()
flickerstreak@22 393 if type(parent) ~= "table" then
flickerstreak@22 394 parent = UIParent
flickerstreak@22 395 end
flickerstreak@1 396 if level.lastDirection == "RIGHT" then
flickerstreak@1 397 if level.lastVDirection == "DOWN" then
flickerstreak@22 398 level:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
flickerstreak@1 399 else
flickerstreak@22 400 level:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
flickerstreak@1 401 end
flickerstreak@1 402 else
flickerstreak@1 403 if level.lastVDirection == "DOWN" then
flickerstreak@22 404 level:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
flickerstreak@1 405 else
flickerstreak@22 406 level:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
flickerstreak@1 407 end
flickerstreak@1 408 end
flickerstreak@1 409 end
flickerstreak@1 410 if level:GetTop() > GetScreenHeight() then
flickerstreak@1 411 local top = level:GetTop()
flickerstreak@1 412 local point, parent, relativePoint, x, y = level:GetPoint(1)
flickerstreak@1 413 level:ClearAllPoints()
flickerstreak@1 414 level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) + GetScreenHeight() - top)
flickerstreak@1 415 elseif level:GetBottom() < 0 then
flickerstreak@1 416 local bottom = level:GetBottom()
flickerstreak@1 417 local point, parent, relativePoint, x, y = level:GetPoint(1)
flickerstreak@1 418 level:ClearAllPoints()
flickerstreak@1 419 level:SetPoint(point, parent, relativePoint, x or 0, (y or 0) - bottom)
flickerstreak@1 420 end
flickerstreak@1 421 CheckDualMonitor(self, level)
flickerstreak@1 422 if mod(level.num, 5) == 0 then
flickerstreak@1 423 local left, bottom = level:GetLeft(), level:GetBottom()
flickerstreak@1 424 level:ClearAllPoints()
flickerstreak@1 425 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
flickerstreak@1 426 end
flickerstreak@1 427 end
flickerstreak@1 428
flickerstreak@1 429 local Open
flickerstreak@1 430 local OpenSlider
flickerstreak@1 431 local OpenEditBox
flickerstreak@1 432 local Refresh
flickerstreak@1 433 local Clear
flickerstreak@1 434 local function ReleaseButton(self, level, index)
flickerstreak@1 435 if not level.buttons then
flickerstreak@1 436 return
flickerstreak@1 437 end
flickerstreak@1 438 if not level.buttons[index] then
flickerstreak@1 439 return
flickerstreak@1 440 end
flickerstreak@1 441 local button = level.buttons[index]
flickerstreak@1 442 button:Hide()
flickerstreak@1 443 if button.highlight then
flickerstreak@1 444 button.highlight:Hide()
flickerstreak@1 445 end
flickerstreak@1 446 -- button.arrow:SetVertexColor(1, 1, 1)
flickerstreak@1 447 -- button.arrow:SetHeight(16)
flickerstreak@1 448 -- button.arrow:SetWidth(16)
flickerstreak@1 449 table.remove(level.buttons, index)
flickerstreak@1 450 table.insert(buttons, button)
flickerstreak@1 451 for k in pairs(button) do
flickerstreak@1 452 if k ~= 0 and k ~= "text" and k ~= "check" and k ~= "arrow" and k ~= "colorSwatch" and k ~= "highlight" and k ~= "radioHighlight" then
flickerstreak@1 453 button[k] = nil
flickerstreak@1 454 end
flickerstreak@1 455 end
flickerstreak@1 456 return true
flickerstreak@1 457 end
flickerstreak@1 458
flickerstreak@1 459 local function Scroll(self, level, down)
flickerstreak@1 460 if down then
flickerstreak@1 461 if level:GetBottom() < 0 then
flickerstreak@1 462 local point, parent, relativePoint, x, y = level:GetPoint(1)
flickerstreak@1 463 level:SetPoint(point, parent, relativePoint, x, y + 50)
flickerstreak@1 464 if level:GetBottom() > 0 then
flickerstreak@1 465 level:SetPoint(point, parent, relativePoint, x, y + 50 - level:GetBottom())
flickerstreak@1 466 end
flickerstreak@1 467 end
flickerstreak@1 468 else
flickerstreak@1 469 if level:GetTop() > GetScreenHeight() then
flickerstreak@1 470 local point, parent, relativePoint, x, y = level:GetPoint(1)
flickerstreak@1 471 level:SetPoint(point, parent, relativePoint, x, y - 50)
flickerstreak@1 472 if level:GetTop() < GetScreenHeight() then
flickerstreak@1 473 level:SetPoint(point, parent, relativePoint, x, y - 50 + GetScreenHeight() - level:GetTop())
flickerstreak@1 474 end
flickerstreak@1 475 end
flickerstreak@1 476 end
flickerstreak@1 477 end
flickerstreak@1 478
flickerstreak@22 479 local function getArgs(t, str, num, ...)
flickerstreak@22 480 local x = t[str .. num]
flickerstreak@22 481 if x == nil then
flickerstreak@22 482 return ...
flickerstreak@22 483 else
flickerstreak@22 484 return x, getArgs(t, str, num + 1, ...)
flickerstreak@22 485 end
flickerstreak@22 486 end
flickerstreak@22 487
flickerstreak@1 488 local sliderFrame
flickerstreak@1 489 local editBoxFrame
flickerstreak@1 490
flickerstreak@22 491 local normalFont
flickerstreak@22 492 local lastSetFont
flickerstreak@22 493 local justSetFont = false
flickerstreak@22 494 local regionTmp = {}
flickerstreak@22 495 local function fillRegionTmp(...)
flickerstreak@22 496 for i = 1, select('#', ...) do
flickerstreak@22 497 regionTmp[i] = select(i, ...)
flickerstreak@22 498 end
flickerstreak@22 499 end
flickerstreak@22 500
flickerstreak@1 501 local function showGameTooltip(this)
flickerstreak@1 502 if this.tooltipTitle or this.tooltipText then
flickerstreak@1 503 GameTooltip_SetDefaultAnchor(GameTooltip, this)
flickerstreak@1 504 local disabled = not this.isTitle and this.disabled
flickerstreak@22 505 local font
flickerstreak@1 506 if this.tooltipTitle then
flickerstreak@22 507 if SharedMedia and SharedMedia:IsValid("font", this.tooltipTitle) then
flickerstreak@22 508 font = SharedMedia:Fetch("font", this.tooltipTitle)
flickerstreak@22 509 end
flickerstreak@1 510 if disabled then
flickerstreak@1 511 GameTooltip:SetText(this.tooltipTitle, 0.5, 0.5, 0.5, 1)
flickerstreak@1 512 else
flickerstreak@1 513 GameTooltip:SetText(this.tooltipTitle, 1, 1, 1, 1)
flickerstreak@1 514 end
flickerstreak@1 515 if this.tooltipText then
flickerstreak@22 516 if not font and SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
flickerstreak@22 517 font = SharedMedia:Fetch("font", this.tooltipText)
flickerstreak@22 518 end
flickerstreak@1 519 if disabled then
flickerstreak@1 520 GameTooltip:AddLine(this.tooltipText, (NORMAL_FONT_COLOR.r + 0.5) / 2, (NORMAL_FONT_COLOR.g + 0.5) / 2, (NORMAL_FONT_COLOR.b + 0.5) / 2, 1)
flickerstreak@1 521 else
flickerstreak@1 522 GameTooltip:AddLine(this.tooltipText, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
flickerstreak@1 523 end
flickerstreak@1 524 end
flickerstreak@1 525 else
flickerstreak@22 526 if SharedMedia and SharedMedia:IsValid("font", this.tooltipText) then
flickerstreak@22 527 font = SharedMedia:Fetch("font", this.tooltipText)
flickerstreak@22 528 end
flickerstreak@1 529 if disabled then
flickerstreak@1 530 GameTooltip:SetText(this.tooltipText, 0.5, 0.5, 0.5, 1)
flickerstreak@1 531 else
flickerstreak@1 532 GameTooltip:SetText(this.tooltipText, 1, 1, 1, 1)
flickerstreak@1 533 end
flickerstreak@1 534 end
flickerstreak@22 535 if font then
flickerstreak@22 536 fillRegionTmp(GameTooltip:GetRegions())
flickerstreak@22 537 lastSetFont = font
flickerstreak@22 538 justSetFont = true
flickerstreak@22 539 for i,v in ipairs(regionTmp) do
flickerstreak@22 540 if v.SetFont then
flickerstreak@22 541 local norm,size,outline = v:GetFont()
flickerstreak@22 542 v:SetFont(font, size, outline)
flickerstreak@22 543 if not normalFont then
flickerstreak@22 544 normalFont = norm
flickerstreak@22 545 end
flickerstreak@22 546 end
flickerstreak@22 547 regionTmp[i] = nil
flickerstreak@22 548 end
flickerstreak@22 549 elseif not normalFont then
flickerstreak@22 550 fillRegionTmp(GameTooltip:GetRegions())
flickerstreak@22 551 for i,v in ipairs(regionTmp) do
flickerstreak@22 552 if v.GetFont and not normalFont then
flickerstreak@22 553 normalFont = v:GetFont()
flickerstreak@22 554 end
flickerstreak@22 555 regionTmp[i] = nil
flickerstreak@22 556 end
flickerstreak@22 557 end
flickerstreak@1 558 GameTooltip:Show()
flickerstreak@1 559 end
flickerstreak@1 560 if this.tooltipFunc then
flickerstreak@1 561 GameTooltip:SetOwner(this, "ANCHOR_NONE")
flickerstreak@1 562 GameTooltip:SetPoint("TOPLEFT", this, "TOPRIGHT", 5, 0)
flickerstreak@22 563 this.tooltipFunc(getArgs(this, 'tooltipArg', 1))
flickerstreak@1 564 GameTooltip:Show()
flickerstreak@1 565 end
flickerstreak@1 566 end
flickerstreak@1 567
flickerstreak@22 568 local tmpt = setmetatable({}, {mode='v'})
flickerstreak@1 569 local numButtons = 0
flickerstreak@1 570 local function AcquireButton(self, level)
flickerstreak@1 571 if not levels[level] then
flickerstreak@1 572 return
flickerstreak@1 573 end
flickerstreak@1 574 level = levels[level]
flickerstreak@1 575 if not level.buttons then
flickerstreak@1 576 level.buttons = {}
flickerstreak@1 577 end
flickerstreak@1 578 local button
flickerstreak@1 579 if #buttons == 0 then
flickerstreak@1 580 numButtons = numButtons + 1
flickerstreak@1 581 button = CreateFrame("Button", "Dewdrop20Button" .. numButtons, nil)
flickerstreak@1 582 button:SetFrameStrata("FULLSCREEN_DIALOG")
flickerstreak@1 583 button:SetHeight(16)
flickerstreak@1 584 local highlight = button:CreateTexture(nil, "BACKGROUND")
flickerstreak@1 585 highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
flickerstreak@1 586 button.highlight = highlight
flickerstreak@1 587 highlight:SetBlendMode("ADD")
flickerstreak@1 588 highlight:SetAllPoints(button)
flickerstreak@1 589 highlight:Hide()
flickerstreak@1 590 local check = button:CreateTexture(nil, "ARTWORK")
flickerstreak@1 591 button.check = check
flickerstreak@1 592 check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
flickerstreak@1 593 check:SetPoint("CENTER", button, "LEFT", 12, 0)
flickerstreak@1 594 check:SetWidth(24)
flickerstreak@1 595 check:SetHeight(24)
flickerstreak@1 596 local radioHighlight = button:CreateTexture(nil, "ARTWORK")
flickerstreak@1 597 button.radioHighlight = radioHighlight
flickerstreak@1 598 radioHighlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
flickerstreak@1 599 radioHighlight:SetAllPoints(check)
flickerstreak@1 600 radioHighlight:SetBlendMode("ADD")
flickerstreak@1 601 radioHighlight:SetTexCoord(0.5, 0.75, 0, 1)
flickerstreak@1 602 radioHighlight:Hide()
flickerstreak@1 603 button:SetScript("OnEnter", function()
flickerstreak@1 604 if (sliderFrame and sliderFrame:IsShown() and sliderFrame.mouseDown and sliderFrame.level == this.level.num + 1) or (editBoxFrame and editBoxFrame:IsShown() and editBoxFrame.mouseDown and editBoxFrame.level == this.level.num + 1) then
flickerstreak@1 605 for i = 1, this.level.num do
flickerstreak@1 606 Refresh(self, levels[i])
flickerstreak@1 607 end
flickerstreak@1 608 return
flickerstreak@1 609 end
flickerstreak@1 610 self:Close(this.level.num + 1)
flickerstreak@1 611 if not this.disabled then
flickerstreak@22 612 if this.secure then
flickerstreak@22 613 secureFrame:Activate(this)
flickerstreak@22 614 elseif this.hasSlider then
flickerstreak@1 615 OpenSlider(self, this)
flickerstreak@1 616 elseif this.hasEditBox then
flickerstreak@1 617 OpenEditBox(self, this)
flickerstreak@1 618 elseif this.hasArrow then
flickerstreak@1 619 Open(self, this, nil, this.level.num + 1, this.value)
flickerstreak@1 620 end
flickerstreak@1 621 end
flickerstreak@1 622 if not this.level then -- button reclaimed
flickerstreak@1 623 return
flickerstreak@1 624 end
flickerstreak@1 625 StopCounting(self, this.level.num + 1)
flickerstreak@1 626 if not this.disabled then
flickerstreak@1 627 highlight:Show()
flickerstreak@1 628 if this.isRadio then
flickerstreak@1 629 button.radioHighlight:Show()
flickerstreak@1 630 end
flickerstreak@22 631 if this.mouseoverUnderline then
flickerstreak@22 632 underlineFrame:SetParent(this)
flickerstreak@22 633 underlineFrame:SetPoint("BOTTOMLEFT",this.text,0,0)
flickerstreak@22 634 underlineFrame:SetWidth(this.text:GetWidth())
flickerstreak@22 635 underlineFrame:Show()
flickerstreak@22 636 end
flickerstreak@1 637 end
flickerstreak@1 638 showGameTooltip(this)
flickerstreak@1 639 end)
flickerstreak@22 640 button:SetScript("OnHide", function()
flickerstreak@22 641 if this.secure and secureFrame:IsOwnedBy(this) then
flickerstreak@22 642 secureFrame:Deactivate()
flickerstreak@22 643 end
flickerstreak@22 644 end)
flickerstreak@1 645 button:SetScript("OnLeave", function()
flickerstreak@22 646 if this.secure and secureFrame:IsShown() then
flickerstreak@22 647 return; -- it's ok, we didn't actually mouse out of the button, only onto the secure frame on top of it
flickerstreak@22 648 end
flickerstreak@22 649 underlineFrame:Hide()
flickerstreak@1 650 if not this.selected then
flickerstreak@1 651 highlight:Hide()
flickerstreak@1 652 end
flickerstreak@1 653 button.radioHighlight:Hide()
flickerstreak@1 654 if this.level then
flickerstreak@1 655 StartCounting(self, this.level.num)
flickerstreak@1 656 end
flickerstreak@1 657 GameTooltip:Hide()
flickerstreak@1 658 end)
flickerstreak@22 659 local first = true
flickerstreak@1 660 button:SetScript("OnClick", function()
flickerstreak@1 661 if not this.disabled then
flickerstreak@1 662 if this.hasColorSwatch then
flickerstreak@1 663 local func = button.colorFunc
flickerstreak@1 664 local hasOpacity = this.hasOpacity
flickerstreak@22 665 local this = this
flickerstreak@22 666 for k in pairs(tmpt) do
flickerstreak@22 667 tmpt[k] = nil
flickerstreak@22 668 end
flickerstreak@22 669 for i = 1, 1000 do
flickerstreak@22 670 local x = this['colorArg'..i]
flickerstreak@22 671 if x == nil then
flickerstreak@22 672 break
flickerstreak@22 673 else
flickerstreak@22 674 tmpt[i] = x
flickerstreak@22 675 end
flickerstreak@22 676 end
flickerstreak@1 677 ColorPickerFrame.func = function()
flickerstreak@1 678 if func then
flickerstreak@1 679 local r,g,b = ColorPickerFrame:GetColorRGB()
flickerstreak@1 680 local a = hasOpacity and 1 - OpacitySliderFrame:GetValue() or nil
flickerstreak@22 681 local n = #tmpt
flickerstreak@22 682 tmpt[n+1] = r
flickerstreak@22 683 tmpt[n+2] = g
flickerstreak@22 684 tmpt[n+3] = b
flickerstreak@22 685 tmpt[n+4] = a
flickerstreak@22 686 func(unpack(tmpt))
flickerstreak@22 687 tmpt[n+1] = nil
flickerstreak@22 688 tmpt[n+2] = nil
flickerstreak@22 689 tmpt[n+3] = nil
flickerstreak@22 690 tmpt[n+4] = nil
flickerstreak@1 691 end
flickerstreak@1 692 end
flickerstreak@1 693 ColorPickerFrame.hasOpacity = this.hasOpacity
flickerstreak@1 694 ColorPickerFrame.opacityFunc = ColorPickerFrame.func
flickerstreak@1 695 ColorPickerFrame.opacity = 1 - this.opacity
flickerstreak@1 696 ColorPickerFrame:SetColorRGB(this.r, this.g, this.b)
flickerstreak@1 697 local r, g, b, a = this.r, this.g, this.b, this.opacity
flickerstreak@1 698 ColorPickerFrame.cancelFunc = function()
flickerstreak@22 699 if func then
flickerstreak@22 700 local n = #tmpt
flickerstreak@22 701 tmpt[n+1] = r
flickerstreak@22 702 tmpt[n+2] = g
flickerstreak@22 703 tmpt[n+3] = b
flickerstreak@22 704 tmpt[n+4] = a
flickerstreak@22 705 func(unpack(tmpt))
flickerstreak@22 706 for i = 1, n+4 do
flickerstreak@22 707 tmpt[i] = nil
flickerstreak@22 708 end
flickerstreak@1 709 end
flickerstreak@1 710 end
flickerstreak@1 711 self:Close(1)
flickerstreak@1 712 ShowUIPanel(ColorPickerFrame)
flickerstreak@1 713 elseif this.func then
flickerstreak@22 714 local level = this.level
flickerstreak@1 715 if type(this.func) == "string" then
flickerstreak@22 716 if type(this.arg1[this.func]) ~= "function" then
flickerstreak@22 717 self:error("Cannot call method %q", this.func)
flickerstreak@22 718 end
flickerstreak@22 719 this.arg1[this.func](this.arg1, getArgs(this, 'arg', 2))
flickerstreak@1 720 else
flickerstreak@22 721 this.func(getArgs(this, 'arg', 1))
flickerstreak@1 722 end
flickerstreak@1 723 if this.closeWhenClicked then
flickerstreak@1 724 self:Close()
flickerstreak@1 725 elseif level:IsShown() then
flickerstreak@1 726 for i = 1, level.num do
flickerstreak@1 727 Refresh(self, levels[i])
flickerstreak@1 728 end
flickerstreak@22 729 local value = levels[level.num].value
flickerstreak@22 730 for i = level.num-1, 1, -1 do
flickerstreak@22 731 local level = levels[i]
flickerstreak@22 732 local good = false
flickerstreak@22 733 for _,button in ipairs(level.buttons) do
flickerstreak@22 734 if button.value == value then
flickerstreak@22 735 good = true
flickerstreak@22 736 break
flickerstreak@22 737 end
flickerstreak@22 738 end
flickerstreak@22 739 if not good then
flickerstreak@22 740 Dewdrop:Close(i+1)
flickerstreak@22 741 end
flickerstreak@22 742 value = levels[i].value
flickerstreak@22 743 end
flickerstreak@1 744 end
flickerstreak@1 745 elseif this.closeWhenClicked then
flickerstreak@1 746 self:Close()
flickerstreak@1 747 end
flickerstreak@1 748 end
flickerstreak@1 749 end)
flickerstreak@1 750 local text = button:CreateFontString(nil, "ARTWORK")
flickerstreak@1 751 button.text = text
flickerstreak@1 752 text:SetFontObject(GameFontHighlightSmall)
flickerstreak@1 753 button.text:SetFont(STANDARD_TEXT_FONT, UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT)
flickerstreak@1 754 button:SetScript("OnMouseDown", function()
flickerstreak@1 755 if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
flickerstreak@1 756 text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 1 or 25, -1)
flickerstreak@1 757 end
flickerstreak@1 758 end)
flickerstreak@1 759 button:SetScript("OnMouseUp", function()
flickerstreak@1 760 if not this.disabled and (this.func or this.colorFunc or this.closeWhenClicked) then
flickerstreak@1 761 text:SetPoint("LEFT", button, "LEFT", this.notCheckable and 0 or 24, 0)
flickerstreak@1 762 end
flickerstreak@1 763 end)
flickerstreak@1 764 local arrow = button:CreateTexture(nil, "ARTWORK")
flickerstreak@1 765 button.arrow = arrow
flickerstreak@1 766 arrow:SetPoint("LEFT", button, "RIGHT", -16, 0)
flickerstreak@1 767 arrow:SetWidth(16)
flickerstreak@1 768 arrow:SetHeight(16)
flickerstreak@1 769 arrow:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
flickerstreak@22 770 local colorSwatch = button:CreateTexture(nil, "ARTWORK")
flickerstreak@1 771 button.colorSwatch = colorSwatch
flickerstreak@1 772 colorSwatch:SetWidth(20)
flickerstreak@1 773 colorSwatch:SetHeight(20)
flickerstreak@1 774 colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
flickerstreak@1 775 local texture = button:CreateTexture(nil, "OVERLAY")
flickerstreak@1 776 colorSwatch.texture = texture
flickerstreak@22 777 texture:SetTexture("Interface\\Buttons\\WHITE8X8")
flickerstreak@1 778 texture:SetWidth(11.5)
flickerstreak@1 779 texture:SetHeight(11.5)
flickerstreak@1 780 texture:Show()
flickerstreak@1 781 texture:SetPoint("CENTER", colorSwatch, "CENTER")
flickerstreak@1 782 colorSwatch:SetPoint("RIGHT", button, "RIGHT", 0, 0)
flickerstreak@1 783 else
flickerstreak@1 784 button = table.remove(buttons)
flickerstreak@1 785 end
flickerstreak@1 786 button:ClearAllPoints()
flickerstreak@1 787 button:SetParent(level)
flickerstreak@1 788 button:SetFrameStrata(level:GetFrameStrata())
flickerstreak@1 789 button:SetFrameLevel(level:GetFrameLevel() + 1)
flickerstreak@1 790 button:SetPoint("LEFT", level, "LEFT", 10, 0)
flickerstreak@1 791 button:SetPoint("RIGHT", level, "RIGHT", -10, 0)
flickerstreak@1 792 if #level.buttons == 0 then
flickerstreak@1 793 button:SetPoint("TOP", level, "TOP", 0, -10)
flickerstreak@1 794 else
flickerstreak@1 795 button:SetPoint("TOP", level.buttons[#level.buttons], "BOTTOM", 0, 0)
flickerstreak@1 796 end
flickerstreak@1 797 button.text:SetPoint("LEFT", button, "LEFT", 24, 0)
flickerstreak@1 798 button:Show()
flickerstreak@1 799 button.level = level
flickerstreak@1 800 table.insert(level.buttons, button)
flickerstreak@1 801 if not level.parented then
flickerstreak@1 802 level.parented = true
flickerstreak@1 803 level:ClearAllPoints()
flickerstreak@1 804 if level.num == 1 then
flickerstreak@22 805 if level.parent ~= UIParent and type(level.parent) == "table" then
flickerstreak@1 806 level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT")
flickerstreak@1 807 else
flickerstreak@22 808 level:SetPoint("CENTER", UIParent, "CENTER")
flickerstreak@1 809 end
flickerstreak@1 810 else
flickerstreak@1 811 if level.lastDirection == "RIGHT" then
flickerstreak@1 812 if level.lastVDirection == "DOWN" then
flickerstreak@1 813 level:SetPoint("TOPLEFT", level.parent, "TOPRIGHT", 5, 10)
flickerstreak@1 814 else
flickerstreak@1 815 level:SetPoint("BOTTOMLEFT", level.parent, "BOTTOMRIGHT", 5, -10)
flickerstreak@1 816 end
flickerstreak@1 817 else
flickerstreak@1 818 if level.lastVDirection == "DOWN" then
flickerstreak@1 819 level:SetPoint("TOPRIGHT", level.parent, "TOPLEFT", -5, 10)
flickerstreak@1 820 else
flickerstreak@1 821 level:SetPoint("BOTTOMRIGHT", level.parent, "BOTTOMLEFT", -5, -10)
flickerstreak@1 822 end
flickerstreak@1 823 end
flickerstreak@1 824 end
flickerstreak@1 825 level:SetFrameStrata("FULLSCREEN_DIALOG")
flickerstreak@1 826 end
flickerstreak@1 827 button:SetAlpha(1)
flickerstreak@1 828 return button
flickerstreak@1 829 end
flickerstreak@1 830
flickerstreak@1 831 local numLevels = 0
flickerstreak@1 832 local function AcquireLevel(self, level)
flickerstreak@1 833 if not levels[level] then
flickerstreak@1 834 for i = #levels + 1, level, -1 do
flickerstreak@1 835 local i = i
flickerstreak@1 836 numLevels = numLevels + 1
flickerstreak@1 837 local frame = CreateFrame("Button", "Dewdrop20Level" .. numLevels, nil)
flickerstreak@1 838 if i == 1 then
flickerstreak@1 839 local old_CloseSpecialWindows = CloseSpecialWindows
flickerstreak@1 840 function CloseSpecialWindows()
flickerstreak@1 841 local found = old_CloseSpecialWindows()
flickerstreak@1 842 if levels[1]:IsShown() then
flickerstreak@1 843 self:Close()
flickerstreak@1 844 return 1
flickerstreak@1 845 end
flickerstreak@1 846 return found
flickerstreak@1 847 end
flickerstreak@1 848 end
flickerstreak@1 849 levels[i] = frame
flickerstreak@1 850 frame.num = i
flickerstreak@1 851 frame:SetParent(UIParent)
flickerstreak@1 852 frame:SetFrameStrata("FULLSCREEN_DIALOG")
flickerstreak@1 853 frame:Hide()
flickerstreak@1 854 frame:SetWidth(180)
flickerstreak@1 855 frame:SetHeight(10)
flickerstreak@1 856 frame:SetFrameLevel(i * 3)
flickerstreak@1 857 frame:SetScript("OnHide", function()
flickerstreak@1 858 self:Close(level + 1)
flickerstreak@1 859 end)
flickerstreak@1 860 if frame.SetTopLevel then
flickerstreak@1 861 frame:SetTopLevel(true)
flickerstreak@1 862 end
flickerstreak@1 863 frame:EnableMouse(true)
flickerstreak@1 864 frame:EnableMouseWheel(true)
flickerstreak@1 865 local backdrop = CreateFrame("Frame", nil, frame)
flickerstreak@1 866 backdrop:SetAllPoints(frame)
flickerstreak@1 867 backdrop:SetBackdrop(tmp(
flickerstreak@1 868 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
flickerstreak@1 869 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
flickerstreak@1 870 'tile', true,
flickerstreak@1 871 'insets', tmp2(
flickerstreak@1 872 'left', 5,
flickerstreak@1 873 'right', 5,
flickerstreak@1 874 'top', 5,
flickerstreak@1 875 'bottom', 5
flickerstreak@1 876 ),
flickerstreak@1 877 'tileSize', 16,
flickerstreak@1 878 'edgeSize', 16
flickerstreak@1 879 ))
flickerstreak@1 880 backdrop:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
flickerstreak@1 881 backdrop:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
flickerstreak@1 882 frame:SetScript("OnClick", function()
flickerstreak@1 883 self:Close(i)
flickerstreak@1 884 end)
flickerstreak@1 885 frame:SetScript("OnEnter", function()
flickerstreak@1 886 StopCounting(self, i)
flickerstreak@1 887 end)
flickerstreak@1 888 frame:SetScript("OnLeave", function()
flickerstreak@1 889 StartCounting(self, i)
flickerstreak@1 890 end)
flickerstreak@1 891 frame:SetScript("OnMouseWheel", function()
flickerstreak@1 892 Scroll(self, frame, arg1 < 0)
flickerstreak@1 893 end)
flickerstreak@1 894 if i == 1 then
flickerstreak@22 895 frame:SetScript("OnUpdate", function(this, arg1)
flickerstreak@1 896 OnUpdate(self, arg1)
flickerstreak@1 897 end)
flickerstreak@1 898 levels[1].lastDirection = "RIGHT"
flickerstreak@1 899 levels[1].lastVDirection = "DOWN"
flickerstreak@1 900 else
flickerstreak@1 901 levels[i].lastDirection = levels[i - 1].lastDirection
flickerstreak@1 902 levels[i].lastVDirection = levels[i - 1].lastVDirection
flickerstreak@1 903 end
flickerstreak@1 904 end
flickerstreak@1 905 end
flickerstreak@22 906 local fullscreenFrame = GetUIPanel("fullscreen")
flickerstreak@1 907 local l = levels[level]
flickerstreak@1 908 local strata, framelevel = l:GetFrameStrata(), l:GetFrameLevel()
flickerstreak@1 909 if fullscreenFrame then
flickerstreak@1 910 l:SetParent(fullscreenFrame)
flickerstreak@1 911 else
flickerstreak@1 912 l:SetParent(UIParent)
flickerstreak@1 913 end
flickerstreak@1 914 l:SetFrameStrata(strata)
flickerstreak@1 915 l:SetFrameLevel(framelevel)
flickerstreak@1 916 l:SetAlpha(1)
flickerstreak@1 917 return l
flickerstreak@1 918 end
flickerstreak@1 919
flickerstreak@1 920 local function validateOptions(options, position, baseOptions, fromPass)
flickerstreak@1 921 if not baseOptions then
flickerstreak@1 922 baseOptions = options
flickerstreak@1 923 end
flickerstreak@1 924 if type(options) ~= "table" then
flickerstreak@1 925 return "Options must be a table.", position
flickerstreak@1 926 end
flickerstreak@1 927 local kind = options.type
flickerstreak@1 928 if type(kind) ~= "string" then
flickerstreak@1 929 return '"type" must be a string.', position
flickerstreak@22 930 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@22 931 return '"type" must either be "range", "text", "group", "toggle", "execute", "color", "dragLink", or "header".', position
flickerstreak@1 932 end
flickerstreak@1 933 if options.aliases then
flickerstreak@1 934 if type(options.aliases) ~= "table" and type(options.aliases) ~= "string" then
flickerstreak@1 935 return '"alias" must be a table or string', position
flickerstreak@1 936 end
flickerstreak@1 937 end
flickerstreak@1 938 if not fromPass then
flickerstreak@1 939 if kind == "execute" then
flickerstreak@1 940 if type(options.func) ~= "string" and type(options.func) ~= "function" then
flickerstreak@1 941 return '"func" must be a string or function', position
flickerstreak@1 942 end
flickerstreak@1 943 elseif kind == "range" or kind == "text" or kind == "toggle" then
flickerstreak@1 944 if type(options.set) ~= "string" and type(options.set) ~= "function" then
flickerstreak@1 945 return '"set" must be a string or function', position
flickerstreak@1 946 end
flickerstreak@1 947 if kind == "text" and options.get == false then
flickerstreak@1 948 elseif type(options.get) ~= "string" and type(options.get) ~= "function" then
flickerstreak@1 949 return '"get" must be a string or function', position
flickerstreak@1 950 end
flickerstreak@1 951 elseif kind == "group" and options.pass then
flickerstreak@1 952 if options.pass ~= true then
flickerstreak@1 953 return '"pass" must be either nil, true, or false', position
flickerstreak@1 954 end
flickerstreak@1 955 if not options.func then
flickerstreak@1 956 if type(options.set) ~= "string" and type(options.set) ~= "function" then
flickerstreak@1 957 return '"set" must be a string or function', position
flickerstreak@1 958 end
flickerstreak@1 959 if type(options.get) ~= "string" and type(options.get) ~= "function" then
flickerstreak@1 960 return '"get" must be a string or function', position
flickerstreak@1 961 end
flickerstreak@1 962 elseif type(options.func) ~= "string" and type(options.func) ~= "function" then
flickerstreak@1 963 return '"func" must be a string or function', position
flickerstreak@1 964 end
flickerstreak@1 965 end
flickerstreak@1 966 end
flickerstreak@1 967 if options ~= baseOptions then
flickerstreak@1 968 if kind == "header" then
flickerstreak@1 969 elseif type(options.desc) ~= "string" then
flickerstreak@1 970 return '"desc" must be a string', position
flickerstreak@1 971 elseif options.desc:len() == 0 then
flickerstreak@1 972 return '"desc" cannot be a 0-length string', position
flickerstreak@1 973 end
flickerstreak@1 974 end
flickerstreak@1 975 if options ~= baseOptions or kind == "range" or kind == "text" or kind == "toggle" or kind == "color" then
flickerstreak@1 976 if options.type == "header" and not options.cmdName and not options.name then
flickerstreak@1 977 elseif options.cmdName then
flickerstreak@1 978 if type(options.cmdName) ~= "string" then
flickerstreak@1 979 return '"cmdName" must be a string or nil', position
flickerstreak@1 980 elseif options.cmdName:len() == 0 then
flickerstreak@1 981 return '"cmdName" cannot be a 0-length string', position
flickerstreak@1 982 end
flickerstreak@1 983 if type(options.guiName) ~= "string" then
flickerstreak@1 984 if not options.guiNameIsMap then
flickerstreak@1 985 return '"guiName" must be a string or nil', position
flickerstreak@1 986 end
flickerstreak@1 987 elseif options.guiName:len() == 0 then
flickerstreak@1 988 return '"guiName" cannot be a 0-length string', position
flickerstreak@1 989 end
flickerstreak@1 990 else
flickerstreak@1 991 if type(options.name) ~= "string" then
flickerstreak@1 992 return '"name" must be a string', position
flickerstreak@1 993 elseif options.name:len() == 0 then
flickerstreak@1 994 return '"name" cannot be a 0-length string', position
flickerstreak@1 995 end
flickerstreak@1 996 end
flickerstreak@1 997 end
flickerstreak@1 998 if options.guiNameIsMap then
flickerstreak@1 999 if type(options.guiNameIsMap) ~= "boolean" then
flickerstreak@1 1000 return '"guiNameIsMap" must be a boolean or nil', position
flickerstreak@1 1001 elseif options.type ~= "toggle" then
flickerstreak@1 1002 return 'if "guiNameIsMap" is true, then "type" must be set to \'toggle\'', position
flickerstreak@1 1003 elseif type(options.map) ~= "table" then
flickerstreak@1 1004 return '"map" must be a table', position
flickerstreak@1 1005 end
flickerstreak@1 1006 end
flickerstreak@1 1007 if options.message and type(options.message) ~= "string" then
flickerstreak@1 1008 return '"message" must be a string or nil', position
flickerstreak@1 1009 end
flickerstreak@1 1010 if options.error and type(options.error) ~= "string" then
flickerstreak@1 1011 return '"error" must be a string or nil', position
flickerstreak@1 1012 end
flickerstreak@1 1013 if options.current and type(options.current) ~= "string" then
flickerstreak@1 1014 return '"current" must be a string or nil', position
flickerstreak@1 1015 end
flickerstreak@1 1016 if options.order then
flickerstreak@1 1017 if type(options.order) ~= "number" or (-1 < options.order and options.order < 0.999) then
flickerstreak@1 1018 return '"order" must be a non-zero number or nil', position
flickerstreak@1 1019 end
flickerstreak@1 1020 end
flickerstreak@1 1021 if options.disabled then
flickerstreak@1 1022 if type(options.disabled) ~= "function" and type(options.disabled) ~= "string" and options.disabled ~= true then
flickerstreak@1 1023 return '"disabled" must be a function, string, or boolean', position
flickerstreak@1 1024 end
flickerstreak@1 1025 end
flickerstreak@1 1026 if options.cmdHidden then
flickerstreak@1 1027 if type(options.cmdHidden) ~= "function" and type(options.cmdHidden) ~= "string" and options.cmdHidden ~= true then
flickerstreak@1 1028 return '"cmdHidden" must be a function, string, or boolean', position
flickerstreak@1 1029 end
flickerstreak@1 1030 end
flickerstreak@1 1031 if options.guiHidden then
flickerstreak@1 1032 if type(options.guiHidden) ~= "function" and type(options.guiHidden) ~= "string" and options.guiHidden ~= true then
flickerstreak@1 1033 return '"guiHidden" must be a function, string, or boolean', position
flickerstreak@1 1034 end
flickerstreak@1 1035 end
flickerstreak@1 1036 if options.hidden then
flickerstreak@1 1037 if type(options.hidden) ~= "function" and type(options.hidden) ~= "string" and options.hidden ~= true then
flickerstreak@1 1038 return '"hidden" must be a function, string, or boolean', position
flickerstreak@1 1039 end
flickerstreak@1 1040 end
flickerstreak@1 1041 if kind == "text" then
flickerstreak@1 1042 if type(options.validate) == "table" then
flickerstreak@1 1043 local t = options.validate
flickerstreak@1 1044 local iTable = nil
flickerstreak@1 1045 for k,v in pairs(t) do
flickerstreak@1 1046 if type(k) == "number" then
flickerstreak@1 1047 if iTable == nil then
flickerstreak@1 1048 iTable = true
flickerstreak@1 1049 elseif not iTable then
flickerstreak@1 1050 return '"validate" must either have all keys be indexed numbers or strings', position
flickerstreak@1 1051 elseif k < 1 or k > #t then
flickerstreak@1 1052 return '"validate" numeric keys must be indexed properly. >= 1 and <= #t', position
flickerstreak@1 1053 end
flickerstreak@1 1054 else
flickerstreak@1 1055 if iTable == nil then
flickerstreak@1 1056 iTable = false
flickerstreak@1 1057 elseif iTable then
flickerstreak@1 1058 return '"validate" must either have all keys be indexed numbers or strings', position
flickerstreak@1 1059 end
flickerstreak@1 1060 end
flickerstreak@1 1061 if type(v) ~= "string" then
flickerstreak@1 1062 return '"validate" values must all be strings', position
flickerstreak@1 1063 end
flickerstreak@1 1064 end
flickerstreak@22 1065 if options.multiToggle and options.multiToggle ~= true then
flickerstreak@22 1066 return '"multiToggle" must be a boolean or nil if "validate" is a table', position
flickerstreak@22 1067 end
flickerstreak@1 1068 elseif options.validate == "keybinding" then
flickerstreak@1 1069 -- no other checks
flickerstreak@1 1070 else
flickerstreak@1 1071 if type(options.usage) ~= "string" then
flickerstreak@1 1072 return '"usage" must be a string', position
flickerstreak@1 1073 elseif options.validate and type(options.validate) ~= "string" and type(options.validate) ~= "function" then
flickerstreak@1 1074 return '"validate" must be a string, function, or table', position
flickerstreak@1 1075 end
flickerstreak@1 1076 end
flickerstreak@22 1077 if options.multiToggle and type(options.validate) ~= "table" then
flickerstreak@22 1078 return '"validate" must be a table if "multiToggle" is true', position
flickerstreak@22 1079 end
flickerstreak@1 1080 elseif kind == "range" then
flickerstreak@1 1081 if options.min or options.max then
flickerstreak@1 1082 if type(options.min) ~= "number" then
flickerstreak@1 1083 return '"min" must be a number', position
flickerstreak@1 1084 elseif type(options.max) ~= "number" then
flickerstreak@1 1085 return '"max" must be a number', position
flickerstreak@1 1086 elseif options.min >= options.max then
flickerstreak@1 1087 return '"min" must be less than "max"', position
flickerstreak@1 1088 end
flickerstreak@1 1089 end
flickerstreak@1 1090 if options.step then
flickerstreak@1 1091 if type(options.step) ~= "number" then
flickerstreak@1 1092 return '"step" must be a number', position
flickerstreak@1 1093 elseif options.step < 0 then
flickerstreak@1 1094 return '"step" must be nonnegative', position
flickerstreak@1 1095 end
flickerstreak@1 1096 end
flickerstreak@22 1097 if options.bigStep then
flickerstreak@22 1098 if type(options.bigStep) ~= "number" then
flickerstreak@22 1099 return '"bigStep" must be a number', position
flickerstreak@22 1100 elseif options.bigStep < 0 then
flickerstreak@22 1101 return '"bigStep" must be nonnegative', position
flickerstreak@22 1102 end
flickerstreak@22 1103 end
flickerstreak@1 1104 if options.isPercent and options.isPercent ~= true then
flickerstreak@1 1105 return '"isPercent" must either be nil, true, or false', position
flickerstreak@1 1106 end
flickerstreak@1 1107 elseif kind == "toggle" then
flickerstreak@1 1108 if options.map then
flickerstreak@1 1109 if type(options.map) ~= "table" then
flickerstreak@1 1110 return '"map" must be a table', position
flickerstreak@1 1111 elseif type(options.map[true]) ~= "string" then
flickerstreak@1 1112 return '"map[true]" must be a string', position
flickerstreak@1 1113 elseif type(options.map[false]) ~= "string" then
flickerstreak@1 1114 return '"map[false]" must be a string', position
flickerstreak@1 1115 end
flickerstreak@1 1116 end
flickerstreak@1 1117 elseif kind == "color" then
flickerstreak@1 1118 if options.hasAlpha and options.hasAlpha ~= true then
flickerstreak@1 1119 return '"hasAlpha" must be nil, true, or false', position
flickerstreak@1 1120 end
flickerstreak@1 1121 elseif kind == "group" then
flickerstreak@1 1122 if options.pass and options.pass ~= true then
flickerstreak@1 1123 return '"pass" must be nil, true, or false', position
flickerstreak@1 1124 end
flickerstreak@1 1125 if type(options.args) ~= "table" then
flickerstreak@1 1126 return '"args" must be a table', position
flickerstreak@1 1127 end
flickerstreak@1 1128 for k,v in pairs(options.args) do
flickerstreak@22 1129 if type(k) ~= "number" then
flickerstreak@22 1130 if type(k) ~= "string" then
flickerstreak@22 1131 return '"args" keys must be strings or numbers', position
flickerstreak@22 1132 elseif k:len() == 0 then
flickerstreak@22 1133 return '"args" keys must not be 0-length strings.', position
flickerstreak@22 1134 end
flickerstreak@1 1135 end
flickerstreak@1 1136 if type(v) ~= "table" then
flickerstreak@1 1137 return '"args" values must be tables', position and position .. "." .. k or k
flickerstreak@1 1138 end
flickerstreak@1 1139 local newposition
flickerstreak@1 1140 if position then
flickerstreak@1 1141 newposition = position .. ".args." .. k
flickerstreak@1 1142 else
flickerstreak@1 1143 newposition = "args." .. k
flickerstreak@1 1144 end
flickerstreak@1 1145 local err, pos = validateOptions(v, newposition, baseOptions, options.pass)
flickerstreak@1 1146 if err then
flickerstreak@1 1147 return err, pos
flickerstreak@1 1148 end
flickerstreak@1 1149 end
flickerstreak@22 1150 elseif kind == "execute" then
flickerstreak@22 1151 if type(options.confirm) ~= "string" and type(options.confirm) ~= "boolean" and type(options.confirm) ~= "nil" then
flickerstreak@22 1152 return '"confirm" must be a string, boolean, or nil', position
flickerstreak@22 1153 end
flickerstreak@1 1154 end
flickerstreak@1 1155 if options.icon and type(options.icon) ~= "string" then
flickerstreak@1 1156 return'"icon" must be a string', position
flickerstreak@1 1157 end
flickerstreak@1 1158 if options.iconWidth or options.iconHeight then
flickerstreak@1 1159 if type(options.iconWidth) ~= "number" or type(options.iconHeight) ~= "number" then
flickerstreak@1 1160 return '"iconHeight" and "iconWidth" must be numbers', position
flickerstreak@1 1161 end
flickerstreak@1 1162 end
flickerstreak@1 1163 if options.iconCoordLeft or options.iconCoordRight or options.iconCoordTop or options.iconCoordBottom then
flickerstreak@1 1164 if type(options.iconCoordLeft) ~= "number" or type(options.iconCoordRight) ~= "number" or type(options.iconCoordTop) ~= "number" or type(options.iconCoordBottom) ~= "number" then
flickerstreak@1 1165 return '"iconCoordLeft", "iconCoordRight", "iconCoordTop", and "iconCoordBottom" must be numbers', position
flickerstreak@1 1166 end
flickerstreak@1 1167 end
flickerstreak@1 1168 end
flickerstreak@1 1169
flickerstreak@1 1170 local validatedOptions
flickerstreak@1 1171
flickerstreak@1 1172 local values
flickerstreak@1 1173 local mysort_args
flickerstreak@1 1174 local mysort
flickerstreak@1 1175 local othersort
flickerstreak@1 1176 local othersort_validate
flickerstreak@1 1177
flickerstreak@1 1178 local baseFunc, currentLevel
flickerstreak@1 1179
flickerstreak@22 1180 local function confirmPopup(message, func, ...)
flickerstreak@22 1181 if not StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] then
flickerstreak@22 1182 StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"] = {}
flickerstreak@22 1183 end
flickerstreak@22 1184 local t = StaticPopupDialogs["DEWDROP20_CONFIRM_DIALOG"]
flickerstreak@22 1185 for k in pairs(t) do
flickerstreak@22 1186 t[k] = nil
flickerstreak@22 1187 end
flickerstreak@22 1188 t.text = message
flickerstreak@22 1189 t.button1 = ACCEPT or "Accept"
flickerstreak@22 1190 t.button2 = CANCEL or "Cancel"
flickerstreak@22 1191 t.OnAccept = function()
flickerstreak@22 1192 func(unpack(t))
flickerstreak@22 1193 end
flickerstreak@22 1194 for i = 1, select('#', ...) do
flickerstreak@22 1195 t[i] = select(i, ...)
flickerstreak@22 1196 end
flickerstreak@22 1197 t.timeout = 0
flickerstreak@22 1198 t.whileDead = 1
flickerstreak@22 1199 t.hideOnEscape = 1
flickerstreak@22 1200
flickerstreak@22 1201 Dewdrop:Close()
flickerstreak@22 1202 StaticPopup_Show("DEWDROP20_CONFIRM_DIALOG")
flickerstreak@22 1203 end
flickerstreak@22 1204
flickerstreak@22 1205
flickerstreak@22 1206 local function getMethod(settingname, handler, v, methodName, ...) -- "..." is simply returned straight out cause you can't do "a,b,c = 111,f(),222"
flickerstreak@22 1207 assert(v and type(v)=="table")
flickerstreak@22 1208 assert(methodName and type(methodName)=="string")
flickerstreak@22 1209
flickerstreak@22 1210 local method = v[methodName]
flickerstreak@22 1211 if type(method)=="function" then
flickerstreak@22 1212 return method, ...
flickerstreak@22 1213 elseif type(method)=="string" then
flickerstreak@22 1214 if not handler then
flickerstreak@22 1215 Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
flickerstreak@22 1216 elseif not handler[method] then
flickerstreak@22 1217 Dewdrop:error("[%s] 'handler' method %q not defined", tostring(settingname), method)
flickerstreak@22 1218 end
flickerstreak@22 1219 return handler[method], handler, ...
flickerstreak@22 1220 end
flickerstreak@22 1221
flickerstreak@22 1222 Dewdrop:error("[%s] Missing %q directive", tostring(settingname), methodName)
flickerstreak@22 1223 end
flickerstreak@22 1224
flickerstreak@22 1225 local function callMethod(settingname, handler, v, methodName, ...)
flickerstreak@22 1226 assert(v and type(v)=="table")
flickerstreak@22 1227 assert(methodName and type(methodName)=="string")
flickerstreak@22 1228
flickerstreak@22 1229 local method = v[methodName]
flickerstreak@22 1230 if type(method)=="function" then
flickerstreak@22 1231 local success, ret,ret2,ret3,ret4 = pcall(v[methodName], ...)
flickerstreak@22 1232 if not success then
flickerstreak@22 1233 geterrorhandler()(ret)
flickerstreak@22 1234 return nil
flickerstreak@22 1235 end
flickerstreak@22 1236 return ret,ret2,ret3,ret4
flickerstreak@22 1237
flickerstreak@22 1238 elseif type(method)=="string" then
flickerstreak@22 1239
flickerstreak@22 1240 local neg = method:match("^~(.-)$")
flickerstreak@22 1241 if neg then
flickerstreak@22 1242 method = neg
flickerstreak@22 1243 end
flickerstreak@22 1244 if not handler then
flickerstreak@22 1245 Dewdrop:error("[%s] 'handler' is required if providing a method name: %q", tostring(settingname), method)
flickerstreak@22 1246 elseif not handler[method] then
flickerstreak@22 1247 Dewdrop:error("[%s] 'handler' (%q) method %q not defined", tostring(settingname), handler.name or "(unnamed)", method)
flickerstreak@22 1248 end
flickerstreak@22 1249 local success, ret,ret2,ret3,ret4 = pcall(handler[method], handler, ...)
flickerstreak@22 1250 if not success then
flickerstreak@22 1251 geterrorhandler()(ret)
flickerstreak@22 1252 return nil
flickerstreak@22 1253 end
flickerstreak@22 1254 if neg then
flickerstreak@22 1255 return not ret
flickerstreak@22 1256 end
flickerstreak@22 1257 return ret,ret2,ret3,ret4
flickerstreak@22 1258 elseif method == false then
flickerstreak@22 1259 return nil
flickerstreak@22 1260 end
flickerstreak@22 1261
flickerstreak@22 1262 Dewdrop:error("[%s] Missing %q directive in %q", tostring(settingname), methodName, v.name or "(unnamed)")
flickerstreak@22 1263 end
flickerstreak@22 1264
flickerstreak@22 1265 local function skip1Nil(...)
flickerstreak@22 1266 if select(1,...)==nil then
flickerstreak@22 1267 return select(2,...)
flickerstreak@22 1268 end
flickerstreak@22 1269 return ...
flickerstreak@22 1270 end
flickerstreak@22 1271
flickerstreak@1 1272 function Dewdrop:FeedAceOptionsTable(options, difference)
flickerstreak@1 1273 self:argCheck(options, 2, "table")
flickerstreak@1 1274 self:argCheck(difference, 3, "nil", "number")
flickerstreak@22 1275 if not currentLevel then
flickerstreak@22 1276 self:error("Cannot call `FeedAceOptionsTable' outside of a Dewdrop declaration")
flickerstreak@22 1277 end
flickerstreak@1 1278 if not difference then
flickerstreak@1 1279 difference = 0
flickerstreak@1 1280 end
flickerstreak@1 1281 if not validatedOptions then
flickerstreak@1 1282 validatedOptions = {}
flickerstreak@1 1283 end
flickerstreak@1 1284 if not validatedOptions[options] then
flickerstreak@1 1285 local err, position = validateOptions(options)
flickerstreak@1 1286
flickerstreak@1 1287 if err then
flickerstreak@1 1288 if position then
flickerstreak@1 1289 Dewdrop:error(position .. ": " .. err)
flickerstreak@1 1290 else
flickerstreak@1 1291 Dewdrop:error(err)
flickerstreak@1 1292 end
flickerstreak@1 1293 end
flickerstreak@1 1294
flickerstreak@1 1295 validatedOptions[options] = true
flickerstreak@1 1296 end
flickerstreak@1 1297 local level = levels[currentLevel]
flickerstreak@22 1298 if not level then
flickerstreak@22 1299 self:error("Improper level given")
flickerstreak@22 1300 end
flickerstreak@1 1301 if not values then
flickerstreak@1 1302 values = {}
flickerstreak@1 1303 else
flickerstreak@1 1304 for k,v in pairs(values) do
flickerstreak@1 1305 values[k] = nil
flickerstreak@1 1306 end
flickerstreak@1 1307 end
flickerstreak@1 1308
flickerstreak@1 1309 local current = level
flickerstreak@22 1310 while current do -- this traverses from higher level numbers to lower, building "values" with leaf nodes first and trunk nodes later
flickerstreak@1 1311 if current.num == difference + 1 then
flickerstreak@1 1312 break
flickerstreak@1 1313 end
flickerstreak@1 1314 table.insert(values, current.value)
flickerstreak@1 1315 current = levels[current.num - 1]
flickerstreak@1 1316 end
flickerstreak@1 1317
flickerstreak@1 1318 local realOptions = options
flickerstreak@1 1319 local handler = options.handler
flickerstreak@1 1320 local passTable
flickerstreak@1 1321 local passValue
flickerstreak@22 1322 while #values > 0 do -- This loop traverses values from the END (trunk nodes first, then onto leaf nodes)
flickerstreak@22 1323 if options.pass then
flickerstreak@22 1324 if options.get and options.set then
flickerstreak@22 1325 passTable = options
flickerstreak@22 1326 elseif not passTable then
flickerstreak@22 1327 passTable = options
flickerstreak@22 1328 end
flickerstreak@22 1329 else
flickerstreak@22 1330 passTable = nil
flickerstreak@22 1331 end
flickerstreak@1 1332 local value = table.remove(values)
flickerstreak@1 1333 options = options.args and options.args[value]
flickerstreak@1 1334 if not options then
flickerstreak@1 1335 return
flickerstreak@1 1336 end
flickerstreak@1 1337 handler = options.handler or handler
flickerstreak@1 1338 passValue = passTable and value or nil
flickerstreak@1 1339 end
flickerstreak@1 1340
flickerstreak@1 1341 if options.type == "group" then
flickerstreak@22 1342 local hidden = options.hidden
flickerstreak@22 1343 if type(hidden) == "function" or type(hidden) == "string" then
flickerstreak@22 1344 hidden = callMethod(options.name or "(options root)", handler, options, "hidden", options.passValue) or false
flickerstreak@22 1345 end
flickerstreak@22 1346 if hidden then
flickerstreak@22 1347 return
flickerstreak@22 1348 end
flickerstreak@22 1349 local disabled = options.disabled
flickerstreak@22 1350 if type(disabled) == "function" or type(disabled) == "string" then
flickerstreak@22 1351 disabled = callMethod(options.name or "(options root)", handler, options, "disabled", options.passValue) or false
flickerstreak@22 1352 end
flickerstreak@22 1353 if disabled then
flickerstreak@22 1354 self:AddLine(
flickerstreak@22 1355 'text', DISABLED,
flickerstreak@22 1356 'disabled', true
flickerstreak@22 1357 )
flickerstreak@22 1358 return
flickerstreak@22 1359 end
flickerstreak@1 1360 for k in pairs(options.args) do
flickerstreak@1 1361 table.insert(values, k)
flickerstreak@1 1362 end
flickerstreak@22 1363 if options.pass then
flickerstreak@22 1364 if options.get and options.set then
flickerstreak@22 1365 passTable = options
flickerstreak@22 1366 elseif not passTable then
flickerstreak@22 1367 passTable = options
flickerstreak@22 1368 end
flickerstreak@22 1369 else
flickerstreak@22 1370 passTable = nil
flickerstreak@22 1371 end
flickerstreak@1 1372 if not mysort then
flickerstreak@1 1373 mysort = function(a, b)
flickerstreak@1 1374 local alpha, bravo = mysort_args[a], mysort_args[b]
flickerstreak@1 1375 local alpha_order = alpha.order or 100
flickerstreak@1 1376 local bravo_order = bravo.order or 100
flickerstreak@1 1377 local alpha_name = alpha.guiName or alpha.name
flickerstreak@1 1378 local bravo_name = bravo.guiName or bravo.name
flickerstreak@1 1379 if alpha_order == bravo_order then
flickerstreak@1 1380 if not alpha_name then
flickerstreak@22 1381 return bravo_name
flickerstreak@1 1382 elseif not bravo_name then
flickerstreak@1 1383 return false
flickerstreak@1 1384 else
flickerstreak@22 1385 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@1 1386 end
flickerstreak@1 1387 else
flickerstreak@1 1388 if alpha_order < 0 then
flickerstreak@1 1389 if bravo_order > 0 then
flickerstreak@1 1390 return false
flickerstreak@1 1391 end
flickerstreak@1 1392 else
flickerstreak@1 1393 if bravo_order < 0 then
flickerstreak@1 1394 return true
flickerstreak@1 1395 end
flickerstreak@1 1396 end
flickerstreak@1 1397 return alpha_order < bravo_order
flickerstreak@1 1398 end
flickerstreak@1 1399 end
flickerstreak@1 1400 end
flickerstreak@1 1401 mysort_args = options.args
flickerstreak@1 1402 table.sort(values, mysort)
flickerstreak@1 1403 mysort_args = nil
flickerstreak@1 1404 local hasBoth = #values >= 1 and (options.args[values[1]].order or 100) > 0 and (options.args[values[#values]].order or 100) < 0
flickerstreak@1 1405 local last_order = 1
flickerstreak@1 1406 for _,k in ipairs(values) do
flickerstreak@1 1407 local v = options.args[k]
flickerstreak@1 1408 local handler = v.handler or handler
flickerstreak@1 1409 if hasBoth and last_order > 0 and (v.order or 100) < 0 then
flickerstreak@1 1410 hasBoth = false
flickerstreak@1 1411 self:AddLine()
flickerstreak@1 1412 end
flickerstreak@1 1413 local hidden, disabled = v.guiHidden or v.hidden, v.disabled
flickerstreak@22 1414
flickerstreak@22 1415 if type(hidden) == "function" or type(hidden) == "string" then
flickerstreak@22 1416 hidden = callMethod(k, handler, v, "hidden", v.passValue) or false
flickerstreak@1 1417 end
flickerstreak@1 1418 if not hidden then
flickerstreak@22 1419 if type(disabled) == "function" or type(disabled) == "string" then
flickerstreak@22 1420 disabled = callMethod(k, handler, v, "disabled", v.passValue) or false
flickerstreak@1 1421 end
flickerstreak@1 1422 local name = (v.guiIconOnly and v.icon) and "" or (v.guiName or v.name)
flickerstreak@22 1423 local desc = v.guiDesc or v.desc
flickerstreak@1 1424 local iconHeight = v.iconHeight or 16
flickerstreak@1 1425 local iconWidth = v.iconWidth or 16
flickerstreak@1 1426 local iconCoordLeft = v.iconCoordLeft
flickerstreak@1 1427 local iconCoordRight = v.iconCoordRight
flickerstreak@1 1428 local iconCoordBottom = v.iconCoordBottom
flickerstreak@1 1429 local iconCoordTop = v.iconCoordTop
flickerstreak@1 1430 local tooltipTitle, tooltipText
flickerstreak@1 1431 tooltipTitle = name
flickerstreak@1 1432 if name ~= desc then
flickerstreak@1 1433 tooltipText = desc
flickerstreak@1 1434 end
flickerstreak@22 1435 if type(v.usage) == "string" and v.usage:trim():len() > 0 then
flickerstreak@22 1436 if tooltipText then
flickerstreak@22 1437 tooltipText = tooltipText .. "\n\n" .. USAGE_TOOLTIP:format(v.usage)
flickerstreak@22 1438 else
flickerstreak@22 1439 tooltipText = USAGE_TOOLTIP:format(v.usage)
flickerstreak@22 1440 end
flickerstreak@22 1441 end
flickerstreak@22 1442 local v_p = passTable
flickerstreak@22 1443 if not v_p or (v.type ~= "execute" and v.get and v.set) or (v.type == "execute" and v.func) then
flickerstreak@22 1444 v_p = v
flickerstreak@22 1445 end
flickerstreak@22 1446 local passValue = v.passValue or (v_p~=v and k) or nil
flickerstreak@1 1447 if v.type == "toggle" then
flickerstreak@22 1448 local checked = callMethod(name, handler, v_p, "get", passValue) or false
flickerstreak@22 1449 local checked_arg = checked
flickerstreak@22 1450 if type(v_p.get)=="string" and v_p.get:match("^~") then
flickerstreak@22 1451 checked_arg = not checked
flickerstreak@1 1452 end
flickerstreak@22 1453 local func, arg1, arg2, arg3 = getMethod(name, handler, v_p, "set", skip1Nil(passValue, not checked_arg))
flickerstreak@1 1454 if v.guiNameIsMap then
flickerstreak@1 1455 checked = checked and true or false
flickerstreak@1 1456 name = tostring(v.map and v.map[checked]):gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
flickerstreak@22 1457 tooltipTitle = name
flickerstreak@22 1458 checked = true--nil
flickerstreak@1 1459 end
flickerstreak@1 1460 self:AddLine(
flickerstreak@1 1461 'text', name,
flickerstreak@1 1462 'checked', checked,
flickerstreak@1 1463 'isRadio', v.isRadio,
flickerstreak@1 1464 'func', func,
flickerstreak@1 1465 'arg1', arg1,
flickerstreak@1 1466 'arg2', arg2,
flickerstreak@1 1467 'arg3', arg3,
flickerstreak@1 1468 'disabled', disabled,
flickerstreak@1 1469 'tooltipTitle', tooltipTitle,
flickerstreak@1 1470 'tooltipText', tooltipText
flickerstreak@1 1471 )
flickerstreak@1 1472 elseif v.type == "execute" then
flickerstreak@22 1473 local func, arg1, arg2, arg3, arg4
flickerstreak@22 1474 local confirm = v.confirm
flickerstreak@22 1475 if confirm == true then
flickerstreak@22 1476 confirm = DEFAULT_CONFIRM_MESSAGE:format(tooltipText or tooltipTitle)
flickerstreak@22 1477 func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
flickerstreak@22 1478 elseif type(confirm) == "string" then
flickerstreak@22 1479 func,arg1,arg2,arg3,arg4 = confirmPopup, confirm, getMethod(name, handler, v_p, "func", passValue)
flickerstreak@1 1480 else
flickerstreak@22 1481 func,arg1,arg2 = getMethod(name, handler, v_p, "func", passValue)
flickerstreak@1 1482 end
flickerstreak@1 1483 self:AddLine(
flickerstreak@1 1484 'text', name,
flickerstreak@1 1485 'checked', checked,
flickerstreak@1 1486 'func', func,
flickerstreak@1 1487 'arg1', arg1,
flickerstreak@1 1488 'arg2', arg2,
flickerstreak@22 1489 'arg3', arg3,
flickerstreak@22 1490 'arg4', arg4,
flickerstreak@1 1491 'disabled', disabled,
flickerstreak@1 1492 'tooltipTitle', tooltipTitle,
flickerstreak@1 1493 'tooltipText', tooltipText,
flickerstreak@1 1494 'icon', v.icon,
flickerstreak@1 1495 'iconHeight', iconHeight,
flickerstreak@1 1496 'iconWidth', iconWidth,
flickerstreak@1 1497 'iconCoordLeft', iconCoordLeft,
flickerstreak@1 1498 'iconCoordRight', iconCoordRight,
flickerstreak@1 1499 'iconCoordTop', iconCoordTop,
flickerstreak@1 1500 'iconCoordBottom', iconCoordBottom
flickerstreak@1 1501 )
flickerstreak@1 1502 elseif v.type == "range" then
flickerstreak@1 1503 local sliderValue
flickerstreak@22 1504 sliderValue = callMethod(name, handler, v_p, "get", passValue) or 0
flickerstreak@22 1505 local sliderFunc, sliderArg1, sliderArg2 = getMethod(name, handler, v_p, "set", passValue)
flickerstreak@22 1506 if tooltipText then
flickerstreak@22 1507 tooltipText = format("%s\n\n%s", tooltipText, RANGE_TOOLTIP)
flickerstreak@1 1508 else
flickerstreak@22 1509 tooltipText = RANGE_TOOLTIP
flickerstreak@1 1510 end
flickerstreak@1 1511 self:AddLine(
flickerstreak@1 1512 'text', name,
flickerstreak@1 1513 'hasArrow', true,
flickerstreak@1 1514 'hasSlider', true,
flickerstreak@1 1515 'sliderMin', v.min or 0,
flickerstreak@1 1516 'sliderMax', v.max or 1,
flickerstreak@1 1517 'sliderStep', v.step or 0,
flickerstreak@22 1518 'sliderBigStep', v.bigStep or nil,
flickerstreak@1 1519 'sliderIsPercent', v.isPercent or false,
flickerstreak@1 1520 'sliderValue', sliderValue,
flickerstreak@1 1521 'sliderFunc', sliderFunc,
flickerstreak@1 1522 'sliderArg1', sliderArg1,
flickerstreak@1 1523 'sliderArg2', sliderArg2,
flickerstreak@22 1524 'fromAceOptions', true,
flickerstreak@1 1525 'disabled', disabled,
flickerstreak@1 1526 'tooltipTitle', tooltipTitle,
flickerstreak@1 1527 'tooltipText', tooltipText,
flickerstreak@1 1528 'icon', v.icon,
flickerstreak@1 1529 'iconHeight', iconHeight,
flickerstreak@1 1530 'iconWidth', iconWidth,
flickerstreak@1 1531 'iconCoordLeft', iconCoordLeft,
flickerstreak@1 1532 'iconCoordRight', iconCoordRight,
flickerstreak@1 1533 'iconCoordTop', iconCoordTop,
flickerstreak@1 1534 'iconCoordBottom', iconCoordBottom
flickerstreak@1 1535 )
flickerstreak@1 1536 elseif v.type == "color" then
flickerstreak@22 1537 local r,g,b,a = callMethod(name, handler, v_p, "get", passValue)
flickerstreak@22 1538 if not r then
flickerstreak@22 1539 r,g,b,a = 0,0,0,0
flickerstreak@1 1540 end
flickerstreak@22 1541 local colorFunc, colorArg1, colorArg2 = getMethod(name, handler, v_p, "set", passValue)
flickerstreak@1 1542 self:AddLine(
flickerstreak@1 1543 'text', name,
flickerstreak@1 1544 'hasArrow', true,
flickerstreak@1 1545 'hasColorSwatch', true,
flickerstreak@1 1546 'r', r,
flickerstreak@1 1547 'g', g,
flickerstreak@1 1548 'b', b,
flickerstreak@1 1549 'opacity', v.hasAlpha and a or nil,
flickerstreak@1 1550 'hasOpacity', v.hasAlpha,
flickerstreak@1 1551 'colorFunc', colorFunc,
flickerstreak@1 1552 'colorArg1', colorArg1,
flickerstreak@1 1553 'colorArg2', colorArg2,
flickerstreak@1 1554 'disabled', disabled,
flickerstreak@1 1555 'tooltipTitle', tooltipTitle,
flickerstreak@1 1556 'tooltipText', tooltipText
flickerstreak@1 1557 )
flickerstreak@1 1558 elseif v.type == "text" then
flickerstreak@22 1559 if type(v.validate) == "table" then
flickerstreak@22 1560 local func,arg1,arg2
flickerstreak@22 1561 if v.onClick then
flickerstreak@22 1562 func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
flickerstreak@22 1563 end
flickerstreak@22 1564 local checked
flickerstreak@22 1565 if v.isChecked then
flickerstreak@22 1566 checked = callMethod(name, handler, v, "isChecked", passValue) or false
flickerstreak@22 1567 end
flickerstreak@1 1568 self:AddLine(
flickerstreak@1 1569 'text', name,
flickerstreak@1 1570 'hasArrow', true,
flickerstreak@1 1571 'value', k,
flickerstreak@22 1572 'func', func,
flickerstreak@22 1573 'arg1', arg1,
flickerstreak@22 1574 'arg2', arg2,
flickerstreak@22 1575 'mouseoverUnderline', func and true or nil,
flickerstreak@1 1576 'disabled', disabled,
flickerstreak@22 1577 'checked', checked,
flickerstreak@1 1578 'tooltipTitle', tooltipTitle,
flickerstreak@1 1579 'tooltipText', tooltipText,
flickerstreak@1 1580 'icon', v.icon,
flickerstreak@1 1581 'iconHeight', iconHeight,
flickerstreak@1 1582 'iconWidth', iconWidth,
flickerstreak@1 1583 'iconCoordLeft', iconCoordLeft,
flickerstreak@1 1584 'iconCoordRight', iconCoordRight,
flickerstreak@1 1585 'iconCoordTop', iconCoordTop,
flickerstreak@1 1586 'iconCoordBottom', iconCoordBottom
flickerstreak@1 1587 )
flickerstreak@1 1588 else
flickerstreak@1 1589 local editBoxText
flickerstreak@22 1590 editBoxText = callMethod(name, handler, v_p, "get", passValue) or ""
flickerstreak@22 1591 local editBoxFunc, editBoxArg1, editBoxArg2 = getMethod(name, handler, v_p, "set", passValue)
flickerstreak@22 1592
flickerstreak@1 1593 local editBoxValidateFunc, editBoxValidateArg1
flickerstreak@1 1594
flickerstreak@1 1595 if v.validate and v.validate ~= "keybinding" then
flickerstreak@22 1596 if v.validate == "keybinding" then
flickerstreak@22 1597 if tooltipText then
flickerstreak@22 1598 tooltipText = format("%s\n\n%s", tooltipText, RESET_KEYBINDING_DESC)
flickerstreak@22 1599 else
flickerstreak@22 1600 tooltipText = RESET_KEYBINDING_DESC
flickerstreak@22 1601 end
flickerstreak@1 1602 else
flickerstreak@22 1603 editBoxValidateFunc, editBoxValidateArg1 = getMethod(name, handler, v, "validate") -- no passvalue!
flickerstreak@1 1604 end
flickerstreak@1 1605 end
flickerstreak@22 1606
flickerstreak@1 1607 self:AddLine(
flickerstreak@1 1608 'text', name,
flickerstreak@1 1609 'hasArrow', true,
flickerstreak@1 1610 'icon', v.icon,
flickerstreak@1 1611 'iconHeight', iconHeight,
flickerstreak@1 1612 'iconWidth', iconWidth,
flickerstreak@1 1613 'iconCoordLeft', iconCoordLeft,
flickerstreak@1 1614 'iconCoordRight', iconCoordRight,
flickerstreak@1 1615 'iconCoordTop', iconCoordTop,
flickerstreak@1 1616 'iconCoordBottom', iconCoordBottom,
flickerstreak@1 1617 'hasEditBox', true,
flickerstreak@1 1618 'editBoxText', editBoxText,
flickerstreak@1 1619 'editBoxFunc', editBoxFunc,
flickerstreak@1 1620 'editBoxArg1', editBoxArg1,
flickerstreak@1 1621 'editBoxArg2', editBoxArg2,
flickerstreak@1 1622 'editBoxValidateFunc', editBoxValidateFunc,
flickerstreak@1 1623 'editBoxValidateArg1', editBoxValidateArg1,
flickerstreak@1 1624 'editBoxIsKeybinding', v.validate == "keybinding",
flickerstreak@22 1625 'editBoxKeybindingOnly', v.keybindingOnly,
flickerstreak@22 1626 'editBoxKeybindingExcept', v.keybindingExcept,
flickerstreak@1 1627 'disabled', disabled,
flickerstreak@1 1628 'tooltipTitle', tooltipTitle,
flickerstreak@1 1629 'tooltipText', tooltipText
flickerstreak@1 1630 )
flickerstreak@1 1631 end
flickerstreak@1 1632 elseif v.type == "group" then
flickerstreak@22 1633 local func,arg1,arg2
flickerstreak@22 1634 if v.onClick then
flickerstreak@22 1635 func,arg1,arg2 = getMethod(name, handler, v, "onClick", passValue)
flickerstreak@22 1636 end
flickerstreak@22 1637 local checked
flickerstreak@22 1638 if v.isChecked then
flickerstreak@22 1639 checked = callMethod(name, handler, v, "isChecked", passValue) or false
flickerstreak@22 1640 end
flickerstreak@1 1641 self:AddLine(
flickerstreak@1 1642 'text', name,
flickerstreak@1 1643 'hasArrow', true,
flickerstreak@1 1644 'value', k,
flickerstreak@22 1645 'func', func,
flickerstreak@22 1646 'arg1', arg1,
flickerstreak@22 1647 'arg2', arg2,
flickerstreak@22 1648 'mouseoverUnderline', func and true or nil,
flickerstreak@1 1649 'disabled', disabled,
flickerstreak@22 1650 'checked', checked,
flickerstreak@1 1651 'tooltipTitle', tooltipTitle,
flickerstreak@1 1652 'tooltipText', tooltipText,
flickerstreak@1 1653 'icon', v.icon,
flickerstreak@1 1654 'iconHeight', iconHeight,
flickerstreak@1 1655 'iconWidth', iconWidth,
flickerstreak@1 1656 'iconCoordLeft', iconCoordLeft,
flickerstreak@1 1657 'iconCoordRight', iconCoordRight,
flickerstreak@1 1658 'iconCoordTop', iconCoordTop,
flickerstreak@1 1659 'iconCoordBottom', iconCoordBottom
flickerstreak@1 1660 )
flickerstreak@1 1661 elseif v.type == "header" then
flickerstreak@1 1662 if name == "" or not name then
flickerstreak@1 1663 self:AddLine(
flickerstreak@1 1664 'isTitle', true,
flickerstreak@1 1665 'icon', v.icon,
flickerstreak@1 1666 'iconHeight', iconHeight,
flickerstreak@1 1667 'iconWidth', iconWidth,
flickerstreak@1 1668 'iconCoordLeft', iconCoordLeft,
flickerstreak@1 1669 'iconCoordRight', iconCoordRight,
flickerstreak@1 1670 'iconCoordTop', iconCoordTop,
flickerstreak@1 1671 'iconCoordBottom', iconCoordBottom
flickerstreak@1 1672 )
flickerstreak@1 1673 else
flickerstreak@1 1674 self:AddLine(
flickerstreak@1 1675 'text', name,
flickerstreak@1 1676 'isTitle', true,
flickerstreak@1 1677 'icon', v.icon,
flickerstreak@1 1678 'iconHeight', iconHeight,
flickerstreak@1 1679 'iconWidth', iconWidth,
flickerstreak@1 1680 'iconCoordLeft', iconCoordLeft,
flickerstreak@1 1681 'iconCoordRight', iconCoordRight,
flickerstreak@1 1682 'iconCoordTop', iconCoordTop,
flickerstreak@1 1683 'iconCoordBottom', iconCoordBottom
flickerstreak@1 1684 )
flickerstreak@1 1685 end
flickerstreak@1 1686 end
flickerstreak@1 1687 end
flickerstreak@1 1688 last_order = v.order or 100
flickerstreak@1 1689 end
flickerstreak@1 1690 elseif options.type == "text" and type(options.validate) == "table" then
flickerstreak@1 1691 local current
flickerstreak@22 1692 local options_p = passTable
flickerstreak@22 1693 if not options_p or (options.get and options.set) then
flickerstreak@22 1694 options_p = options
flickerstreak@22 1695 passTable = nil
flickerstreak@22 1696 passValue = nil
flickerstreak@22 1697 end
flickerstreak@22 1698 local multiToggle = options.multiToggle
flickerstreak@22 1699 local passValue = options.passValue or passValue
flickerstreak@22 1700 if not multiToggle then
flickerstreak@22 1701 current = callMethod(k, handler, options_p, "get", passValue)
flickerstreak@1 1702 end
flickerstreak@1 1703 local indexed = true
flickerstreak@1 1704 for k,v in pairs(options.validate) do
flickerstreak@1 1705 if type(k) ~= "number" then
flickerstreak@1 1706 indexed = false
flickerstreak@1 1707 end
flickerstreak@1 1708 table.insert(values, k)
flickerstreak@1 1709 end
flickerstreak@1 1710 if not indexed then
flickerstreak@1 1711 if not othersort then
flickerstreak@1 1712 othersort = function(alpha, bravo)
flickerstreak@22 1713 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@1 1714 end
flickerstreak@1 1715 end
flickerstreak@1 1716 othersort_validate = options.validate
flickerstreak@1 1717 table.sort(values, othersort)
flickerstreak@1 1718 othersort_validate = nil
flickerstreak@1 1719 end
flickerstreak@1 1720 for _,k in ipairs(values) do
flickerstreak@1 1721 local v = options.validate[k]
flickerstreak@1 1722 if type(k) == "number" then
flickerstreak@1 1723 k = v
flickerstreak@1 1724 end
flickerstreak@22 1725 local func, arg1, arg2, arg3, arg4 = getMethod(k, handler, options_p, "set", skip1Nil(passValue, k))
flickerstreak@22 1726 local checked
flickerstreak@22 1727 if multiToggle then
flickerstreak@22 1728 checked = callMethod(k, handler, options_p, "get", skip1Nil(passValue, k)) or false
flickerstreak@22 1729 if arg2 == nil then
flickerstreak@22 1730 arg2 = not checked
flickerstreak@22 1731 elseif arg3 == nil then
flickerstreak@22 1732 arg3 = not checked
flickerstreak@1 1733 else
flickerstreak@22 1734 arg4 = not checked
flickerstreak@1 1735 end
flickerstreak@1 1736 else
flickerstreak@22 1737 checked = (k == current or (type(k) == "string" and type(current) == "string" and k:lower() == current:lower()))
flickerstreak@22 1738 if checked then
flickerstreak@22 1739 func, arg1, arg2, arg3, arg4 = nil, nil, nil, nil, nil
flickerstreak@1 1740 end
flickerstreak@1 1741 end
flickerstreak@22 1742 local tooltipTitle
flickerstreak@22 1743 local tooltipText
flickerstreak@22 1744 if options.validateDesc then
flickerstreak@22 1745 tooltipTitle = v
flickerstreak@22 1746 tooltipText = options.validateDesc[k]
flickerstreak@22 1747 else
flickerstreak@22 1748 tooltipTitle = options.guiName or options.name
flickerstreak@22 1749 tooltipText = v
flickerstreak@22 1750 end
flickerstreak@1 1751 self:AddLine(
flickerstreak@1 1752 'text', v,
flickerstreak@22 1753 'func', func,
flickerstreak@22 1754 'arg1', arg1,
flickerstreak@22 1755 'arg2', arg2,
flickerstreak@22 1756 'arg3', arg3,
flickerstreak@22 1757 'arg4', arg4,
flickerstreak@22 1758 'isRadio', not multiToggle,
flickerstreak@1 1759 'checked', checked,
flickerstreak@22 1760 'tooltipTitle', tooltipTitle,
flickerstreak@22 1761 'tooltipText', tooltipText
flickerstreak@1 1762 )
flickerstreak@1 1763 end
flickerstreak@1 1764 for k in pairs(values) do
flickerstreak@1 1765 values[k] = nil
flickerstreak@1 1766 end
flickerstreak@1 1767 else
flickerstreak@1 1768 return false
flickerstreak@1 1769 end
flickerstreak@1 1770 return true
flickerstreak@1 1771 end
flickerstreak@1 1772
flickerstreak@22 1773 function Dewdrop:FeedTable(s, difference)
flickerstreak@22 1774 self:argCheck(s, 2, "table")
flickerstreak@22 1775 self:argCheck(difference, 3, "nil", "number")
flickerstreak@22 1776 if not currentLevel then
flickerstreak@22 1777 self:error("Cannot call `FeedTable' outside of a Dewdrop declaration")
flickerstreak@22 1778 end
flickerstreak@22 1779 if not difference then
flickerstreak@22 1780 difference = 0
flickerstreak@22 1781 end
flickerstreak@22 1782 local level = levels[currentLevel]
flickerstreak@22 1783 if not level then
flickerstreak@22 1784 self:error("Improper level given")
flickerstreak@22 1785 end
flickerstreak@22 1786 if not values then
flickerstreak@22 1787 values = {}
flickerstreak@22 1788 else
flickerstreak@22 1789 for k,v in pairs(values) do
flickerstreak@22 1790 values[k] = nil
flickerstreak@22 1791 end
flickerstreak@22 1792 end
flickerstreak@22 1793 local t = s.subMenu and s or {subMenu = s}
flickerstreak@22 1794 local current = level
flickerstreak@22 1795 while current do
flickerstreak@22 1796 if current.num == difference + 1 then
flickerstreak@22 1797 break
flickerstreak@22 1798 end
flickerstreak@22 1799 table.insert(values, current.value)
flickerstreak@22 1800 current = levels[current.num - 1]
flickerstreak@22 1801 end
flickerstreak@22 1802
flickerstreak@22 1803 while #values > 0 do
flickerstreak@22 1804 local value = table.remove(values)
flickerstreak@22 1805 t = t.subMenu and t.subMenu[value]
flickerstreak@22 1806 if not t then
flickerstreak@22 1807 return
flickerstreak@22 1808 end
flickerstreak@22 1809 end
flickerstreak@22 1810
flickerstreak@22 1811 if t.subMenu or current.num == 1 then
flickerstreak@22 1812 for k in pairs(t.subMenu) do
flickerstreak@22 1813 table.insert(values, k)
flickerstreak@22 1814 end
flickerstreak@22 1815 table.sort(values)
flickerstreak@22 1816 for _,k in ipairs(values) do
flickerstreak@22 1817 local argTable = {"value", k}
flickerstreak@22 1818 for key, val in pairs(t.subMenu[k]) do
flickerstreak@22 1819 table.insert(argTable, key)
flickerstreak@22 1820 table.insert(argTable, val)
flickerstreak@22 1821 end
flickerstreak@22 1822 self:AddLine(unpack(argTable))
flickerstreak@22 1823 end
flickerstreak@22 1824 for k in pairs(values) do
flickerstreak@22 1825 values[k] = nil
flickerstreak@22 1826 end
flickerstreak@22 1827 return false
flickerstreak@22 1828 end
flickerstreak@22 1829 return true
flickerstreak@22 1830 end
flickerstreak@22 1831
flickerstreak@1 1832 function Refresh(self, level)
flickerstreak@1 1833 if type(level) == "number" then
flickerstreak@1 1834 level = levels[level]
flickerstreak@1 1835 end
flickerstreak@1 1836 if not level then
flickerstreak@1 1837 return
flickerstreak@1 1838 end
flickerstreak@1 1839 if baseFunc then
flickerstreak@1 1840 Clear(self, level)
flickerstreak@1 1841 currentLevel = level.num
flickerstreak@1 1842 if type(baseFunc) == "table" then
flickerstreak@1 1843 if currentLevel == 1 then
flickerstreak@1 1844 local handler = baseFunc.handler
flickerstreak@1 1845 if handler then
flickerstreak@1 1846 local name = tostring(handler)
flickerstreak@22 1847 if not name:find('^table:') and not handler.hideMenuTitle then
flickerstreak@1 1848 name = name:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
flickerstreak@1 1849 self:AddLine(
flickerstreak@1 1850 'text', name,
flickerstreak@1 1851 'isTitle', true
flickerstreak@1 1852 )
flickerstreak@1 1853 end
flickerstreak@1 1854 end
flickerstreak@1 1855 -- elseif level.parentText then
flickerstreak@1 1856 -- self:AddLine(
flickerstreak@1 1857 -- 'text', level.parentText,
flickerstreak@1 1858 -- 'tooltipTitle', level.parentTooltipTitle,
flickerstreak@1 1859 -- 'tooltipText', level.parentTooltipText,
flickerstreak@1 1860 -- 'tooltipFunc', level.parentTooltipFunc,
flickerstreak@1 1861 -- 'isTitle', true
flickerstreak@1 1862 -- )
flickerstreak@1 1863 end
flickerstreak@1 1864 self:FeedAceOptionsTable(baseFunc)
flickerstreak@1 1865 if currentLevel == 1 then
flickerstreak@1 1866 self:AddLine(
flickerstreak@1 1867 'text', CLOSE,
flickerstreak@1 1868 'tooltipTitle', CLOSE,
flickerstreak@1 1869 'tooltipText', CLOSE_DESC,
flickerstreak@1 1870 'closeWhenClicked', true
flickerstreak@1 1871 )
flickerstreak@1 1872 end
flickerstreak@1 1873 else
flickerstreak@1 1874 -- if level.parentText then
flickerstreak@1 1875 -- self:AddLine(
flickerstreak@1 1876 -- 'text', level.parentText,
flickerstreak@1 1877 -- 'tooltipTitle', level.parentTooltipTitle,
flickerstreak@1 1878 -- 'tooltipText', level.parentTooltipText,
flickerstreak@1 1879 -- 'tooltipFunc', level.parentTooltipFunc,
flickerstreak@1 1880 -- 'isTitle', true
flickerstreak@1 1881 -- )
flickerstreak@1 1882 -- end
flickerstreak@1 1883 baseFunc(currentLevel, level.value, levels[level.num - 1] and levels[level.num - 1].value, levels[level.num - 2] and levels[level.num - 2].value, levels[level.num - 3] and levels[level.num - 3].value, levels[level.num - 4] and levels[level.num - 4].value)
flickerstreak@1 1884 end
flickerstreak@1 1885 currentLevel = nil
flickerstreak@1 1886 CheckSize(self, level)
flickerstreak@1 1887 end
flickerstreak@1 1888 end
flickerstreak@1 1889
flickerstreak@1 1890 function Dewdrop:Refresh(level)
flickerstreak@22 1891 self:argCheck(level, 2, "number", "nil")
flickerstreak@22 1892 if not level then
flickerstreak@22 1893 for k,v in pairs(levels) do
flickerstreak@22 1894 Refresh(self, v)
flickerstreak@22 1895 end
flickerstreak@22 1896 else
flickerstreak@22 1897 Refresh(self, levels[level])
flickerstreak@22 1898 end
flickerstreak@1 1899 end
flickerstreak@1 1900
flickerstreak@1 1901 function OpenSlider(self, parent)
flickerstreak@1 1902 if not sliderFrame then
flickerstreak@1 1903 sliderFrame = CreateFrame("Frame", nil, nil)
flickerstreak@22 1904 sliderFrame:SetWidth(100)
flickerstreak@1 1905 sliderFrame:SetHeight(170)
flickerstreak@1 1906 sliderFrame:SetScale(UIParent:GetScale())
flickerstreak@1 1907 sliderFrame:SetBackdrop(tmp(
flickerstreak@1 1908 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
flickerstreak@1 1909 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
flickerstreak@1 1910 'tile', true,
flickerstreak@1 1911 'insets', tmp2(
flickerstreak@1 1912 'left', 5,
flickerstreak@1 1913 'right', 5,
flickerstreak@1 1914 'top', 5,
flickerstreak@1 1915 'bottom', 5
flickerstreak@1 1916 ),
flickerstreak@1 1917 'tileSize', 16,
flickerstreak@1 1918 'edgeSize', 16
flickerstreak@1 1919 ))
flickerstreak@1 1920 sliderFrame:SetFrameStrata("FULLSCREEN_DIALOG")
flickerstreak@1 1921 if sliderFrame.SetTopLevel then
flickerstreak@1 1922 sliderFrame:SetTopLevel(true)
flickerstreak@1 1923 end
flickerstreak@1 1924 sliderFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
flickerstreak@1 1925 sliderFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
flickerstreak@1 1926 sliderFrame:EnableMouse(true)
flickerstreak@22 1927 sliderFrame:EnableMouseWheel(true)
flickerstreak@1 1928 sliderFrame:Hide()
flickerstreak@1 1929 sliderFrame:SetPoint("CENTER", UIParent, "CENTER")
flickerstreak@1 1930 local slider = CreateFrame("Slider", nil, sliderFrame)
flickerstreak@1 1931 sliderFrame.slider = slider
flickerstreak@1 1932 slider:SetOrientation("VERTICAL")
flickerstreak@1 1933 slider:SetMinMaxValues(0, 1)
flickerstreak@22 1934 slider:SetValueStep(0.000000001)
flickerstreak@1 1935 slider:SetValue(0.5)
flickerstreak@1 1936 slider:SetWidth(16)
flickerstreak@1 1937 slider:SetHeight(128)
flickerstreak@1 1938 slider:SetPoint("LEFT", sliderFrame, "LEFT", 15, 0)
flickerstreak@1 1939 slider:SetBackdrop(tmp(
flickerstreak@1 1940 'bgFile', "Interface\\Buttons\\UI-SliderBar-Background",
flickerstreak@1 1941 'edgeFile', "Interface\\Buttons\\UI-SliderBar-Border",
flickerstreak@1 1942 'tile', true,
flickerstreak@1 1943 'edgeSize', 8,
flickerstreak@1 1944 'tileSize', 8,
flickerstreak@1 1945 'insets', tmp2(
flickerstreak@1 1946 'left', 3,
flickerstreak@1 1947 'right', 3,
flickerstreak@1 1948 'top', 3,
flickerstreak@1 1949 'bottom', 3
flickerstreak@1 1950 )
flickerstreak@1 1951 ))
flickerstreak@1 1952 local texture = slider:CreateTexture()
flickerstreak@1 1953 slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Vertical")
flickerstreak@1 1954 local text = slider:CreateFontString(nil, "ARTWORK")
flickerstreak@1 1955 sliderFrame.topText = text
flickerstreak@1 1956 text:SetFontObject(GameFontGreenSmall)
flickerstreak@1 1957 text:SetText("100%")
flickerstreak@1 1958 text:SetPoint("BOTTOM", slider, "TOP")
flickerstreak@1 1959 local text = slider:CreateFontString(nil, "ARTWORK")
flickerstreak@1 1960 sliderFrame.bottomText = text
flickerstreak@1 1961 text:SetFontObject(GameFontGreenSmall)
flickerstreak@1 1962 text:SetText("0%")
flickerstreak@1 1963 text:SetPoint("TOP", slider, "BOTTOM")
flickerstreak@22 1964 local editBox = CreateFrame("EditBox", nil, sliderFrame)
flickerstreak@22 1965 sliderFrame.currentText = editBox
flickerstreak@22 1966 editBox:SetFontObject(ChatFontNormal)
flickerstreak@22 1967 editBox:SetHeight(13)
flickerstreak@22 1968 editBox:SetPoint("RIGHT", sliderFrame, "RIGHT", -16, 0)
flickerstreak@22 1969 editBox:SetPoint("LEFT", slider, "RIGHT", 12, 0)
flickerstreak@22 1970 editBox:SetText("50%")
flickerstreak@22 1971 editBox:SetJustifyH("CENTER")
flickerstreak@22 1972
flickerstreak@22 1973 local width = editBox:GetWidth()/2 + 10
flickerstreak@22 1974 local left = editBox:CreateTexture(nil, "BACKGROUND")
flickerstreak@22 1975 left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
flickerstreak@22 1976 left:SetTexCoord(0, width / 256, 0, 1)
flickerstreak@22 1977 left:SetWidth(width)
flickerstreak@22 1978 left:SetHeight(32)
flickerstreak@22 1979 left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
flickerstreak@22 1980 local right = editBox:CreateTexture(nil, "BACKGROUND")
flickerstreak@22 1981 right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
flickerstreak@22 1982 right:SetTexCoord(1 - width / 256, 1, 0, 1)
flickerstreak@22 1983 right:SetWidth(width)
flickerstreak@22 1984 right:SetHeight(32)
flickerstreak@22 1985 right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
flickerstreak@22 1986
flickerstreak@1 1987 local changed = false
flickerstreak@1 1988 local inside = false
flickerstreak@1 1989 slider:SetScript("OnValueChanged", function()
flickerstreak@1 1990 if sliderFrame.changing then
flickerstreak@1 1991 return
flickerstreak@1 1992 end
flickerstreak@1 1993 changed = true
flickerstreak@1 1994 local done = false
flickerstreak@1 1995 if sliderFrame.parent and sliderFrame.parent.sliderFunc then
flickerstreak@1 1996 local min = sliderFrame.parent.sliderMin or 0
flickerstreak@1 1997 local max = sliderFrame.parent.sliderMax or 1
flickerstreak@22 1998 local step
flickerstreak@22 1999 if sliderFrame.fineStep then
flickerstreak@22 2000 step = sliderFrame.parent.sliderStep or (max - min) / 100
flickerstreak@22 2001 else
flickerstreak@22 2002 step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
flickerstreak@22 2003 end
flickerstreak@1 2004 local value = (1 - slider:GetValue()) * (max - min) + min
flickerstreak@1 2005 if step > 0 then
flickerstreak@1 2006 value = math.floor((value - min) / step + 0.5) * step + min
flickerstreak@1 2007 if value > max then
flickerstreak@1 2008 value = max
flickerstreak@1 2009 elseif value < min then
flickerstreak@1 2010 value = min
flickerstreak@1 2011 end
flickerstreak@1 2012 end
flickerstreak@1 2013 if value == sliderFrame.lastValue then
flickerstreak@1 2014 return
flickerstreak@1 2015 end
flickerstreak@1 2016 sliderFrame.lastValue = value
flickerstreak@22 2017 local text = sliderFrame.parent.sliderFunc(getArgs(sliderFrame.parent, 'sliderArg', 1, value))
flickerstreak@22 2018 if sliderFrame.parent.fromAceOptions then
flickerstreak@22 2019 text = nil
flickerstreak@22 2020 elseif type(text) == "string" or type(text) == "number" then
flickerstreak@1 2021 sliderFrame.currentText:SetText(text)
flickerstreak@1 2022 done = true
flickerstreak@1 2023 end
flickerstreak@1 2024 end
flickerstreak@1 2025 if not done then
flickerstreak@1 2026 local min = sliderFrame.parent.sliderMin or 0
flickerstreak@1 2027 local max = sliderFrame.parent.sliderMax or 1
flickerstreak@22 2028 local step
flickerstreak@22 2029 if sliderFrame.fineStep then
flickerstreak@22 2030 step = sliderFrame.parent.sliderStep or (max - min) / 100
flickerstreak@22 2031 else
flickerstreak@22 2032 step = sliderFrame.parent.sliderBigStep or sliderFrame.parent.sliderStep or (max - min) / 100
flickerstreak@22 2033 end
flickerstreak@1 2034 local value = (1 - slider:GetValue()) * (max - min) + min
flickerstreak@1 2035 if step > 0 then
flickerstreak@1 2036 value = math.floor((value - min) / step + 0.5) * step + min
flickerstreak@1 2037 if value > max then
flickerstreak@1 2038 value = max
flickerstreak@1 2039 elseif value < min then
flickerstreak@1 2040 value = min
flickerstreak@1 2041 end
flickerstreak@1 2042 end
flickerstreak@1 2043 if sliderFrame.parent.sliderIsPercent then
flickerstreak@1 2044 sliderFrame.currentText:SetText(string.format("%.0f%%", value * 100))
flickerstreak@1 2045 else
flickerstreak@1 2046 if step < 0.1 then
flickerstreak@1 2047 sliderFrame.currentText:SetText(string.format("%.2f", value))
flickerstreak@1 2048 elseif step < 1 then
flickerstreak@1 2049 sliderFrame.currentText:SetText(string.format("%.1f", value))
flickerstreak@1 2050 else
flickerstreak@1 2051 sliderFrame.currentText:SetText(string.format("%.0f", value))
flickerstreak@1 2052 end
flickerstreak@1 2053 end
flickerstreak@1 2054 end
flickerstreak@1 2055 end)
flickerstreak@22 2056 local function onEnter()
flickerstreak@1 2057 StopCounting(self, sliderFrame.level)
flickerstreak@1 2058 showGameTooltip(sliderFrame.parent)
flickerstreak@22 2059 end
flickerstreak@22 2060 local function onLeave()
flickerstreak@22 2061 GameTooltip:Hide()
flickerstreak@22 2062 end
flickerstreak@22 2063 sliderFrame:SetScript("OnEnter", onEnter)
flickerstreak@22 2064 sliderFrame:SetScript("OnLeave", function()
flickerstreak@22 2065 GameTooltip:Hide()
flickerstreak@22 2066 if changed then
flickerstreak@22 2067 local parent = sliderFrame.parent
flickerstreak@22 2068 local sliderFunc = parent.sliderFunc
flickerstreak@22 2069 for i = 1, sliderFrame.level - 1 do
flickerstreak@22 2070 Refresh(self, levels[i])
flickerstreak@22 2071 end
flickerstreak@22 2072 local newParent
flickerstreak@22 2073 for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
flickerstreak@22 2074 if button.sliderFunc == sliderFunc then
flickerstreak@22 2075 newParent = button
flickerstreak@22 2076 break
flickerstreak@22 2077 end
flickerstreak@22 2078 end
flickerstreak@22 2079 if newParent then
flickerstreak@22 2080 OpenSlider(self, newParent)
flickerstreak@22 2081 else
flickerstreak@22 2082 sliderFrame:Hide()
flickerstreak@22 2083 end
flickerstreak@22 2084 end
flickerstreak@1 2085 end)
flickerstreak@22 2086 editBox:SetScript("OnEnter", onEnter)
flickerstreak@22 2087 editBox:SetScript("OnLeave", onLeave)
flickerstreak@1 2088 slider:SetScript("OnMouseDown", function()
flickerstreak@1 2089 sliderFrame.mouseDown = true
flickerstreak@1 2090 GameTooltip:Hide()
flickerstreak@1 2091 end)
flickerstreak@1 2092 slider:SetScript("OnMouseUp", function()
flickerstreak@1 2093 sliderFrame.mouseDown = false
flickerstreak@1 2094 if changed--[[ and not inside]] then
flickerstreak@1 2095 local parent = sliderFrame.parent
flickerstreak@1 2096 local sliderFunc = parent.sliderFunc
flickerstreak@1 2097 for i = 1, sliderFrame.level - 1 do
flickerstreak@1 2098 Refresh(self, levels[i])
flickerstreak@1 2099 end
flickerstreak@1 2100 local newParent
flickerstreak@1 2101 for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
flickerstreak@1 2102 if button.sliderFunc == sliderFunc then
flickerstreak@1 2103 newParent = button
flickerstreak@1 2104 break
flickerstreak@1 2105 end
flickerstreak@1 2106 end
flickerstreak@1 2107 if newParent then
flickerstreak@1 2108 OpenSlider(self, newParent)
flickerstreak@1 2109 else
flickerstreak@1 2110 sliderFrame:Hide()
flickerstreak@1 2111 end
flickerstreak@1 2112 end
flickerstreak@1 2113 if inside then
flickerstreak@1 2114 showGameTooltip(sliderFrame.parent)
flickerstreak@1 2115 end
flickerstreak@1 2116 end)
flickerstreak@1 2117 slider:SetScript("OnEnter", function()
flickerstreak@1 2118 inside = true
flickerstreak@1 2119 StopCounting(self, sliderFrame.level)
flickerstreak@1 2120 showGameTooltip(sliderFrame.parent)
flickerstreak@1 2121 end)
flickerstreak@1 2122 slider:SetScript("OnLeave", function()
flickerstreak@1 2123 inside = false
flickerstreak@1 2124 GameTooltip:Hide()
flickerstreak@1 2125 if changed and not sliderFrame.mouseDown then
flickerstreak@1 2126 local parent = sliderFrame.parent
flickerstreak@1 2127 local sliderFunc = parent.sliderFunc
flickerstreak@1 2128 for i = 1, sliderFrame.level - 1 do
flickerstreak@1 2129 Refresh(self, levels[i])
flickerstreak@1 2130 end
flickerstreak@1 2131 local newParent
flickerstreak@1 2132 for _,button in ipairs(levels[sliderFrame.level-1].buttons) do
flickerstreak@1 2133 if button.sliderFunc == sliderFunc then
flickerstreak@1 2134 newParent = button
flickerstreak@1 2135 break
flickerstreak@1 2136 end
flickerstreak@1 2137 end
flickerstreak@1 2138 if newParent then
flickerstreak@1 2139 OpenSlider(self, newParent)
flickerstreak@1 2140 else
flickerstreak@1 2141 sliderFrame:Hide()
flickerstreak@1 2142 end
flickerstreak@22 2143
flickerstreak@22 2144 changed = false
flickerstreak@1 2145 end
flickerstreak@1 2146 end)
flickerstreak@22 2147 sliderFrame:SetScript("OnMouseWheel", function(t, a1)
flickerstreak@22 2148 local arg1 = a1 or arg1
flickerstreak@22 2149 local up = arg1 > 0
flickerstreak@22 2150
flickerstreak@22 2151 local min = sliderFrame.parent.sliderMin or 0
flickerstreak@22 2152 local max = sliderFrame.parent.sliderMax or 1
flickerstreak@22 2153 local step = sliderFrame.parent.sliderStep or (max - min) / 100
flickerstreak@22 2154 if step <= 0 then
flickerstreak@22 2155 step = (max - min) / 100
flickerstreak@22 2156 end
flickerstreak@22 2157
flickerstreak@22 2158 local value = (1 - slider:GetValue()) * (max - min) + min
flickerstreak@22 2159 if up then
flickerstreak@22 2160 value = value + step
flickerstreak@22 2161 else
flickerstreak@22 2162 value = value - step
flickerstreak@22 2163 end
flickerstreak@22 2164 if value > max then
flickerstreak@22 2165 value = max
flickerstreak@22 2166 elseif value < min then
flickerstreak@22 2167 value = min
flickerstreak@22 2168 end
flickerstreak@22 2169 sliderFrame.fineStep = true
flickerstreak@22 2170 if max<=min then
flickerstreak@22 2171 slider:SetValue(0)
flickerstreak@22 2172 else
flickerstreak@22 2173 slider:SetValue(1 - (value - min) / (max - min))
flickerstreak@22 2174 end
flickerstreak@22 2175 sliderFrame.fineStep = nil
flickerstreak@22 2176 end)
flickerstreak@22 2177 slider:SetScript("OnMouseWheel", sliderFrame:GetScript("OnMouseWheel"))
flickerstreak@22 2178 editBox:SetScript("OnEnterPressed", function(t, a1)
flickerstreak@22 2179 local value = editBox:GetNumber()
flickerstreak@22 2180
flickerstreak@22 2181 if sliderFrame.parent.sliderIsPercent then
flickerstreak@22 2182 value = value / 100
flickerstreak@22 2183 end
flickerstreak@22 2184
flickerstreak@22 2185 local min = sliderFrame.parent.sliderMin or 0
flickerstreak@22 2186 local max = sliderFrame.parent.sliderMax or 1
flickerstreak@22 2187
flickerstreak@22 2188 if value > max then
flickerstreak@22 2189 value = max
flickerstreak@22 2190 elseif value < min then
flickerstreak@22 2191 value = min
flickerstreak@22 2192 end
flickerstreak@22 2193 sliderFrame.fineStep = true
flickerstreak@22 2194 if max <= min then
flickerstreak@22 2195 slider:SetValue(0)
flickerstreak@22 2196 else
flickerstreak@22 2197 slider:SetValue(1 - (value - min) / (max - min))
flickerstreak@22 2198 end
flickerstreak@22 2199 sliderFrame.fineStep = nil
flickerstreak@22 2200
flickerstreak@22 2201 StartCounting(self, sliderFrame.level)
flickerstreak@22 2202 end)
flickerstreak@22 2203 editBox:SetScript("OnEscapePressed", function()
flickerstreak@22 2204 self:Close(sliderFrame.level)
flickerstreak@22 2205 StartCounting(self, sliderFrame.level)
flickerstreak@22 2206 end)
flickerstreak@22 2207 editBox:SetAutoFocus(false)
flickerstreak@1 2208 end
flickerstreak@1 2209 sliderFrame.parent = parent
flickerstreak@1 2210 sliderFrame.level = parent.level.num + 1
flickerstreak@1 2211 sliderFrame.parentValue = parent.level.value
flickerstreak@1 2212 sliderFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
flickerstreak@1 2213 sliderFrame.slider:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
flickerstreak@22 2214 sliderFrame.currentText:SetFrameLevel(sliderFrame:GetFrameLevel() + 1)
flickerstreak@22 2215 sliderFrame.currentText:ClearFocus()
flickerstreak@1 2216 sliderFrame.changing = true
flickerstreak@1 2217 if not parent.sliderMin or not parent.sliderMax then
flickerstreak@1 2218 return
flickerstreak@1 2219 end
flickerstreak@1 2220
flickerstreak@1 2221 if parent.arrow then
flickerstreak@1 2222 -- parent.arrow:SetVertexColor(0.2, 0.6, 0)
flickerstreak@1 2223 -- parent.arrow:SetHeight(24)
flickerstreak@1 2224 -- parent.arrow:SetWidth(24)
flickerstreak@1 2225 parent.selected = true
flickerstreak@1 2226 parent.highlight:Show()
flickerstreak@1 2227 end
flickerstreak@1 2228
flickerstreak@1 2229 sliderFrame:SetClampedToScreen(false)
flickerstreak@1 2230 if not parent.sliderValue then
flickerstreak@1 2231 parent.sliderValue = (parent.sliderMin + parent.sliderMax) / 2
flickerstreak@1 2232 end
flickerstreak@22 2233 if parent.sliderMax <= parent.sliderMin then
flickerstreak@22 2234 sliderFrame.slider:SetValue(0)
flickerstreak@22 2235 else
flickerstreak@22 2236 sliderFrame.slider:SetValue(1 - (parent.sliderValue - parent.sliderMin) / (parent.sliderMax - parent.sliderMin))
flickerstreak@22 2237 end
flickerstreak@1 2238 sliderFrame.changing = false
flickerstreak@1 2239 sliderFrame.bottomText:SetText(parent.sliderMinText or "0")
flickerstreak@1 2240 sliderFrame.topText:SetText(parent.sliderMaxText or "1")
flickerstreak@1 2241 local text
flickerstreak@22 2242 if parent.sliderFunc and not parent.fromAceOptions then
flickerstreak@22 2243 text = parent.sliderFunc(getArgs(parent, 'sliderArg', 1, parent.sliderValue))
flickerstreak@1 2244 end
flickerstreak@22 2245 if type(text) == "number" or type(text) == "string" then
flickerstreak@1 2246 sliderFrame.currentText:SetText(text)
flickerstreak@1 2247 elseif parent.sliderIsPercent then
flickerstreak@1 2248 sliderFrame.currentText:SetText(string.format("%.0f%%", parent.sliderValue * 100))
flickerstreak@1 2249 else
flickerstreak@22 2250 if parent.sliderStep < 0.1 then
flickerstreak@22 2251 sliderFrame.currentText:SetText(string.format("%.2f", parent.sliderValue))
flickerstreak@22 2252 elseif parent.sliderStep < 1 then
flickerstreak@22 2253 sliderFrame.currentText:SetText(string.format("%.1f", parent.sliderValue))
flickerstreak@22 2254 else
flickerstreak@22 2255 sliderFrame.currentText:SetText(string.format("%.0f", parent.sliderValue))
flickerstreak@22 2256 end
flickerstreak@1 2257 end
flickerstreak@1 2258
flickerstreak@22 2259
flickerstreak@1 2260 sliderFrame.lastValue = parent.sliderValue
flickerstreak@22 2261
flickerstreak@1 2262 local level = parent.level
flickerstreak@1 2263 sliderFrame:Show()
flickerstreak@1 2264 sliderFrame:ClearAllPoints()
flickerstreak@1 2265 if level.lastDirection == "RIGHT" then
flickerstreak@1 2266 if level.lastVDirection == "DOWN" then
flickerstreak@1 2267 sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
flickerstreak@1 2268 else
flickerstreak@1 2269 sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
flickerstreak@1 2270 end
flickerstreak@1 2271 else
flickerstreak@1 2272 if level.lastVDirection == "DOWN" then
flickerstreak@1 2273 sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
flickerstreak@1 2274 else
flickerstreak@1 2275 sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
flickerstreak@1 2276 end
flickerstreak@1 2277 end
flickerstreak@1 2278 local dirty
flickerstreak@1 2279 if level.lastDirection == "RIGHT" then
flickerstreak@1 2280 if sliderFrame:GetRight() > GetScreenWidth() then
flickerstreak@1 2281 level.lastDirection = "LEFT"
flickerstreak@1 2282 dirty = true
flickerstreak@1 2283 end
flickerstreak@1 2284 elseif sliderFrame:GetLeft() < 0 then
flickerstreak@1 2285 level.lastDirection = "RIGHT"
flickerstreak@1 2286 dirty = true
flickerstreak@1 2287 end
flickerstreak@1 2288 if level.lastVDirection == "DOWN" then
flickerstreak@1 2289 if sliderFrame:GetBottom() < 0 then
flickerstreak@1 2290 level.lastVDirection = "UP"
flickerstreak@1 2291 dirty = true
flickerstreak@1 2292 end
flickerstreak@1 2293 elseif sliderFrame:GetTop() > GetScreenWidth() then
flickerstreak@1 2294 level.lastVDirection = "DOWN"
flickerstreak@1 2295 dirty = true
flickerstreak@1 2296 end
flickerstreak@1 2297 if dirty then
flickerstreak@1 2298 sliderFrame:ClearAllPoints()
flickerstreak@1 2299 if level.lastDirection == "RIGHT" then
flickerstreak@1 2300 if level.lastVDirection == "DOWN" then
flickerstreak@1 2301 sliderFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
flickerstreak@1 2302 else
flickerstreak@1 2303 sliderFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
flickerstreak@1 2304 end
flickerstreak@1 2305 else
flickerstreak@1 2306 if level.lastVDirection == "DOWN" then
flickerstreak@1 2307 sliderFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
flickerstreak@1 2308 else
flickerstreak@1 2309 sliderFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
flickerstreak@1 2310 end
flickerstreak@1 2311 end
flickerstreak@1 2312 end
flickerstreak@1 2313 local left, bottom = sliderFrame:GetLeft(), sliderFrame:GetBottom()
flickerstreak@1 2314 sliderFrame:ClearAllPoints()
flickerstreak@1 2315 sliderFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
flickerstreak@1 2316 if mod(level.num, 5) == 0 then
flickerstreak@1 2317 local left, bottom = level:GetLeft(), level:GetBottom()
flickerstreak@1 2318 level:ClearAllPoints()
flickerstreak@1 2319 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
flickerstreak@1 2320 end
flickerstreak@1 2321 sliderFrame:SetClampedToScreen(true)
flickerstreak@1 2322 end
flickerstreak@1 2323
flickerstreak@1 2324 function OpenEditBox(self, parent)
flickerstreak@1 2325 if not editBoxFrame then
flickerstreak@1 2326 editBoxFrame = CreateFrame("Frame", nil, nil)
flickerstreak@1 2327 editBoxFrame:SetWidth(200)
flickerstreak@1 2328 editBoxFrame:SetHeight(40)
flickerstreak@1 2329 editBoxFrame:SetScale(UIParent:GetScale())
flickerstreak@1 2330 editBoxFrame:SetBackdrop(tmp(
flickerstreak@1 2331 'bgFile', "Interface\\Tooltips\\UI-Tooltip-Background",
flickerstreak@1 2332 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
flickerstreak@1 2333 'tile', true,
flickerstreak@1 2334 'insets', tmp2(
flickerstreak@1 2335 'left', 5,
flickerstreak@1 2336 'right', 5,
flickerstreak@1 2337 'top', 5,
flickerstreak@1 2338 'bottom', 5
flickerstreak@1 2339 ),
flickerstreak@1 2340 'tileSize', 16,
flickerstreak@1 2341 'edgeSize', 16
flickerstreak@1 2342 ))
flickerstreak@1 2343 editBoxFrame:SetFrameStrata("FULLSCREEN_DIALOG")
flickerstreak@1 2344 if editBoxFrame.SetTopLevel then
flickerstreak@1 2345 editBoxFrame:SetTopLevel(true)
flickerstreak@1 2346 end
flickerstreak@1 2347 editBoxFrame:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
flickerstreak@1 2348 editBoxFrame:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
flickerstreak@1 2349 editBoxFrame:EnableMouse(true)
flickerstreak@22 2350 editBoxFrame:EnableMouseWheel(true)
flickerstreak@1 2351 editBoxFrame:Hide()
flickerstreak@1 2352 editBoxFrame:SetPoint("CENTER", UIParent, "CENTER")
flickerstreak@1 2353
flickerstreak@1 2354 local editBox = CreateFrame("EditBox", nil, editBoxFrame)
flickerstreak@1 2355 editBoxFrame.editBox = editBox
flickerstreak@1 2356 editBox:SetFontObject(ChatFontNormal)
flickerstreak@1 2357 editBox:SetWidth(160)
flickerstreak@1 2358 editBox:SetHeight(13)
flickerstreak@1 2359 editBox:SetPoint("CENTER", editBoxFrame, "CENTER", 0, 0)
flickerstreak@1 2360
flickerstreak@1 2361 local left = editBox:CreateTexture(nil, "BACKGROUND")
flickerstreak@1 2362 left:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Left")
flickerstreak@1 2363 left:SetTexCoord(0, 100 / 256, 0, 1)
flickerstreak@1 2364 left:SetWidth(100)
flickerstreak@1 2365 left:SetHeight(32)
flickerstreak@1 2366 left:SetPoint("LEFT", editBox, "LEFT", -10, 0)
flickerstreak@1 2367 local right = editBox:CreateTexture(nil, "BACKGROUND")
flickerstreak@1 2368 right:SetTexture("Interface\\ChatFrame\\UI-ChatInputBorder-Right")
flickerstreak@1 2369 right:SetTexCoord(156/256, 1, 0, 1)
flickerstreak@1 2370 right:SetWidth(100)
flickerstreak@1 2371 right:SetHeight(32)
flickerstreak@1 2372 right:SetPoint("RIGHT", editBox, "RIGHT", 10, 0)
flickerstreak@1 2373
flickerstreak@1 2374 editBox:SetScript("OnEnterPressed", function()
flickerstreak@1 2375 if editBoxFrame.parent and editBoxFrame.parent.editBoxValidateFunc then
flickerstreak@1 2376 local t = editBox.realText or editBox:GetText() or ""
flickerstreak@22 2377 local result = editBoxFrame.parent.editBoxValidateFunc(getArgs(editBoxFrame.parent, 'editBoxValidateArg', 1, t))
flickerstreak@1 2378 if not result then
flickerstreak@1 2379 UIErrorsFrame:AddMessage(VALIDATION_ERROR, 1, 0, 0)
flickerstreak@1 2380 return
flickerstreak@1 2381 end
flickerstreak@1 2382 end
flickerstreak@1 2383 if editBoxFrame.parent and editBoxFrame.parent.editBoxFunc then
flickerstreak@1 2384 local t
flickerstreak@1 2385 if editBox.realText ~= "NONE" then
flickerstreak@1 2386 t = editBox.realText or editBox:GetText() or ""
flickerstreak@1 2387 end
flickerstreak@22 2388 editBoxFrame.parent.editBoxFunc(getArgs(editBoxFrame.parent, 'editBoxArg', 1, t))
flickerstreak@1 2389 end
flickerstreak@1 2390 self:Close(editBoxFrame.level)
flickerstreak@1 2391 for i = 1, editBoxFrame.level - 1 do
flickerstreak@1 2392 Refresh(self, levels[i])
flickerstreak@1 2393 end
flickerstreak@22 2394 StartCounting(self, editBoxFrame.level-1)
flickerstreak@1 2395 end)
flickerstreak@1 2396 editBox:SetScript("OnEscapePressed", function()
flickerstreak@1 2397 self:Close(editBoxFrame.level)
flickerstreak@22 2398 StartCounting(self, editBoxFrame.level-1)
flickerstreak@22 2399 end)
flickerstreak@22 2400 editBox:SetScript("OnReceiveDrag", function(this)
flickerstreak@22 2401 if GetCursorInfo then
flickerstreak@22 2402 local type, alpha, bravo = GetCursorInfo()
flickerstreak@22 2403 local text
flickerstreak@22 2404 if type == "spell" then
flickerstreak@22 2405 text = GetSpellName(alpha, bravo)
flickerstreak@22 2406 elseif type == "item" then
flickerstreak@22 2407 text = bravo
flickerstreak@22 2408 end
flickerstreak@22 2409 if not text then
flickerstreak@22 2410 return
flickerstreak@22 2411 end
flickerstreak@22 2412 ClearCursor()
flickerstreak@22 2413 editBox:SetText(text)
flickerstreak@22 2414 end
flickerstreak@1 2415 end)
flickerstreak@1 2416 local changing = false
flickerstreak@1 2417 local skipNext = false
flickerstreak@1 2418
flickerstreak@1 2419 function editBox:SpecialSetText(text)
flickerstreak@1 2420 local oldText = editBox:GetText() or ""
flickerstreak@1 2421 if not text then
flickerstreak@1 2422 text = ""
flickerstreak@1 2423 end
flickerstreak@1 2424 if text ~= oldText then
flickerstreak@1 2425 changing = true
flickerstreak@22 2426 self:SetText(tostring(text))
flickerstreak@1 2427 changing = false
flickerstreak@1 2428 skipNext = true
flickerstreak@1 2429 end
flickerstreak@1 2430 end
flickerstreak@1 2431
flickerstreak@1 2432 editBox:SetScript("OnTextChanged", function()
flickerstreak@1 2433 if skipNext then
flickerstreak@1 2434 skipNext = false
flickerstreak@1 2435 elseif not changing and editBoxFrame.parent and editBoxFrame.parent.editBoxChangeFunc then
flickerstreak@1 2436 local t
flickerstreak@1 2437 if editBox.realText ~= "NONE" then
flickerstreak@1 2438 t = editBox.realText or editBox:GetText() or ""
flickerstreak@1 2439 end
flickerstreak@22 2440 local text = editBoxFrame.parent.editBoxChangeFunc(getArgs(editBoxFrame.parent, 'editBoxChangeArg', 1, t))
flickerstreak@1 2441 if text then
flickerstreak@1 2442 editBox:SpecialSetText(text)
flickerstreak@1 2443 end
flickerstreak@1 2444 end
flickerstreak@1 2445 end)
flickerstreak@1 2446 editBoxFrame:SetScript("OnEnter", function()
flickerstreak@1 2447 StopCounting(self, editBoxFrame.level)
flickerstreak@1 2448 showGameTooltip(editBoxFrame.parent)
flickerstreak@1 2449 end)
flickerstreak@1 2450 editBoxFrame:SetScript("OnLeave", function()
flickerstreak@1 2451 GameTooltip:Hide()
flickerstreak@1 2452 end)
flickerstreak@1 2453 editBox:SetScript("OnEnter", function()
flickerstreak@1 2454 StopCounting(self, editBoxFrame.level)
flickerstreak@1 2455 showGameTooltip(editBoxFrame.parent)
flickerstreak@1 2456 end)
flickerstreak@1 2457 editBox:SetScript("OnLeave", function()
flickerstreak@1 2458 GameTooltip:Hide()
flickerstreak@1 2459 end)
flickerstreak@22 2460 editBoxFrame:SetScript("OnKeyDown", function(this, a1)
flickerstreak@1 2461 if not editBox.keybinding then
flickerstreak@1 2462 return
flickerstreak@1 2463 end
flickerstreak@22 2464 local arg1 = a1 or arg1
flickerstreak@1 2465 local screenshotKey = GetBindingKey("SCREENSHOT")
flickerstreak@1 2466 if screenshotKey and arg1 == screenshotKey then
flickerstreak@1 2467 Screenshot()
flickerstreak@1 2468 return
flickerstreak@1 2469 end
flickerstreak@22 2470
flickerstreak@1 2471 if arg1 == "LeftButton" then
flickerstreak@1 2472 arg1 = "BUTTON1"
flickerstreak@1 2473 elseif arg1 == "RightButton" then
flickerstreak@1 2474 arg1 = "BUTTON2"
flickerstreak@1 2475 elseif arg1 == "MiddleButton" then
flickerstreak@1 2476 arg1 = "BUTTON3"
flickerstreak@1 2477 elseif arg1 == "Button4" then
flickerstreak@1 2478 arg1 = "BUTTON4"
flickerstreak@1 2479 elseif arg1 == "Button5" then
flickerstreak@1 2480 arg1 = "BUTTON5"
flickerstreak@1 2481 end
flickerstreak@22 2482 if arg1 == "UNKNOWN" then
flickerstreak@1 2483 return
flickerstreak@1 2484 elseif arg1 == "SHIFT" or arg1 == "CTRL" or arg1 == "ALT" then
flickerstreak@1 2485 return
flickerstreak@1 2486 elseif arg1 == "ENTER" then
flickerstreak@22 2487 if editBox.keybindingOnly and not editBox.keybindingOnly[editBox.realText] then
flickerstreak@22 2488 return editBox:GetScript("OnEscapePressed")()
flickerstreak@22 2489 elseif editBox.keybindingExcept and editBox.keybindingExcept[editBox.realText] then
flickerstreak@22 2490 return editBox:GetScript("OnEscapePressed")()
flickerstreak@22 2491 else
flickerstreak@22 2492 return editBox:GetScript("OnEnterPressed")()
flickerstreak@22 2493 end
flickerstreak@1 2494 elseif arg1 == "ESCAPE" then
flickerstreak@1 2495 if editBox.realText == "NONE" then
flickerstreak@1 2496 return editBox:GetScript("OnEscapePressed")()
flickerstreak@1 2497 else
flickerstreak@1 2498 editBox:SpecialSetText(NONE or "NONE")
flickerstreak@1 2499 editBox.realText = "NONE"
flickerstreak@1 2500 return
flickerstreak@1 2501 end
flickerstreak@22 2502 elseif editBox.keybindingOnly and not editBox.keybindingOnly[arg1] then
flickerstreak@22 2503 return
flickerstreak@22 2504 elseif editBox.keybindingExcept and editBox.keybindingExcept[arg1] then
flickerstreak@22 2505 return
flickerstreak@1 2506 end
flickerstreak@1 2507 local s = GetBindingText(arg1, "KEY_")
flickerstreak@22 2508 if s == "BUTTON1" then
flickerstreak@22 2509 s = KEY_BUTTON1
flickerstreak@22 2510 elseif s == "BUTTON2" then
flickerstreak@22 2511 s = KEY_BUTTON2
flickerstreak@22 2512 end
flickerstreak@1 2513 local real = arg1
flickerstreak@1 2514 if IsShiftKeyDown() then
flickerstreak@22 2515 s = "Shift-" .. s
flickerstreak@1 2516 real = "SHIFT-" .. real
flickerstreak@1 2517 end
flickerstreak@1 2518 if IsControlKeyDown() then
flickerstreak@22 2519 s = "Ctrl-" .. s
flickerstreak@1 2520 real = "CTRL-" .. real
flickerstreak@1 2521 end
flickerstreak@1 2522 if IsAltKeyDown() then
flickerstreak@22 2523 s = "Alt-" .. s
flickerstreak@1 2524 real = "ALT-" .. real
flickerstreak@1 2525 end
flickerstreak@1 2526 if editBox:GetText() ~= s then
flickerstreak@22 2527 editBox:SpecialSetText("-")
flickerstreak@1 2528 editBox:SpecialSetText(s)
flickerstreak@1 2529 editBox.realText = real
flickerstreak@1 2530 return editBox:GetScript("OnTextChanged")()
flickerstreak@1 2531 end
flickerstreak@1 2532 end)
flickerstreak@1 2533 editBoxFrame:SetScript("OnMouseDown", editBoxFrame:GetScript("OnKeyDown"))
flickerstreak@22 2534 editBox:SetScript("OnMouseDown", function(this, ...)
flickerstreak@22 2535 if GetCursorInfo and (CursorHasItem() or CursorHasSpell()) then
flickerstreak@22 2536 return editBox:GetScript("OnReceiveDrag")(this, ...)
flickerstreak@22 2537 end
flickerstreak@22 2538 return editBoxFrame:GetScript("OnKeyDown")(this, ...)
flickerstreak@22 2539 end)
flickerstreak@22 2540 editBoxFrame:SetScript("OnMouseWheel", function(t, a1)
flickerstreak@22 2541 local arg1 = a1 or arg1
flickerstreak@22 2542 local up = arg1 > 0
flickerstreak@22 2543 arg1 = up and "MOUSEWHEELUP" or "MOUSEWHEELDOWN"
flickerstreak@22 2544 return editBoxFrame:GetScript("OnKeyDown")(t or this, arg1)
flickerstreak@22 2545 end)
flickerstreak@22 2546 editBox:SetScript("OnMouseWheel", editBoxFrame:GetScript("OnMouseWheel"))
flickerstreak@1 2547 end
flickerstreak@1 2548 editBoxFrame.parent = parent
flickerstreak@1 2549 editBoxFrame.level = parent.level.num + 1
flickerstreak@1 2550 editBoxFrame.parentValue = parent.level.value
flickerstreak@1 2551 editBoxFrame:SetFrameLevel(parent.level:GetFrameLevel() + 3)
flickerstreak@1 2552 editBoxFrame.editBox:SetFrameLevel(editBoxFrame:GetFrameLevel() + 1)
flickerstreak@1 2553 editBoxFrame.editBox.realText = nil
flickerstreak@1 2554 editBoxFrame:SetClampedToScreen(false)
flickerstreak@22 2555
flickerstreak@22 2556 editBoxFrame.editBox:SpecialSetText("")
flickerstreak@1 2557 if parent.editBoxIsKeybinding then
flickerstreak@1 2558 local s = parent.editBoxText
flickerstreak@22 2559 if s == "" then
flickerstreak@22 2560 s = "NONE"
flickerstreak@22 2561 end
flickerstreak@1 2562 editBoxFrame.editBox.realText = s
flickerstreak@22 2563 if s and s ~= "NONE" then
flickerstreak@1 2564 local alpha,bravo = s:match("^(.+)%-(.+)$")
flickerstreak@1 2565 if not bravo then
flickerstreak@1 2566 alpha = nil
flickerstreak@1 2567 bravo = s
flickerstreak@1 2568 end
flickerstreak@1 2569 bravo = GetBindingText(bravo, "KEY_")
flickerstreak@1 2570 if alpha then
flickerstreak@1 2571 editBoxFrame.editBox:SpecialSetText(alpha:upper() .. "-" .. bravo)
flickerstreak@1 2572 else
flickerstreak@1 2573 editBoxFrame.editBox:SpecialSetText(bravo)
flickerstreak@1 2574 end
flickerstreak@1 2575 else
flickerstreak@1 2576 editBoxFrame.editBox:SpecialSetText(NONE or "NONE")
flickerstreak@1 2577 end
flickerstreak@1 2578 else
flickerstreak@1 2579 editBoxFrame.editBox:SpecialSetText(parent.editBoxText)
flickerstreak@1 2580 end
flickerstreak@22 2581
flickerstreak@1 2582 editBoxFrame.editBox.keybinding = parent.editBoxIsKeybinding
flickerstreak@22 2583 editBoxFrame.editBox.keybindingOnly = parent.editBoxKeybindingOnly
flickerstreak@22 2584 editBoxFrame.editBox.keybindingExcept = parent.editBoxKeybindingExcept
flickerstreak@1 2585 editBoxFrame.editBox:EnableKeyboard(not parent.editBoxIsKeybinding)
flickerstreak@1 2586 editBoxFrame:EnableKeyboard(parent.editBoxIsKeybinding)
flickerstreak@1 2587
flickerstreak@1 2588 if parent.arrow then
flickerstreak@1 2589 -- parent.arrow:SetVertexColor(0.2, 0.6, 0)
flickerstreak@1 2590 -- parent.arrow:SetHeight(24)
flickerstreak@1 2591 -- parent.arrow:SetWidth(24)
flickerstreak@1 2592 parent.selected = true
flickerstreak@1 2593 parent.highlight:Show()
flickerstreak@1 2594 end
flickerstreak@1 2595
flickerstreak@1 2596 local level = parent.level
flickerstreak@1 2597 editBoxFrame:Show()
flickerstreak@1 2598 editBoxFrame:ClearAllPoints()
flickerstreak@1 2599 if level.lastDirection == "RIGHT" then
flickerstreak@1 2600 if level.lastVDirection == "DOWN" then
flickerstreak@1 2601 editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
flickerstreak@1 2602 else
flickerstreak@1 2603 editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
flickerstreak@1 2604 end
flickerstreak@1 2605 else
flickerstreak@1 2606 if level.lastVDirection == "DOWN" then
flickerstreak@1 2607 editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
flickerstreak@1 2608 else
flickerstreak@1 2609 editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
flickerstreak@1 2610 end
flickerstreak@1 2611 end
flickerstreak@1 2612 local dirty
flickerstreak@1 2613 if level.lastDirection == "RIGHT" then
flickerstreak@1 2614 if editBoxFrame:GetRight() > GetScreenWidth() then
flickerstreak@1 2615 level.lastDirection = "LEFT"
flickerstreak@1 2616 dirty = true
flickerstreak@1 2617 end
flickerstreak@1 2618 elseif editBoxFrame:GetLeft() < 0 then
flickerstreak@1 2619 level.lastDirection = "RIGHT"
flickerstreak@1 2620 dirty = true
flickerstreak@1 2621 end
flickerstreak@1 2622 if level.lastVDirection == "DOWN" then
flickerstreak@1 2623 if editBoxFrame:GetBottom() < 0 then
flickerstreak@1 2624 level.lastVDirection = "UP"
flickerstreak@1 2625 dirty = true
flickerstreak@1 2626 end
flickerstreak@1 2627 elseif editBoxFrame:GetTop() > GetScreenWidth() then
flickerstreak@1 2628 level.lastVDirection = "DOWN"
flickerstreak@1 2629 dirty = true
flickerstreak@1 2630 end
flickerstreak@1 2631 if dirty then
flickerstreak@1 2632 editBoxFrame:ClearAllPoints()
flickerstreak@1 2633 if level.lastDirection == "RIGHT" then
flickerstreak@1 2634 if level.lastVDirection == "DOWN" then
flickerstreak@1 2635 editBoxFrame:SetPoint("TOPLEFT", parent, "TOPRIGHT", 5, 10)
flickerstreak@1 2636 else
flickerstreak@1 2637 editBoxFrame:SetPoint("BOTTOMLEFT", parent, "BOTTOMRIGHT", 5, -10)
flickerstreak@1 2638 end
flickerstreak@1 2639 else
flickerstreak@1 2640 if level.lastVDirection == "DOWN" then
flickerstreak@1 2641 editBoxFrame:SetPoint("TOPRIGHT", parent, "TOPLEFT", -5, 10)
flickerstreak@1 2642 else
flickerstreak@1 2643 editBoxFrame:SetPoint("BOTTOMRIGHT", parent, "BOTTOMLEFT", -5, -10)
flickerstreak@1 2644 end
flickerstreak@1 2645 end
flickerstreak@1 2646 end
flickerstreak@1 2647 local left, bottom = editBoxFrame:GetLeft(), editBoxFrame:GetBottom()
flickerstreak@1 2648 editBoxFrame:ClearAllPoints()
flickerstreak@1 2649 editBoxFrame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
flickerstreak@1 2650 if mod(level.num, 5) == 0 then
flickerstreak@1 2651 local left, bottom = level:GetLeft(), level:GetBottom()
flickerstreak@1 2652 level:ClearAllPoints()
flickerstreak@1 2653 level:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left, bottom)
flickerstreak@1 2654 end
flickerstreak@1 2655 editBoxFrame:SetClampedToScreen(true)
flickerstreak@1 2656 end
flickerstreak@1 2657
flickerstreak@22 2658 function Dewdrop:EncodeKeybinding(text)
flickerstreak@22 2659 if text == nil or text == "NONE" then
flickerstreak@22 2660 return nil
flickerstreak@22 2661 end
flickerstreak@22 2662 text = tostring(text):upper()
flickerstreak@22 2663 local shift, ctrl, alt
flickerstreak@22 2664 local modifier
flickerstreak@22 2665 while true do
flickerstreak@22 2666 if text == "-" then
flickerstreak@22 2667 break
flickerstreak@22 2668 end
flickerstreak@22 2669 modifier, text = strsplit('-', text, 2)
flickerstreak@22 2670 if text then
flickerstreak@22 2671 if modifier ~= "SHIFT" and modifier ~= "CTRL" and modifier ~= "ALT" then
flickerstreak@22 2672 return false
flickerstreak@22 2673 end
flickerstreak@22 2674 if modifier == "SHIFT" then
flickerstreak@22 2675 if shift then
flickerstreak@22 2676 return false
flickerstreak@22 2677 end
flickerstreak@22 2678 shift = true
flickerstreak@22 2679 end
flickerstreak@22 2680 if modifier == "CTRL" then
flickerstreak@22 2681 if ctrl then
flickerstreak@22 2682 return false
flickerstreak@22 2683 end
flickerstreak@22 2684 ctrl = true
flickerstreak@22 2685 end
flickerstreak@22 2686 if modifier == "ALT" then
flickerstreak@22 2687 if alt then
flickerstreak@22 2688 return false
flickerstreak@22 2689 end
flickerstreak@22 2690 alt = true
flickerstreak@22 2691 end
flickerstreak@22 2692 else
flickerstreak@22 2693 text = modifier
flickerstreak@22 2694 break
flickerstreak@22 2695 end
flickerstreak@22 2696 end
flickerstreak@22 2697 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@22 2698 return false
flickerstreak@22 2699 end
flickerstreak@22 2700 local s = GetBindingText(text, "KEY_")
flickerstreak@22 2701 if s == "BUTTON1" then
flickerstreak@22 2702 s = KEY_BUTTON1
flickerstreak@22 2703 elseif s == "BUTTON2" then
flickerstreak@22 2704 s = KEY_BUTTON2
flickerstreak@22 2705 end
flickerstreak@22 2706 if shift then
flickerstreak@22 2707 s = "Shift-" .. s
flickerstreak@22 2708 end
flickerstreak@22 2709 if ctrl then
flickerstreak@22 2710 s = "Ctrl-" .. s
flickerstreak@22 2711 end
flickerstreak@22 2712 if alt then
flickerstreak@22 2713 s = "Alt-" .. s
flickerstreak@22 2714 end
flickerstreak@22 2715 return s
flickerstreak@22 2716 end
flickerstreak@22 2717
flickerstreak@1 2718 function Dewdrop:IsOpen(parent)
flickerstreak@22 2719 self:argCheck(parent, 2, "table", "string", "nil")
flickerstreak@1 2720 return levels[1] and levels[1]:IsShown() and (not parent or parent == levels[1].parent or parent == levels[1]:GetParent())
flickerstreak@1 2721 end
flickerstreak@1 2722
flickerstreak@1 2723 function Dewdrop:GetOpenedParent()
flickerstreak@1 2724 return (levels[1] and levels[1]:IsShown()) and (levels[1].parent or levels[1]:GetParent())
flickerstreak@1 2725 end
flickerstreak@1 2726
flickerstreak@1 2727 function Open(self, parent, func, level, value, point, relativePoint, cursorX, cursorY)
flickerstreak@1 2728 self:Close(level)
flickerstreak@1 2729 if DewdropLib then
flickerstreak@1 2730 local d = DewdropLib:GetInstance('1.0')
flickerstreak@1 2731 local ret, val = pcall(d, IsOpen, d)
flickerstreak@1 2732 if ret and val then
flickerstreak@1 2733 DewdropLib:GetInstance('1.0'):Close()
flickerstreak@1 2734 end
flickerstreak@1 2735 end
flickerstreak@22 2736 if type(parent) == "table" then
flickerstreak@22 2737 parent:GetCenter()
flickerstreak@22 2738 end
flickerstreak@1 2739 local frame = AcquireLevel(self, level)
flickerstreak@1 2740 if level == 1 then
flickerstreak@1 2741 frame.lastDirection = "RIGHT"
flickerstreak@1 2742 frame.lastVDirection = "DOWN"
flickerstreak@1 2743 else
flickerstreak@1 2744 frame.lastDirection = levels[level - 1].lastDirection
flickerstreak@1 2745 frame.lastVDirection = levels[level - 1].lastVDirection
flickerstreak@1 2746 end
flickerstreak@1 2747 frame:SetFrameStrata("FULLSCREEN_DIALOG")
flickerstreak@1 2748 frame:ClearAllPoints()
flickerstreak@1 2749 frame.parent = parent
flickerstreak@1 2750 frame:SetPoint("LEFT", UIParent, "RIGHT", 10000, 0)
flickerstreak@1 2751 frame:Show()
flickerstreak@1 2752 if level == 1 then
flickerstreak@1 2753 baseFunc = func
flickerstreak@1 2754 end
flickerstreak@1 2755 levels[level].value = value
flickerstreak@1 2756 -- levels[level].parentText = parent.text and parent.text:GetText() or nil
flickerstreak@1 2757 -- levels[level].parentTooltipTitle = parent.tooltipTitle
flickerstreak@1 2758 -- levels[level].parentTooltipText = parent.tooltipText
flickerstreak@1 2759 -- levels[level].parentTooltipFunc = parent.tooltipFunc
flickerstreak@22 2760 if type(parent) == "table" and parent.arrow then
flickerstreak@1 2761 -- parent.arrow:SetVertexColor(0.2, 0.6, 0)
flickerstreak@1 2762 -- parent.arrow:SetHeight(24)
flickerstreak@1 2763 -- parent.arrow:SetWidth(24)
flickerstreak@1 2764 parent.selected = true
flickerstreak@1 2765 parent.highlight:Show()
flickerstreak@1 2766 end
flickerstreak@1 2767 relativePoint = relativePoint or point
flickerstreak@1 2768 Refresh(self, levels[level])
flickerstreak@1 2769 if point or (cursorX and cursorY) then
flickerstreak@1 2770 frame:ClearAllPoints()
flickerstreak@1 2771 if cursorX and cursorY then
flickerstreak@1 2772 local curX, curY = GetScaledCursorPosition()
flickerstreak@1 2773 if curY < GetScreenHeight() / 2 then
flickerstreak@1 2774 point, relativePoint = "BOTTOM", "BOTTOM"
flickerstreak@1 2775 else
flickerstreak@1 2776 point, relativePoint = "TOP", "TOP"
flickerstreak@1 2777 end
flickerstreak@1 2778 if curX < GetScreenWidth() / 2 then
flickerstreak@1 2779 point, relativePoint = point .. "LEFT", relativePoint .. "RIGHT"
flickerstreak@1 2780 else
flickerstreak@1 2781 point, relativePoint = point .. "RIGHT", relativePoint .. "LEFT"
flickerstreak@1 2782 end
flickerstreak@1 2783 end
flickerstreak@22 2784 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint)
flickerstreak@1 2785 if cursorX and cursorY then
flickerstreak@1 2786 local left = frame:GetLeft()
flickerstreak@1 2787 local width = frame:GetWidth()
flickerstreak@1 2788 local bottom = frame:GetBottom()
flickerstreak@1 2789 local height = frame:GetHeight()
flickerstreak@1 2790 local curX, curY = GetScaledCursorPosition()
flickerstreak@1 2791 frame:ClearAllPoints()
flickerstreak@1 2792 relativePoint = relativePoint or point
flickerstreak@1 2793 if point == "BOTTOM" or point == "TOP" then
flickerstreak@1 2794 if curX < GetScreenWidth() / 2 then
flickerstreak@1 2795 point = point .. "LEFT"
flickerstreak@1 2796 else
flickerstreak@1 2797 point = point .. "RIGHT"
flickerstreak@1 2798 end
flickerstreak@1 2799 elseif point == "CENTER" then
flickerstreak@1 2800 if curX < GetScreenWidth() / 2 then
flickerstreak@1 2801 point = "LEFT"
flickerstreak@1 2802 else
flickerstreak@1 2803 point = "RIGHT"
flickerstreak@1 2804 end
flickerstreak@1 2805 end
flickerstreak@1 2806 local xOffset, yOffset = 0, 0
flickerstreak@1 2807 if curY > GetScreenHeight() / 2 then
flickerstreak@1 2808 yOffset = -height
flickerstreak@1 2809 end
flickerstreak@1 2810 if curX > GetScreenWidth() / 2 then
flickerstreak@1 2811 xOffset = -width
flickerstreak@1 2812 end
flickerstreak@22 2813 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left + xOffset, curY - bottom + yOffset)
flickerstreak@1 2814 if level == 1 then
flickerstreak@1 2815 frame.lastDirection = "RIGHT"
flickerstreak@1 2816 end
flickerstreak@1 2817 elseif cursorX then
flickerstreak@1 2818 local left = frame:GetLeft()
flickerstreak@1 2819 local width = frame:GetWidth()
flickerstreak@1 2820 local curX, curY = GetScaledCursorPosition()
flickerstreak@1 2821 frame:ClearAllPoints()
flickerstreak@1 2822 relativePoint = relativePoint or point
flickerstreak@1 2823 if point == "BOTTOM" or point == "TOP" then
flickerstreak@1 2824 if curX < GetScreenWidth() / 2 then
flickerstreak@1 2825 point = point .. "LEFT"
flickerstreak@1 2826 else
flickerstreak@1 2827 point = point .. "RIGHT"
flickerstreak@1 2828 end
flickerstreak@1 2829 elseif point == "CENTER" then
flickerstreak@1 2830 if curX < GetScreenWidth() / 2 then
flickerstreak@1 2831 point = "LEFT"
flickerstreak@1 2832 else
flickerstreak@1 2833 point = "RIGHT"
flickerstreak@1 2834 end
flickerstreak@1 2835 end
flickerstreak@22 2836 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, curX - left - width / 2, 0)
flickerstreak@1 2837 if level == 1 then
flickerstreak@1 2838 frame.lastDirection = "RIGHT"
flickerstreak@1 2839 end
flickerstreak@1 2840 elseif cursorY then
flickerstreak@1 2841 local bottom = frame:GetBottom()
flickerstreak@1 2842 local height = frame:GetHeight()
flickerstreak@1 2843 local curX, curY = GetScaledCursorPosition()
flickerstreak@1 2844 frame:ClearAllPoints()
flickerstreak@1 2845 relativePoint = relativePoint or point
flickerstreak@1 2846 if point == "LEFT" or point == "RIGHT" then
flickerstreak@1 2847 if curX < GetScreenHeight() / 2 then
flickerstreak@1 2848 point = point .. "BOTTOM"
flickerstreak@1 2849 else
flickerstreak@1 2850 point = point .. "TOP"
flickerstreak@1 2851 end
flickerstreak@1 2852 elseif point == "CENTER" then
flickerstreak@1 2853 if curX < GetScreenHeight() / 2 then
flickerstreak@1 2854 point = "BOTTOM"
flickerstreak@1 2855 else
flickerstreak@1 2856 point = "TOP"
flickerstreak@1 2857 end
flickerstreak@1 2858 end
flickerstreak@22 2859 frame:SetPoint(point, type(parent) == "table" and parent or UIParent, relativePoint, 0, curY - bottom - height / 2)
flickerstreak@1 2860 if level == 1 then
flickerstreak@1 2861 frame.lastDirection = "DOWN"
flickerstreak@1 2862 end
flickerstreak@1 2863 end
flickerstreak@1 2864 if (strsub(point, 1, 3) ~= strsub(relativePoint, 1, 3)) then
flickerstreak@1 2865 if frame:GetBottom() < 0 then
flickerstreak@1 2866 local point, parent, relativePoint, x, y = frame:GetPoint(1)
flickerstreak@1 2867 local change = GetScreenHeight() - frame:GetTop()
flickerstreak@1 2868 local otherChange = -frame:GetBottom()
flickerstreak@1 2869 if otherChange < change then
flickerstreak@1 2870 change = otherChange
flickerstreak@1 2871 end
flickerstreak@1 2872 frame:SetPoint(point, parent, relativePoint, x, y + change)
flickerstreak@1 2873 elseif frame:GetTop() > GetScreenHeight() then
flickerstreak@1 2874 local point, parent, relativePoint, x, y = frame:GetPoint(1)
flickerstreak@1 2875 local change = GetScreenHeight() - frame:GetTop()
flickerstreak@1 2876 local otherChange = -frame:GetBottom()
flickerstreak@1 2877 if otherChange < change then
flickerstreak@1 2878 change = otherChange
flickerstreak@1 2879 end
flickerstreak@1 2880 frame:SetPoint(point, parent, relativePoint, x, y + change)
flickerstreak@1 2881 end
flickerstreak@1 2882 end
flickerstreak@1 2883 end
flickerstreak@1 2884 CheckDualMonitor(self, frame)
flickerstreak@1 2885 frame:SetClampedToScreen(true)
flickerstreak@22 2886 frame:SetClampedToScreen(false)
flickerstreak@1 2887 StartCounting(self, level)
flickerstreak@1 2888 end
flickerstreak@1 2889
flickerstreak@1 2890 function Dewdrop:IsRegistered(parent)
flickerstreak@22 2891 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2892 return not not self.registry[parent]
flickerstreak@1 2893 end
flickerstreak@1 2894
flickerstreak@1 2895 function Dewdrop:Register(parent, ...)
flickerstreak@22 2896 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2897 if self.registry[parent] then
flickerstreak@1 2898 self:Unregister(parent)
flickerstreak@1 2899 end
flickerstreak@1 2900 local info = new(...)
flickerstreak@1 2901 if type(info.children) == "table" then
flickerstreak@1 2902 local err, position = validateOptions(info.children)
flickerstreak@22 2903
flickerstreak@1 2904 if err then
flickerstreak@1 2905 if position then
flickerstreak@1 2906 Dewdrop:error(position .. ": " .. err)
flickerstreak@1 2907 else
flickerstreak@1 2908 Dewdrop:error(err)
flickerstreak@1 2909 end
flickerstreak@1 2910 end
flickerstreak@1 2911 end
flickerstreak@1 2912 self.registry[parent] = info
flickerstreak@22 2913 if not info.dontHook and not self.onceRegistered[parent] and type(parent) == "table" then
flickerstreak@1 2914 if parent:HasScript("OnMouseUp") then
flickerstreak@1 2915 local script = parent:GetScript("OnMouseUp")
flickerstreak@22 2916 parent:SetScript("OnMouseUp", function(this, ...)
flickerstreak@1 2917 if script then
flickerstreak@22 2918 script(this, ...)
flickerstreak@1 2919 end
flickerstreak@1 2920 if arg1 == "RightButton" and self.registry[parent] then
flickerstreak@1 2921 if self:IsOpen(parent) then
flickerstreak@1 2922 self:Close()
flickerstreak@1 2923 else
flickerstreak@1 2924 self:Open(parent)
flickerstreak@1 2925 end
flickerstreak@1 2926 end
flickerstreak@1 2927 end)
flickerstreak@1 2928 end
flickerstreak@1 2929 if parent:HasScript("OnMouseDown") then
flickerstreak@1 2930 local script = parent:GetScript("OnMouseDown")
flickerstreak@22 2931 parent:SetScript("OnMouseDown", function(this, ...)
flickerstreak@1 2932 if script then
flickerstreak@22 2933 script(this, ...)
flickerstreak@1 2934 end
flickerstreak@1 2935 if self.registry[parent] then
flickerstreak@1 2936 self:Close()
flickerstreak@1 2937 end
flickerstreak@1 2938 end)
flickerstreak@1 2939 end
flickerstreak@1 2940 end
flickerstreak@1 2941 self.onceRegistered[parent] = true
flickerstreak@1 2942 end
flickerstreak@1 2943
flickerstreak@1 2944 function Dewdrop:Unregister(parent)
flickerstreak@22 2945 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2946 self.registry[parent] = nil
flickerstreak@1 2947 end
flickerstreak@1 2948
flickerstreak@1 2949 function Dewdrop:Open(parent, ...)
flickerstreak@22 2950 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2951 local info
flickerstreak@1 2952 local k1 = ...
flickerstreak@1 2953 if type(k1) == "table" and k1[0] and k1.IsFrameType and self.registry[k1] then
flickerstreak@22 2954 info = tmp(select(2, ...))
flickerstreak@1 2955 for k,v in pairs(self.registry[k1]) do
flickerstreak@22 2956 if info[k] == nil then
flickerstreak@22 2957 info[k] = v
flickerstreak@22 2958 end
flickerstreak@1 2959 end
flickerstreak@1 2960 else
flickerstreak@1 2961 info = tmp(...)
flickerstreak@1 2962 if self.registry[parent] then
flickerstreak@1 2963 for k,v in pairs(self.registry[parent]) do
flickerstreak@1 2964 if info[k] == nil then
flickerstreak@1 2965 info[k] = v
flickerstreak@1 2966 end
flickerstreak@1 2967 end
flickerstreak@1 2968 end
flickerstreak@1 2969 end
flickerstreak@1 2970 local point = info.point
flickerstreak@1 2971 local relativePoint = info.relativePoint
flickerstreak@1 2972 local cursorX = info.cursorX
flickerstreak@1 2973 local cursorY = info.cursorY
flickerstreak@1 2974 if type(point) == "function" then
flickerstreak@1 2975 local b
flickerstreak@1 2976 point, b = point(parent)
flickerstreak@1 2977 if b then
flickerstreak@1 2978 relativePoint = b
flickerstreak@1 2979 end
flickerstreak@1 2980 end
flickerstreak@1 2981 if type(relativePoint) == "function" then
flickerstreak@1 2982 relativePoint = relativePoint(parent)
flickerstreak@1 2983 end
flickerstreak@1 2984 Open(self, parent, info.children, 1, nil, point, relativePoint, cursorX, cursorY)
flickerstreak@1 2985 end
flickerstreak@1 2986
flickerstreak@1 2987 function Clear(self, level)
flickerstreak@1 2988 if level then
flickerstreak@1 2989 if level.buttons then
flickerstreak@1 2990 for i = #level.buttons, 1, -1 do
flickerstreak@1 2991 ReleaseButton(self, level, i)
flickerstreak@1 2992 end
flickerstreak@1 2993 end
flickerstreak@1 2994 end
flickerstreak@1 2995 end
flickerstreak@1 2996
flickerstreak@1 2997 function Dewdrop:Close(level)
flickerstreak@1 2998 if DropDownList1:IsShown() then
flickerstreak@1 2999 DropDownList1:Hide()
flickerstreak@1 3000 end
flickerstreak@1 3001 if DewdropLib then
flickerstreak@1 3002 local d = DewdropLib:GetInstance('1.0')
flickerstreak@1 3003 local ret, val = pcall(d, IsOpen, d)
flickerstreak@1 3004 if ret and val then
flickerstreak@1 3005 DewdropLib:GetInstance('1.0'):Close()
flickerstreak@1 3006 end
flickerstreak@1 3007 end
flickerstreak@1 3008 self:argCheck(level, 2, "number", "nil")
flickerstreak@1 3009 if not level then
flickerstreak@1 3010 level = 1
flickerstreak@1 3011 end
flickerstreak@1 3012 if level == 1 and levels[level] then
flickerstreak@1 3013 levels[level].parented = false
flickerstreak@1 3014 end
flickerstreak@1 3015 if level > 1 and levels[level-1].buttons then
flickerstreak@1 3016 local buttons = levels[level-1].buttons
flickerstreak@1 3017 for _,button in ipairs(buttons) do
flickerstreak@1 3018 -- button.arrow:SetWidth(16)
flickerstreak@1 3019 -- button.arrow:SetHeight(16)
flickerstreak@1 3020 button.selected = nil
flickerstreak@1 3021 button.highlight:Hide()
flickerstreak@1 3022 -- button.arrow:SetVertexColor(1, 1, 1)
flickerstreak@1 3023 end
flickerstreak@1 3024 end
flickerstreak@1 3025 if sliderFrame and sliderFrame.level >= level then
flickerstreak@1 3026 sliderFrame:Hide()
flickerstreak@1 3027 end
flickerstreak@1 3028 if editBoxFrame and editBoxFrame.level >= level then
flickerstreak@1 3029 editBoxFrame:Hide()
flickerstreak@1 3030 end
flickerstreak@1 3031 for i = level, #levels do
flickerstreak@1 3032 Clear(self, levels[level])
flickerstreak@1 3033 levels[i]:Hide()
flickerstreak@1 3034 levels[i]:ClearAllPoints()
flickerstreak@1 3035 levels[i]:SetPoint("CENTER", UIParent, "CENTER")
flickerstreak@1 3036 levels[i].value = nil
flickerstreak@1 3037 end
flickerstreak@1 3038 end
flickerstreak@1 3039
flickerstreak@22 3040 function Dewdrop:AddSeparator(level)
flickerstreak@22 3041 level = levels[level or currentLevel]
flickerstreak@22 3042 if not level or not level.buttons then return; end
flickerstreak@22 3043
flickerstreak@22 3044 local prevbutton = level.buttons[#level.buttons]
flickerstreak@22 3045 if not prevbutton then return; end
flickerstreak@22 3046
flickerstreak@22 3047 if prevbutton.disabled and prevbutton.text:GetText() == "" then
flickerstreak@22 3048 return
flickerstreak@22 3049 end
flickerstreak@22 3050 self:AddLine("text", "", "disabled", true)
flickerstreak@22 3051 end
flickerstreak@22 3052
flickerstreak@1 3053 function Dewdrop:AddLine(...)
flickerstreak@1 3054 local info = tmp(...)
flickerstreak@1 3055 local level = info.level or currentLevel
flickerstreak@1 3056 info.level = nil
flickerstreak@1 3057 local button = AcquireButton(self, level)
flickerstreak@1 3058 if not next(info) then
flickerstreak@1 3059 info.disabled = true
flickerstreak@1 3060 end
flickerstreak@22 3061 button.disabled = info.isTitle or info.notClickable or info.disabled or (self.combat and info.secure)
flickerstreak@1 3062 button.isTitle = info.isTitle
flickerstreak@1 3063 button.notClickable = info.notClickable
flickerstreak@1 3064 if button.isTitle then
flickerstreak@1 3065 button.text:SetFontObject(GameFontNormalSmall)
flickerstreak@1 3066 elseif button.notClickable then
flickerstreak@1 3067 button.text:SetFontObject(GameFontHighlightSmall)
flickerstreak@1 3068 elseif button.disabled then
flickerstreak@1 3069 button.text:SetFontObject(GameFontDisableSmall)
flickerstreak@1 3070 else
flickerstreak@1 3071 button.text:SetFontObject(GameFontHighlightSmall)
flickerstreak@1 3072 end
flickerstreak@1 3073 if info.disabled then
flickerstreak@1 3074 button.arrow:SetDesaturated(true)
flickerstreak@1 3075 button.check:SetDesaturated(true)
flickerstreak@1 3076 else
flickerstreak@1 3077 button.arrow:SetDesaturated(false)
flickerstreak@1 3078 button.check:SetDesaturated(false)
flickerstreak@1 3079 end
flickerstreak@1 3080 if info.textR and info.textG and info.textB then
flickerstreak@1 3081 button.textR = info.textR
flickerstreak@1 3082 button.textG = info.textG
flickerstreak@1 3083 button.textB = info.textB
flickerstreak@1 3084 button.text:SetTextColor(button.textR, button.textG, button.textB)
flickerstreak@1 3085 else
flickerstreak@1 3086 button.text:SetTextColor(button.text:GetFontObject():GetTextColor())
flickerstreak@1 3087 end
flickerstreak@1 3088 button.notCheckable = info.notCheckable
flickerstreak@1 3089 button.text:SetPoint("LEFT", button, "LEFT", button.notCheckable and 0 or 24, 0)
flickerstreak@1 3090 button.checked = not info.notCheckable and info.checked
flickerstreak@22 3091 button.mouseoverUnderline = info.mouseoverUnderline
flickerstreak@1 3092 button.isRadio = not info.notCheckable and info.isRadio
flickerstreak@1 3093 if info.isRadio then
flickerstreak@1 3094 button.check:Show()
flickerstreak@1 3095 button.check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
flickerstreak@1 3096 if button.checked then
flickerstreak@1 3097 button.check:SetTexCoord(0.25, 0.5, 0, 1)
flickerstreak@1 3098 button.check:SetVertexColor(1, 1, 1, 1)
flickerstreak@1 3099 else
flickerstreak@1 3100 button.check:SetTexCoord(0, 0.25, 0, 1)
flickerstreak@1 3101 button.check:SetVertexColor(1, 1, 1, 0.5)
flickerstreak@1 3102 end
flickerstreak@1 3103 button.radioHighlight:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
flickerstreak@1 3104 button.check:SetWidth(16)
flickerstreak@1 3105 button.check:SetHeight(16)
flickerstreak@1 3106 elseif info.icon then
flickerstreak@1 3107 button.check:Show()
flickerstreak@1 3108 button.check:SetTexture(info.icon)
flickerstreak@1 3109 if info.iconWidth and info.iconHeight then
flickerstreak@1 3110 button.check:SetWidth(info.iconWidth)
flickerstreak@1 3111 button.check:SetHeight(info.iconHeight)
flickerstreak@1 3112 else
flickerstreak@1 3113 button.check:SetWidth(16)
flickerstreak@1 3114 button.check:SetHeight(16)
flickerstreak@1 3115 end
flickerstreak@1 3116 if info.iconCoordLeft and info.iconCoordRight and info.iconCoordTop and info.iconCoordBottom then
flickerstreak@1 3117 button.check:SetTexCoord(info.iconCoordLeft, info.iconCoordRight, info.iconCoordTop, info.iconCoordBottom)
flickerstreak@1 3118 elseif info.icon:find("^Interface\\Icons\\") then
flickerstreak@1 3119 button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
flickerstreak@1 3120 else
flickerstreak@1 3121 button.check:SetTexCoord(0, 1, 0, 1)
flickerstreak@1 3122 end
flickerstreak@1 3123 button.check:SetVertexColor(1, 1, 1, 1)
flickerstreak@1 3124 else
flickerstreak@1 3125 if button.checked then
flickerstreak@1 3126 if info.checkIcon then
flickerstreak@1 3127 button.check:SetWidth(16)
flickerstreak@1 3128 button.check:SetHeight(16)
flickerstreak@1 3129 button.check:SetTexture(info.checkIcon)
flickerstreak@1 3130 if info.checkIcon:find("^Interface\\Icons\\") then
flickerstreak@1 3131 button.check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
flickerstreak@1 3132 else
flickerstreak@1 3133 button.check:SetTexCoord(0, 1, 0, 1)
flickerstreak@1 3134 end
flickerstreak@1 3135 else
flickerstreak@1 3136 button.check:SetWidth(24)
flickerstreak@1 3137 button.check:SetHeight(24)
flickerstreak@1 3138 button.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
flickerstreak@1 3139 button.check:SetTexCoord(0, 1, 0, 1)
flickerstreak@1 3140 end
flickerstreak@1 3141 button.check:SetVertexColor(1, 1, 1, 1)
flickerstreak@1 3142 else
flickerstreak@1 3143 button.check:SetVertexColor(1, 1, 1, 0)
flickerstreak@1 3144 end
flickerstreak@1 3145 end
flickerstreak@1 3146 if not button.disabled then
flickerstreak@1 3147 button.func = info.func
flickerstreak@22 3148 button.secure = info.secure
flickerstreak@1 3149 end
flickerstreak@1 3150 button.hasColorSwatch = info.hasColorSwatch
flickerstreak@1 3151 if button.hasColorSwatch then
flickerstreak@1 3152 button.colorSwatch:Show()
flickerstreak@1 3153 button.colorSwatch.texture:Show()
flickerstreak@1 3154 button.r = info.r or 1
flickerstreak@1 3155 button.g = info.g or 1
flickerstreak@1 3156 button.b = info.b or 1
flickerstreak@22 3157 button.colorSwatch.texture:SetVertexColor(button.r, button.g, button.b)
flickerstreak@1 3158 button.checked = false
flickerstreak@1 3159 button.func = nil
flickerstreak@1 3160 button.colorFunc = info.colorFunc
flickerstreak@22 3161 local i = 1
flickerstreak@22 3162 while true do
flickerstreak@22 3163 local k = "colorArg" .. i
flickerstreak@22 3164 local x = info[k]
flickerstreak@22 3165 if x == nil then
flickerstreak@22 3166 break
flickerstreak@22 3167 end
flickerstreak@22 3168 button[k] = x
flickerstreak@22 3169 i = i + 1
flickerstreak@22 3170 end
flickerstreak@1 3171 button.hasOpacity = info.hasOpacity
flickerstreak@1 3172 button.opacity = info.opacity or 1
flickerstreak@1 3173 else
flickerstreak@1 3174 button.colorSwatch:Hide()
flickerstreak@1 3175 button.colorSwatch.texture:Hide()
flickerstreak@1 3176 end
flickerstreak@1 3177 button.hasArrow = not button.hasColorSwatch and (info.value or info.hasSlider or info.hasEditBox) and info.hasArrow
flickerstreak@1 3178 if button.hasArrow then
flickerstreak@1 3179 button.arrow:SetAlpha(1)
flickerstreak@1 3180 if info.hasSlider then
flickerstreak@1 3181 button.hasSlider = true
flickerstreak@1 3182 button.sliderMin = info.sliderMin or 0
flickerstreak@1 3183 button.sliderMax = info.sliderMax or 1
flickerstreak@1 3184 button.sliderStep = info.sliderStep or 0
flickerstreak@22 3185 button.sliderBigStep = info.sliderBigStep or button.sliderStep
flickerstreak@22 3186 if button.sliderBigStep < button.sliderStep then
flickerstreak@22 3187 button.sliderBigStep = button.sliderStep
flickerstreak@22 3188 end
flickerstreak@1 3189 button.sliderIsPercent = info.sliderIsPercent and true or false
flickerstreak@1 3190 button.sliderMinText = info.sliderMinText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMin * 100) or button.sliderMin
flickerstreak@1 3191 button.sliderMaxText = info.sliderMaxText or button.sliderIsPercent and string.format("%.0f%%", button.sliderMax * 100) or button.sliderMax
flickerstreak@1 3192 button.sliderFunc = info.sliderFunc
flickerstreak@1 3193 button.sliderValue = info.sliderValue
flickerstreak@22 3194 button.fromAceOptions = info.fromAceOptions
flickerstreak@22 3195 local i = 1
flickerstreak@22 3196 while true do
flickerstreak@22 3197 local k = "sliderArg" .. i
flickerstreak@22 3198 local x = info[k]
flickerstreak@22 3199 if x == nil then
flickerstreak@22 3200 break
flickerstreak@22 3201 end
flickerstreak@22 3202 button[k] = x
flickerstreak@22 3203 i = i + 1
flickerstreak@22 3204 end
flickerstreak@1 3205 elseif info.hasEditBox then
flickerstreak@1 3206 button.hasEditBox = true
flickerstreak@1 3207 button.editBoxText = info.editBoxText or ""
flickerstreak@1 3208 button.editBoxFunc = info.editBoxFunc
flickerstreak@22 3209 local i = 1
flickerstreak@22 3210 while true do
flickerstreak@22 3211 local k = "editBoxArg" .. i
flickerstreak@22 3212 local x = info[k]
flickerstreak@22 3213 if x == nil then
flickerstreak@22 3214 break
flickerstreak@22 3215 end
flickerstreak@22 3216 button[k] = x
flickerstreak@22 3217 i = i + 1
flickerstreak@22 3218 end
flickerstreak@1 3219 button.editBoxChangeFunc = info.editBoxChangeFunc
flickerstreak@22 3220 local i = 1
flickerstreak@22 3221 while true do
flickerstreak@22 3222 local k = "editBoxChangeArg" .. i
flickerstreak@22 3223 local x = info[k]
flickerstreak@22 3224 if x == nil then
flickerstreak@22 3225 break
flickerstreak@22 3226 end
flickerstreak@22 3227 button[k] = x
flickerstreak@22 3228 i = i + 1
flickerstreak@22 3229 end
flickerstreak@1 3230 button.editBoxValidateFunc = info.editBoxValidateFunc
flickerstreak@22 3231 local i = 1
flickerstreak@22 3232 while true do
flickerstreak@22 3233 local k = "editBoxValidateArg" .. i
flickerstreak@22 3234 local x = info[k]
flickerstreak@22 3235 if x == nil then
flickerstreak@22 3236 break
flickerstreak@22 3237 end
flickerstreak@22 3238 button[k] = x
flickerstreak@22 3239 i = i + 1
flickerstreak@22 3240 end
flickerstreak@1 3241 button.editBoxIsKeybinding = info.editBoxIsKeybinding
flickerstreak@22 3242 button.editBoxKeybindingOnly = info.editBoxKeybindingOnly
flickerstreak@22 3243 button.editBoxKeybindingExcept = info.editBoxKeybindingExcept
flickerstreak@1 3244 else
flickerstreak@1 3245 button.value = info.value
flickerstreak@1 3246 local l = levels[level+1]
flickerstreak@1 3247 if l and info.value == l.value then
flickerstreak@1 3248 -- button.arrow:SetWidth(24)
flickerstreak@1 3249 -- button.arrow:SetHeight(24)
flickerstreak@1 3250 button.selected = true
flickerstreak@1 3251 button.highlight:Show()
flickerstreak@1 3252 end
flickerstreak@1 3253 end
flickerstreak@1 3254 else
flickerstreak@1 3255 button.arrow:SetAlpha(0)
flickerstreak@1 3256 end
flickerstreak@22 3257 local i = 1
flickerstreak@22 3258 while true do
flickerstreak@22 3259 local k = "arg" .. i
flickerstreak@22 3260 local x = info[k]
flickerstreak@22 3261 if x == nil then
flickerstreak@22 3262 break
flickerstreak@22 3263 end
flickerstreak@22 3264 button[k] = x
flickerstreak@22 3265 i = i + 1
flickerstreak@22 3266 end
flickerstreak@1 3267 button.closeWhenClicked = info.closeWhenClicked
flickerstreak@1 3268 button.textHeight = info.textHeight or UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT or 10
flickerstreak@1 3269 local font,_ = button.text:GetFont()
flickerstreak@1 3270 button.text:SetFont(STANDARD_TEXT_FONT or "Fonts\\FRIZQT__.TTF", button.textHeight)
flickerstreak@1 3271 button:SetHeight(button.textHeight + 6)
flickerstreak@1 3272 button.text:SetPoint("RIGHT", button.arrow, (button.hasColorSwatch or button.hasArrow) and "LEFT" or "RIGHT")
flickerstreak@1 3273 button.text:SetJustifyH(info.justifyH or "LEFT")
flickerstreak@1 3274 button.text:SetText(info.text)
flickerstreak@1 3275 button.tooltipTitle = info.tooltipTitle
flickerstreak@1 3276 button.tooltipText = info.tooltipText
flickerstreak@1 3277 button.tooltipFunc = info.tooltipFunc
flickerstreak@22 3278 local i = 1
flickerstreak@22 3279 while true do
flickerstreak@22 3280 local k = "tooltipArg" .. i
flickerstreak@22 3281 local x = info[k]
flickerstreak@22 3282 if x == nil then
flickerstreak@22 3283 break
flickerstreak@22 3284 end
flickerstreak@22 3285 button[k] = x
flickerstreak@22 3286 i = i + 1
flickerstreak@22 3287 end
flickerstreak@1 3288 if not button.tooltipTitle and not button.tooltipText and not button.tooltipFunc and not info.isTitle then
flickerstreak@1 3289 button.tooltipTitle = info.text
flickerstreak@1 3290 end
flickerstreak@1 3291 if type(button.func) == "string" then
flickerstreak@22 3292 if type(button.arg1) ~= "table" then
flickerstreak@22 3293 self:error("Cannot call method %q on a non-table", button.func)
flickerstreak@22 3294 end
flickerstreak@22 3295 if type(button.arg1[button.func]) ~= "function" then
flickerstreak@22 3296 self:error("Method %q nonexistant.", button.func)
flickerstreak@22 3297 end
flickerstreak@1 3298 end
flickerstreak@1 3299 end
flickerstreak@1 3300
flickerstreak@1 3301 function Dewdrop:InjectAceOptionsTable(handler, options)
flickerstreak@1 3302 self:argCheck(handler, 2, "table")
flickerstreak@1 3303 self:argCheck(options, 3, "table")
flickerstreak@1 3304 if tostring(options.type):lower() ~= "group" then
flickerstreak@1 3305 self:error('Cannot inject into options table argument #3 if its type is not "group"')
flickerstreak@1 3306 end
flickerstreak@1 3307 if options.handler ~= nil and options.handler ~= handler then
flickerstreak@1 3308 self:error("Cannot inject into options table argument #3 if it has a different handler than argument #2")
flickerstreak@1 3309 end
flickerstreak@1 3310 options.handler = handler
flickerstreak@1 3311 local class = handler.class
flickerstreak@1 3312 if not AceLibrary:HasInstance("AceOO-2.0") or not class then
flickerstreak@22 3313 if Rock then
flickerstreak@22 3314 -- possible Rock object
flickerstreak@22 3315 for mixin in Rock:IterateObjectMixins(handler) do
flickerstreak@1 3316 if type(mixin.GetAceOptionsDataTable) == "function" then
flickerstreak@1 3317 local t = mixin:GetAceOptionsDataTable(handler)
flickerstreak@1 3318 for k,v in pairs(t) do
flickerstreak@1 3319 if type(options.args) ~= "table" then
flickerstreak@1 3320 options.args = {}
flickerstreak@1 3321 end
flickerstreak@1 3322 if options.args[k] == nil then
flickerstreak@1 3323 options.args[k] = v
flickerstreak@1 3324 end
flickerstreak@1 3325 end
flickerstreak@1 3326 end
flickerstreak@1 3327 end
flickerstreak@1 3328 end
flickerstreak@22 3329 else
flickerstreak@22 3330 -- Ace2 object
flickerstreak@22 3331 while class and class ~= AceLibrary("AceOO-2.0").Class do
flickerstreak@22 3332 if type(class.GetAceOptionsDataTable) == "function" then
flickerstreak@22 3333 local t = class:GetAceOptionsDataTable(handler)
flickerstreak@22 3334 for k,v in pairs(t) do
flickerstreak@22 3335 if type(options.args) ~= "table" then
flickerstreak@22 3336 options.args = {}
flickerstreak@22 3337 end
flickerstreak@22 3338 if options.args[k] == nil then
flickerstreak@22 3339 options.args[k] = v
flickerstreak@22 3340 end
flickerstreak@22 3341 end
flickerstreak@22 3342 end
flickerstreak@22 3343 local mixins = class.mixins
flickerstreak@22 3344 if mixins then
flickerstreak@22 3345 for mixin in pairs(mixins) do
flickerstreak@22 3346 if type(mixin.GetAceOptionsDataTable) == "function" then
flickerstreak@22 3347 local t = mixin:GetAceOptionsDataTable(handler)
flickerstreak@22 3348 for k,v in pairs(t) do
flickerstreak@22 3349 if type(options.args) ~= "table" then
flickerstreak@22 3350 options.args = {}
flickerstreak@22 3351 end
flickerstreak@22 3352 if options.args[k] == nil then
flickerstreak@22 3353 options.args[k] = v
flickerstreak@22 3354 end
flickerstreak@22 3355 end
flickerstreak@22 3356 end
flickerstreak@22 3357 end
flickerstreak@22 3358 end
flickerstreak@22 3359 class = class.super
flickerstreak@22 3360 end
flickerstreak@1 3361 end
flickerstreak@1 3362 return options
flickerstreak@1 3363 end
flickerstreak@1 3364
flickerstreak@22 3365 function Dewdrop:OnTooltipHide()
flickerstreak@22 3366 if lastSetFont then
flickerstreak@22 3367 if lastSetFont == normalFont then
flickerstreak@22 3368 lastSetFont = nil
flickerstreak@22 3369 return
flickerstreak@22 3370 end
flickerstreak@22 3371 fillRegionTmp(GameTooltip:GetRegions())
flickerstreak@22 3372 for i,v in ipairs(regionTmp) do
flickerstreak@22 3373 if v.GetFont then
flickerstreak@22 3374 local font,size,outline = v:GetFont()
flickerstreak@22 3375 if font == lastSetFont then
flickerstreak@22 3376 v:SetFont(normalFont, size, outline)
flickerstreak@22 3377 end
flickerstreak@22 3378 end
flickerstreak@22 3379 regionTmp[i] = nil
flickerstreak@22 3380 end
flickerstreak@22 3381 lastSetFont = nil
flickerstreak@22 3382 end
flickerstreak@22 3383 end
flickerstreak@22 3384
flickerstreak@1 3385 local function activate(self, oldLib, oldDeactivate)
flickerstreak@1 3386 Dewdrop = self
flickerstreak@1 3387 if oldLib and oldLib.registry then
flickerstreak@1 3388 self.registry = oldLib.registry
flickerstreak@1 3389 self.onceRegistered = oldLib.onceRegistered
flickerstreak@1 3390 else
flickerstreak@1 3391 self.registry = {}
flickerstreak@1 3392 self.onceRegistered = {}
flickerstreak@1 3393
flickerstreak@1 3394 local WorldFrame_OnMouseDown = WorldFrame:GetScript("OnMouseDown")
flickerstreak@1 3395 local WorldFrame_OnMouseUp = WorldFrame:GetScript("OnMouseUp")
flickerstreak@1 3396 local oldX, oldY, clickTime
flickerstreak@22 3397 WorldFrame:SetScript("OnMouseDown", function(this, ...)
flickerstreak@1 3398 oldX,oldY = GetCursorPosition()
flickerstreak@1 3399 clickTime = GetTime()
flickerstreak@1 3400 if WorldFrame_OnMouseDown then
flickerstreak@22 3401 WorldFrame_OnMouseDown(this, ...)
flickerstreak@1 3402 end
flickerstreak@1 3403 end)
flickerstreak@1 3404
flickerstreak@22 3405 WorldFrame:SetScript("OnMouseUp", function(this, ...)
flickerstreak@1 3406 local x,y = GetCursorPosition()
flickerstreak@1 3407 if not oldX or not oldY or not x or not y or not clickTime then
flickerstreak@1 3408 self:Close()
flickerstreak@1 3409 if WorldFrame_OnMouseUp then
flickerstreak@22 3410 WorldFrame_OnMouseUp(this, ...)
flickerstreak@1 3411 end
flickerstreak@1 3412 return
flickerstreak@1 3413 end
flickerstreak@1 3414 local d = math.abs(x - oldX) + math.abs(y - oldY)
flickerstreak@1 3415 if d <= 5 and GetTime() - clickTime < 0.5 then
flickerstreak@1 3416 self:Close()
flickerstreak@1 3417 end
flickerstreak@1 3418 if WorldFrame_OnMouseUp then
flickerstreak@22 3419 WorldFrame_OnMouseUp(this, ...)
flickerstreak@1 3420 end
flickerstreak@1 3421 end)
flickerstreak@1 3422
flickerstreak@22 3423 hooksecurefunc(DropDownList1, "Show", function()
flickerstreak@22 3424 if levels[1] and levels[1]:IsVisible() then
flickerstreak@22 3425 self:Close()
flickerstreak@22 3426 end
flickerstreak@22 3427 end)
flickerstreak@22 3428
flickerstreak@22 3429 hooksecurefunc("HideDropDownMenu", function()
flickerstreak@22 3430 if levels[1] and levels[1]:IsVisible() then
flickerstreak@22 3431 self:Close()
flickerstreak@22 3432 end
flickerstreak@22 3433 end)
flickerstreak@22 3434
flickerstreak@22 3435 hooksecurefunc("CloseDropDownMenus", function()
flickerstreak@22 3436 if levels[1] and levels[1]:IsVisible() then
flickerstreak@22 3437 local stack = debugstack()
flickerstreak@22 3438 if not stack:find("`TargetFrame_OnHide'") then
flickerstreak@1 3439 self:Close()
flickerstreak@1 3440 end
flickerstreak@1 3441 end
flickerstreak@22 3442 end)
flickerstreak@22 3443 end
flickerstreak@22 3444 self.frame = oldLib and oldLib.frame or CreateFrame("Frame")
flickerstreak@22 3445 self.frame:UnregisterAllEvents()
flickerstreak@22 3446 self.frame:RegisterEvent("PLAYER_REGEN_ENABLED")
flickerstreak@22 3447 self.frame:RegisterEvent("PLAYER_REGEN_DISABLED")
flickerstreak@22 3448 self.frame:Hide()
flickerstreak@22 3449 self.frame:SetScript("OnEvent", function(this, event)
flickerstreak@22 3450 this:Show()
flickerstreak@22 3451 if event=="PLAYER_REGEN_ENABLED" then -- track combat state for secure frame operations
flickerstreak@22 3452 self.combat = false
flickerstreak@22 3453 elseif event=="PLAYER_REGEN_DISABLED" then
flickerstreak@22 3454 self.combat = true
flickerstreak@1 3455 end
flickerstreak@22 3456 end)
flickerstreak@22 3457 self.frame:SetScript("OnUpdate", function(this)
flickerstreak@22 3458 this:Hide()
flickerstreak@22 3459 self:Refresh(1)
flickerstreak@22 3460 end)
flickerstreak@22 3461 self.hookedTooltip = true
flickerstreak@22 3462 if not oldLib or not oldLib.hookedTooltip then
flickerstreak@22 3463 local OnTooltipHide = GameTooltip:GetScript("OnHide")
flickerstreak@22 3464 GameTooltip:SetScript("OnHide", function(this, ...)
flickerstreak@22 3465 if OnTooltipHide then
flickerstreak@22 3466 OnTooltipHide(this, ...)
flickerstreak@1 3467 end
flickerstreak@22 3468 if type(self.OnTooltipHide) == "function" then
flickerstreak@22 3469 self:OnTooltipHide()
flickerstreak@1 3470 end
flickerstreak@22 3471 end)
flickerstreak@1 3472 end
flickerstreak@1 3473 levels = {}
flickerstreak@1 3474 buttons = {}
flickerstreak@1 3475
flickerstreak@1 3476 if oldDeactivate then
flickerstreak@1 3477 oldDeactivate(oldLib)
flickerstreak@1 3478 end
flickerstreak@1 3479 end
flickerstreak@1 3480
flickerstreak@22 3481 local function external(lib, major, instance)
flickerstreak@22 3482 if major == "SharedMedia-1.0" then
flickerstreak@22 3483 SharedMedia = instance
flickerstreak@22 3484 end
flickerstreak@22 3485 end
flickerstreak@22 3486
flickerstreak@22 3487 AceLibrary:Register(Dewdrop, MAJOR_VERSION, MINOR_VERSION, activate, nil, external)