-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathring-prototypes.txt
197 lines (150 loc) · 8.07 KB
/
ring-prototypes.txt
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
This documentation describes how to create your own ring. It is quite out-dated
and won't be updated until some real 3rd party interest is there.
nyyr, 2012-08-22
ArcHUD Rings support
---------------------
Since 1.2 ArcHUD's rings have been completely reworked. Every ring are now created from
a base class. This class has a few predefined functions and behind-the-scenes functionality.
This makes it very easy to add your own rings to ArcHUD. If you want to add your own ring to
ArcHUD there are a few guidelines you need to follow. What will follow below is a basic setup
to get a ring up and running.
Rings created can be added as a new addon with ArcHUD as a dependency. This is the preferred way
to add your own custom rings to ArcHUD.
First you will need to create your ring object, if you've worked with Ace2 addons previously this
will be very similar to how you create an addon with Ace2. Alot of things will be set up for you
however. Things such as locale and database support are created for every new ring added. To access
the database you use the object self.db. To access the locale table you use self.L. You can read more
about these objects at the WoWAce Wiki at http://wiki.wowace.com/index.php/Ace2.
-------------------------------------------------------------------
local module = ArcHUD:NewModule("MyRing")
module.unit = "player"
defaults = {
Enabled = true,
Outline = true,
}
options = {
attach = false,
}
-------------------------------------------------------------------
This will create a module with the name MyRing and a few default options.
All options needed for the ring are specified in the defaults table. They are automatically added to
the ArcHUD DB when you load the ring.
There are few base methods you will need to get the ring set up. These are Initialize and Enable.
If you don't have the Initialize method the ring wont load. Initialize is a good place to create
any frames the ring will use, for example the ring frame itself.
-------------------------------------------------------------------
function module:Initialize()
self.f = self:CreateRing(true, ArcHUDFrame)
self.f:SetPoint("TOPLEFT", self.parent:GetModule("Anchors").Left, "TOPLEFT", -30, 0);
end
-------------------------------------------------------------------
We've now created a ring with a background outline and stored it in self.f. The ring is now a
child frame of ArcHUDFrame, the main frame for ArcHUD. It has also been positioned onto the left
anchor as the second ring from the center. Attaching to the anchors will make sure the ring follows
the width option.
Next we will need an Enable method. This will contain things that will be run every time the ring
is enabled. Initialize will only run once while Enable will run if the user enables or disables the
ring.
-------------------------------------------------------------------
function module:Enable()
-- Take care of options
if(self.db.profile.Outline) then
self.f.BG:Show()
else
self.f.BG:Hide()
end
-- Register some events
self:RegisterEvent("UNIT_HEALTH")
-- Override Update timer
self:UnregisterMetro(self.name .. "Update")
self:RegisterMetro(self.name .. "Update", self.UpdateAlpha, 0.05, self)
-- Activate timer
self:StartMetro(self.name .. "Alpha")
self:StartMetro(self.name .. "Fade")
self:StartMetro(self.name .. Update")
end
function module:UpdateAlpha()
if(self.f.startValue < self.f.maxValue) then
self.f:SetRingAlpha(ArcHUD.FadeOOC)
else
self.f:SetRingAlpha(ArcHUD.FadeFull)
end
end
-------------------------------------------------------------------
Now that that's done you will need to take care of that event somehow. This works just like in an Ace
addon
-------------------------------------------------------------------
function module:UNIT_HEALTH()
self.f:SetValue(UnitHealth(self.unit))
end
-------------------------------------------------------------------
This is a very basic ring and will probably not do very much good. At least you got a little something
start from. I suggest you look at the other rings to get a better understanding of how it all works.
ArcHUDRing reference
---------------------
SPECIAL TABLES
The base class will look for certain special tables in the created ring object. These are listed below
along with the format in which they should be in.
unit = "unit" This is an optional variable. Specify the unit name the ring will be
working with here and use it through the code.
defaults = { defaults contains all the default options the ring uses. These
option1 = value1, will be added to the user options if they load the ring for the
option2 = value2, first time. These will also get loaded into the main defaults
} table to be used in case the user requests a reset of the options.
NOTE: Enabled and Outline must be present on all rings! If you want
the ring to be movable in the options you must also specify
a default placement by use of Side and Level.
options = { options contains the options and locals to be used in the options
{name = "option1", frame. Do not include Enabled, Outline, Side and Level in this
text = "Sets option1", table. The first two are handled automatically by the options frame
tooltip = "This will set and the last two are controlled by the attach entry. If attach is
option1"}, TRUE then the ring will be allowed to repositioned.
{name = "option2",
text = "Sets option2", NOTE: name must match the option name in the defaults table! You
tooltip = "This will set must have this table if you want your ring to appear in the
option2"}, options frame. Leave it empty if you don't have any other
attach = false, options other than Enabled and Outline.
}
disableEvents = { disableEvents contains certain events that you want the ring to
{frame = "framename", disable on load. This could be to prevent another frame from
events = {"event1", recieving events that your ring should be taking care of. An
"event2"}}, example of this can be seen in the Casting and MirrorTimer rings.
{frame = "framename2",
events = {"event1", NOTE: Events specified will be disabled when the ring is enabled
"event2"}}, and re-enabled once the ring is disabled.
}
METHODS
The base class got a few functions for you to start off with.
self:CreateRing(hasBG, parent)
This will create a ring for you and return the object.
Parameters:
hasBG - Set to true to also create a background outline
parent - The parent object for the ring (must pass an object, not a string)
Returns:
frame - Frame containing the ring
self:CreateFontString(parent, layer, size, fontsize, justify, color, point)
This creates a FontString object, sets the font, size, color, justification and positions it.
Parameters:
parent - The parent object for the fontstring (must pass an object, not a string)
layer - The layer of which it will be created on (see WoWWiki for more information)
size - An array of two values. Sets the size of the fontstring.
{width, height}
fontsize - The size of the font
justify - Horizontal justification (LEFT, CENTER, RIGHT)
color - The color of the fontstring in RGB values.
{red, green, blue}
point - Same as the arguments passed to frame:SetPoint
{"point","relativeFrame" or relativeObject,"relativePoint"[,xOfs,yOfs]}
Returns:
fontstring - Fontstring created according to input parameters
self:CreateTexture(parent, layer, size, texture, point)
This creates a texture object, optionally sets the texture and position.
Parameters:
parent - The parent object for the texture (must pass an object, not a string)
layer - The layer of which it will be created on (see WoWWiki for more information)
size - An array of two values. Sets the size of the texture.
{width, height}
point - Same as the arguments passed to frame:SetPoint
{"point","relativeFrame" or relativeObject,"relativePoint"[,xOfs,yOfs]}
Returns:
texture - Texture created according to input parameters