-
Notifications
You must be signed in to change notification settings - Fork 6
/
ThirdPartyHooks.lua
284 lines (253 loc) · 10.7 KB
/
ThirdPartyHooks.lua
1
2
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
--[[
Skillet: A tradeskill window replacement.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--
--[[
**** Not all of this documentation has been verified as accurate in Skillet-Classic ****
This file contains functions intended to be used by authors of other mods.
I will make every effort never to change the names or behaviour of any of the
methods listed in this file. All bets are off for methods in other files though.
If you would like to see a method added here that would benefit your mod, by all
means contact me and let me know.
While I have provided "Hooking" documentation, I do not recommend or support it's use.
I have left the documentation in this file for historical purposes.
In the time since this file was first created, some newer methods of interfacing with
Skillet have been created. See the Skillet\Plugins folder for some examples.
Hooking a Method Using AceHook
------------------------------
To hook this routine with an Ace2 mod, use (for example):
self:Hook(Skillet, "GetExtraItemDetailText")
and write your method:
function MyMod:GetExtraItemDetailText(skill, recipe)
-- get the previous value from the hook chain
local before = self.hooks["GetExtraItemDetailText"](obj, skill, recipe)
local myvalue = "samplething"
if before then
return before .. "\n" .. myvalue
else
return myvalue
end
end
Hooking a Method Without Using AceHook
--------------------------------------
local orig_get_extra = Skillet.GetExtraItemDetailText
Skillet.GetExtraItemDetailText = function(obj, skill, recipe)
local before = orig_get_extra(obj, skill, recipe)
local myvalue = "samplething"
if before then
return before .. "\n" .. myvalue
else
return myvalue
end
end
In both methods, the 'obj' passed in will be a copy of the 'Skillet' main object.
Of course, the action you take with the previous value is entirely dependent
of what the method does. For methods that return text, you should probably
concatenetate the values. For something like Skillet:GetMinSkillButtonWidth()
you should return the maximum of the previous value and you value.
Please remember that there may be multple mods hooking these methods so please
be courteous and make sure not to discard their data, but rather combine it with
your own in as sane a fashion as possible.
]]
--=================================================================================
-- ******* Start of the public API ********
--
-- NOTE: This file documents functions that are defined (and used) in other
-- Skillet source files. The function line is copied here as a comment.
--=================================================================================
--
--== function Skillet:AddButtonToTradeskillWindow(button) ==
--
-- Adds a button to the tradeskill window. The button will be
-- reparented and placed appropriately in the window.
--
-- You should not hook this method, you should call it directly.
--
-- The frame representing the main tradeskill window will be
-- returned in case you need to pop up a frame attached to it.
--
--
--== function Skillet:AddRecipeSorter(text, sorter) ==
--
-- Adds a sort method to those used for recipe names.
--
-- You should not hook this method, you should call it directly.
--
-- With this method you can add your own custom sorting to the
-- list of recipes in the scrolling list.
--
-- @param text The name of you sorting method, will be shown to the
-- user in a drop-down menu
-- @param method Your sorting method (described below)
--
-- Your sorting method must have the following signature
--
-- function sort(tradeskill, index_a, index_b)
--
-- where:
-- tradeskill is the name of the currently selected tradeskill
-- index_a in the skill index of the first recipe
-- index_b is the skill index of the second recipe
--
-- Your method must return 'true' if a should be before b and 'false'
-- if a should be after b.
--
--
-- The following four functions, RecipeNamePrefix, RecipeNameSuffix, Update, and GetExtraText are
-- documented here but are used by plugins written like those in the Skillet\Plugins folder.
--
--== function plugin.RecipeNamePrefix(skill, recipe) ==
--
-- A function called to get text to prefix the name of the recipe in the scrolling list of recipes.
--
-- This will be called for both crafts and tradeskills, you can use Skillet:IsCraft()
-- to determine if it's a craft. This avoid having to localize the tradeskill name just to
-- see if it is a craft or a tradeskill.
--
-- @param skill table containing name of the currently selected tradeskill (see documentation below)
-- @param recipe table containing the index and ID of the currently selected recipe (see documentation below)
--
-- @return text string (left side)
--
--
--== function plugin.RecipeNameSuffix(skill, recipe) ==
--
-- A function called to get text to append to the name of the recipe in the scrolling list of recipes
--
-- This will be called for both crafts and tradeskills, you can use Skillet:IsCraft()
-- to determine if it's a craft. This avoid having to localize the tradeskill name just to
-- see if it is a craft or a tradeskill.
--
-- @param skill table containing name of the currently selected tradeskill (see documentation below)
-- @param recipe table containing the index and ID of the currently selected recipe (see documentation below)
--
-- @return text string (right side)
--
--== function plugin.Update() ==
--
-- A function called by the UpdateTradeSkillWindow function to do any plugin specific
-- SkilletFrame updates.
--
-- This will be called for both crafts and tradeskills, you can use Skillet:IsCraft()
-- to determine if it's a craft. This avoids having to localize the tradeskill name just to
-- see if it is a craft or a tradeskill.
--
-- @return is ignored
--
--== function plugin.GetExtraText(skill, recipe) ==
--
-- A function called to display extra information about a recipe. Any text returned from this function
-- will be displayed in the recipe details frame when the user clicks on the recipe name.
-- The text will be added to the bottom the frame, after the list of reagents.
--
-- This will be called for both crafts and tradeskills, you can use Skillet:IsCraft()
-- to determine if it's a craft. This avoids having to localize the tradeskill name just to
-- see if it is a craft or a tradeskill.
--
-- @param skill table containing name of the currently selected tradeskill (need to add documentation below)
-- @param recipe table containing the index and ID of the currently selected recipe (need to update documentation below)
--
-- @return label string (left side)
-- @return text string (right side)
--
--
--== function Skillet:AddPreButtonShowCallback(method) == **** Untested in Skillet-Classic ****
--
-- Adds a method that will be called before a button in the recipe list
-- is shown. If multiple methods are added, they will be called in the
-- order they are registered.
--
-- The method you provide *must* have the following signature and behaviour:
--
-- function yourfunc(button, tradeskill, skillIndex, listOffset, recipeID)
--
-- where:
-- o button the button that is about to be displayed
-- o tradeskill the name of the currently selected tradeskill
-- o skillIndex the index of recipe this button is used for
-- o listOffset how far down in the scrolling this button is located.
-- No matter where the list is scrolled to, the first visible recipe
-- is at listOffset 0
-- o recipeID is the id of the recipe of this button
--
-- returns:
-- the button who's :Show() method is to be called
--
-- If you return your own button (instead of returning the button passed in),
-- you are responsible for attaching it properly in the list. The listOffset
-- parameter might be useful here as you could use this to determine the name
-- of the button immediately before this one in the list and attach to it.
--
--
--== function Skillet:AddPreButtonHideCallback(method) == **** Untested in Skillet-Classic ****
--
-- Adds a method that will be called before a button in the recipe list
-- is hidden. If multiple methods are added, they will be called in the
-- order they are registered.
--
-- The method you provide *must* have the following signature and behaviour:
--
-- function yourfunc(button, tradeskill, skillIndex, listOffset)
--
-- where:
-- o button the button that is about to be displayed
-- o tradeskill the name of the currently selected tradeskill
-- o skillIndex the index of recipe thius button is used for
-- o listOffset how far down in the scrolling this button is located.
-- No matter where the list is scrolled to, the first visible recipe
-- is at listOffset 0
--
-- returns:
-- the button who's :Hide() method is to be called
--
-- If you return your own button (instead of returning the button passed in),
-- you are responsible for attaching it properly in the list. The listOffset
-- parameter might be useful here as you could use this to determine the name
-- of the button immediately before this one in the list and attach to it.
--
-- =================================================================
-- Skillet Recipe API
-- =================================================================
--[[
All data returned from theses methods is to be considered READ-ONLY
**** Update for Skillet-Classic needed ****
Data Formats
============
Skill = {
["parentIndex"] = number
["skillData"] = {table}
["name"] = string
["skillIndex"] = number
["parent"] = {table}
["depth"] = number
["recipeID"] = number
["spellID"] = number (same as recipeID)
}
Recipe = {
["name"] = string
["numMade"] = number (how many this recipe make)
["vendorOnly"] = boolean
["itemID"] = number
["tradeID"] = number
["spellID"] = number
["scrollID"] = number
["reagentData] = {table} with number of reagents for this recipe
[index 1] = Reagent
[index 2] = Reagent
...
}
Reagent = {
["id"] = number (itemID)
["name"] = string (name of reagent)
["numNeeded"] = number (how many of this reagent needed)
}
]]