vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --$Id: OneView.lua 8341 2006-08-18 03:57:52Z kaelten $
2 OneView = OneCore:NewModule("OneView", "AceEvent-2.0", "AceHook-2.0", "AceDebug-2.0", "AceConsole-2.0", "AceDB-2.0")
3 local L = AceLibrary("AceLocale-2.0"):new("OneView")
4  
5 BINDING_HEADER_ONEVIEW = "OneView"
6  
7 function OneView:OnInitialize()
8 local baseArgs = OneCore:GetFreshOptionsTable(self)
9 local customArgs = {
10 ["0"] = {
11 name = L"Backpack", type = 'toggle', order = 5,
12 desc = L"Turns display of your backpack on and off.",
13 get = function() return self.db.profile.show[0] end,
14 set = function(v)
15 self.db.profile.show[0] = v
16 self:OrganizeFrame(true)
17 end,
18 },
19 ["1"] = {
20 name = L"First Bag", type = 'toggle', order = 6,
21 desc = L"Turns display of your first bag on and off.",
22 get = function() return self.db.profile.show[1] end,
23 set = function(v)
24 self.db.profile.show[1] = v
25 self:OrganizeFrame(true)
26 end,
27 },
28 ["2"] = {
29 name = L"Second Bag", type = 'toggle', order = 7,
30 desc = L"Turns display of your second bag on and off.",
31 get = function() return self.db.profile.show[2] end,
32 set = function(v)
33 self.db.profile.show[2] = v
34 self:OrganizeFrame(true)
35 end,
36 },
37 ["3"] = {
38 name = L"Third Bag", type = 'toggle', order = 8,
39 desc = L"Turns display of your third bag on and off.",
40 get = function() return self.db.profile.show[3] end,
41 set = function(v)
42 self.db.profile.show[3] = v
43 self:OrganizeFrame(true)
44 end,
45 },
46 ["4"] = {
47 name = L"Fourth Bag", type = 'toggle', order = 9,
48 desc = L"Turns display of your fourth bag on and off.",
49 get = function() return self.db.profile.show[4] end,
50 set = function(v)
51 self.db.profile.show[4] = v
52 self:OrganizeFrame(true)
53 end,
54 },
55 ["5"] = {
56 name = L"First Bank Bag", type = 'toggle', order = 10,
57 desc = L"Turns display of your first bag on and off.",
58 get = function() return self.db.profile.show[5] end,
59 set = function(v)
60 self.db.profile.show[5] = v
61 self:OrganizeFrame(true)
62 end,
63 },
64 ["6"] = {
65 name = L"Second Bank Bag", type = 'toggle', order = 11,
66 desc = L"Turns display of your second bag on and off.",
67 get = function() return self.db.profile.show[6] end,
68 set = function(v)
69 self.db.profile.show[6] = v
70 self:OrganizeFrame(true)
71 end,
72 },
73 ["7"] = {
74 name = L"Third Bank Bag", type = 'toggle', order = 12,
75 desc = L"Turns display of your third bag on and off.",
76 get = function() return self.db.profile.show[7] end,
77 set = function(v)
78 self.db.profile.show[7] = v
79 self:OrganizeFrame(true)
80 end,
81 },
82 ["8"] = {
83 name = L"Fourth Bank Bag", type = 'toggle', order = 13,
84 desc = L"Turns display of your fourth bag on and off.",
85 get = function() return self.db.profile.show[8] end,
86 set = function(v)
87 self.db.profile.show[8] = v
88 self:OrganizeFrame(true)
89 end,
90 },
91 ["9"] = {
92 name = L"Fifth Bank Bag", type = 'toggle', order = 14,
93 desc = L"Turns display of your fifth bag on and off.",
94 get = function() return self.db.profile.show[9] end,
95 set = function(v)
96 self.db.profile.show[9] = v
97 self:OrganizeFrame(true)
98 end,
99 },
100 ["10"] = {
101 name = L"Sixth Bank Bag", type = 'toggle', order = 15,
102 desc = L"Turns display of your sixth bag on and off.",
103 get = function() return self.db.profile.show[10] end,
104 set = function(v)
105 self.db.profile.show[10] = v
106 self:OrganizeFrame(true)
107 end,
108 },
109 }
110  
111 OneCore:CopyTable(customArgs, baseArgs.args.show.args)
112  
113  
114 baseArgs.args.remember = {
115 cmdName = L"Remember", guiName = L"Remember Selection", type = 'toggle',
116 desc = L"Toggles wether to remember which was the last character you selected.",
117 get = function() return self.db.profile.remember end,
118 set = function(v)
119 self.db.profile.remember = v
120 if v then
121 self.db.account.faction = self.faction
122 self.db.account.characterId = self.charId
123 else
124 self.db.account.faction = nil
125 self.db.account.characterId = nil
126 end
127 end,
128 }
129  
130  
131 self:RegisterDB("OneViewDB")
132 self:RegisterDefaults('profile', OneCore.defaults)
133 self:RegisterChatCommand({"/ov", "/OneView"}, baseArgs, string.upper(self.title))
134 self:RegisterChatCommand({"/ovs", "/ovshow"}, {type="execute", func= function()
135 if OneViewFrame:IsVisible() then
136 OneViewFrame:Hide()
137 else
138 OneViewFrame:Show()
139 end
140 end})
141  
142 --self:SetDebugging(true)
143  
144 self.fBags = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
145  
146 self.frame = OneViewFrame
147 self.frame.bags = {}
148 self.frame.handler = self
149  
150 self.storage = OneStorage
151  
152 self:TriggerEvent("OneView_Loaded")
153  
154 self:RegisterDewdrop(baseArgs)
155 end
156  
157 function OneView:OnEnable()
158 self.frame:SetClampedToScreen(true)
159 self:BuildCharSelectOptions()
160 end
161  
162 function OneView:BuildFrame()
163 debugprofilestart()
164  
165 if not self.frame.bags[-1] then
166 self.frame.bags[-1] = CreateFrame("Frame", "OVBankBag", self.frame)
167 self.frame.bags[-1]:SetID(-1)
168 self.frame.bags[-1].size = 24
169 for slot = 1, 24 do
170 self.frame.bags[-1][slot] = CreateFrame("Button", self.frame.bags[-1]:GetName().."Item"..slot, self.frame.bags[-1], "OneViewItemButtonTemplate")
171 self.frame.bags[-1][slot]:SetID(slot)
172 end
173 end
174  
175  
176 for bag = 0, 10 do
177 local itemId, size, isAmmo, isSoul, isProf = self.storage:BagInfo(self.faction, self.charId, bag)
178 for slot = 1, (tonumber(size) or 0) do
179 if not self.frame.bags[bag] then
180 self.frame.bags[bag] = CreateFrame("Frame", tostring(self)..bag, self.frame)
181 self.frame.bags[bag]:SetID(bag)
182 end
183 if not self.frame.bags[bag][slot] then
184 self.frame.bags[bag][slot] = CreateFrame("Button", tostring(self)..bag.."Item"..slot, self.frame.bags[bag], "OneViewItemButtonTemplate")
185 self.frame.bags[bag][slot]:SetID(slot)
186 end
187 end
188 if self.frame.bags[bag] then
189 local curBag = self.frame.bags[bag]
190 curBag.itemId, curBag.size, curBag.isAmmo, curBag.isSoul, curBag.isProf = itemId, size or 0, isAmmo, isSoul, isProf
191 end
192 end
193 self:Debug("%s ran in %s", "BuildFrame", debugprofilestop())
194 end
195  
196  
197 function OneView:OrganizeFrame(needs)
198 debugprofilestart()
199  
200 local cols, curCol, curRow = self.db.profile.cols, 1, 1
201 local lastslot
202 self.bankSoulSlots, self.bankAmmoSlots, self.bankProfSlots, self.bankSlotCount, self.bankTotalCount = 0, 0, 0, 0, 0
203 self.invSoulSlots, self.invAmmoSlots, self.invProfSlots, self.invSlotCount, self.invTotalCount = 0, 0, 0, 0, 0
204  
205 for bag = -1, 10 do
206 if self.frame.bags[bag] then
207 for k2, v2 in ipairs(self.frame.bags[bag]) do
208 v2:Hide()
209 end
210 end
211 local curBag = getglobal("OneViewFrameBag" .. bag)
212 if curBag and not self.db.profile.show.bank and bag > 4 then
213 curBag:Hide()
214 elseif curBag and not self.db.profile.show.inventory and bag < 5 and bag > 0 then
215 curBag:Hide()
216 elseif curBag then
217 curBag:Show()
218 end
219 end
220  
221  
222 for k, bag in {-1, 5, 6, 7, 8, 9, 10} do
223 local curBag = self.frame.bags[bag]
224 if curBag and curBag.size and curBag.size > 0 then
225 if curBag.isAmmo then
226 self.bankAmmoSlots = self.bankAmmoSlots + curBag.size
227 elseif curBag.isSoul then
228 self.bankSoulSlots = self.bankSoulSlots + curBag.size
229 elseif curBag.isProf then
230 self.bankProfSlots = self.bankProfSlots + curBag.size
231 else
232 self.bankSlotCount = self.bankSlotCount + curBag.size
233 end
234 if self.db.profile.show.bank then
235 if self:ShouldShow(bag, curBag.isAmmo, curBag.isSoul, curBag.isProf) then
236 self.bankTotalCount = self.bankTotalCount + curBag.size
237 for slot = 1, curBag.size do
238 curBag[slot]:ClearAllPoints()
239 curBag[slot]:SetPoint("TOPLEFT", self.frame:GetName(), "TOPLEFT", self.leftBorder + (self.colWidth * (curCol - 1)) , 0 - self.topBorder - (self.rowHeight * curRow))
240 curBag[slot]:Show()
241 if curCol == 1 then lastslot = curBag[slot] end
242 curCol = curCol + 1
243 if curCol > cols then curCol, curRow = 1, curRow + 1 end
244 end
245 end
246 else
247 curRow = curRow + .1
248 end
249 end
250 end
251  
252 OneViewFrameBankInfo1:ClearAllPoints()
253 if self.db.profile.show.bagslots and lastslot then
254 OneViewFrameBag5:ClearAllPoints()
255 OneViewFrameBag5:SetPoint("TOPLEFT", lastslot, "BOTTOMLEFT", 0, -10)
256 OneViewFrameBankInfo1:SetPoint("TOPLEFT", OneViewFrameBag5, "BOTTOMLEFT", 0, -10)
257 for i = 5, 10 do
258 getglobal("OneViewFrameBag" .. i):Show()
259 end
260 elseif lastslot then
261 for i = 5, 10 do
262 getglobal("OneViewFrameBag" .. i):Hide()
263 end
264 curRow = curRow - 1
265 OneViewFrameBankInfo1:SetPoint("TOPLEFT", lastslot, "BOTTOMLEFT", 0, -10)
266 else
267 for i = 5, 10 do
268 getglobal("OneViewFrameBag" .. i):Hide()
269 end
270 curRow = curRow - 1
271 OneViewFrameBankInfo1:SetPoint("TOPLEFT", OneViewFrameBankButton, "BOTTOMLEFT", 5, -10)
272 end
273  
274 lastslot = nil
275 curCol = 1
276 curRow = curRow + (self.db.profile.show.bank and 3.5 or 2)
277  
278  
279  
280 for bag = 0, 4 do
281 local curBag = self.frame.bags[bag]
282 if curBag and curBag.size and curBag.size > 0 then
283 if curBag.isAmmo then
284 self.invAmmoSlots = self.invAmmoSlots + curBag.size
285 elseif curBag.isSoul then
286 self.invSoulSlots = self.invSoulSlots + curBag.size
287 elseif curBag.isProf then
288 self.invProfSlots = self.invProfSlots + curBag.size
289 else
290 self.invSlotCount = self.invSlotCount + curBag.size
291 end
292 if self.db.profile.show.inventory then
293 if self:ShouldShow(bag, curBag.isAmmo, curBag.isSoul, curBag.isProf) then
294 self.invTotalCount = self.invTotalCount + curBag.size
295 for slot = 1, curBag.size do
296 curBag[slot]:ClearAllPoints()
297 curBag[slot]:SetPoint("TOPLEFT", self.frame:GetName(), "TOPLEFT", self.leftBorder + (self.colWidth * (curCol - 1)) , 0 - self.topBorder - (self.rowHeight * curRow))
298 curBag[slot]:Show()
299 if curCol == 1 then lastslot = curBag[slot] end
300 curCol = curCol + 1
301 if curCol > cols then curCol, curRow = 1, curRow + 1 end
302 end
303 end
304 local invButton = getglobal(self.frame:GetName() .. "InventoryButton")
305 invButton:ClearAllPoints()
306 invButton:SetPoint("BOTTOMLEFT", self.frame.bags[0][1]:GetName(), "TOPLEFT", -5, 0)
307 else
308 local invButton = getglobal(self.frame:GetName() .. "InventoryButton")
309 invButton:ClearAllPoints()
310 invButton:SetPoint("BOTTOMLEFT", self.frame:GetName(), "BOTTOMLEFT", 3, 24)
311 end
312 end
313 end
314  
315 OneViewFrameInventoryInfo1:ClearAllPoints()
316 if self.db.profile.show.bagslots and lastslot then
317 curRow = curRow + 1
318 OneViewFrameBag1:ClearAllPoints()
319 OneViewFrameBag1:SetPoint("TOPLEFT", lastslot, "BOTTOMLEFT", 0, -10)
320 OneViewFrameInventoryInfo1:SetPoint("TOPLEFT", OneViewFrameBag1, "BOTTOMLEFT", 0, -5)
321 for i = 1, 4 do
322 getglobal("OneViewFrameBag" .. i):Show()
323 end
324 elseif lastslot then
325 for i = 1, 4 do
326 getglobal("OneViewFrameBag" .. i):Hide()
327 end
328 OneViewFrameInventoryInfo1:SetPoint("TOPLEFT", lastslot, "BOTTOMLEFT", 0, -5)
329 else
330 for i = 1, 4 do
331 getglobal("OneViewFrameBag" .. i):Hide()
332 end
333 OneViewFrameInventoryInfo1:SetPoint("TOPLEFT", OneViewFrameInventoryButton, "BOTTOMLEFT", 5, -4)
334 end
335  
336  
337 self:Debug("CurrentRow: %s", curRow)
338  
339 if math.mod(self.invTotalCount, cols) ~= 0 then curRow = curRow + 1 end
340 self.frame:SetHeight(curRow * self.rowHeight + self.bottomBorder + self.topBorder)
341 self.frame:SetWidth(cols * self.colWidth + self.leftBorder + self.rightBorder)
342  
343 self:Debug("%s ran in %s", "OrganizeFrame", debugprofilestop())
344  
345 OneViewFrameInventoryName:ClearAllPoints()
346 OneViewFrameInventoryName:SetPoint("LEFT", OneViewFrameInventoryButton, "RIGHT", 5, 1)
347  
348 OneViewFrameBankName:ClearAllPoints()
349 OneViewFrameBankName:SetPoint("LEFT", OneViewFrameBankButton, "RIGHT", 5, 1)
350  
351 OneViewFrameBankName:SetText(format(L"%s's Bank Bags", self.charId or ""))
352 OneViewFrameInventoryName:SetText(format(L"%s's Bags", self.charId or ""))
353  
354 end
355  
356 function OneView:FillBags()
357 for bag = -1, 10 do
358 local curBag = self.frame.bags[bag]
359 if curBag and curBag.size and curBag.size > 0 then
360 for slot = 1, curBag.size do
361 local itemId, qty = self.storage:SlotInfo(self.faction, self.charId, bag, slot)
362 if itemId then
363 local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemEquipLoc, itemTexture = GetItemInfo(itemId)
364 getglobal(curBag[slot]:GetName() .. "IconTexture"):SetTexture(itemTexture)
365 getglobal(curBag[slot]:GetName() .. "IconTexture"):Show()
366 if qty > 1 then
367 getglobal(curBag[slot]:GetName() .. "Count"):SetText(qty)
368 getglobal(curBag[slot]:GetName() .. "Count"):Show()
369 else
370 getglobal(curBag[slot]:GetName() .. "Count"):SetText("")
371 getglobal(curBag[slot]:GetName() .. "Count"):Hide()
372 end
373 curBag[slot].itemId = itemId
374 curBag[slot].itemQuality = itemQuality
375 curBag[slot].qty = qty
376 else
377 getglobal(curBag[slot]:GetName() .. "IconTexture"):Hide()
378 getglobal(curBag[slot]:GetName() .. "Count"):Hide()
379 curBag[slot].itemId = nil
380 curBag[slot].itemQuality = nil
381 curBag[slot].qty = nil
382 end
383 self:SetBorderColor(curBag[slot])
384 end
385 end
386 local bagSlot = getglobal("OneViewFrameBag" .. bag)
387 if bagSlot then
388 local itemId = self.storage:BagInfo(self.faction, self.charId, bag)
389 if itemId then
390 local itemName, itemLink, itemQuality, itemLevel, itemType, itemSubType, itemCount, itemEquipLoc, itemTexture = GetItemInfo(itemId)
391 getglobal(bagSlot:GetName() .. "IconTexture"):SetTexture(itemTexture)
392 getglobal(bagSlot:GetName() .. "IconTexture"):Show()
393 bagSlot.itemId = itemId
394 else
395 getglobal(bagSlot:GetName() .. "IconTexture"):Hide()
396 bagSlot.itemId = nil
397 end
398 end
399 end
400  
401 MoneyFrame_Update(self.frame:GetName().."MoneyFrame", self.storage:GetMoney(self.faction, self.charId) or 0)
402  
403 self:DoBankSlotCounts()
404 self:DoInventorySlotCounts()
405 end
406  
407 function OneView:SetBorderColor(slot)
408 local color = {r = 1, g = 1, b = 1}
409  
410 local bag = slot:GetParent()
411 local special = false
412  
413 if bag.isAmmo then
414 color = self.db.profile.colors.ammo
415 special = true
416 elseif bag.isSoul then
417 color = self.db.profile.colors.soul
418 special = true
419 elseif bag.isProf then
420 color = self.db.profile.colors.prof
421 special = true
422 elseif self.db.profile.colors.rarity and slot.itemQuality then
423 color = ITEM_QUALITY_COLORS[slot.itemQuality]
424  
425 if slot.itemQuality > 1 then
426 special = true
427 end
428 end
429  
430 if special and self.db.profile.colors.glow then
431 slot:SetNormalTexture("Interface\\Buttons\\UI-ActionButton-Border")
432 slot:GetNormalTexture():SetBlendMode("ADD")
433 slot:GetNormalTexture():SetAlpha(.8)
434 slot:GetNormalTexture():SetPoint("CENTER", slot:GetName(), "CENTER", 0, 1)
435 elseif special then
436 slot:SetNormalTexture("Interface\\AddOns\\OneBag\\BagSlot2")
437 slot:GetNormalTexture():SetBlendMode("BLEND")
438 slot:GetNormalTexture():SetPoint("CENTER", slot:GetName(), "CENTER", 0, 0)
439 else
440 slot:SetNormalTexture("Interface\\AddOns\\OneBag\\BagSlot")
441 slot:GetNormalTexture():SetBlendMode("BLEND")
442 slot:GetNormalTexture():SetPoint("CENTER", slot:GetName(), "CENTER", 0, 0)
443 end
444 slot:GetNormalTexture():SetVertexColor(color.r, color.g, color.b)
445 end
446  
447 function OneView:DoBankSlotCounts()
448 local usedSlots, usedAmmoSlots, usedSoulSlots, usedProfSlots, ammoQuantity = 0, 0, 0, 0, 0
449  
450 for k, bag in {-1, 5, 6, 7, 8, 9, 10} do
451 if self.frame.bags[bag] then
452 local tmp, qty = 0, 0
453 for slot = 1, self.frame.bags[bag].size do
454 if(self.frame.bags[bag][slot].itemId) then
455 tmp = tmp + 1
456 qty = qty + self.frame.bags[bag][slot].qty
457 end
458 end
459  
460 if self.frame.bags[bag].isAmmo then
461 usedAmmoSlots = usedAmmoSlots + tmp
462 ammoQuantity = ammoQuantity + qty
463 elseif self.frame.bags[bag].isSoul then
464 usedSoulSlots = usedSoulSlots + tmp
465 elseif self.frame.bags[bag].isProf then
466 usedProfSlots = usedProfSlots + tmp
467 else
468 usedSlots = usedSlots + tmp
469 end
470 end
471 end
472  
473 self:Debug("Normal used: %s, Soul used: %s, Prof used: %s, Ammo used %s, Ammo quantity %s.", usedSlots, usedSoulSlots, usedProfSlots, usedAmmoSlots, ammoQuantity)
474  
475 local info = 1
476 local name = self.frame:GetName() .. "BankInfo"
477  
478  
479 getglobal(name .. info):SetText(format(L"%s/%s Slots", usedSlots, self.bankSlotCount))
480 info = info + 1
481  
482 for i = 2, 4 do
483 getglobal(name .. i):SetText("")
484 end
485  
486 if self.db.profile.show.counts then
487 if self.bankAmmoSlots > 0 then
488 getglobal(name .. info):SetText(format(L"%s/%s Ammo", ammoQuantity, self.bankAmmoSlots * 200))
489 info = info + 1
490 end
491 if self.bankSoulSlots > 0 then
492 getglobal(name .. info):SetText(format(L"%s/%s Soul Shards", usedSoulSlots, self.bankSoulSlots))
493 info = info + 1
494 end
495 if self.bankProfSlots > 0 then
496 getglobal(name .. info):SetText(format(L"%s/%s Profession Slots", usedProfSlots, self.bankProfSlots))
497 info = info + 1
498 end
499 end
500 end
501  
502 function OneView:DoInventorySlotCounts()
503 local usedSlots, usedAmmoSlots, usedSoulSlots, usedProfSlots, ammoQuantity = 0, 0, 0, 0, 0
504  
505 for bag = 0, 4 do
506 if self.frame.bags[bag] then
507 local tmp, qty = 0, 0
508 for slot = 1, self.frame.bags[bag].size do
509 if(self.frame.bags[bag][slot].itemId) then
510 tmp = tmp + 1
511 qty = qty + self.frame.bags[bag][slot].qty
512 end
513 end
514  
515 if self.frame.bags[bag].isAmmo then
516 usedAmmoSlots = usedAmmoSlots + tmp
517 ammoQuantity = ammoQuantity + qty
518 elseif self.frame.bags[bag].isSoul then
519 usedSoulSlots = usedSoulSlots + tmp
520 elseif self.frame.bags[bag].isProf then
521 usedProfSlots = usedProfSlots + tmp
522 else
523 usedSlots = usedSlots + tmp
524 end
525 end
526 end
527  
528 self:Debug("Normal used: %s, Soul used: %s, Prof used: %s, Ammo used %s, Ammo quantity %s.", usedSlots, usedSoulSlots, usedProfSlots, usedAmmoSlots, ammoQuantity)
529  
530 local info = 1
531 local name = self.frame:GetName() .. "InventoryInfo"
532  
533  
534 getglobal(name .. info):SetText(format(L"%s/%s Slots", usedSlots, self.invSlotCount))
535 info = info + 1
536  
537 for i = 2, 4 do
538 getglobal(name .. i):SetText("")
539 end
540 if self.db.profile.show.counts then
541 if self.invAmmoSlots > 0 then
542 getglobal(name .. info):SetText(format(L"%s/%s Ammo", ammoQuantity, self.invAmmoSlots * 200))
543 info = info + 1
544 end
545 if self.invSoulSlots > 0 then
546 getglobal(name .. info):SetText(format(L"%s/%s Soul Shards", usedSoulSlots, self.invSoulSlots))
547 info = info + 1
548 end
549 if self.invProfSlots > 0 then
550 getglobal(name .. info):SetText(format(L"%s/%s Profession Slots", usedProfSlots, self.invProfSlots))
551 info = info + 1
552 end
553 end
554 end
555  
556 function OneView:BuildCharSelectOptions()
557 local list = self.storage:GetCharListByServerId()
558  
559 local args = {
560 type="group",
561 args = {},
562 }
563  
564 for serverId, v in list do
565 local _, _, server, faction = string.find(serverId, "(.+) . (.+)")
566 while string.find(server, "(.+) (.+)") do
567 local _, _, p1, p2 = string.find(server, "(.+) (.+)")
568  
569 server = p1..p2
570 end
571  
572 print(server)
573  
574 args.args[server..faction] = {
575 name = serverId, type = 'group',
576 desc = L"Characters on "..serverId,
577 args = {}
578 }
579 for k, v2 in v do
580 local fact = faction
581 local _, _, charName, charId = string.find(v2, "(.+) . (.+)")
582 local func = function() self:LoadCharacter(fact, charId) end
583 args.args[server..faction].args[charName] = {
584 name = charName, type = 'execute',
585 func = func, desc = charName,
586 }
587 end
588 end
589  
590 self.dewdrop:Register(OneViewFrameCharSelectButton,
591 'children', args,
592 'point', function(parent)
593 if parent:GetTop() < GetScreenHeight() / 2 then
594 return "BOTTOMLEFT", "TOPLEFT"
595 else
596 return "TOPLEFT", "BOTTOMLEFT"
597 end
598 end,
599 'dontHook', true
600 )
601  
602 end
603  
604 function OneView:CharSelect()
605 if self.dewdrop:IsOpen(getglobal(self.frame:GetName() .. "CharSelectButton")) then
606 self.dewdrop:Close()
607 else
608 self.dewdrop:Open(getglobal(self.frame:GetName() .. "CharSelectButton"), OneViewFrameCharSelectButton)
609 end
610 end
611  
612 function OneView:LoadCharacter(faction, characterId)
613 faction = faction or self.db.account.faction or AceLibrary("AceDB-2.0").FACTION
614 characterId = characterId or self.db.account.characterId or AceLibrary("AceDB-2.0").CHAR_ID
615  
616 if self.db.profile.remember then
617 self.db.account.faction = faction
618 self.db.account.characterId = characterId
619 end
620  
621 self.faction = faction
622 self.charId = characterId
623  
624 self:BuildFrame()
625 self:OrganizeFrame()
626 self:FillBags()
627 end
628  
629 function OneView:LinkItem(itemId)
630 local name, link, quality = GetItemInfo(itemId)
631 if ( ChatFrameEditBox:IsShown() ) then
632 ChatFrameEditBox:Insert(format("%s|H%s|h[%s]|h|r", ITEM_QUALITY_COLORS[quality].hex, link, name))
633 end
634 end
635  
636 function OneView:OnCustomShow()
637 if self.db.profile.point then
638 local point = self.db.profile.point
639 this:ClearAllPoints()
640 this:SetPoint("TOPLEFT", point.parent, "BOTTOMLEFT", point.left, point.top)
641 end
642 end