/trunk/Broker_BonusScanner/libs
-- f:AddChild(btn) |
-- @class file |
-- @name AceGUI-3.0 |
-- @release $Id: AceGUI-3.0.lua 803 2009-04-14 12:37:54Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 23 |
-- @release $Id: AceGUI-3.0.lua 815 2009-07-08 20:58:17Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 25 |
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR) |
if not AceGUI then return end -- No upgrade needed |
widget.noAutoHeight = nil |
widget.frame:ClearAllPoints() |
widget.frame:Hide() |
widget.frame:SetParent(nil) |
widget.frame:SetParent(UIParent) |
widget.frame.width = nil |
widget.frame.height = nil |
if widget.content then |
WidgetContainerBase.ReleaseChildren = function(self) |
local children = self.children |
for i in ipairs(children) do |
for i = 1,#children do |
AceGUI:Release(children[i]) |
children[i] = nil |
end |
frame:ClearAllPoints() |
if i == 1 then |
-- anchor the first control to the top left |
--frame:SetPoint("TOPLEFT",content,"TOPLEFT",0,0) |
frame:SetPoint("TOPLEFT",content,"TOPLEFT",0,0) |
rowheight = frameheight |
rowoffset = frameoffset |
rowstart = frame |
--[[ $Id: AceGUIWidget-DropDown.lua 793 2009-04-07 09:26:44Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown.lua 815 2009-07-08 20:58:17Z nevcairiel $ ]]-- |
local min, max, floor = math.min, math.max, math.floor |
local AceGUI = LibStub("AceGUI-3.0") |
AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion) |
end |
do |
do |
local widgetType = "Dropdown" |
local widgetVersion = 19 |
local widgetVersion = 20 |
--[[ Static data ]]-- |
self.pullout:Close() |
end |
AceGUI:Release(self.pullout) |
self.pullout = nil |
self:SetText("") |
self:SetLabel("") |
self:SetMultiselect(false) |
self.value = nil |
self.list = nil |
self.list = nil |
self.open = nil |
self.hasClose = nil |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.frame:Hide() |
end |
-- exported |
local close = AceGUI:Create("Dropdown-Item-Execute") |
close:SetText(CLOSE) |
self.pullout:AddItem(close) |
self.hasClose = true |
self.hasClose = true |
end |
end |
-------------------------- |
do |
local Type = "ColorPicker" |
local Version = 10 |
local Version = 11 |
local function OnAcquire(self) |
self.HasAlpha = false |
local function SetDisabled(self, disabled) |
self.disabled = disabled |
if self.disabled then |
self.frame:Disable() |
self.text:SetTextColor(0.5,0.5,0.5) |
else |
self.frame:Enable() |
self.text:SetTextColor(1,1,1) |
end |
end |
-------------------------- |
do |
local Type = "InteractiveLabel" |
local Version = 3 |
local Version = 5 |
local function OnAcquire(self) |
self:SetHeight(18) |
end |
local function OnRelease(self) |
self:SetDisabled(false) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
end |
end |
local function SetDisabled(self,disabled) |
self.disabled = disabled |
if disabled then |
self.frame:EnableMouse(false) |
self.label:SetTextColor(0.5, 0.5, 0.5) |
else |
self.frame:EnableMouse(true) |
self.label:SetTextColor(1, 1, 1) |
end |
end |
local function OnEnter(this) |
this.obj.highlight:Show() |
this.obj:Fire("OnEnter") |
self.SetFontObject = SetFontObject |
self.SetHighlight = SetHighlight |
self.SetHighlightTexCoord = SetHighlightTexCoord |
self.SetDisabled = SetDisabled |
frame.obj = self |
frame:SetHeight(18) |
do |
local Type = "Keybinding" |
local Version = 12 |
local Version = 13 |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
self.frame:Hide() |
self.waitingForKey = nil |
self.msgframe:Hide() |
self:SetDisabled(false) |
end |
local function SetDisabled(self, disabled) |
]] |
do |
local Type = "CheckBox" |
local Version = 6 |
local Version = 7 |
local function OnAcquire(self) |
self:SetValue(false) |
local function CheckBox_OnEnter(this) |
local self = this.obj |
if not self.disabled then |
self.highlight:Show() |
end |
self.highlight:Show() |
self:Fire("OnEnter") |
end |
local function CheckBox_OnLeave(this) |
local self = this.obj |
if not self.down then |
self.highlight:Hide() |
end |
self.highlight:Hide() |
self:Fire("OnLeave") |
end |
local function SetDisabled(self,disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
self.text:SetTextColor(0.5,0.5,0.5) |
SetDesaturation(self.check, true) |
else |
self.frame:Enable() |
self.text:SetTextColor(1,1,1) |
if self.tristate and self.checked == nil then |
SetDesaturation(self.check, true) |
-------------------------- |
do |
local Type = "Icon" |
local Version = 9 |
local Version = 10 |
local function OnAcquire(self) |
self:SetHeight(110) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
end |
local function SetLabel(self, text) |
end |
end |
local function SetDisabled(self, disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
self.label:SetTextColor(0.5,0.5,0.5) |
self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5) |
else |
self.frame:Enable() |
self.label:SetTextColor(1,1,1) |
self.image:SetVertexColor(1, 1, 1) |
end |
end |
local function OnClick(this, button) |
this.obj:Fire("OnClick", button) |
AceGUI:ClearFocus() |
-- SetText should be deprecated along the way |
self.SetText = SetLabel |
self.SetDisabled = SetDisabled |
frame.obj = self |
]] |
do |
local Type = "Frame" |
local Version = 7 |
local Version = 8 |
local FrameBackdrop = { |
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", |
closebutton:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-27,17) |
closebutton:SetHeight(20) |
closebutton:SetWidth(100) |
closebutton:SetText("Close") |
closebutton:SetText(CLOSE) |
self.closebutton = closebutton |
closebutton.obj = self |
--[[ |
Name: DBIcon-1.0 |
Revision: $Rev: 6 $ |
Revision: $Rev: 10 $ |
Author(s): Rabbit (rabbit.magtheridon@gmail.com) |
Description: Allows addons to register to recieve a lightweight minimap icon as an alternative to more heavy LDB displays. |
Dependencies: LibStub |
]] |
--[[ |
Copyright (C) 2008 Rabbit |
Copyright (C) 2008-2009 Rabbit |
This program is free software; you can redistribute it and/or |
modify it under the terms of the GNU General Public License |
-- |
local DBICON10 = "LibDBIcon-1.0" |
local DBICON10_MINOR = tonumber(("$Rev: 6 $"):match("(%d+)")) |
local DBICON10_MINOR = tonumber(("$Rev: 10 $"):match("(%d+)")) |
if not LibStub then error(DBICON10 .. " requires LibStub.") end |
local ldb = LibStub("LibDataBroker-1.1", true) |
if not ldb then error(DBICON10 .. " requires LibDataBroker-1.1.") end |
local lib = LibStub:NewLibrary(DBICON10, DBICON10_MINOR) |
if not lib then return end |
local ldb = LibStub("LibDataBroker-1.1", true) |
if not ldb then error(DBICON10 .. " requires LibDataBroker-1.1.") end |
lib.objects = lib.objects or {} |
lib.callbackRegistered = lib.callbackRegistered or nil |
lib.notCreated = lib.notCreated or {} |
function lib:IconCallback(event, name, key, value, dataobj) |
if lib.objects[name] then |
lib.callbackRegistered = true |
end |
-- Tooltip code ripped from Fortress |
-- Tooltip code ripped from StatBlockCore by Funkydude |
local function getAnchors(frame) |
local x, y = frame:GetCenter() |
local xFrom, xTo = "", "" |
local yFrom, yTo = "", "" |
if x < GetScreenWidth() / 3 then |
xFrom, xTo = "LEFT", "RIGHT" |
elseif x > GetScreenWidth() / 3 then |
xFrom, xTo = "RIGHT", "LEFT" |
end |
if y < GetScreenHeight() / 3 then |
yFrom, yTo = "BOTTOM", "TOP" |
return "BOTTOM"..xFrom, "TOP"..xTo |
elseif y > GetScreenWidth() / 3 then |
yFrom, yTo = "TOP", "BOTTOM" |
end |
local from = yFrom..xFrom |
local to = yTo..xTo |
return (from == "" and "CENTER" or from), (to == "" and "CENTER" or to) |
local x,y = frame:GetCenter() |
if not x or not y then return "TOPLEFT", "BOTTOMLEFT" end |
local hhalf = (x > UIParent:GetWidth()*2/3) and "RIGHT" or (x < UIParent:GetWidth()/3) and "LEFT" or "" |
local vhalf = (y > UIParent:GetHeight()/2) and "TOP" or "BOTTOM" |
return vhalf..hhalf, frame, (vhalf == "TOP" and "BOTTOM" or "TOP")..hhalf |
end |
local GameTooltip = GameTooltip |
local function GT_OnLeave() |
GameTooltip:SetScript("OnLeave", GameTooltip.oldOnLeave) |
GameTooltip:Hide() |
GameTooltip:EnableMouse(false) |
end |
local function PrepareTooltip(frame, anchorFrame) |
if frame == GameTooltip then |
GameTooltip.oldOnLeave = GameTooltip:GetScript("OnLeave") |
GameTooltip:EnableMouse(true) |
GameTooltip:SetScript("OnLeave", GT_OnLeave) |
end |
frame:SetOwner(anchorFrame, "ANCHOR_NONE") |
frame:ClearAllPoints() |
local from, to = getAnchors(anchorFrame) |
frame:SetPoint(from, anchorFrame, to) |
end |
local function onEnter(self) |
local o = self.dataObject |
if o.tooltip then |
PrepareTooltip(o.tooltip, self) |
if o.tooltiptext then |
o.tooltip:SetText(o.tooltiptext) |
end |
o.tooltip:Show() |
elseif o.OnTooltipShow then |
PrepareTooltip(GameTooltip, self) |
o.OnTooltipShow(GameTooltip) |
if self.isMoving then return end |
local obj = self.dataObject |
if obj.OnTooltipShow then |
GameTooltip:SetOwner(self, "ANCHOR_NONE") |
GameTooltip:SetPoint(getAnchors(self)) |
obj.OnTooltipShow(GameTooltip) |
GameTooltip:Show() |
elseif o.tooltiptext then |
PrepareTooltip(GameTooltip, self) |
GameTooltip:SetText(o.tooltiptext) |
GameTooltip:Show() |
elseif obj.OnEnter then |
obj.OnEnter(self) |
end |
if o.OnEnter then o.OnEnter(self) end |
end |
local function onLeave(self) |
local o = self.dataObject |
if MouseIsOver(GameTooltip) and (o.tooltiptext or o.OnTooltipShow) then return end |
if o.tooltiptext or o.OnTooltipShow then |
GT_OnLeave(GameTooltip) |
end |
if o.OnLeave then o.OnLeave(self) end |
local obj = self.dataObject |
GameTooltip:Hide() |
if obj.OnLeave then obj.OnLeave(self) end |
end |
-------------------------------------------------------------------------------- |
local minimapShapes = { |
} |
local function updatePosition(button) |
local radius = button.db.radius or 80 |
local rounding = button.db.rounding or 10 |
local position = button.db.minimapPos or random(0, 360) |
button.db.minimapPos = position |
button.db.radius = radius |
local angle = math.rad(position) |
local angle = math.rad(button.db.minimapPos or 225) |
local x, y, q = math.cos(angle), math.sin(angle), 1 |
if x < 0 then q = q + 1 end |
if y > 0 then q = q + 2 end |
local minimapShape = GetMinimapShape and GetMinimapShape() or "ROUND" |
local quadTable = minimapShapes[minimapShape] |
if quadTable[q] then |
x, y = x*radius, y*radius |
x, y = x*80, y*80 |
else |
local diagRadius = math.sqrt(2*(radius)^2)-rounding |
x = math.max(-radius, math.min(x*diagRadius, radius)) |
y = math.max(-radius, math.min(y*diagRadius, radius)) |
local diagRadius = 103.13708498985 --math.sqrt(2*(80)^2)-10 |
x = math.max(-80, math.min(x*diagRadius, 80)) |
y = math.max(-80, math.min(y*diagRadius, 80)) |
end |
button:SetPoint("CENTER", Minimap, "CENTER", x, y) |
if not button.db.hide then |
button:Show() |
else |
button:Hide() |
end |
end |
local function onClick(self, b) if self.dataObject.OnClick then self.dataObject.OnClick(self, b) end end |
self:LockHighlight() |
self.icon:SetTexCoord(0, 1, 0, 1) |
self:SetScript("OnUpdate", onUpdate) |
self.isMoving = true |
GameTooltip:Hide() |
end |
self:SetScript("OnUpdate", nil) |
self.icon:SetTexCoord(0.05, 0.95, 0.05, 0.95) |
self:UnlockHighlight() |
self.isMoving = nil |
end |
local function updateAndKill(self, elapsed) |
self.total = self.total + elapsed |
if self.total <= 15 then |
updatePosition(self) |
self:SetScript("OnUpdate", nil) |
end |
end |
function lib:Register(name, object, db) |
if not object.icon then error("Can't register LDB objects without icons set!") end |
if lib.objects[name] then error("Already registered, nubcake.") end |
local function createButton(name, object, db) |
local button = CreateFrame("Button", "LibDBIcon10_"..name, Minimap) |
button.dataObject = object |
button.db = db |
icon:SetPoint("TOPLEFT", 7, -5) |
button.icon = icon |
button.total = 0 |
button:SetScript("OnEnter", onEnter) |
button:SetScript("OnLeave", onLeave) |
button:SetScript("OnClick", onClick) |
button:SetScript("OnDragStop", onDragStop) |
button:SetScript("OnMouseDown", onMouseDown) |
button:SetScript("OnMouseUp", onMouseUp) |
button:SetScript("OnUpdate", updateAndKill) |
lib.objects[name] = button |
updatePosition(button) |
if lib.loggedIn then |
updatePosition(button) |
if not db.hide then button:Show() |
else button:Hide() end |
end |
end |
function lib:Hide(name) lib.objects[name]:Hide() end |
function lib:Show(name) lib.objects[name]:Show() end |
function lib:IsRegistered(name) |
return lib.objects[name] and true or false |
-- We could use a metatable.__index on lib.objects, but then we'd create |
-- the icons when checking things like :IsRegistered, which is not necessary. |
local function check(name) |
if lib.notCreated[name] then |
createButton(name, lib.notCreated[name][1], lib.notCreated[name][2]) |
lib.notCreated[name] = nil |
end |
end |
lib.loggedIn = lib.loggedIn or false |
-- Wait a bit with the initial positioning to let any GetMinimapShape addons |
-- load up. |
if not lib.loggedIn then |
local f = CreateFrame("Frame") |
f:SetScript("OnEvent", function() |
for _, object in pairs(lib.objects) do |
updatePosition(object) |
if not object.db.hide then object:Show() |
else object:Hide() end |
end |
lib.loggedIn = true |
f:SetScript("OnEvent", nil) |
f = nil |
end) |
f:RegisterEvent("PLAYER_LOGIN") |
end |
function lib:Register(name, object, db) |
if not object.icon then error("Can't register LDB objects without icons set!") end |
if lib.objects[name] or lib.notCreated[name] then error("Already registered, nubcake.") end |
if not db or not db.hide then |
createButton(name, object, db) |
else |
lib.notCreated[name] = {object, db} |
end |
end |
function lib:Hide(name) |
check(name) |
lib.objects[name]:Hide() |
end |
function lib:Show(name) |
check(name) |
lib.objects[name]:Show() |
updatePosition(lib.objects[name]) |
end |
function lib:IsRegistered(name) |
return (lib.objects[name] or lib.notCreated[name]) and true or false |
end |
function lib:Refresh(name, db) |
check(name) |
local button = lib.objects[name] |
if db then button.db = db end |
updatePosition(button) |
end |