annotate modules/ReAction_ConfigUI/lib/Dewdrop-2.0/Dewdrop-2.0.lua @ 28:21bcaf8215ff

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