1 |
13 |
Thurallor-7095 |
Slot = class(Turbine.UI.Control); |
2 |
|
Thurallor-7095 |
|
3 |
117 |
Thurallor-7095 |
function Slot:Constructor(info, wantsMouseWheelEvents) |
4 |
13 |
Thurallor-7095 |
Turbine.UI.Control.Constructor(self); |
5 |
|
Thurallor-7095 |
self:SetMouseVisible(false); |
6 |
|
Thurallor-7095 |
self:SetSize(36, 36); |
7 |
143 |
Thurallor-7095 |
self.advanceFunc = {}; |
8 |
13 |
Thurallor-7095 |
self:SetInfo(info); |
9 |
15 |
Thurallor-7095 |
self:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend); |
10 |
|
Thurallor-7095 |
Turbine.UI.Control.SetAllowDrop(self, false); |
11 |
117 |
Thurallor-7095 |
self.wantsMouseWheelEvents = wantsMouseWheelEvents; |
12 |
13 |
Thurallor-7095 |
end |
13 |
|
Thurallor-7095 |
|
14 |
|
Thurallor-7095 |
function Slot:GetInfo() |
15 |
|
Thurallor-7095 |
return self.info; |
16 |
|
Thurallor-7095 |
end |
17 |
|
Thurallor-7095 |
|
18 |
151 |
Thurallor-7095 |
-- Get skill name(s) from moebius92's SkillData database |
19 |
|
Thurallor-7095 |
function Slot:GetSkillNames() |
20 |
|
Thurallor-7095 |
if (not self.skillNames and (self.info.type == Turbine.UI.Lotro.ShortcutType.Skill)) then |
21 |
143 |
Thurallor-7095 |
local shortcut = self.object and self.object.GetShortcut and self.object:GetShortcut(); |
22 |
151 |
Thurallor-7095 |
self.skillNames = shortcut and shortcut:GetSkillName(); |
23 |
|
Thurallor-7095 |
if (type(self.skillNames) == "string") then |
24 |
|
Thurallor-7095 |
self.skillNames = { self.skillNames }; |
25 |
|
Thurallor-7095 |
end |
26 |
143 |
Thurallor-7095 |
end |
27 |
151 |
Thurallor-7095 |
return self.skillNames; |
28 |
143 |
Thurallor-7095 |
end |
29 |
|
Thurallor-7095 |
|
30 |
151 |
Thurallor-7095 |
-- Get canonical skill name (with no fire oil, light oil, alternate stance, etc.) |
31 |
|
Thurallor-7095 |
function Slot:GetSkillName() |
32 |
152 |
Thurallor-7095 |
local skillNames = self:GetSkillNames(); |
33 |
|
Thurallor-7095 |
if (skillNames) then |
34 |
|
Thurallor-7095 |
return skillNames[1]; |
35 |
151 |
Thurallor-7095 |
end |
36 |
|
Thurallor-7095 |
end |
37 |
|
Thurallor-7095 |
|
38 |
143 |
Thurallor-7095 |
function Slot:GetSkill() |
39 |
151 |
Thurallor-7095 |
local names = self:GetSkillNames(); |
40 |
|
Thurallor-7095 |
if (type(names) == "string") then |
41 |
|
Thurallor-7095 |
return Thurallor.Utils.Watcher.GetSkillByNames(names); |
42 |
|
Thurallor-7095 |
elseif (type(names) == "table") then |
43 |
|
Thurallor-7095 |
return Thurallor.Utils.Watcher.GetSkillByNames(names); |
44 |
|
Thurallor-7095 |
end |
45 |
143 |
Thurallor-7095 |
end |
46 |
|
Thurallor-7095 |
|
47 |
20 |
Thurallor-7095 |
function Slot:GetItem() |
48 |
|
Thurallor-7095 |
if (self.object.GetItem) then |
49 |
|
Thurallor-7095 |
return self.object:GetItem(); |
50 |
|
Thurallor-7095 |
end |
51 |
|
Thurallor-7095 |
end |
52 |
|
Thurallor-7095 |
|
53 |
143 |
Thurallor-7095 |
function Slot:GetItemName() |
54 |
|
Thurallor-7095 |
local item = self:GetItem(); |
55 |
|
Thurallor-7095 |
return item and item:GetItemInfo():GetName(); |
56 |
|
Thurallor-7095 |
end |
57 |
|
Thurallor-7095 |
|
58 |
13 |
Thurallor-7095 |
function Slot:GetNumLabel() |
59 |
|
Thurallor-7095 |
return self.slotNumber; |
60 |
|
Thurallor-7095 |
end |
61 |
|
Thurallor-7095 |
|
62 |
|
Thurallor-7095 |
function Slot:IsQuickslot() |
63 |
|
Thurallor-7095 |
return self.isQuickslot; |
64 |
|
Thurallor-7095 |
end |
65 |
|
Thurallor-7095 |
|
66 |
|
Thurallor-7095 |
function Slot:SetActionEnabled(enabled) |
67 |
|
Thurallor-7095 |
self.actionEnabled = enabled; |
68 |
21 |
Thurallor-7095 |
if (self.object) then |
69 |
|
Thurallor-7095 |
self.object:SetMouseVisible(enabled); |
70 |
|
Thurallor-7095 |
end |
71 |
13 |
Thurallor-7095 |
if (self.numLabel) then |
72 |
|
Thurallor-7095 |
self.numLabel:SetMouseVisible(not enabled); |
73 |
|
Thurallor-7095 |
end |
74 |
|
Thurallor-7095 |
end |
75 |
|
Thurallor-7095 |
|
76 |
|
Thurallor-7095 |
function Slot:SetAllowDrop(allowDrop) |
77 |
|
Thurallor-7095 |
if (self.numLabel) then |
78 |
|
Thurallor-7095 |
self.numLabel:SetAllowDrop(allowDrop); |
79 |
21 |
Thurallor-7095 |
elseif (self.object) then |
80 |
13 |
Thurallor-7095 |
self.object:SetAllowDrop(allowDrop); |
81 |
|
Thurallor-7095 |
end |
82 |
|
Thurallor-7095 |
end |
83 |
|
Thurallor-7095 |
|
84 |
167 |
Thurallor-7095 |
function Slot:SetUseOnRightClick(useOnRightClick) |
85 |
|
Thurallor-7095 |
self.useOnRightClick = useOnRightClick; |
86 |
|
Thurallor-7095 |
if (self.object and self.object.SetUseOnRightClick) then |
87 |
|
Thurallor-7095 |
self.object:SetUseOnRightClick(useOnRightClick); |
88 |
|
Thurallor-7095 |
end |
89 |
|
Thurallor-7095 |
end |
90 |
|
Thurallor-7095 |
|
91 |
13 |
Thurallor-7095 |
function Slot:SetDraggable(draggable) |
92 |
|
Thurallor-7095 |
if (draggable) then |
93 |
|
Thurallor-7095 |
self.numLabel.MouseDown = function(sender, args) |
94 |
|
Thurallor-7095 |
self:MouseDown(args); |
95 |
|
Thurallor-7095 |
end |
96 |
|
Thurallor-7095 |
self.numLabel.MouseUp = function(sender, args) |
97 |
|
Thurallor-7095 |
self:MouseUp(args); |
98 |
|
Thurallor-7095 |
end |
99 |
|
Thurallor-7095 |
self.numLabel.MouseMove = function() |
100 |
|
Thurallor-7095 |
self:MouseMove(); |
101 |
|
Thurallor-7095 |
end |
102 |
|
Thurallor-7095 |
elseif (self.numLabel) then |
103 |
|
Thurallor-7095 |
self.numLabel.MouseDown = nil; |
104 |
|
Thurallor-7095 |
self.numLabel.MouseUp = nil; |
105 |
|
Thurallor-7095 |
self.numLabel.MouseMove = nil; |
106 |
|
Thurallor-7095 |
end |
107 |
|
Thurallor-7095 |
end |
108 |
|
Thurallor-7095 |
|
109 |
|
Thurallor-7095 |
function Slot:SetInfo(info) |
110 |
|
Thurallor-7095 |
|
111 |
|
Thurallor-7095 |
-- Discard old object, if it's a different type |
112 |
|
Thurallor-7095 |
if (self.object and (self.info.class ~= info.class)) then |
113 |
|
Thurallor-7095 |
self.object:SetParent(nil); |
114 |
|
Thurallor-7095 |
self.object = nil; |
115 |
|
Thurallor-7095 |
end |
116 |
|
Thurallor-7095 |
|
117 |
|
Thurallor-7095 |
self.info = {}; |
118 |
|
Thurallor-7095 |
DeepTableCopy(info, self.info); |
119 |
|
Thurallor-7095 |
|
120 |
21 |
Thurallor-7095 |
if (not self.parent) then |
121 |
|
Thurallor-7095 |
return; |
122 |
|
Thurallor-7095 |
end |
123 |
|
Thurallor-7095 |
|
124 |
13 |
Thurallor-7095 |
-- Create the quickslot object or command icon |
125 |
|
Thurallor-7095 |
if ((not info.class) or (info.class == "Turbine.UI.Lotro.Quickslot")) then |
126 |
|
Thurallor-7095 |
if (not self.object) then |
127 |
|
Thurallor-7095 |
local object = Turbine.UI.Lotro.Quickslot(); |
128 |
|
Thurallor-7095 |
object:SetParent(self); |
129 |
15 |
Thurallor-7095 |
object:SetZOrder(1); |
130 |
116 |
Thurallor-7095 |
self.object = object; |
131 |
|
Thurallor-7095 |
|
132 |
|
Thurallor-7095 |
-- Forward events to parent object |
133 |
13 |
Thurallor-7095 |
object.MouseClick = function(sender, args) |
134 |
20 |
Thurallor-7095 |
DoCallbacks(self, "MouseClick", args); |
135 |
13 |
Thurallor-7095 |
end |
136 |
116 |
Thurallor-7095 |
object.MouseWheel = function(sender, args) |
137 |
|
Thurallor-7095 |
DoCallbacks(self, "MouseWheel", args); |
138 |
|
Thurallor-7095 |
end |
139 |
13 |
Thurallor-7095 |
end |
140 |
143 |
Thurallor-7095 |
local shortcut = Turbine.UI.Lotro.Shortcut(info.type, ((type(info.Data) == "string") and info.Data:toWindows()) or info.Data); |
141 |
|
Thurallor-7095 |
self.object:SetShortcut(shortcut); |
142 |
13 |
Thurallor-7095 |
self.isQuickslot = true; |
143 |
151 |
Thurallor-7095 |
self.skillNames = nil; |
144 |
15 |
Thurallor-7095 |
self.object.DragDrop = function(sender) |
145 |
|
Thurallor-7095 |
sender:SetShortcut(Turbine.UI.Lotro.Shortcut(self.info.type, self.info.Data)); |
146 |
|
Thurallor-7095 |
end |
147 |
135 |
Thurallor-7095 |
elseif ((info.class == "Turbine.UI.Control") or (info.class == "Turbine.UI.Lotro.EntityControl")) then |
148 |
13 |
Thurallor-7095 |
if (not self.object) then |
149 |
117 |
Thurallor-7095 |
|
150 |
|
Thurallor-7095 |
local object; |
151 |
136 |
Thurallor-7095 |
if (info.type == "SelectTarget") then |
152 |
135 |
Thurallor-7095 |
object = Turbine.UI.Lotro.EntityControl(); |
153 |
|
Thurallor-7095 |
object:SetSelectionEnabled(true); |
154 |
|
Thurallor-7095 |
object:SetContextMenuEnabled(false); |
155 |
137 |
Thurallor-7095 |
object:SetBackground(resources.Icon.SelectTarget); |
156 |
135 |
Thurallor-7095 |
self.watcher = Thurallor.Utils.Watcher; |
157 |
|
Thurallor-7095 |
self.player = Turbine.Gameplay.LocalPlayer:GetInstance(); |
158 |
|
Thurallor-7095 |
self.getTargetFunc = loadstring(info.getTargetFunc); |
159 |
117 |
Thurallor-7095 |
else |
160 |
135 |
Thurallor-7095 |
-- MouseWheel events aren't implemented for Controls, only ListBoxes. |
161 |
|
Thurallor-7095 |
-- But I think they probably use more resources than Controls, so I'll |
162 |
|
Thurallor-7095 |
-- only use ListBoxes if the mouse wheel option is enabled. |
163 |
|
Thurallor-7095 |
if (self.wantsMouseWheelEvents) then |
164 |
|
Thurallor-7095 |
object = Turbine.UI.ListBox(); |
165 |
|
Thurallor-7095 |
else |
166 |
|
Thurallor-7095 |
object = Turbine.UI.Control(); |
167 |
|
Thurallor-7095 |
end |
168 |
117 |
Thurallor-7095 |
end |
169 |
|
Thurallor-7095 |
|
170 |
13 |
Thurallor-7095 |
object:SetParent(self); |
171 |
|
Thurallor-7095 |
object:SetSize(32, 32); |
172 |
|
Thurallor-7095 |
object:SetPosition(3, 3); |
173 |
15 |
Thurallor-7095 |
object:SetZOrder(1); |
174 |
116 |
Thurallor-7095 |
self.object = object; |
175 |
137 |
Thurallor-7095 |
object.slot = self; |
176 |
116 |
Thurallor-7095 |
|
177 |
|
Thurallor-7095 |
-- Forward events to parent object |
178 |
137 |
Thurallor-7095 |
object.MouseClick = function(obj, args) |
179 |
|
Thurallor-7095 |
if (obj.slot.info.type == "SelectTarget") then |
180 |
135 |
Thurallor-7095 |
-- Update the round-robin "cursor" to the next member, regardless |
181 |
|
Thurallor-7095 |
-- of whether the member was successfully selected; clicking on the |
182 |
|
Thurallor-7095 |
-- slot is enough to know the user's intent. |
183 |
137 |
Thurallor-7095 |
Thurallor.Utils.Watcher.GetNextPartyMember(obj.slot.entity); |
184 |
135 |
Thurallor-7095 |
end |
185 |
137 |
Thurallor-7095 |
DoCallbacks(obj.slot, "MouseClick", args); |
186 |
13 |
Thurallor-7095 |
end |
187 |
137 |
Thurallor-7095 |
object.MouseEnter = function(obj) |
188 |
|
Thurallor-7095 |
if (obj.slot.info.type == "SelectTarget") then |
189 |
|
Thurallor-7095 |
obj.slot:UpdateEntity(); |
190 |
|
Thurallor-7095 |
obj.slot:SetWantsUpdates(true); |
191 |
135 |
Thurallor-7095 |
end |
192 |
137 |
Thurallor-7095 |
DoCallbacks(obj.slot, "MouseEnter"); |
193 |
13 |
Thurallor-7095 |
end |
194 |
137 |
Thurallor-7095 |
object.MouseLeave = function(obj) |
195 |
|
Thurallor-7095 |
if (obj.slot.info.type == "SelectTarget") then |
196 |
|
Thurallor-7095 |
obj:SetBackground(resources.Icon.SelectTarget); |
197 |
|
Thurallor-7095 |
obj:SetEntity(nil); |
198 |
|
Thurallor-7095 |
obj.slot.entity = nil; |
199 |
|
Thurallor-7095 |
obj.slot:SetWantsUpdates(false); |
200 |
136 |
Thurallor-7095 |
end |
201 |
137 |
Thurallor-7095 |
DoCallbacks(obj.slot, "MouseLeave"); |
202 |
13 |
Thurallor-7095 |
end |
203 |
137 |
Thurallor-7095 |
object.MouseWheel = function(obj, args) |
204 |
|
Thurallor-7095 |
DoCallbacks(obj.slot, "MouseWheel", args); |
205 |
116 |
Thurallor-7095 |
end |
206 |
157 |
Thurallor-7095 |
|
207 |
|
Thurallor-7095 |
-- Add tooltip |
208 |
|
Thurallor-7095 |
if (info.type == "SelectTarget") then |
209 |
|
Thurallor-7095 |
self:SetTooltip(function() |
210 |
|
Thurallor-7095 |
local entity = self.object:GetEntity(); |
211 |
|
Thurallor-7095 |
return entity and entity:GetName() or L:GetText("/SequenceEditor/NoTarget"); |
212 |
|
Thurallor-7095 |
end); |
213 |
|
Thurallor-7095 |
end |
214 |
13 |
Thurallor-7095 |
end |
215 |
|
Thurallor-7095 |
self.isQuickslot = false; |
216 |
|
Thurallor-7095 |
end |
217 |
167 |
Thurallor-7095 |
self:SetUseOnRightClick(self.useOnRightClick); |
218 |
15 |
Thurallor-7095 |
|
219 |
34 |
Thurallor-7095 |
-- Draw text overlay and icon overlay (if any) |
220 |
|
Thurallor-7095 |
if (not self.textOverlay) then |
221 |
|
Thurallor-7095 |
local textOverlay = Turbine.UI.Label(); |
222 |
|
Thurallor-7095 |
textOverlay:SetParent(self); |
223 |
|
Thurallor-7095 |
textOverlay:SetZOrder(2); |
224 |
|
Thurallor-7095 |
textOverlay:SetSize(32, 32); |
225 |
|
Thurallor-7095 |
textOverlay:SetPosition(3, 3); |
226 |
|
Thurallor-7095 |
textOverlay:SetMouseVisible(false); |
227 |
|
Thurallor-7095 |
textOverlay:SetFont(Turbine.UI.Lotro.Font.Verdana10); |
228 |
|
Thurallor-7095 |
textOverlay:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleCenter); |
229 |
|
Thurallor-7095 |
textOverlay:SetFontStyle(Turbine.UI.FontStyle.Outline); |
230 |
|
Thurallor-7095 |
textOverlay:SetOutlineColor(Turbine.UI.Color(1, 0, 0, 0)); |
231 |
|
Thurallor-7095 |
textOverlay:SetMultiline(true); |
232 |
|
Thurallor-7095 |
textOverlay:SetMarkupEnabled(true); |
233 |
|
Thurallor-7095 |
textOverlay:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend); |
234 |
|
Thurallor-7095 |
self.textOverlay = textOverlay; |
235 |
13 |
Thurallor-7095 |
end |
236 |
34 |
Thurallor-7095 |
self.background = info.background; |
237 |
|
Thurallor-7095 |
if (info.altIcon) then |
238 |
|
Thurallor-7095 |
self.background = info.altIcon; |
239 |
|
Thurallor-7095 |
end |
240 |
|
Thurallor-7095 |
self.textOverlay:SetBackground(self.background); |
241 |
|
Thurallor-7095 |
self.textOverlay:SetText(info.textOverlay); |
242 |
13 |
Thurallor-7095 |
end |
243 |
|
Thurallor-7095 |
|
244 |
136 |
Thurallor-7095 |
-- For "Select Target" slots only: |
245 |
|
Thurallor-7095 |
function Slot:UpdateEntity() |
246 |
157 |
Thurallor-7095 |
local entity = self.getTargetFunc(Thurallor.Utils.Watcher, self.player, self.info.raidMemberName, self.info.number); |
247 |
136 |
Thurallor-7095 |
if (entity ~= self.entity) then |
248 |
|
Thurallor-7095 |
self.object:SetEntity(entity); |
249 |
|
Thurallor-7095 |
self.entity = entity; |
250 |
157 |
Thurallor-7095 |
self.tooltip:Update(); |
251 |
136 |
Thurallor-7095 |
end |
252 |
|
Thurallor-7095 |
if (entity) then |
253 |
137 |
Thurallor-7095 |
self.object:SetBackground(resources.Icon.SelectTargetKnown); |
254 |
136 |
Thurallor-7095 |
else |
255 |
137 |
Thurallor-7095 |
self.object:SetBackground(resources.Icon.SelectTargetUnknown); |
256 |
136 |
Thurallor-7095 |
end |
257 |
|
Thurallor-7095 |
end |
258 |
|
Thurallor-7095 |
|
259 |
157 |
Thurallor-7095 |
function Slot:SetTooltip(content) |
260 |
|
Thurallor-7095 |
if (self.tooltip) then |
261 |
|
Thurallor-7095 |
self.tooltip:SetVisible(false); |
262 |
|
Thurallor-7095 |
self.tooltip:Detach(); |
263 |
|
Thurallor-7095 |
end |
264 |
|
Thurallor-7095 |
self.tooltip = Thurallor.UI.Tooltip(content); |
265 |
|
Thurallor-7095 |
self.tooltip:Attach(self.object); |
266 |
|
Thurallor-7095 |
end |
267 |
|
Thurallor-7095 |
|
268 |
13 |
Thurallor-7095 |
function Slot:SetNumLabel(slotNumber) |
269 |
|
Thurallor-7095 |
if (not self.numLabel) then |
270 |
|
Thurallor-7095 |
local numLabel = Turbine.UI.Label(); |
271 |
|
Thurallor-7095 |
numLabel:SetParent(self); |
272 |
|
Thurallor-7095 |
numLabel:SetFont(Turbine.UI.Lotro.Font.TrajanPro15); |
273 |
|
Thurallor-7095 |
numLabel:SetFontStyle(Turbine.UI.FontStyle.Outline); |
274 |
|
Thurallor-7095 |
numLabel:SetOutlineColor(Turbine.UI.Color(1, 0, 0, 0)); |
275 |
|
Thurallor-7095 |
numLabel:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleCenter); |
276 |
|
Thurallor-7095 |
numLabel:SetBlendMode(Turbine.UI.BlendMode.AlphaBlend); |
277 |
15 |
Thurallor-7095 |
numLabel:SetSize(38, 38); |
278 |
|
Thurallor-7095 |
numLabel:SetZOrder(3); |
279 |
13 |
Thurallor-7095 |
numLabel.DragDrop = function(sender, args) |
280 |
20 |
Thurallor-7095 |
DoCallbacks(self, "DragDrop", args); |
281 |
13 |
Thurallor-7095 |
end |
282 |
|
Thurallor-7095 |
numLabel.MouseClick = function(sender, args) |
283 |
20 |
Thurallor-7095 |
DoCallbacks(self, "MouseClick", args); |
284 |
13 |
Thurallor-7095 |
end |
285 |
|
Thurallor-7095 |
self.numLabel = numLabel; |
286 |
|
Thurallor-7095 |
end |
287 |
|
Thurallor-7095 |
self.numLabel:SetText(slotNumber); |
288 |
|
Thurallor-7095 |
self.slotNumber = slotNumber; |
289 |
|
Thurallor-7095 |
end |
290 |
|
Thurallor-7095 |
|
291 |
34 |
Thurallor-7095 |
function Slot:StartCooldown(period) |
292 |
|
Thurallor-7095 |
if (period <= 0) then |
293 |
|
Thurallor-7095 |
period = 0.001; |
294 |
|
Thurallor-7095 |
end |
295 |
|
Thurallor-7095 |
self.coolDown = period; |
296 |
|
Thurallor-7095 |
self.resetTime = Turbine.Engine.GetGameTime() + period; |
297 |
43 |
Thurallor-7095 |
if (self.textOverlay) then |
298 |
|
Thurallor-7095 |
self.textOverlay:SetBackground(resources.Icon.Delay); |
299 |
|
Thurallor-7095 |
self.textOverlay:SetText(nil); |
300 |
|
Thurallor-7095 |
end |
301 |
147 |
Thurallor-7095 |
self:ShowTimeRemaining(true); |
302 |
34 |
Thurallor-7095 |
self:SetWantsUpdates(true); |
303 |
|
Thurallor-7095 |
end |
304 |
|
Thurallor-7095 |
|
305 |
|
Thurallor-7095 |
function Slot:Update() |
306 |
136 |
Thurallor-7095 |
if (self.info.type == "SelectTarget") then |
307 |
|
Thurallor-7095 |
self:UpdateEntity(); |
308 |
|
Thurallor-7095 |
else |
309 |
|
Thurallor-7095 |
self:ShowTimeRemaining(); |
310 |
|
Thurallor-7095 |
end |
311 |
34 |
Thurallor-7095 |
end |
312 |
|
Thurallor-7095 |
|
313 |
|
Thurallor-7095 |
-- Reuse the numLabel layer for cooldown overlay. |
314 |
147 |
Thurallor-7095 |
function Slot:ShowTimeRemaining(starting) |
315 |
34 |
Thurallor-7095 |
local currentTime = Turbine.Engine.GetGameTime(); |
316 |
147 |
Thurallor-7095 |
-- Check for abort ("Reset" event handler removed) |
317 |
|
Thurallor-7095 |
if (not starting and not self.Reset) then |
318 |
|
Thurallor-7095 |
self.resetTime = currentTime; |
319 |
|
Thurallor-7095 |
end |
320 |
|
Thurallor-7095 |
|
321 |
34 |
Thurallor-7095 |
if (currentTime >= self.resetTime) then |
322 |
|
Thurallor-7095 |
self.numLabel:SetParent(nil); |
323 |
|
Thurallor-7095 |
self.numLabel = nil; |
324 |
|
Thurallor-7095 |
self.resetTime = nil; |
325 |
|
Thurallor-7095 |
self:SetWantsUpdates(false); |
326 |
43 |
Thurallor-7095 |
if (self.textOverlay) then |
327 |
|
Thurallor-7095 |
self.textOverlay:SetBackground(self.background); |
328 |
|
Thurallor-7095 |
self.textOverlay:SetText(self.info.textOverlay); |
329 |
|
Thurallor-7095 |
end |
330 |
34 |
Thurallor-7095 |
self.hidden = self.hiddenAfterReset; |
331 |
|
Thurallor-7095 |
DoCallbacks(self, "Reset"); |
332 |
|
Thurallor-7095 |
else |
333 |
|
Thurallor-7095 |
self:SetNumLabel(""); |
334 |
|
Thurallor-7095 |
self.numLabel.MouseClick = nil; |
335 |
|
Thurallor-7095 |
self.numLabel:SetPosition(3, 3); |
336 |
|
Thurallor-7095 |
self.numLabel:SetSize(32, 32); |
337 |
|
Thurallor-7095 |
local steps = resources.Icon.CoolDownEnd - resources.Icon.CoolDownStart + 1; |
338 |
|
Thurallor-7095 |
local progress = 1 - (self.resetTime - currentTime) / self.coolDown; |
339 |
|
Thurallor-7095 |
self.numLabel:SetBackground(resources.Icon.CoolDownStart + math.floor(progress * steps)); |
340 |
|
Thurallor-7095 |
end |
341 |
|
Thurallor-7095 |
end |
342 |
|
Thurallor-7095 |
|
343 |
16 |
Thurallor-7095 |
function Slot:SetSelected(selected, color) |
344 |
13 |
Thurallor-7095 |
if (not selected) then |
345 |
|
Thurallor-7095 |
if (self.marquee) then |
346 |
|
Thurallor-7095 |
self.marquee:SetParent(nil); |
347 |
|
Thurallor-7095 |
self.marquee = nil; |
348 |
|
Thurallor-7095 |
end |
349 |
|
Thurallor-7095 |
return; |
350 |
|
Thurallor-7095 |
end |
351 |
|
Thurallor-7095 |
|
352 |
16 |
Thurallor-7095 |
if (not color) then |
353 |
|
Thurallor-7095 |
color = Turbine.UI.Color.White; |
354 |
|
Thurallor-7095 |
end |
355 |
|
Thurallor-7095 |
|
356 |
13 |
Thurallor-7095 |
if (not self.marquee) then |
357 |
|
Thurallor-7095 |
local marquee = Thurallor.UI.Marquee(); |
358 |
|
Thurallor-7095 |
marquee:SetParent(self); |
359 |
|
Thurallor-7095 |
marquee:SetPosition(2, 2); |
360 |
|
Thurallor-7095 |
marquee:SetSize(34, 34); |
361 |
|
Thurallor-7095 |
marquee:SetMouseVisible(false); |
362 |
|
Thurallor-7095 |
self.marquee = marquee; |
363 |
|
Thurallor-7095 |
end |
364 |
16 |
Thurallor-7095 |
|
365 |
|
Thurallor-7095 |
self.marquee:SetColor(color); |
366 |
13 |
Thurallor-7095 |
end |
367 |
|
Thurallor-7095 |
|
368 |
21 |
Thurallor-7095 |
function Slot:SetParent(parent) |
369 |
|
Thurallor-7095 |
self.parent = parent; |
370 |
|
Thurallor-7095 |
if (parent) then |
371 |
|
Thurallor-7095 |
self:SetInfo(self.info); |
372 |
|
Thurallor-7095 |
elseif (self.object) then |
373 |
26 |
Thurallor-7095 |
self:MouseLeave(); |
374 |
21 |
Thurallor-7095 |
self.object:SetParent(nil); |
375 |
|
Thurallor-7095 |
self.object = nil; |
376 |
|
Thurallor-7095 |
end |
377 |
|
Thurallor-7095 |
Turbine.UI.Control.SetParent(self, parent); |
378 |
|
Thurallor-7095 |
end |
379 |
|
Thurallor-7095 |
|
380 |
13 |
Thurallor-7095 |
function Slot:DragDrop(args) |
381 |
|
Thurallor-7095 |
local info = {}; |
382 |
|
Thurallor-7095 |
info.class = "Turbine.UI.Lotro.Quickslot"; |
383 |
15 |
Thurallor-7095 |
local newShortcut = args.DragDropInfo:GetShortcut(); |
384 |
|
Thurallor-7095 |
if (newShortcut) then |
385 |
|
Thurallor-7095 |
info.type = newShortcut:GetType(); |
386 |
|
Thurallor-7095 |
info.Data = newShortcut:GetData(); |
387 |
|
Thurallor-7095 |
self:SetInfo(info); |
388 |
132 |
Thurallor-7095 |
DoCallbacks(self, "ShortcutChanged", info.type, info.Data); |
389 |
15 |
Thurallor-7095 |
end |
390 |
13 |
Thurallor-7095 |
|
391 |
|
Thurallor-7095 |
-- Don't remove the item/skill from the location where it was dragged from. |
392 |
|
Thurallor-7095 |
args.DragDropInfo:SetSuccessful(false); |
393 |
|
Thurallor-7095 |
end |
394 |
|
Thurallor-7095 |
|
395 |
|
Thurallor-7095 |
function Slot:MouseEnter() |
396 |
|
Thurallor-7095 |
if ((self.actionEnabled) and (not self.highlight)) then |
397 |
|
Thurallor-7095 |
local highlight = Turbine.UI.Control(); |
398 |
|
Thurallor-7095 |
highlight:SetParent(self); |
399 |
|
Thurallor-7095 |
highlight:SetSize(32, 32); |
400 |
|
Thurallor-7095 |
highlight:SetPosition(3, 3); |
401 |
15 |
Thurallor-7095 |
highlight:SetZOrder(4); |
402 |
13 |
Thurallor-7095 |
highlight:SetBlendMode(Turbine.UI.BlendMode.Overlay); |
403 |
|
Thurallor-7095 |
highlight:SetBackground(resources.Icon.Highlight); |
404 |
|
Thurallor-7095 |
highlight:SetMouseVisible(false); |
405 |
|
Thurallor-7095 |
self.highlight = highlight; |
406 |
|
Thurallor-7095 |
end |
407 |
|
Thurallor-7095 |
end |
408 |
|
Thurallor-7095 |
|
409 |
|
Thurallor-7095 |
function Slot:MouseLeave() |
410 |
|
Thurallor-7095 |
if (self.highlight) then |
411 |
|
Thurallor-7095 |
self.highlight:SetParent(nil); |
412 |
|
Thurallor-7095 |
self.highlight = nil; |
413 |
|
Thurallor-7095 |
end |
414 |
|
Thurallor-7095 |
end |
415 |
|
Thurallor-7095 |
|
416 |
|
Thurallor-7095 |
function Slot:MouseDown(args) |
417 |
|
Thurallor-7095 |
if (args.Button == Turbine.UI.MouseButton.Left) then |
418 |
|
Thurallor-7095 |
-- Drag begin. Save the current position of the slot and mouse. |
419 |
|
Thurallor-7095 |
self.mouseDown = true; |
420 |
|
Thurallor-7095 |
self.mouseMoved = false; |
421 |
|
Thurallor-7095 |
self.originalLeft, self.originalTop = self:PointToScreen(0, 0); |
422 |
|
Thurallor-7095 |
self.originalMouseX, self.originalMouseY = Turbine.UI.Display.GetMouseX(), Turbine.UI.Display.GetMouseY(); |
423 |
|
Thurallor-7095 |
end |
424 |
|
Thurallor-7095 |
end |
425 |
|
Thurallor-7095 |
|
426 |
|
Thurallor-7095 |
function Slot:MouseMove() |
427 |
|
Thurallor-7095 |
if (not self.mouseDown) then |
428 |
|
Thurallor-7095 |
return; |
429 |
|
Thurallor-7095 |
end |
430 |
|
Thurallor-7095 |
|
431 |
|
Thurallor-7095 |
-- Detach from parent if we haven't already done so. |
432 |
|
Thurallor-7095 |
if (not self.mouseMoved) then |
433 |
|
Thurallor-7095 |
self.numLabel:SetText(nil); |
434 |
|
Thurallor-7095 |
self.parent = self:GetParent(); |
435 |
|
Thurallor-7095 |
self.tempContainer = Turbine.UI.Window(); |
436 |
|
Thurallor-7095 |
self.tempContainer:SetVisible(true); |
437 |
|
Thurallor-7095 |
self.tempContainer:SetSize(self:GetSize()); |
438 |
|
Thurallor-7095 |
self.tempContainer:SetZOrder(2147483647); |
439 |
|
Thurallor-7095 |
self.tempContainer:SetOpacity(0.75); |
440 |
|
Thurallor-7095 |
self:SetParent(self.tempContainer); |
441 |
|
Thurallor-7095 |
self:SetPosition(0, 0); |
442 |
|
Thurallor-7095 |
self.mouseMoved = true; |
443 |
|
Thurallor-7095 |
end |
444 |
|
Thurallor-7095 |
|
445 |
|
Thurallor-7095 |
-- Drag continuing. Find out how much the mouse has moved. |
446 |
|
Thurallor-7095 |
local newMouseX, newMouseY = Turbine.UI.Display.GetMouseX(), Turbine.UI.Display.GetMouseY(); |
447 |
|
Thurallor-7095 |
local deltaX, deltaY = newMouseX - self.originalMouseX, newMouseY - self.originalMouseY; |
448 |
|
Thurallor-7095 |
|
449 |
|
Thurallor-7095 |
-- Move the icon and overlay. |
450 |
|
Thurallor-7095 |
local left, top = self.originalLeft + deltaX, self.originalTop + deltaY; |
451 |
|
Thurallor-7095 |
self.tempContainer:SetPosition(left, top); |
452 |
|
Thurallor-7095 |
|
453 |
|
Thurallor-7095 |
-- Show a red "X" if invalid drag location is selected. |
454 |
|
Thurallor-7095 |
local centerX, centerY = left + 16, top + 16; |
455 |
|
Thurallor-7095 |
if (self:DropPositionValid(centerX, centerY)) then |
456 |
|
Thurallor-7095 |
self.numLabel:SetBackground(nil); |
457 |
|
Thurallor-7095 |
else |
458 |
|
Thurallor-7095 |
self.numLabel:SetBackground(resources.Icon.DragFail); |
459 |
|
Thurallor-7095 |
end |
460 |
|
Thurallor-7095 |
end |
461 |
|
Thurallor-7095 |
|
462 |
|
Thurallor-7095 |
function Slot:MouseUp(args) |
463 |
|
Thurallor-7095 |
if (args.Button ~= Turbine.UI.MouseButton.Left) then |
464 |
|
Thurallor-7095 |
return; |
465 |
|
Thurallor-7095 |
end |
466 |
|
Thurallor-7095 |
self.mouseDown = false; |
467 |
|
Thurallor-7095 |
if (not self.mouseMoved) then |
468 |
|
Thurallor-7095 |
return; |
469 |
|
Thurallor-7095 |
end |
470 |
|
Thurallor-7095 |
|
471 |
|
Thurallor-7095 |
-- Reattach to parent. |
472 |
|
Thurallor-7095 |
local left, top = self.tempContainer:GetPosition(); |
473 |
|
Thurallor-7095 |
self:SetParent(self.parent); |
474 |
|
Thurallor-7095 |
self.tempContainer:Close(); |
475 |
|
Thurallor-7095 |
self.tempContainer = nil; |
476 |
|
Thurallor-7095 |
self.numLabel:SetBackground(nil); |
477 |
|
Thurallor-7095 |
self.numLabel:SetText(self.slotNumber); |
478 |
|
Thurallor-7095 |
|
479 |
|
Thurallor-7095 |
local centerX, centerY = left + 16, top + 16; |
480 |
|
Thurallor-7095 |
self:DragDropComplete(centerX, centerY); |
481 |
|
Thurallor-7095 |
end |
482 |
|
Thurallor-7095 |
|
483 |
|
Thurallor-7095 |
-- Event handlers that should be overridden |
484 |
116 |
Thurallor-7095 |
-- |
485 |
|
Thurallor-7095 |
-- function Slot:ShortcutChanged(shortcutType, shortcutData) |
486 |
|
Thurallor-7095 |
-- Puts("ShortcutChanged(" .. Serialize(shortcutType) .. ", " .. Serialize(shortcutData) .. ")"); |
487 |
|
Thurallor-7095 |
-- end |
488 |
|
Thurallor-7095 |
-- |
489 |
|
Thurallor-7095 |
-- function Slot:MouseClick(args) |
490 |
|
Thurallor-7095 |
-- Puts("MouseClick(" .. Serialize(args) .. ")"); |
491 |
|
Thurallor-7095 |
-- end |
492 |
|
Thurallor-7095 |
-- |
493 |
|
Thurallor-7095 |
-- function Slot:MouseWheel(args) |
494 |
|
Thurallor-7095 |
-- Puts("MouseWheel(" .. Serialize(args) .. ")"); |
495 |
|
Thurallor-7095 |
-- end |
496 |
|
Thurallor-7095 |
-- |
497 |
|
Thurallor-7095 |
-- function Slot:DropPositionValid(left, top) |
498 |
|
Thurallor-7095 |
-- Puts("DropPositionValid(" .. tostring(left) .. ", " .. tostring(top) .. ")"); |
499 |
|
Thurallor-7095 |
-- return true; |
500 |
|
Thurallor-7095 |
-- end |
501 |
|
Thurallor-7095 |
-- |
502 |
|
Thurallor-7095 |
-- function Slot:DragDropComplete(left, top) |
503 |
|
Thurallor-7095 |
-- Puts("DragDropComplete(" .. tostring(left) .. ", " .. tostring(top) .. ")"); |
504 |
|
Thurallor-7095 |
-- return true; |
505 |
|
Thurallor-7095 |
-- end |