/trunk
## Interface: 50100 |
## Interface: 50200 |
## Title: Urban Achiever |
## Author: Syzgyn, Tomate |
## Notes: Improved Achievement Frame |
## Notes-frFR: Fenêtre de Hauts Faits améliorée |
## Notes-zhTW:æ¹é²æå°±æ¡æ¶ |
## Notes-zhCN:æ¹è¿æå°±æ¡æ¶ |
## Version 15.3.wowi:revision |
## Version 15.4.wowi:revision |
## OptionalDeps: Blizzard_AchievementUI |
## SavedVariables: UASV |
## SavedVariablesPerCharacter: UASVPC |
} |
foreach($completearray as $k => $v){ |
echo '["' . $k . '"] = ' . $v . '<br />'; |
$double = ''; |
if($k < 1000){ |
$double = " "; |
} |
echo '["' . $k . '"]'.$double.' = ' . $v . '<br />'; |
} |
?> |
--bindings |
BINDING_HEADER_URBANACHIEVER = "Urban Achiever" |
local MAX_ACHIEVEMENTS = 8032 --last 8031 |
local MAX_ACHIEVEMENTS = 8261 --last 8260 |
local menuTypes = {"PLAYER", "PARTY", "RAID_PLAYER"} |
local playerFaction = UnitFactionGroup("player") == "Alliance" and 1 or 2 |
--Horde = 2 |
UrbanAchiever.factionAchs = { |
["5318"] = 1, --20,000 Leagues Under the Sea |
["7988"] = 1, --A Little Patience |
["8030"] = 1, --A Test of Valor |
["4156"] = 1, --A Tribute to Immortality |
["5853"] = 1, --A-Caroling We Will Go |
["5171"] = 1, --Blood Elf Slayer |
["4926"] = 1, --Bloodmyst Isle Quests |
["7941"] = 1, --Brawlin' and Shot Callin' |
["7989"] = 1, --Bubbletrapped! |
["7990"] = 1, --Cannonballer |
["7534"] = 1, --Chapter II: Wrathion's War |
["5195"] = 1, --City Attacker |
["5131"] = 1, --Classic Battles |
["5126"] = 1, --Dungeon Diplomat |
["4929"] = 1, --Dustwallow Marsh Quests |
["6007"] = 1, --Extinguishing Northrend |
["8042"] = 1, --Extinguishing Pandaria |
["6013"] = 1, --Extinguishing the Cataclysm |
["4873"] = 1, --Fading into Twilight |
["4932"] = 1, --Feralas Quests |
["5476"] = 1, --Fish or Cut Bait: Stormwind |
["6011"] = 1, --Flame Warden of Cataclysm |
["6008"] = 1, --Flame Warden of Northrend |
["8045"] = 1, --Flame Warden of Pandaria |
["5453"] = 1, --Ghosts in the Dark |
["5172"] = 1, --Goblin Slayer |
["5343"] = 1, --Grand Marshal |
["5014"] = 1, --Guild Northrend Dungeon Hero |
["6942"] = 1, --Hero of the Alliance |
["6939"] = 1, --Hero of the Alliance: Cataclysmic |
["8243"] = 1, --Hero of the Alliance: Malevolent |
["6316"] = 1, --Hero of the Alliance: Ruthless |
["5344"] = 1, --Hero of the Alliance: Vicious |
["4298"] = 1, --Heroic: Trial of the Champion |
["5111"] = 1, --Heroic: Trial of the Champion Guild Run |
["5031"] = 1, --Horde Slayer |
["7992"] = 1, --I Used To Love Them |
["5219"] = 1, --I'm in the White Lodge |
["5327"] = 1, --In Service of the Alliance |
["5268"] = 1, --In Service of the Alliance |
["5322"] = 1, --In Service of the Alliance |
["5718"] = 1, --Just Another Day in Tol Barad |
["8052"] = 1, --Khan |
["5320"] = 1, --King of the Mountain |
["8208"] = 1, --Kirin Tor Offensive |
["7526"] = 1, --Kite Fight |
["5335"] = 1, --Knight |
["5337"] = 1, --Knight-Captain |
["7946"] = 1, --Now You're Just Showing Off |
["8011"] = 1, --Number Five Is Alive |
["4786"] = 1, --Operation: Gnomeregan |
["7928"] = 1, --Operation: Shieldwall |
["8205"] = 1, --Operation: Shieldwall |
["7928"] = 1, --Operation: Shieldwall Campaign |
["5167"] = 1, --Orc Slayer |
["6828"] = 1, --Pandaren Ambassador |
["6644"] = 1, --Pandaren Embassy |
["5168"] = 1, --Tauren Slayer |
["7947"] = 1, --The First Rule of Brawler's Guild |
["7940"] = 1, --The Second Rule of Brawler's Guild |
["7523"] = 1, --Theramore's Fall |
["7467"] = 1, --Theramore's Fall |
["7523"] = 1, --Theramore's Fall |
["5417"] = 1, --Tol Barad Veteran |
["4296"] = 1, --Trial of the Champion |
["5836"] = 1, --Tricks and Treats of Northrend |
["7601"] = 1, --Tricks and Treat of Pandaria |
["7601"] = 1, --Tricks and Treats of Pandaria |
["5837"] = 1, --Tricks and Treats of the Cataclysm |
["5170"] = 1, --Troll Slayer |
["8218"] = 1, --Tyrannical Conquest |
["5169"] = 1, --Undead Slayer |
["5812"] = 1, --United Nations |
["6300"] = 1, --Upjade Complete |
["5329"] = 1, --Warbound Veteran of the Alliance |
["8012"] = 1, --Waste Not, Want Not |
["7860"] = 1, --We're Going to Need More Saddles |
["7993"] = 1, --We've Been Dancin' |
["4903"] = 1, --Westfall and Duskwood Quests |
["7991"] = 1, --Which Came First? |
["4885"] = 1, --Wildhammer Clan |
["5481"] = 1, --Wildhammer Tour of Duty |
["7937"] = 1, --You Are Not Your $#*@! Legplates |
["5162"] = 2, --Classy Trolls |
["5164"] = 2, --Classy Undead |
["5227"] = 2, --Cloud Nine |
["8009"] = 2, --Dagger in the Dark |
["4256"] = 2, --Demolition Derby |
["7843"] = 2, --Diplomacy |
["7929"] = 2, --Dominance Offensive |
["8206"] = 2, --Dominance Offensive |
["7929"] = 2, --Dominance Offensive Campaign |
["8013"] = 2, --Domination Point |
["5552"] = 2, --Double Jeopardy |
["5177"] = 2, --Draenei Slayer |
["4978"] = 2, --Dustwallow Marsh Quests |
["5175"] = 2, --Dwarf Slayer |
["6010"] = 2, --Extinguishing Northrend |
["8043"] = 2, --Extinguishing Pandaria |
["6014"] = 2, --Extinguishing the Cataclysm |
["5501"] = 2, --Fading into Twilight |
["4979"] = 2, --Feralas Quests |
["5850"] = 2, --Fish or Cut Bait: Undercity |
["6012"] = 2, --Flame Keeper of Cataclysm |
["6009"] = 2, --Flame Keeper of Northrend |
["8044"] = 2, --Flame Keeper of Pandaria |
["5355"] = 2, --General |
["4908"] = 2, --Ghostlands Quests |
["5176"] = 2, --Gnome Slayer |
["5376"] = 2, --Hellscream's Reach |
["6941"] = 2, --Hero of the Horde |
["6940"] = 2, --Hero of the Horde: Cataclysmic |
["8244"] = 2, --Hero of the Horde: Malevolent |
["6317"] = 2, --Hero of the Horde: Ruthless |
["5358"] = 2, --Hero of the Horde: Vicious |
["4297"] = 2, --Heroic: Trial of the Champion |
["4895"] = 2, --Hillsbrad Foothills Quests |
["5173"] = 2, --Human Slayer |
["5220"] = 2, --I'm in the Black Lodge |
["5323"] = 2, --In Service of the Horde |
["5269"] = 2, --In Service of the Horde |
["5323"] = 2, --In Service of the Horde |
["5324"] = 2, --In Service of the Horde |
["5454"] = 2, --Joy Ride |
["5719"] = 2, --Just Another Day in Tol Barad |
["8055"] = 2, --Khan |
["5321"] = 2, --King of the Mountain |
["7529"] = 2, --Kite Fight |
["5352"] = 2, --Legionnaire |
["6536"] = 2, --Mighty Roamin' Krasaranger |
["4177"] = 2, --Mine |
["5174"] = 2, --Night Elf Slayer |
["7987"] = 2, --No Egg Left Behind |
["7530"] = 2, --No Tank You |
["4933"] = 2, --Northern Barrens Quests |
["8022"] = 2, --Now You're Just Showing Off |
["5158"] = 2, --Stay Classy |
["5350"] = 2, --Stone Guard |
["4980"] = 2, --Stonetalon Mountains Quests |
["8209"] = 2, --Sunreaver Onslaught |
["6031"] = 2, --Taking the Show on the Road |
["6602"] = 2, --Taming Kalimdor |
["7948"] = 2, --The First Rule of Brawler's Guild |
["7939"] = 2, --The Second Rule of Brawler's Guild |
["7524"] = 2, --Theramore's Fall |
["7468"] = 2, --Theramore's Fall |
["7524"] = 2, --Theramore's Fall |
["5418"] = 2, --Tol Barad Veteran |
["5835"] = 2, --Tricks and Treats of Northrend |
["7602"] = 2, --Tricks and Treat of Pandaria |
["7602"] = 2, --Tricks and Treats of Pandaria |
["5838"] = 2, --Tricks and Treats of the Cataclysm |
["8093"] = 2, --Tyrannical Conquest |
["5892"] = 2, --United Nations |
["6534"] = 2, --Upjade Complete |
["5325"] = 2, --Veteran of the Horde |
["5326"] = 2, --Warbringer of the Horde |
["5342"] = 2, --Warlord |
["8015"] = 2, --Waste Not, Want Not |
["7984"] = 2, --Watery Grave |
["7862"] = 2, --We're Going to Need More Saddles |
["5228"] = 2, --Wild Hammering |
["5178"] = 2, --Worgen Slayer |
["8020"] = 2, --You Are Not Your $#*@! Legplates |
["7986"] = 2, --You Mean That Wasn't a Void Zone? |
["4790"] = 2, --Zalazane's Fall |
["762"] = 2, --Ambassador of the Horde |
["1175"] = 2, --Battlemaster |
--[[ $Id: CallbackHandler-1.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ ]] |
local MAJOR, MINOR = "CallbackHandler-1.0", 5 |
--[[ $Id: CallbackHandler-1.0.lua 965 2010-08-09 00:47:52Z mikk $ ]] |
local MAJOR, MINOR = "CallbackHandler-1.0", 6 |
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) |
if not CallbackHandler then return end -- No upgrade needed |
regfunc = function(...) self[method](self,...) end |
end |
else |
-- function ref with self=object or self="addonId" |
if type(self)~="table" and type(self)~="string" then |
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2) |
-- function ref with self=object or self="addonId" or self=thread |
if type(self)~="table" and type(self)~="string" and type(self)~="thread" then |
error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2) |
end |
if select("#",...)>=1 then -- this is not the same as testing for arg==nil! |
-- make into AceHook. |
-- @class file |
-- @name AceHook-3.0 |
-- @release $Id: AceHook-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
local ACEHOOK_MAJOR, ACEHOOK_MINOR = "AceHook-3.0", 5 |
-- @release $Id: AceHook-3.0.lua 1064 2012-09-04 17:14:01Z nevcairiel $ |
local ACEHOOK_MAJOR, ACEHOOK_MINOR = "AceHook-3.0", 6 |
local AceHook, oldminor = LibStub:NewLibrary(ACEHOOK_MAJOR, ACEHOOK_MINOR) |
if not AceHook then return end -- No upgrade needed |
error(format("%s: 'handler' - Handler specified does not exist at self[handler]", usage), 3) |
end |
if script then |
if not secure and obj:IsProtected() and protectedScripts[method] then |
error(format("Cannot hook secure script %q; Use SecureHookScript(obj, method, [handler]) instead.", method), 3) |
end |
if not obj or not obj.GetScript or not obj:HasScript(method) then |
error(format("%s: You can only hook a script on a frame object", usage), 3) |
end |
if not secure and obj:IsProtected() and protectedScripts[method] then |
error(format("Cannot hook secure script %q; Use SecureHookScript(obj, method, [handler]) instead.", method), 3) |
end |
else |
local issecure |
if obj then |
-- make into AceEvent. |
-- @class file |
-- @name AceEvent-3.0 |
-- @release $Id: AceEvent-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
-- @release $Id: AceEvent-3.0.lua 975 2010-10-23 11:26:18Z nevcairiel $ |
local MAJOR, MINOR = "AceEvent-3.0", 3 |
local AceEvent = LibStub:NewLibrary(MAJOR, MINOR) |
} |
--- Register for a Blizzard Event. |
-- The callback will always be called with the event as the first argument, and if supplied, the `arg` as second argument. |
-- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied) |
-- Any arguments to the event will be passed on after that. |
-- @name AceEvent:RegisterEvent |
-- @class function |
-- @param event The event to unregister |
--- Register for a custom AceEvent-internal message. |
-- The callback will always be called with the event as the first argument, and if supplied, the `arg` as second argument. |
-- The callback will be called with the optional `arg` as the first argument (if supplied), and the event name as the second (or first, if no arg was supplied) |
-- Any arguments to the event will be passed on after that. |
-- @name AceEvent:RegisterMessage |
-- @class function |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
Checkbox Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "CheckBox", 22 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local select = select |
local select, pairs = select, pairs |
-- WoW APIs |
local PlaySound = PlaySound |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: SetDesaturation, GameFontHighlight |
-------------------------- |
-- Check Box -- |
-------------------------- |
--[[ |
Events : |
OnValueChanged |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
local function AlignImage(self) |
local img = self.image:GetTexture() |
self.text:ClearAllPoints() |
if not img then |
self.text:SetPoint("LEFT", self.checkbg, "RIGHT") |
self.text:SetPoint("RIGHT") |
else |
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0) |
self.text:SetPoint("RIGHT") |
end |
end |
]] |
do |
local Type = "CheckBox" |
local Version = 16 |
local function OnAcquire(self) |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
local function CheckBox_OnMouseDown(frame) |
local self = frame.obj |
if not self.disabled then |
if self.image:GetTexture() then |
self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1) |
else |
self.text:SetPoint("LEFT", self.checkbg, "RIGHT", 1, -1) |
end |
end |
AceGUI:ClearFocus() |
end |
local function CheckBox_OnMouseUp(frame) |
local self = frame.obj |
if not self.disabled then |
self:ToggleChecked() |
if self.checked then |
PlaySound("igMainMenuOptionCheckBoxOn") |
else -- for both nil and false (tristate) |
PlaySound("igMainMenuOptionCheckBoxOff") |
end |
self:Fire("OnValueChanged", self.checked) |
AlignImage(self) |
end |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self:SetType() |
self:SetValue(false) |
self.tristate = nil |
self:SetHeight(24) |
self:SetTriState(nil) |
-- height is calculated from the width and required space for the description |
self:SetWidth(200) |
self:SetImage() |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.check:Hide() |
self.highlight:Hide() |
self.down = nil |
self.checked = nil |
self:SetType() |
self:SetDisabled(false) |
self:SetDisabled(nil) |
self:SetDescription(nil) |
end |
local function CheckBox_OnEnter(this) |
local self = this.obj |
self.highlight:Show() |
self:Fire("OnEnter") |
end |
local function CheckBox_OnLeave(this) |
local self = this.obj |
self.highlight:Hide() |
self:Fire("OnLeave") |
end |
local function CheckBox_OnMouseUp(this) |
local self = this.obj |
if not self.disabled then |
self:ToggleChecked() |
if self.checked then |
PlaySound("igMainMenuOptionCheckBoxOn") |
else -- for both nil and false (tristate) |
PlaySound("igMainMenuOptionCheckBoxOff") |
end, |
-- ["OnRelease"] = nil, |
["OnWidthSet"] = function(self, width) |
if self.desc then |
self.desc:SetWidth(width - 30) |
if self.desc:GetText() and self.desc:GetText() ~= "" then |
self:SetHeight(28 + self.desc:GetHeight()) |
end |
self:Fire("OnValueChanged",self.checked) |
self.text:SetPoint("LEFT",self.check,"RIGHT",0,0) |
end |
self.down = nil |
end |
local function CheckBox_OnMouseDown(this) |
local self = this.obj |
if not self.disabled then |
self.text:SetPoint("LEFT",self.check,"RIGHT",1,-1) |
self.down = true |
end |
AceGUI:ClearFocus() |
end |
end, |
local function SetDisabled(self,disabled) |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
self.text:SetTextColor(0.5,0.5,0.5) |
self.text:SetTextColor(0.5, 0.5, 0.5) |
SetDesaturation(self.check, true) |
if self.desc then |
self.desc:SetTextColor(0.5, 0.5, 0.5) |
end |
else |
self.frame:Enable() |
self.text:SetTextColor(1,1,1) |
self.text:SetTextColor(1, 1, 1) |
if self.tristate and self.checked == nil then |
SetDesaturation(self.check, true) |
else |
SetDesaturation(self.check, false) |
end |
if self.desc then |
self.desc:SetTextColor(1, 1, 1) |
end |
end |
end |
local function SetValue(self,value) |
end, |
["SetValue"] = function(self,value) |
local check = self.check |
self.checked = value |
if value then |
self.check:Hide() |
end |
end |
SetDisabled(self, self.disabled) |
end |
local function SetTriState(self, enabled) |
self:SetDisabled(self.disabled) |
end, |
["GetValue"] = function(self) |
return self.checked |
end, |
["SetTriState"] = function(self, enabled) |
self.tristate = enabled |
self:SetValue(self:GetValue()) |
end |
local function GetValue(self) |
return self.checked |
end |
local function SetType(self, type) |
end, |
["SetType"] = function(self, type) |
local checkbg = self.checkbg |
local check = self.check |
local highlight = self.highlight |
local size |
if type == "radio" then |
checkbg:SetHeight(16) |
checkbg:SetWidth(16) |
size = 16 |
checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton") |
checkbg:SetTexCoord(0,0.25,0,1) |
check:SetHeight(16) |
check:SetWidth(16) |
checkbg:SetTexCoord(0, 0.25, 0, 1) |
check:SetTexture("Interface\\Buttons\\UI-RadioButton") |
check:SetTexCoord(0.25,0.5,0,1) |
check:SetTexCoord(0.25, 0.5, 0, 1) |
check:SetBlendMode("ADD") |
highlight:SetTexture("Interface\\Buttons\\UI-RadioButton") |
highlight:SetTexCoord(0.5,0.75,0,1) |
highlight:SetTexCoord(0.5, 0.75, 0, 1) |
else |
checkbg:SetHeight(24) |
checkbg:SetWidth(24) |
size = 24 |
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up") |
checkbg:SetTexCoord(0,1,0,1) |
check:SetHeight(24) |
check:SetWidth(24) |
checkbg:SetTexCoord(0, 1, 0, 1) |
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") |
check:SetTexCoord(0,1,0,1) |
check:SetTexCoord(0, 1, 0, 1) |
check:SetBlendMode("BLEND") |
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight") |
highlight:SetTexCoord(0,1,0,1) |
highlight:SetTexCoord(0, 1, 0, 1) |
end |
end |
local function ToggleChecked(self) |
checkbg:SetHeight(size) |
checkbg:SetWidth(size) |
end, |
["ToggleChecked"] = function(self) |
local value = self:GetValue() |
if self.tristate then |
--cycle in true, nil, false order |
else |
self:SetValue(not self:GetValue()) |
end |
end |
local function SetLabel(self, label) |
end, |
["SetLabel"] = function(self, label) |
self.text:SetText(label) |
end |
local function SetDescription(self, desc) |
end, |
["SetDescription"] = function(self, desc) |
if desc then |
if not self.desc then |
local desc = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") |
desc:ClearAllPoints() |
desc:SetPoint("TOPLEFT", self.check, "TOPRIGHT", 5, -21) |
desc:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21) |
desc:SetWidth(self.frame.width - 30) |
desc:SetJustifyH("LEFT") |
desc:SetJustifyV("TOP") |
self.desc:SetText("") |
self.desc:Hide() |
end |
self.text:SetFontObject(GameFontHighlight) |
--self.text:SetFontObject(GameFontHighlight) |
self:SetHeight(24) |
end |
end |
end, |
local function SetImage(self, path, ...) |
["SetImage"] = function(self, path, ...) |
local image = self.image |
image:SetTexture(path) |
if image:GetTexture() then |
local n = select('#', ...) |
local n = select("#", ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
else |
image:SetTexCoord(0, 1, 0, 1) |
end |
end |
self:AlignImage() |
AlignImage(self) |
end |
local function AlignImage(self) |
local img = self.image:GetTexture() |
self.text:ClearAllPoints() |
if not img then |
self.text:SetPoint("LEFT", self.check, "RIGHT", 0, 0) |
self.text:SetPoint("RIGHT", self.frame, "RIGHT", 0, 0) |
else |
self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0) |
self.text:SetPoint("RIGHT", self.frame,"RIGHT", 0, 0) |
end |
end |
local function OnWidthSet(self, width) |
if self.desc and self.desc:GetText() ~= "" and self.desc:GetText() ~= nil then |
self.desc:SetWidth(width - 30) |
self:SetHeight(28 + self.desc:GetHeight()) |
end |
end |
local function Constructor() |
local frame = CreateFrame("Button",nil,UIParent) |
local self = {} |
self.type = Type |
} |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local frame = CreateFrame("Button", nil, UIParent) |
frame:Hide() |
self.SetValue = SetValue |
self.GetValue = GetValue |
self.SetDisabled = SetDisabled |
self.SetType = SetType |
self.ToggleChecked = ToggleChecked |
self.SetLabel = SetLabel |
self.SetTriState = SetTriState |
self.SetDescription = SetDescription |
self.OnWidthSet = OnWidthSet |
self.SetImage = SetImage |
self.AlignImage = AlignImage |
self.frame = frame |
frame.obj = self |
local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") |
self.text = text |
frame:SetScript("OnEnter",CheckBox_OnEnter) |
frame:SetScript("OnLeave",CheckBox_OnLeave) |
frame:SetScript("OnMouseUp",CheckBox_OnMouseUp) |
frame:SetScript("OnMouseDown",CheckBox_OnMouseDown) |
frame:EnableMouse() |
local checkbg = frame:CreateTexture(nil,"ARTWORK") |
self.checkbg = checkbg |
checkbg:SetWidth(24) |
checkbg:SetHeight(24) |
checkbg:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up") |
local check = frame:CreateTexture(nil,"OVERLAY") |
self.check = check |
check:SetWidth(24) |
check:SetHeight(24) |
check:SetPoint("CENTER",checkbg,"CENTER",0,0) |
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") |
local highlight = frame:CreateTexture(nil, "OVERLAY") |
self.highlight = highlight |
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight") |
highlight:SetBlendMode("ADD") |
highlight:SetAllPoints(checkbg) |
highlight:Hide() |
local image = frame:CreateTexture(nil, "OVERLAY") |
self.image = image |
image:SetHeight(16) |
image:SetWidth(16) |
image:SetPoint("LEFT", check, "RIGHT", 1, 0) |
text:SetJustifyH("LEFT") |
frame:SetHeight(24) |
frame:SetWidth(200) |
text:SetHeight(18) |
text:SetPoint("LEFT",check,"RIGHT",0,0) |
text:SetPoint("RIGHT",frame,"RIGHT",0,0) |
AceGUI:RegisterAsWidget(self) |
return self |
frame:EnableMouse(true) |
frame:SetScript("OnEnter", Control_OnEnter) |
frame:SetScript("OnLeave", Control_OnLeave) |
frame:SetScript("OnMouseDown", CheckBox_OnMouseDown) |
frame:SetScript("OnMouseUp", CheckBox_OnMouseUp) |
local checkbg = frame:CreateTexture(nil, "ARTWORK") |
checkbg:SetWidth(24) |
checkbg:SetHeight(24) |
checkbg:SetPoint("TOPLEFT") |
checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up") |
local check = frame:CreateTexture(nil, "OVERLAY") |
check:SetAllPoints(checkbg) |
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") |
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") |
text:SetJustifyH("LEFT") |
text:SetHeight(18) |
text:SetPoint("LEFT", checkbg, "RIGHT") |
text:SetPoint("RIGHT") |
local highlight = frame:CreateTexture(nil, "HIGHLIGHT") |
highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight") |
highlight:SetBlendMode("ADD") |
highlight:SetAllPoints(checkbg) |
local image = frame:CreateTexture(nil, "OVERLAY") |
image:SetHeight(16) |
image:SetWidth(16) |
image:SetPoint("LEFT", checkbg, "RIGHT", 1, 0) |
local widget = { |
checkbg = checkbg, |
check = check, |
text = text, |
highlight = highlight, |
image = image, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
Icon Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "Icon", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local select = select |
local select, pairs, print = select, pairs, print |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
local CreateFrame, UIParent, GetBuildInfo = CreateFrame, UIParent, GetBuildInfo |
-------------------------- |
-- Label -- |
-------------------------- |
do |
local Type = "Icon" |
local Version = 12 |
local function OnAcquire(self) |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
local function Button_OnClick(frame, button) |
frame.obj:Fire("OnClick", button) |
AceGUI:ClearFocus() |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self:SetHeight(110) |
self:SetWidth(110) |
self:SetLabel("") |
self:SetLabel() |
self:SetImage(nil) |
self:SetImageSize(64, 64) |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
end |
local function SetLabel(self, text) |
end, |
-- ["OnRelease"] = nil, |
["SetLabel"] = function(self, text) |
if text and text ~= "" then |
self.label:Show() |
self.label:SetText(text) |
self.label:Hide() |
self:SetHeight(self.image:GetHeight() + 10) |
end |
end |
local function SetImage(self, path, ...) |
end, |
["SetImage"] = function(self, path, ...) |
local image = self.image |
image:SetTexture(path) |
if image:GetTexture() then |
self.imageshown = true |
local n = select('#', ...) |
local n = select("#", ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
else |
image:SetTexCoord(0, 1, 0, 1) |
end |
else |
self.imageshown = nil |
end |
end |
local function SetImageSize(self, width, height) |
end, |
["SetImageSize"] = function(self, width, height) |
self.image:SetWidth(width) |
self.image:SetHeight(height) |
--self.frame:SetWidth(width + 30) |
else |
self:SetHeight(height + 10) |
end |
end |
local function SetDisabled(self, disabled) |
end, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
self.label:SetTextColor(0.5,0.5,0.5) |
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) |
self.label:SetTextColor(1, 1, 1) |
self.image:SetVertexColor(1, 1, 1, 1) |
end |
end |
local function OnClick(this, button) |
this.obj:Fire("OnClick", button) |
AceGUI:ClearFocus() |
end |
local function OnEnter(this) |
this.obj.highlight:Show() |
this.obj:Fire("OnEnter") |
end |
local function OnLeave(this) |
this.obj.highlight:Hide() |
this.obj:Fire("OnLeave") |
end |
} |
local function Constructor() |
local frame = CreateFrame("Button",nil,UIParent) |
local self = {} |
self.type = Type |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetLabel = SetLabel |
self.frame = frame |
self.SetImage = SetImage |
self.SetImageSize = SetImageSize |
-- SetText should be deprecated along the way |
self.SetText = SetLabel |
self.SetDisabled = SetDisabled |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local frame = CreateFrame("Button", nil, UIParent) |
frame:Hide() |
frame.obj = self |
frame:SetHeight(110) |
frame:SetWidth(110) |
frame:EnableMouse(true) |
frame:SetScript("OnClick", OnClick) |
frame:SetScript("OnLeave", OnLeave) |
frame:SetScript("OnEnter", OnEnter) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight") |
label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) |
label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
label:SetJustifyH("CENTER") |
label:SetJustifyV("TOP") |
label:SetHeight(18) |
self.label = label |
local image = frame:CreateTexture(nil,"BACKGROUND") |
self.image = image |
image:SetWidth(64) |
image:SetHeight(64) |
image:SetPoint("TOP",frame,"TOP",0,-5) |
local highlight = frame:CreateTexture(nil,"OVERLAY") |
self.highlight = highlight |
highlight:SetAllPoints(image) |
highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight") |
highlight:SetTexCoord(0,1,0.23,0.77) |
highlight:SetBlendMode("ADD") |
highlight:Hide() |
AceGUI:RegisterAsWidget(self) |
return self |
frame:EnableMouse(true) |
frame:SetScript("OnEnter", Control_OnEnter) |
frame:SetScript("OnLeave", Control_OnLeave) |
frame:SetScript("OnClick", Button_OnClick) |
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight") |
label:SetPoint("BOTTOMLEFT") |
label:SetPoint("BOTTOMRIGHT") |
label:SetJustifyH("CENTER") |
label:SetJustifyV("TOP") |
label:SetHeight(18) |
local image = frame:CreateTexture(nil, "BACKGROUND") |
image:SetWidth(64) |
image:SetHeight(64) |
image:SetPoint("TOP", 0, -5) |
local highlight = frame:CreateTexture(nil, "HIGHLIGHT") |
highlight:SetAllPoints(image) |
highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight") |
highlight:SetTexCoord(0, 1, 0.23, 0.77) |
highlight:SetBlendMode("ADD") |
local widget = { |
label = label, |
image = image, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
-- SetText is deprecated, but keep it around for a while. (say, to WoW 4.0) |
if (select(4, GetBuildInfo()) < 40000) then |
widget.SetText = widget.SetLabel |
else |
widget.SetText = function(self, ...) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(...) end |
end |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
--[[ $Id: AceGUIWidget-DropDown.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown.lua 1029 2011-06-10 23:10:58Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
-- Lua APIs |
local min, max, floor = math.min, math.max, math.floor |
local select, pairs, ipairs = select, pairs, ipairs |
local select, pairs, ipairs, type = select, pairs, ipairs, type |
local tsort = table.sort |
-- WoW APIs |
do |
local widgetType = "Dropdown" |
local widgetVersion = 22 |
local widgetVersion = 25 |
--[[ Static data ]]-- |
self:SetHeight(44) |
self:SetWidth(200) |
self:SetLabel() |
end |
-- exported, AceGUI callback |
self.pullout = nil |
self:SetText("") |
self:SetLabel("") |
self:SetDisabled(false) |
self:SetMultiselect(false) |
self.label:SetText(text) |
self.label:Show() |
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,-18) |
self.frame:SetHeight(44) |
self:SetHeight(44) |
self.alignoffset = 30 |
else |
self.label:SetText("") |
self.label:Hide() |
self.dropdown:SetPoint("TOPLEFT",self.frame,"TOPLEFT",-15,0) |
self.frame:SetHeight(26) |
self:SetHeight(26) |
self.alignoffset = 12 |
end |
end |
end |
end |
local function AddListItem(self, value, text) |
local item = AceGUI:Create("Dropdown-Item-Toggle") |
local function AddListItem(self, value, text, itemType) |
if not itemType then itemType = "Dropdown-Item-Toggle" end |
local exists = AceGUI:GetWidgetVersion(itemType) |
if not exists then error(("The given item type, %q, does not exist within AceGUI-3.0"):format(tostring(itemType)), 2) end |
local item = AceGUI:Create(itemType) |
item:SetText(text) |
item.userdata.obj = self |
item.userdata.value = value |
-- exported |
local sortlist = {} |
local function SetList(self, list) |
local function SetList(self, list, order, itemType) |
self.list = list |
self.pullout:Clear() |
self.hasClose = nil |
if not list then return end |
for v in pairs(list) do |
sortlist[#sortlist + 1] = v |
if type(order) ~= "table" then |
for v in pairs(list) do |
sortlist[#sortlist + 1] = v |
end |
tsort(sortlist) |
for i, key in ipairs(sortlist) do |
AddListItem(self, key, list[key], itemType) |
sortlist[i] = nil |
end |
else |
for i, key in ipairs(order) do |
AddListItem(self, key, list[key], itemType) |
end |
end |
tsort(sortlist) |
for i, value in pairs(sortlist) do |
AddListItem(self, value, list[value]) |
sortlist[i] = nil |
end |
if self.multiselect then |
ShowMultiText(self) |
AddCloseButton(self) |
end |
-- exported |
local function AddItem(self, value, text) |
local function AddItem(self, value, text, itemType) |
if self.list then |
self.list[value] = text |
AddListItem(self, value, text) |
AddListItem(self, value, text, itemType) |
end |
end |
self.SetItemValue = SetItemValue |
self.SetItemDisabled = SetItemDisabled |
self.alignoffset = 31 |
self.alignoffset = 30 |
frame:SetHeight(44) |
frame:SetWidth(200) |
frame:SetScript("OnHide",Dropdown_OnHide) |
dropdown:ClearAllPoints() |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
EditBox Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "EditBox", 24 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local tostring = tostring |
local tostring, pairs = tostring, pairs |
-- WoW APIs |
local PlaySound = PlaySound |
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName |
local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo |
local CreateFrame, UIParent = CreateFrame, UIParent |
local _G = _G |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY |
local Type = "EditBox" |
local Version = 14 |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
if not AceGUIEditBoxInsertLink then |
-- upgradeable hook |
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end) |
end |
function _G.AceGUIEditBoxInsertLink(text) |
for i = 1, AceGUI:GetNextWidgetNum(Type)-1 do |
for i = 1, AceGUI:GetWidgetCount(Type) do |
local editbox = _G["AceGUI-3.0EditBox"..i] |
if editbox and editbox:IsVisible() and editbox:HasFocus() then |
editbox:Insert(text) |
end |
end |
local function ShowButton(self) |
if not self.disablebutton then |
self.button:Show() |
self.editbox:SetTextInsets(0, 20, 3, 3) |
end |
end |
-------------------------- |
-- Edit box -- |
-------------------------- |
--[[ |
Events : |
OnTextChanged |
OnEnterPressed |
local function HideButton(self) |
self.button:Hide() |
self.editbox:SetTextInsets(0, 0, 3, 3) |
end |
]] |
do |
local function OnAcquire(self) |
self:SetHeight(26) |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
local function Frame_OnShowFocus(frame) |
frame.obj.editbox:SetFocus() |
frame:SetScript("OnShow", nil) |
end |
local function EditBox_OnEscapePressed(frame) |
AceGUI:ClearFocus() |
end |
local function EditBox_OnEnterPressed(frame) |
local self = frame.obj |
local value = frame:GetText() |
local cancel = self:Fire("OnEnterPressed", value) |
if not cancel then |
PlaySound("igMainMenuOptionCheckBoxOn") |
HideButton(self) |
end |
end |
local function EditBox_OnReceiveDrag(frame) |
local self = frame.obj |
local type, id, info = GetCursorInfo() |
if type == "item" then |
self:SetText(info) |
self:Fire("OnEnterPressed", info) |
ClearCursor() |
elseif type == "spell" then |
local name = GetSpellInfo(id, info) |
self:SetText(name) |
self:Fire("OnEnterPressed", name) |
ClearCursor() |
end |
HideButton(self) |
AceGUI:ClearFocus() |
end |
local function EditBox_OnTextChanged(frame) |
local self = frame.obj |
local value = frame:GetText() |
if tostring(value) ~= tostring(self.lasttext) then |
self:Fire("OnTextChanged", value) |
self.lasttext = value |
ShowButton(self) |
end |
end |
local function EditBox_OnFocusGained(frame) |
AceGUI:SetFocus(frame.obj) |
end |
local function Button_OnClick(frame) |
local editbox = frame.obj.editbox |
editbox:ClearFocus() |
EditBox_OnEnterPressed(editbox) |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
-- height is controlled by SetLabel |
self:SetWidth(200) |
self:SetDisabled(false) |
self:SetLabel() |
self.showbutton = true |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
self:SetText() |
end |
local function Control_OnEnter(this) |
this.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function EditBox_OnEscapePressed(this) |
this:ClearFocus() |
end |
local function ShowButton(self) |
if self.showbutton then |
self.button:Show() |
self.editbox:SetTextInsets(0,20,3,3) |
end |
end |
local function HideButton(self) |
self.button:Hide() |
self.editbox:SetTextInsets(0,0,3,3) |
end |
local function EditBox_OnEnterPressed(this) |
local self = this.obj |
local value = this:GetText() |
local cancel = self:Fire("OnEnterPressed",value) |
if not cancel then |
PlaySound("igMainMenuOptionCheckBoxOn") |
HideButton(self) |
end |
end |
local function Button_OnClick(this) |
local editbox = this.obj.editbox |
editbox:ClearFocus() |
EditBox_OnEnterPressed(editbox) |
end |
local function EditBox_OnReceiveDrag(this) |
local self = this.obj |
local type, id, info = GetCursorInfo() |
if type == "item" then |
self:SetText(info) |
self:Fire("OnEnterPressed",info) |
ClearCursor() |
elseif type == "spell" then |
local name, rank = GetSpellName(id, info) |
if rank and rank:match("%d") then |
name = name.."("..rank..")" |
end |
self:SetText(name) |
self:Fire("OnEnterPressed",name) |
ClearCursor() |
end |
HideButton(self) |
AceGUI:ClearFocus() |
end |
local function EditBox_OnTextChanged(this) |
local self = this.obj |
local value = this:GetText() |
if tostring(value) ~= tostring(self.lasttext) then |
self:Fire("OnTextChanged",value) |
self.lasttext = value |
ShowButton(self) |
end |
end |
local function SetDisabled(self, disabled) |
self:DisableButton(false) |
self:SetMaxLetters(0) |
end, |
["OnRelease"] = function(self) |
self:ClearFocus() |
end, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
if disabled then |
self.editbox:EnableMouse(false) |
self.editbox:SetTextColor(1,1,1) |
self.label:SetTextColor(1,.82,0) |
end |
end |
local function SetText(self, text) |
end, |
["SetText"] = function(self, text) |
self.lasttext = text or "" |
self.editbox:SetText(text or "") |
self.editbox:SetCursorPosition(0) |
HideButton(self) |
end |
local function SetLabel(self, text) |
end, |
["GetText"] = function(self, text) |
return self.editbox:GetText() |
end, |
["SetLabel"] = function(self, text) |
if text and text ~= "" then |
self.label:SetText(text) |
self.label:Show() |
self:SetHeight(26) |
self.alignoffset = 12 |
end |
end, |
["DisableButton"] = function(self, disabled) |
self.disablebutton = disabled |
if disabled then |
HideButton(self) |
end |
end, |
["SetMaxLetters"] = function (self, num) |
self.editbox:SetMaxLetters(num or 0) |
end, |
["ClearFocus"] = function(self) |
self.editbox:ClearFocus() |
self.frame:SetScript("OnShow", nil) |
end, |
["SetFocus"] = function(self) |
self.editbox:SetFocus() |
if not self.frame:IsShown() then |
self.frame:SetScript("OnShow", Frame_OnShowFocus) |
end |
end |
} |
local function Constructor() |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame",nil,UIParent) |
local editbox = CreateFrame("EditBox","AceGUI-3.0EditBox"..num,frame,"InputBoxTemplate") |
local self = {} |
self.type = Type |
self.num = num |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:Hide() |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate") |
editbox:SetAutoFocus(false) |
editbox:SetFontObject(ChatFontNormal) |
editbox:SetScript("OnEnter", Control_OnEnter) |
editbox:SetScript("OnLeave", Control_OnLeave) |
editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed) |
editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed) |
editbox:SetScript("OnTextChanged", EditBox_OnTextChanged) |
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) |
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) |
editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained) |
editbox:SetTextInsets(0, 0, 3, 3) |
editbox:SetMaxLetters(256) |
editbox:SetPoint("BOTTOMLEFT", 6, 0) |
editbox:SetPoint("BOTTOMRIGHT") |
editbox:SetHeight(19) |
self.SetDisabled = SetDisabled |
self.SetText = SetText |
self.SetLabel = SetLabel |
self.frame = frame |
frame.obj = self |
self.editbox = editbox |
editbox.obj = self |
self.alignoffset = 30 |
frame:SetHeight(44) |
frame:SetWidth(200) |
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") |
label:SetPoint("TOPLEFT", 0, -2) |
label:SetPoint("TOPRIGHT", 0, -2) |
label:SetJustifyH("LEFT") |
label:SetHeight(18) |
editbox:SetScript("OnEnter",Control_OnEnter) |
editbox:SetScript("OnLeave",Control_OnLeave) |
editbox:SetAutoFocus(false) |
editbox:SetFontObject(ChatFontNormal) |
editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed) |
editbox:SetScript("OnEnterPressed",EditBox_OnEnterPressed) |
editbox:SetScript("OnTextChanged",EditBox_OnTextChanged) |
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) |
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) |
local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate") |
button:SetWidth(40) |
button:SetHeight(20) |
button:SetPoint("RIGHT", -2, 0) |
button:SetText(OKAY) |
button:SetScript("OnClick", Button_OnClick) |
button:Hide() |
editbox:SetTextInsets(0,0,3,3) |
editbox:SetMaxLetters(256) |
editbox:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",6,0) |
editbox:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
editbox:SetHeight(19) |
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2) |
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-2) |
label:SetJustifyH("LEFT") |
label:SetHeight(18) |
self.label = label |
local button = CreateFrame("Button",nil,editbox,"UIPanelButtonTemplate") |
button:SetWidth(40) |
button:SetHeight(20) |
button:SetPoint("RIGHT",editbox,"RIGHT",-2,0) |
button:SetText(OKAY) |
button:SetScript("OnClick", Button_OnClick) |
button:Hide() |
self.button = button |
button.obj = self |
local widget = { |
alignoffset = 30, |
editbox = editbox, |
label = label, |
button = button, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
editbox.obj, button.obj = widget, widget |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
Heading Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "Heading", 20 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local pairs = pairs |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
-------------------------- |
-- Heading -- |
-------------------------- |
do |
local Type = "Heading" |
local Version = 5 |
local function OnAcquire(self) |
self:SetText("") |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self:SetText() |
self:SetFullWidth() |
self:SetHeight(18) |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local function SetText(self, text) |
end, |
-- ["OnRelease"] = nil, |
["SetText"] = function(self, text) |
self.label:SetText(text or "") |
if (text or "") == "" then |
self.left:SetPoint("RIGHT",self.frame,"RIGHT",-3,0) |
if text and text ~= "" then |
self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0) |
self.right:Show() |
else |
self.left:SetPoint("RIGHT", -3, 0) |
self.right:Hide() |
else |
self.left:SetPoint("RIGHT",self.label,"LEFT",-5,0) |
self.right:Show() |
end |
end |
} |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = Type |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.frame = frame |
frame.obj = self |
frame:SetHeight(18) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontNormal") |
label:SetPoint("TOP",frame,"TOP",0,0) |
label:SetPoint("BOTTOM",frame,"BOTTOM",0,0) |
label:SetJustifyH("CENTER") |
label:SetHeight(18) |
self.label = label |
local left = frame:CreateTexture(nil, "BACKGROUND") |
self.left = left |
left:SetHeight(8) |
left:SetPoint("LEFT",frame,"LEFT",3,0) |
left:SetPoint("RIGHT",label,"LEFT",-5,0) |
left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") |
left:SetTexCoord(0.81, 0.94, 0.5, 1) |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:Hide() |
local right = frame:CreateTexture(nil, "BACKGROUND") |
self.right = right |
right:SetHeight(8) |
right:SetPoint("RIGHT",frame,"RIGHT",-3,0) |
right:SetPoint("LEFT",label,"RIGHT",5,0) |
right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") |
right:SetTexCoord(0.81, 0.94, 0.5, 1) |
AceGUI:RegisterAsWidget(self) |
return self |
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal") |
label:SetPoint("TOP") |
label:SetPoint("BOTTOM") |
label:SetJustifyH("CENTER") |
local left = frame:CreateTexture(nil, "BACKGROUND") |
left:SetHeight(8) |
left:SetPoint("LEFT", 3, 0) |
left:SetPoint("RIGHT", label, "LEFT", -5, 0) |
left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") |
left:SetTexCoord(0.81, 0.94, 0.5, 1) |
local right = frame:CreateTexture(nil, "BACKGROUND") |
right:SetHeight(8) |
right:SetPoint("RIGHT", -3, 0) |
right:SetPoint("LEFT", label, "RIGHT", 5, 0) |
right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") |
right:SetTexCoord(0.81, 0.94, 0.5, 1) |
local widget = { |
label = label, |
left = left, |
right = right, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
Button Widget |
Graphical Button. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Button", 22 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local pairs = pairs |
-- WoW APIs |
local _G = _G |
local PlaySound = PlaySound |
local CreateFrame, UIParent = CreateFrame, UIParent |
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent |
-------------------------- |
-- Button -- |
-------------------------- |
local wowMoP |
do |
local Type = "Button" |
local Version = 13 |
local function OnAcquire(self) |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Button_OnClick(frame, ...) |
AceGUI:ClearFocus() |
PlaySound("igMainMenuOption") |
frame.obj:Fire("OnClick", ...) |
end |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
-- restore default values |
self:SetHeight(24) |
self:SetWidth(200) |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self:SetDisabled(false) |
end |
local function Button_OnClick(this, ...) |
PlaySound("igMainMenuOption") |
this.obj:Fire("OnClick", ...) |
AceGUI:ClearFocus() |
end |
local function Button_OnEnter(this) |
this.obj:Fire("OnEnter") |
end |
local function Button_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function SetText(self, text) |
self.text:SetText(text or "") |
end |
local function SetDisabled(self, disabled) |
self:SetText() |
end, |
-- ["OnRelease"] = nil, |
["SetText"] = function(self, text) |
self.text:SetText(text) |
end, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
if disabled then |
self.frame:Disable() |
self.frame:Enable() |
end |
end |
local function Constructor() |
local num = AceGUI:GetNextWidgetNum(Type) |
local name = "AceGUI30Button"..num |
local frame = CreateFrame("Button",name,UIParent,"UIPanelButtonTemplate2") |
local self = {} |
self.num = num |
self.type = Type |
self.frame = frame |
local left = _G[name .. "Left"] |
local right = _G[name .. "Right"] |
local middle = _G[name .. "Middle"] |
left:SetPoint("TOP", frame, "TOP", 0, 0) |
left:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) |
right:SetPoint("TOP", frame, "TOP", 0, 0) |
right:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) |
middle:SetPoint("TOP", frame, "TOP", 0, 0) |
middle:SetPoint("BOTTOM", frame, "BOTTOM", 0, 0) |
} |
local text = frame:GetFontString() |
self.text = text |
text:ClearAllPoints() |
text:SetPoint("TOPLEFT",frame,"TOPLEFT", 15, -1) |
text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT", -15, 1) |
text:SetJustifyV("MIDDLE") |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Button", name, UIParent, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
frame:Hide() |
frame:SetScript("OnClick",Button_OnClick) |
frame:SetScript("OnEnter",Button_OnEnter) |
frame:SetScript("OnLeave",Button_OnLeave) |
frame:EnableMouse(true) |
frame:SetScript("OnClick", Button_OnClick) |
frame:SetScript("OnEnter", Control_OnEnter) |
frame:SetScript("OnLeave", Control_OnLeave) |
self.SetText = SetText |
self.SetDisabled = SetDisabled |
frame:EnableMouse(true) |
local text = frame:GetFontString() |
text:ClearAllPoints() |
text:SetPoint("TOPLEFT", 15, -1) |
text:SetPoint("BOTTOMRIGHT", -15, 1) |
text:SetJustifyV("MIDDLE") |
frame:SetHeight(24) |
frame:SetWidth(200) |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
frame.obj = self |
AceGUI:RegisterAsWidget(self) |
return self |
local widget = { |
text = text, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 916 2010-03-15 12:24:36Z nevcairiel $ ]]-- |
--[[ $Id: AceGUIWidget-DropDown-Items.lua 996 2010-12-01 18:34:17Z nevcairiel $ ]]-- |
local AceGUI = LibStub("AceGUI-3.0") |
return self |
end |
-- Register a dummy LibStub library to retrieve the ItemBase, so other addons can use it. |
local IBLib = LibStub:NewLibrary("AceGUI-3.0-DropDown-ItemBase", ItemBase.version) |
if IBLib then |
IBLib.GetItemBase = function() return ItemBase end |
end |
--[[ |
Template for items: |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
ColorPicker Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "ColorPicker", 21 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local pairs = pairs |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: ShowUIPanel, HideUIPanel, ColorPickerFrame, OpacitySliderFrame |
-------------------------- |
-- ColorPicker -- |
-------------------------- |
do |
local Type = "ColorPicker" |
local Version = 11 |
local function OnAcquire(self) |
self.HasAlpha = false |
self:SetColor(0,0,0,1) |
self:SetHeight(24) |
self:SetWidth(200) |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
local function ColorCallback(self, r, g, b, a, isAlpha) |
if not self.HasAlpha then |
a = 1 |
end |
local function SetLabel(self, text) |
self.text:SetText(text) |
self:SetColor(r, g, b, a) |
if ColorPickerFrame:IsVisible() then |
--colorpicker is still open |
self:Fire("OnValueChanged", r, g, b, a) |
else |
--colorpicker is closed, color callback is first, ignore it, |
--alpha callback is the final call after it closes so confirm now |
if isAlpha then |
self:Fire("OnValueConfirmed", r, g, b, a) |
end |
end |
end |
local function SetColor(self,r,g,b,a) |
self.r = r |
self.g = g |
self.b = b |
self.a = a or 1 |
self.colorSwatch:SetVertexColor(r,g,b,a) |
end |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnEnter(this) |
this.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
local function Control_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function SetHasAlpha(self, HasAlpha) |
self.HasAlpha = HasAlpha |
end |
local function ColorSwatch_OnClick(frame) |
HideUIPanel(ColorPickerFrame) |
local self = frame.obj |
if not self.disabled then |
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG") |
ColorPickerFrame:SetClampedToScreen(true) |
local function ColorCallback(self,r,g,b,a,isAlpha) |
if not self.HasAlpha then |
a = 1 |
ColorPickerFrame.func = function() |
local r, g, b = ColorPickerFrame:GetColorRGB() |
local a = 1 - OpacitySliderFrame:GetValue() |
ColorCallback(self, r, g, b, a) |
end |
self:SetColor(r,g,b,a) |
if ColorPickerFrame:IsVisible() then |
--colorpicker is still open |
self:Fire("OnValueChanged",r,g,b,a) |
else |
--colorpicker is closed, color callback is first, ignore it, |
--alpha callback is the final call after it closes so confirm now |
if isAlpha then |
self:Fire("OnValueConfirmed",r,g,b,a) |
end |
ColorPickerFrame.hasOpacity = self.HasAlpha |
ColorPickerFrame.opacityFunc = function() |
local r, g, b = ColorPickerFrame:GetColorRGB() |
local a = 1 - OpacitySliderFrame:GetValue() |
ColorCallback(self, r, g, b, a, true) |
end |
end |
local function ColorSwatch_OnClick(this) |
HideUIPanel(ColorPickerFrame) |
local self = this.obj |
if not self.disabled then |
ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG") |
ColorPickerFrame.func = function() |
local r,g,b = ColorPickerFrame:GetColorRGB() |
local a = 1 - OpacitySliderFrame:GetValue() |
ColorCallback(self,r,g,b,a) |
end |
ColorPickerFrame.hasOpacity = self.HasAlpha |
ColorPickerFrame.opacityFunc = function() |
local r,g,b = ColorPickerFrame:GetColorRGB() |
local a = 1 - OpacitySliderFrame:GetValue() |
ColorCallback(self,r,g,b,a,true) |
end |
local r, g, b, a = self.r, self.g, self.b, self.a |
if self.HasAlpha then |
ColorPickerFrame.opacity = 1 - (a or 0) |
end |
ColorPickerFrame:SetColorRGB(r, g, b) |
ColorPickerFrame.cancelFunc = function() |
ColorCallback(self,r,g,b,a,true) |
end |
ShowUIPanel(ColorPickerFrame) |
local r, g, b, a = self.r, self.g, self.b, self.a |
if self.HasAlpha then |
ColorPickerFrame.opacity = 1 - (a or 0) |
end |
AceGUI:ClearFocus() |
end |
ColorPickerFrame:SetColorRGB(r, g, b) |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
ColorPickerFrame.cancelFunc = function() |
ColorCallback(self, r, g, b, a, true) |
end |
ShowUIPanel(ColorPickerFrame) |
end |
AceGUI:ClearFocus() |
end |
local function SetDisabled(self, disabled) |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self:SetHeight(24) |
self:SetWidth(200) |
self:SetHasAlpha(false) |
self:SetColor(0, 0, 0, 1) |
self:SetDisabled(nil) |
self:SetLabel(nil) |
end, |
-- ["OnRelease"] = nil, |
["SetLabel"] = function(self, text) |
self.text:SetText(text) |
end, |
["SetColor"] = function(self, r, g, b, a) |
self.r = r |
self.g = g |
self.b = b |
self.a = a or 1 |
self.colorSwatch:SetVertexColor(r, g, b, a) |
end, |
["SetHasAlpha"] = function(self, HasAlpha) |
self.HasAlpha = HasAlpha |
end, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
if self.disabled then |
self.frame:Disable() |
self.text:SetTextColor(0.5,0.5,0.5) |
self.text:SetTextColor(0.5, 0.5, 0.5) |
else |
self.frame:Enable() |
self.text:SetTextColor(1,1,1) |
self.text:SetTextColor(1, 1, 1) |
end |
end |
} |
local function Constructor() |
local frame = CreateFrame("Button",nil,UIParent) |
local self = {} |
self.type = Type |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local frame = CreateFrame("Button", nil, UIParent) |
frame:Hide() |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetLabel = SetLabel |
self.SetColor = SetColor |
self.SetDisabled = SetDisabled |
self.SetHasAlpha = SetHasAlpha |
self.frame = frame |
frame.obj = self |
local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") |
self.text = text |
text:SetJustifyH("LEFT") |
text:SetTextColor(1,1,1) |
frame:SetHeight(24) |
frame:SetWidth(200) |
text:SetHeight(24) |
frame:SetScript("OnClick", ColorSwatch_OnClick) |
frame:SetScript("OnEnter",Control_OnEnter) |
frame:SetScript("OnLeave",Control_OnLeave) |
local colorSwatch = frame:CreateTexture(nil, "OVERLAY") |
self.colorSwatch = colorSwatch |
colorSwatch:SetWidth(19) |
colorSwatch:SetHeight(19) |
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") |
local texture = frame:CreateTexture(nil, "BACKGROUND") |
colorSwatch.texture = texture |
texture:SetWidth(16) |
texture:SetHeight(16) |
texture:SetTexture(1,1,1) |
texture:Show() |
local checkers = frame:CreateTexture(nil, "BACKGROUND") |
colorSwatch.checkers = checkers |
checkers:SetTexture("Tileset\\Generic\\Checkers") |
checkers:SetDesaturated(true) |
checkers:SetVertexColor(1,1,1,0.75) |
checkers:SetTexCoord(.25,0,0.5,.25) |
checkers:SetWidth(14) |
checkers:SetHeight(14) |
checkers:Show() |
local highlight = frame:CreateTexture(nil, "BACKGROUND") |
self.highlight = highlight |
highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") |
highlight:SetBlendMode("ADD") |
highlight:SetAllPoints(frame) |
highlight:Hide() |
texture:SetPoint("CENTER", colorSwatch, "CENTER") |
checkers:SetPoint("CENTER", colorSwatch, "CENTER") |
colorSwatch:SetPoint("LEFT", frame, "LEFT", 0, 0) |
text:SetPoint("LEFT",colorSwatch,"RIGHT",2,0) |
text:SetPoint("RIGHT",frame,"RIGHT") |
frame:EnableMouse(true) |
frame:SetScript("OnEnter", Control_OnEnter) |
frame:SetScript("OnLeave", Control_OnLeave) |
frame:SetScript("OnClick", ColorSwatch_OnClick) |
AceGUI:RegisterAsWidget(self) |
return self |
local colorSwatch = frame:CreateTexture(nil, "OVERLAY") |
colorSwatch:SetWidth(19) |
colorSwatch:SetHeight(19) |
colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch") |
colorSwatch:SetPoint("LEFT") |
local texture = frame:CreateTexture(nil, "BACKGROUND") |
texture:SetWidth(16) |
texture:SetHeight(16) |
texture:SetTexture(1, 1, 1) |
texture:SetPoint("CENTER", colorSwatch) |
texture:Show() |
local checkers = frame:CreateTexture(nil, "BACKGROUND") |
checkers:SetWidth(14) |
checkers:SetHeight(14) |
checkers:SetTexture("Tileset\\Generic\\Checkers") |
checkers:SetTexCoord(.25, 0, 0.5, .25) |
checkers:SetDesaturated(true) |
checkers:SetVertexColor(1, 1, 1, 0.75) |
checkers:SetPoint("CENTER", colorSwatch) |
checkers:Show() |
local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") |
text:SetHeight(24) |
text:SetJustifyH("LEFT") |
text:SetTextColor(1, 1, 1) |
text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0) |
text:SetPoint("RIGHT") |
--local highlight = frame:CreateTexture(nil, "HIGHLIGHT") |
--highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") |
--highlight:SetBlendMode("ADD") |
--highlight:SetAllPoints(frame) |
local widget = { |
colorSwatch = colorSwatch, |
text = text, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
InteractiveLabel Widget |
-------------------------------------------------------------------------------]] |
local Type, Version = "InteractiveLabel", 20 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local select, max = select, math.max |
local select, pairs = select, pairs |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: GameFontHighlightSmall |
-------------------------- |
-- Label -- |
-------------------------- |
do |
local Type = "InteractiveLabel" |
local Version = 6 |
local function OnAcquire(self) |
self:SetHeight(18) |
self:SetWidth(200) |
self:SetText("") |
self:SetImage(nil) |
self:SetColor() |
self:SetFontObject() |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
local function Label_OnClick(frame, button) |
frame.obj:Fire("OnClick", button) |
AceGUI:ClearFocus() |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self:LabelOnAcquire() |
self:SetHighlight() |
self:SetHighlightTexCoord() |
end |
local function OnRelease(self) |
self:SetDisabled(false) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local function UpdateImageAnchor(self) |
local width = self.frame.width or self.frame:GetWidth() or 0 |
local image = self.image |
local label = self.label |
local frame = self.frame |
local height |
label:ClearAllPoints() |
image:ClearAllPoints() |
if self.imageshown then |
local imagewidth = image:GetWidth() |
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then |
--image goes on top centered when less than 200 width for the text, or if there is no text |
image:SetPoint("TOP",frame,"TOP",0,0) |
label:SetPoint("TOP",image,"BOTTOM",0,0) |
label:SetPoint("LEFT",frame,"LEFT",0,0) |
label:SetWidth(width) |
height = image:GetHeight() + label:GetHeight() |
else |
--image on the left |
local imageheight = image:GetHeight() |
local labelheight = label:GetHeight() |
--center image with label |
if imageheight > labelheight then |
image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("LEFT",image,"RIGHT",0,0) |
else |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",imagewidth,0) |
image:SetPoint("RIGHT",label,"LEFT",0,0) |
end |
label:SetWidth(width - imagewidth) |
height = max(imageheight, labelheight) |
end |
else |
--no image shown |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetWidth(width) |
height = self.label:GetHeight() |
end |
self.resizing = true |
self.frame:SetHeight(height) |
self.frame.height = height |
self.resizing = nil |
end |
local function SetText(self, text) |
self.label:SetText(text or "") |
UpdateImageAnchor(self) |
end |
local function SetColor(self, r, g, b) |
if not (r and g and b) then |
r, g, b = 1, 1, 1 |
end |
self.label:SetVertexColor(r, g, b) |
end |
local function OnWidthSet(self, width) |
if self.resizing then return end |
UpdateImageAnchor(self) |
end |
local function SetImage(self, path, ...) |
local image = self.image |
image:SetTexture(path) |
if image:GetTexture() then |
self.imageshown = true |
local n = select('#', ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
end |
else |
self.imageshown = nil |
end |
UpdateImageAnchor(self) |
end |
local function SetFont(self, font, height, flags) |
self.label:SetFont(font, height, flags) |
end |
local function SetFontObject(self, font) |
self.label:SetFontObject(font or GameFontHighlightSmall) |
end |
local function SetImageSize(self, width, height) |
self.image:SetWidth(width) |
self.image:SetHeight(height) |
UpdateImageAnchor(self) |
end |
local function SetHighlight(self, ...) |
end, |
-- ["OnRelease"] = nil, |
["SetHighlight"] = function(self, ...) |
self.highlight:SetTexture(...) |
end |
local function SetHighlightTexCoord(self, ...) |
if select('#', ...) >= 1 then |
end, |
["SetHighlightTexCoord"] = function(self, ...) |
local c = select("#", ...) |
if c == 4 or c == 8 then |
self.highlight:SetTexCoord(...) |
else |
self.highlight:SetTexCoord(0, 1, 0, 1) |
end |
end |
local function SetDisabled(self,disabled) |
end, |
["SetDisabled"] = function(self,disabled) |
self.disabled = disabled |
if disabled then |
self.frame:EnableMouse(false) |
self.label:SetTextColor(1, 1, 1) |
end |
end |
local function OnEnter(this) |
this.obj.highlight:Show() |
this.obj:Fire("OnEnter") |
end |
local function OnLeave(this) |
this.obj.highlight:Hide() |
this.obj:Fire("OnLeave") |
end |
local function OnClick(this, ...) |
this.obj:Fire("OnClick", ...) |
AceGUI:ClearFocus() |
end |
} |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = Type |
frame:EnableMouse(true) |
frame:SetScript("OnEnter", OnEnter) |
frame:SetScript("OnLeave", OnLeave) |
frame:SetScript("OnMouseDown", OnClick) |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.SetColor = SetColor |
self.frame = frame |
self.OnWidthSet = OnWidthSet |
self.SetImage = SetImage |
self.SetImageSize = SetImageSize |
self.SetFont = SetFont |
self.SetFontObject = SetFontObject |
self.SetHighlight = SetHighlight |
self.SetHighlightTexCoord = SetHighlightTexCoord |
self.SetDisabled = SetDisabled |
frame.obj = self |
frame:SetHeight(18) |
frame:SetWidth(200) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetWidth(200) |
label:SetJustifyH("LEFT") |
label:SetJustifyV("TOP") |
self.label = label |
local highlight = frame:CreateTexture(nil, "OVERLAY") |
highlight:SetTexture(nil) |
highlight:SetAllPoints() |
highlight:SetBlendMode("ADD") |
highlight:Hide() |
self.highlight = highlight |
local image = frame:CreateTexture(nil,"BACKGROUND") |
self.image = image |
AceGUI:RegisterAsWidget(self) |
return self |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
-- create a Label type that we will hijack |
local label = AceGUI:Create("Label") |
local frame = label.frame |
frame:EnableMouse(true) |
frame:SetScript("OnEnter", Control_OnEnter) |
frame:SetScript("OnLeave", Control_OnLeave) |
frame:SetScript("OnMouseDown", Label_OnClick) |
local highlight = frame:CreateTexture(nil, "HIGHLIGHT") |
highlight:SetTexture(nil) |
highlight:SetAllPoints() |
highlight:SetBlendMode("ADD") |
label.highlight = highlight |
label.type = Type |
label.LabelOnAcquire = label.OnAcquire |
for method, func in pairs(methods) do |
label[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
return label |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
Label Widget |
Displays text and optionally an icon. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Label", 23 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local max, select = math.max, select |
local max, select, pairs = math.max, select, pairs |
-- WoW APIs |
local CreateFrame, UIParent = CreateFrame, UIParent |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: GameFontHighlightSmall |
-------------------------- |
-- Label -- |
-------------------------- |
do |
local Type = "Label" |
local Version = 12 |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
local function UpdateImageAnchor(self) |
if self.resizing then return end |
local frame = self.frame |
local width = frame.width or frame:GetWidth() or 0 |
local image = self.image |
local label = self.label |
local height |
label:ClearAllPoints() |
image:ClearAllPoints() |
if self.imageshown then |
local imagewidth = image:GetWidth() |
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then |
-- image goes on top centered when less than 200 width for the text, or if there is no text |
image:SetPoint("TOP") |
label:SetPoint("TOP", image, "BOTTOM") |
label:SetPoint("LEFT") |
label:SetWidth(width) |
height = image:GetHeight() + label:GetHeight() |
else |
-- image on the left |
image:SetPoint("TOPLEFT") |
if image:GetHeight() > label:GetHeight() then |
label:SetPoint("LEFT", image, "RIGHT", 4, 0) |
else |
label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0) |
end |
label:SetWidth(width - imagewidth - 4) |
height = max(image:GetHeight(), label:GetHeight()) |
end |
else |
-- no image shown |
label:SetPoint("TOPLEFT") |
label:SetWidth(width) |
height = label:GetHeight() |
end |
local function OnAcquire(self) |
self:SetHeight(18) |
self.resizing = true |
frame:SetHeight(height) |
frame.height = height |
self.resizing = nil |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
-- set the flag to stop constant size updates |
self.resizing = true |
-- height is set dynamically by the text and image size |
self:SetWidth(200) |
self:SetText("") |
self:SetText() |
self:SetImage(nil) |
self:SetImageSize(16, 16) |
self:SetColor() |
self:SetFontObject() |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local function UpdateImageAnchor(self) |
local width = self.frame.width or self.frame:GetWidth() or 0 |
local image = self.image |
local label = self.label |
local frame = self.frame |
local height |
label:ClearAllPoints() |
image:ClearAllPoints() |
if self.imageshown then |
local imagewidth = image:GetWidth() |
if (width - imagewidth) < 200 or (label:GetText() or "") == "" then |
--image goes on top centered when less than 200 width for the text, or if there is no text |
image:SetPoint("TOP",frame,"TOP",0,0) |
label:SetPoint("TOP",image,"BOTTOM",0,0) |
label:SetPoint("LEFT",frame,"LEFT",0,0) |
label:SetWidth(width) |
height = image:GetHeight() + label:GetHeight() |
else |
--image on the left |
image:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("TOPLEFT",image,"TOPRIGHT",4,0) |
label:SetWidth(width - imagewidth) |
height = max(image:GetHeight(), label:GetHeight()) |
end |
else |
--no image shown |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetWidth(width) |
height = self.label:GetHeight() |
end |
self.resizing = true |
self.frame:SetHeight(height) |
self.frame.height = height |
-- reset the flag |
self.resizing = nil |
end |
local function SetText(self, text) |
self.label:SetText(text or "") |
-- run the update explicitly |
UpdateImageAnchor(self) |
end |
local function SetColor(self, r, g, b) |
end, |
-- ["OnRelease"] = nil, |
["OnWidthSet"] = function(self, width) |
UpdateImageAnchor(self) |
end, |
["SetText"] = function(self, text) |
self.label:SetText(text) |
UpdateImageAnchor(self) |
end, |
["SetColor"] = function(self, r, g, b) |
if not (r and g and b) then |
r, g, b = 1, 1, 1 |
end |
self.label:SetVertexColor(r, g, b) |
end |
local function OnWidthSet(self, width) |
if self.resizing then return end |
UpdateImageAnchor(self) |
end |
local function SetImage(self, path, ...) |
end, |
["SetImage"] = function(self, path, ...) |
local image = self.image |
image:SetTexture(path) |
if image:GetTexture() then |
self.imageshown = true |
local n = select('#', ...) |
local n = select("#", ...) |
if n == 4 or n == 8 then |
image:SetTexCoord(...) |
else |
self.imageshown = nil |
end |
UpdateImageAnchor(self) |
end |
local function SetFont(self, font, height, flags) |
end, |
["SetFont"] = function(self, font, height, flags) |
self.label:SetFont(font, height, flags) |
end |
local function SetFontObject(self, font) |
self.label:SetFontObject(font or GameFontHighlightSmall) |
end |
local function SetImageSize(self, width, height) |
end, |
["SetFontObject"] = function(self, font) |
self:SetFont((font or GameFontHighlightSmall):GetFont()) |
end, |
["SetImageSize"] = function(self, width, height) |
self.image:SetWidth(width) |
self.image:SetHeight(height) |
UpdateImageAnchor(self) |
end, |
} |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local function Constructor() |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:Hide() |
local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall") |
label:SetJustifyH("LEFT") |
label:SetJustifyV("TOP") |
local image = frame:CreateTexture(nil, "BACKGROUND") |
-- create widget |
local widget = { |
label = label, |
image = image, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = Type |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetText = SetText |
self.SetColor = SetColor |
self.frame = frame |
self.OnWidthSet = OnWidthSet |
self.SetImage = SetImage |
self.SetImageSize = SetImageSize |
self.SetFont = SetFont |
self.SetFontObject = SetFontObject |
frame.obj = self |
frame:SetHeight(18) |
frame:SetWidth(200) |
local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlightSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetWidth(200) |
label:SetJustifyH("LEFT") |
label:SetJustifyV("TOP") |
self.label = label |
local image = frame:CreateTexture(nil,"BACKGROUND") |
self.image = image |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
local Type, Version = "MultiLineEditBox", 27 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
--[[ |
--Multiline Editbox Widget, Originally by bam |
--]] |
local AceGUI = LibStub("AceGUI-3.0") |
-- Lua APIs |
local format, pairs, tostring = string.format, pairs, tostring |
local pairs = pairs |
-- WoW APIs |
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName |
local GetCursorInfo, GetSpellInfo, ClearCursor = GetCursorInfo, GetSpellInfo, ClearCursor |
local CreateFrame, UIParent = CreateFrame, UIParent |
local _G = _G |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: ChatFontNormal, ACCEPT |
-- GLOBALS: ACCEPT, ChatFontNormal |
local Version = 11 |
--------------------- |
-- Common Elements -- |
--------------------- |
local wowMoP |
do |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
local FrameBackdrop = { |
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", |
edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", |
tile = true, tileSize = 32, edgeSize = 32, |
insets = { left = 8, right = 8, top = 8, bottom = 8 } |
} |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
local PaneBackdrop = { |
if not AceGUIMultiLineEditBoxInsertLink then |
-- upgradeable hook |
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIMultiLineEditBoxInsertLink(...) end) |
end |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 5, bottom = 3 } |
} |
function _G.AceGUIMultiLineEditBoxInsertLink(text) |
for i = 1, AceGUI:GetWidgetCount(Type) do |
local editbox = _G[("MultiLineEditBox%uEdit"):format(i)] |
if editbox and editbox:IsVisible() and editbox:HasFocus() then |
editbox:Insert(text) |
return true |
end |
end |
end |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 3, bottom = 3 } |
} |
-------------------------- |
-- Edit box -- |
-------------------------- |
--[[ |
Events : |
OnTextChanged |
OnEnterPressed |
local function Layout(self) |
self:SetHeight(self.numlines * 14 + (self.disablebutton and 19 or 41) + self.labelHeight) |
]] |
do |
local Type = "MultiLineEditBox" |
if self.labelHeight == 0 then |
self.scrollBar:SetPoint("TOP", self.frame, "TOP", 0, -23) |
else |
self.scrollBar:SetPoint("TOP", self.label, "BOTTOM", 0, -19) |
end |
local MultiLineEditBox = {} |
if self.disablebutton then |
self.scrollBar:SetPoint("BOTTOM", self.frame, "BOTTOM", 0, 21) |
self.scrollBG:SetPoint("BOTTOMLEFT", 0, 4) |
else |
self.scrollBar:SetPoint("BOTTOM", self.button, "TOP", 0, 18) |
self.scrollBG:SetPoint("BOTTOMLEFT", self.button, "TOPLEFT") |
end |
end |
local function EditBox_OnEnterPressed(this) |
local self = this.obj |
local value = this:GetText() |
local cancel = self:Fire("OnEnterPressed",value) |
if not cancel then |
self.button:Disable() |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function OnClick(self) -- Button |
self = self.obj |
self.editBox:ClearFocus() |
if not self:Fire("OnEnterPressed", self.editBox:GetText()) then |
self.button:Disable() |
end |
end |
local function OnCursorChanged(self, _, y, _, cursorHeight) -- EditBox |
self, y = self.obj.scrollFrame, -y |
local offset = self:GetVerticalScroll() |
if y < offset then |
self:SetVerticalScroll(y) |
else |
y = y + cursorHeight - self:GetHeight() |
if y > offset then |
self:SetVerticalScroll(y) |
end |
end |
local function Button_OnClick(this) |
local editbox = this.obj.editbox |
editbox:ClearFocus() |
EditBox_OnEnterPressed(editbox) |
end |
local function OnEditFocusLost(self) -- EditBox |
self:HighlightText(0, 0) |
self.obj:Fire("OnEditFocusLost") |
end |
local function OnEnter(self) -- EditBox / ScrollFrame |
self = self.obj |
if not self.entered then |
self.entered = true |
self:Fire("OnEnter") |
end |
local function EditBox_OnReceiveDrag(this) |
local self = this.obj |
local type, id, info = GetCursorInfo() |
if type == "item" then |
self:SetText(info) |
self:Fire("OnEnterPressed",info) |
ClearCursor() |
elseif type == "spell" then |
local name, rank = GetSpellName(id, info) |
if rank and rank:match("%d") then |
name = name.."("..rank..")" |
end |
self:SetText(name) |
self:Fire("OnEnterPressed",name) |
ClearCursor() |
end |
--self.button:Disable() |
AceGUI:ClearFocus() |
end |
local function OnLeave(self) -- EditBox / ScrollFrame |
self = self.obj |
if self.entered then |
self.entered = nil |
self:Fire("OnLeave") |
end |
function MultiLineEditBox:OnAcquire() |
self:SetWidth(200) |
self:SetHeight(116) |
self:SetNumLines(4) |
self:SetDisabled(false) |
self:ShowButton(true) |
end |
local function OnMouseUp(self) -- ScrollFrame |
self = self.obj.editBox |
self:SetFocus() |
self:SetCursorPosition(self:GetNumLetters()) |
end |
local function OnReceiveDrag(self) -- EditBox / ScrollFrame |
local type, id, info = GetCursorInfo() |
if type == "spell" then |
info = GetSpellInfo(id, info) |
elseif type ~= "item" then |
return |
end |
function MultiLineEditBox:OnRelease() |
self.frame:ClearAllPoints() |
self.frame:Hide() |
ClearCursor() |
self = self.obj |
local editBox = self.editBox |
if not editBox:HasFocus() then |
editBox:SetFocus() |
editBox:SetCursorPosition(editBox:GetNumLetters()) |
end |
editBox:Insert(info) |
self.button:Enable() |
end |
local function OnSizeChanged(self, width, height) -- ScrollFrame |
self.obj.editBox:SetWidth(width) |
end |
local function OnTextChanged(self, userInput) -- EditBox |
if userInput then |
self = self.obj |
self:Fire("OnTextChanged", self.editBox:GetText()) |
self.button:Enable() |
end |
end |
local function OnTextSet(self) -- EditBox |
self:HighlightText(0, 0) |
self:SetCursorPosition(self:GetNumLetters()) |
self:SetCursorPosition(0) |
self.obj.button:Disable() |
end |
local function OnVerticalScroll(self, offset) -- ScrollFrame |
local editBox = self.obj.editBox |
editBox:SetHitRectInsets(0, 0, offset, editBox:GetHeight() - offset - self:GetHeight()) |
end |
local function OnShowFocus(frame) |
frame.obj.editBox:SetFocus() |
frame:SetScript("OnShow", nil) |
end |
local function OnEditFocusGained(frame) |
AceGUI:SetFocus(frame.obj) |
frame.obj:Fire("OnEditFocusGained") |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self.editBox:SetText("") |
self:SetDisabled(false) |
end |
function MultiLineEditBox:SetDisabled(disabled) |
self.disabled = disabled |
self:SetWidth(200) |
self:DisableButton(false) |
self:SetNumLines() |
self.entered = nil |
self:SetMaxLetters(0) |
end, |
["OnRelease"] = function(self) |
self:ClearFocus() |
end, |
["SetDisabled"] = function(self, disabled) |
local editBox = self.editBox |
if disabled then |
self.editbox:EnableMouse(false) |
self.scrollframe:EnableMouse(false) |
self.editbox:ClearFocus() |
self.editbox:SetTextColor(0.5, 0.5, 0.5) |
self.label:SetTextColor(0.5,0.5,0.5) |
editBox:ClearFocus() |
editBox:EnableMouse(false) |
editBox:SetTextColor(0.5, 0.5, 0.5) |
self.label:SetTextColor(0.5, 0.5, 0.5) |
self.scrollFrame:EnableMouse(false) |
self.button:Disable() |
else |
self.editbox:EnableMouse(true) |
self.scrollframe:EnableMouse(true) |
self.editbox:SetTextColor(1, 1, 1) |
self.label:SetTextColor(1,.82,0) |
self.button:Enable() |
editBox:EnableMouse(true) |
editBox:SetTextColor(1, 1, 1) |
self.label:SetTextColor(1, 0.82, 0) |
self.scrollFrame:EnableMouse(true) |
end |
end |
end, |
function MultiLineEditBox:SetText(text) |
text = text or "" |
local editbox = self.editbox |
local oldText = editbox:GetText() |
local dummy = format(" %s", text) |
self.lasttext = dummy -- prevents OnTextChanged from firing |
editbox:SetText(dummy) |
editbox:HighlightText(0, 1) |
self.lasttext = oldText |
editbox:Insert("") |
end |
function MultiLineEditBox:SetLabel(text) |
if (text or "") == "" then |
self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,0) |
["SetLabel"] = function(self, text) |
if text and text ~= "" then |
self.label:SetText(text) |
if self.labelHeight ~= 10 then |
self.labelHeight = 10 |
self.label:Show() |
end |
elseif self.labelHeight ~= 0 then |
self.labelHeight = 0 |
self.label:Hide() |
self.label:SetText("") |
end |
Layout(self) |
end, |
["SetNumLines"] = function(self, value) |
if not value or value < 4 then |
value = 4 |
end |
self.numlines = value |
Layout(self) |
end, |
["SetText"] = function(self, text) |
self.editBox:SetText(text) |
end, |
["GetText"] = function(self) |
return self.editBox:GetText() |
end, |
["SetMaxLetters"] = function (self, num) |
self.editBox:SetMaxLetters(num or 0) |
end, |
["DisableButton"] = function(self, disabled) |
self.disablebutton = disabled |
if disabled then |
self.button:Hide() |
else |
self.backdrop:SetPoint("TOPLEFT",self.frame,"TOPLEFT",0,-20) |
self.label:Show() |
self.label:SetText(text) |
self.button:Show() |
end |
end |
Layout(self) |
end, |
function MultiLineEditBox:SetNumLines(number) |
number = number or 4 |
self:SetHeight(60 + (14*number)) |
end |
["ClearFocus"] = function(self) |
self.editBox:ClearFocus() |
self.frame:SetScript("OnShow", nil) |
end, |
function MultiLineEditBox:GetText() |
return self.editbox:GetText() |
end |
["SetFocus"] = function(self) |
self.editBox:SetFocus() |
if not self.frame:IsShown() then |
self.frame:SetScript("OnShow", OnShowFocus) |
end |
end, |
function MultiLineEditBox:ShowButton(show) |
if show then |
self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,22) |
self.button:Show() |
else |
self.backdrop:SetPoint("BOTTOMRIGHT",self.frame,"BOTTOMRIGHT",0,0) |
self.button:Hide() |
end |
end |
["GetCursorPosition"] = function(self) |
return self.editBox:GetCursorPosition() |
end, |
["SetCursorPosition"] = function(self, ...) |
return self.editBox:SetCursorPosition(...) |
end, |
} |
local function Constructor() |
local frame = CreateFrame("Frame", nil, UIParent) |
local backdrop = CreateFrame("Frame", nil, frame) |
local self = {} |
for k, v in pairs(MultiLineEditBox) do self[k] = v end |
self.type = Type |
self.frame = frame |
self.backdrop = backdrop |
frame.obj = self |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local backdrop = { |
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], |
edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], edgeSize = 16, |
insets = { left = 4, right = 3, top = 4, bottom = 3 } |
} |
backdrop:SetBackdrop(ControlBackdrop) |
backdrop:SetBackdropColor(0, 0, 0) |
backdrop:SetBackdropBorderColor(0.4, 0.4, 0.4) |
local function Constructor() |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:Hide() |
backdrop:SetPoint("TOPLEFT",frame,"TOPLEFT",0, -20) |
backdrop:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,22) |
local scrollframe = CreateFrame("ScrollFrame", format("%s@%s@%s", Type, "ScrollFrame", tostring(self)), backdrop, "UIPanelScrollFrameTemplate") |
scrollframe:SetPoint("TOPLEFT", 5, -6) |
scrollframe:SetPoint("BOTTOMRIGHT", -28, 6) |
scrollframe.obj = self |
self.scrollframe = scrollframe |
--local scrollchild = CreateFrame("Frame", nil, scrollframe) |
--scrollframe:SetScrollChild(scrollchild) |
--scrollchild:SetHeight(2) |
--scrollchild:SetWidth(2) |
local widgetNum = AceGUI:GetNextWidgetNum(Type) |
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") |
label:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, -4) |
label:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -4) |
label:SetJustifyH("LEFT") |
label:SetText(ACCEPT) |
label:SetHeight(10) |
local button = CreateFrame("Button", ("%s%dButton"):format(Type, widgetNum), frame, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
button:SetPoint("BOTTOMLEFT", 0, 4) |
button:SetHeight(22) |
button:SetWidth(label:GetStringWidth() + 24) |
button:SetText(ACCEPT) |
button:SetScript("OnClick", OnClick) |
button:Disable() |
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,-2) |
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,-2) |
label:SetJustifyH("LEFT") |
label:SetHeight(18) |
self.label = label |
local editbox = CreateFrame("EditBox", nil, scrollframe) |
self.editbox = editbox |
editbox.obj = self |
editbox:SetPoint("TOPLEFT") |
editbox:SetPoint("BOTTOMLEFT") |
editbox:SetHeight(50) |
editbox:SetWidth(50) |
editbox:SetMultiLine(true) |
-- editbox:SetMaxLetters(7500) |
editbox:SetTextInsets(5, 5, 3, 3) |
editbox:EnableMouse(true) |
editbox:SetAutoFocus(false) |
editbox:SetFontObject(ChatFontNormal) |
scrollframe:SetScrollChild(editbox) |
local text = button:GetFontString() |
text:ClearAllPoints() |
text:SetPoint("TOPLEFT", button, "TOPLEFT", 5, -5) |
text:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -5, 1) |
text:SetJustifyV("MIDDLE") |
local button = CreateFrame("Button",nil,scrollframe,"UIPanelButtonTemplate") |
button:SetWidth(80) |
button:SetHeight(20) |
button:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,2) |
button:SetText(ACCEPT) |
button:SetScript("OnClick", Button_OnClick) |
button:SetFrameLevel(editbox:GetFrameLevel() + 1) |
button:Disable() |
button:Hide() |
self.button = button |
button.obj = self |
scrollframe:EnableMouse(true) |
scrollframe:SetScript("OnMouseUp", function() editbox:SetFocus() end) |
scrollframe:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end) |
scrollframe:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end) |
editbox:SetScript("OnEnter", function(this) this.obj:Fire("OnEnter") end) |
editbox:SetScript("OnLeave", function(this) this.obj:Fire("OnLeave") end) |
local function FixSize() |
--scrollchild:SetHeight(scrollframe:GetHeight()) |
--scrollchild:SetWidth(scrollframe:GetWidth()) |
editbox:SetWidth(scrollframe:GetWidth()) |
end |
scrollframe:SetScript("OnShow", FixSize) |
scrollframe:SetScript("OnSizeChanged", FixSize) |
local scrollBG = CreateFrame("Frame", nil, frame) |
scrollBG:SetBackdrop(backdrop) |
scrollBG:SetBackdropColor(0, 0, 0) |
scrollBG:SetBackdropBorderColor(0.4, 0.4, 0.4) |
local scrollFrame = CreateFrame("ScrollFrame", ("%s%dScrollFrame"):format(Type, widgetNum), frame, "UIPanelScrollFrameTemplate") |
local scrollBar = _G[scrollFrame:GetName() .. "ScrollBar"] |
scrollBar:ClearAllPoints() |
scrollBar:SetPoint("TOP", label, "BOTTOM", 0, -19) |
scrollBar:SetPoint("BOTTOM", button, "TOP", 0, 18) |
scrollBar:SetPoint("RIGHT", frame, "RIGHT") |
scrollBG:SetPoint("TOPRIGHT", scrollBar, "TOPLEFT", 0, 19) |
scrollBG:SetPoint("BOTTOMLEFT", button, "TOPLEFT") |
scrollFrame:SetPoint("TOPLEFT", scrollBG, "TOPLEFT", 5, -6) |
scrollFrame:SetPoint("BOTTOMRIGHT", scrollBG, "BOTTOMRIGHT", -4, 4) |
scrollFrame:SetScript("OnEnter", OnEnter) |
scrollFrame:SetScript("OnLeave", OnLeave) |
scrollFrame:SetScript("OnMouseUp", OnMouseUp) |
scrollFrame:SetScript("OnReceiveDrag", OnReceiveDrag) |
scrollFrame:SetScript("OnSizeChanged", OnSizeChanged) |
scrollFrame:HookScript("OnVerticalScroll", OnVerticalScroll) |
local editBox = CreateFrame("EditBox", ("%s%dEdit"):format(Type, widgetNum), scrollFrame) |
editBox:SetAllPoints() |
editBox:SetFontObject(ChatFontNormal) |
editBox:SetMultiLine(true) |
editBox:EnableMouse(true) |
editBox:SetAutoFocus(false) |
editBox:SetCountInvisibleLetters(false) |
editBox:SetScript("OnCursorChanged", OnCursorChanged) |
editBox:SetScript("OnEditFocusLost", OnEditFocusLost) |
editBox:SetScript("OnEnter", OnEnter) |
editBox:SetScript("OnEscapePressed", editBox.ClearFocus) |
editBox:SetScript("OnLeave", OnLeave) |
editBox:SetScript("OnMouseDown", OnReceiveDrag) |
editBox:SetScript("OnReceiveDrag", OnReceiveDrag) |
editBox:SetScript("OnTextChanged", OnTextChanged) |
editBox:SetScript("OnTextSet", OnTextSet) |
editBox:SetScript("OnEditFocusGained", OnEditFocusGained) |
editbox:SetScript("OnEscapePressed", editbox.ClearFocus) |
editbox:SetScript("OnTextChanged", function(_, ...) |
scrollframe:UpdateScrollChildRect() |
local value = editbox:GetText() |
if value ~= self.lasttext then |
self:Fire("OnTextChanged", value) |
self.lasttext = value |
if not self.disabled then |
self.button:Enable() |
end |
end |
end) |
editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag) |
editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag) |
do |
local cursorOffset, cursorHeight |
local idleTime |
local function FixScroll(_, elapsed) |
if cursorOffset and cursorHeight then |
idleTime = 0 |
local height = scrollframe:GetHeight() |
local range = scrollframe:GetVerticalScrollRange() |
local scroll = scrollframe:GetVerticalScroll() |
local size = height + range |
cursorOffset = -cursorOffset |
while cursorOffset < scroll do |
scroll = scroll - (height / 2) |
if scroll < 0 then scroll = 0 end |
scrollframe:SetVerticalScroll(scroll) |
end |
while cursorOffset + cursorHeight > scroll + height and scroll < range do |
scroll = scroll + (height / 2) |
if scroll > range then scroll = range end |
scrollframe:SetVerticalScroll(scroll) |
end |
elseif not idleTime or idleTime > 2 then |
frame:SetScript("OnUpdate", nil) |
idleTime = nil |
else |
idleTime = idleTime + elapsed |
end |
cursorOffset = nil |
end |
editbox:SetScript("OnCursorChanged", function(_, x, y, w, h) |
cursorOffset, cursorHeight = y, h |
if not idleTime then |
frame:SetScript("OnUpdate", FixScroll) |
end |
end) |
end |
AceGUI:RegisterAsWidget(self) |
return self |
scrollFrame:SetScrollChild(editBox) |
local widget = { |
button = button, |
editBox = editBox, |
frame = frame, |
label = label, |
labelHeight = 10, |
numlines = 4, |
scrollBar = scrollBar, |
scrollBG = scrollBG, |
scrollFrame = scrollFrame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
button.obj, editBox.obj, scrollFrame.obj = widget, widget, widget |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
Slider Widget |
Graphical Slider, like, for Range values. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Slider", 20 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local min, max, floor = math.min, math.max, math.floor |
local tonumber = tonumber |
local tonumber, pairs = tonumber, pairs |
-- WoW APIs |
local PlaySound = PlaySound |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: GameFontHighlightSmall |
-------------------------- |
-- Slider -- |
-------------------------- |
do |
local Type = "Slider" |
local Version = 10 |
local function OnAcquire(self) |
self:SetWidth(200) |
self:SetHeight(44) |
self:SetDisabled(false) |
self:SetIsPercent(nil) |
self:SetSliderValues(0,100,1) |
self:SetValue(0) |
--[[----------------------------------------------------------------------------- |
Support functions |
-------------------------------------------------------------------------------]] |
local function UpdateText(self) |
local value = self.value or 0 |
if self.ispercent then |
self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10)) |
else |
self.editbox:SetText(floor(value * 100 + 0.5) / 100) |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.slider:EnableMouseWheel(false) |
self:SetDisabled(false) |
end |
end |
local function Control_OnEnter(this) |
this.obj:Fire("OnEnter") |
local function UpdateLabels(self) |
local min, max = (self.min or 0), (self.max or 100) |
if self.ispercent then |
self.lowtext:SetFormattedText("%s%%", (min * 100)) |
self.hightext:SetFormattedText("%s%%", (max * 100)) |
else |
self.lowtext:SetText(min) |
self.hightext:SetText(max) |
end |
local function Control_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function UpdateText(self) |
local value = self.value or 0 |
if self.ispercent then |
self.editbox:SetText(("%s%%"):format(floor(value*1000+0.5)/10)) |
else |
self.editbox:SetText(floor(value*100+0.5)/100) |
end |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
local function Frame_OnMouseDown(frame) |
frame.obj.slider:EnableMouseWheel(true) |
AceGUI:ClearFocus() |
end |
local function Slider_OnValueChanged(frame) |
local self = frame.obj |
if not frame.setup then |
local newvalue = frame:GetValue() |
if newvalue ~= self.value and not self.disabled then |
self.value = newvalue |
self:Fire("OnValueChanged", newvalue) |
end |
if self.value then |
UpdateText(self) |
end |
end |
local function UpdateLabels(self) |
local min, max = (self.min or 0), (self.max or 100) |
if self.ispercent then |
self.lowtext:SetFormattedText("%s%%",(min * 100)) |
self.hightext:SetFormattedText("%s%%",(max * 100)) |
end |
local function Slider_OnMouseUp(frame) |
local self = frame.obj |
self:Fire("OnMouseUp", self.value) |
end |
local function Slider_OnMouseWheel(frame, v) |
local self = frame.obj |
if not self.disabled then |
local value = self.value |
if v > 0 then |
value = min(value + (self.step or 1), self.max) |
else |
self.lowtext:SetText(min) |
self.hightext:SetText(max) |
value = max(value - (self.step or 1), self.min) |
end |
self.slider:SetValue(value) |
end |
local function Slider_OnValueChanged(this) |
local self = this.obj |
if not this.setup then |
local newvalue |
newvalue = this:GetValue() |
if newvalue ~= self.value and not self.disabled then |
self.value = newvalue |
self:Fire("OnValueChanged", newvalue) |
end |
if self.value then |
local value = self.value |
UpdateText(self) |
end |
end |
end |
local function EditBox_OnEscapePressed(frame) |
frame:ClearFocus() |
end |
local function EditBox_OnEnterPressed(frame) |
local self = frame.obj |
local value = frame:GetText() |
if self.ispercent then |
value = value:gsub('%%', '') |
value = tonumber(value) / 100 |
else |
value = tonumber(value) |
end |
local function Slider_OnMouseUp(this) |
local self = this.obj |
self:Fire("OnMouseUp",this:GetValue()) |
if value then |
PlaySound("igMainMenuOptionCheckBoxOn") |
self.slider:SetValue(value) |
self:Fire("OnMouseUp", value) |
end |
local function Slider_OnMouseWheel(this, v) |
local self = this.obj |
if not self.disabled then |
local value = self.value |
if v > 0 then |
value = min(value + (self.step or 1),self.max) |
else |
value = max(value - (self.step or 1), self.min) |
end |
self.slider:SetValue(value) |
end |
end |
local function SetDisabled(self, disabled) |
end |
local function EditBox_OnEnter(frame) |
frame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1) |
end |
local function EditBox_OnLeave(frame) |
frame:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8) |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self:SetWidth(200) |
self:SetHeight(44) |
self:SetDisabled(false) |
self:SetIsPercent(nil) |
self:SetSliderValues(0,100,1) |
self:SetValue(0) |
self.slider:EnableMouseWheel(false) |
end, |
-- ["OnRelease"] = nil, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
if disabled then |
self.slider:EnableMouse(false) |
self.label:SetTextColor(.5,.5,.5) |
self.hightext:SetTextColor(.5,.5,.5) |
self.lowtext:SetTextColor(.5,.5,.5) |
--self.valuetext:SetTextColor(.5,.5,.5) |
self.editbox:SetTextColor(.5,.5,.5) |
self.label:SetTextColor(.5, .5, .5) |
self.hightext:SetTextColor(.5, .5, .5) |
self.lowtext:SetTextColor(.5, .5, .5) |
--self.valuetext:SetTextColor(.5, .5, .5) |
self.editbox:SetTextColor(.5, .5, .5) |
self.editbox:EnableMouse(false) |
self.editbox:ClearFocus() |
else |
self.slider:EnableMouse(true) |
self.label:SetTextColor(1,.82,0) |
self.hightext:SetTextColor(1,1,1) |
self.lowtext:SetTextColor(1,1,1) |
--self.valuetext:SetTextColor(1,1,1) |
self.editbox:SetTextColor(1,1,1) |
self.label:SetTextColor(1, .82, 0) |
self.hightext:SetTextColor(1, 1, 1) |
self.lowtext:SetTextColor(1, 1, 1) |
--self.valuetext:SetTextColor(1, 1, 1) |
self.editbox:SetTextColor(1, 1, 1) |
self.editbox:EnableMouse(true) |
end |
end |
local function SetValue(self, value) |
end, |
["SetValue"] = function(self, value) |
self.slider.setup = true |
self.slider:SetValue(value) |
self.value = value |
UpdateText(self) |
self.slider.setup = nil |
end |
local function SetLabel(self, text) |
end, |
["GetValue"] = function(self) |
return self.value |
end, |
["SetLabel"] = function(self, text) |
self.label:SetText(text) |
end |
local function SetSliderValues(self, min, max, step) |
end, |
["SetSliderValues"] = function(self, min, max, step) |
local frame = self.slider |
frame.setup = true |
self.min = min |
frame:SetValue(self.value) |
end |
frame.setup = nil |
end |
local function EditBox_OnEscapePressed(this) |
this:ClearFocus() |
end |
local function EditBox_OnEnterPressed(this) |
local self = this.obj |
local value = this:GetText() |
if self.ispercent then |
value = value:gsub('%%','') |
value = tonumber(value) / 100 |
else |
value = tonumber(value) |
end |
if value then |
PlaySound("igMainMenuOptionCheckBoxOn") |
self:Fire("OnMouseUp",value) |
end |
end |
local function EditBox_OnEnter(this) |
this:SetBackdropBorderColor(0.5,0.5,0.5,1) |
end |
local function EditBox_OnLeave(this) |
this:SetBackdropBorderColor(0.3,0.3,0.3,0.8) |
end |
local function SetIsPercent(self, value) |
end, |
["SetIsPercent"] = function(self, value) |
self.ispercent = value |
UpdateLabels(self) |
UpdateText(self) |
end |
local function FrameOnMouseDown(this) |
this.obj.slider:EnableMouseWheel(true) |
AceGUI:ClearFocus() |
end |
local SliderBackdrop = { |
bgFile = "Interface\\Buttons\\UI-SliderBar-Background", |
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", |
tile = true, tileSize = 8, edgeSize = 8, |
insets = { left = 3, right = 3, top = 6, bottom = 6 } |
} |
local ManualBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", |
tile = true, edgeSize = 1, tileSize = 5, |
} |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = Type |
} |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
frame.obj = self |
self.SetDisabled = SetDisabled |
self.SetValue = SetValue |
self.SetSliderValues = SetSliderValues |
self.SetLabel = SetLabel |
self.SetIsPercent = SetIsPercent |
self.alignoffset = 25 |
frame:EnableMouse(true) |
frame:SetScript("OnMouseDown",FrameOnMouseDown) |
self.slider = CreateFrame("Slider",nil,frame) |
local slider = self.slider |
slider:SetScript("OnEnter",Control_OnEnter) |
slider:SetScript("OnLeave",Control_OnLeave) |
slider:SetScript("OnMouseUp", Slider_OnMouseUp) |
slider.obj = self |
slider:SetOrientation("HORIZONTAL") |
slider:SetHeight(15) |
slider:SetHitRectInsets(0,0,-10,0) |
slider:SetBackdrop(SliderBackdrop) |
--slider:EnableMouseWheel(true) |
slider:SetScript("OnMouseWheel", Slider_OnMouseWheel) |
local label = frame:CreateFontString(nil,"OVERLAY","GameFontNormal") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) |
label:SetJustifyH("CENTER") |
label:SetHeight(15) |
self.label = label |
self.lowtext = slider:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall") |
self.lowtext:SetPoint("TOPLEFT",slider,"BOTTOMLEFT",2,3) |
self.hightext = slider:CreateFontString(nil,"ARTWORK","GameFontHighlightSmall") |
self.hightext:SetPoint("TOPRIGHT",slider,"BOTTOMRIGHT",-2,3) |
local editbox = CreateFrame("EditBox",nil,frame) |
editbox:SetAutoFocus(false) |
editbox:SetFontObject(GameFontHighlightSmall) |
editbox:SetPoint("TOP",slider,"BOTTOM",0,0) |
editbox:SetHeight(14) |
editbox:SetWidth(70) |
editbox:SetJustifyH("CENTER") |
editbox:EnableMouse(true) |
editbox:SetScript("OnEscapePressed",EditBox_OnEscapePressed) |
editbox:SetScript("OnEnterPressed",EditBox_OnEnterPressed) |
editbox:SetScript("OnEnter",EditBox_OnEnter) |
editbox:SetScript("OnLeave",EditBox_OnLeave) |
editbox:SetBackdrop(ManualBackdrop) |
editbox:SetBackdropColor(0,0,0,0.5) |
editbox:SetBackdropBorderColor(0.3,0.3,0.30,0.80) |
self.editbox = editbox |
editbox.obj = self |
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") |
frame:SetWidth(200) |
frame:SetHeight(44) |
slider:SetPoint("TOP",label,"BOTTOM",0,0) |
slider:SetPoint("LEFT",frame,"LEFT",3,0) |
slider:SetPoint("RIGHT",frame,"RIGHT",-3,0) |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local SliderBackdrop = { |
bgFile = "Interface\\Buttons\\UI-SliderBar-Background", |
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", |
tile = true, tileSize = 8, edgeSize = 8, |
insets = { left = 3, right = 3, top = 6, bottom = 6 } |
} |
slider:SetValue(self.value or 0) |
slider:SetScript("OnValueChanged",Slider_OnValueChanged) |
AceGUI:RegisterAsWidget(self) |
return self |
local ManualBackdrop = { |
bgFile = "Interface\\ChatFrame\\ChatFrameBackground", |
edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", |
tile = true, edgeSize = 1, tileSize = 5, |
} |
local function Constructor() |
local frame = CreateFrame("Frame", nil, UIParent) |
frame:EnableMouse(true) |
frame:SetScript("OnMouseDown", Frame_OnMouseDown) |
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") |
label:SetPoint("TOPLEFT") |
label:SetPoint("TOPRIGHT") |
label:SetJustifyH("CENTER") |
label:SetHeight(15) |
local slider = CreateFrame("Slider", nil, frame) |
slider:SetOrientation("HORIZONTAL") |
slider:SetHeight(15) |
slider:SetHitRectInsets(0, 0, -10, 0) |
slider:SetBackdrop(SliderBackdrop) |
slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal") |
slider:SetPoint("TOP", label, "BOTTOM") |
slider:SetPoint("LEFT", 3, 0) |
slider:SetPoint("RIGHT", -3, 0) |
slider:SetValue(0) |
slider:SetScript("OnValueChanged",Slider_OnValueChanged) |
slider:SetScript("OnEnter", Control_OnEnter) |
slider:SetScript("OnLeave", Control_OnLeave) |
slider:SetScript("OnMouseUp", Slider_OnMouseUp) |
slider:SetScript("OnMouseWheel", Slider_OnMouseWheel) |
local lowtext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
lowtext:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 2, 3) |
local hightext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall") |
hightext:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3) |
local editbox = CreateFrame("EditBox", nil, frame) |
editbox:SetAutoFocus(false) |
editbox:SetFontObject(GameFontHighlightSmall) |
editbox:SetPoint("TOP", slider, "BOTTOM") |
editbox:SetHeight(14) |
editbox:SetWidth(70) |
editbox:SetJustifyH("CENTER") |
editbox:EnableMouse(true) |
editbox:SetBackdrop(ManualBackdrop) |
editbox:SetBackdropColor(0, 0, 0, 0.5) |
editbox:SetBackdropBorderColor(0.3, 0.3, 0.30, 0.80) |
editbox:SetScript("OnEnter", EditBox_OnEnter) |
editbox:SetScript("OnLeave", EditBox_OnLeave) |
editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed) |
editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed) |
local widget = { |
label = label, |
slider = slider, |
lowtext = lowtext, |
hightext = hightext, |
editbox = editbox, |
alignoffset = 25, |
frame = frame, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
slider.obj, editbox.obj = widget, widget |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
local AceGUI = LibStub("AceGUI-3.0") |
--[[----------------------------------------------------------------------------- |
Keybinding Widget |
Set Keybindings in the Config UI. |
-------------------------------------------------------------------------------]] |
local Type, Version = "Keybinding", 24 |
local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
-- Lua APIs |
local pairs = pairs |
-- WoW APIs |
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown |
-- List them here for Mikk's FindGlobals script |
-- GLOBALS: NOT_BOUND |
-------------------------- |
-- Keybinding -- |
-------------------------- |
local wowMoP |
do |
local Type = "Keybinding" |
local Version = 13 |
local _, _, _, interface = GetBuildInfo() |
wowMoP = (interface >= 50000) |
end |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 3, bottom = 3 } |
} |
--[[----------------------------------------------------------------------------- |
Scripts |
-------------------------------------------------------------------------------]] |
local function Control_OnEnter(this) |
this.obj:Fire("OnEnter") |
end |
local function Control_OnEnter(frame) |
frame.obj:Fire("OnEnter") |
end |
local function Control_OnLeave(this) |
this.obj:Fire("OnLeave") |
end |
local function keybindingMsgFixWidth(this) |
this:SetWidth(this.msg:GetWidth()+10) |
this:SetScript("OnUpdate",nil) |
end |
local function Control_OnLeave(frame) |
frame.obj:Fire("OnLeave") |
end |
local function Keybinding_OnClick(this, button) |
if button == "LeftButton" or button == "RightButton" then |
local self = this.obj |
if self.waitingForKey then |
this:EnableKeyboard(false) |
self.msgframe:Hide() |
this:UnlockHighlight() |
self.waitingForKey = nil |
else |
this:EnableKeyboard(true) |
self.msgframe:Show() |
this:LockHighlight() |
self.waitingForKey = true |
end |
local function Keybinding_OnClick(frame, button) |
if button == "LeftButton" or button == "RightButton" then |
local self = frame.obj |
if self.waitingForKey then |
frame:EnableKeyboard(false) |
self.msgframe:Hide() |
frame:UnlockHighlight() |
self.waitingForKey = nil |
else |
frame:EnableKeyboard(true) |
self.msgframe:Show() |
frame:LockHighlight() |
self.waitingForKey = true |
end |
AceGUI:ClearFocus() |
end |
AceGUI:ClearFocus() |
end |
local ignoreKeys = nil |
local function Keybinding_OnKeyDown(this, key) |
local self = this.obj |
if self.waitingForKey then |
local keyPressed = key |
if keyPressed == "ESCAPE" then |
keyPressed = "" |
else |
if not ignoreKeys then |
ignoreKeys = { |
["BUTTON1"] = true, ["BUTTON2"] = true, |
["UNKNOWN"] = true, |
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true, |
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true, |
} |
end |
if ignoreKeys[keyPressed] then return end |
if IsShiftKeyDown() then |
keyPressed = "SHIFT-"..keyPressed |
end |
if IsControlKeyDown() then |
keyPressed = "CTRL-"..keyPressed |
end |
if IsAltKeyDown() then |
keyPressed = "ALT-"..keyPressed |
end |
local ignoreKeys = { |
["BUTTON1"] = true, ["BUTTON2"] = true, |
["UNKNOWN"] = true, |
["LSHIFT"] = true, ["LCTRL"] = true, ["LALT"] = true, |
["RSHIFT"] = true, ["RCTRL"] = true, ["RALT"] = true, |
} |
local function Keybinding_OnKeyDown(frame, key) |
local self = frame.obj |
if self.waitingForKey then |
local keyPressed = key |
if keyPressed == "ESCAPE" then |
keyPressed = "" |
else |
if ignoreKeys[keyPressed] then return end |
if IsShiftKeyDown() then |
keyPressed = "SHIFT-"..keyPressed |
end |
this:EnableKeyboard(false) |
self.msgframe:Hide() |
this:UnlockHighlight() |
self.waitingForKey = nil |
if not self.disabled then |
self:SetKey(keyPressed) |
self:Fire("OnKeyChanged",keyPressed) |
if IsControlKeyDown() then |
keyPressed = "CTRL-"..keyPressed |
end |
if IsAltKeyDown() then |
keyPressed = "ALT-"..keyPressed |
end |
end |
end |
local function Keybinding_OnMouseDown(this, button) |
if button == "LeftButton" or button == "RightButton" then |
return |
elseif button == "MiddleButton" then |
button = "BUTTON3" |
elseif button == "Button4" then |
button = "BUTTON4" |
elseif button == "Button5" then |
button = "BUTTON5" |
frame:EnableKeyboard(false) |
self.msgframe:Hide() |
frame:UnlockHighlight() |
self.waitingForKey = nil |
if not self.disabled then |
self:SetKey(keyPressed) |
self:Fire("OnKeyChanged", keyPressed) |
end |
Keybinding_OnKeyDown(this, button) |
end |
local function OnAcquire(self) |
end |
local function Keybinding_OnMouseDown(frame, button) |
if button == "LeftButton" or button == "RightButton" then |
return |
elseif button == "MiddleButton" then |
button = "BUTTON3" |
elseif button == "Button4" then |
button = "BUTTON4" |
elseif button == "Button5" then |
button = "BUTTON5" |
end |
Keybinding_OnKeyDown(frame, button) |
end |
--[[----------------------------------------------------------------------------- |
Methods |
-------------------------------------------------------------------------------]] |
local methods = { |
["OnAcquire"] = function(self) |
self:SetWidth(200) |
self:SetHeight(44) |
self:SetLabel("") |
self:SetKey("") |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
self.waitingForKey = nil |
self.msgframe:Hide() |
self:SetDisabled(false) |
end |
local function SetDisabled(self, disabled) |
self.button:EnableKeyboard(false) |
end, |
-- ["OnRelease"] = nil, |
["SetDisabled"] = function(self, disabled) |
self.disabled = disabled |
if disabled then |
self.button:Disable() |
self.button:Enable() |
self.label:SetTextColor(1,1,1) |
end |
end |
local function SetKey(self, key) |
end, |
["SetKey"] = function(self, key) |
if (key or "") == "" then |
self.button:SetText(NOT_BOUND) |
self.button:SetNormalFontObject("GameFontNormal") |
self.button:SetText(key) |
self.button:SetNormalFontObject("GameFontHighlight") |
end |
end |
local function SetLabel(self, label) |
end, |
["GetKey"] = function(self) |
local key = self.button:GetText() |
if key == NOT_BOUND then |
key = nil |
end |
return key |
end, |
["SetLabel"] = function(self, label) |
self.label:SetText(label or "") |
if (label or "") == "" then |
self.alignoffset = nil |
self.alignoffset = 30 |
self:SetHeight(44) |
end |
end |
end, |
} |
local function Constructor() |
local num = AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame",nil,UIParent) |
local button = CreateFrame("Button","AceGUI-3.0 KeybindingButton"..num,frame,"UIPanelButtonTemplate2") |
local self = {} |
self.type = Type |
self.num = num |
--[[----------------------------------------------------------------------------- |
Constructor |
-------------------------------------------------------------------------------]] |
local text = button:GetFontString() |
text:SetPoint("LEFT",button,"LEFT",7,0) |
text:SetPoint("RIGHT",button,"RIGHT",-7,0) |
button:SetScript("OnClick",Keybinding_OnClick) |
button:SetScript("OnKeyDown",Keybinding_OnKeyDown) |
button:SetScript("OnEnter",Control_OnEnter) |
button:SetScript("OnLeave",Control_OnLeave) |
button:SetScript("OnMouseDown",Keybinding_OnMouseDown) |
button:RegisterForClicks("AnyDown") |
button:EnableMouse() |
button:SetHeight(24) |
button:SetWidth(200) |
button:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0) |
button:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) |
frame:SetWidth(200) |
frame:SetHeight(44) |
self.alignoffset = 30 |
self.button = button |
local label = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight") |
label:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) |
label:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0) |
label:SetJustifyH("CENTER") |
label:SetHeight(18) |
self.label = label |
local msgframe = CreateFrame("Frame",nil,UIParent) |
msgframe:SetHeight(30) |
msgframe:SetBackdrop(ControlBackdrop) |
msgframe:SetBackdropColor(0,0,0) |
msgframe:SetFrameStrata("FULLSCREEN_DIALOG") |
msgframe:SetFrameLevel(1000) |
self.msgframe = msgframe |
local msg = msgframe:CreateFontString(nil,"OVERLAY","GameFontNormal") |
msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel") |
msgframe.msg = msg |
msg:SetPoint("TOPLEFT",msgframe,"TOPLEFT",5,-5) |
msgframe:SetScript("OnUpdate", keybindingMsgFixWidth) |
msgframe:SetPoint("BOTTOM",button,"TOP",0,0) |
msgframe:Hide() |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.SetLabel = SetLabel |
self.SetDisabled = SetDisabled |
self.SetKey = SetKey |
self.frame = frame |
frame.obj = self |
button.obj = self |
local ControlBackdrop = { |
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", |
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
tile = true, tileSize = 16, edgeSize = 16, |
insets = { left = 3, right = 3, top = 3, bottom = 3 } |
} |
AceGUI:RegisterAsWidget(self) |
return self |
local function keybindingMsgFixWidth(frame) |
frame:SetWidth(frame.msg:GetWidth() + 10) |
frame:SetScript("OnUpdate", nil) |
end |
local function Constructor() |
local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type) |
local frame = CreateFrame("Frame", nil, UIParent) |
local button = CreateFrame("Button", name, frame, wowMoP and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2") |
button:EnableMouse(true) |
button:RegisterForClicks("AnyDown") |
button:SetScript("OnEnter", Control_OnEnter) |
button:SetScript("OnLeave", Control_OnLeave) |
button:SetScript("OnClick", Keybinding_OnClick) |
button:SetScript("OnKeyDown", Keybinding_OnKeyDown) |
button:SetScript("OnMouseDown", Keybinding_OnMouseDown) |
button:SetPoint("BOTTOMLEFT") |
button:SetPoint("BOTTOMRIGHT") |
button:SetHeight(24) |
button:EnableKeyboard(false) |
local text = button:GetFontString() |
text:SetPoint("LEFT", 7, 0) |
text:SetPoint("RIGHT", -7, 0) |
local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight") |
label:SetPoint("TOPLEFT") |
label:SetPoint("TOPRIGHT") |
label:SetJustifyH("CENTER") |
label:SetHeight(18) |
local msgframe = CreateFrame("Frame", nil, UIParent) |
msgframe:SetHeight(30) |
msgframe:SetBackdrop(ControlBackdrop) |
msgframe:SetBackdropColor(0,0,0) |
msgframe:SetFrameStrata("FULLSCREEN_DIALOG") |
msgframe:SetFrameLevel(1000) |
msgframe:SetToplevel(true) |
local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal") |
msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.") |
msgframe.msg = msg |
msg:SetPoint("TOPLEFT", 5, -5) |
msgframe:SetScript("OnUpdate", keybindingMsgFixWidth) |
msgframe:SetPoint("BOTTOM", button, "TOP") |
msgframe:Hide() |
local widget = { |
button = button, |
label = label, |
msgframe = msgframe, |
frame = frame, |
alignoffset = 30, |
type = Type |
} |
for method, func in pairs(methods) do |
widget[method] = func |
end |
AceGUI:RegisterWidgetType(Type,Constructor,Version) |
button.obj = widget |
return AceGUI:RegisterAsWidget(widget) |
end |
AceGUI:RegisterWidgetType(Type, Constructor, Version) |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Script file="AceGUI-3.0.lua"/> |
<!-- Container --> |
<Script file="widgets\AceGUIContainer-BlizOptionsGroup.lua"/> |
<Script file="widgets\AceGUIContainer-DropDownGroup.lua"/> |
<Script file="widgets\AceGUIContainer-Frame.lua"/> |
<Script file="widgets\AceGUIContainer-InlineGroup.lua"/> |
<Script file="widgets\AceGUIContainer-ScrollFrame.lua"/> |
<Script file="widgets\AceGUIContainer-SimpleGroup.lua"/> |
<Script file="widgets\AceGUIContainer-TabGroup.lua"/> |
<Script file="widgets\AceGUIContainer-TreeGroup.lua"/> |
<Script file="widgets\AceGUIContainer-Window.lua"/> |
<!-- Widgets --> |
<Script file="widgets\AceGUIWidget-Button.lua"/> |
<Script file="widgets\AceGUIWidget-CheckBox.lua"/> |
<Script file="widgets\AceGUIWidget-ColorPicker.lua"/> |
<Script file="widgets\AceGUIWidget-DropDownGroup.lua"/> |
<Script file="widgets\AceGUIWidget-DropDown.lua"/> |
<Script file="widgets\AceGUIWidget-DropDown-Items.lua"/> |
<Script file="widgets\AceGUIWidget-EditBox.lua"/> |
<Script file="widgets\AceGUIWidget-Frame.lua"/> |
<Script file="widgets\AceGUIWidget-Window.lua"/> |
<Script file="widgets\AceGUIWidget-Heading.lua"/> |
<Script file="widgets\AceGUIWidget-InlineGroup.lua"/> |
<Script file="widgets\AceGUIWidget-Keybinding.lua"/> |
<Script file="widgets\AceGUIWidget-ScrollFrame.lua"/> |
<Script file="widgets\AceGUIWidget-SimpleGroup.lua"/> |
<Script file="widgets\AceGUIWidget-Slider.lua"/> |
<Script file="widgets\AceGUIWidget-TabGroup.lua"/> |
<Script file="widgets\AceGUIWidget-TreeGroup.lua"/> |
<Script file="widgets\AceGUIWidget-Heading.lua"/> |
<Script file="widgets\AceGUIWidget-Icon.lua"/> |
<Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/> |
<Script file="widgets\AceGUIWidget-Keybinding.lua"/> |
<Script file="widgets\AceGUIWidget-Label.lua"/> |
<Script file="widgets\AceGUIWidget-MultiLineEditBox.lua"/> |
<Script file="widgets\AceGUIWidget-BlizOptionsGroup.lua"/> |
<Script file="widgets\AceGUIWidget-InteractiveLabel.lua"/> |
<Script file="widgets\AceGUIWidget-Icon.lua"/> |
</Ui> |
-- |
-- **Note**: When using AceGUI-3.0 directly, please do not modify the frames of the widgets directly, |
-- as any "unknown" change to the widgets will cause addons that get your widget out of the widget pool |
-- to misbehave. If you think some part of a widget should be modifiable, please open a ticket, and we'll |
-- to misbehave. If you think some part of a widget should be modifiable, please open a ticket, and we"ll |
-- implement a proper API to modify it. |
-- @usage |
-- local AceGUI = LibStub("AceGUI-3.0") |
-- f:AddChild(btn) |
-- @class file |
-- @name AceGUI-3.0 |
-- @release $Id: AceGUI-3.0.lua 896 2009-12-06 16:29:49Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 30 |
-- @release $Id: AceGUI-3.0.lua 924 2010-05-13 15:12:20Z nevcairiel $ |
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 33 |
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR) |
if not AceGUI then return end -- No upgrade needed |
end |
local function safecall(func, ...) |
return Dispatchers[select('#', ...)](func, ...) |
return Dispatchers[select("#", ...)](func, ...) |
end |
-- Recycling functions |
if WidgetRegistry[type] then |
local widget = newWidget(type) |
if rawget(widget,'Acquire') then |
if rawget(widget, "Acquire") then |
widget.OnAcquire = widget.Acquire |
widget.Acquire = nil |
elseif rawget(widget,'Aquire') then |
elseif rawget(widget, "Aquire") then |
widget.OnAcquire = widget.Aquire |
widget.Aquire = nil |
end |
if rawget(widget,'Release') then |
widget.OnRelease = rawget(widget,'Release') |
if rawget(widget, "Release") then |
widget.OnRelease = rawget(widget, "Release") |
widget.Release = nil |
end |
else |
error(("Widget type %s doesn't supply an OnAcquire Function"):format(type)) |
end |
-- Set the default Layout ('List') |
safecall(widget.SetLayout, widget, 'List') |
-- Set the default Layout ("List") |
safecall(widget.SetLayout, widget, "List") |
safecall(widget.ResumeLayout, widget) |
return widget |
end |
-- If this widget is a Container-Widget, all of its Child-Widgets will be releases as well. |
-- @param widget The widget to release |
function AceGUI:Release(widget) |
safecall( widget.PauseLayout, widget ) |
safecall(widget.PauseLayout, widget) |
widget:Fire("OnRelease") |
safecall( widget.ReleaseChildren, widget ) |
safecall(widget.ReleaseChildren, widget) |
if widget.OnRelease then |
widget:OnRelease() |
else |
error(("Widget type %s doesn't supply an OnRelease Function"):format(type)) |
-- else |
-- error(("Widget type %s doesn't supply an OnRelease Function"):format(widget.type)) |
end |
for k in pairs(widget.userdata) do |
widget.userdata[k] = nil |
--[[ |
Widgets must provide the following functions |
OnAcquire() - Called when the object is acquired, should set everything to a default hidden state |
OnRelease() - Called when the object is Released, should remove any anchors and hide the Widget |
And the following members |
frame - the frame or derivitive object that will be treated as the widget for size and anchoring purposes |
content - frame or derivitive that children will be anchored to |
The Widget can supply the following Optional Members |
:OnRelease() - Called when the object is Released, should remove any additional anchors and clear any data |
:OnWidthSet(width) - Called when the width of the widget is changed |
:OnHeightSet(height) - Called when the height of the widget is changed |
Widgets should not use the OnSizeChanged events of thier frame or content members, use these methods instead |
-- Widget Base Template -- |
-------------------------- |
do |
local function fixlevels(parent,...) |
local i = 1 |
local child = select(i, ...) |
while child do |
child:SetFrameLevel(parent:GetFrameLevel()+1) |
fixlevels(child, child:GetChildren()) |
i = i + 1 |
child = select(i, ...) |
end |
end |
local WidgetBase = AceGUI.WidgetBase |
WidgetBase.SetParent = function(self, parent) |
frame:SetParent(nil) |
frame:SetParent(parent.content) |
self.parent = parent |
--fixlevels(parent.frame,parent.frame:GetChildren()) |
end |
WidgetBase.SetCallback = function(self, name, func) |
if self.LayoutPaused then |
return |
end |
safecall(self.LayoutFunc,self.content, self.children) |
safecall(self.LayoutFunc, self.content, self.children) |
end |
--call this function to layout, makes sure layed out objects get a frame to get sizes etc |
end |
end |
setmetatable(WidgetContainerBase,{__index=WidgetBase}) |
setmetatable(WidgetContainerBase, {__index=WidgetBase}) |
--One of these function should be called on each Widget Instance as part of its creation process |
widget.base = WidgetContainerBase |
widget.content.obj = widget |
widget.frame.obj = widget |
widget.content:SetScript("OnSizeChanged",ContentResize) |
widget.frame:SetScript("OnSizeChanged",FrameResize) |
setmetatable(widget,{__index=WidgetContainerBase}) |
widget.content:SetScript("OnSizeChanged", ContentResize) |
widget.frame:SetScript("OnSizeChanged", FrameResize) |
setmetatable(widget, {__index = WidgetContainerBase}) |
widget:SetLayout("List") |
return widget |
end |
--- Register a widget-class as a widget. |
widget.events = {} |
widget.base = WidgetBase |
widget.frame.obj = widget |
widget.frame:SetScript("OnSizeChanged",FrameResize) |
setmetatable(widget,{__index=WidgetBase}) |
widget.frame:SetScript("OnSizeChanged", FrameResize) |
setmetatable(widget, {__index = WidgetBase}) |
return widget |
end |
end |
return self.counts[type] |
end |
--[[ Widget Template |
--- Return the number of created widgets for this type. |
-- In contrast to GetNextWidgetNum, the number is not incremented. |
-- @param type The widget type |
function AceGUI:GetWidgetCount(type) |
return self.counts[type] or 0 |
end |
-------------------------- |
-- Widget Name -- |
-------------------------- |
do |
local Type = "Type" |
local function OnAcquire(self) |
end |
local function OnRelease(self) |
self.frame:ClearAllPoints() |
self.frame:Hide() |
end |
local function Constructor() |
local frame = CreateFrame("Frame",nil,UIParent) |
local self = {} |
self.type = Type |
self.OnRelease = OnRelease |
self.OnAcquire = OnAcquire |
self.frame = frame |
frame.obj = self |
--Container Support |
--local content = CreateFrame("Frame",nil,frame) |
--self.content = content |
--AceGUI:RegisterAsContainer(self) |
AceGUI:RegisterAsWidget(self) |
return self |
end |
AceGUI:RegisterWidgetType(Type,Constructor) |
--- Return the version of the currently registered widget type. |
-- @param type The widget type |
function AceGUI:GetWidgetVersion(type) |
return WidgetVersions[type] |
end |
]] |
------------- |
-- Layouts -- |
------------- |
A Layout is a func that takes 2 parameters |
content - the frame that widgets will be placed inside |
children - a table containing the widgets to layout |
]] |
-- Very simple Layout, Children are stacked on top of each other down the left side |
AceGUI:RegisterLayout("List", |
function(content, children) |
local height = 0 |
local width = content.width or content:GetWidth() or 0 |
function(content, children) |
local height = 0 |
local width = content.width or content:GetWidth() or 0 |
for i = 1, #children do |
local child = children[i] |
frame:ClearAllPoints() |
frame:Show() |
if i == 1 then |
frame:SetPoint("TOPLEFT",content,"TOPLEFT",0,0) |
frame:SetPoint("TOPLEFT", content) |
else |
frame:SetPoint("TOPLEFT",children[i-1].frame,"BOTTOMLEFT",0,0) |
frame:SetPoint("TOPLEFT", children[i-1].frame, "BOTTOMLEFT") |
end |
if child.width == "fill" then |
child:SetWidth(width) |
frame:SetPoint("RIGHT",content,"RIGHT") |
if child.OnWidthSet then |
child:OnWidthSet(content.width or content:GetWidth()) |
end |
frame:SetPoint("RIGHT", content) |
if child.DoLayout then |
child:DoLayout() |
end |
elseif child.width == "relative" then |
child:SetWidth(width * child.relWidth) |
if child.OnWidthSet then |
child:OnWidthSet(content.width or content:GetWidth()) |
end |
if child.DoLayout then |
child:DoLayout() |
end |
height = height + (frame.height or frame:GetHeight() or 0) |
end |
safecall( content.obj.LayoutFinished, content.obj, nil, height ) |
end |
) |
safecall(content.obj.LayoutFinished, content.obj, nil, height) |
end) |
-- A single control fills the whole content area |
AceGUI:RegisterLayout("Fill", |
function(content, children) |
function(content, children) |
if children[1] then |
children[1]:SetWidth(content:GetWidth() or 0) |
children[1]:SetHeight(content:GetHeight() or 0) |
children[1].frame:SetAllPoints(content) |
children[1].frame:Show() |
safecall( content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight() ) |
safecall(content.obj.LayoutFinished, content.obj, nil, children[1].frame:GetHeight()) |
end |
end |
) |
AceGUI:RegisterLayout("Flow", |
function(content, children) |
--used height so far |
local height = 0 |
--width used in the current row |
local usedwidth = 0 |
--height of the current row |
local rowheight = 0 |
local rowoffset = 0 |
local lastrowoffset |
end) |
local width = content.width or content:GetWidth() or 0 |
--control at the start of the row |
local rowstart |
AceGUI:RegisterLayout("Flow", |
function(content, children) |
--used height so far |
local height = 0 |
--width used in the current row |
local usedwidth = 0 |
--height of the current row |
local rowheight = 0 |
local rowoffset = 0 |
local lastrowoffset |
local width = content.width or content:GetWidth() or 0 |
--control at the start of the row |
local rowstart |
local rowstartoffset |
local lastrowstart |
local isfullheight |
local frameoffset |
local lastframeoffset |
local oversize |
local lastrowstart |
local isfullheight |
local frameoffset |
local lastframeoffset |
local oversize |
for i = 1, #children do |
local child = children[i] |
oversize = nil |
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) |
rowheight = frameheight |
rowoffset = frameoffset |
rowstart = frame |
break |
end |
--anchor the previous row, we will now know its height and offset |
rowstart:SetPoint("TOPLEFT",content,"TOPLEFT",0,-(height+(rowoffset-rowstartoffset)+3)) |
rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -(height + (rowoffset - rowstartoffset) + 3)) |
height = height + rowheight + 3 |
--save this as the rowstart so we can anchor it after the row is complete and we have the max height and offset of controls in it |
rowstart = frame |
--offset is always the larger of the two offsets |
rowoffset = math_max(rowoffset, frameoffset) |
rowheight = math_max(rowheight, rowoffset + (frameheight / 2)) |
rowheight = math_max(rowheight,rowoffset+(frameheight/2)) |
--print("type:", child.type, "offset:",frameoffset-lastframeoffset) |
frame:SetPoint("TOPLEFT",children[i-1].frame,"TOPRIGHT",0,frameoffset-lastframeoffset) |
frame:SetPoint("TOPLEFT", children[i-1].frame, "TOPRIGHT", 0, frameoffset - lastframeoffset) |
usedwidth = framewidth + usedwidth |
end |
end |
if child.width == "fill" then |
child:SetWidth(width) |
frame:SetPoint("RIGHT",content,"RIGHT",0,0) |
frame:SetPoint("RIGHT", content) |
usedwidth = 0 |
rowstart = frame |
rowstartoffset = frameoffset |
if child.OnWidthSet then |
child:OnWidthSet(width) |
end |
if child.DoLayout then |
child:DoLayout() |
end |
elseif child.width == "relative" then |
child:SetWidth(width * child.relWidth) |
if child.OnWidthSet then |
child:OnWidthSet(width) |
end |
if child.DoLayout then |
child:DoLayout() |
end |
elseif oversize then |
if width > 1 then |
frame:SetPoint("RIGHT",content,"RIGHT",0,0) |
frame:SetPoint("RIGHT", content) |
end |
end |
if child.height == "fill" then |
frame:SetPoint("BOTTOM",content,"BOTTOM") |
frame:SetPoint("BOTTOM", content) |
isfullheight = true |
end |
end |
--anchor the last row, if its full height needs a special case since its height has just been changed by the anchor |
if isfullheight then |
rowstart:SetPoint("TOPLEFT",content,"TOPLEFT",0,-height) |
rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -height) |
elseif rowstart then |
rowstart:SetPoint("TOPLEFT",content,"TOPLEFT",0,-(height+(rowoffset-rowstartoffset)+3)) |
rowstart:SetPoint("TOPLEFT", content, "TOPLEFT", 0, -(height + (rowoffset - rowstartoffset) + 3)) |
end |
height = height + rowheight + 3 |
safecall( content.obj.LayoutFinished, content.obj, nil, height ) |
end |
) |
safecall(content.obj.LayoutFinished, content.obj, nil, height) |
end) |
-- end |
-- @class file |
-- @name AceAddon-3.0.lua |
-- @release $Id: AceAddon-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $ |
-- @release $Id: AceAddon-3.0.lua 1036 2011-08-16 22:45:05Z nevcairiel $ |
local MAJOR, MINOR = "AceAddon-3.0", 5 |
local MAJOR, MINOR = "AceAddon-3.0", 11 |
local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceAddon then return end -- No Upgrade needed. |
setmetatable( object, addonmeta ) |
self.addons[name] = object |
object.modules = {} |
object.orderedModules = {} |
object.defaultModuleLibraries = {} |
Embed( object ) -- embed NewModule, GetModule methods |
self:EmbedLibraries(object, select(i,...)) |
safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy. |
self.modules[name] = module |
tinsert(self.orderedModules, module) |
return module |
end |
-- target (object) - target object to embed aceaddon in |
-- |
-- this is a local function specifically since it's meant to be only called internally |
function Embed(target) |
function Embed(target, skipPMixins) |
for k, v in pairs(mixins) do |
target[k] = v |
end |
for k, v in pairs(pmixins) do |
target[k] = target[k] or v |
if not skipPMixins then |
for k, v in pairs(pmixins) do |
target[k] = target[k] or v |
end |
end |
end |
end |
-- enable possible modules. |
for name, module in pairs(addon.modules) do |
self:EnableAddon(module) |
local modules = addon.orderedModules |
for i = 1, #modules do |
self:EnableAddon(modules[i]) |
end |
end |
return self.statuses[addon.name] -- return true if we're disabled |
if lib then safecall(lib.OnEmbedDisable, lib, addon) end |
end |
-- disable possible modules. |
for name, module in pairs(addon.modules) do |
self:DisableAddon(module) |
local modules = addon.orderedModules |
for i = 1, #modules do |
self:DisableAddon(modules[i]) |
end |
end |
-- Event Handling |
local function onEvent(this, event, arg1) |
if event == "ADDON_LOADED" or event == "PLAYER_LOGIN" then |
-- 2011-08-17 nevcairiel - ignore the load event of Blizzard_DebugTools, so a potential startup error isn't swallowed up |
if (event == "ADDON_LOADED" and arg1 ~= "Blizzard_DebugTools") or event == "PLAYER_LOGIN" then |
-- if a addon loads another addon, recursion could happen here, so we need to validate the table on every iteration |
while(#AceAddon.initializequeue > 0) do |
local addon = tremove(AceAddon.initializequeue, 1) |
-- upgrade embeded |
for name, addon in pairs(AceAddon.addons) do |
Embed(addon) |
Embed(addon, true) |
end |
-- 2010-10-27 nevcairiel - add new "orderedModules" table |
if oldminor and oldminor < 10 then |
for name, addon in pairs(AceAddon.addons) do |
addon.orderedModules = {} |
for module_name, module in pairs(addon.modules) do |
tinsert(addon.orderedModules, module) |
end |
end |
end |
--- AceConfigCmd-3.0 handles access to an options table through the "command line" interface via the ChatFrames. |
-- @class file |
-- @name AceConfigCmd-3.0 |
-- @release $Id: AceConfigCmd-3.0.lua 904 2009-12-13 11:56:37Z nevcairiel $ |
-- @release $Id: AceConfigCmd-3.0.lua 1045 2011-12-09 17:58:40Z nevcairiel $ |
--[[ |
AceConfigCmd-3.0 |
-- TODO: plugin args |
local MAJOR, MINOR = "AceConfigCmd-3.0", 12 |
local MAJOR, MINOR = "AceConfigCmd-3.0", 13 |
local AceConfigCmd = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigCmd then return end |
local r, g, b, a |
if tab.hasAlpha then |
local hasAlpha = tab.hasAlpha |
if type(hasAlpha) == "function" or type(hasAlpha) == "string" then |
info.hasAlpha = hasAlpha |
hasAlpha = callmethod(info, inputpos, tab, 'hasAlpha') |
info.hasAlpha = nil |
end |
if hasAlpha then |
if str:len() == 8 and str:find("^%x*$") then |
--parse a hex string |
r,g,b,a = tonumber(str:sub(1, 2), 16) / 255, tonumber(str:sub(3, 4), 16) / 255, tonumber(str:sub(5, 6), 16) / 255, tonumber(str:sub(7, 8), 16) / 255 |
-- :IterateOptionsTables() (and :GetOptionsTable() if only given one argument) return a function reference that the requesting config handling addon must call with valid "uiType", "uiName". |
-- @class file |
-- @name AceConfigRegistry-3.0 |
-- @release $Id: AceConfigRegistry-3.0.lua 890 2009-12-06 12:50:05Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 11 |
-- @release $Id: AceConfigRegistry-3.0.lua 1045 2011-12-09 17:58:40Z nevcairiel $ |
local MAJOR, MINOR = "AceConfigRegistry-3.0", 14 |
local AceConfigRegistry = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigRegistry then return end |
}, |
range={ |
min=optnumber, |
softMin=optnumber, |
max=optnumber, |
softMax=optnumber, |
step=optnumber, |
bigStep=optnumber, |
isPercent=optbool, |
control=optstring, |
dialogControl=optstring, |
dropdownControl=optstring, |
itemControl=optstring, |
}, |
multiselect={ |
values=ismethodtable, |
dropdownControl=optstring, |
}, |
color={ |
hasAlpha=optbool, |
hasAlpha=optmethodbool, |
}, |
keybinding={ |
-- TODO |
-- as well as associate it with a slash command. |
-- @class file |
-- @name AceConfig-3.0 |
-- @release $Id: AceConfig-3.0.lua 877 2009-11-02 15:56:50Z nevcairiel $ |
-- @release $Id: AceConfig-3.0.lua 969 2010-10-07 02:11:48Z shefki $ |
--[[ |
AceConfig-3.0 |
local cfgreg = LibStub("AceConfigRegistry-3.0") |
local cfgcmd = LibStub("AceConfigCmd-3.0") |
local cfgdlg = LibStub("AceConfigDialog-3.0") |
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0") |
--TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true) |
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true) |
-- Lua APIs |
local pcall, error, type, pairs = pcall, error, type, pairs |
-- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly. |
-- @paramsig appName, options [, slashcmd] |
-- @param appName The application name for the config table. |
-- @param options The option table (or a function to generate one on demand) |
-- @param options The option table (or a function to generate one on demand). http://www.wowace.com/addons/ace3/pages/ace-config-3-0-options-tables/ |
-- @param slashcmd A slash command to register for the option table, or a table of slash commands. |
-- @usage |
-- local AceConfig = LibStub("AceConfig-3.0") |
--- AceConfigDialog-3.0 generates AceGUI-3.0 based windows based on option tables. |
-- @class file |
-- @name AceConfigDialog-3.0 |
-- @release $Id: AceConfigDialog-3.0.lua 913 2010-02-13 12:16:13Z nevcairiel $ |
-- @release $Id: AceConfigDialog-3.0.lua 1049 2012-04-02 13:22:10Z mikk $ |
local LibStub = LibStub |
local MAJOR, MINOR = "AceConfigDialog-3.0", 45 |
local MAJOR, MINOR = "AceConfigDialog-3.0", 57 |
local AceConfigDialog, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
if not AceConfigDialog then return end |
AceConfigDialog.frame.apps = AceConfigDialog.frame.apps or {} |
AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {} |
AceConfigDialog.frame.closeAllOverride = AceConfigDialog.frame.closeAllOverride or {} |
local gui = LibStub("AceGUI-3.0") |
local reg = LibStub("AceConfigRegistry-3.0") |
-- Lua APIs |
local tconcat, tinsert, tsort, tremove = table.concat, table.insert, table.sort, table.remove |
local tconcat, tinsert, tsort, tremove, tsort = table.concat, table.insert, table.sort, table.remove, table.sort |
local strmatch, format = string.match, string.format |
local assert, loadstring, error = assert, loadstring, error |
local pairs, next, select, type, unpack = pairs, next, select, type, unpack |
local rawset, tostring = rawset, tostring |
local pairs, next, select, type, unpack, wipe, ipairs = pairs, next, select, type, unpack, wipe, ipairs |
local rawset, tostring, tonumber = rawset, tostring, tonumber |
local math_min, math_max, math_floor = math.min, math.max, math.floor |
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded |
end |
local function safecall(func, ...) |
return Dispatchers[select('#', ...)](func, ...) |
return Dispatchers[select("#", ...)](func, ...) |
end |
local width_multiplier = 170 |
local new, del, copy |
--newcount, delcount,createdcount,cached = 0,0,0 |
do |
local pool = setmetatable({},{__mode='k'}) |
local pool = setmetatable({},{__mode="k"}) |
function new() |
--newcount = newcount + 1 |
local t = next(pool) |
end |
function del(t) |
--delcount = delcount + 1 |
for k in pairs(t) do |
t[k] = nil |
end |
wipe(t) |
pool[t] = true |
end |
-- function cached() |
info.handler = handler |
info.option = option |
info.type = option.type |
info.uiType = 'dialog' |
info.uiType = "dialog" |
info.uiName = MAJOR |
local a, b, c ,d |
end |
local OrderA, OrderB = tempOrders[a] or 100, tempOrders[b] or 100 |
if OrderA == OrderB then |
local NameA = (type(tempNames[a] == "string") and tempNames[a]) or "" |
local NameB = (type(tempNames[b] == "string") and tempNames[b]) or "" |
local NameA = (type(tempNames[a]) == "string") and tempNames[a] or "" |
local NameB = (type(tempNames[b]) == "string") and tempNames[b] or "" |
return NameA:upper() < NameB:upper() |
end |
if OrderA < 0 then |
if user.grouplist then |
del(user.grouplist) |
end |
if user.orderlist then |
del(user.orderlist) |
end |
end |
end |
local treevalue |
local treestatus |
for n = 1, select('#',...) do |
for n = 1, select("#",...) do |
local key = select(n, ...) |
if group.childGroups == "tab" or group.childGroups == "select" then |
GameTooltip:SetText(name, 1, .82, 0, 1) |
if opt.type == 'multiselect' then |
if opt.type == "multiselect" then |
GameTooltip:AddLine(user.text,0.5, 0.5, 0.8, 1) |
end |
if type(desc) == "string" then |
local function GetFuncName(option) |
local type = option.type |
if type == 'execute' then |
return 'func' |
if type == "execute" then |
return "func" |
else |
return 'set' |
return "set" |
end |
end |
local function confirmPopup(appName, rootframe, basepath, info, message, func, ...) |
t.text = message |
t.button1 = ACCEPT |
t.button2 = CANCEL |
t.preferredIndex = 3 |
local dialog, oldstrata |
t.OnAccept = function() |
safecall(func, unpack(t)) |
AceConfigDialog:Open(appName, rootframe, unpack(basepath or emptyTbl)) |
del(info) |
end |
for i = 1, select('#', ...) do |
for i = 1, select("#", ...) do |
t[i] = select(i, ...) or false |
end |
t.timeout = 0 |
info.handler = handler |
info.option = option |
info.type = option.type |
info.uiType = 'dialog' |
info.uiType = "dialog" |
info.uiName = MAJOR |
local name |
end |
end |
local iscustom = user.rootframe:GetUserData('iscustom') |
local iscustom = user.rootframe:GetUserData("iscustom") |
local rootframe |
if iscustom then |
rootframe = user.rootframe |
end |
local basepath = user.rootframe:GetUserData('basepath') |
local basepath = user.rootframe:GetUserData("basepath") |
if type(func) == "string" then |
if handler and handler[func] then |
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...) |
local iscustom = user.rootframe:GetUserData('iscustom') |
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl |
local iscustom = user.rootframe:GetUserData("iscustom") |
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl |
--full refresh of the frame, some controls dont cause this on all events |
if option.type == "color" then |
if event == "OnValueConfirmed" then |
end |
local function ActivateSlider(widget, event, value) |
local option = widget:GetUserData('option') |
local min, max, step = option.min or 0, option.max or 100, option.step |
if step then |
value = math_floor((value - min) / step + 0.5) * step + min |
local option = widget:GetUserData("option") |
local min, max, step = option.min or (not option.softMin and 0 or nil), option.max or (not option.softMax and 100 or nil), option.step |
if min then |
if step then |
value = math_floor((value - min) / step + 0.5) * step + min |
end |
value = math_max(value, min) |
end |
value = math_max(math_min(value,max),min) |
if max then |
value = math_min(value, max) |
end |
ActivateControl(widget,event,value) |
end |
--called from a checkbox that is part of an internally created multiselect group |
--this type is safe to refresh on activation of one control |
local function ActivateMultiControl(widget, event, ...) |
ActivateControl(widget, event, widget:GetUserData('value'), ...) |
ActivateControl(widget, event, widget:GetUserData("value"), ...) |
local user = widget:GetUserDataTable() |
local iscustom = user.rootframe:GetUserData('iscustom') |
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl |
local iscustom = user.rootframe:GetUserData("iscustom") |
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
local function MultiControlOnClosed(widget, event, ...) |
local user = widget:GetUserDataTable() |
if user.valuechanged then |
local iscustom = user.rootframe:GetUserData('iscustom') |
local basepath = user.rootframe:GetUserData('basepath') or emptyTbl |
local iscustom = user.rootframe:GetUserData("iscustom") |
local basepath = user.rootframe:GetUserData("basepath") or emptyTbl |
if iscustom then |
AceConfigDialog:Open(user.appName, user.rootframe, unpack(basepath)) |
else |
end |
local function FrameOnClose(widget, event) |
local appName = widget:GetUserData('appName') |
local appName = widget:GetUserData("appName") |
AceConfigDialog.OpenFrames[appName] = nil |
gui:Release(widget) |
end |
]] |
local function BuildSelect(group, options, path, appName) |
local groups = new() |
local order = new() |
local keySort = new() |
local opts = new() |
local hidden = CheckOptionHidden(v, options, path, appName) |
if not inline and not hidden then |
groups[k] = GetOptionsMemberValue("name", v, options, path, appName) |
tinsert(order, k) |
end |
path[#path] = nil |
end |
end |
del(opts) |
del(keySort) |
del(opts) |
return groups |
return groups, order |
end |
local function BuildSubGroups(group, tree, options, path, appName) |
local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) |
local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) |
if type(image) == 'string' then |
if type(image) == "string" then |
control = gui:Create("Icon") |
if not width then |
width = GetOptionsMemberValue("imageWidth",v, options, path, appName) |
if not height then |
height = GetOptionsMemberValue("imageHeight",v, options, path, appName) |
end |
if type(imageCoords) == 'table' then |
if type(imageCoords) == "table" then |
control:SetImage(image, unpack(imageCoords)) |
else |
control:SetImage(image) |
control = gui:Create(v.multiline and "MultiLineEditBox" or "EditBox") |
end |
if v.multiline then |
local lines = 4 |
if type(v.multiline) == "number" then |
lines = v.multiline |
end |
control:SetHeight(60 + (14*lines)) |
if v.multiline and control.SetNumLines then |
control:SetNumLines(tonumber(v.multiline) or 4) |
end |
control:SetLabel(name) |
control:SetCallback("OnEnterPressed",ActivateControl) |
local image = GetOptionsMemberValue("image", v, options, path, appName) |
local imageCoords = GetOptionsMemberValue("imageCoords", v, options, path, appName) |
if type(image) == 'string' then |
if type(imageCoords) == 'table' then |
if type(image) == "string" then |
if type(imageCoords) == "table" then |
control:SetImage(image, unpack(imageCoords)) |
else |
control:SetImage(image) |
elseif v.type == "range" then |
control = gui:Create("Slider") |
control:SetLabel(name) |
control:SetSliderValues(v.min or 0,v.max or 100, v.bigStep or v.step or 0) |
control:SetSliderValues(v.softMin or v.min or 0, v.softMax or v.max or 100, v.bigStep or v.step or 0) |
control:SetIsPercent(v.isPercent) |
local value = GetOptionsMemberValue("get",v, options, path, appName) |
if type(value) ~= "number" then |
elseif v.type == "select" then |
local values = GetOptionsMemberValue("values", v, options, path, appName) |
local controlType = v.dialogControl or v.control or "Dropdown" |
control = gui:Create(controlType) |
if not control then |
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType))) |
control = gui:Create("Dropdown") |
if v.style == "radio" then |
local disabled = CheckOptionDisabled(v, options, path, appName) |
local width = GetOptionsMemberValue("width",v,options,path,appName) |
control = gui:Create("InlineGroup") |
control:SetLayout("Flow") |
control:SetTitle(name) |
control.width = "fill" |
control:PauseLayout() |
local optionValue = GetOptionsMemberValue("get",v, options, path, appName) |
local t = {} |
for value, text in pairs(values) do |
t[#t+1]=value |
end |
tsort(t) |
for k, value in ipairs(t) do |
local text = values[value] |
local radio = gui:Create("CheckBox") |
radio:SetLabel(text) |
radio:SetUserData("value", value) |
radio:SetUserData("text", text) |
radio:SetDisabled(disabled) |
radio:SetType("radio") |
radio:SetValue(optionValue == value) |
radio:SetCallback("OnValueChanged", ActivateMultiControl) |
InjectInfo(radio, options, v, path, rootframe, appName) |
control:AddChild(radio) |
if width == "double" then |
radio:SetWidth(width_multiplier * 2) |
elseif width == "half" then |
radio:SetWidth(width_multiplier / 2) |
elseif width == "full" then |
radio.width = "fill" |
else |
radio:SetWidth(width_multiplier) |
end |
end |
control:ResumeLayout() |
control:DoLayout() |
else |
local controlType = v.dialogControl or v.control or "Dropdown" |
control = gui:Create(controlType) |
if not control then |
geterrorhandler()(("Invalid Custom Control Type - %s"):format(tostring(controlType))) |
control = gui:Create("Dropdown") |
end |
local itemType = v.itemControl |
if itemType and not gui:GetWidgetVersion(itemType) then |
geterrorhandler()(("Invalid Custom Item Type - %s"):format(tostring(itemType))) |
itemType = nil |
end |
control:SetLabel(name) |
control:SetList(values, nil, itemType) |
local value = GetOptionsMemberValue("get",v, options, path, appName) |
if not values[value] then |
value = nil |
end |
control:SetValue(value) |
control:SetCallback("OnValueChanged", ActivateControl) |
end |
control:SetLabel(name) |
control:SetList(values) |
local value = GetOptionsMemberValue("get",v, options, path, appName) |
if not values[value] then |
value = nil |
end |
control:SetValue(value) |
control:SetCallback("OnValueChanged",ActivateControl) |
elseif v.type == "multiselect" then |
local values = GetOptionsMemberValue("values", v, options, path, appName) |
local text = values[value] |
local check = gui:Create("CheckBox") |
check:SetLabel(text) |
check:SetUserData('value', value) |
check:SetUserData('text', text) |
check:SetUserData("value", value) |
check:SetUserData("text", text) |
check:SetDisabled(disabled) |
check:SetTriState(v.tristate) |
check:SetValue(GetOptionsMemberValue("get",v, options, path, appName, value)) |
elseif v.type == "color" then |
control = gui:Create("ColorPicker") |
control:SetLabel(name) |
control:SetHasAlpha(v.hasAlpha) |
control:SetHasAlpha(GetOptionsMemberValue("hasAlpha",v, options, path, appName)) |
control:SetColor(GetOptionsMemberValue("get",v, options, path, appName)) |
control:SetCallback("OnValueChanged",ActivateControl) |
control:SetCallback("OnValueConfirmed",ActivateControl) |
local imageCoords = GetOptionsMemberValue("imageCoords",v, options, path, appName) |
local image, width, height = GetOptionsMemberValue("image",v, options, path, appName) |
if type(image) == 'string' then |
if type(image) == "string" then |
if not width then |
width = GetOptionsMemberValue("imageWidth",v, options, path, appName) |
end |
if not height then |
height = GetOptionsMemberValue("imageHeight",v, options, path, appName) |
end |
if type(imageCoords) == 'table' then |
if type(imageCoords) == "table" then |
control:SetImage(image, unpack(imageCoords)) |
else |
control:SetImage(image) |
end |
local function BuildPath(path, ...) |
for i = 1, select('#',...) do |
for i = 1, select("#",...) do |
tinsert(path, (select(i,...))) |
end |
end |
local grouptype, parenttype = options.childGroups, "none" |
--temp path table to pass to callbacks as we traverse the tree |
local temppath = new() |
for i = 1, #path do |
local v = path[i] |
temppath[i] = v |
group = GetSubOption(group, v) |
inline = inline or pickfirstset(v.dialogInline,v.guiInline,v.inline, false) |
parenttype = grouptype |
grouptype = group.childGroups |
end |
del(temppath) |
if not parenttype then |
parenttype = "tree" |
status.groups = {} |
end |
select:SetStatusTable(status.groups) |
local grouplist = BuildSelect(group, options, path, appName) |
select:SetGroupList(grouplist) |
local grouplist, orderlist = BuildSelect(group, options, path, appName) |
select:SetGroupList(grouplist, orderlist) |
select:SetUserData("grouplist", grouplist) |
local firstgroup |
for k, v in pairs(grouplist) do |
if not firstgroup or k < firstgroup then |
firstgroup = k |
end |
end |
select:SetUserData("orderlist", orderlist) |
local firstgroup = orderlist[1] |
if firstgroup then |
select:SetGroup((GroupExists(appName, options, path,status.groups.selected) and status.groups.selected) or firstgroup) |
end |
if this.closeAll then |
for k, v in pairs(AceConfigDialog.OpenFrames) do |
v:Hide() |
if not this.closeAllOverride[k] then |
v:Hide() |
end |
end |
this.closeAll = nil |
wipe(this.closeAllOverride) |
end |
for appName in pairs(this.apps) do |
for key, widget in pairs(AceConfigDialog.BlizOptions[appName]) do |
local user = widget:GetUserDataTable() |
if widget:IsVisible() then |
AceConfigDialog:Open(widget:GetUserData('appName'), widget, unpack(user.basepath or emptyTbl)) |
AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(user.basepath or emptyTbl)) |
end |
end |
end |
tinsert(path, container) |
container = nil |
end |
for n = 1, select('#',...) do |
for n = 1, select("#",...) do |
tinsert(path, (select(n, ...))) |
end |
if container then |
f = container |
f:ReleaseChildren() |
f:SetUserData('appName', appName) |
f:SetUserData('iscustom', true) |
f:SetUserData("appName", appName) |
f:SetUserData("iscustom", true) |
if #path > 0 then |
f:SetUserData('basepath', copy(path)) |
f:SetUserData("basepath", copy(path)) |
end |
local status = AceConfigDialog:GetStatusTable(appName) |
if not status.width then |
end |
f:ReleaseChildren() |
f:SetCallback("OnClose", FrameOnClose) |
f:SetUserData('appName', appName) |
f:SetUserData("appName", appName) |
if #path > 0 then |
f:SetUserData('basepath', copy(path)) |
f:SetUserData("basepath", copy(path)) |
end |
f:SetTitle(name or "") |
local status = AceConfigDialog:GetStatusTable(appName) |
f:Show() |
end |
del(path) |
if AceConfigDialog.frame.closeAll then |
-- close all is set, but thats not good, since we're just opening here, so force it |
AceConfigDialog.frame.closeAllOverride[appName] = true |
end |
end |
-- convert pre-39 BlizOptions structure to the new format |
local old = AceConfigDialog.BlizOptions |
local new = {} |
for key, widget in pairs(old) do |
local appName = widget:GetUserData('appName') |
local appName = widget:GetUserData("appName") |
if not new[appName] then new[appName] = {} end |
new[appName][key] = widget |
end |
end |
local function FeedToBlizPanel(widget, event) |
local path = widget:GetUserData('path') |
AceConfigDialog:Open(widget:GetUserData('appName'), widget, unpack(path or emptyTbl)) |
local path = widget:GetUserData("path") |
AceConfigDialog:Open(widget:GetUserData("appName"), widget, unpack(path or emptyTbl)) |
end |
local function ClearBlizPanel(widget, event) |
local appName = widget:GetUserData('appName') |
local appName = widget:GetUserData("appName") |
AceConfigDialog.frame.closing[appName] = true |
AceConfigDialog.frame:SetScript("OnUpdate", RefreshOnUpdate) |
end |
local BlizOptions = AceConfigDialog.BlizOptions |
local key = appName |
for n = 1, select('#', ...) do |
key = key..'\001'..select(n, ...) |
for n = 1, select("#", ...) do |
key = key.."\001"..select(n, ...) |
end |
if not BlizOptions[appName] then |
group:SetName(name or appName, parent) |
group:SetTitle(name or appName) |
group:SetUserData('appName', appName) |
if select('#', ...) > 0 then |
group:SetUserData("appName", appName) |
if select("#", ...) > 0 then |
local path = {} |
for n = 1, select('#',...) do |
for n = 1, select("#",...) do |
tinsert(path, (select(n, ...))) |
end |
group:SetUserData('path', path) |
group:SetUserData("path", path) |
end |
group:SetCallback("OnShow", FeedToBlizPanel) |
group:SetCallback("OnHide", ClearBlizPanel) |
-- end |
-- @class file |
-- @name AceDB-3.0.lua |
-- @release $Id: AceDB-3.0.lua 914 2010-03-08 12:09:22Z nevcairiel $ |
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 20 |
-- @release $Id: AceDB-3.0.lua 1035 2011-07-09 03:20:13Z kaelten $ |
local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 22 |
local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR) |
if not AceDB then return end -- No upgrade needed |
local _, raceKey = UnitRace("player") |
local factionKey = UnitFactionGroup("player") |
local factionrealmKey = factionKey .. " - " .. realmKey |
local factionrealmregionKey = factionrealmKey .. " - " .. string.sub(GetCVar("realmList"), 1, 2):upper() |
local localeKey = GetLocale():lower() |
-- Actual database initialization function |
local function initdb(sv, defaults, defaultProfile, olddb, parent) |
-- Generate the database keys for each section |
["race"] = raceKey, |
["faction"] = factionKey, |
["factionrealm"] = factionrealmKey, |
["factionrealmregion"] = factionrealmregionKey, |
["profile"] = profileKey, |
["locale"] = localeKey, |
["global"] = true, |
["profiles"] = true, |
} |
for db in pairs(AceDB.db_registry) do |
db.callbacks:Fire("OnDatabaseShutdown", db) |
db:RegisterDefaults(nil) |
-- cleanup sections that are empty without defaults |
local sv = rawget(db, "sv") |
for section in pairs(db.keys) do |
error("Cannot delete the active profile in an AceDBObject.", 2) |
end |
if not rawget(self.sv.profiles, name) and not silent then |
if not rawget(self.profiles, name) and not silent then |
error("Cannot delete profile '" .. name .. "'. It does not exist.", 2) |
end |
self.sv.profiles[name] = nil |
self.profiles[name] = nil |
-- populate to child namespaces |
if self.children then |
error("Cannot have the same source and destination profiles.", 2) |
end |
if not rawget(self.sv.profiles, name) and not silent then |
if not rawget(self.profiles, name) and not silent then |
error("Cannot copy profile '" .. name .. "'. It does not exist.", 2) |
end |
DBObjectLib.ResetProfile(self, nil, true) |
local profile = self.profile |
local source = self.sv.profiles[name] |
local source = self.profiles[name] |
copyTable(source, profile) |