├── .docmeta
├── .gitignore
├── .gitmodules
├── .pkgmeta
├── Ace3.lua
├── Ace3.toc
├── AceAddon-3.0
├── AceAddon-3.0.lua
└── AceAddon-3.0.xml
├── AceBucket-3.0
├── AceBucket-3.0.lua
└── AceBucket-3.0.xml
├── AceComm-3.0
├── AceComm-3.0.lua
├── AceComm-3.0.xml
└── ChatThrottleLib.lua
├── AceConfig-3.0
├── AceConfig-3.0.lua
├── AceConfig-3.0.xml
├── AceConfigCmd-3.0
│ ├── AceConfigCmd-3.0.lua
│ └── AceConfigCmd-3.0.xml
├── AceConfigDialog-3.0
│ ├── AceConfigDialog-3.0.lua
│ └── AceConfigDialog-3.0.xml
└── AceConfigRegistry-3.0
│ ├── AceConfigRegistry-3.0.lua
│ └── AceConfigRegistry-3.0.xml
├── AceConsole-3.0
├── AceConsole-3.0.lua
└── AceConsole-3.0.xml
├── AceCore-3.0
├── AceCore-3.0.lua
└── AceCore-3.0.xml
├── AceCursor-3.0
├── AceCursor-3.0.lua
└── AceCursor-3.0.xml
├── AceDB-3.0
├── AceDB-3.0.lua
└── AceDB-3.0.xml
├── AceDBOptions-3.0
├── AceDBOptions-3.0.lua
└── AceDBOptions-3.0.xml
├── AceEvent-3.0
├── AceEvent-3.0.lua
└── AceEvent-3.0.xml
├── AceGUI-3.0
├── AceGUI-3.0.lua
├── AceGUI-3.0.xml
└── widgets
│ ├── AceGUIContainer-BlizOptionsGroup.lua
│ ├── AceGUIContainer-DropDownGroup.lua
│ ├── AceGUIContainer-Frame.lua
│ ├── AceGUIContainer-InlineGroup.lua
│ ├── AceGUIContainer-ScrollFrame.lua
│ ├── AceGUIContainer-SimpleGroup.lua
│ ├── AceGUIContainer-TabGroup.lua
│ ├── AceGUIContainer-TreeGroup.lua
│ ├── AceGUIContainer-Window.lua
│ ├── AceGUIWidget-Button.lua
│ ├── AceGUIWidget-CheckBox.lua
│ ├── AceGUIWidget-ColorPicker.lua
│ ├── AceGUIWidget-DropDown-Items.lua
│ ├── AceGUIWidget-DropDown.lua
│ ├── AceGUIWidget-EditBox.lua
│ ├── AceGUIWidget-Heading.lua
│ ├── AceGUIWidget-Icon.lua
│ ├── AceGUIWidget-InteractiveLabel.lua
│ ├── AceGUIWidget-Keybinding.lua
│ ├── AceGUIWidget-Label.lua
│ ├── AceGUIWidget-MultiLineEditBox.lua
│ ├── AceGUIWidget-Slider.lua
│ └── widgets.xml
├── AceHook-3.0
├── AceHook-3.0.lua
└── AceHook-3.0.xml
├── AceLocale-3.0
├── AceLocale-3.0.lua
└── AceLocale-3.0.xml
├── AceLocale-3.1
├── AceLocale-3.1.lua
└── AceLocale-3.1.xml
├── AceSerializer-3.0
├── AceSerializer-3.0.lua
└── AceSerializer-3.0.xml
├── AceTab-3.0
├── AceTab-3.0.lua
└── AceTab-3.0.xml
├── AceTimer-3.0
├── AceTimer-3.0.lua
└── AceTimer-3.0.xml
├── Bindings.xml
├── LICENSE.txt
├── README.md
└── changelog.txt
/.docmeta:
--------------------------------------------------------------------------------
1 | -
2 | type: luadoc
3 | input-files:
4 | - "Ace*/Ace*.lua"
5 | - "AceConfig-3.0/AceConfig*/AceConfig*.lua"
6 | output-directory: API
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Lua sources
2 | luac.out
3 |
4 | # luarocks build files
5 | *.src.rock
6 | *.zip
7 | *.tar.gz
8 |
9 | # Object files
10 | *.o
11 | *.os
12 | *.ko
13 | *.obj
14 | *.elf
15 |
16 | # Precompiled Headers
17 | *.gch
18 | *.pch
19 |
20 | # Libraries
21 | *.lib
22 | *.a
23 | *.la
24 | *.lo
25 | *.def
26 | *.exp
27 |
28 | # Shared objects (inc. Windows DLLs)
29 | *.dll
30 | *.so
31 | *.so.*
32 | *.dylib
33 |
34 | # Executables
35 | *.exe
36 | *.out
37 | *.app
38 | *.i*86
39 | *.x86_64
40 | *.hex
41 |
42 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "LibStub"]
2 | path = LibStub
3 | url = git@github.com:zerosnake0/LibStub.git
4 | [submodule "CallbackHandler-1.0"]
5 | path = CallbackHandler-1.0
6 | url = git@github.com:zerosnake0/CallbackHandler-1.0.git
7 |
--------------------------------------------------------------------------------
/.pkgmeta:
--------------------------------------------------------------------------------
1 | package-as: Ace3
2 |
3 | ignore:
4 | - tests
--------------------------------------------------------------------------------
/Ace3.lua:
--------------------------------------------------------------------------------
1 |
2 | -- This file is only there in standalone Ace3 and provides handy dev tool stuff I guess
3 | -- for now only /rl to reload your UI :)
4 | -- note the complete overkill use of AceAddon and console, ain't it cool?
5 |
6 | -- GLOBALS: next, loadstring, ReloadUI, geterrorhandler
7 | -- GLOBALS: BINDING_HEADER_ACE3, BINDING_NAME_RELOADUI, Ace3, LibStub
8 |
9 | -- BINDINGs labels
10 | BINDING_HEADER_ACE3 = "Ace3"
11 | BINDING_NAME_RELOADUI = "ReloadUI"
12 | --
13 |
14 | local gui = LibStub("AceGUI-3.0")
15 | local reg = LibStub("AceConfigRegistry-3.0")
16 | local dialog = LibStub("AceConfigDialog-3.0")
17 | local AceCore = LibStub("AceCore-3.0")
18 |
19 | Ace3 = LibStub("AceAddon-3.0"):NewAddon("Ace3", "AceConsole-3.0")
20 | local Ace3 = Ace3
21 |
22 | local strfind = string.find
23 | local strtrim = AceCore.strtrim
24 |
25 | local selectedgroup
26 | local frame
27 | local select
28 | local status = {}
29 | local configs = {}
30 |
31 | local function frameOnClose()
32 | gui:Release(frame)
33 | frame = nil
34 | end
35 |
36 | local function RefreshConfigs()
37 | for name in reg:IterateOptionsTables() do
38 | configs[name] = name
39 | end
40 | end
41 |
42 | local function ConfigSelected(widget, event, _, value)
43 | selectedgroup = value
44 | dialog:Open(value, widget)
45 | end
46 |
47 | local old_CloseSpecialWindows
48 |
49 | -- GLOBALS: CloseSpecialWindows, next
50 | function Ace3:Open()
51 | if not old_CloseSpecialWindows then
52 | old_CloseSpecialWindows = CloseSpecialWindows
53 | CloseSpecialWindows = function()
54 | local found = old_CloseSpecialWindows()
55 | if frame then
56 | frame:Hide()
57 | return true
58 | end
59 | return found
60 | end
61 | end
62 | RefreshConfigs()
63 | if next(configs) == nil then
64 | self:Print("No Configs are Registered")
65 | return
66 | end
67 |
68 | if not frame then
69 | frame = gui:Create("Frame")
70 | frame:ReleaseChildren()
71 | frame:SetTitle("Ace3 Options")
72 | frame:SetLayout("FILL")
73 | frame:SetCallback("OnClose", frameOnClose)
74 |
75 | select = gui:Create("DropdownGroup")
76 | select:SetGroupList(configs)
77 | select:SetCallback("OnGroupSelected", ConfigSelected)
78 | frame:AddChild(select)
79 | end
80 | if not selectedgroup then
81 | selectedgroup = next(configs)
82 | end
83 | select:SetGroup(selectedgroup)
84 | frame:Show()
85 | end
86 |
87 | local function RefreshOnUpdate(this)
88 | select:SetGroup(selectedgroup)
89 | this:SetScript("OnUpdate", nil)
90 | end
91 |
92 | function Ace3:ConfigTableChanged(event, appName)
93 | if selectedgroup == appName and frame then
94 | frame.frame:SetScript("OnUpdate", RefreshOnUpdate)
95 | end
96 | end
97 |
98 | reg.RegisterCallback(Ace3, "ConfigTableChange", "ConfigTableChanged")
99 |
100 | function Ace3:PrintCmd(input)
101 | local _,_,input = strfind(strtrim(input), "^(.-);*$")
102 | local func, err = loadstring("LibStub(\"AceConsole-3.0\"):Print(" .. input .. ")")
103 | if not func then
104 | LibStub("AceConsole-3.0"):Print("Error: " .. err)
105 | else
106 | func()
107 | end
108 | end
109 |
110 | function Ace3:OnInitialize()
111 | self:RegisterChatCommand("ace3", function() self:Open() end)
112 | self:RegisterChatCommand("rl", function() ReloadUI() end)
113 | self:RegisterChatCommand("print", "PrintCmd")
114 | end
115 |
--------------------------------------------------------------------------------
/Ace3.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 11200
2 |
3 | ## Title: Lib: Ace3
4 | ## Notes: AddOn development framework
5 | ## Author: Ace3 Development Team
6 | ## X-Website: http://www.wowace.com
7 | ## X-Category: Library
8 | ## X-License: Limited BSD
9 |
10 | LibStub\LibStub.lua
11 | CallbackHandler-1.0\CallbackHandler-1.0.xml
12 |
13 | AceCore-3.0\AceCore-3.0.xml
14 | AceAddon-3.0\AceAddon-3.0.xml
15 | AceEvent-3.0\AceEvent-3.0.xml
16 | AceTimer-3.0\AceTimer-3.0.xml
17 | AceBucket-3.0\AceBucket-3.0.xml
18 | AceHook-3.0\AceHook-3.0.xml
19 | AceDB-3.0\AceDB-3.0.xml
20 | AceDBOptions-3.0\AceDBOptions-3.0.xml
21 | AceLocale-3.0\AceLocale-3.0.xml
22 | AceLocale-3.1\AceLocale-3.1.xml
23 | AceConsole-3.0\AceConsole-3.0.xml
24 | AceCursor-3.0\AceCursor-3.0.xml
25 | AceGUI-3.0\AceGUI-3.0.xml
26 | AceGUI-3.0\widgets\widgets.xml
27 | AceConfig-3.0\AceConfig-3.0.xml
28 | AceComm-3.0\AceComm-3.0.xml
29 | AceTab-3.0\AceTab-3.0.xml
30 | AceSerializer-3.0\AceSerializer-3.0.xml
31 |
32 | Ace3.lua
33 |
--------------------------------------------------------------------------------
/AceAddon-3.0/AceAddon-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceBucket-3.0/AceBucket-3.0.lua:
--------------------------------------------------------------------------------
1 | --- A bucket to catch events in. **AceBucket-3.0** provides throttling of events that fire in bursts and
2 | -- your addon only needs to know about the full burst.
3 | --
4 | -- This Bucket implementation works as follows:\\
5 | -- Initially, no schedule is running, and its waiting for the first event to happen.\\
6 | -- The first event will start the bucket, and get the scheduler running, which will collect all
7 | -- events in the given interval. When that interval is reached, the bucket is pushed to the
8 | -- callback and a new schedule is started. When a bucket is empty after its interval, the scheduler is
9 | -- stopped, and the bucket is only listening for the next event to happen, basically back in its initial state.
10 | --
11 | -- In addition, the buckets collect information about the "arg1" argument of the events that fire, and pass those as a
12 | -- table to your callback. This functionality was mostly designed for the UNIT_* events.\\
13 | -- The table will have the different values of "arg1" as keys, and the number of occurances as their value, e.g.\\
14 | -- { ["player"] = 2, ["target"] = 1, ["party1"] = 1 }
15 | --
16 | -- **AceBucket-3.0** can be embeded into your addon, either explicitly by calling AceBucket:Embed(MyAddon) or by
17 | -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
18 | -- and can be accessed directly, without having to explicitly call AceBucket itself.\\
19 | -- It is recommended to embed AceBucket, otherwise you'll have to specify a custom `self` on all calls you
20 | -- make into AceBucket.
21 | -- @usage
22 | -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("BucketExample", "AceBucket-3.0")
23 | --
24 | -- function MyAddon:OnEnable()
25 | -- -- Register a bucket that listens to all the HP related events,
26 | -- -- and fires once per second
27 | -- self:RegisterBucketEvent({"UNIT_HEALTH", "UNIT_MAXHEALTH"}, 1, "UpdateHealth")
28 | -- end
29 | --
30 | -- function MyAddon:UpdateHealth(units)
31 | -- if units.player then
32 | -- print("Your HP changed!")
33 | -- end
34 | -- end
35 | -- @class file
36 | -- @name AceBucket-3.0.lua
37 | -- @release $Id: AceBucket-3.0.lua 895 2009-12-06 16:28:55Z nevcairiel $
38 |
39 | local MAJOR, MINOR = "AceBucket-3.0", 3
40 | local AceBucket, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
41 |
42 | if not AceBucket then return end -- No Upgrade needed
43 |
44 | local AceCore = LibStub("AceCore-3.0")
45 | local wipe = AceCore.wipe
46 |
47 | AceBucket.buckets = AceBucket.buckets or {}
48 | AceBucket.embeds = AceBucket.embeds or {}
49 | AceBucket.bucketCache = AceBucket.bucketCache or setmetatable({}, {__mode='k'})
50 |
51 | -- the libraries will be lazyly bound later, to avoid errors due to loading order issues
52 | local AceEvent, AceTimer
53 |
54 | -- Lua APIs
55 | local tconcat = table.concat
56 | local type, next, pairs = type, next, pairs
57 | local tonumber, tostring, rawset = tonumber, tostring, rawset
58 | local assert, loadstring, error = assert, loadstring, error
59 |
60 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
61 | -- List them here for Mikk's FindGlobals script
62 | -- GLOBALS: LibStub, geterrorhandler
63 |
64 | local bucketCache = AceBucket.bucketCache
65 |
66 | --[[
67 | xpcall safecall implementation
68 | ]]
69 | local safecall = AceCore.safecall
70 |
71 | -- FireBucket ( bucket )
72 | --
73 | -- send the bucket to the callback function and schedule the next FireBucket in interval seconds
74 | local function FireBucket(bucket)
75 | local received = bucket.received
76 | -- we dont want to fire empty buckets
77 | if next(received) then
78 | local callback = bucket.callback
79 | local timer = bucket.timer
80 | if type(callback) == "string" then
81 | safecall(bucket.object[callback], 2, bucket.object, received)
82 | else
83 | safecall(callback, 1, received)
84 | end
85 | -- Ace3v: if the timer becomes different, that means the bucket has been cancelled in the callback
86 | -- and the received table was already cleared once, it may also contain the new datas if the
87 | -- event/message for the new bucket is also fired in the callback
88 | if bucket.timer == timer then
89 | for k in pairs(received) do
90 | received[k] = nil
91 | end
92 | -- if the bucket was not empty, schedule another FireBucket in interval seconds
93 | bucket.timer = AceTimer.ScheduleTimer(bucket, FireBucket, bucket.interval, 1, bucket)
94 | end
95 | else -- if it was empty, clear the timer and wait for the next event
96 | bucket.timer = nil
97 | end
98 | end
99 |
100 | -- BucketHandler ( event, arg1 )
101 | --
102 | -- callback func for AceEvent
103 | -- stores arg1 in the received table, and schedules the bucket if necessary
104 | local function BucketHandler(self, a1)
105 | if not self.isMessage then a1 = arg1 end
106 | if a1 == nil then
107 | a1 = "nil"
108 | end
109 |
110 | self.received[a1] = (self.received[a1] or 0) + 1
111 |
112 | -- if we are not scheduled yet, start a timer on the interval for our bucket to be cleared
113 | if not self.timer then
114 | self.timer = AceTimer.ScheduleTimer(self, FireBucket, self.interval, 1, self)
115 | end
116 | end
117 |
118 | -- RegisterBucket( event, interval, callback, isMessage )
119 | --
120 | -- event(string or table) - the event, or a table with the events, that this bucket listens to
121 | -- interval(int) - time between bucket fireings
122 | -- callback(func or string) - function pointer, or method name of the object, that gets called when the bucket is cleared
123 | -- isMessage(boolean) - register AceEvent Messages instead of game events
124 | local function RegisterBucket(self, event, interval, callback, isMessage)
125 | -- try to fetch the librarys
126 | if not AceEvent or not AceTimer then
127 | AceEvent = LibStub:GetLibrary("AceEvent-3.0", true)
128 | AceTimer = LibStub:GetLibrary("AceTimer-3.0", true)
129 | if not AceEvent or not AceTimer then
130 | error(MAJOR .. " requires AceEvent-3.0 and AceTimer-3.0", 3)
131 | end
132 | end
133 |
134 | if type(event) ~= "string" and type(event) ~= "table" then error("Usage: RegisterBucket(event, interval, callback): 'event' - string or table expected.", 3) end
135 | if not callback then
136 | if type(event) == "string" then
137 | callback = event
138 | else
139 | error("Usage: RegisterBucket(event, interval, callback): cannot omit callback when event is not a string.", 3)
140 | end
141 | end
142 |
143 | if not tonumber(interval) then error("Usage: RegisterBucket(event, interval, callback): 'interval' - number expected.", 3) end
144 | if type(callback) ~= "string" and type(callback) ~= "function" then error("Usage: RegisterBucket(event, interval, callback): 'callback' - string or function or nil expected.", 3) end
145 | if type(callback) == "string" and type(self[callback]) ~= "function" then error("Usage: RegisterBucket(event, interval, callback): 'callback' - method not found on target object.", 3) end
146 |
147 | local bucket = next(bucketCache)
148 | if bucket then
149 | bucketCache[bucket] = nil
150 | else
151 | bucket = { handler = BucketHandler, received = {} }
152 | end
153 | bucket.isMessage = isMessage
154 | bucket.object, bucket.callback, bucket.interval = self, callback, tonumber(interval)
155 |
156 | local regFunc = isMessage and AceEvent.RegisterMessage or AceEvent.RegisterEvent
157 |
158 | if type(event) == "table" then
159 | for _,e in pairs(event) do
160 | regFunc(bucket, e, "handler")
161 | end
162 | else
163 | regFunc(bucket, event, "handler")
164 | end
165 |
166 | local handle = tostring(bucket)
167 | AceBucket.buckets[handle] = bucket
168 |
169 | return handle
170 | end
171 |
172 | --- Register a Bucket for an event (or a set of events)
173 | -- @param event The event to listen for, or a table of events.
174 | -- @param interval The Bucket interval (burst interval)
175 | -- @param callback The callback function, either as a function reference, or a string pointing to a method of the addon object.
176 | -- @return The handle of the bucket (for unregistering)
177 | -- @usage
178 | -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceBucket-3.0")
179 | -- MyAddon:RegisterBucketEvent("BAG_UPDATE", 0.2, "UpdateBags")
180 | --
181 | -- function MyAddon:UpdateBags()
182 | -- -- do stuff
183 | -- end
184 | function AceBucket:RegisterBucketEvent(event, interval, callback)
185 | return RegisterBucket(self, event, interval, callback, false)
186 | end
187 |
188 | --- Register a Bucket for an AceEvent-3.0 addon message (or a set of messages)
189 | -- @param message The message to listen for, or a table of messages.
190 | -- @param interval The Bucket interval (burst interval)
191 | -- @param callback The callback function, either as a function reference, or a string pointing to a method of the addon object.
192 | -- @return The handle of the bucket (for unregistering)
193 | -- @usage
194 | -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceBucket-3.0")
195 | -- MyAddon:RegisterBucketEvent("SomeAddon_InformationMessage", 0.2, "ProcessData")
196 | --
197 | -- function MyAddon:ProcessData()
198 | -- -- do stuff
199 | -- end
200 | function AceBucket:RegisterBucketMessage(message, interval, callback)
201 | return RegisterBucket(self, message, interval, callback, true)
202 | end
203 |
204 | --- Unregister any events and messages from the bucket and clear any remaining data.
205 | -- @param handle The handle of the bucket as returned by RegisterBucket*
206 | function AceBucket:UnregisterBucket(handle)
207 | local bucket = AceBucket.buckets[handle]
208 | if bucket then
209 | AceEvent.UnregisterAllEvents(bucket)
210 | AceEvent.UnregisterAllMessages(bucket)
211 |
212 | -- clear any remaining data in the bucket
213 | for k in pairs(bucket.received) do
214 | bucket.received[k] = nil
215 | end
216 |
217 | if bucket.timer then
218 | AceTimer.CancelTimer(bucket, bucket.timer)
219 | bucket.timer = nil
220 | end
221 |
222 | AceBucket.buckets[handle] = nil
223 | -- store our bucket in the cache
224 | bucketCache[bucket] = true
225 | end
226 | end
227 |
228 | --- Unregister all buckets of the current addon object (or custom "self").
229 | function AceBucket:UnregisterAllBuckets()
230 | -- hmm can we do this more efficient? (it is not done often so shouldn't matter much)
231 | for handle, bucket in pairs(AceBucket.buckets) do
232 | if bucket.object == self then
233 | AceBucket.UnregisterBucket(self, handle)
234 | end
235 | end
236 | end
237 |
238 | -- embedding and embed handling
239 | local mixins = {
240 | "RegisterBucketEvent",
241 | "RegisterBucketMessage",
242 | "UnregisterBucket",
243 | "UnregisterAllBuckets",
244 | }
245 |
246 | -- Embeds AceBucket into the target object making the functions from the mixins list available on target:..
247 | -- @param target target object to embed AceBucket in
248 | function AceBucket:Embed( target )
249 | for _, v in pairs( mixins ) do
250 | target[v] = self[v]
251 | end
252 | self.embeds[target] = true
253 | return target
254 | end
255 |
256 | function AceBucket:OnEmbedDisable( target )
257 | target:UnregisterAllBuckets()
258 | end
259 |
260 | for addon in pairs(AceBucket.embeds) do
261 | AceBucket:Embed(addon)
262 | end
263 |
--------------------------------------------------------------------------------
/AceBucket-3.0/AceBucket-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceComm-3.0/AceComm-3.0.lua:
--------------------------------------------------------------------------------
1 | --- **AceComm-3.0** allows you to send messages of unlimited length over the addon comm channels.
2 | -- It'll automatically split the messages into multiple parts and rebuild them on the receiving end.\\
3 | -- **ChatThrottleLib** is of course being used to avoid being disconnected by the server.
4 | --
5 | -- **AceComm-3.0** can be embeded into your addon, either explicitly by calling AceComm:Embed(MyAddon) or by
6 | -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
7 | -- and can be accessed directly, without having to explicitly call AceComm itself.\\
8 | -- It is recommended to embed AceComm, otherwise you'll have to specify a custom `self` on all calls you
9 | -- make into AceComm.
10 | -- @class file
11 | -- @name AceComm-3.0
12 | -- @release $Id: AceComm-3.0.lua 1107 2014-02-19 16:40:32Z nevcairiel $
13 |
14 | --[[ AceComm-3.0
15 |
16 | TODO: Time out old data rotting around from dead senders? Not a HUGE deal since the number of possible sender names is somewhat limited.
17 |
18 | ]]
19 |
20 | local MAJOR, MINOR = "AceComm-3.0", 9
21 |
22 | local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR)
23 |
24 | if not AceComm then return end
25 |
26 | local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
27 | local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib")
28 |
29 | -- Lua APIs
30 | local type, next, pairs, tostring = type, next, pairs, tostring
31 | local strlen, strsub, strfind = string.len, string.sub, string.find
32 | local tinsert, tconcat, tgetn, tremove = table.insert, table.concat, table.getn, table.remove
33 | local error, assert = error, assert
34 |
35 |
36 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
37 | -- List them here for Mikk's FindGlobals script
38 | -- GLOBALS: LibStub, DEFAULT_CHAT_FRAME, geterrorhandler, RegisterAddonMessagePrefix
39 |
40 | AceComm.embeds = AceComm.embeds or {}
41 |
42 | -- for my sanity and yours, let's give the message type bytes some names
43 | local MSG_MULTI_FIRST = "\001"
44 | local MSG_MULTI_NEXT = "\002"
45 | local MSG_MULTI_LAST = "\003"
46 | local MSG_ESCAPE = "\004"
47 |
48 | -- remove old structures (pre WoW 4.0)
49 | AceComm.multipart_origprefixes = nil
50 | AceComm.multipart_reassemblers = nil
51 |
52 | -- the multipart message spool: indexed by a combination of sender+distribution+
53 | AceComm.multipart_spool = AceComm.multipart_spool or {}
54 |
55 | --- Register for Addon Traffic on a specified prefix
56 | -- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent), max 16 characters
57 | -- @param method Callback to call on message reception: Function reference, or method name (string) to call on self. Defaults to "OnCommReceived"
58 | function AceComm:RegisterComm(prefix, method)
59 | if method == nil then
60 | method = "OnCommReceived"
61 | end
62 |
63 | if strlen(prefix) > 16 then -- TODO: 15?
64 | error("AceComm:RegisterComm(prefix,method): prefix length is limited to 16 characters")
65 | end
66 |
67 | return AceComm._RegisterComm(self, prefix, method) -- created by CallbackHandler
68 | end
69 |
70 | local warnedPrefix=false
71 |
72 | --- Send a message over the Addon Channel
73 | -- @param prefix A printable character (\032-\255) classification of the message (typically AddonName or AddonNameEvent)
74 | -- @param text Data to send, nils (\000) not allowed. Any length.
75 | -- @param distribution Addon channel, e.g. "RAID", "GUILD", etc; see SendAddonMessage API
76 | -- @param target Destination for some distributions; see SendAddonMessage API
77 | -- @param prio OPTIONAL: ChatThrottleLib priority, "BULK", "NORMAL" or "ALERT". Defaults to "NORMAL".
78 | -- @param callbackFn OPTIONAL: callback function to be called as each chunk is sent. receives 3 args: the user supplied arg (see next), the number of bytes sent so far, and the number of bytes total to send.
79 | -- @param callbackArg: OPTIONAL: first arg to the callback function. nil will be passed if not specified.
80 | function AceComm:SendCommMessage(prefix, text, distribution, target, prio, callbackFn, callbackArg)
81 | prio = prio or "NORMAL" -- pasta's reference implementation had different prio for singlepart and multipart, but that's a very bad idea since that can easily lead to out-of-sequence delivery!
82 | if not( type(prefix)=="string" and
83 | type(text)=="string" and
84 | type(distribution)=="string" and
85 | (target==nil or type(target)=="string") and
86 | (prio=="BULK" or prio=="NORMAL" or prio=="ALERT")
87 | ) then
88 | error('Usage: SendCommMessage(addon, "prefix", "text", "distribution"[, "target"[, "prio"[, callbackFn, callbackarg]]])', 2)
89 | end
90 |
91 | local textlen = strlen(text)
92 | -- Yes, the max is 255 even if the dev post said 256. I tested. Char 256+ get silently truncated. /Mikk, 20110327
93 | -- Ace3v: substract the prefix length
94 | local maxtextlen = 254 - strlen(prefix)
95 | local queueName = prefix..distribution..(target or "")
96 |
97 | local ctlCallback = nil
98 | if callbackFn then
99 | ctlCallback = function(sent)
100 | return callbackFn(callbackArg, sent, textlen)
101 | end
102 | end
103 |
104 | local forceMultipart
105 | if strfind(text, "^[\001-\009]") then -- 4.1+: see if the first character is a control character
106 | -- we need to escape the first character with a \004
107 | if textlen+1 > maxtextlen then -- would we go over the size limit?
108 | forceMultipart = true -- just make it multipart, no escape problems then
109 | else
110 | text = "\004" .. text
111 | end
112 | end
113 |
114 | if not forceMultipart and textlen <= maxtextlen then
115 | -- fits all in one message
116 | CTL:SendAddonMessage(prio, prefix, text, distribution, target, queueName, ctlCallback, textlen)
117 | else
118 | maxtextlen = maxtextlen - 1 -- 1 extra byte for part indicator in prefix(4.0)/start of message(4.1)
119 |
120 | -- first part
121 | local chunk = strsub(text, 1, maxtextlen)
122 | CTL:SendAddonMessage(prio, prefix, MSG_MULTI_FIRST..chunk, distribution, target, queueName, ctlCallback, maxtextlen)
123 |
124 | -- continuation
125 | local pos = 1+maxtextlen
126 |
127 | while pos+maxtextlen <= textlen do
128 | chunk = strsub(text, pos, pos+maxtextlen-1)
129 | CTL:SendAddonMessage(prio, prefix, MSG_MULTI_NEXT..chunk, distribution, target, queueName, ctlCallback, pos+maxtextlen-1)
130 | pos = pos + maxtextlen
131 | end
132 |
133 | -- final part
134 | chunk = strsub(text, pos)
135 | CTL:SendAddonMessage(prio, prefix, MSG_MULTI_LAST..chunk, distribution, target, queueName, ctlCallback, textlen)
136 | end
137 | end
138 |
139 |
140 | ----------------------------------------
141 | -- Message receiving
142 | ----------------------------------------
143 |
144 | do
145 | local compost = setmetatable({}, {__mode = "k"})
146 | local function new()
147 | local t = next(compost)
148 | if t then
149 | compost[t]=nil
150 | for i=tgetn(t),3,-1 do -- faster than pairs loop. don't even nil out 1/2 since they'll be overwritten
151 | tremove(t) -- Ace3v: t[i] = nil wont affect the tgetn return value
152 | end
153 | return t
154 | end
155 |
156 | return {}
157 | end
158 |
159 | local function lostdatawarning(prefix,sender,where)
160 | DEFAULT_CHAT_FRAME:AddMessage(MAJOR..": Warning: lost network data regarding '"..tostring(prefix).."' from '"..tostring(sender).."' (in "..where..")")
161 | end
162 |
163 | function AceComm:OnReceiveMultipartFirst(prefix, message, distribution, sender)
164 | local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
165 | local spool = AceComm.multipart_spool
166 |
167 | --[[
168 | if spool[key] then
169 | lostdatawarning(prefix,sender,"First")
170 | -- continue and overwrite
171 | end
172 | --]]
173 |
174 | spool[key] = message -- plain string for now
175 | end
176 |
177 | function AceComm:OnReceiveMultipartNext(prefix, message, distribution, sender)
178 | local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
179 | local spool = AceComm.multipart_spool
180 | local olddata = spool[key]
181 |
182 | if not olddata then
183 | --lostdatawarning(prefix,sender,"Next")
184 | return
185 | end
186 |
187 | if type(olddata)~="table" then
188 | -- ... but what we have is not a table. So make it one. (Pull a composted one if available)
189 | local t = new()
190 | t[1] = olddata -- add old data as first string
191 | t[2] = message -- and new message as second string
192 | spool[key] = t -- and put the table in the spool instead of the old string
193 | else
194 | tinsert(olddata, message)
195 | end
196 | end
197 |
198 | function AceComm:OnReceiveMultipartLast(prefix, message, distribution, sender)
199 | local key = prefix.."\t"..distribution.."\t"..sender -- a unique stream is defined by the prefix + distribution + sender
200 | local spool = AceComm.multipart_spool
201 | local olddata = spool[key]
202 |
203 | if not olddata then
204 | --lostdatawarning(prefix,sender,"End")
205 | return
206 | end
207 |
208 | spool[key] = nil
209 |
210 | if type(olddata) == "table" then
211 | -- if we've received a "next", the spooled data will be a table for rapid & garbage-free tconcat
212 | tinsert(olddata, message)
213 | AceComm.callbacks:Fire(prefix, 3, tconcat(olddata, ""), distribution, sender)
214 | compost[olddata] = true
215 | else
216 | -- if we've only received a "first", the spooled data will still only be a string
217 | AceComm.callbacks:Fire(prefix, 3, olddata..message, distribution, sender)
218 | end
219 | end
220 | end
221 |
222 |
223 |
224 |
225 |
226 |
227 | ----------------------------------------
228 | -- Embed CallbackHandler
229 | ----------------------------------------
230 |
231 | if not AceComm.callbacks then
232 | AceComm.callbacks = CallbackHandler:New(AceComm,
233 | "_RegisterComm",
234 | "UnregisterComm",
235 | "UnregisterAllComm")
236 | end
237 |
238 | AceComm.callbacks.OnUsed = nil
239 | AceComm.callbacks.OnUnused = nil
240 |
241 | -- Ace3v: in vanilla, global vars:
242 | -- event -> event type
243 | -- arg1 -> prefix
244 | -- arg2 -> message
245 | -- arg3 -> channel
246 | -- arg4 -> sender
247 | local function OnEvent()
248 | local prefix, message, distribution, sender = arg1, arg2, arg3, arg4
249 | if event == "CHAT_MSG_ADDON" then
250 | local _, _, control, rest = strfind(message, "^([\001-\009])(.*)")
251 | if control then
252 | if control==MSG_MULTI_FIRST then
253 | AceComm:OnReceiveMultipartFirst(prefix, rest, distribution, sender)
254 | elseif control==MSG_MULTI_NEXT then
255 | AceComm:OnReceiveMultipartNext(prefix, rest, distribution, sender)
256 | elseif control==MSG_MULTI_LAST then
257 | AceComm:OnReceiveMultipartLast(prefix, rest, distribution, sender)
258 | elseif control==MSG_ESCAPE then
259 | AceComm.callbacks:Fire(prefix, 3, rest, distribution, sender)
260 | else
261 | -- unknown control character, ignore SILENTLY (dont warn unnecessarily about future extensions!)
262 | end
263 | else
264 | -- single part: fire it off immediately and let CallbackHandler decide if it's registered or not
265 | AceComm.callbacks:Fire(prefix, 3, message, distribution, sender)
266 | end
267 | else
268 | assert(false, "Received "..tostring(event).." event?!")
269 | end
270 | end
271 |
272 | AceComm.frame = AceComm.frame or CreateFrame("Frame", "AceComm30Frame")
273 | AceComm.frame:SetScript("OnEvent", OnEvent)
274 | AceComm.frame:UnregisterAllEvents()
275 | AceComm.frame:RegisterEvent("CHAT_MSG_ADDON")
276 |
277 |
278 | ----------------------------------------
279 | -- Base library stuff
280 | ----------------------------------------
281 |
282 | local mixins = {
283 | "RegisterComm",
284 | "UnregisterComm",
285 | "UnregisterAllComm",
286 | "SendCommMessage",
287 | }
288 |
289 | -- Embeds AceComm-3.0 into the target object making the functions from the mixins list available on target:..
290 | -- @param target target object to embed AceComm-3.0 in
291 | function AceComm:Embed(target)
292 | for k, v in pairs(mixins) do
293 | target[v] = self[v]
294 | end
295 | self.embeds[target] = true
296 | return target
297 | end
298 |
299 | function AceComm:OnEmbedDisable(target)
300 | target:UnregisterAllComm()
301 | end
302 |
303 | -- Update embeds
304 | for target, v in pairs(AceComm.embeds) do
305 | AceComm:Embed(target)
306 | end
307 |
--------------------------------------------------------------------------------
/AceComm-3.0/AceComm-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AceConfig-3.0/AceConfig-3.0.lua:
--------------------------------------------------------------------------------
1 | --- AceConfig-3.0 wrapper library.
2 | -- Provides an API to register an options table with the config registry,
3 | -- as well as associate it with a slash command.
4 | -- @class file
5 | -- @name AceConfig-3.0
6 | -- @release $Id: AceConfig-3.0.lua 969 2010-10-07 02:11:48Z shefki $
7 |
8 | --[[
9 | AceConfig-3.0
10 |
11 | Very light wrapper library that combines all the AceConfig subcomponents into one more easily used whole.
12 |
13 | ]]
14 |
15 | local MAJOR, MINOR = "AceConfig-3.0", 2
16 | local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
17 |
18 | if not AceConfig then return end
19 |
20 | AceConfig.embeds = AceConfig.embeds or {}
21 |
22 | local cfgreg = LibStub("AceConfigRegistry-3.0")
23 | local cfgcmd = LibStub("AceConfigCmd-3.0")
24 | --TODO: local cfgdlg = LibStub("AceConfigDialog-3.0", true)
25 | --TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0", true)
26 |
27 | -- Lua APIs
28 | local pcall, error, type, pairs = pcall, error, type, pairs
29 |
30 | -- -------------------------------------------------------------------
31 | -- :RegisterOptionsTable(appName, options, slashcmd, persist)
32 | --
33 | -- - appName - (string) application name
34 | -- - options - table or function ref, see AceConfigRegistry
35 | -- - slashcmd - slash command (string) or table with commands, or nil to NOT create a slash command
36 |
37 | --- Register a option table with the AceConfig registry.
38 | -- You can supply a slash command (or a table of slash commands) to register with AceConfigCmd directly.
39 | -- @paramsig appName, options [, slashcmd]
40 | -- @param appName The application name for the config table.
41 | -- @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/
42 | -- @param slashcmd A slash command to register for the option table, or a table of slash commands.
43 | -- @usage
44 | -- local AceConfig = LibStub("AceConfig-3.0")
45 | -- AceConfig:RegisterOptionsTable("MyAddon", myOptions, {"/myslash", "/my"})
46 | function AceConfig:RegisterOptionsTable(appName, options, slashcmd)
47 | if self == AceConfig then
48 | error([[Usage: RegisterOptionsTable(appName, options[, slashcmd]): 'self' - use your own 'self']], 2)
49 | end
50 | local ok,msg = pcall(cfgreg.RegisterOptionsTable, self, appName, options)
51 | if not ok then error(msg, 2) end
52 |
53 | if slashcmd then
54 | if type(slashcmd) == "table" then
55 | for _,cmd in pairs(slashcmd) do
56 | cfgcmd.CreateChatCommand(self, cmd, appName)
57 | end
58 | else
59 | cfgcmd.CreateChatCommand(self, slashcmd, appName)
60 | end
61 | end
62 | end
63 |
64 | function AceConfig:Embed(target)
65 | target["RegisterOptionsTable"] = self["RegisterOptionsTable"]
66 | end
67 |
68 | for addon in pairs(AceConfig.embeds) do
69 | AceConfig:Embed(addon)
70 | end
--------------------------------------------------------------------------------
/AceConfig-3.0/AceConfig-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceConfig-3.0/AceConfigRegistry-3.0/AceConfigRegistry-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceConsole-3.0/AceConsole-3.0.lua:
--------------------------------------------------------------------------------
1 | --- **AceConsole-3.0** provides registration facilities for slash commands.
2 | -- You can register slash commands to your custom functions and use the `GetArgs` function to parse them
3 | -- to your addons individual needs.
4 | --
5 | -- **AceConsole-3.0** can be embeded into your addon, either explicitly by calling AceConsole:Embed(MyAddon) or by
6 | -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
7 | -- and can be accessed directly, without having to explicitly call AceConsole itself.\\
8 | -- It is recommended to embed AceConsole, otherwise you'll have to specify a custom `self` on all calls you
9 | -- make into AceConsole.
10 | -- @class file
11 | -- @name AceConsole-3.0
12 | -- @release $Id: AceConsole-3.0.lua 1143 2016-07-11 08:52:03Z nevcairiel $
13 | local MAJOR,MINOR = "AceConsole-3.0", 7
14 |
15 | local AceConsole, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
16 |
17 | if not AceConsole then return end -- No upgrade needed
18 |
19 | local AceCore = LibStub("AceCore-3.0")
20 |
21 | AceConsole.embeds = AceConsole.embeds or {} -- table containing objects AceConsole is embedded in.
22 | AceConsole.commands = AceConsole.commands or {} -- table containing commands registered
23 | AceConsole.weakcommands = AceConsole.weakcommands or {} -- table containing self, command => func references for weak commands that don't persist through enable/disable
24 |
25 | -- Lua APIs
26 | local tinsert, tconcat, tgetn, tsetn = table.insert, table.concat, table.getn, table.setn
27 | local tostring = tostring
28 | local type, pairs, error = type, pairs, error
29 | local format, strfind, strsub = string.format, string.find, string.sub
30 | local max = math.max
31 | local strupper, strlower = string.upper, string.lower
32 |
33 | -- WoW APIs
34 | local _G = AceCore._G
35 |
36 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
37 | -- List them here for Mikk's FindGlobals script
38 | -- GLOBALS: DEFAULT_CHAT_FRAME, SlashCmdList, hash_SlashCmdList
39 | local Print
40 | do
41 | local tmp = {}
42 | function Print(self, frame, arg)
43 | if self ~= AceConsole then
44 | tmp[1] = "|cff33ff99"..tostring(self).."|r:"
45 | else
46 | tmp[1] = ''
47 | end
48 | if type(arg) == "string" then
49 | frame:AddMessage(tmp[1]..arg)
50 | else -- arg is table and may contain frame as first element if argument frame is nil
51 | local b, e = frame and 1 or 2, tgetn(arg)
52 | if e >= b then
53 | frame = frame or arg[1]
54 | for i=0,e-b do
55 | tmp[2+i] = tostring(arg[b+i])
56 | end
57 | frame:AddMessage(tconcat(tmp," ",1,e-b+2)) -- explicitly, because the length is not affected by assignment
58 | end
59 | end
60 | end
61 | end -- Print
62 |
63 | --- Print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
64 | -- @paramsig [chatframe ,] ...
65 | -- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
66 | -- @param ... List of any values to be printed
67 | function AceConsole:Print(...)
68 | local frame = arg[1]
69 | if type(frame) == "table" and frame.AddMessage then -- Is first argument something with an .AddMessage member?
70 | return Print(self, nil, arg)
71 | else
72 | return Print(self, DEFAULT_CHAT_FRAME, arg)
73 | end
74 | end
75 |
76 | --- Formatted (using format()) print to DEFAULT_CHAT_FRAME or given ChatFrame (anything with an .AddMessage function)
77 | -- @paramsig [chatframe ,] "format"[, ...]
78 | -- @param chatframe Custom ChatFrame to print to (or any frame with an .AddMessage function)
79 | -- @param format Format string - same syntax as standard Lua format()
80 | -- @param ... Arguments to the format string
81 | function AceConsole:Printf(a1, ...)
82 | local frame, succ, s
83 | if type(a1) == "table" and a1.AddMessage then -- Is first argument something with an .AddMessage member?
84 | frame, succ, s = a1, pcall(format, unpack(arg))
85 | else
86 | frame, succ, s = DEFAULT_CHAT_FRAME, pcall(format, a1, unpack(arg))
87 | end
88 | if not succ then error(s,2) end
89 | return Print(self, frame, s)
90 | end
91 |
92 |
93 |
94 |
95 |
96 | --- Register a simple chat command
97 | -- @param command Chat command to be registered WITHOUT leading "/"
98 | -- @param func Function to call when the slash command is being used (funcref or methodname)
99 | -- @param persist if false, the command will be soft disabled/enabled when aceconsole is used as a mixin (default: true)
100 | function AceConsole:RegisterChatCommand( command, func, persist )
101 | if type(command)~="string" then error([[Usage: AceConsole:RegisterChatCommand(command, func[, persist ]): 'command' - expected a string]], 2) end
102 |
103 | if persist==nil then persist=true end -- I'd rather have my addon's "/addon enable" around if the author screws up. Having some extra slash regged when it shouldnt be isn't as destructive. True is a better default. /Mikk
104 |
105 | local name = "ACECONSOLE_"..strupper(command)
106 |
107 | local t = type(func)
108 |
109 | if t == "string" then
110 | -- Ace3v: prevent user from using AceConSole as self
111 | if self == AceConsole then
112 | error([[Usage: RegisterChatCommand(command, func[, persist]): 'self' - use your own 'self']], 2)
113 | end
114 | SlashCmdList[name] = function(input, editBox)
115 | self[func](self, input, editBox)
116 | end
117 | elseif t == "function" then
118 | SlashCmdList[name] = func
119 | else
120 | error([[Usage: AceConsole:RegisterChatCommand(command, func[, persist ]): 'func' - expected a string or a function]], 2)
121 | end
122 | _G["SLASH_"..name.."1"] = "/"..strlower(command)
123 | AceConsole.commands[command] = name
124 | -- non-persisting commands are registered for enabling disabling
125 | if not persist then
126 | if not AceConsole.weakcommands[self] then AceConsole.weakcommands[self] = {} end
127 | AceConsole.weakcommands[self][command] = func
128 | end
129 | return true
130 | end
131 |
132 | --- Unregister a chatcommand
133 | -- @param command Chat command to be unregistered WITHOUT leading "/"
134 | function AceConsole:UnregisterChatCommand( command )
135 | local name = AceConsole.commands[command]
136 | if name then
137 | SlashCmdList[name] = nil
138 | _G["SLASH_" .. name .. "1"] = nil
139 | AceConsole.commands[command] = nil
140 | end
141 | end
142 |
143 | --- Get an iterator over all Chat Commands registered with AceConsole
144 | -- @return Iterator (pairs) over all commands
145 | function AceConsole:IterateChatCommands() return pairs(AceConsole.commands) end
146 |
147 | local function nils(n,argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
148 | if n >= 1 then
149 | return nil, nils(n-1,argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
150 | elseif not argc or argc == 0 then
151 | return
152 | else
153 | return a1, nils(0,argc-1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
154 | end
155 | end
156 |
157 | --- Retreive one or more space-separated arguments from a string.
158 | -- Treats quoted strings and itemlinks as non-spaced.
159 | -- @param str The raw argument string
160 | -- @param numargs How many arguments to get (default 1)
161 | -- @param startpos Where in the string to start scanning (default 1)
162 | -- @return Returns arg1, arg2, ..., nextposition\\
163 | -- Missing arguments will be returned as nils. 'nextposition' is returned as 1e9 at the end of the string.
164 | function AceConsole:GetArgs(str, numargs, startpos)
165 | numargs = numargs or 1
166 | startpos = max(startpos or 1, 1)
167 |
168 | local pos=startpos
169 |
170 | -- find start of new arg
171 | pos = strfind(str, "[^ ]", pos)
172 | if not pos then -- whoops, end of string
173 | return nils(numargs, 1, 1e9)
174 | end
175 |
176 | if numargs<1 then
177 | return pos
178 | end
179 |
180 | -- quoted or space separated? find out which pattern to use
181 | local delim_or_pipe
182 | local ch = strsub(str, pos, pos)
183 | if ch=='"' then
184 | pos = pos + 1
185 | delim_or_pipe='([|"])'
186 | elseif ch=="'" then
187 | pos = pos + 1
188 | delim_or_pipe="([|'])"
189 | else
190 | delim_or_pipe="([| ])"
191 | end
192 |
193 | startpos = pos
194 |
195 | while true do
196 | -- find delimiter or hyperlink
197 | local ch,_
198 | pos,_,ch = strfind(str, delim_or_pipe, pos)
199 |
200 | if not pos then break end
201 |
202 | if ch=="|" then
203 | -- some kind of escape
204 |
205 | if strsub(str,pos,pos+1)=="|H" then
206 | -- It's a |H....|hhyper link!|h
207 | pos=strfind(str, "|h", pos+2) -- first |h
208 | if not pos then break end
209 |
210 | pos=strfind(str, "|h", pos+2) -- second |h
211 | if not pos then break end
212 | elseif strsub(str,pos, pos+1) == "|T" then
213 | -- It's a |T....|t texture
214 | pos=strfind(str, "|t", pos+2)
215 | if not pos then break end
216 | end
217 |
218 | pos=pos+2 -- skip past this escape (last |h if it was a hyperlink)
219 |
220 | else
221 | -- found delimiter, done with this arg
222 | return strsub(str, startpos, pos-1), AceConsole:GetArgs(str, numargs-1, pos+1)
223 | end
224 |
225 | end
226 |
227 | -- search aborted, we hit end of string. return it all as one argument. (yes, even if it's an unterminated quote or hyperlink)
228 | return strsub(str, startpos), nils(numargs-1, 1, 1e9)
229 | end
230 |
231 |
232 | --- embedding and embed handling
233 |
234 | local mixins = {
235 | "Print",
236 | "Printf",
237 | "RegisterChatCommand",
238 | "UnregisterChatCommand",
239 | "GetArgs",
240 | }
241 |
242 | -- Embeds AceConsole into the target object making the functions from the mixins list available on target:..
243 | -- @param target target object to embed AceBucket in
244 | function AceConsole:Embed( target )
245 | for k, v in pairs( mixins ) do
246 | target[v] = self[v]
247 | end
248 | self.embeds[target] = true
249 | return target
250 | end
251 |
252 | function AceConsole:OnEmbedEnable( target )
253 | if AceConsole.weakcommands[target] then
254 | for command, func in pairs( AceConsole.weakcommands[target] ) do
255 | target:RegisterChatCommand( command, func, false, true ) -- nonpersisting and silent registry
256 | end
257 | end
258 | end
259 |
260 | function AceConsole:OnEmbedDisable( target )
261 | if AceConsole.weakcommands[target] then
262 | for command, func in pairs( AceConsole.weakcommands[target] ) do
263 | target:UnregisterChatCommand( command ) -- TODO: this could potentially unregister a command from another application in case of command conflicts. Do we care?
264 | end
265 | end
266 | end
267 |
268 | for addon in pairs(AceConsole.embeds) do
269 | AceConsole:Embed(addon)
270 | end
271 |
--------------------------------------------------------------------------------
/AceConsole-3.0/AceConsole-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceCore-3.0/AceCore-3.0.lua:
--------------------------------------------------------------------------------
1 | local ACECORE_MAJOR, ACECORE_MINOR = "AceCore-3.0", 1
2 | local AceCore, oldminor = LibStub:NewLibrary(ACECORE_MAJOR, ACECORE_MINOR)
3 |
4 | if not AceCore then return end -- No upgrade needed
5 |
6 | AceCore._G = AceCore._G or getfenv()
7 | local _G = AceCore._G
8 | local strsub, strgsub, strfind = string.sub, string.gsub, string.find
9 | local tremove, tconcat = table.remove, table.concat
10 | local tgetn, tsetn = table.getn, table.setn
11 |
12 | local new, del
13 | do
14 | local list = setmetatable({}, {__mode = "k"})
15 | function new()
16 | local t = next(list)
17 | if not t then
18 | return {}
19 | end
20 | list[t] = nil
21 | return t
22 | end
23 |
24 | function del(t)
25 | setmetatable(t, nil)
26 | for k in pairs(t) do
27 | t[k] = nil
28 | end
29 | tsetn(t,0)
30 | list[t] = true
31 | end
32 |
33 | -- debug
34 | function AceCore.listcount()
35 | local count = 0
36 | for k in list do
37 | count = count + 1
38 | end
39 | return count
40 | end
41 | end -- AceCore.new, AceCore.del
42 | AceCore.new, AceCore.del = new, del
43 |
44 | local function errorhandler(err)
45 | return geterrorhandler()(err)
46 | end
47 | AceCore.errorhandler = errorhandler
48 |
49 | local function CreateSafeDispatcher(argCount)
50 | local code = [[
51 | local errorhandler = LibStub("AceCore-3.0").errorhandler
52 | local method, UP_ARGS
53 | local function call()
54 | local func, ARGS = method, UP_ARGS
55 | method, UP_ARGS = nil, NILS
56 | return func(ARGS)
57 | end
58 | return function(func, ARGS)
59 | method, UP_ARGS = func, ARGS
60 | return xpcall(call, errorhandler)
61 | end
62 | ]]
63 | local c = 4*argCount-1
64 | local s = "b01,b02,b03,b04,b05,b06,b07,b08,b09,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20"
65 | code = strgsub(code, "UP_ARGS", string.sub(s,1,c))
66 | s = "a01,a02,a03,a04,a05,a06,a07,a08,a09,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20"
67 | code = strgsub(code, "ARGS", string.sub(s,1,c))
68 | s = "nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil"
69 | code = strgsub(code, "NILS", string.sub(s,1,c))
70 | return assert(loadstring(code, "safecall SafeDispatcher["..tostring(argCount).."]"))()
71 | end
72 |
73 | local SafeDispatchers = setmetatable({}, {__index=function(self, argCount)
74 | local dispatcher
75 | if not tonumber(argCount) then dbg(debugstack()) end
76 | if argCount > 0 then
77 | dispatcher = CreateSafeDispatcher(argCount)
78 | else
79 | dispatcher = function(func) return xpcall(func,errorhandler) end
80 | end
81 | rawset(self, argCount, dispatcher)
82 | return dispatcher
83 | end})
84 |
85 | local function safecall(func,argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20)
86 | -- we check to see if the func is passed is actually a function here and don't error when it isn't
87 | -- this safecall is used for optional functions like OnInitialize OnEnable etc. When they are not
88 | -- present execution should continue without hinderance
89 | if type(func) == "function" then
90 | return SafeDispatchers[argc](func,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20)
91 | end
92 | end
93 | AceCore.safecall = safecall
94 |
95 | local function CreateDispatcher(argCount)
96 | local code = [[
97 | return function(func,ARGS)
98 | return func(ARGS)
99 | end
100 | ]]
101 | local s = "a01,a02,a03,a04,a05,a06,a07,a08,a09,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20"
102 | code = strgsub(code, "ARGS", string.sub(s,1,4*argCount-1))
103 | return assert(loadstring(code, "call Dispatcher["..tostring(argCount).."]"))()
104 | end
105 |
106 | AceCore.Dispatchers = setmetatable({}, {__index=function(self, argCount)
107 | local dispatcher
108 | if argCount > 0 then
109 | dispatcher = CreateDispatcher(argCount)
110 | else
111 | dispatcher = function(func) return func() end
112 | end
113 | rawset(self, argCount, dispatcher)
114 | return dispatcher
115 | end})
116 |
117 | -- some string functions
118 | -- vanilla available string operations:
119 | -- sub, gfind, rep, gsub, char, dump, find, upper, len, format, byte, lower
120 | -- we will just replace every string.match with string.find in the code
121 | function AceCore.strtrim(s)
122 | return strgsub(s, "^%s*(.-)%s*$", "%1")
123 | end
124 |
125 | local function strsplit(delim, s, n)
126 | if n and n < 2 then return s end
127 | beg = beg or 1
128 | local i,j = string.find(s,delim,beg)
129 | if not i then
130 | return s, nil
131 | end
132 | return string.sub(s,1,j-1), strsplit(delim, string.sub(s,j+1), n and n-1 or nil)
133 | end
134 | AceCore.strsplit = strsplit
135 |
136 | -- Ace3v: fonctions copied from AceHook-2.1
137 | local protFuncs = {
138 | CameraOrSelectOrMoveStart = true, CameraOrSelectOrMoveStop = true,
139 | TurnOrActionStart = true, TurnOrActionStop = true,
140 | PitchUpStart = true, PitchUpStop = true,
141 | PitchDownStart = true, PitchDownStop = true,
142 | MoveBackwardStart = true, MoveBackwardStop = true,
143 | MoveForwardStart = true, MoveForwardStop = true,
144 | Jump = true, StrafeLeftStart = true,
145 | StrafeLeftStop = true, StrafeRightStart = true,
146 | StrafeRightStop = true, ToggleMouseMove = true,
147 | ToggleRun = true, TurnLeftStart = true,
148 | TurnLeftStop = true, TurnRightStart = true,
149 | TurnRightStop = true,
150 | }
151 |
152 | local function issecurevariable(x)
153 | return protFuncs[x] and 1 or nil
154 | end
155 | AceCore.issecurevariable = issecurevariable
156 |
157 | local function hooksecurefunc(arg1, arg2, arg3)
158 | if type(arg1) == "string" then
159 | arg1, arg2, arg3 = _G, arg1, arg2
160 | end
161 | local orig = arg1[arg2]
162 | if type(orig) ~= "function" then
163 | error("The function "..arg2.." does not exist", 2)
164 | end
165 | arg1[arg2] = function(...)
166 | local tmp = {orig(unpack(arg))}
167 | arg3(unpack(arg))
168 | return unpack(tmp)
169 | end
170 | end
171 | AceCore.hooksecurefunc = hooksecurefunc
172 |
173 | -- pickfirstset() - picks the first non-nil value and returns it
174 | local function pickfirstset(argc,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
175 | if (argc <= 1) or (a1 ~= nil) then
176 | return a1
177 | else
178 | return pickfirstset(argc-1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
179 | end
180 | end
181 | AceCore.pickfirstset = pickfirstset
182 |
183 | local function countargs(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
184 | if (a1 == nil) then return 0 end
185 | return 1 + countargs(a2,a3,a4,a5,a6,a7,a8,a9,a10)
186 | end
187 | AceCore.countargs = countargs
188 |
189 | -- wipe preserves metatable
190 | function AceCore.wipe(t)
191 | for k,v in pairs(t) do t[k] = nil end
192 | tsetn(t,0)
193 | return t
194 | end
195 |
196 | function AceCore.truncate(t,e)
197 | e = e or tgetn(t)
198 | for i=1,e do
199 | if t[i] == nil then
200 | tsetn(t,i-1)
201 | return
202 | end
203 | end
204 | tsetn(t,e)
205 | end
206 |
--------------------------------------------------------------------------------
/AceCore-3.0/AceCore-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceCursor-3.0/AceCursor-3.0.lua:
--------------------------------------------------------------------------------
1 | local ACECURSOR_MAJOR, ACECURSOR_MINOR = "AceCursor-3.0", 1
2 | local AceCursor, oldminor = LibStub:NewLibrary(ACECURSOR_MAJOR, ACECURSOR_MINOR)
3 |
4 | if not AceCursor then return end -- No upgrade needed
5 |
6 | local AceCore = LibStub("AceCore-3.0")
7 | local _G = AceCore._G
8 | local hooksecurefunc = AceCore.hooksecurefunc
9 |
10 | local cursorType, cursorData, cursorSubType, cursorSubData
11 | function _G.GetCursorInfo()
12 | return cursorType, cursorData, cursorSubType, cursorSubData
13 | end
14 |
15 | local function setcursoritem(link)
16 | local _,_,id = strfind(link,"|Hitem:(%d+):")
17 | cursorType = "item"
18 | cursorData = tonumber(id)
19 | cursorSubType = link
20 | cursorSubData = nil
21 | end
22 |
23 | -- ClearCursor
24 | if not AceCore_ClearCursor then
25 | hooksecurefunc("ClearCursor", function()
26 | return _G.AceCore_ClearCursor()
27 | end)
28 | end
29 |
30 | function _G.AceCore_ClearCursor()
31 | cursorType, cursorData, cursorSubType, cursorSubData = nil,nil,nil,nil
32 | end
33 |
34 | -- PickupContainerItem
35 | if not AceCore_PickupContainerItem then
36 | hooksecurefunc("PickupContainerItem",
37 | function(container, slot)
38 | return _G.AceCore_PickupContainerItem(container, slot)
39 | end)
40 | end
41 |
42 | function _G.AceCore_PickupContainerItem(container, slot)
43 | if CursorHasItem() then
44 | return setcursoritem(GetContainerItemLink(container, slot))
45 | end
46 | end
47 |
48 | -- PickupBagFromSlot
49 | if not _G.AceCore_PickupBagFromSlot then
50 | hooksecurefunc("PickupBagFromSlot",
51 | function(inventoryID)
52 | return _G.AceCore_PickupBagFromSlot(inventoryID)
53 | end)
54 | end
55 |
56 | function _G.AceCore_PickupBagFromSlot(inventoryID)
57 | return setcursoritem(GetInventoryItemLink("player", inventoryID))
58 | end
59 |
60 | -- PutItemInBag
61 | if not _G.AceCore_PutItemInBag then
62 | hooksecurefunc("PutItemInBag",
63 | function(inventoryID)
64 | return _G.AceCore_PutItemInBag(inventoryID)
65 | end)
66 | end
67 |
68 | function _G.AceCore_PutItemInBag(inventoryID)
69 | cursorType, cursorData, cursorSubType, cursorSubData = nil,nil,nil,nil
70 | end
71 |
72 | -- PickupSpell
73 | if not _G.AceCore_PickupSpell then
74 | hooksecurefunc("PickupSpell",
75 | function(spellbookID, bookType)
76 | return _G.AceCore_PickupSpell(spellbookID, bookType)
77 | end)
78 | end
79 |
80 | function _G.AceCore_PickupSpell(spellbookID, bookType)
81 | cursorType = "spell"
82 | cursorData = spellbookID
83 | cursorSubType = bookType
84 | cursorSubData = nil -- Ace3v: how to get spellID?
85 | end
86 |
87 | -- PickupMacro
88 | if not _G.AceCore_PickupMacro then
89 | hooksecurefunc("PickupMacro",
90 | function(macroID)
91 | return _G.AceCore_PickupMacro(macroID)
92 | end)
93 | end
94 |
95 | function _G.AceCore_PickupMacro(macroID)
96 | cursorType = "macro"
97 | cursorData = macroID
98 | cursorSubType = nil
99 | cursorSubData = nil
100 | end
101 |
102 | --[[------------------------------------
103 | The Action part is not fully working yet
104 | --------------------------------------]]
105 | -- PickupAction
106 | if not _G.AceCore_PickupAction then
107 | hooksecurefunc("PickupAction",
108 | function(slot)
109 | return _G.AceCore_PickupAction(slot)
110 | end)
111 | end
112 |
113 | function _G.AceCore_PickupAction(slot)
114 | cursorType = nil
115 | cursorData = nil
116 | cursorSubType = nil
117 | cursorSubData = nil
118 | end
119 |
120 | -- PlaceAction
121 | if not _G.AceCore_PlaceAction then
122 | hooksecurefunc("PlaceAction",
123 | function(slot)
124 | return _G.AceCore_PlaceAction(slot)
125 | end)
126 | end
127 |
128 | function _G.AceCore_PlaceAction(slot)
129 | cursorType, cursorData, cursorSubType, cursorSubData = nil,nil,nil,nil
130 | end
131 |
132 | local function ActionButton_OnClick()
133 | if ( IsShiftKeyDown() ) then
134 | PickupAction(ActionButton_GetPagedID(this));
135 | else
136 | if ( MacroFrame_SaveMacro ) then
137 | MacroFrame_SaveMacro();
138 | end
139 | UseAction(ActionButton_GetPagedID(this), 1);
140 | end
141 | ActionButton_UpdateState();
142 | end
143 |
144 | local function ActionButton_OnDragStart()
145 | if ( LOCK_ACTIONBAR ~= "1" ) then
146 | PickupAction(ActionButton_GetPagedID(this));
147 | ActionButton_UpdateHotkeys(this.buttonType);
148 | ActionButton_UpdateState();
149 | ActionButton_UpdateFlash();
150 | end
151 | end
152 |
153 | local function ActionButton_OnReceiveDrag()
154 | if ( LOCK_ACTIONBAR ~= "1" ) then
155 | PlaceAction(ActionButton_GetPagedID(this));
156 | ActionButton_UpdateHotkeys(this.buttonType);
157 | ActionButton_UpdateState();
158 | ActionButton_UpdateFlash();
159 | end
160 | end
161 |
162 | local actionButtons = {
163 | "ActionButton",
164 | "BonusActionButton",
165 | "MultiBarLeftButton",
166 | "MultiBarRightButton",
167 | "MultiBarBottomLeftButton",
168 | "MultiBarBottomRightButton",
169 | }
170 |
171 | for _,btn in actionButtons do
172 | for i=1,12 do
173 | local frame = _G[btn..i]
174 | frame:SetScript("OnDragStart",ActionButton_OnDragStart)
175 | frame:SetScript("OnReceiveDrag",ActionButton_OnReceiveDrag)
176 | frame:SetScript("OnClick",ActionButton_OnClick)
177 | end
178 | end
179 | for i=1,10 do
180 | local frame = _G["PetActionButton"..i]
181 | frame:SetScript("OnDragStart",ActionButton_OnDragStart)
182 | frame:SetScript("OnReceiveDrag",ActionButton_OnReceiveDrag)
183 | frame:SetScript("OnClick",ActionButton_OnClick)
184 | end
185 |
--------------------------------------------------------------------------------
/AceCursor-3.0/AceCursor-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AceDB-3.0/AceDB-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceDBOptions-3.0/AceDBOptions-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceEvent-3.0/AceEvent-3.0.lua:
--------------------------------------------------------------------------------
1 | --- AceEvent-3.0 provides event registration and secure dispatching.
2 | -- All dispatching is done using **CallbackHandler-1.0**. AceEvent is a simple wrapper around
3 | -- CallbackHandler, and dispatches all game events or addon message to the registrees.
4 | --
5 | -- **AceEvent-3.0** can be embeded into your addon, either explicitly by calling AceEvent:Embed(MyAddon) or by
6 | -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
7 | -- and can be accessed directly, without having to explicitly call AceEvent itself.\\
8 | -- It is recommended to embed AceEvent, otherwise you'll have to specify a custom `self` on all calls you
9 | -- make into AceEvent.
10 | -- @class file
11 | -- @name AceEvent-3.0
12 | -- @release $Id: AceEvent-3.0.lua 975 2010-10-23 11:26:18Z nevcairiel $
13 | local MAJOR, MINOR = "AceEvent-3.0", 3
14 | local AceEvent = LibStub:NewLibrary(MAJOR, MINOR)
15 |
16 | if not AceEvent then return end
17 |
18 | -- Lua APIs
19 | local pairs = pairs
20 |
21 | local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
22 |
23 | AceEvent.frame = AceEvent.frame or CreateFrame("Frame", "AceEvent30Frame") -- our event frame
24 | AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib
25 |
26 | -- APIs and registry for blizzard events, using CallbackHandler lib
27 | if not AceEvent.events then
28 | AceEvent.events = CallbackHandler:New(AceEvent,
29 | "RegisterEvent", "UnregisterEvent", "UnregisterAllEvents")
30 | end
31 |
32 | function AceEvent.events:OnUsed(target, eventname)
33 | AceEvent.frame:RegisterEvent(eventname)
34 | end
35 |
36 | function AceEvent.events:OnUnused(target, eventname)
37 | AceEvent.frame:UnregisterEvent(eventname)
38 | end
39 |
40 |
41 | -- APIs and registry for IPC messages, using CallbackHandler lib
42 | if not AceEvent.messages then
43 | AceEvent.messages = CallbackHandler:New(AceEvent,
44 | "RegisterMessage", "UnregisterMessage", "UnregisterAllMessages"
45 | )
46 | AceEvent.SendMessage = AceEvent.messages.Fire
47 | end
48 |
49 | --- embedding and embed handling
50 | local mixins = {
51 | "RegisterEvent", "UnregisterEvent",
52 | "RegisterMessage", "UnregisterMessage",
53 | "SendMessage",
54 | "UnregisterAllEvents", "UnregisterAllMessages",
55 | }
56 |
57 | --- Register for a Blizzard Event.
58 | -- 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)
59 | -- Any arguments to the event will be passed on after that.
60 | -- @name AceEvent:RegisterEvent
61 | -- @class function
62 | -- @paramsig event[, callback [, arg]]
63 | -- @param event The event to register for
64 | -- @param callback The callback function to call when the event is triggered (funcref or method, defaults to a method with the event name)
65 | -- @param arg An optional argument to pass to the callback function
66 |
67 | --- Unregister an event.
68 | -- @name AceEvent:UnregisterEvent
69 | -- @class function
70 | -- @paramsig event
71 | -- @param event The event to unregister
72 |
73 | --- Register for a custom AceEvent-internal message.
74 | -- 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)
75 | -- Any arguments to the event will be passed on after that.
76 | -- @name AceEvent:RegisterMessage
77 | -- @class function
78 | -- @paramsig message[, callback [, arg]]
79 | -- @param message The message to register for
80 | -- @param callback The callback function to call when the message is triggered (funcref or method, defaults to a method with the event name)
81 | -- @param arg An optional argument to pass to the callback function
82 |
83 | --- Unregister a message
84 | -- @name AceEvent:UnregisterMessage
85 | -- @class function
86 | -- @paramsig message
87 | -- @param message The message to unregister
88 |
89 | --- Send a message over the AceEvent-3.0 internal message system to other addons registered for this message.
90 | -- @name AceEvent:SendMessage
91 | -- @class function
92 | -- @paramsig message, ...
93 | -- @param message The message to send
94 | -- @param ... Any arguments to the message
95 |
96 |
97 | -- Embeds AceEvent into the target object making the functions from the mixins list available on target:..
98 | -- @param target target object to embed AceEvent in
99 | function AceEvent:Embed(target)
100 | for k, v in pairs(mixins) do
101 | target[v] = self[v]
102 | end
103 | self.embeds[target] = true
104 | return target
105 | end
106 |
107 | -- AceEvent:OnEmbedDisable( target )
108 | -- target (object) - target object that is being disabled
109 | --
110 | -- Unregister all events messages etc when the target disables.
111 | -- this method should be called by the target manually or by an addon framework
112 | function AceEvent:OnEmbedDisable(target)
113 | target:UnregisterAllEvents()
114 | target:UnregisterAllMessages()
115 | end
116 |
117 | -- Script to fire blizzard events into the event listeners
118 | -- Ace3v: in vanilla the arguments are set to global:
119 | -- event, arg1, arg2, arg3 ...
120 | -- the user have always access to them, so we save the table cost here
121 | local events = AceEvent.events
122 | AceEvent.frame:SetScript("OnEvent", function()
123 | events:Fire(event)
124 | end)
125 |
126 | --- Finally: upgrade our old embeds
127 | for target, v in pairs(AceEvent.embeds) do
128 | AceEvent:Embed(target)
129 | end
130 |
--------------------------------------------------------------------------------
/AceEvent-3.0/AceEvent-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceGUI-3.0/AceGUI-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-BlizOptionsGroup.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | BlizOptionsGroup Container
3 | Simple container widget for the integration of AceGUI into the Blizzard Interface Options
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "BlizOptionsGroup", 21
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | -- Lua APIs
10 | local pairs = pairs
11 |
12 | -- WoW APIs
13 | local CreateFrame = CreateFrame
14 |
15 | --[[-----------------------------------------------------------------------------
16 | Scripts
17 | -------------------------------------------------------------------------------]]
18 |
19 | local function OnShow(frame)
20 | frame.obj:Fire("OnShow")
21 | end
22 |
23 | local function OnHide(frame)
24 | frame.obj:Fire("OnHide")
25 | end
26 |
27 | --[[-----------------------------------------------------------------------------
28 | Support functions
29 | -------------------------------------------------------------------------------]]
30 |
31 | local function okay(frame)
32 | frame.obj:Fire("okay")
33 | end
34 |
35 | local function cancel(frame)
36 | frame.obj:Fire("cancel")
37 | end
38 |
39 | local function default(frame)
40 | frame.obj:Fire("default")
41 | end
42 |
43 | local function refresh(frame)
44 | frame.obj:Fire("refresh")
45 | end
46 |
47 | --[[-----------------------------------------------------------------------------
48 | Methods
49 | -------------------------------------------------------------------------------]]
50 |
51 | local methods = {
52 | ["OnAcquire"] = function(self)
53 | self:SetName()
54 | self:SetTitle()
55 | end,
56 |
57 | -- ["OnRelease"] = nil,
58 |
59 | ["OnWidthSet"] = function(self, width)
60 | local content = self.content
61 | local contentwidth = width - 63
62 | if contentwidth < 0 then
63 | contentwidth = 0
64 | end
65 | content:SetWidth(contentwidth)
66 | content.width = contentwidth
67 | end,
68 |
69 | ["OnHeightSet"] = function(self, height)
70 | local content = self.content
71 | local contentheight = height - 26
72 | if contentheight < 0 then
73 | contentheight = 0
74 | end
75 | content:SetHeight(contentheight)
76 | content.height = contentheight
77 | end,
78 |
79 | ["SetName"] = function(self, name, parent)
80 | self.frame.name = name
81 | self.frame.parent = parent
82 | end,
83 |
84 | ["SetTitle"] = function(self, title)
85 | local content = self.content
86 | content:ClearAllPoints()
87 | if not title or title == "" then
88 | content:SetPoint("TOPLEFT", 10, -10)
89 | self.label:SetText("")
90 | else
91 | content:SetPoint("TOPLEFT", 10, -40)
92 | self.label:SetText(title)
93 | end
94 | content:SetPoint("BOTTOMRIGHT", -10, 10)
95 | end
96 | }
97 |
98 | --[[-----------------------------------------------------------------------------
99 | Constructor
100 | -------------------------------------------------------------------------------]]
101 | local function Constructor()
102 | local frame = CreateFrame("Frame")
103 | frame:Hide()
104 |
105 | -- support functions for the Blizzard Interface Options
106 | frame.okay = okay
107 | frame.cancel = cancel
108 | frame.default = default
109 | frame.refresh = refresh
110 |
111 | frame:SetScript("OnHide", OnHide)
112 | frame:SetScript("OnShow", OnShow)
113 |
114 | local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
115 | label:SetPoint("TOPLEFT", 10, -15)
116 | label:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", 10, -45)
117 | label:SetJustifyH("LEFT")
118 | label:SetJustifyV("TOP")
119 |
120 | --Container Support
121 | local content = CreateFrame("Frame", nil, frame)
122 | content:SetPoint("TOPLEFT", 10, -10)
123 | content:SetPoint("BOTTOMRIGHT", -10, 10)
124 |
125 | local widget = {
126 | label = label,
127 | frame = frame,
128 | content = content,
129 | type = Type
130 | }
131 | for method, func in pairs(methods) do
132 | widget[method] = func
133 | end
134 |
135 | return AceGUI:RegisterAsContainer(widget)
136 | end
137 |
138 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
139 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-DropDownGroup.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | DropdownGroup Container
3 | Container controlled by a dropdown on the top.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "DropdownGroup", 21
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | -- Lua APIs
10 | local assert, pairs, type = assert, pairs, type
11 |
12 | -- WoW APIs
13 | local CreateFrame = CreateFrame
14 |
15 | --[[-----------------------------------------------------------------------------
16 | Scripts
17 | -------------------------------------------------------------------------------]]
18 | local function SelectedGroup(self, event, _, value)
19 | local group = self.parentgroup
20 | local status = group.status or group.localstatus
21 | status.selected = value
22 | self.parentgroup:Fire("OnGroupSelected", 1, value)
23 | end
24 |
25 | --[[-----------------------------------------------------------------------------
26 | Methods
27 | -------------------------------------------------------------------------------]]
28 | local methods = {
29 | ["OnAcquire"] = function(self)
30 | self.dropdown:SetText("")
31 | self:SetDropdownWidth(200)
32 | self:SetTitle("")
33 | end,
34 |
35 | ["OnRelease"] = function(self)
36 | self.dropdown.list = nil
37 | self.status = nil
38 | for k in pairs(self.localstatus) do
39 | self.localstatus[k] = nil
40 | end
41 | end,
42 |
43 | ["SetTitle"] = function(self, title)
44 | self.titletext:SetText(title)
45 | self.dropdown.frame:ClearAllPoints()
46 | if title and title ~= "" then
47 | self.dropdown.frame:SetPoint("TOPRIGHT", -2, 0)
48 | else
49 | self.dropdown.frame:SetPoint("TOPLEFT", -1, 0)
50 | end
51 | end,
52 |
53 | ["SetGroupList"] = function(self,list,order)
54 | self.dropdown:SetList(list,order)
55 | end,
56 |
57 | ["SetStatusTable"] = function(self, status)
58 | assert(type(status) == "table")
59 | self.status = status
60 | end,
61 |
62 | ["SetGroup"] = function(self,group)
63 | self.dropdown:SetValue(group)
64 | local status = self.status or self.localstatus
65 | status.selected = group
66 | self:Fire("OnGroupSelected", 1, group)
67 | end,
68 |
69 | ["OnWidthSet"] = function(self, width)
70 | local content = self.content
71 | local contentwidth = width - 26
72 | if contentwidth < 0 then
73 | contentwidth = 0
74 | end
75 | content:SetWidth(contentwidth)
76 | content.width = contentwidth
77 | end,
78 |
79 | ["OnHeightSet"] = function(self, height)
80 | local content = self.content
81 | local contentheight = height - 63
82 | if contentheight < 0 then
83 | contentheight = 0
84 | end
85 | content:SetHeight(contentheight)
86 | content.height = contentheight
87 | end,
88 |
89 | ["LayoutFinished"] = function(self, width, height)
90 | self:SetHeight((height or 0) + 63)
91 | end,
92 |
93 | ["SetDropdownWidth"] = function(self, width)
94 | self.dropdown:SetWidth(width)
95 | end
96 | }
97 |
98 | --[[-----------------------------------------------------------------------------
99 | Constructor
100 | -------------------------------------------------------------------------------]]
101 | local PaneBackdrop = {
102 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
103 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
104 | tile = true, tileSize = 16, edgeSize = 16,
105 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
106 | }
107 |
108 | local function Constructor()
109 | local frame = CreateFrame("Frame")
110 | frame:SetHeight(100)
111 | frame:SetWidth(100)
112 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
113 |
114 | local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
115 | titletext:SetPoint("TOPLEFT", 4, -5)
116 | titletext:SetPoint("TOPRIGHT", -4, -5)
117 | titletext:SetJustifyH("LEFT")
118 | titletext:SetHeight(18)
119 |
120 | local dropdown = AceGUI:Create("Dropdown")
121 | dropdown.frame:SetParent(frame)
122 | dropdown.frame:SetFrameLevel(dropdown.frame:GetFrameLevel() + 2)
123 | dropdown:SetCallback("OnValueChanged", SelectedGroup)
124 | dropdown.frame:SetPoint("TOPLEFT", -1, 0)
125 | dropdown.frame:Show()
126 | dropdown:SetLabel("")
127 |
128 | local border = CreateFrame("Frame", nil, frame)
129 | border:SetPoint("TOPLEFT", 0, -26)
130 | border:SetPoint("BOTTOMRIGHT", 0, 3)
131 | border:SetBackdrop(PaneBackdrop)
132 | border:SetBackdropColor(0.1,0.1,0.1,0.5)
133 | border:SetBackdropBorderColor(0.4,0.4,0.4)
134 |
135 | --Container Support
136 | local content = CreateFrame("Frame", nil, border)
137 | content:SetPoint("TOPLEFT", 10, -10)
138 | content:SetPoint("BOTTOMRIGHT", -10, 10)
139 |
140 | local widget = {
141 | frame = frame,
142 | localstatus = {},
143 | titletext = titletext,
144 | dropdown = dropdown,
145 | border = border,
146 | content = content,
147 | type = Type
148 | }
149 | for method, func in pairs(methods) do
150 | widget[method] = func
151 | end
152 | dropdown.parentgroup = widget
153 |
154 | return AceGUI:RegisterAsContainer(widget)
155 | end
156 |
157 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
158 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-Frame.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Frame Container
3 | -------------------------------------------------------------------------------]]
4 | local Type, Version = "Frame", 24
5 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7 |
8 | local AceCore = LibStub("AceCore-3.0")
9 | local wipe = AceCore.wipe
10 |
11 | -- Lua APIs
12 | local pairs, assert, type = pairs, assert, type
13 |
14 | -- WoW APIs
15 | local PlaySound = PlaySound
16 | local CreateFrame, UIParent = CreateFrame, UIParent
17 |
18 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
19 | -- List them here for Mikk's FindGlobals script
20 | -- GLOBALS: CLOSE
21 |
22 | --[[-----------------------------------------------------------------------------
23 | Scripts
24 | -------------------------------------------------------------------------------]]
25 | local function Button_OnClick()
26 | PlaySound("gsTitleOptionExit")
27 | this.obj:Hide()
28 | end
29 |
30 | local function Frame_OnClose()
31 | this.obj:Fire("OnClose")
32 | end
33 |
34 | local function Frame_OnMouseDown()
35 | AceGUI:ClearFocus()
36 | end
37 |
38 | local function Title_OnMouseDown()
39 | this:GetParent():StartMoving()
40 | AceGUI:ClearFocus()
41 | end
42 |
43 | local function MoverSizer_OnMouseUp()
44 | local frame = this:GetParent()
45 | frame:StopMovingOrSizing()
46 | local self = frame.obj
47 | local status = self.status or self.localstatus
48 | status.width = frame:GetWidth()
49 | status.height = frame:GetHeight()
50 | status.top = frame:GetTop()
51 | status.left = frame:GetLeft()
52 | end
53 |
54 | local function SizerSE_OnMouseDown()
55 | this:GetParent():StartSizing("BOTTOMRIGHT")
56 | AceGUI:ClearFocus()
57 | end
58 |
59 | local function SizerS_OnMouseDown()
60 | this:GetParent():StartSizing("BOTTOM")
61 | AceGUI:ClearFocus()
62 | end
63 |
64 | local function SizerE_OnMouseDown()
65 | this:GetParent():StartSizing("RIGHT")
66 | AceGUI:ClearFocus()
67 | end
68 |
69 | local function StatusBar_OnEnter()
70 | this.obj:Fire("OnEnterStatusBar")
71 | end
72 |
73 | local function StatusBar_OnLeave()
74 | this.obj:Fire("OnLeaveStatusBar")
75 | end
76 |
77 | --[[-----------------------------------------------------------------------------
78 | Methods
79 | -------------------------------------------------------------------------------]]
80 | local methods = {
81 | ["OnAcquire"] = function(self)
82 | self.frame:SetParent(UIParent)
83 | self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
84 | self:SetTitle()
85 | self:SetStatusText()
86 | self:ApplyStatus()
87 | self:Show()
88 | self:EnableResize(true)
89 | end,
90 |
91 | ["OnRelease"] = function(self)
92 | self.status = nil
93 | wipe(self.localstatus)
94 | end,
95 |
96 | ["OnWidthSet"] = function(self, width)
97 | local content = self.content
98 | local contentwidth = width - 34
99 | if contentwidth < 0 then
100 | contentwidth = 0
101 | end
102 | content:SetWidth(contentwidth)
103 | content.width = contentwidth
104 | end,
105 |
106 | ["OnHeightSet"] = function(self, height)
107 | local content = self.content
108 | local contentheight = height - 57
109 | if contentheight < 0 then
110 | contentheight = 0
111 | end
112 | content:SetHeight(contentheight)
113 | content.height = contentheight
114 | end,
115 |
116 | ["SetTitle"] = function(self, title)
117 | self.titletext:SetText(title)
118 | self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
119 | end,
120 |
121 | ["SetStatusText"] = function(self, text)
122 | self.statustext:SetText(text)
123 | end,
124 |
125 | ["Hide"] = function(self)
126 | self.frame:Hide()
127 | end,
128 |
129 | ["Show"] = function(self)
130 | self.frame:Show()
131 | end,
132 |
133 | ["EnableResize"] = function(self, state)
134 | local func = state and "Show" or "Hide"
135 | self.sizer_se[func](self.sizer_se)
136 | self.sizer_s[func](self.sizer_s)
137 | self.sizer_e[func](self.sizer_e)
138 | end,
139 |
140 | -- called to set an external table to store status in
141 | ["SetStatusTable"] = function(self, status)
142 | assert(type(status) == "table")
143 | self.status = status
144 | self:ApplyStatus()
145 | end,
146 |
147 | ["ApplyStatus"] = function(self)
148 | local status = self.status or self.localstatus
149 | local frame = self.frame
150 | self:SetWidth(status.width or 700)
151 | self:SetHeight(status.height or 500)
152 | frame:ClearAllPoints()
153 | if status.top and status.left then
154 | frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
155 | frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
156 | else
157 | frame:SetPoint("CENTER", UIParent)
158 | end
159 | end
160 | }
161 |
162 | --[[-----------------------------------------------------------------------------
163 | Constructor
164 | -------------------------------------------------------------------------------]]
165 | local FrameBackdrop = {
166 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
167 | edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
168 | tile = true, tileSize = 32, edgeSize = 32,
169 | insets = { left = 8, right = 8, top = 8, bottom = 8 }
170 | }
171 |
172 | local PaneBackdrop = {
173 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
174 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
175 | tile = true, tileSize = 16, edgeSize = 16,
176 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
177 | }
178 |
179 | local function Constructor()
180 | local frame = CreateFrame("Frame", nil, UIParent)
181 | frame:Hide()
182 |
183 | frame:EnableMouse(true)
184 | frame:SetMovable(true)
185 | frame:SetResizable(true)
186 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
187 | frame:SetBackdrop(FrameBackdrop)
188 | frame:SetBackdropColor(0, 0, 0, 1)
189 | frame:SetMinResize(400, 200)
190 | frame:SetToplevel(true)
191 | frame:SetScript("OnHide", Frame_OnClose)
192 | frame:SetScript("OnMouseDown", Frame_OnMouseDown)
193 |
194 | local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
195 | closebutton:SetScript("OnClick", Button_OnClick)
196 | closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
197 | closebutton:SetHeight(20)
198 | closebutton:SetWidth(100)
199 | closebutton:SetText(CLOSE)
200 |
201 | local statusbg = CreateFrame("Button", nil, frame)
202 | statusbg:SetPoint("BOTTOMLEFT", 15, 15)
203 | statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
204 | statusbg:SetHeight(24)
205 | statusbg:SetBackdrop(PaneBackdrop)
206 | statusbg:SetBackdropColor(0.1,0.1,0.1)
207 | statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
208 | statusbg:SetScript("OnEnter", StatusBar_OnEnter)
209 | statusbg:SetScript("OnLeave", StatusBar_OnLeave)
210 |
211 | local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
212 | statustext:SetPoint("TOPLEFT", 7, -2)
213 | statustext:SetPoint("BOTTOMRIGHT", -7, 2)
214 | statustext:SetHeight(20)
215 | statustext:SetJustifyH("LEFT")
216 | statustext:SetText("")
217 |
218 | local titlebg = frame:CreateTexture(nil, "OVERLAY")
219 | titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
220 | titlebg:SetTexCoord(0.31, 0.67, 0, 0.63)
221 | titlebg:SetPoint("TOP", 0, 12)
222 | titlebg:SetWidth(100)
223 | titlebg:SetHeight(40)
224 |
225 | local title = CreateFrame("Frame", nil, frame)
226 | title:EnableMouse(true)
227 | title:SetScript("OnMouseDown", Title_OnMouseDown)
228 | title:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
229 | title:SetAllPoints(titlebg)
230 |
231 | local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal")
232 | titletext:SetPoint("TOP", titlebg, "TOP", 0, -14)
233 |
234 | local titlebg_l = frame:CreateTexture(nil, "OVERLAY")
235 | titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
236 | titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
237 | titlebg_l:SetPoint("RIGHT", titlebg, "LEFT")
238 | titlebg_l:SetWidth(30)
239 | titlebg_l:SetHeight(40)
240 |
241 | local titlebg_r = frame:CreateTexture(nil, "OVERLAY")
242 | titlebg_r:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
243 | titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
244 | titlebg_r:SetPoint("LEFT", titlebg, "RIGHT")
245 | titlebg_r:SetWidth(30)
246 | titlebg_r:SetHeight(40)
247 |
248 | -- bottom right sizer
249 | local sizer_se = CreateFrame("Frame", nil, frame)
250 | sizer_se:SetPoint("BOTTOMRIGHT", 0, 0)
251 | sizer_se:SetWidth(25)
252 | sizer_se:SetHeight(25)
253 | sizer_se:EnableMouse()
254 | sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown)
255 | sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
256 |
257 | local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
258 | line1:SetPoint("BOTTOMRIGHT", -10, 10)
259 | line1:SetTexture("Interface\\Cursor\\Item")
260 | line1:SetTexCoord(1, 0, 1, 0)
261 |
262 | local sizer_s = CreateFrame("Frame", nil, frame)
263 | sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
264 | sizer_s:SetPoint("BOTTOMLEFT", 0, 0)
265 | sizer_s:SetHeight(25)
266 | sizer_s:EnableMouse(true)
267 | sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
268 | sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
269 |
270 | local sizer_e = CreateFrame("Frame", nil, frame)
271 | sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
272 | sizer_e:SetPoint("TOPRIGHT", 0, 0)
273 | sizer_e:SetWidth(25)
274 | sizer_e:EnableMouse(true)
275 | sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
276 | sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
277 |
278 | --Container Support
279 | local content = CreateFrame("Frame", nil, frame)
280 | content:SetPoint("TOPLEFT", 17, -27)
281 | content:SetPoint("BOTTOMRIGHT", -17, 40)
282 |
283 | local widget = {
284 | localstatus = {},
285 | titletext = titletext,
286 | statustext = statustext,
287 | titlebg = titlebg,
288 | sizer_se = sizer_se,
289 | sizer_s = sizer_s,
290 | sizer_e = sizer_e,
291 | content = content,
292 | frame = frame,
293 | type = Type
294 | }
295 | for method, func in pairs(methods) do
296 | widget[method] = func
297 | end
298 | closebutton.obj, statusbg.obj = widget, widget
299 |
300 | return AceGUI:RegisterAsContainer(widget)
301 | end
302 |
303 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
304 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | InlineGroup Container
3 | Simple container widget that creates a visible "box" with an optional title.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "InlineGroup", 21
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | -- Lua APIs
10 | local pairs = pairs
11 |
12 | -- WoW APIs
13 | local CreateFrame, UIParent = CreateFrame, UIParent
14 |
15 | --[[-----------------------------------------------------------------------------
16 | Methods
17 | -------------------------------------------------------------------------------]]
18 | local methods = {
19 | ["OnAcquire"] = function(self)
20 | self:SetWidth(300)
21 | self:SetHeight(100)
22 | self:SetTitle("")
23 | end,
24 |
25 | -- ["OnRelease"] = nil,
26 |
27 | ["SetTitle"] = function(self,title)
28 | self.titletext:SetText(title)
29 | end,
30 |
31 |
32 | ["LayoutFinished"] = function(self, width, height)
33 | if self.noAutoHeight then return end
34 | self:SetHeight((height or 0) + 40)
35 | end,
36 |
37 | ["OnWidthSet"] = function(self, width)
38 | local content = self.content
39 | local contentwidth = width - 20
40 | if contentwidth < 0 then
41 | contentwidth = 0
42 | end
43 | content:SetWidth(contentwidth)
44 | content.width = contentwidth
45 | end,
46 |
47 | ["OnHeightSet"] = function(self, height)
48 | local content = self.content
49 | local contentheight = height - 20
50 | if contentheight < 0 then
51 | contentheight = 0
52 | end
53 | content:SetHeight(contentheight)
54 | content.height = contentheight
55 | end
56 | }
57 |
58 | --[[-----------------------------------------------------------------------------
59 | Constructor
60 | -------------------------------------------------------------------------------]]
61 | local PaneBackdrop = {
62 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
63 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
64 | tile = true, tileSize = 16, edgeSize = 16,
65 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
66 | }
67 |
68 | local function Constructor()
69 | local frame = CreateFrame("Frame", nil, UIParent)
70 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
71 |
72 | local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
73 | titletext:SetPoint("TOPLEFT", 14, 0)
74 | titletext:SetPoint("TOPRIGHT", -14, 0)
75 | titletext:SetJustifyH("LEFT")
76 | titletext:SetHeight(18)
77 |
78 | local border = CreateFrame("Frame", nil, frame)
79 | border:SetPoint("TOPLEFT", 0, -17)
80 | border:SetPoint("BOTTOMRIGHT", -1, 3)
81 | border:SetBackdrop(PaneBackdrop)
82 | border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
83 | border:SetBackdropBorderColor(0.4, 0.4, 0.4)
84 |
85 | --Container Support
86 | local content = CreateFrame("Frame", nil, border)
87 | content:SetPoint("TOPLEFT", 10, -10)
88 | content:SetPoint("BOTTOMRIGHT", -10, 10)
89 |
90 | local widget = {
91 | frame = frame,
92 | content = content,
93 | titletext = titletext,
94 | type = Type
95 | }
96 | for method, func in pairs(methods) do
97 | widget[method] = func
98 | end
99 |
100 | return AceGUI:RegisterAsContainer(widget)
101 | end
102 |
103 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
104 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-ScrollFrame.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | ScrollFrame Container
3 | Plain container that scrolls its content and doesn't grow in height.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "ScrollFrame", 24
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | local fixlevels = AceGUI.fixlevels
10 |
11 | -- Lua APIs
12 | local pairs, assert, type = pairs, assert, type
13 | local min, max, floor, abs = math.min, math.max, math.floor, math.abs
14 | local format = string.format
15 |
16 | -- WoW APIs
17 | local CreateFrame, UIParent = CreateFrame, UIParent
18 |
19 | --[[-----------------------------------------------------------------------------
20 | Support functions
21 | -------------------------------------------------------------------------------]]
22 | local function FixScrollOnUpdate()
23 | this:SetScript("OnUpdate", nil)
24 | this.obj:FixScroll()
25 | end
26 |
27 | --[[-----------------------------------------------------------------------------
28 | Scripts
29 | -------------------------------------------------------------------------------]]
30 | local function ScrollFrame_OnMouseWheel()
31 | this.obj:MoveScroll(arg1)
32 | end
33 |
34 | local function ScrollFrame_OnSizeChanged()
35 | this:SetScript("OnUpdate", FixScrollOnUpdate)
36 | end
37 |
38 | local function ScrollBar_OnScrollValueChanged()
39 | this.obj:SetScroll(arg1)
40 | end
41 |
42 | --[[-----------------------------------------------------------------------------
43 | Methods
44 | -------------------------------------------------------------------------------]]
45 | local methods = {
46 | ["OnAcquire"] = function(self)
47 | self:SetScroll(0)
48 | self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
49 | end,
50 |
51 | ["OnRelease"] = function(self)
52 | self.status = nil
53 | for k in pairs(self.localstatus) do
54 | self.localstatus[k] = nil
55 | end
56 | self.scrollframe:SetPoint("BOTTOMRIGHT",0,0)
57 | self.scrollbar:Hide()
58 | self.scrollBarShown = nil
59 | self.content.height, self.content.width = nil, nil
60 | end,
61 |
62 | ["SetScroll"] = function(self, value)
63 | local status = self.status or self.localstatus
64 | local viewheight = self.scrollframe:GetHeight()
65 | local height = self.content:GetHeight()
66 | local offset
67 |
68 | if viewheight > height then
69 | offset = 0
70 | else
71 | offset = floor((height - viewheight) / 1000.0 * value)
72 | end
73 | self.content:ClearAllPoints()
74 | self.content:SetPoint("TOPLEFT", 0, offset)
75 | self.content:SetPoint("TOPRIGHT", 0, offset)
76 | status.offset = offset
77 | status.scrollvalue = value
78 | end,
79 |
80 | ["MoveScroll"] = function(self, value)
81 | local status = self.status or self.localstatus
82 | local height, viewheight = self.scrollframe:GetHeight(), self.content:GetHeight()
83 |
84 | if self.scrollBarShown then
85 | local diff = height - viewheight
86 | local delta = 1
87 | if value < 0 then
88 | delta = -1
89 | end
90 | self.scrollbar:SetValue(min(max(status.scrollvalue + delta*(1000/(diff/45)),0), 1000))
91 | end
92 | end,
93 |
94 | ["FixScroll"] = function(self)
95 |
96 | if self.updateLock then return end
97 | self.updateLock = true
98 | local status = self.status or self.localstatus
99 | local scrollframe, content, scrollbar = self.scrollframe, self.content, self.scrollbar
100 | local viewheight, height = self.scrollframe:GetHeight(), self.content:GetHeight()
101 | local offset = status.offset or 0
102 | local curvalue = scrollbar:GetValue()
103 | -- Give us a margin of error of 2 pixels to stop some conditions that i would blame on floating point inaccuracys
104 | -- No-one is going to miss 2 pixels at the bottom of the frame, anyhow!
105 |
106 | if height < viewheight + 2 then
107 | if self.scrollBarShown then
108 | self.scrollBarShown = nil
109 | scrollbar:Hide()
110 | scrollbar:SetValue(0)
111 | scrollframe:SetPoint("BOTTOMRIGHT",0,0)
112 | self:DoLayout()
113 | end
114 | offset = 0
115 | else
116 | if not self.scrollBarShown then
117 | self.scrollBarShown = true
118 | scrollbar:Show()
119 | scrollframe:SetPoint("BOTTOMRIGHT", -20, 0)
120 | self:DoLayout()
121 | end
122 | local value = (offset / (height - viewheight) * 1000)
123 | if value > 1000 then
124 | value = 1000
125 | offset = height - viewheight
126 | end
127 | scrollbar:SetValue(value)
128 | self:SetScroll(value)
129 | end
130 | status.offset = offset
131 | scrollframe:SetScrollChild(content)
132 | content:ClearAllPoints()
133 | content:SetPoint("TOPLEFT", 0, offset)
134 | content:SetPoint("TOPRIGHT", 0, offset)
135 | self.updateLock = nil
136 | end,
137 |
138 | ["LayoutFinished"] = function(self, width, height)
139 | self.content:SetHeight(height or 0 + 20)
140 | self.scrollframe:SetScript("OnUpdate", FixScrollOnUpdate)
141 | end,
142 |
143 | ["SetStatusTable"] = function(self, status)
144 | assert(type(status) == "table")
145 | self.status = status
146 | if not status.scrollvalue then
147 | status.scrollvalue = 0
148 | end
149 | end,
150 |
151 | ["OnWidthSet"] = function(self, width)
152 | local content = self.content
153 | content.width = width
154 | end,
155 |
156 | ["OnHeightSet"] = function(self, height)
157 | local content = self.content
158 | content.height = height
159 | end
160 | }
161 | --[[-----------------------------------------------------------------------------
162 | Constructor
163 | -------------------------------------------------------------------------------]]
164 | local function Constructor()
165 | local frame = CreateFrame("Frame", nil, UIParent)
166 | local num = AceGUI:GetNextWidgetNum(Type)
167 |
168 | local scrollframe = CreateFrame("ScrollFrame", nil, frame)
169 | scrollframe:SetPoint("TOPLEFT",0,0)
170 | scrollframe:SetPoint("BOTTOMRIGHT",0,0)
171 | scrollframe:EnableMouseWheel(true)
172 | scrollframe:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel)
173 | scrollframe:SetScript("OnSizeChanged", ScrollFrame_OnSizeChanged)
174 |
175 | local scrollbar = CreateFrame("Slider", format("AceConfigDialogScrollFrame%dScrollBar", num), scrollframe, "UIPanelScrollBarTemplate")
176 | scrollbar:SetPoint("TOPLEFT", scrollframe, "TOPRIGHT", 4, -16)
177 | scrollbar:SetPoint("BOTTOMLEFT", scrollframe, "BOTTOMRIGHT", 4, 16)
178 | scrollbar:SetMinMaxValues(0, 1000)
179 | scrollbar:SetValueStep(1)
180 | scrollbar:SetValue(0)
181 | scrollbar:SetWidth(16)
182 | scrollbar:Hide()
183 | -- set the script as the last step, so it doesn't fire yet
184 | scrollbar:SetScript("OnValueChanged", ScrollBar_OnScrollValueChanged)
185 |
186 | local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND")
187 | scrollbg:SetAllPoints(scrollbar)
188 | scrollbg:SetTexture(0, 0, 0, 0.4)
189 |
190 | --Container Support
191 | local content = CreateFrame("Frame", nil, scrollframe)
192 | content:SetPoint("TOPLEFT",0,0)
193 | content:SetPoint("TOPRIGHT",0,0)
194 | content:SetHeight(400)
195 | scrollframe:SetScrollChild(content)
196 |
197 | local widget = {
198 | localstatus = { scrollvalue = 0 },
199 | scrollframe = scrollframe,
200 | scrollbar = scrollbar,
201 | content = content,
202 | frame = frame,
203 | type = Type
204 | }
205 | for method, func in pairs(methods) do
206 | widget[method] = func
207 | end
208 | scrollframe.obj, scrollbar.obj = widget, widget
209 |
210 | return AceGUI:RegisterAsContainer(widget)
211 | end
212 |
213 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
214 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-SimpleGroup.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | SimpleGroup Container
3 | Simple container widget that just groups widgets.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "SimpleGroup", 20
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | -- Lua APIs
10 | local pairs = pairs
11 |
12 | -- WoW APIs
13 | local CreateFrame, UIParent = CreateFrame, UIParent
14 |
15 |
16 | --[[-----------------------------------------------------------------------------
17 | Methods
18 | -------------------------------------------------------------------------------]]
19 | local methods = {
20 | ["OnAcquire"] = function(self)
21 | self:SetWidth(300)
22 | self:SetHeight(100)
23 | end,
24 |
25 | -- ["OnRelease"] = nil,
26 |
27 | ["LayoutFinished"] = function(self, width, height)
28 | if self.noAutoHeight then return end
29 | self:SetHeight(height or 0)
30 | end,
31 |
32 | ["OnWidthSet"] = function(self, width)
33 | local content = self.content
34 | content:SetWidth(width)
35 | content.width = width
36 | end,
37 |
38 | ["OnHeightSet"] = function(self, height)
39 | local content = self.content
40 | content:SetHeight(height)
41 | content.height = height
42 | end
43 | }
44 |
45 | --[[-----------------------------------------------------------------------------
46 | Constructor
47 | -------------------------------------------------------------------------------]]
48 | local function Constructor()
49 | local frame = CreateFrame("Frame", nil, UIParent)
50 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
51 |
52 | --Container Support
53 | local content = CreateFrame("Frame", nil, frame)
54 | content:SetPoint("TOPLEFT")
55 | content:SetPoint("BOTTOMRIGHT")
56 |
57 | local widget = {
58 | frame = frame,
59 | content = content,
60 | type = Type
61 | }
62 | for method, func in pairs(methods) do
63 | widget[method] = func
64 | end
65 |
66 | return AceGUI:RegisterAsContainer(widget)
67 | end
68 |
69 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
70 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-TabGroup.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | TabGroup Container
3 | Container that uses tabs on top to switch between groups.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "TabGroup", 35
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | local AceCore = LibStub("AceCore-3.0")
10 | local wipe = AceCore.wipe
11 |
12 | -- Lua APIs
13 | local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
14 | local tgetn = table.getn
15 | local strfmt = string.format
16 |
17 | -- WoW APIs
18 | local PlaySound = PlaySound
19 | local CreateFrame, UIParent = CreateFrame, UIParent
20 | local _G = AceCore._G
21 |
22 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
23 | -- List them here for Mikk's FindGlobals script
24 | -- GLOBALS: PanelTemplates_TabResize, PanelTemplates_SetDisabledTabState, PanelTemplates_SelectTab, PanelTemplates_DeselectTab
25 |
26 | -- local upvalue storage used by BuildTabs
27 | local widths = {}
28 | local rowwidths = {}
29 | local rowends = {}
30 |
31 | --[[-----------------------------------------------------------------------------
32 | Support functions
33 | -------------------------------------------------------------------------------]]
34 | local function UpdateTabLook(frame)
35 | if frame.disabled then
36 | PanelTemplates_SetDisabledTabState(frame)
37 | frame:SetAlpha(0.5)
38 | elseif frame.selected then
39 | PanelTemplates_SelectTab(frame)
40 | frame:SetAlpha(1)
41 | else
42 | PanelTemplates_DeselectTab(frame)
43 | frame:SetAlpha(0.5)
44 | end
45 | end
46 |
47 | local function Tab_SetText(tab, text)
48 | tab:_SetText(text)
49 | local width = tab.obj.frame.width or tab.obj.frame:GetWidth() or 0
50 | PanelTemplates_TabResize(0, tab, nil, width)
51 | end
52 |
53 | local function Tab_SetSelected(tab, selected)
54 | tab.selected = selected
55 | UpdateTabLook(tab)
56 | end
57 |
58 | local function Tab_SetDisabled(tab, disabled)
59 | tab.disabled = disabled
60 | UpdateTabLook(tab)
61 | end
62 |
63 | local function BuildTabsOnUpdate()
64 | local self = this.obj
65 | self:BuildTabs()
66 | this:SetScript("OnUpdate", nil)
67 | end
68 |
69 | --[[-----------------------------------------------------------------------------
70 | Scripts
71 | -------------------------------------------------------------------------------]]
72 | local function Tab_OnClick()
73 | if not (this.selected or this.disabled) then
74 | PlaySound("igCharacterInfoTab")
75 | this.obj:SelectTab(this.value)
76 | end
77 | end
78 |
79 | local function Tab_OnEnter()
80 | local self = this.obj
81 | self:Fire("OnTabEnter", 2, self.tabs[this.id].value, this)
82 | end
83 |
84 | local function Tab_OnLeave()
85 | local self = this.obj
86 | self:Fire("OnTabLeave", 2, self.tabs[this.id].value, this)
87 | end
88 |
89 | local function Tab_OnShow()
90 | _G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
91 | end
92 |
93 | --[[-----------------------------------------------------------------------------
94 | Methods
95 | -------------------------------------------------------------------------------]]
96 | local methods = {
97 | ["OnAcquire"] = function(self)
98 | self:SetTitle()
99 | end,
100 |
101 | ["OnRelease"] = function(self)
102 | self.status = nil
103 | for k in pairs(self.localstatus) do
104 | self.localstatus[k] = nil
105 | end
106 | self.tablist = nil
107 | for _, tab in pairs(self.tabs) do
108 | tab:Hide()
109 | end
110 | end,
111 |
112 | ["CreateTab"] = function(self, id)
113 | local tabname = strfmt("AceGUITabGroup%dTab%d", self.num, id)
114 | local tab = CreateFrame("Button", tabname, self.border, "TabButtonTemplate")
115 | -- Normal texture
116 | local texture = getglobal(tabname.."Left")
117 | texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
118 | texture:ClearAllPoints()
119 | texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
120 | texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
121 | texture = getglobal(tabname.."Middle")
122 | texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
123 | texture = getglobal(tabname.."Right")
124 | texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
125 | -- Disabled texture
126 | texture = getglobal(tabname.."LeftDisabled")
127 | texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
128 | texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
129 | texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
130 | texture = getglobal(tabname.."MiddleDisabled")
131 | texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
132 | texture = getglobal(tabname.."RightDisabled")
133 | texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
134 |
135 | tab.obj = self
136 | tab.id = id
137 |
138 | tab:SetScript("OnClick", Tab_OnClick)
139 | tab:SetScript("OnEnter", Tab_OnEnter)
140 | tab:SetScript("OnLeave", Tab_OnLeave)
141 | tab:SetScript("OnShow", Tab_OnShow)
142 |
143 | tab._SetText = tab.SetText
144 | tab.SetText = Tab_SetText
145 | tab.SetSelected = Tab_SetSelected
146 | tab.SetDisabled = Tab_SetDisabled
147 |
148 | return tab
149 | end,
150 |
151 | ["SetTitle"] = function(self, text)
152 | self.titletext:SetText(text or "")
153 | if text and text ~= "" then
154 | self.alignoffset = 25
155 | else
156 | self.alignoffset = 18
157 | end
158 | self:BuildTabs()
159 | end,
160 |
161 | ["SetStatusTable"] = function(self, status)
162 | assert(type(status) == "table")
163 | self.status = status
164 | end,
165 |
166 | ["SelectTab"] = function(self, value)
167 | local status = self.status or self.localstatus
168 | local found
169 | for i, v in ipairs(self.tabs) do
170 | if v.value == value then
171 | v:SetSelected(true)
172 | found = true
173 | else
174 | v:SetSelected(false)
175 | end
176 | end
177 | status.selected = value
178 | if found then
179 | self:Fire("OnGroupSelected",1,value)
180 | end
181 | end,
182 |
183 | ["SetTabs"] = function(self, tabs)
184 | self.tablist = tabs
185 | self:BuildTabs()
186 | end,
187 |
188 |
189 | ["BuildTabs"] = function(self)
190 | local hastitle = (self.titletext:GetText() and self.titletext:GetText() ~= "")
191 | local status = self.status or self.localstatus
192 | local tablist = self.tablist
193 | local tabs = self.tabs
194 |
195 | if not tablist then return end
196 |
197 | local width = self.frame.width or self.frame:GetWidth() or 0
198 |
199 | wipe(widths)
200 | wipe(rowwidths)
201 | wipe(rowends)
202 |
203 | --Place Text into tabs and get thier initial width
204 | for i, v in ipairs(tablist) do
205 | local tab = tabs[i]
206 | if not tab then
207 | tab = self:CreateTab(i)
208 | tabs[i] = tab
209 | end
210 |
211 | tab:Show()
212 | if type(v) == "table" then
213 | tab:SetText(v.text)
214 | tab:SetDisabled(v.disabled)
215 | tab.value = v.value
216 | elseif type(v) == "string" then
217 | tab:SetText(v)
218 | tab.value = v
219 | end
220 |
221 | widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
222 | end
223 |
224 | for i = tgetn(tablist)+1, tgetn(tabs), 1 do
225 | tabs[i]:Hide()
226 | end
227 |
228 | --First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
229 | local numtabs = tgetn(tablist)
230 | local numrows = 1
231 | local usedwidth = 0
232 |
233 | for i = 1, tgetn(tablist) do
234 | --If this is not the first tab of a row and there isn't room for it
235 | if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
236 | rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
237 | rowends[numrows] = i - 1
238 | numrows = numrows + 1
239 | usedwidth = 0
240 | end
241 | usedwidth = usedwidth + widths[i]
242 | end
243 | rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
244 | rowends[numrows] = tgetn(tablist)
245 |
246 | --Fix for single tabs being left on the last row, move a tab from the row above if applicable
247 | if numrows > 1 then
248 | --if the last row has only one tab
249 | if rowends[numrows-1] == numtabs-1 then
250 | --if there are more than 2 tabs in the 2nd last row
251 | if (numrows == 2 and rowends[numrows-1] > 2) or (rowends[numrows] - rowends[numrows-1] > 2) then
252 | --move 1 tab from the second last row to the last, if there is enough space
253 | if (rowwidths[numrows] + widths[numtabs-1]) <= width then
254 | rowends[numrows-1] = rowends[numrows-1] - 1
255 | rowwidths[numrows] = rowwidths[numrows] + widths[numtabs-1]
256 | rowwidths[numrows-1] = rowwidths[numrows-1] - widths[numtabs-1]
257 | end
258 | end
259 | end
260 | end
261 |
262 | --anchor the rows as defined and resize tabs to fill thier row
263 | local starttab = 1
264 | for row, endtab in ipairs(rowends) do
265 | local first = true
266 | for tabno = starttab, endtab do
267 | local tab = tabs[tabno]
268 | tab:ClearAllPoints()
269 | if first then
270 | tab:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, -(hastitle and 14 or 7)-(row-1)*20 )
271 | first = false
272 | else
273 | tab:SetPoint("LEFT", tabs[tabno-1], "RIGHT", -10, 0)
274 | end
275 | end
276 |
277 | -- equal padding for each tab to fill the available width,
278 | -- if the used space is above 75% already
279 | -- the 18 pixel is the typical width of a scrollbar, so we can have a tab group inside a scrolling frame,
280 | -- and not have the tabs jump around funny when switching between tabs that need scrolling and those that don't
281 | local padding = 0
282 | if not (numrows == 1 and rowwidths[1] < width*0.75 - 18) then
283 | padding = (width - rowwidths[row]) / (endtab - starttab+1)
284 | end
285 |
286 | for i = starttab, endtab do
287 | PanelTemplates_TabResize(padding + 4, tabs[i], nil, width)
288 | end
289 | starttab = endtab + 1
290 | end
291 |
292 | self.borderoffset = (hastitle and 17 or 10)+((numrows)*20)+7
293 | self.border:SetPoint("TOPLEFT", 1, -self.borderoffset)
294 | end,
295 |
296 | ["OnWidthSet"] = function(self, width)
297 | local content = self.content
298 | local contentwidth = width - 60
299 | if contentwidth < 0 then
300 | contentwidth = 0
301 | end
302 | content:SetWidth(contentwidth)
303 | content.width = contentwidth
304 | self:BuildTabs(self)
305 | self.frame:SetScript("OnUpdate", BuildTabsOnUpdate)
306 | end,
307 |
308 | ["OnHeightSet"] = function(self, height)
309 | local content = self.content
310 | local contentheight = height - (self.borderoffset + 23)
311 | if contentheight < 0 then
312 | contentheight = 0
313 | end
314 | content:SetHeight(contentheight)
315 | content.height = contentheight
316 | end,
317 |
318 | ["LayoutFinished"] = function(self, width, height)
319 | if self.noAutoHeight then return end
320 | self:SetHeight((height or 0) + (self.borderoffset + 23))
321 | end
322 | }
323 |
324 | --[[-----------------------------------------------------------------------------
325 | Constructor
326 | -------------------------------------------------------------------------------]]
327 | local PaneBackdrop = {
328 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
329 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
330 | tile = true, tileSize = 16, edgeSize = 16,
331 | insets = { left = 3, right = 3, top = 5, bottom = 3 }
332 | }
333 |
334 | local function Constructor()
335 | local num = AceGUI:GetNextWidgetNum(Type)
336 | local frame = CreateFrame("Frame",nil,UIParent)
337 | frame:SetHeight(100)
338 | frame:SetWidth(100)
339 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
340 |
341 | local titletext = frame:CreateFontString(nil,"OVERLAY","GameFontNormal")
342 | titletext:SetPoint("TOPLEFT", 14, 0)
343 | titletext:SetPoint("TOPRIGHT", -14, 0)
344 | titletext:SetJustifyH("LEFT")
345 | titletext:SetHeight(18)
346 | titletext:SetText("")
347 |
348 | local border = CreateFrame("Frame", nil, frame)
349 | border:SetPoint("TOPLEFT", 1, -27)
350 | border:SetPoint("BOTTOMRIGHT", -1, 3)
351 | border:SetBackdrop(PaneBackdrop)
352 | border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
353 | border:SetBackdropBorderColor(0.4, 0.4, 0.4)
354 |
355 | local content = CreateFrame("Frame", nil, border)
356 | content:SetPoint("TOPLEFT", 10, -7)
357 | content:SetPoint("BOTTOMRIGHT", -10, 7)
358 |
359 | local widget = {
360 | num = num,
361 | frame = frame,
362 | localstatus = {},
363 | alignoffset = 18,
364 | titletext = titletext,
365 | border = border,
366 | borderoffset = 27,
367 | tabs = {},
368 | content = content,
369 | type = Type
370 | }
371 | for method, func in pairs(methods) do
372 | widget[method] = func
373 | end
374 |
375 | return AceGUI:RegisterAsContainer(widget)
376 | end
377 |
378 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
379 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIContainer-Window.lua:
--------------------------------------------------------------------------------
1 | local AceGUI = LibStub("AceGUI-3.0")
2 |
3 | -- Lua APIs
4 | local pairs, assert, type = pairs, assert, type
5 |
6 | -- WoW APIs
7 | local PlaySound = PlaySound
8 | local CreateFrame, UIParent = CreateFrame, UIParent
9 |
10 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
11 | -- List them here for Mikk's FindGlobals script
12 | -- GLOBALS: GameFontNormal
13 |
14 | ----------------
15 | -- Main Frame --
16 | ----------------
17 | --[[
18 | Events :
19 | OnClose
20 |
21 | ]]
22 | do
23 | local Type = "Window"
24 | local Version = 4
25 |
26 | local function frameOnClose()
27 | this.obj:Fire("OnClose")
28 | end
29 |
30 | local function closeOnClick()
31 | PlaySound("gsTitleOptionExit")
32 | this.obj:Hide()
33 | end
34 |
35 | local function frameOnMouseDown()
36 | AceGUI:ClearFocus()
37 | end
38 |
39 | local function titleOnMouseDown()
40 | this:GetParent():StartMoving()
41 | AceGUI:ClearFocus()
42 | end
43 |
44 | local function frameOnMouseUp()
45 | local frame = this:GetParent()
46 | frame:StopMovingOrSizing()
47 | local self = frame.obj
48 | local status = self.status or self.localstatus
49 | status.width = frame:GetWidth()
50 | status.height = frame:GetHeight()
51 | status.top = frame:GetTop()
52 | status.left = frame:GetLeft()
53 | end
54 |
55 | local function sizerseOnMouseDown()
56 | this:GetParent():StartSizing("BOTTOMRIGHT")
57 | AceGUI:ClearFocus()
58 | end
59 |
60 | local function sizersOnMouseDown()
61 | this:GetParent():StartSizing("BOTTOM")
62 | AceGUI:ClearFocus()
63 | end
64 |
65 | local function sizereOnMouseDown()
66 | this:GetParent():StartSizing("RIGHT")
67 | AceGUI:ClearFocus()
68 | end
69 |
70 | local function sizerOnMouseUp()
71 | this:GetParent():StopMovingOrSizing()
72 | end
73 |
74 | local function SetTitle(self,title)
75 | self.titletext:SetText(title)
76 | end
77 |
78 | local function SetStatusText(self,text)
79 | -- self.statustext:SetText(text)
80 | end
81 |
82 | local function Hide(self)
83 | self.frame:Hide()
84 | end
85 |
86 | local function Show(self)
87 | self.frame:Show()
88 | end
89 |
90 | local function OnAcquire(self)
91 | self.frame:SetParent(UIParent)
92 | self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
93 | self:ApplyStatus()
94 | self:EnableResize(true)
95 | self:Show()
96 | end
97 |
98 | local function OnRelease(self)
99 | self.status = nil
100 | for k in pairs(self.localstatus) do
101 | self.localstatus[k] = nil
102 | end
103 | end
104 |
105 | -- called to set an external table to store status in
106 | local function SetStatusTable(self, status)
107 | assert(type(status) == "table")
108 | self.status = status
109 | self:ApplyStatus()
110 | end
111 |
112 | local function ApplyStatus(self)
113 | local status = self.status or self.localstatus
114 | local frame = self.frame
115 | self:SetWidth(status.width or 700)
116 | self:SetHeight(status.height or 500)
117 | if status.top and status.left then
118 | frame:SetPoint("TOP",UIParent,"BOTTOM",0,status.top)
119 | frame:SetPoint("LEFT",UIParent,"LEFT",status.left,0)
120 | else
121 | frame:SetPoint("CENTER",UIParent,"CENTER")
122 | end
123 | end
124 |
125 | local function OnWidthSet(self, width)
126 | local content = self.content
127 | local contentwidth = width - 34
128 | if contentwidth < 0 then
129 | contentwidth = 0
130 | end
131 | content:SetWidth(contentwidth)
132 | content.width = contentwidth
133 | end
134 |
135 |
136 | local function OnHeightSet(self, height)
137 | local content = self.content
138 | local contentheight = height - 57
139 | if contentheight < 0 then
140 | contentheight = 0
141 | end
142 | content:SetHeight(contentheight)
143 | content.height = contentheight
144 | end
145 |
146 | local function EnableResize(self, state)
147 | local func = state and "Show" or "Hide"
148 | self.sizer_se[func](self.sizer_se)
149 | self.sizer_s[func](self.sizer_s)
150 | self.sizer_e[func](self.sizer_e)
151 | end
152 |
153 | local function Constructor()
154 | local frame = CreateFrame("Frame",nil,UIParent)
155 | local self = {}
156 | self.type = "Window"
157 |
158 | self.Hide = Hide
159 | self.Show = Show
160 | self.SetTitle = SetTitle
161 | self.OnRelease = OnRelease
162 | self.OnAcquire = OnAcquire
163 | self.SetStatusText = SetStatusText
164 | self.SetStatusTable = SetStatusTable
165 | self.ApplyStatus = ApplyStatus
166 | self.OnWidthSet = OnWidthSet
167 | self.OnHeightSet = OnHeightSet
168 | self.EnableResize = EnableResize
169 |
170 | self.localstatus = {}
171 |
172 | self.frame = frame
173 | frame.obj = self
174 | frame:SetWidth(700)
175 | frame:SetHeight(500)
176 | frame:SetPoint("CENTER",UIParent,"CENTER",0,0)
177 | frame:EnableMouse()
178 | frame:SetMovable(true)
179 | frame:SetResizable(true)
180 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
181 | frame:SetScript("OnMouseDown", frameOnMouseDown)
182 |
183 | frame:SetScript("OnHide",frameOnClose)
184 | frame:SetMinResize(240,240)
185 | frame:SetToplevel(true)
186 |
187 | local titlebg = frame:CreateTexture(nil, "BACKGROUND")
188 | titlebg:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Title-Background]])
189 | titlebg:SetPoint("TOPLEFT", 9, -6)
190 | titlebg:SetPoint("BOTTOMRIGHT", frame, "TOPRIGHT", -28, -24)
191 |
192 | local dialogbg = frame:CreateTexture(nil, "BACKGROUND")
193 | dialogbg:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
194 | dialogbg:SetPoint("TOPLEFT", 8, -24)
195 | dialogbg:SetPoint("BOTTOMRIGHT", -6, 8)
196 | dialogbg:SetVertexColor(0, 0, 0, .75)
197 |
198 | local topleft = frame:CreateTexture(nil, "BORDER")
199 | topleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
200 | topleft:SetWidth(64)
201 | topleft:SetHeight(64)
202 | topleft:SetPoint("TOPLEFT")
203 | topleft:SetTexCoord(0.501953125, 0.625, 0, 1)
204 |
205 | local topright = frame:CreateTexture(nil, "BORDER")
206 | topright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
207 | topright:SetWidth(64)
208 | topright:SetHeight(64)
209 | topright:SetPoint("TOPRIGHT")
210 | topright:SetTexCoord(0.625, 0.75, 0, 1)
211 |
212 | local top = frame:CreateTexture(nil, "BORDER")
213 | top:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
214 | top:SetHeight(64)
215 | top:SetPoint("TOPLEFT", topleft, "TOPRIGHT")
216 | top:SetPoint("TOPRIGHT", topright, "TOPLEFT")
217 | top:SetTexCoord(0.25, 0.369140625, 0, 1)
218 |
219 | local bottomleft = frame:CreateTexture(nil, "BORDER")
220 | bottomleft:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
221 | bottomleft:SetWidth(64)
222 | bottomleft:SetHeight(64)
223 | bottomleft:SetPoint("BOTTOMLEFT")
224 | bottomleft:SetTexCoord(0.751953125, 0.875, 0, 1)
225 |
226 | local bottomright = frame:CreateTexture(nil, "BORDER")
227 | bottomright:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
228 | bottomright:SetWidth(64)
229 | bottomright:SetHeight(64)
230 | bottomright:SetPoint("BOTTOMRIGHT")
231 | bottomright:SetTexCoord(0.875, 1, 0, 1)
232 |
233 | local bottom = frame:CreateTexture(nil, "BORDER")
234 | bottom:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
235 | bottom:SetHeight(64)
236 | bottom:SetPoint("BOTTOMLEFT", bottomleft, "BOTTOMRIGHT")
237 | bottom:SetPoint("BOTTOMRIGHT", bottomright, "BOTTOMLEFT")
238 | bottom:SetTexCoord(0.376953125, 0.498046875, 0, 1)
239 |
240 | local left = frame:CreateTexture(nil, "BORDER")
241 | left:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
242 | left:SetWidth(64)
243 | left:SetPoint("TOPLEFT", topleft, "BOTTOMLEFT")
244 | left:SetPoint("BOTTOMLEFT", bottomleft, "TOPLEFT")
245 | left:SetTexCoord(0.001953125, 0.125, 0, 1)
246 |
247 | local right = frame:CreateTexture(nil, "BORDER")
248 | right:SetTexture([[Interface\PaperDollInfoFrame\UI-GearManager-Border]])
249 | right:SetWidth(64)
250 | right:SetPoint("TOPRIGHT", topright, "BOTTOMRIGHT")
251 | right:SetPoint("BOTTOMRIGHT", bottomright, "TOPRIGHT")
252 | right:SetTexCoord(0.1171875, 0.2421875, 0, 1)
253 |
254 | local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
255 | close:SetPoint("TOPRIGHT", 2, 1)
256 | close:SetScript("OnClick", closeOnClick)
257 | self.closebutton = close
258 | close.obj = self
259 |
260 | local titletext = frame:CreateFontString(nil, "ARTWORK")
261 | titletext:SetFontObject(GameFontNormal)
262 | titletext:SetPoint("TOPLEFT", 12, -8)
263 | titletext:SetPoint("TOPRIGHT", -32, -8)
264 | self.titletext = titletext
265 |
266 | local title = CreateFrame("Button", nil, frame)
267 | title:SetPoint("TOPLEFT", titlebg)
268 | title:SetPoint("BOTTOMRIGHT", titlebg)
269 | title:EnableMouse()
270 | title:SetScript("OnMouseDown",titleOnMouseDown)
271 | title:SetScript("OnMouseUp", frameOnMouseUp)
272 | self.title = title
273 |
274 | local sizer_se = CreateFrame("Frame",nil,frame)
275 | sizer_se:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
276 | sizer_se:SetWidth(25)
277 | sizer_se:SetHeight(25)
278 | sizer_se:EnableMouse()
279 | sizer_se:SetScript("OnMouseDown",sizerseOnMouseDown)
280 | sizer_se:SetScript("OnMouseUp", sizerOnMouseUp)
281 | self.sizer_se = sizer_se
282 |
283 | local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
284 | self.line1 = line1
285 | line1:SetWidth(14)
286 | line1:SetHeight(14)
287 | line1:SetPoint("BOTTOMRIGHT", -8, 8)
288 | line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
289 | local x = 0.1 * 14/17
290 | line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
291 |
292 | local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
293 | self.line2 = line2
294 | line2:SetWidth(8)
295 | line2:SetHeight(8)
296 | line2:SetPoint("BOTTOMRIGHT", -8, 8)
297 | line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
298 | local x = 0.1 * 8/17
299 | line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
300 |
301 | local sizer_s = CreateFrame("Frame",nil,frame)
302 | sizer_s:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-25,0)
303 | sizer_s:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
304 | sizer_s:SetHeight(25)
305 | sizer_s:EnableMouse()
306 | sizer_s:SetScript("OnMouseDown",sizersOnMouseDown)
307 | sizer_s:SetScript("OnMouseUp", sizerOnMouseUp)
308 | self.sizer_s = sizer_s
309 |
310 | local sizer_e = CreateFrame("Frame",nil,frame)
311 | sizer_e:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,25)
312 | sizer_e:SetPoint("TOPRIGHT",frame,"TOPRIGHT",0,0)
313 | sizer_e:SetWidth(25)
314 | sizer_e:EnableMouse()
315 | sizer_e:SetScript("OnMouseDown",sizereOnMouseDown)
316 | sizer_e:SetScript("OnMouseUp", sizerOnMouseUp)
317 | self.sizer_e = sizer_e
318 |
319 | --Container Support
320 | local content = CreateFrame("Frame",nil,frame)
321 | self.content = content
322 | content.obj = self
323 | content:SetPoint("TOPLEFT",frame,"TOPLEFT",12,-32)
324 | content:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-12,13)
325 |
326 | AceGUI:RegisterAsContainer(self)
327 | return self
328 | end
329 |
330 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
331 | end
332 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-Button.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Button Widget
3 | Graphical Button.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "Button", 23
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | local AceCore = LibStub("AceCore-3.0")
10 |
11 | -- Lua APIs
12 | local pairs = pairs
13 |
14 | -- WoW APIs
15 | local _G = AceCore._G
16 | local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent
17 |
18 | --[[-----------------------------------------------------------------------------
19 | Scripts
20 | -------------------------------------------------------------------------------]]
21 | -- arg1 is the button for OnClick event
22 | local function Button_OnClick()
23 | AceGUI:ClearFocus()
24 | PlaySound("igMainMenuOption")
25 | this.obj:Fire("OnClick", 1, arg1)
26 | end
27 |
28 | local function Control_OnEnter()
29 | this.obj:Fire("OnEnter")
30 | end
31 |
32 | local function Control_OnLeave()
33 | this.obj:Fire("OnLeave")
34 | end
35 |
36 | --[[-----------------------------------------------------------------------------
37 | Methods
38 | -------------------------------------------------------------------------------]]
39 | local methods = {
40 | ["OnAcquire"] = function(self)
41 | -- restore default values
42 | self:SetHeight(24)
43 | self:SetWidth(200)
44 | self:SetDisabled(false)
45 | self:SetAutoWidth(false)
46 | self:SetText()
47 | end,
48 |
49 | -- ["OnRelease"] = nil,
50 |
51 | ["SetText"] = function(self, text)
52 | self.text:SetText(text)
53 | if self.autoWidth then
54 | self:SetWidth(self.text:GetStringWidth() + 30)
55 | end
56 | end,
57 |
58 | ["SetAutoWidth"] = function(self, autoWidth)
59 | self.autoWidth = autoWidth
60 | if self.autoWidth then
61 | self:SetWidth(self.text:GetStringWidth() + 30)
62 | end
63 | end,
64 |
65 | ["SetDisabled"] = function(self, disabled)
66 | self.disabled = disabled
67 | if disabled then
68 | self.frame:Disable()
69 | else
70 | self.frame:Enable()
71 | end
72 | end
73 | }
74 |
75 | --[[-----------------------------------------------------------------------------
76 | Constructor
77 | -------------------------------------------------------------------------------]]
78 | local function Constructor()
79 | local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
80 | local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate2")
81 | frame:Hide()
82 |
83 | frame:EnableMouse(true)
84 | frame:SetScript("OnClick", Button_OnClick)
85 | frame:SetScript("OnEnter", Control_OnEnter)
86 | frame:SetScript("OnLeave", Control_OnLeave)
87 |
88 | local text = frame:GetFontString()
89 | text:ClearAllPoints()
90 | text:SetPoint("TOPLEFT", 15, -1)
91 | text:SetPoint("BOTTOMRIGHT", -15, 1)
92 | text:SetJustifyV("MIDDLE")
93 |
94 | local widget = {
95 | text = text,
96 | frame = frame,
97 | type = Type
98 | }
99 | for method, func in pairs(methods) do
100 | widget[method] = func
101 | end
102 |
103 | return AceGUI:RegisterAsWidget(widget)
104 | end
105 |
106 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
107 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-CheckBox.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Checkbox Widget
3 | -------------------------------------------------------------------------------]]
4 | local Type, Version = "CheckBox", 22
5 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7 |
8 | -- Lua APIs
9 | local pairs = pairs
10 |
11 | -- WoW APIs
12 | local PlaySound = PlaySound
13 | local CreateFrame, UIParent = CreateFrame, UIParent
14 |
15 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
16 | -- List them here for Mikk's FindGlobals script
17 | -- GLOBALS: SetDesaturation, GameFontHighlight
18 |
19 | --[[-----------------------------------------------------------------------------
20 | Support functions
21 | -------------------------------------------------------------------------------]]
22 | local function AlignImage(self)
23 | local img = self.image:GetTexture()
24 | self.text:ClearAllPoints()
25 | if not img then
26 | self.text:SetPoint("LEFT", self.checkbg, "RIGHT")
27 | self.text:SetPoint("RIGHT",0,0)
28 | else
29 | self.text:SetPoint("LEFT", self.image,"RIGHT", 1, 0)
30 | self.text:SetPoint("RIGHT",0,0)
31 | end
32 | end
33 |
34 | --[[-----------------------------------------------------------------------------
35 | Scripts
36 | -------------------------------------------------------------------------------]]
37 | local function Control_OnEnter()
38 | this.obj:Fire("OnEnter")
39 | end
40 |
41 | local function Control_OnLeave()
42 | this.obj:Fire("OnLeave")
43 | end
44 |
45 | local function CheckBox_OnMouseDown()
46 | local self = this.obj
47 | if not self.disabled then
48 | if self.image:GetTexture() then
49 | self.text:SetPoint("LEFT", self.image,"RIGHT", 2, -1)
50 | else
51 | self.text:SetPoint("LEFT", self.checkbg, "RIGHT", 1, -1)
52 | end
53 | end
54 | AceGUI:ClearFocus()
55 | end
56 |
57 | local function CheckBox_OnMouseUp()
58 |
59 | local self = this.obj
60 | if not self.disabled then
61 | self:ToggleChecked()
62 |
63 | if self.checked then
64 | PlaySound("igMainMenuOptionCheckBoxOn")
65 | else -- for both nil and false (tristate)
66 | PlaySound("igMainMenuOptionCheckBoxOff")
67 | end
68 |
69 | self:Fire("OnValueChanged", 1, self.checked)
70 | AlignImage(self)
71 | end
72 | end
73 |
74 | --[[-----------------------------------------------------------------------------
75 | Methods
76 | -------------------------------------------------------------------------------]]
77 | local methods = {
78 | ["OnAcquire"] = function(self)
79 | self:SetType()
80 | self:SetValue(false)
81 | self:SetTriState(nil)
82 | -- height is calculated from the width and required space for the description
83 | self:SetWidth(200)
84 | self:SetImage()
85 | self:SetDisabled(nil)
86 | self:SetDescription(nil)
87 | end,
88 |
89 | -- ["OnRelease"] = nil,
90 |
91 | ["OnWidthSet"] = function(self, width)
92 | if self.desc then
93 | self.desc:SetWidth(width - 30)
94 | if self.desc:GetText() and self.desc:GetText() ~= "" then
95 | self:SetHeight(28 + self.desc:GetHeight())
96 | end
97 | end
98 | end,
99 |
100 | ["SetDisabled"] = function(self, disabled)
101 | self.disabled = disabled
102 | if disabled then
103 | self.frame:Disable()
104 | self.text:SetTextColor(0.5, 0.5, 0.5)
105 | SetDesaturation(self.check, true)
106 | if self.desc then
107 | self.desc:SetTextColor(0.5, 0.5, 0.5)
108 | end
109 | else
110 | self.frame:Enable()
111 | self.text:SetTextColor(1, 1, 1)
112 | if self.tristate and self.checked == nil then
113 | SetDesaturation(self.check, true)
114 | else
115 | SetDesaturation(self.check, false)
116 | end
117 | if self.desc then
118 | self.desc:SetTextColor(1, 1, 1)
119 | end
120 | end
121 | end,
122 |
123 | ["SetValue"] = function(self,value)
124 | local check = self.check
125 | self.checked = value
126 | if value then
127 | SetDesaturation(self.check, false)
128 | self.check:Show()
129 | else
130 | --Nil is the unknown tristate value
131 | if self.tristate and value == nil then
132 | SetDesaturation(self.check, true)
133 | self.check:Show()
134 | else
135 | SetDesaturation(self.check, false)
136 | self.check:Hide()
137 | end
138 | end
139 | self:SetDisabled(self.disabled)
140 | end,
141 |
142 | ["GetValue"] = function(self)
143 | return self.checked
144 | end,
145 |
146 | ["SetTriState"] = function(self, enabled)
147 | self.tristate = enabled
148 | self:SetValue(self:GetValue())
149 | end,
150 |
151 | ["SetType"] = function(self, type)
152 | local checkbg = self.checkbg
153 | local check = self.check
154 | local highlight = self.highlight
155 |
156 | local size
157 | if type == "radio" then
158 | size = 16
159 | checkbg:SetTexture("Interface\\Buttons\\UI-RadioButton")
160 | checkbg:SetTexCoord(0, 0.25, 0, 1)
161 | check:SetTexture("Interface\\Buttons\\UI-RadioButton")
162 | check:SetTexCoord(0.25, 0.5, 0, 1)
163 | check:SetBlendMode("ADD")
164 | highlight:SetTexture("Interface\\Buttons\\UI-RadioButton")
165 | highlight:SetTexCoord(0.5, 0.75, 0, 1)
166 | else
167 | size = 24
168 | checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
169 | checkbg:SetTexCoord(0, 1, 0, 1)
170 | check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
171 | check:SetTexCoord(0, 1, 0, 1)
172 | check:SetBlendMode("BLEND")
173 | highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
174 | highlight:SetTexCoord(0, 1, 0, 1)
175 | end
176 |
177 | checkbg:SetHeight(size)
178 | checkbg:SetWidth(size)
179 | end,
180 |
181 | ["ToggleChecked"] = function(self)
182 | local value = self:GetValue()
183 | if self.tristate then
184 | --cycle in true, nil, false order
185 | if value then
186 | self:SetValue(nil)
187 | elseif value == nil then
188 | self:SetValue(false)
189 | else
190 | self:SetValue(true)
191 | end
192 | else
193 | self:SetValue(not self:GetValue())
194 | end
195 | end,
196 |
197 | ["SetLabel"] = function(self, label)
198 | self.text:SetText(label)
199 | end,
200 |
201 | ["SetDescription"] = function(self, desc)
202 | if desc then
203 | if not self.desc then
204 | local desc = self.frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
205 | desc:ClearAllPoints()
206 | desc:SetPoint("TOPLEFT", self.checkbg, "TOPRIGHT", 5, -21)
207 | desc:SetWidth(self.frame.width - 30)
208 | desc:SetJustifyH("LEFT")
209 | desc:SetJustifyV("TOP")
210 | self.desc = desc
211 | end
212 | self.desc:Show()
213 | --self.text:SetFontObject(GameFontNormal)
214 | self.desc:SetText(desc)
215 | self:SetHeight(28 + self.desc:GetHeight())
216 | else
217 | if self.desc then
218 | self.desc:SetText("")
219 | self.desc:Hide()
220 | end
221 | --self.text:SetFontObject(GameFontHighlight)
222 | self:SetHeight(24)
223 | end
224 | end,
225 |
226 | ["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
227 | local image = self.image
228 | image:SetTexture(path)
229 |
230 | if image:GetTexture() then
231 | if a4 or a8 then
232 | image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
233 | else
234 | image:SetTexCoord(0, 1, 0, 1)
235 | end
236 | end
237 | AlignImage(self)
238 | end
239 | }
240 |
241 | --[[-----------------------------------------------------------------------------
242 | Constructor
243 | -------------------------------------------------------------------------------]]
244 | local function Constructor()
245 | local frame = CreateFrame("Button", nil, UIParent)
246 | frame:Hide()
247 |
248 | frame:EnableMouse(true)
249 | frame:SetScript("OnEnter", Control_OnEnter)
250 | frame:SetScript("OnLeave", Control_OnLeave)
251 | frame:SetScript("OnMouseDown", CheckBox_OnMouseDown)
252 | frame:SetScript("OnMouseUp", CheckBox_OnMouseUp)
253 |
254 | local checkbg = frame:CreateTexture(nil, "ARTWORK")
255 | checkbg:SetWidth(24)
256 | checkbg:SetHeight(24)
257 | checkbg:SetPoint("TOPLEFT",0,0)
258 | checkbg:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
259 |
260 | local check = frame:CreateTexture(nil, "OVERLAY")
261 | check:SetAllPoints(checkbg)
262 | check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
263 |
264 | local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
265 | text:SetJustifyH("LEFT")
266 | text:SetHeight(18)
267 | text:SetPoint("LEFT", checkbg, "RIGHT")
268 | text:SetPoint("RIGHT",0,0)
269 |
270 | local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
271 | highlight:SetTexture("Interface\\Buttons\\UI-CheckBox-Highlight")
272 | highlight:SetBlendMode("ADD")
273 | highlight:SetAllPoints(checkbg)
274 |
275 | local image = frame:CreateTexture(nil, "OVERLAY")
276 | image:SetHeight(16)
277 | image:SetWidth(16)
278 | image:SetPoint("LEFT", checkbg, "RIGHT", 1, 0)
279 |
280 | local widget = {
281 | checkbg = checkbg,
282 | check = check,
283 | text = text,
284 | highlight = highlight,
285 | image = image,
286 | frame = frame,
287 | type = Type
288 | }
289 | for method, func in pairs(methods) do
290 | widget[method] = func
291 | end
292 |
293 | return AceGUI:RegisterAsWidget(widget)
294 | end
295 |
296 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
297 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | ColorPicker Widget
3 | -------------------------------------------------------------------------------]]
4 | local Type, Version = "ColorPicker", 23
5 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7 |
8 | -- Lua APIs
9 | local pairs = pairs
10 |
11 | -- WoW APIs
12 | local CreateFrame, UIParent = CreateFrame, UIParent
13 |
14 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
15 | -- List them here for Mikk's FindGlobals script
16 | -- GLOBALS: ShowUIPanel, HideUIPanel, ColorPickerFrame, OpacitySliderFrame
17 |
18 | --[[-----------------------------------------------------------------------------
19 | Support functions
20 | -------------------------------------------------------------------------------]]
21 | local function ColorCallback(self, r, g, b, a, isAlpha)
22 | if not self.HasAlpha then
23 | a = 1
24 | end
25 | self:SetColor(r, g, b, a)
26 | if ColorPickerFrame:IsVisible() then
27 | --colorpicker is still open
28 | self:Fire("OnValueChanged", 4, r, g, b, a)
29 | else
30 | --colorpicker is closed, color callback is first, ignore it,
31 | --alpha callback is the final call after it closes so confirm now
32 | if isAlpha then
33 | self:Fire("OnValueConfirmed", 4, r, g, b, a)
34 | end
35 | end
36 | end
37 |
38 | --[[-----------------------------------------------------------------------------
39 | Scripts
40 | -------------------------------------------------------------------------------]]
41 | local function Control_OnEnter()
42 | this.obj:Fire("OnEnter")
43 | end
44 |
45 | local function Control_OnLeave()
46 | this.obj:Fire("OnLeave")
47 | end
48 |
49 | local function ColorSwatch_OnClick()
50 | HideUIPanel(ColorPickerFrame)
51 | local self = this.obj
52 | if not self.disabled then
53 | ColorPickerFrame:SetFrameStrata("FULLSCREEN_DIALOG")
54 | ColorPickerFrame:SetClampedToScreen(true)
55 |
56 | ColorPickerFrame.func = function()
57 | local r, g, b = ColorPickerFrame:GetColorRGB()
58 | local a = 1 - OpacitySliderFrame:GetValue()
59 | ColorCallback(self, r, g, b, a)
60 | end
61 |
62 | ColorPickerFrame.hasOpacity = self.HasAlpha
63 | ColorPickerFrame.opacityFunc = function()
64 | local r, g, b = ColorPickerFrame:GetColorRGB()
65 | local a = 1 - OpacitySliderFrame:GetValue()
66 | ColorCallback(self, r, g, b, a, true)
67 | end
68 |
69 | local r, g, b, a = self.r, self.g, self.b, self.a
70 | if self.HasAlpha then
71 | ColorPickerFrame.opacity = 1 - (a or 0)
72 | end
73 | ColorPickerFrame:SetColorRGB(r, g, b)
74 |
75 | ColorPickerFrame.cancelFunc = function()
76 | ColorCallback(self, r, g, b, a, true)
77 | end
78 |
79 | ShowUIPanel(ColorPickerFrame)
80 | end
81 | AceGUI:ClearFocus()
82 | end
83 |
84 | --[[-----------------------------------------------------------------------------
85 | Methods
86 | -------------------------------------------------------------------------------]]
87 | local methods = {
88 | ["OnAcquire"] = function(self)
89 | self:SetHeight(24)
90 | self:SetWidth(200)
91 | self:SetHasAlpha(false)
92 | self:SetColor(0, 0, 0, 1)
93 | self:SetDisabled(nil)
94 | self:SetLabel(nil)
95 | end,
96 |
97 | -- ["OnRelease"] = nil,
98 |
99 | ["SetLabel"] = function(self, text)
100 | self.text:SetText(text)
101 | end,
102 |
103 | ["SetColor"] = function(self, r, g, b, a)
104 | self.r = r
105 | self.g = g
106 | self.b = b
107 | self.a = a or 1
108 | self.colorSwatch:SetVertexColor(r, g, b, a)
109 | end,
110 |
111 | ["SetHasAlpha"] = function(self, HasAlpha)
112 | self.HasAlpha = HasAlpha
113 | end,
114 |
115 | ["SetDisabled"] = function(self, disabled)
116 | self.disabled = disabled
117 | if self.disabled then
118 | self.frame:Disable()
119 | self.text:SetTextColor(0.5, 0.5, 0.5)
120 | else
121 | self.frame:Enable()
122 | self.text:SetTextColor(1, 1, 1)
123 | end
124 | end
125 | }
126 |
127 | --[[-----------------------------------------------------------------------------
128 | Constructor
129 | -------------------------------------------------------------------------------]]
130 | local function Constructor()
131 | local frame = CreateFrame("Button", nil, UIParent)
132 | frame:Hide()
133 |
134 | frame:EnableMouse(true)
135 | frame:SetScript("OnEnter", Control_OnEnter)
136 | frame:SetScript("OnLeave", Control_OnLeave)
137 | frame:SetScript("OnClick", ColorSwatch_OnClick)
138 |
139 | local colorSwatch = frame:CreateTexture(nil, "OVERLAY")
140 | colorSwatch:SetWidth(19)
141 | colorSwatch:SetHeight(19)
142 | colorSwatch:SetTexture("Interface\\ChatFrame\\ChatFrameColorSwatch")
143 | colorSwatch:SetPoint("LEFT",0,0)
144 |
145 | local texture = frame:CreateTexture(nil, "BACKGROUND")
146 | texture:SetWidth(16)
147 | texture:SetHeight(16)
148 | texture:SetTexture(1, 1, 1)
149 | texture:SetPoint("CENTER", colorSwatch)
150 | texture:Show()
151 |
152 | local checkers = frame:CreateTexture(nil, "BACKGROUND")
153 | checkers:SetWidth(14)
154 | checkers:SetHeight(14)
155 | checkers:SetTexture("Tileset\\Generic\\Checkers")
156 | checkers:SetTexCoord(.25, 0, 0.5, .25)
157 | checkers:SetDesaturated(true)
158 | checkers:SetVertexColor(1, 1, 1, 0.75)
159 | checkers:SetPoint("CENTER", colorSwatch)
160 | checkers:Show()
161 |
162 | local text = frame:CreateFontString(nil,"OVERLAY","GameFontHighlight")
163 | text:SetHeight(24)
164 | text:SetJustifyH("LEFT")
165 | text:SetTextColor(1, 1, 1)
166 | text:SetPoint("LEFT", colorSwatch, "RIGHT", 2, 0)
167 | text:SetPoint("RIGHT",0,0)
168 |
169 | --local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
170 | --highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
171 | --highlight:SetBlendMode("ADD")
172 | --highlight:SetAllPoints(frame)
173 |
174 | local widget = {
175 | colorSwatch = colorSwatch,
176 | text = text,
177 | frame = frame,
178 | type = Type
179 | }
180 | for method, func in pairs(methods) do
181 | widget[method] = func
182 | end
183 |
184 | return AceGUI:RegisterAsWidget(widget)
185 | end
186 |
187 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
188 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-DropDown-Items.lua:
--------------------------------------------------------------------------------
1 | --[[ $Id: AceGUIWidget-DropDown-Items.lua 1137 2016-05-15 10:57:36Z nevcairiel $ ]]--
2 |
3 | local AceGUI = LibStub("AceGUI-3.0")
4 |
5 | local IsLegion = false
6 |
7 | -- Lua APIs
8 | local assert = assert
9 | local tgetn = table.getn
10 |
11 | -- WoW APIs
12 | local PlaySound = PlaySound
13 | local CreateFrame = CreateFrame
14 |
15 | local fixlevels = AceGUI.fixlevels
16 | local fixstrata = AceGUI.fixstrata
17 |
18 | -- ItemBase is the base "class" for all dropdown items.
19 | -- Each item has to use ItemBase.Create(widgetType) to
20 | -- create an initial 'self' value.
21 | -- ItemBase will add common functions and ui event handlers.
22 | -- Be sure to keep basic usage when you override functions.
23 |
24 | local ItemBase = {
25 | -- NOTE: The ItemBase version is added to each item's version number
26 | -- to ensure proper updates on ItemBase changes.
27 | -- Use at least 1000er steps.
28 | version = 1000,
29 | counter = 0,
30 | }
31 |
32 | function ItemBase.Frame_OnEnter()
33 | local self = this.obj
34 |
35 | if self.useHighlight then
36 | self.highlight:Show()
37 | end
38 | self:Fire("OnEnter")
39 |
40 | if self.specialOnEnter then
41 | self.specialOnEnter(self)
42 | end
43 | end
44 |
45 | function ItemBase.Frame_OnLeave()
46 | local self = this.obj
47 |
48 | self.highlight:Hide()
49 | self:Fire("OnLeave")
50 |
51 | if self.specialOnLeave then
52 | self.specialOnLeave(self)
53 | end
54 | end
55 |
56 | -- exported, AceGUI callback
57 | function ItemBase.OnAcquire(self)
58 | self.frame:SetToplevel(true)
59 | self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
60 | end
61 |
62 | -- exported, AceGUI callback
63 | function ItemBase.OnRelease(self)
64 | self:SetDisabled(false)
65 | self.pullout = nil
66 | self.frame:SetParent(nil)
67 | self.frame:ClearAllPoints()
68 | self.frame:Hide()
69 | end
70 |
71 | -- exported
72 | -- NOTE: this is called by a Dropdown-Pullout.
73 | -- Do not call this method directly
74 | function ItemBase.SetPullout(self, pullout)
75 | self.pullout = pullout
76 |
77 | self.frame:SetParent(nil)
78 | local itemFrame = pullout.itemFrame
79 | self.frame:SetParent(itemFrame)
80 | self.parent = itemFrame
81 | fixlevels(itemFrame)
82 | end
83 |
84 | -- exported
85 | function ItemBase.SetText(self, text)
86 | self.text:SetText(text or "")
87 | end
88 |
89 | -- exported
90 | function ItemBase.GetText(self)
91 | return self.text:GetText()
92 | end
93 |
94 | -- exported
95 | function ItemBase.SetPoint(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
96 | self.frame:SetPoint(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
97 | end
98 |
99 | -- exported
100 | function ItemBase.Show(self)
101 | self.frame:Show()
102 | end
103 |
104 | -- exported
105 | function ItemBase.Hide(self)
106 | self.frame:Hide()
107 | end
108 |
109 | -- exported
110 | function ItemBase.SetDisabled(self, disabled)
111 | self.disabled = disabled
112 | if disabled then
113 | self.useHighlight = false
114 | self.text:SetTextColor(.5, .5, .5)
115 | else
116 | self.useHighlight = true
117 | self.text:SetTextColor(1, 1, 1)
118 | end
119 | end
120 |
121 | -- exported
122 | -- NOTE: this is called by a Dropdown-Pullout.
123 | -- Do not call this method directly
124 | function ItemBase.SetOnLeave(self, func)
125 | self.specialOnLeave = func
126 | end
127 |
128 | -- exported
129 | -- NOTE: this is called by a Dropdown-Pullout.
130 | -- Do not call this method directly
131 | function ItemBase.SetOnEnter(self, func)
132 | self.specialOnEnter = func
133 | end
134 |
135 | function ItemBase.Create(type)
136 | -- NOTE: Most of the following code is copied from AceGUI-3.0/Dropdown widget
137 | local count = AceGUI:GetNextWidgetNum(type)
138 | local frame = CreateFrame("Button", "AceGUI30DropDownItem"..count)
139 | local self = {}
140 | self.frame = frame
141 | frame.obj = self
142 | self.type = type
143 |
144 | self.useHighlight = true
145 |
146 | frame:SetHeight(17)
147 | frame:SetFrameStrata("FULLSCREEN_DIALOG")
148 |
149 | local text = frame:CreateFontString(nil,"OVERLAY","GameFontNormalSmall")
150 | text:SetTextColor(1,1,1)
151 | text:SetJustifyH("LEFT")
152 | text:SetPoint("TOPLEFT",frame,"TOPLEFT",18,0)
153 | text:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",-8,0)
154 | self.text = text
155 |
156 | local highlight = frame:CreateTexture(nil, "OVERLAY")
157 | highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
158 | highlight:SetBlendMode("ADD")
159 | highlight:SetHeight(14)
160 | highlight:ClearAllPoints()
161 | highlight:SetPoint("RIGHT",frame,"RIGHT",-3,0)
162 | highlight:SetPoint("LEFT",frame,"LEFT",5,0)
163 | highlight:Hide()
164 | self.highlight = highlight
165 |
166 | local check = frame:CreateTexture("OVERLAY")
167 | check:SetWidth(16)
168 | check:SetHeight(16)
169 | check:SetPoint("LEFT",frame,"LEFT",3,-1)
170 | check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
171 | check:Hide()
172 | self.check = check
173 |
174 | local sub = frame:CreateTexture("OVERLAY")
175 | sub:SetWidth(16)
176 | sub:SetHeight(16)
177 | sub:SetPoint("RIGHT",frame,"RIGHT",-3,-1)
178 | sub:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
179 | sub:Hide()
180 | self.sub = sub
181 |
182 | frame:SetScript("OnEnter", ItemBase.Frame_OnEnter)
183 | frame:SetScript("OnLeave", ItemBase.Frame_OnLeave)
184 |
185 | self.OnAcquire = ItemBase.OnAcquire
186 | self.OnRelease = ItemBase.OnRelease
187 |
188 | self.SetPullout = ItemBase.SetPullout
189 | self.GetText = ItemBase.GetText
190 | self.SetText = ItemBase.SetText
191 | self.SetDisabled = ItemBase.SetDisabled
192 |
193 | self.SetPoint = ItemBase.SetPoint
194 | self.Show = ItemBase.Show
195 | self.Hide = ItemBase.Hide
196 |
197 | self.SetOnLeave = ItemBase.SetOnLeave
198 | self.SetOnEnter = ItemBase.SetOnEnter
199 |
200 | return self
201 | end
202 |
203 | -- Register a dummy LibStub library to retrieve the ItemBase, so other addons can use it.
204 | local IBLib = LibStub:NewLibrary("AceGUI-3.0-DropDown-ItemBase", ItemBase.version)
205 | if IBLib then
206 | IBLib.GetItemBase = function() return ItemBase end
207 | end
208 |
209 | --[[
210 | Template for items:
211 |
212 | -- Item:
213 | --
214 | do
215 | local widgetType = "Dropdown-Item-"
216 | local widgetVersion = 1
217 |
218 | local function Constructor()
219 | local self = ItemBase.Create(widgetType)
220 |
221 | AceGUI:RegisterAsWidget(self)
222 | return self
223 | end
224 |
225 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
226 | end
227 | --]]
228 |
229 | -- Item: Header
230 | -- A single text entry.
231 | -- Special: Different text color and no highlight
232 | do
233 | local widgetType = "Dropdown-Item-Header"
234 | local widgetVersion = 1
235 |
236 | local function OnEnter(this)
237 | local self = this.obj
238 | self:Fire("OnEnter")
239 |
240 | if self.specialOnEnter then
241 | self.specialOnEnter(self)
242 | end
243 | end
244 |
245 | local function OnLeave()
246 | local self = this.obj
247 | self:Fire("OnLeave")
248 |
249 | if self.specialOnLeave then
250 | self.specialOnLeave(self)
251 | end
252 | end
253 |
254 | -- exported, override
255 | local function SetDisabled(self, disabled)
256 | ItemBase.SetDisabled(self, disabled)
257 | if not disabled then
258 | self.text:SetTextColor(1, 1, 0)
259 | end
260 | end
261 |
262 | local function Constructor()
263 | local self = ItemBase.Create(widgetType)
264 |
265 | self.SetDisabled = SetDisabled
266 |
267 | self.frame:SetScript("OnEnter", OnEnter)
268 | self.frame:SetScript("OnLeave", OnLeave)
269 |
270 | self.text:SetTextColor(1, 1, 0)
271 |
272 | AceGUI:RegisterAsWidget(self)
273 | return self
274 | end
275 |
276 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
277 | end
278 |
279 | -- Item: Execute
280 | -- A simple button
281 | do
282 | local widgetType = "Dropdown-Item-Execute"
283 | local widgetVersion = 1
284 |
285 | local function Frame_OnClick(this, button)
286 | local self = this.obj
287 | if self.disabled then return end
288 | self:Fire("OnClick")
289 | if self.pullout then
290 | self.pullout:Close()
291 | end
292 | end
293 |
294 | local function Constructor()
295 | local self = ItemBase.Create(widgetType)
296 |
297 | self.frame:SetScript("OnClick", Frame_OnClick)
298 |
299 | AceGUI:RegisterAsWidget(self)
300 | return self
301 | end
302 |
303 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
304 | end
305 |
306 | -- Item: Toggle
307 | -- Some sort of checkbox for dropdown menus.
308 | -- Does not close the pullout on click.
309 | do
310 | local widgetType = "Dropdown-Item-Toggle"
311 | local widgetVersion = 3
312 |
313 | local function UpdateToggle(self)
314 | if self.value then
315 | self.check:Show()
316 | else
317 | self.check:Hide()
318 | end
319 | end
320 |
321 | local function OnRelease(self)
322 | ItemBase.OnRelease(self)
323 | self:SetValue(nil)
324 | end
325 |
326 | local function Frame_OnClick()
327 | local self = this.obj
328 | if self.disabled then return end
329 | self.value = not self.value
330 | if self.value then
331 | PlaySound("igMainMenuOptionCheckBoxOn")
332 | else
333 | PlaySound("igMainMenuOptionCheckBoxOff")
334 | end
335 | UpdateToggle(self)
336 | self:Fire("OnValueChanged", 1, self.value)
337 | end
338 |
339 | -- exported
340 | local function SetValue(self, value)
341 | self.value = value
342 | UpdateToggle(self)
343 | end
344 |
345 | -- exported
346 | local function GetValue(self)
347 | return self.value
348 | end
349 |
350 | local function Constructor()
351 | local self = ItemBase.Create(widgetType)
352 |
353 | self.frame:SetScript("OnClick", Frame_OnClick)
354 |
355 | self.SetValue = SetValue
356 | self.GetValue = GetValue
357 | self.OnRelease = OnRelease
358 |
359 | AceGUI:RegisterAsWidget(self)
360 | return self
361 | end
362 |
363 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
364 | end
365 |
366 | -- Item: Menu
367 | -- Shows a submenu on mouse over
368 | -- Does not close the pullout on click
369 | do
370 | local widgetType = "Dropdown-Item-Menu"
371 | local widgetVersion = 2
372 |
373 | local function OnEnter()
374 | local self = this.obj
375 | self:Fire("OnEnter")
376 |
377 | if self.specialOnEnter then
378 | self.specialOnEnter(self)
379 | end
380 |
381 | self.highlight:Show()
382 |
383 | if not self.disabled and self.submenu then
384 | self.submenu:Open("TOPLEFT", self.frame, "TOPRIGHT", self.pullout:GetRightBorderWidth(), 0, self.frame:GetFrameLevel() + 100)
385 | end
386 | end
387 |
388 | local function OnHide()
389 | local self = this.obj
390 | if self.submenu then
391 | self.submenu:Close()
392 | end
393 | end
394 |
395 | -- exported
396 | local function SetMenu(self, menu)
397 | assert(menu.type == "Dropdown-Pullout")
398 | self.submenu = menu
399 | end
400 |
401 | -- exported
402 | local function CloseMenu(self)
403 | self.submenu:Close()
404 | end
405 |
406 | local function Constructor()
407 | local self = ItemBase.Create(widgetType)
408 |
409 | self.sub:Show()
410 |
411 | self.frame:SetScript("OnEnter", OnEnter)
412 | self.frame:SetScript("OnHide", OnHide)
413 |
414 | self.SetMenu = SetMenu
415 | self.CloseMenu = CloseMenu
416 |
417 | AceGUI:RegisterAsWidget(self)
418 | return self
419 | end
420 |
421 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
422 | end
423 |
424 | -- Item: Separator
425 | -- A single line to separate items
426 | do
427 | local widgetType = "Dropdown-Item-Separator"
428 | local widgetVersion = 2
429 |
430 | -- exported, override
431 | local function SetDisabled(self, disabled)
432 | ItemBase.SetDisabled(self, disabled)
433 | self.useHighlight = false
434 | end
435 |
436 | local function Constructor()
437 | local self = ItemBase.Create(widgetType)
438 |
439 | self.SetDisabled = SetDisabled
440 |
441 | local line = self.frame:CreateTexture(nil, "OVERLAY")
442 | line:SetHeight(1)
443 | line:SetTexture(.5, .5, .5)
444 |
445 | line:SetPoint("LEFT", self.frame, "LEFT", 10, 0)
446 | line:SetPoint("RIGHT", self.frame, "RIGHT", -10, 0)
447 |
448 | self.text:Hide()
449 |
450 | self.useHighlight = false
451 |
452 | AceGUI:RegisterAsWidget(self)
453 | return self
454 | end
455 |
456 | AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion + ItemBase.version)
457 | end
458 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-EditBox.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | EditBox Widget
3 | -------------------------------------------------------------------------------]]
4 | local Type, Version = "EditBox", 26
5 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7 |
8 | local AceCore = LibStub("AceCore-3.0")
9 | local hooksecurefunc = AceCore.hooksecurefunc
10 | local _G = AceCore._G
11 | local GetCursorInfo = _G.GetCursorInfo
12 |
13 | -- Lua APIs
14 | local tostring, pairs = tostring, pairs
15 |
16 | -- WoW APIs
17 | local PlaySound = PlaySound
18 | local GetCursorInfo, ClearCursor, GetSpellInfo = GetCursorInfo, ClearCursor, GetSpellInfo
19 | local CreateFrame, UIParent = CreateFrame, UIParent
20 | local strlen = string.len
21 |
22 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
23 | -- List them here for Mikk's FindGlobals script
24 | -- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY
25 |
26 | --[[-----------------------------------------------------------------------------
27 | Support functions
28 | -------------------------------------------------------------------------------]]
29 | if not AceGUIEditBoxInsertLink then
30 | -- upgradeable hook
31 | hooksecurefunc("BankFrameItemButtonGeneric_OnClick",
32 | function(button)
33 | if button == "LeftButton" and IsShiftKeyDown() and not this.isBag then
34 | return _G.AceGUIEditBoxInsertLink(GetContainerItemLink(BANK_CONTAINER, this:GetID()))
35 | end
36 | end)
37 | hooksecurefunc("ContainerFrameItemButton_OnClick",
38 | function(button, ignoreModifiers)
39 | if button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
40 | return _G.AceGUIEditBoxInsertLink(GetContainerItemLink(this:GetParent():GetID(), this:GetID()))
41 | end
42 | end)
43 |
44 | hooksecurefunc("KeyRingItemButton_OnClick",
45 | function(button)
46 | if button == "LeftButton" and IsShiftKeyDown() and not this.isBag then
47 | return _G.AceGUIEditBoxInsertLink(GetContainerItemLink(KEYRING_CONTAINER, this:GetID()))
48 | end
49 | end)
50 | hooksecurefunc("LootFrameItem_OnClick",
51 | function(button)
52 | if button == "LeftButton" and IsShiftKeyDown() then
53 | return _G.AceGUIEditBoxInsertLink(GetLootSlotLink(this.slot))
54 | end
55 | end)
56 | hooksecurefunc("SetItemRef",
57 | function(link, text, button)
58 | if IsShiftKeyDown() then
59 | if strsub(link,1,6) == "player" then
60 | local name = strsub(link,8)
61 | if name and (strlen(name) > 0) then
62 | return _G.AceGUIEditBoxInsertLink(name)
63 | end
64 | else
65 | return _G.AceGUIEditBoxInsertLink(text)
66 | end
67 | end
68 | end)
69 | hooksecurefunc("MerchantItemButton_OnClick",
70 | function(button, ignoreModifiers)
71 | if MerchantFrame.selectedTab == 1 and button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
72 | return _G.AceGUIEditBoxInsertLink(GetMerchantItemLink(this:GetID()))
73 | end
74 | end)
75 | hooksecurefunc("PaperDollItemSlotButton_OnClick",
76 | function(button, ignoreModifiers)
77 | if button == "LeftButton" and IsShiftKeyDown() and not ignoreModifiers then
78 | return _G.AceGUIEditBoxInsertLink(GetInventoryItemLink("player", this:GetID()))
79 | end
80 | end)
81 | hooksecurefunc("QuestItem_OnClick",
82 | function()
83 | if IsShiftKeyDown() and this.rewardType ~= "spell" then
84 | return _G.AceGUIEditBoxInsertLink(GetQuestItemLink(this.type, this:GetID()))
85 | end
86 | end)
87 | hooksecurefunc("QuestRewardItem_OnClick",
88 | function()
89 | if IsShiftKeyDown() and this.rewardType ~= "spell" then
90 | return _G.AceGUIEditBoxInsertLink(GetQuestItemLink(this.type, this:GetID()))
91 | end
92 | end)
93 | hooksecurefunc("QuestLogTitleButton_OnClick",
94 | function(button)
95 | if IsShiftKeyDown() and (not this.isHeader) then
96 | return _G.AceGUIEditBoxInsertLink(gsub(this:GetText(), " *(.*)", "%1"))
97 | end
98 | end)
99 | hooksecurefunc("QuestLogRewardItem_OnClick",
100 | function()
101 | if IsShiftKeyDown() and this.rewardType ~= "spell" then
102 | return _G.AceGUIEditBoxInsertLink(GetQuestLogItemLink(this.type, this:GetID()))
103 | end
104 | end)
105 | hooksecurefunc("SpellButton_OnClick",
106 | function(drag)
107 | local id = SpellBook_GetSpellID(this:GetID())
108 | if id <= MAX_SPELLS and (not drag) and IsShiftKeyDown() then
109 | local spellName, subSpellName = GetSpellName(id, SpellBookFrame.bookType)
110 | if spellName and not IsSpellPassive(id, SpellBookFrame.bookType) then
111 | if subSpellName and (strlen(subSpellName) > 0) then
112 | _G.AceGUIEditBoxInsertLink(spellName.."("..subSpellName..")");
113 | else
114 | _G.AceGUIEditBoxInsertLink(spellName);
115 | end
116 | end
117 | end
118 | end)
119 | end
120 |
121 | function _G.AceGUIEditBoxInsertLink(text)
122 | for i = 1, AceGUI:GetWidgetCount(Type) do
123 | local editbox = _G["AceGUI-3.0EditBox"..i]
124 | if editbox and editbox:IsVisible() and editbox.hasfocus then
125 | editbox:Insert(text)
126 | return true
127 | end
128 | end
129 | end
130 |
131 | local function ShowButton(self)
132 | if not self.disablebutton then
133 | self.button:Show()
134 | self.editbox:SetTextInsets(0, 20, 3, 3)
135 | end
136 | end
137 |
138 | local function HideButton(self)
139 | self.button:Hide()
140 | self.editbox:SetTextInsets(0, 0, 3, 3)
141 | end
142 |
143 | --[[-----------------------------------------------------------------------------
144 | Scripts
145 | -------------------------------------------------------------------------------]]
146 | local function Control_OnEnter()
147 | this.obj:Fire("OnEnter")
148 | end
149 |
150 | local function Control_OnLeave()
151 | this.obj:Fire("OnLeave")
152 | end
153 |
154 | local function Frame_OnShowFocus()
155 | this.obj.editbox:SetFocus()
156 | this:SetScript("OnShow", nil)
157 | end
158 |
159 | local function EditBox_OnEscapePressed()
160 | AceGUI:ClearFocus()
161 | end
162 |
163 | local function EditBox_OnEnterPressed()
164 | local self = this.obj
165 | local value = this:GetText()
166 | local cancel = self:Fire("OnEnterPressed", 1, value)
167 | if not cancel then
168 | PlaySound("igMainMenuOptionCheckBoxOn")
169 | HideButton(self)
170 | end
171 | end
172 |
173 | local function EditBox_OnReceiveDrag()
174 | if not GetCursorInfo then return end
175 | local self = this.obj
176 | local type, id, info = GetCursorInfo()
177 | if type == "item" then
178 | self:SetText(info)
179 | self:Fire("OnEnterPressed", 1, info)
180 | ClearCursor()
181 | elseif type == "spell" then
182 | local spell, rank = GetSpellName(id, info)
183 | if rank ~= "" then spell = spell.."("..rank..")" end
184 | self:SetText(spell)
185 | self:Fire("OnEnterPressed", 1, spell)
186 | ClearCursor()
187 | elseif type == "macro" then
188 | local name = GetMacroInfo(id)
189 | self:SetText(name)
190 | self:Fire("OnEnterPressed", 1, name)
191 | ClearCursor()
192 | end
193 | HideButton(self)
194 | AceGUI:ClearFocus()
195 | end
196 |
197 |
198 | local function EditBox_OnTextChanged()
199 | local self = this.obj
200 | local value = this:GetText()
201 | if tostring(value) ~= tostring(self.lasttext) then
202 | self:Fire("OnTextChanged", 1, value)
203 | self.lasttext = value
204 | ShowButton(self)
205 | end
206 | end
207 |
208 | local function EditBox_OnFocusGained()
209 | this.hasfocus = true
210 | AceGUI:SetFocus(this.obj)
211 | end
212 |
213 | local function EditBox_OnFocusLost()
214 | this.hasfocus = nil
215 | end
216 |
217 | local function Button_OnClick()
218 | local editbox = this.obj.editbox
219 | editbox:ClearFocus()
220 | this = editbox -- Ace3v: this is kinda hack here
221 | EditBox_OnEnterPressed()
222 | end
223 |
224 | --[[-----------------------------------------------------------------------------
225 | Methods
226 | -------------------------------------------------------------------------------]]
227 | local methods = {
228 | ["OnAcquire"] = function(self)
229 | -- height is controlled by SetLabel
230 | self:SetWidth(200)
231 | self:SetDisabled(false)
232 | self:SetLabel()
233 | self:SetText()
234 | self:DisableButton(false)
235 | self:SetMaxLetters(0)
236 | end,
237 |
238 | ["OnRelease"] = function(self)
239 | self:ClearFocus()
240 | end,
241 |
242 | ["SetDisabled"] = function(self, disabled)
243 | self.disabled = disabled
244 | if disabled then
245 | self.editbox:EnableMouse(false)
246 | self.editbox:ClearFocus()
247 | self.editbox:SetTextColor(0.5,0.5,0.5)
248 | self.label:SetTextColor(0.5,0.5,0.5)
249 | else
250 | self.editbox:EnableMouse(true)
251 | self.editbox:SetTextColor(1,1,1)
252 | self.label:SetTextColor(1,.82,0)
253 | end
254 | end,
255 |
256 | ["SetText"] = function(self, text)
257 | self.lasttext = text or ""
258 | self.editbox:SetText(text or "")
259 | self.editbox:HighlightText(0)
260 | HideButton(self)
261 | end,
262 |
263 | ["GetText"] = function(self, text)
264 | return self.editbox:GetText()
265 | end,
266 |
267 | ["SetLabel"] = function(self, text)
268 | if text and text ~= "" then
269 | self.label:SetText(text)
270 | self.label:Show()
271 | self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
272 | self:SetHeight(44)
273 | self.alignoffset = 30
274 | else
275 | self.label:SetText("")
276 | self.label:Hide()
277 | self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
278 | self:SetHeight(26)
279 | self.alignoffset = 12
280 | end
281 | end,
282 |
283 | ["DisableButton"] = function(self, disabled)
284 | self.disablebutton = disabled
285 | if disabled then
286 | HideButton(self)
287 | end
288 | end,
289 |
290 | ["SetMaxLetters"] = function (self, num)
291 | self.editbox:SetMaxLetters(num or 0)
292 | end,
293 |
294 | ["ClearFocus"] = function(self)
295 | self.editbox:ClearFocus()
296 | self.frame:SetScript("OnShow", nil)
297 | end,
298 |
299 | ["SetFocus"] = function(self)
300 | self.editbox:SetFocus()
301 | if not self.frame:IsShown() then
302 | self.frame:SetScript("OnShow", Frame_OnShowFocus)
303 | end
304 | end,
305 |
306 | ["HighlightText"] = function(self, from, to)
307 | self.editbox:HighlightText(from, to)
308 | end
309 | }
310 |
311 | --[[-----------------------------------------------------------------------------
312 | Constructor
313 | -------------------------------------------------------------------------------]]
314 | local function Constructor()
315 | local num = AceGUI:GetNextWidgetNum(Type)
316 | local frame = CreateFrame("Frame", nil, UIParent)
317 | frame:Hide()
318 |
319 | local editbox = CreateFrame("EditBox", "AceGUI-3.0EditBox"..num, frame, "InputBoxTemplate")
320 | editbox:SetAutoFocus(false)
321 | editbox:SetFontObject(ChatFontNormal)
322 | editbox:SetScript("OnEnter", Control_OnEnter)
323 | editbox:SetScript("OnLeave", Control_OnLeave)
324 | editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
325 | editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
326 | editbox:SetScript("OnTextChanged", EditBox_OnTextChanged)
327 | editbox:SetScript("OnReceiveDrag", EditBox_OnReceiveDrag)
328 | editbox:SetScript("OnMouseDown", EditBox_OnReceiveDrag)
329 | editbox:SetScript("OnEditFocusGained", EditBox_OnFocusGained)
330 | editbox:SetScript("OnEditFocusLost", EditBox_OnFocusLost)
331 | editbox:SetTextInsets(0, 0, 3, 3)
332 | editbox:SetMaxLetters(256)
333 | editbox:SetPoint("BOTTOMLEFT", 6, 0)
334 | editbox:SetPoint("BOTTOMRIGHT", 0, 0)
335 | editbox:SetHeight(19)
336 |
337 | local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
338 | label:SetPoint("TOPLEFT", 0, -2)
339 | label:SetPoint("TOPRIGHT", 0, -2)
340 | label:SetJustifyH("LEFT")
341 | label:SetHeight(18)
342 |
343 | local button = CreateFrame("Button", nil, editbox, "UIPanelButtonTemplate")
344 | button:SetWidth(40)
345 | button:SetHeight(20)
346 | button:SetPoint("RIGHT", -2, 0)
347 | button:SetText(OKAY)
348 | button:SetScript("OnClick", Button_OnClick)
349 | button:Hide()
350 |
351 | local widget = {
352 | alignoffset = 30,
353 | editbox = editbox,
354 | label = label,
355 | button = button,
356 | frame = frame,
357 | type = Type
358 | }
359 | for method, func in pairs(methods) do
360 | widget[method] = func
361 | end
362 | editbox.obj, button.obj = widget, widget
363 |
364 | return AceGUI:RegisterAsWidget(widget)
365 | end
366 |
367 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
368 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Heading Widget
3 | -------------------------------------------------------------------------------]]
4 | local Type, Version = "Heading", 20
5 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7 |
8 | -- Lua APIs
9 | local pairs = pairs
10 |
11 | -- WoW APIs
12 | local CreateFrame, UIParent = CreateFrame, UIParent
13 |
14 | --[[-----------------------------------------------------------------------------
15 | Methods
16 | -------------------------------------------------------------------------------]]
17 | local methods = {
18 | ["OnAcquire"] = function(self)
19 | self:SetText()
20 | self:SetFullWidth()
21 | self:SetHeight(18)
22 | end,
23 |
24 | -- ["OnRelease"] = nil,
25 |
26 | ["SetText"] = function(self, text)
27 | self.label:SetText(text or "")
28 | if text and text ~= "" then
29 | self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0)
30 | self.right:Show()
31 | else
32 | self.left:SetPoint("RIGHT", -3, 0)
33 | self.right:Hide()
34 | end
35 | end
36 | }
37 |
38 | --[[-----------------------------------------------------------------------------
39 | Constructor
40 | -------------------------------------------------------------------------------]]
41 | local function Constructor()
42 | local frame = CreateFrame("Frame", nil, UIParent)
43 | frame:Hide()
44 |
45 | local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
46 | label:SetPoint("TOP",0,0)
47 | label:SetPoint("BOTTOM",0,0)
48 | label:SetJustifyH("CENTER")
49 |
50 | local left = frame:CreateTexture(nil, "BACKGROUND")
51 | left:SetHeight(8)
52 | left:SetPoint("LEFT", 3, 0)
53 | left:SetPoint("RIGHT", label, "LEFT", -5, 0)
54 | left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
55 | left:SetTexCoord(0.81, 0.94, 0.5, 1)
56 |
57 | local right = frame:CreateTexture(nil, "BACKGROUND")
58 | right:SetHeight(8)
59 | right:SetPoint("RIGHT", -3, 0)
60 | right:SetPoint("LEFT", label, "RIGHT", 5, 0)
61 | right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
62 | right:SetTexCoord(0.81, 0.94, 0.5, 1)
63 |
64 | local widget = {
65 | label = label,
66 | left = left,
67 | right = right,
68 | frame = frame,
69 | type = Type
70 | }
71 | for method, func in pairs(methods) do
72 | widget[method] = func
73 | end
74 |
75 | return AceGUI:RegisterAsWidget(widget)
76 | end
77 |
78 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
79 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Icon Widget
3 | -------------------------------------------------------------------------------]]
4 | local Type, Version = "Icon", 21
5 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7 |
8 | -- Lua APIs
9 | local pairs, print = pairs, print
10 |
11 | -- WoW APIs
12 | local CreateFrame, UIParent = CreateFrame, UIParent
13 |
14 | --[[-----------------------------------------------------------------------------
15 | Scripts
16 | -------------------------------------------------------------------------------]]
17 | local function Control_OnEnter()
18 | this.obj:Fire("OnEnter")
19 | end
20 |
21 | local function Control_OnLeave()
22 | this.obj:Fire("OnLeave")
23 | end
24 |
25 | local function Button_OnClick()
26 | this.obj:Fire("OnClick", 1, arg1)
27 | AceGUI:ClearFocus()
28 | end
29 |
30 | --[[-----------------------------------------------------------------------------
31 | Methods
32 | -------------------------------------------------------------------------------]]
33 | local methods = {
34 | ["OnAcquire"] = function(self)
35 | self:SetHeight(110)
36 | self:SetWidth(110)
37 | self:SetLabel()
38 | self:SetImage(nil)
39 | self:SetImageSize(64, 64)
40 | self:SetDisabled(false)
41 | end,
42 |
43 | -- ["OnRelease"] = nil,
44 |
45 | ["SetLabel"] = function(self, text)
46 | if text and text ~= "" then
47 | self.label:Show()
48 | self.label:SetText(text)
49 | self:SetHeight(self.image:GetHeight() + 25)
50 | else
51 | self.label:Hide()
52 | self:SetHeight(self.image:GetHeight() + 10)
53 | end
54 | end,
55 |
56 | ["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
57 | local image = self.image
58 | image:SetTexture(path)
59 |
60 | if image:GetTexture() then
61 | if a4 or a8 then
62 | image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
63 | else
64 | image:SetTexCoord(0, 1, 0, 1)
65 | end
66 | end
67 | end,
68 |
69 | ["SetImageSize"] = function(self, width, height)
70 | self.image:SetWidth(width)
71 | self.image:SetHeight(height)
72 | --self.frame:SetWidth(width + 30)
73 | if self.label:IsShown() then
74 | self:SetHeight(height + 25)
75 | else
76 | self:SetHeight(height + 10)
77 | end
78 | end,
79 |
80 | ["SetDisabled"] = function(self, disabled)
81 | self.disabled = disabled
82 | if disabled then
83 | self.frame:Disable()
84 | self.label:SetTextColor(0.5, 0.5, 0.5)
85 | self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
86 | else
87 | self.frame:Enable()
88 | self.label:SetTextColor(1, 1, 1)
89 | self.image:SetVertexColor(1, 1, 1, 1)
90 | end
91 | end
92 | }
93 |
94 | --[[-----------------------------------------------------------------------------
95 | Constructor
96 | -------------------------------------------------------------------------------]]
97 | local function Constructor()
98 | local frame = CreateFrame("Button", nil, UIParent)
99 | frame:Hide()
100 |
101 | frame:EnableMouse(true)
102 | frame:SetScript("OnEnter", Control_OnEnter)
103 | frame:SetScript("OnLeave", Control_OnLeave)
104 | frame:SetScript("OnClick", Button_OnClick)
105 |
106 | local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlight")
107 | label:SetPoint("BOTTOMLEFT")
108 | label:SetPoint("BOTTOMRIGHT")
109 | label:SetJustifyH("CENTER")
110 | label:SetJustifyV("TOP")
111 | label:SetHeight(18)
112 |
113 | local image = frame:CreateTexture(nil, "BACKGROUND")
114 | image:SetWidth(64)
115 | image:SetHeight(64)
116 | image:SetPoint("TOP", 0, -5)
117 |
118 | local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
119 | highlight:SetAllPoints(image)
120 | highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
121 | highlight:SetTexCoord(0, 1, 0.23, 0.77)
122 | highlight:SetBlendMode("ADD")
123 |
124 | local widget = {
125 | label = label,
126 | image = image,
127 | frame = frame,
128 | type = Type
129 | }
130 | for method, func in pairs(methods) do
131 | widget[method] = func
132 | end
133 |
134 | widget.SetText = function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) print("AceGUI-3.0-Icon: SetText is deprecated! Use SetLabel instead!"); self:SetLabel(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) end
135 |
136 | return AceGUI:RegisterAsWidget(widget)
137 | end
138 |
139 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
140 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-InteractiveLabel.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | InteractiveLabel Widget
3 | -------------------------------------------------------------------------------]]
4 | local Type, Version = "InteractiveLabel", 20
5 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7 |
8 | -- Lua APIs
9 | local pairs = pairs
10 |
11 | -- WoW APIs
12 | local CreateFrame, UIParent = CreateFrame, UIParent
13 |
14 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
15 | -- List them here for Mikk's FindGlobals script
16 | -- GLOBALS: GameFontHighlightSmall
17 |
18 | --[[-----------------------------------------------------------------------------
19 | Scripts
20 | -------------------------------------------------------------------------------]]
21 | local function Control_OnEnter()
22 | this.obj:Fire("OnEnter")
23 | end
24 |
25 | local function Control_OnLeave()
26 | this.obj:Fire("OnLeave")
27 | end
28 |
29 | local function Label_OnClick()
30 | this.obj:Fire("OnClick", 1, arg1)
31 | AceGUI:ClearFocus()
32 | end
33 |
34 | --[[-----------------------------------------------------------------------------
35 | Methods
36 | -------------------------------------------------------------------------------]]
37 | local methods = {
38 | ["OnAcquire"] = function(self)
39 | self:LabelOnAcquire()
40 | self:SetHighlight()
41 | self:SetHighlightTexCoord()
42 | self:SetDisabled(false)
43 | end,
44 |
45 | -- ["OnRelease"] = nil,
46 |
47 | ["SetHighlight"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
48 | self.highlight:SetTexture(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
49 | end,
50 |
51 | ["SetHighlightTexCoord"] = function(self, a1,a2,a3,a4,a5,a6,a7,a8)
52 | if a4 or a8 then
53 | self.highlight:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
54 | else
55 | self.highlight:SetTexCoord(0, 1, 0, 1)
56 | end
57 | end,
58 |
59 | ["SetDisabled"] = function(self,disabled)
60 | self.disabled = disabled
61 | if disabled then
62 | self.frame:EnableMouse(false)
63 | self.label:SetTextColor(0.5, 0.5, 0.5)
64 | else
65 | self.frame:EnableMouse(true)
66 | self.label:SetTextColor(1, 1, 1)
67 | end
68 | end
69 | }
70 |
71 | --[[-----------------------------------------------------------------------------
72 | Constructor
73 | -------------------------------------------------------------------------------]]
74 | local function Constructor()
75 | -- create a Label type that we will hijack
76 | local label = AceGUI:Create("Label")
77 |
78 | local frame = label.frame
79 | frame:EnableMouse(true)
80 | frame:SetScript("OnEnter", Control_OnEnter)
81 | frame:SetScript("OnLeave", Control_OnLeave)
82 | frame:SetScript("OnMouseDown", Label_OnClick)
83 |
84 | local highlight = frame:CreateTexture(nil, "HIGHLIGHT")
85 | highlight:SetTexture(nil)
86 | highlight:SetAllPoints()
87 | highlight:SetBlendMode("ADD")
88 |
89 | label.highlight = highlight
90 | label.type = Type
91 | label.LabelOnAcquire = label.OnAcquire
92 | for method, func in pairs(methods) do
93 | label[method] = func
94 | end
95 |
96 | return label
97 | end
98 |
99 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
100 |
101 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-Keybinding.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Keybinding Widget
3 | Set Keybindings in the Config UI.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "Keybinding", 25
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | -- Lua APIs
10 | local pairs = pairs
11 |
12 | -- WoW APIs
13 | local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown
14 | local CreateFrame, UIParent = CreateFrame, UIParent
15 |
16 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
17 | -- List them here for Mikk's FindGlobals script
18 | -- GLOBALS: NOT_BOUND
19 |
20 | --[[-----------------------------------------------------------------------------
21 | Scripts
22 | -------------------------------------------------------------------------------]]
23 |
24 | local function Control_OnEnter()
25 | this.obj:Fire("OnEnter")
26 | end
27 |
28 | local function Control_OnLeave()
29 | this.obj:Fire("OnLeave")
30 | end
31 |
32 | local function Keybinding_OnHide()
33 | local self = this.obj
34 | this:EnableKeyboard(false)
35 | this:EnableMouseWheel(false)
36 | self.msgframe:Hide()
37 | this:UnlockHighlight()
38 | self.waitingForKey = nil
39 | end
40 |
41 | local ignoreKeys = {
42 | ["BUTTON1"] = true, ["BUTTON2"] = true,
43 | ["UNKNOWN"] = true,
44 | ["SHIFT"] = true, ["CTRL"] = true, ["ALT"] = true,
45 | }
46 | local function Keybinding_OnKeyDown()
47 | local self = this.obj
48 | if self.waitingForKey then
49 | local keyPressed = arg1
50 | if keyPressed == "ESCAPE" then
51 | keyPressed = ""
52 | else
53 | if ignoreKeys[keyPressed] then return end
54 | if IsShiftKeyDown() then
55 | keyPressed = "SHIFT-"..keyPressed
56 | end
57 | if IsControlKeyDown() then
58 | keyPressed = "CTRL-"..keyPressed
59 | end
60 | if IsAltKeyDown() then
61 | keyPressed = "ALT-"..keyPressed
62 | end
63 | end
64 |
65 | this:EnableKeyboard(false)
66 | this:EnableMouseWheel(false)
67 | self.msgframe:Hide()
68 | this:UnlockHighlight()
69 | self.waitingForKey = nil
70 |
71 | if not self.disabled then
72 | self:SetKey(keyPressed)
73 | self:Fire("OnKeyChanged", 1, keyPressed)
74 | end
75 | end
76 | end
77 |
78 | local function Keybinding_OnMouseDown()
79 | getglobal(this:GetName().."Left"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
80 | getglobal(this:GetName().."Middle"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
81 | getglobal(this:GetName().."Right"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Down");
82 | end
83 |
84 | local function Keybinding_OnMouseUp()
85 | getglobal(this:GetName().."Left"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
86 | getglobal(this:GetName().."Middle"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
87 | getglobal(this:GetName().."Right"):SetTexture("Interface\\Buttons\\UI-Panel-Button-Up");
88 | local self = this.obj
89 | if MouseIsOver(this) and not self.disabled then
90 | if self.waitingForKey then
91 | if arg1 ~= "LeftButton" and arg1 ~= "RightButton" then
92 | Keybinding_OnKeyDown()
93 | end
94 | this:EnableKeyboard(false)
95 | this:EnableMouseWheel(false)
96 | self.msgframe:Hide()
97 | this:UnlockHighlight()
98 | self.waitingForKey = nil
99 | else
100 | this:EnableKeyboard(true)
101 | this:EnableMouseWheel(true)
102 | self.msgframe:Show()
103 | this:LockHighlight()
104 | self.waitingForKey = true
105 | end
106 | end
107 | AceGUI:ClearFocus()
108 | end
109 |
110 | local function Keybinding_OnMouseWheel()
111 | if arg1 >= 0 then
112 | arg1 = "MOUSEWHEELUP"
113 | else
114 | arg1 = "MOUSEWHEELDOWN"
115 | end
116 | Keybinding_OnKeyDown()
117 | end
118 |
119 | --[[-----------------------------------------------------------------------------
120 | Methods
121 | -------------------------------------------------------------------------------]]
122 | local methods = {
123 | ["OnAcquire"] = function(self)
124 | self:SetWidth(200)
125 | self:SetLabel("")
126 | self:SetKey("")
127 | self.waitingForKey = nil
128 | self.msgframe:Hide()
129 | self:SetDisabled(false)
130 | self.button:EnableKeyboard(false)
131 | self.button:EnableMouseWheel(false)
132 | end,
133 |
134 | -- ["OnRelease"] = nil,
135 |
136 | ["SetDisabled"] = function(self, disabled)
137 | self.disabled = disabled
138 | if disabled then
139 | self.button:Disable()
140 | self.label:SetTextColor(0.5,0.5,0.5)
141 | else
142 | self.button:Enable()
143 | self.label:SetTextColor(1,1,1)
144 | end
145 | end,
146 |
147 | ["SetKey"] = function(self, key)
148 | if (key or "") == "" then
149 | self.button:SetText(NOT_BOUND)
150 | self.text:SetFontObject("GameFontNormal")
151 | else
152 | self.button:SetText(key)
153 | self.text:SetFontObject("GameFontHighlight")
154 | end
155 | end,
156 |
157 | ["GetKey"] = function(self)
158 | local key = self.button:GetText()
159 | if key == NOT_BOUND then
160 | key = nil
161 | end
162 | return key
163 | end,
164 |
165 | ["SetLabel"] = function(self, label)
166 | self.label:SetText(label or "")
167 | if (label or "") == "" then
168 | self.alignoffset = nil
169 | self:SetHeight(24)
170 | else
171 | self.alignoffset = 30
172 | self:SetHeight(44)
173 | end
174 | end,
175 | }
176 |
177 | --[[-----------------------------------------------------------------------------
178 | Constructor
179 | -------------------------------------------------------------------------------]]
180 |
181 | local ControlBackdrop = {
182 | bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
183 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
184 | tile = true, tileSize = 16, edgeSize = 16,
185 | insets = { left = 3, right = 3, top = 3, bottom = 3 }
186 | }
187 |
188 | local function keybindingMsgFixWidth()
189 | this:SetWidth(this.msg:GetWidth() + 10)
190 | this:SetScript("OnUpdate", nil)
191 | end
192 |
193 | local function Constructor()
194 | local name = "AceGUI30KeybindingButton" .. AceGUI:GetNextWidgetNum(Type)
195 |
196 | local frame = CreateFrame("Frame", nil, UIParent)
197 | local button = CreateFrame("Button", name, frame, "UIPanelButtonTemplate2")
198 |
199 | button:EnableMouse(true)
200 | button:EnableMouseWheel(false)
201 | button:SetScript("OnEnter", Control_OnEnter)
202 | button:SetScript("OnLeave", Control_OnLeave)
203 |
204 | button:SetScript("OnKeyDown", Keybinding_OnKeyDown)
205 | button:RegisterForClicks("AnyDown","AnyUp")
206 | -- Ace3v: RegisterForClicks means OnClick will not be triggered, so use OnKeyDown and OnKeyUp
207 | button:SetScript("OnMouseDown", Keybinding_OnMouseDown)
208 | button:SetScript("OnMouseUp", Keybinding_OnMouseUp)
209 | button:SetScript("OnMouseWheel", Keybinding_OnMouseWheel)
210 | button:SetScript("OnHide", Keybinding_OnHide)
211 | button:SetPoint("BOTTOMLEFT",0,0)
212 | button:SetPoint("BOTTOMRIGHT",0,0)
213 | button:SetHeight(24)
214 | button:EnableKeyboard(false)
215 |
216 | local text = button:GetFontString()
217 | text:SetPoint("LEFT", 7, 0)
218 | text:SetPoint("RIGHT", -7, 0)
219 |
220 | local label = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
221 | label:SetPoint("TOPLEFT",0,0)
222 | label:SetPoint("TOPRIGHT",0,0)
223 | label:SetJustifyH("CENTER")
224 | label:SetHeight(18)
225 |
226 | local msgframe = CreateFrame("Frame", nil, UIParent)
227 | msgframe:SetHeight(30)
228 | msgframe:SetBackdrop(ControlBackdrop)
229 | msgframe:SetBackdropColor(0,0,0)
230 | msgframe:SetFrameStrata("FULLSCREEN_DIALOG")
231 | msgframe:SetFrameLevel(1000)
232 | msgframe:SetToplevel(true)
233 |
234 | local msg = msgframe:CreateFontString(nil, "OVERLAY", "GameFontNormal")
235 | msg:SetText("Press a key to bind, ESC to clear the binding or click the button again to cancel.")
236 | msgframe.msg = msg
237 | msg:SetPoint("TOPLEFT", 5, -5)
238 | msgframe:SetScript("OnUpdate", keybindingMsgFixWidth)
239 | msgframe:SetPoint("BOTTOM", button, "TOP")
240 | msgframe:Hide()
241 |
242 | local widget = {
243 | button = button,
244 | label = label,
245 | msgframe = msgframe,
246 | frame = frame,
247 | alignoffset = 30,
248 | type = Type,
249 | text = text
250 | }
251 | for method, func in pairs(methods) do
252 | widget[method] = func
253 | end
254 | button.obj = widget
255 |
256 | return AceGUI:RegisterAsWidget(widget)
257 | end
258 |
259 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
260 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-Label.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Label Widget
3 | Displays text and optionally an icon.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "Label", 23
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | -- Lua APIs
10 | local max, pairs = math.max, pairs
11 |
12 | -- WoW APIs
13 | local CreateFrame, UIParent = CreateFrame, UIParent
14 |
15 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
16 | -- List them here for Mikk's FindGlobals script
17 | -- GLOBALS: GameFontHighlightSmall
18 |
19 | --[[-----------------------------------------------------------------------------
20 | Support functions
21 | -------------------------------------------------------------------------------]]
22 |
23 | local function UpdateImageAnchor(self)
24 | if self.resizing then return end
25 | local frame = self.frame
26 | local width = frame.width or frame:GetWidth() or 0
27 | local image = self.image
28 | local label = self.label
29 | local height
30 |
31 | label:ClearAllPoints()
32 | image:ClearAllPoints()
33 |
34 | if self.imageshown then
35 | local imagewidth = image:GetWidth()
36 | if (width - imagewidth) < 200 or (label:GetText() or "") == "" then
37 | -- image goes on top centered when less than 200 width for the text, or if there is no text
38 | image:SetPoint("TOP",0,0)
39 | label:SetPoint("TOP", image, "BOTTOM")
40 | label:SetPoint("LEFT",0,0)
41 | label:SetWidth(width)
42 | height = image:GetHeight() + label:GetHeight()
43 | else
44 | -- image on the left
45 | image:SetPoint("TOPLEFT",0,0)
46 | if image:GetHeight() > label:GetHeight() then
47 | label:SetPoint("LEFT", image, "RIGHT", 4, 0)
48 | else
49 | label:SetPoint("TOPLEFT", image, "TOPRIGHT", 4, 0)
50 | end
51 | label:SetWidth(width - imagewidth - 4)
52 | height = max(image:GetHeight(), label:GetHeight())
53 | end
54 | else
55 | -- no image shown
56 | label:SetPoint("TOPLEFT",0,0)
57 | label:SetWidth(width)
58 | height = label:GetHeight()
59 | end
60 |
61 | self.resizing = true
62 | frame:SetHeight(height)
63 | frame.height = height
64 | self.resizing = nil
65 | end
66 |
67 | --[[-----------------------------------------------------------------------------
68 | Methods
69 | -------------------------------------------------------------------------------]]
70 | local methods = {
71 | ["OnAcquire"] = function(self)
72 | -- set the flag to stop constant size updates
73 | self.resizing = true
74 | -- height is set dynamically by the text and image size
75 | self:SetWidth(200)
76 | self:SetText()
77 | self:SetImage(nil)
78 | self:SetImageSize(16, 16)
79 | self:SetColor()
80 | self:SetFontObject()
81 |
82 | -- reset the flag
83 | self.resizing = nil
84 | -- run the update explicitly
85 | UpdateImageAnchor(self)
86 | end,
87 |
88 | -- ["OnRelease"] = nil,
89 |
90 | ["OnWidthSet"] = function(self, width)
91 | UpdateImageAnchor(self)
92 | end,
93 |
94 | ["SetText"] = function(self, text)
95 | self.label:SetText(text)
96 | UpdateImageAnchor(self)
97 | end,
98 |
99 | ["SetColor"] = function(self, r, g, b)
100 | if not (r and g and b) then
101 | r, g, b = 1, 1, 1
102 | end
103 | self.label:SetVertexColor(r, g, b)
104 | end,
105 |
106 | ["SetImage"] = function(self, path, a1,a2,a3,a4,a5,a6,a7,a8)
107 | local image = self.image
108 | image:SetTexture(path)
109 |
110 | if image:GetTexture() then
111 | self.imageshown = true
112 | if a4 or a8 then
113 | image:SetTexCoord(a1,a2,a3,a4,a5,a6,a7,a8)
114 | else
115 | image:SetTexCoord(0, 1, 0, 1)
116 | end
117 | else
118 | self.imageshown = nil
119 | end
120 | UpdateImageAnchor(self)
121 | end,
122 |
123 | ["SetFont"] = function(self, font, height, flags)
124 | self.label:SetFont(font, height, flags)
125 | end,
126 |
127 | ["SetFontObject"] = function(self, font)
128 | self:SetFont((font or GameFontHighlightSmall):GetFont())
129 | end,
130 |
131 | ["SetImageSize"] = function(self, width, height)
132 | self.image:SetWidth(width)
133 | self.image:SetHeight(height)
134 | UpdateImageAnchor(self)
135 | end,
136 | }
137 |
138 | --[[-----------------------------------------------------------------------------
139 | Constructor
140 | -------------------------------------------------------------------------------]]
141 | local function Constructor()
142 | local frame = CreateFrame("Frame", nil, UIParent)
143 | frame:Hide()
144 |
145 | local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontHighlightSmall")
146 | label:SetJustifyH("LEFT")
147 | label:SetJustifyV("TOP")
148 |
149 | local image = frame:CreateTexture(nil, "BACKGROUND")
150 |
151 | -- create widget
152 | local widget = {
153 | label = label,
154 | image = image,
155 | frame = frame,
156 | type = Type
157 | }
158 | for method, func in pairs(methods) do
159 | widget[method] = func
160 | end
161 |
162 | return AceGUI:RegisterAsWidget(widget)
163 | end
164 |
165 | AceGUI:RegisterWidgetType(Type, Constructor, Version)
166 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/AceGUIWidget-Slider.lua:
--------------------------------------------------------------------------------
1 | --[[-----------------------------------------------------------------------------
2 | Slider Widget
3 | Graphical Slider, like, for Range values.
4 | -------------------------------------------------------------------------------]]
5 | local Type, Version = "Slider", 21
6 | local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
7 | if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
8 |
9 | -- Lua APIs
10 | local min, max, floor = math.min, math.max, math.floor
11 | local tonumber, pairs = tonumber, pairs
12 |
13 | -- WoW APIs
14 | local PlaySound = PlaySound
15 | local CreateFrame, UIParent = CreateFrame, UIParent
16 |
17 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
18 | -- List them here for Mikk's FindGlobals script
19 | -- GLOBALS: GameFontHighlightSmall
20 |
21 | --[[-----------------------------------------------------------------------------
22 | Support functions
23 | -------------------------------------------------------------------------------]]
24 | local function UpdateText(self)
25 | local value = self.value or 0
26 | if self.ispercent then
27 | self.editbox:SetText(("%s%%"):format(floor(value * 1000 + 0.5) / 10))
28 | else
29 | self.editbox:SetText(floor(value * 100 + 0.5) / 100)
30 | end
31 | end
32 |
33 | local function UpdateLabels(self)
34 | local min, max = (self.min or 0), (self.max or 100)
35 | if self.ispercent then
36 | self.lowtext:SetFormattedText("%s%%", (min * 100))
37 | self.hightext:SetFormattedText("%s%%", (max * 100))
38 | else
39 | self.lowtext:SetText(min)
40 | self.hightext:SetText(max)
41 | end
42 | end
43 |
44 | --[[-----------------------------------------------------------------------------
45 | Scripts
46 | -------------------------------------------------------------------------------]]
47 | local function Control_OnEnter()
48 | this.obj:Fire("OnEnter")
49 | end
50 |
51 | local function Control_OnLeave()
52 | this.obj:Fire("OnLeave")
53 | end
54 |
55 | local function Frame_OnMouseDown()
56 | this.obj.slider:EnableMouseWheel(true)
57 | AceGUI:ClearFocus()
58 | end
59 |
60 | local function Slider_OnValueChanged()
61 | local self = this.obj
62 | if not this.setup then
63 | local newvalue = this:GetValue()
64 | if self.step and self.step > 0 then
65 | local min_value = self.min or 0
66 | newvalue = floor((newvalue - min_value) / self.step + 0.5) * self.step + min_value
67 | end
68 | if newvalue ~= self.value and not self.disabled then
69 | self.value = newvalue
70 | self:Fire("OnValueChanged", 1, newvalue)
71 | end
72 | if self.value then
73 | UpdateText(self)
74 | end
75 | end
76 | end
77 |
78 | local function Slider_OnMouseUp()
79 | local self = this.obj
80 | self:Fire("OnMouseUp", 1, self.value)
81 | end
82 |
83 | local function Slider_OnMouseWheel()
84 | local self = this.obj
85 | if not self.disabled then
86 | local value = self.value
87 | if arg1 > 0 then
88 | value = min(value + (self.step or 1), self.max)
89 | else
90 | value = max(value - (self.step or 1), self.min)
91 | end
92 | self.slider:SetValue(value)
93 | end
94 | end
95 |
96 | local function EditBox_OnEscapePressed()
97 | this:ClearFocus()
98 | end
99 |
100 | local function EditBox_OnEnterPressed()
101 | local self = this.obj
102 | local value = this:GetText()
103 | if self.ispercent then
104 | value = value:gsub('%%', '')
105 | value = tonumber(value) / 100
106 | else
107 | value = tonumber(value)
108 | end
109 |
110 | if value then
111 | PlaySound("igMainMenuOptionCheckBoxOn")
112 | self.slider:SetValue(value)
113 | self:Fire("OnMouseUp", 1, value)
114 | end
115 | end
116 |
117 | local function EditBox_OnEnter()
118 | this:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
119 | end
120 |
121 | local function EditBox_OnLeave()
122 | this:SetBackdropBorderColor(0.3, 0.3, 0.3, 0.8)
123 | end
124 |
125 | --[[-----------------------------------------------------------------------------
126 | Methods
127 | -------------------------------------------------------------------------------]]
128 | local methods = {
129 | ["OnAcquire"] = function(self)
130 | self:SetWidth(200)
131 | self:SetHeight(44)
132 | self:SetDisabled(false)
133 | self:SetIsPercent(nil)
134 | self:SetSliderValues(0,100,1)
135 | self:SetValue(0)
136 | self.slider:EnableMouseWheel(false)
137 | end,
138 |
139 | -- ["OnRelease"] = nil,
140 |
141 | ["SetDisabled"] = function(self, disabled)
142 | self.disabled = disabled
143 | if disabled then
144 | self.slider:EnableMouse(false)
145 | self.label:SetTextColor(.5, .5, .5)
146 | self.hightext:SetTextColor(.5, .5, .5)
147 | self.lowtext:SetTextColor(.5, .5, .5)
148 | --self.valuetext:SetTextColor(.5, .5, .5)
149 | self.editbox:SetTextColor(.5, .5, .5)
150 | self.editbox:EnableMouse(false)
151 | self.editbox:ClearFocus()
152 | else
153 | self.slider:EnableMouse(true)
154 | self.label:SetTextColor(1, .82, 0)
155 | self.hightext:SetTextColor(1, 1, 1)
156 | self.lowtext:SetTextColor(1, 1, 1)
157 | --self.valuetext:SetTextColor(1, 1, 1)
158 | self.editbox:SetTextColor(1, 1, 1)
159 | self.editbox:EnableMouse(true)
160 | end
161 | end,
162 |
163 | ["SetValue"] = function(self, value)
164 | self.slider.setup = true
165 | self.slider:SetValue(value)
166 | self.value = value
167 | UpdateText(self)
168 | self.slider.setup = nil
169 | end,
170 |
171 | ["GetValue"] = function(self)
172 | return self.value
173 | end,
174 |
175 | ["SetLabel"] = function(self, text)
176 | self.label:SetText(text)
177 | end,
178 |
179 | ["SetSliderValues"] = function(self, min, max, step)
180 | local frame = self.slider
181 | frame.setup = true
182 | self.min = min
183 | self.max = max
184 | self.step = step
185 | frame:SetMinMaxValues(min or 0,max or 100)
186 | UpdateLabels(self)
187 | frame:SetValueStep(step or 1)
188 | if self.value then
189 | frame:SetValue(self.value)
190 | end
191 | frame.setup = nil
192 | end,
193 |
194 | ["SetIsPercent"] = function(self, value)
195 | self.ispercent = value
196 | UpdateLabels(self)
197 | UpdateText(self)
198 | end
199 | }
200 |
201 | --[[-----------------------------------------------------------------------------
202 | Constructor
203 | -------------------------------------------------------------------------------]]
204 | local SliderBackdrop = {
205 | bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
206 | edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
207 | tile = true, tileSize = 8, edgeSize = 8,
208 | insets = { left = 3, right = 3, top = 6, bottom = 6 }
209 | }
210 |
211 | local ManualBackdrop = {
212 | bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
213 | edgeFile = "Interface\\ChatFrame\\ChatFrameBackground",
214 | tile = true, edgeSize = 1, tileSize = 5,
215 | }
216 |
217 | local function Constructor()
218 | local frame = CreateFrame("Frame", nil, UIParent)
219 |
220 | frame:EnableMouse(true)
221 | frame:SetScript("OnMouseDown", Frame_OnMouseDown)
222 |
223 | local label = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
224 | label:SetPoint("TOPLEFT",0,0)
225 | label:SetPoint("TOPRIGHT",0,0)
226 | label:SetJustifyH("CENTER",0,0)
227 | label:SetHeight(15)
228 |
229 | local slider = CreateFrame("Slider", nil, frame)
230 | slider:SetOrientation("HORIZONTAL")
231 | slider:SetHeight(15)
232 | slider:SetHitRectInsets(0, 0, -10, 0)
233 | slider:SetBackdrop(SliderBackdrop)
234 | slider:SetThumbTexture("Interface\\Buttons\\UI-SliderBar-Button-Horizontal")
235 | slider:SetPoint("TOP", label, "BOTTOM")
236 | slider:SetPoint("LEFT", 3, 0)
237 | slider:SetPoint("RIGHT", -3, 0)
238 | slider:SetValue(0)
239 | slider:SetScript("OnValueChanged",Slider_OnValueChanged)
240 | slider:SetScript("OnEnter", Control_OnEnter)
241 | slider:SetScript("OnLeave", Control_OnLeave)
242 | slider:SetScript("OnMouseUp", Slider_OnMouseUp)
243 | slider:SetScript("OnMouseWheel", Slider_OnMouseWheel)
244 |
245 | local lowtext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
246 | lowtext:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 2, 3)
247 |
248 | local hightext = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
249 | hightext:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", -2, 3)
250 |
251 | local editbox = CreateFrame("EditBox", nil, frame)
252 | editbox:SetAutoFocus(false)
253 | editbox:SetFontObject(GameFontHighlightSmall)
254 | editbox:SetPoint("TOP", slider, "BOTTOM")
255 | editbox:SetHeight(14)
256 | editbox:SetWidth(70)
257 | editbox:SetJustifyH("CENTER")
258 | editbox:EnableMouse(true)
259 | editbox:SetBackdrop(ManualBackdrop)
260 | editbox:SetBackdropColor(0, 0, 0, 0.5)
261 | editbox:SetBackdropBorderColor(0.3, 0.3, 0.30, 0.80)
262 | editbox:SetScript("OnEnter", EditBox_OnEnter)
263 | editbox:SetScript("OnLeave", EditBox_OnLeave)
264 | editbox:SetScript("OnEnterPressed", EditBox_OnEnterPressed)
265 | editbox:SetScript("OnEscapePressed", EditBox_OnEscapePressed)
266 |
267 | local widget = {
268 | label = label,
269 | slider = slider,
270 | lowtext = lowtext,
271 | hightext = hightext,
272 | editbox = editbox,
273 | alignoffset = 25,
274 | frame = frame,
275 | type = Type
276 | }
277 | for method, func in pairs(methods) do
278 | widget[method] = func
279 | end
280 | slider.obj, editbox.obj = widget, widget
281 |
282 | return AceGUI:RegisterAsWidget(widget)
283 | end
284 |
285 | AceGUI:RegisterWidgetType(Type,Constructor,Version)
286 |
--------------------------------------------------------------------------------
/AceGUI-3.0/widgets/widgets.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/AceHook-3.0/AceHook-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceLocale-3.0/AceLocale-3.0.lua:
--------------------------------------------------------------------------------
1 | --- **AceLocale-3.0** manages localization in addons, allowing for multiple locale to be registered with fallback to the base locale for untranslated strings.
2 | -- @class file
3 | -- @name AceLocale-3.0
4 | -- @release $Id: AceLocale-3.0.lua 1035 2011-07-09 03:20:13Z kaelten $
5 | local MAJOR,MINOR = "AceLocale-3.0", 6
6 |
7 | local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
8 |
9 | if not AceLocale then return end -- no upgrade needed
10 |
11 | -- Lua APIs
12 | local assert, tostring, error = assert, tostring, error
13 | local getmetatable, setmetatable, rawset, rawget = getmetatable, setmetatable, rawset, rawget
14 |
15 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
16 | -- List them here for Mikk's FindGlobals script
17 | -- GLOBALS: GAME_LOCALE, geterrorhandler
18 |
19 | local gameLocale = GetLocale()
20 | if gameLocale == "enGB" then
21 | gameLocale = "enUS"
22 | end
23 |
24 | AceLocale.apps = AceLocale.apps or {} -- array of ["AppName"]=localetableref
25 | AceLocale.appnames = AceLocale.appnames or {} -- array of [localetableref]="AppName"
26 |
27 | -- This metatable is used on all tables returned from GetLocale
28 | local readmeta = {
29 | __index = function(self, key) -- requesting totally unknown entries: fire off a nonbreaking error and return key
30 | rawset(self, key, key) -- only need to see the warning once, really
31 | geterrorhandler()(MAJOR..": "..tostring(AceLocale.appnames[self])..": Missing entry for '"..tostring(key).."'")
32 | return key
33 | end
34 | }
35 |
36 | -- This metatable is used on all tables returned from GetLocale if the silent flag is true, it does not issue a warning on unknown keys
37 | local readmetasilent = {
38 | __index = function(self, key) -- requesting totally unknown entries: return key
39 | rawset(self, key, key) -- only need to invoke this function once
40 | return key
41 | end
42 | }
43 |
44 | -- Remember the locale table being registered right now (it gets set by :NewLocale())
45 | -- NOTE: Do never try to register 2 locale tables at once and mix their definition.
46 | local registering
47 |
48 | -- local assert false function
49 | local assertfalse = function() assert(false) end
50 |
51 | -- This metatable proxy is used when registering nondefault locales
52 | local writeproxy = setmetatable({}, {
53 | __newindex = function(self, key, value)
54 | rawset(registering, key, value == true and key or value) -- assigning values: replace 'true' with key string
55 | end,
56 | __index = assertfalse
57 | })
58 |
59 | -- This metatable proxy is used when registering the default locale.
60 | -- It refuses to overwrite existing values
61 | -- Reason 1: Allows loading locales in any order
62 | -- Reason 2: If 2 modules have the same string, but only the first one to be
63 | -- loaded has a translation for the current locale, the translation
64 | -- doesn't get overwritten.
65 | --
66 | local writedefaultproxy = setmetatable({}, {
67 | __newindex = function(self, key, value)
68 | if not rawget(registering, key) then
69 | rawset(registering, key, value == true and key or value)
70 | end
71 | end,
72 | __index = assertfalse
73 | })
74 |
75 | --- Register a new locale (or extend an existing one) for the specified application.
76 | -- :NewLocale will return a table you can fill your locale into, or nil if the locale isn't needed for the players
77 | -- game locale.
78 | -- @paramsig application, locale[, isDefault[, silent]]
79 | -- @param application Unique name of addon / module
80 | -- @param locale Name of the locale to register, e.g. "enUS", "deDE", etc.
81 | -- @param isDefault If this is the default locale being registered (your addon is written in this language, generally enUS)
82 | -- @param silent If true, the locale will not issue warnings for missing keys. Must be set on the first locale registered. If set to "raw", nils will be returned for unknown keys (no metatable used).
83 | -- @usage
84 | -- -- enUS.lua
85 | -- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "enUS", true)
86 | -- L["string1"] = true
87 | --
88 | -- -- deDE.lua
89 | -- local L = LibStub("AceLocale-3.0"):NewLocale("TestLocale", "deDE")
90 | -- if not L then return end
91 | -- L["string1"] = "Zeichenkette1"
92 | -- @return Locale Table to add localizations to, or nil if the current locale is not required.
93 | function AceLocale:NewLocale(application, locale, isDefault, silent)
94 |
95 | -- GAME_LOCALE allows translators to test translations of addons without having that wow client installed
96 | local gameLocale = GAME_LOCALE or gameLocale
97 |
98 | local app = AceLocale.apps[application]
99 |
100 | if silent and app and getmetatable(app) ~= readmetasilent then
101 | geterrorhandler()("Usage: NewLocale(application, locale[, isDefault[, silent]]): 'silent' must be specified for the first locale registered")
102 | end
103 |
104 | if not app then
105 | if silent=="raw" then
106 | app = {}
107 | else
108 | app = setmetatable({}, silent and readmetasilent or readmeta)
109 | end
110 | AceLocale.apps[application] = app
111 | AceLocale.appnames[app] = application
112 | end
113 |
114 | if locale ~= gameLocale and not isDefault then
115 | return nil -- nop, we don't need these translations
116 | end
117 |
118 | registering = app -- remember globally for writeproxy and writedefaultproxy
119 |
120 | if isDefault then
121 | return writedefaultproxy
122 | end
123 |
124 | return writeproxy
125 | end
126 |
127 | --- Returns localizations for the current locale (or default locale if translations are missing).
128 | -- Errors if nothing is registered (spank developer, not just a missing translation)
129 | -- @param application Unique name of addon / module
130 | -- @param silent If true, the locale is optional, silently return nil if it's not found (defaults to false, optional)
131 | -- @return The locale table for the current language.
132 | function AceLocale:GetLocale(application, silent)
133 | if not silent and not AceLocale.apps[application] then
134 | error("Usage: GetLocale(application[, silent]): 'application' - No locales registered for '"..tostring(application).."'", 2)
135 | end
136 | return AceLocale.apps[application]
137 | end
138 |
--------------------------------------------------------------------------------
/AceLocale-3.0/AceLocale-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceLocale-3.1/AceLocale-3.1.lua:
--------------------------------------------------------------------------------
1 | --- **AceLocale-3.1** manages localization in addons, allowing for multiple locale to be registered with fallback to the base locale for untranslated strings. AceLocale-3.1 is experimental.
2 | -- @class file
3 | -- @name AceLocale-3.0
4 | -- @release $Id: AceLocale-3.0.lua 1005 2011-01-29 14:19:43Z mikk $
5 | local MAJOR, MINOR = "AceLocale-3.1", 1
6 |
7 | local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
8 |
9 | if not AceLocale then return end -- no upgrade needed
10 |
11 | -- Lua APIs
12 | local assert, tostring, error = assert, tostring, error
13 | local setmetatable, rawset, rawget = setmetatable, rawset, rawget
14 |
15 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
16 | -- List them here for Mikk's FindGlobals script
17 | -- GLOBALS: GAME_LOCALE, geterrorhandler
18 |
19 | local gameLocale = GetLocale()
20 | if gameLocale == "enGB" then
21 | gameLocale = "enUS"
22 | end
23 |
24 | AceLocale.apps = AceLocale.apps or {} -- array of ["AppName"]=localetableref
25 | AceLocale.appnames = AceLocale.appnames or {} -- array of [localetableref]="AppName"
26 | AceLocale.appmodes = AceLocale.appmodes or {}
27 | AceLocale.applocales = AceLocale.applocales or {}
28 |
29 | AceLocale.KEY_ON_MISSING = "KEY_ON_MISSING"
30 | AceLocale.WARN_ON_MISSING = "WARN_ON_MISSING"
31 | AceLocale.NIL_ON_MISSING = "NIL_ON_MISSING"
32 |
33 | local read_metatables = {
34 | KEY_ON_MISSING = {
35 | -- returns the key for missing strings, no warning
36 | __index = function(self, key)
37 | rawset(self, key, key)
38 | return key
39 | end
40 | },
41 | WARN_ON_MISSING = {
42 | -- returns the key for missing strings, but gives a warning
43 | __index = function(self, key)
44 | rawset(self, key, key)
45 | geterrorhandler()(MAJOR .. ": " .. tostring(AceLocale.appnames[self]) .. ": Missing entry for '" .. tostring(key) .. "'")
46 | return key
47 | end
48 | },
49 | NIL_ON_MISSING = false -- this is here just so that the error checking in SetMode works properly
50 | }
51 |
52 | local registering_app
53 | local write_metatables = {
54 | DEFAULT = setmetatable({}, {
55 | __newindex = function(self, key, value)
56 | if not rawget(registering_app, key) then
57 | rawset(registering_app, key, value == true and key or value)
58 | end
59 | end,
60 | __index = function() assert(false) end
61 | }),
62 | LOCALE = setmetatable({}, {
63 | __newindex = function(self, key, value)
64 | rawset(registering_app, key, value == true and key or value)
65 | end,
66 | __index = function() assert(false) end
67 | })
68 | }
69 |
70 | --- Override the results of GetLocale() for a specific application.
71 | -- This must be called _before_ the first call to NewLocale for a given application.
72 | -- @paramsig application, locale
73 | -- @param application Unique name of the addon / module
74 | -- @param locale Name of the locale to use
75 | -- @usage
76 | -- -- in this example we're wanting to test how the german looks in the addon
77 | -- -- todo this we must call SetLocale before any NewLocale calls
78 | -- local AceLocale = LibStub("AceLocale-3.1")
79 | -- AceLocale:SetLocale("MyAddon", "deDE") -- testing how my addon looks in german
80 | --
81 | -- local L = AceLocale:NewLocale("MyAddon", "enUS", true)
82 | -- L["string1"] = true
83 | --
84 | -- local L = AceLocale:NewLocale("MyAddon", "deDE")
85 | -- L["string1"] = "Zeichenkette1"
86 | --
87 | -- local L = AceLocale:GetLocale("MyAddon")
88 | -- local var = L["string1"] -- will always result in "Zeichenkette1" regardless of what game client locale you're running on
89 | function AceLocale:SetLocale(application, locale)
90 | if self.apps[application] then
91 | error("Usage: GetLocale(application, locale): must be called before the first call to NewLocale.", 2)
92 | end
93 |
94 | self.applocales[application] = locale
95 | end
96 |
97 | --- Determines how AceLocale handles keys missing in the translation tables
98 | -- Valid modes are:
99 | -- * AceLocale.KEY_ON_MISSING - returns the key passed in
100 | -- * AceLocale.WARN_ON_MISSING - issues a warning, and then returns the key passed in
101 | -- * AceLocale.NIL_ON_MISSING - fails silently returning nil
102 | -- @paramsig application, mode
103 | -- @param application Unique name of the addon / module
104 | -- @param mode The flag that sets how to handle the missing keys. The default is KEY_ON_MISSING
105 | -- @usage
106 | -- local AceLocale = LibStub("AceLocale-3.1")
107 | --
108 | -- local L = AceLocale:NewLocale("MyAddon", "enUS", true)
109 | -- L["string1"] = true
110 | --
111 | -- local L = AceLocale:NewLocale("MyAddon", "deDE")
112 | -- L["string1"] = "Zeichenkette1"
113 | --
114 | -- local L = AceLocale:GetLocale("MyAddon")
115 | -- local var = L["string2"] -- will result in "string2"
116 | --
117 | -- AceLocale:SetMode("MyAddon", AceLocale.NIL_ON_MISSING)
118 | -- local var = L["string2"] -- will result in in nil
119 | function AceLocale:SetMode(application, mode)
120 | if not mode then
121 | mode = self.KEY_ON_MISSING
122 | end
123 |
124 | if read_metatables[mode] == nil then
125 | error("Usage: SetMode(application, mode): 'mode' - Invalid mode '" .. tostring(mode) .. "' used.", 2)
126 | end
127 |
128 | self.appmodes[application] = mode
129 |
130 | local app = self.apps[application]
131 | if app then
132 | setmetatable(app, read_metatables[mode] or nil) -- changes the false to a nil for NIL_ON_MISSING
133 | end
134 | end
135 |
136 | --- Register a new locale (or extend an existing one) for the specified application,
137 | -- returns a table you can fill your locale into, or nil if the locale doesn't need to be loaded
138 | -- @paramsig application, locale[, isDefault]
139 | -- @param application Unique name of addon / module
140 | -- @param locale Name of the locale to register, e.g. "enUS", "deDE", etc.
141 | -- @param isDefault If this is the default locale being registered (your addon is written in this language, generally enUS). This should only be passed in for _one_ locale.
142 | -- @usage
143 | -- -- enUS.lua
144 | -- local L = LibStub("AceLocale-3.0"):NewLocale("MyAddon", "enUS", true)
145 | -- L["string1"] = true
146 | --
147 | -- -- deDE.lua
148 | -- local L = LibStub("AceLocale-3.0"):NewLocale("MyAddon", "deDE")
149 | -- if not L then return end
150 | -- L["string1"] = "Zeichenkette1"
151 | -- @return Locale Table to add localizations to, or nil if the current locale is not needed.
152 | function AceLocale:NewLocale(application, locale, isDefault)
153 | local app = AceLocale.apps[application]
154 |
155 | if not app then
156 | app = {}
157 | self.apps[application] = app
158 | self.appnames[app] = application
159 | self:SetMode(application, self.appmodes[application])
160 | end
161 |
162 | local targetLocale = self.applocales[application] or gameLocale
163 |
164 | if locale ~= targetLocale and not isDefault then
165 | return
166 | end
167 |
168 | registering_app = app
169 | return isDefault and write_metatables["DEFAULT"] or write_metatables["LOCALE"]
170 | end
171 |
172 | --- Returns localizations for the current locale (or default locale if translations are missing).
173 | -- Errors if nothing is registered (spank developer, not just a missing translation)
174 | -- @param application Unique name of addon / module
175 | -- @param silent If true, the locale is optional, silently return nil if it's not found (defaults to false, optional)
176 | -- @return The locale table for the current language.
177 | function AceLocale:GetLocale(application, silent)
178 | if not silent and not AceLocale.apps[application] then
179 | error("Usage: GetLocale(application[, silent]): 'application' - No locales registered for '" .. tostring(application) .. "'", 2)
180 | end
181 | return AceLocale.apps[application]
182 | end
183 |
--------------------------------------------------------------------------------
/AceLocale-3.1/AceLocale-3.1.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceSerializer-3.0/AceSerializer-3.0.lua:
--------------------------------------------------------------------------------
1 | --- **AceSerializer-3.0** can serialize any variable (except functions or userdata) into a string format,
2 | -- that can be send over the addon comm channel. AceSerializer was designed to keep all data intact, especially
3 | -- very large numbers or floating point numbers, and table structures. The only caveat currently is, that multiple
4 | -- references to the same table will be send individually.
5 | --
6 | -- **AceSerializer-3.0** can be embeded into your addon, either explicitly by calling AceSerializer:Embed(MyAddon) or by
7 | -- specifying it as an embeded library in your AceAddon. All functions will be available on your addon object
8 | -- and can be accessed directly, without having to explicitly call AceSerializer itself.\\
9 | -- It is recommended to embed AceSerializer, otherwise you'll have to specify a custom `self` on all calls you
10 | -- make into AceSerializer.
11 | -- @class file
12 | -- @name AceSerializer-3.0
13 | -- @release $Id: AceSerializer-3.0.lua 1135 2015-09-19 20:39:16Z nevcairiel $
14 | local MAJOR,MINOR = "AceSerializer-3.0", 5
15 | local AceSerializer, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
16 |
17 | if not AceSerializer then return end
18 |
19 | -- Lua APIs
20 | local strbyte, strchar, gsub, gfind, format = string.byte, string.char, string.gsub, string.gfind, string.format
21 | local assert, error, pcall = assert, error, pcall
22 | local type, tostring, tonumber = type, tostring, tonumber
23 | local pairs, select, frexp = pairs, select, math.frexp
24 | local tconcat, tgetn = table.concat, table.getn
25 |
26 | -- quick copies of string representations of wonky numbers
27 | local inf = 1/0
28 |
29 | local serNaN -- can't do this in 4.3, see ace3 ticket 268
30 | local serInf, serInfMac = "1.#INF", "inf"
31 | local serNegInf, serNegInfMac = "-1.#INF", "-inf"
32 |
33 |
34 | -- Serialization functions
35 |
36 | local function SerializeStringHelper(ch) -- Used by SerializeValue for strings
37 | -- We use \126 ("~") as an escape character for all nonprints plus a few more
38 | local n = strbyte(ch)
39 | if n==30 then -- v3 / ticket 115: catch a nonprint that ends up being "~^" when encoded... DOH
40 | return "\126\122"
41 | elseif n<=32 then -- nonprint + space
42 | return "\126"..strchar(n+64)
43 | elseif n==94 then -- value separator
44 | return "\126\125"
45 | elseif n==126 then -- our own escape character
46 | return "\126\124"
47 | elseif n==127 then -- nonprint (DEL)
48 | return "\126\123"
49 | else
50 | assert(false) -- can't be reached if caller uses a sane regex
51 | end
52 | end
53 |
54 | local function SerializeValue(v, res, nres)
55 | -- We use "^" as a value separator, followed by one byte for type indicator
56 | local t=type(v)
57 |
58 | if t=="string" then -- ^S = string (escaped to remove nonprints, "^"s, etc)
59 | res[nres+1] = "^S"
60 | res[nres+2] = gsub(v,"[%c \94\126\127]", SerializeStringHelper)
61 | nres=nres+2
62 |
63 | elseif t=="number" then -- ^N = number (just tostring()ed) or ^F (float components)
64 | local str = tostring(v)
65 | if tonumber(str)==v --[[not in 4.3 or str==serNaN]] then
66 | -- translates just fine, transmit as-is
67 | res[nres+1] = "^N"
68 | res[nres+2] = str
69 | nres=nres+2
70 | elseif v == inf or v == -inf then
71 | res[nres+1] = "^N"
72 | res[nres+2] = v == inf and serInf or serNegInf
73 | nres=nres+2
74 | else
75 | local m,e = frexp(v)
76 | res[nres+1] = "^F"
77 | res[nres+2] = format("%.0f",m*2^53) -- force mantissa to become integer (it's originally 0.5--0.9999)
78 | res[nres+3] = "^f"
79 | res[nres+4] = tostring(e-53) -- adjust exponent to counteract mantissa manipulation
80 | nres=nres+4
81 | end
82 |
83 | elseif t=="table" then -- ^T...^t = table (list of key,value pairs)
84 | nres=nres+1
85 | res[nres] = "^T"
86 | for k,v in pairs(v) do
87 | nres = SerializeValue(k, res, nres)
88 | nres = SerializeValue(v, res, nres)
89 | end
90 | nres=nres+1
91 | res[nres] = "^t"
92 |
93 | elseif t=="boolean" then -- ^B = true, ^b = false
94 | nres=nres+1
95 | if v then
96 | res[nres] = "^B" -- true
97 | else
98 | res[nres] = "^b" -- false
99 | end
100 |
101 | elseif t=="nil" then -- ^Z = nil (zero, "N" was taken :P)
102 | nres=nres+1
103 | res[nres] = "^Z"
104 |
105 | else
106 | error(MAJOR..": Cannot serialize a value of type '"..t.."'") -- can't produce error on right level, this is wildly recursive
107 | end
108 |
109 | return nres
110 | end
111 |
112 |
113 |
114 | local serializeTbl = { "^1" } -- "^1" = Hi, I'm data serialized by AceSerializer protocol rev 1
115 |
116 | --- Serialize the data passed into the function.
117 | -- Takes a list of values (strings, numbers, booleans, nils, tables)
118 | -- and returns it in serialized form (a string).\\
119 | -- May throw errors on invalid data types.
120 | -- @param ... List of values to serialize
121 | -- @return The data in its serialized form (string)
122 | function AceSerializer:Serialize(...)
123 | local nres = 1
124 | for i = 1,tgetn(arg) do
125 | local v = arg[i]
126 | nres = SerializeValue(v, serializeTbl, nres)
127 | end
128 |
129 | serializeTbl[nres+1] = "^^" -- "^^" = End of serialized data
130 |
131 | return tconcat(serializeTbl, "", 1, nres+1)
132 | end
133 |
134 | -- Deserialization functions
135 | local function DeserializeStringHelper(escape)
136 | if escape<"~\122" then
137 | return strchar(strbyte(escape,2,2)-64)
138 | elseif escape=="~\122" then -- v3 / ticket 115: special case encode since 30+64=94 ("^") - OOPS.
139 | return "\030"
140 | elseif escape=="~\123" then
141 | return "\127"
142 | elseif escape=="~\124" then
143 | return "\126"
144 | elseif escape=="~\125" then
145 | return "\94"
146 | end
147 | error("DeserializeStringHelper got called for '"..escape.."'?!?") -- can't be reached unless regex is screwed up
148 | end
149 |
150 | local function DeserializeNumberHelper(number)
151 | --[[ not in 4.3 if number == serNaN then
152 | return 0/0
153 | else]]if number == serNegInf or number == serNegInfMac then
154 | return -inf
155 | elseif number == serInf or number == serInfMac then
156 | return inf
157 | else
158 | return tonumber(number)
159 | end
160 | end
161 |
162 | -- DeserializeValue: worker function for :Deserialize()
163 | -- It works in two modes:
164 | -- Main (top-level) mode: Deserialize a list of values and return them all
165 | -- Recursive (table) mode: Deserialize only a single value (_may_ of course be another table with lots of subvalues in it)
166 | --
167 | -- The function _always_ works recursively due to having to build a list of values to return
168 | --
169 | -- Callers are expected to pcall(DeserializeValue) to trap errors
170 |
171 | local function DeserializeValue(iter,single,ctl,data)
172 |
173 | if not single then
174 | ctl,data = iter()
175 | end
176 |
177 | if not ctl then
178 | error("Supplied data misses AceSerializer terminator ('^^')")
179 | end
180 |
181 | if ctl=="^^" then
182 | -- ignore extraneous data
183 | return
184 | end
185 |
186 | local res
187 |
188 | if ctl=="^S" then
189 | res = gsub(data, "~.", DeserializeStringHelper)
190 | elseif ctl=="^N" then
191 | res = DeserializeNumberHelper(data)
192 | if not res then
193 | error("Invalid serialized number: '"..tostring(data).."'")
194 | end
195 | elseif ctl=="^F" then -- ^F^f
196 | local ctl2,e = iter()
197 | if ctl2~="^f" then
198 | error("Invalid serialized floating-point number, expected '^f', not '"..tostring(ctl2).."'")
199 | end
200 | local m=tonumber(data)
201 | e=tonumber(e)
202 | if not (m and e) then
203 | error("Invalid serialized floating-point number, expected mantissa and exponent, got '"..tostring(m).."' and '"..tostring(e).."'")
204 | end
205 | res = m*(2^e)
206 | elseif ctl=="^B" then -- yeah yeah ignore data portion
207 | res = true
208 | elseif ctl=="^b" then -- yeah yeah ignore data portion
209 | res = false
210 | elseif ctl=="^Z" then -- yeah yeah ignore data portion
211 | res = nil
212 | elseif ctl=="^T" then
213 | -- ignore ^T's data, future extensibility?
214 | res = {}
215 | local k,v
216 | while true do
217 | ctl,data = iter()
218 | if ctl=="^t" then break end -- ignore ^t's data
219 | k = DeserializeValue(iter,true,ctl,data)
220 | if k==nil then
221 | error("Invalid AceSerializer table format (no table end marker)")
222 | end
223 | ctl,data = iter()
224 | v = DeserializeValue(iter,true,ctl,data)
225 | if v==nil then
226 | error("Invalid AceSerializer table format (no table end marker)")
227 | end
228 | res[k]=v
229 | end
230 | else
231 | error("Invalid AceSerializer control code '"..ctl.."'")
232 | end
233 |
234 | if not single then
235 | return res,DeserializeValue(iter)
236 | else
237 | return res
238 | end
239 | end
240 |
241 | --- Deserializes the data into its original values.
242 | -- Accepts serialized data, ignoring all control characters and whitespace.
243 | -- @param str The serialized data (from :Serialize)
244 | -- @return true followed by a list of values, OR false followed by an error message
245 | function AceSerializer:Deserialize(str)
246 | str = gsub(str, "[%c ]", "") -- ignore all control characters; nice for embedding in email and stuff
247 |
248 | local iter = gfind(str, "(^.)([^^]*)") -- Any ^x followed by string of non-^
249 | local ctl,data = iter()
250 | if not ctl or ctl~="^1" then
251 | -- we purposefully ignore the data portion of the start code, it can be used as an extension mechanism
252 | return false, "Supplied data is not AceSerializer data (rev 1)"
253 | end
254 |
255 | return pcall(DeserializeValue, iter)
256 | end
257 |
258 |
259 | ----------------------------------------
260 | -- Base library stuff
261 | ----------------------------------------
262 |
263 | AceSerializer.internals = { -- for test scripts
264 | SerializeValue = SerializeValue,
265 | SerializeStringHelper = SerializeStringHelper,
266 | }
267 |
268 | local mixins = {
269 | "Serialize",
270 | "Deserialize",
271 | }
272 |
273 | AceSerializer.embeds = AceSerializer.embeds or {}
274 |
275 | function AceSerializer:Embed(target)
276 | for k, v in pairs(mixins) do
277 | target[v] = self[v]
278 | end
279 | self.embeds[target] = true
280 | return target
281 | end
282 |
283 | -- Update embeds
284 | for target, v in pairs(AceSerializer.embeds) do
285 | AceSerializer:Embed(target)
286 | end
--------------------------------------------------------------------------------
/AceSerializer-3.0/AceSerializer-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/AceTab-3.0/AceTab-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AceTimer-3.0/AceTimer-3.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/Bindings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ReloadUI()
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2007, Ace3 Development Team
2 |
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | * Redistributions of source code must retain the above copyright notice,
9 | this list of conditions and the following disclaimer.
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 | * Redistribution of a stand alone version is strictly prohibited without
14 | prior written authorization from the Lead of the Ace3 Development Team.
15 | * Neither the name of the Ace3 Development Team nor the names of its contributors
16 | may be used to endorse or promote products derived from this software without
17 | specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Ace3v
2 | Vanilla WoW AddOn Library - Ace3
3 |
4 | The goal of this project is to bring the Ace3 into vanilla wow. The author of the original Ace3 library is the Ace3 Development team.
5 |
6 | Project current situation:
7 |
8 | * All basic libraries are recoded so that they can be used in vanilla WOW
9 |
10 | * Most of the AceGUI library are recoded, need furthur tests
11 |
12 | * Added an additional lib AceCursor which is still under development, the purpose of this library is to implement the function GetCursorInfo of retail WoW
13 |
--------------------------------------------------------------------------------