forked from shagu/pfQuest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpfBrowser.lua
763 lines (633 loc) · 23.6 KB
/
pfBrowser.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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
-- default config
pfDatabase_fav = { ["spawn"] = {}, ["item"] = {}, ["quest"] = {} }
local search_limit = 100
-- add database shortcuts
local items = pfDatabase["items"]
local quests = pfDatabase["quests"]
local vendors = pfDatabase["vendors"]
local spawns = pfDatabase["spawns"]
local function SelectView(view)
for id, frame in pairs(pfBrowser.tabs) do
frame:Hide()
end
view:Show()
end
local function RefreshView(i, key, caption)
pfBrowser.tabs[key].list:SetHeight( i * 30 )
pfBrowser.tabs[key].list:GetParent():SetScrollChild(pfBrowser.tabs[key].list)
pfBrowser.tabs[key].list:GetParent():SetVerticalScroll(0)
pfBrowser.tabs[key].list:GetParent():UpdateScrollState()
pfBrowser.tabs[key].button:SetText(caption .. " " .. "|cffaaaaaa(" .. ((i == search_limit) and "..." or i) .. ")")
for j=i+1,search_limit do
if pfBrowser.tabs[key].buttons[j] then pfBrowser.tabs[key].buttons[j]:Hide() end
end
end
local function CreateBrowseWindow(fname, name, parent, anchor, x, y)
if not parent.tabs then parent.tabs = {} end
parent.tabs[fname] = pfUI.api.CreateScrollFrame(name, parent)
parent.tabs[fname]:SetPoint("TOPLEFT", parent, "TOPLEFT", 10, -65)
parent.tabs[fname]:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", -10, 45)
parent.tabs[fname].buttons = { }
parent.tabs[fname].backdrop = CreateFrame("Frame", name .. "Backdrop", parent.tabs[fname])
parent.tabs[fname].backdrop:SetFrameLevel(1)
parent.tabs[fname].backdrop:SetPoint("TOPLEFT", parent.tabs[fname], "TOPLEFT", -5, 5)
parent.tabs[fname].backdrop:SetPoint("BOTTOMRIGHT", parent.tabs[fname], "BOTTOMRIGHT", 5, -5)
pfUI.api.CreateBackdrop(parent.tabs[fname].backdrop, nil, true)
parent.tabs[fname].button = CreateFrame("Button", name .. "Button", parent)
parent.tabs[fname].button:SetPoint(anchor, x, y)
parent.tabs[fname].button:SetWidth(207)
parent.tabs[fname].button:SetHeight(30)
parent.tabs[fname].button:SetScript("OnClick", function()
SelectView(parent.tabs[fname])
end)
parent.tabs[fname].button.text = parent.tabs[fname].button:CreateFontString("Caption", "LOW", "GameFontWhite")
parent.tabs[fname].button.text:SetAllPoints(parent.tabs[fname].button)
parent.tabs[fname].button.text:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE")
pfUI.api.SkinButton(parent.tabs[fname].button)
parent.tabs[fname].list = pfUI.api.CreateScrollChild(name .. "Scroll", parent.tabs[fname])
parent.tabs[fname].list:SetWidth(600)
end
local function CreateSpawnEntry(i)
local f = CreateFrame("Button", nil, pfBrowser.tabs.spawn.list)
f:SetPoint("TOPLEFT", pfBrowser.tabs.spawn.list, "TOPLEFT", 10, -i*30 + 5)
f:SetPoint("BOTTOMRIGHT", pfBrowser.tabs.spawn.list, "TOPRIGHT", 10, -i*30 - 15)
f.tex = f:CreateTexture("BACKGROUND")
f.tex:SetAllPoints(f)
if math.mod(i,2) == 1 then
f.tex:SetTexture(1,1,1,.02)
else
f.tex:SetTexture(1,1,1,.04)
end
f:SetScript("OnEnter", function()
this.tex:SetTexture(1,1,1,.1)
local name = this.name
local maps = { }
GameTooltip:SetOwner(this.text, "ANCHOR_LEFT", -10, -5)
GameTooltip:SetText("Located in", .3, 1, .8)
if spawns[name] and spawns[name]["coords"] then
for id, data in pairs(spawns[name]["coords"]) do
local f, t, x, y, zone = strfind(data, "(.*),(.*),(.*)")
maps[zone] = maps[zone] and maps[zone] + 1 or 1
end
else
GameTooltip:AddLine(UNKNOWN, 1,.5,.5)
end
for zone, count in pairs(maps) do
GameTooltip:AddDoubleLine(( zone and pfMap:GetMapNameByID(zone) or UNKNOWN), count .. "x", 1,1,1, .5,.5,.5)
end
GameTooltip:Show()
end)
f:SetScript("OnLeave", function()
if math.mod(i,2) == 1 then
this.tex:SetTexture(1,1,1,.02)
else
this.tex:SetTexture(1,1,1,.04)
end
GameTooltip:Hide()
end)
f:SetScript("OnClick", function()
local map = pfDatabase:SearchMob(this.name)
pfMap:UpdateNodes()
pfMap:ShowMapID(map)
end)
f.text = f:CreateFontString("Caption", "LOW", "GameFontWhite")
f.text:SetPoint("CENTER", 0, 0)
f.text:SetJustifyH("CENTER")
f.factionA = f:CreateTexture("OVERLAY")
f.factionA:SetTexture("Interface\\AddOns\\pfQuest\\img\\icon_alliance")
f.factionA:SetWidth(16)
f.factionA:SetHeight(16)
f.factionA:SetPoint("RIGHT", -5, 0)
f.factionH = f:CreateTexture("OVERLAY")
f.factionH:SetTexture("Interface\\AddOns\\pfQuest\\img\\icon_horde")
f.factionH:SetWidth(16)
f.factionH:SetHeight(16)
f.factionH:SetPoint("RIGHT", -24, 0)
f.fav = CreateFrame("Button", nil, f)
f.fav:SetHitRectInsets(-3,-3,-3,-3)
f.fav:SetPoint("LEFT", 0, 0)
f.fav:SetWidth(16)
f.fav:SetHeight(16)
f.fav.icon = f.fav:CreateTexture("OVERLAY")
f.fav.icon:SetTexture("Interface\\AddOns\\pfQuest\\img\\fav")
f.fav.icon:SetAllPoints(f.fav)
f.fav:SetScript("OnClick", function()
local name = this:GetParent().name
if pfDatabase_fav["spawn"][name] then
pfDatabase_fav["spawn"][name] = nil
this.icon:SetVertexColor(1,1,1,.1)
else
pfDatabase_fav["spawn"][name] = true
this.icon:SetVertexColor(1,1,1,1)
end
end)
return f
end
local function CreateItemEntry(i)
local f = CreateFrame("Button", nil, pfBrowser.tabs.item.list)
f:SetPoint("TOPLEFT", pfBrowser.tabs.item.list, "TOPLEFT", 10, -i*30 + 5)
f:SetPoint("BOTTOMRIGHT", pfBrowser.tabs.item.list, "TOPRIGHT", 10, -i*30 - 15)
f.tex = f:CreateTexture("BACKGROUND")
f.tex:SetAllPoints(f)
if math.mod(i,2) == 1 then
f.tex:SetTexture(1,1,1,.02)
else
f.tex:SetTexture(1,1,1,.04)
end
f:SetScript("OnEnter", function()
this.tex:SetTexture(1,1,1,.1)
GameTooltip:SetOwner(this.text, "ANCHOR_LEFT", -10, -5)
GameTooltip:SetHyperlink("item:" .. this.itemID .. ":0:0:0")
GameTooltip:Show()
end)
f:SetScript("OnLeave", function()
if math.mod(i,2) == 1 then
this.tex:SetTexture(1,1,1,.02)
else
this.tex:SetTexture(1,1,1,.04)
end
--this.text:SetTextColor(1,1,1,1)
GameTooltip:Hide()
end)
f:SetScript("OnClick", function()
local link = "item:"..this.itemID..":0:0:0"
local text = ( this.itemColor or "|cffffffff" ) .."|H" .. link .. "|h["..this.itemName.."]|h|r"
SetItemRef(link, text, arg1)
end)
f.text = f:CreateFontString("Caption", "LOW", "GameFontWhite")
f.text:SetPoint("CENTER", 0, 0)
f.text:SetJustifyH("CENTER")
f.fav = CreateFrame("Button", nil, f)
f.fav:SetHitRectInsets(-3,-3,-3,-3)
f.fav:SetPoint("LEFT", 0, 0)
f.fav:SetWidth(16)
f.fav:SetHeight(16)
f.fav.icon = f.fav:CreateTexture("OVERLAY")
f.fav.icon:SetTexture("Interface\\AddOns\\pfQuest\\img\\fav")
f.fav.icon:SetAllPoints(f.fav)
f.fav:SetScript("OnClick", function()
local name = this:GetParent().itemName
if pfDatabase_fav["item"][name] then
pfDatabase_fav["item"][name] = nil
this.icon:SetVertexColor(1,1,1,.1)
else
pfDatabase_fav["item"][name] = true
this.icon:SetVertexColor(1,1,1,1)
end
end)
f.loot = CreateFrame("Button", nil, f)
f.loot:SetHitRectInsets(-3,-3,-3,-3)
f.loot:SetPoint("RIGHT", -5, 0)
f.loot:SetWidth(16)
f.loot:SetHeight(16)
f.loot.icon = f.loot:CreateTexture("OVERLAY")
f.loot.icon:SetAllPoints(f.loot)
f.loot:SetScript("OnClick", function()
local name = this:GetParent().itemName
local map = pfDatabase:SearchItem(name)
pfMap:UpdateNodes()
pfMap:ShowMapID(map)
end)
f.loot:SetScript("OnEnter", function()
local name = this:GetParent().itemName
local count = 0
GameTooltip:SetOwner(pfBrowser, "ANCHOR_CURSOR")
GameTooltip:SetText("Looted from", .3, 1, .8)
for id, field in pairs(items[name]) do
local f, t, mob, sellCount = strfind(field, "(.*),(.*)")
count = count + 1
if count > 5 then
GameTooltip:AddLine("[...]", .8,.8,.8)
break
end
if spawns[mob] then
local zone = spawns[mob]["zone"]
GameTooltip:AddDoubleLine(mob, ( zone and pfMap:GetMapNameByID(zone) or UNKNOWN), 1,1,1, .5,.5,.5)
end
end
GameTooltip:Show()
end)
f.loot:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
f.vendor = CreateFrame("Button", nil, f)
f.vendor:SetHitRectInsets(-3,-3,-3,-3)
f.vendor:SetPoint("RIGHT", -24, 0)
f.vendor:SetWidth(16)
f.vendor:SetHeight(16)
f.vendor.icon = f.vendor:CreateTexture("OVERLAY")
f.vendor.icon:SetAllPoints(f.vendor)
f.vendor.icon:SetTexture("Interface\\AddOns\\pfQuest\\img\\icon_vendor")
f.vendor:SetScript("OnClick", function()
local name = this:GetParent().itemName
local map = pfDatabase:SearchVendor(name)
pfMap:UpdateNodes()
pfMap:ShowMapID(map)
end)
f.vendor:SetScript("OnEnter", function()
local name = this:GetParent().itemName
local count = 0
GameTooltip:SetOwner(pfBrowser, "ANCHOR_CURSOR")
GameTooltip:SetText("Sold by", .3, 1, .8)
for id, field in pairs(vendors[name]) do
local f, t, vendorName, sellCount = strfind(field, "(.*),(.*)")
count = count + 1
if count > 5 then
GameTooltip:AddLine("[...]", .8,.8,.8)
break
end
if spawns[vendorName] then
local zone = spawns[vendorName]["zone"]
GameTooltip:AddDoubleLine(vendorName, ( zone and pfMap:GetMapNameByID(zone) or UNKNOWN), 1,1,1, .5,.5,.5)
end
end
GameTooltip:Show()
end)
f.vendor:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
return f
end
local function ReplaceQuestDetailWildcards(questText)
questText = string.gsub(questText, "$[Nn]", UnitName("player"))
questText = string.gsub(questText, "$[Cc]", strlower(UnitClass("player")))
questText = string.gsub(questText, "$[Rr]", strlower(UnitRace("player")))
questText = string.gsub(questText, "$[Bb]", "\n")
-- UnitSex("player") returns 2 for male and 3 for female
-- that's why there is an unused capture group around the $[Gg]
return string.gsub(questText, "($[Gg])(.+):(.+);", "%"..UnitSex("player"))
end
local function CreateQuestEntry(i)
local f = CreateFrame("Button", nil, pfBrowser.tabs.quest.list)
f:SetPoint("TOPLEFT", pfBrowser.tabs.quest.list, "TOPLEFT", 10, -i*30 + 5)
f:SetPoint("BOTTOMRIGHT", pfBrowser.tabs.quest.list, "TOPRIGHT", 10, -i*30 - 15)
f.tex = f:CreateTexture("BACKGROUND")
f.tex:SetAllPoints(f)
if math.mod(i,2) == 1 then
f.tex:SetTexture(1,1,1,.02)
else
f.tex:SetTexture(1,1,1,.04)
end
f:SetScript("OnEnter", function()
this.tex:SetTexture(1,1,1,.1)
GameTooltip:SetOwner(this.text, "ANCHOR_LEFT", -10, -5)
GameTooltip:SetText(this.questname, .3, 1, .8)
if quests[this.quest]["obj"] then
GameTooltip:AddLine(quests[this.quest]["obj"], 1,1,1,true)
end
if quests[this.quest]["log"] and quests[this.quest]["objectives"] then
GameTooltip:AddLine("-", 0,0,0)
end
if quests[this.quest]["log"] then
GameTooltip:AddLine(ReplaceQuestDetailWildcards(quests[this.quest]["log"]), .6,1,.9,true)
end
GameTooltip:Show()
end)
f:SetScript("OnLeave", function()
if math.mod(i,2) == 1 then
this.tex:SetTexture(1,1,1,.02)
else
this.tex:SetTexture(1,1,1,.04)
end
GameTooltip:Hide()
end)
f:SetScript("OnClick", function()
if IsShiftKeyDown() then
ChatFrameEditBox:Show()
ChatFrameEditBox:Insert("|cffffff00|Hquest:0:0:0:0|h[" .. this.questname .. "]|h|r")
else
local meta = { ["addon"] = "PFDB" }
local map = pfDatabase:SearchQuest(this.quest, meta, true)
pfMap:ShowMapID(map)
end
end)
f.text = f:CreateFontString("Caption", "LOW", "GameFontWhite")
f.text:SetAllPoints(f)
f.text:SetJustifyH("CENTER")
f.factionA = f:CreateTexture("OVERLAY")
f.factionA:SetTexture("Interface\\AddOns\\pfQuest\\img\\icon_alliance")
f.factionA:SetWidth(16)
f.factionA:SetHeight(16)
f.factionA:SetPoint("RIGHT", -5, 0)
f.factionH = f:CreateTexture("OVERLAY")
f.factionH:SetTexture("Interface\\AddOns\\pfQuest\\img\\icon_horde")
f.factionH:SetWidth(16)
f.factionH:SetHeight(16)
f.factionH:SetPoint("RIGHT", -24, 0)
f.fav = CreateFrame("Button", nil, f)
f.fav:SetHitRectInsets(-3,-3,-3,-3)
f.fav:SetPoint("LEFT", 0, 0)
f.fav:SetWidth(16)
f.fav:SetHeight(16)
f.fav.icon = f.fav:CreateTexture("OVERLAY")
f.fav.icon:SetTexture("Interface\\AddOns\\pfQuest\\img\\fav")
f.fav.icon:SetAllPoints(f.fav)
f.fav:SetScript("OnClick", function()
local name = this:GetParent().quest
if pfDatabase_fav["quest"][name] then
pfDatabase_fav["quest"][name] = nil
this.icon:SetVertexColor(1,1,1,.1)
else
pfDatabase_fav["quest"][name] = true
this.icon:SetVertexColor(1,1,1,1)
end
end)
return f
end
pfBrowserIcon = CreateFrame('Button', "pfBrowserIcon", Minimap)
pfBrowserIcon:SetClampedToScreen(true)
pfBrowserIcon:SetMovable(true)
pfBrowserIcon:EnableMouse(true)
pfBrowserIcon:RegisterForDrag('LeftButton')
pfBrowserIcon:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
pfBrowserIcon:SetScript("OnDragStart", function()
if IsShiftKeyDown() then
this:StartMoving()
end
end)
pfBrowserIcon:SetScript("OnDragStop", function() this:StopMovingOrSizing() end)
pfBrowserIcon:SetScript("OnClick", function()
if arg1 == "RightButton" then
if pfQuestConfig:IsShown() then pfQuestConfig:Hide() else pfQuestConfig:Show() end
else
if pfBrowser:IsShown() then pfBrowser:Hide() else pfBrowser:Show() end
end
end)
pfBrowserIcon:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, ANCHOR_BOTTOMLEFT)
GameTooltip:SetText("pfQuest")
GameTooltip:AddDoubleLine("Left-Click", "Open Browser", 1, 1, 1, 1, 1, 1)
GameTooltip:AddDoubleLine("Right-Click", "Open Configuration", 1, 1, 1, 1, 1, 1)
GameTooltip:AddDoubleLine("Shift-Click", "Move Button", 1, 1, 1, 1, 1, 1)
GameTooltip:Show()
end)
pfBrowserIcon:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
pfBrowserIcon:SetFrameStrata('LOW')
pfBrowserIcon:SetWidth(31)
pfBrowserIcon:SetHeight(31)
pfBrowserIcon:SetFrameLevel(9)
pfBrowserIcon:SetHighlightTexture('Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight')
pfBrowserIcon:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 0, 0)
pfBrowserIcon.overlay = pfBrowserIcon:CreateTexture(nil, 'OVERLAY')
pfBrowserIcon.overlay:SetWidth(53)
pfBrowserIcon.overlay:SetHeight(53)
pfBrowserIcon.overlay:SetTexture('Interface\\Minimap\\MiniMap-TrackingBorder')
pfBrowserIcon.overlay:SetPoint('TOPLEFT', 0,0)
pfBrowserIcon.icon = pfBrowserIcon:CreateTexture(nil, 'BACKGROUND')
pfBrowserIcon.icon:SetWidth(20)
pfBrowserIcon.icon:SetHeight(20)
pfBrowserIcon.icon:SetTexture('Interface\\AddOns\\pfQuest\\img\\logo')
pfBrowserIcon.icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
pfBrowserIcon.icon:SetPoint('CENTER',1,1)
pfBrowser = CreateFrame("Frame", "pfQuestBrowser", UIParent)
pfBrowser:Hide()
pfBrowser:SetWidth(640)
pfBrowser:SetHeight(480)
pfBrowser:SetPoint("CENTER", 0, 0)
pfBrowser:SetFrameStrata("FULLSCREEN_DIALOG")
pfBrowser:SetMovable(true)
pfBrowser:EnableMouse(true)
pfBrowser:SetScript("OnMouseDown",function()
this:StartMoving()
end)
pfBrowser:SetScript("OnMouseUp",function()
this:StopMovingOrSizing()
end)
pfUI.api.CreateBackdrop(pfBrowser, nil, true, 0.75)
table.insert(UISpecialFrames, "pfQuestBrowser")
pfBrowser.title = pfBrowser:CreateFontString("Status", "LOW", "GameFontNormal")
pfBrowser.title:SetFontObject(GameFontWhite)
pfBrowser.title:SetPoint("TOP", pfBrowser, "TOP", 0, -8)
pfBrowser.title:SetJustifyH("LEFT")
pfBrowser.title:SetFont(pfUI.font_default, 14)
pfBrowser.title:SetText("|cff33ffccpf|rQuest")
pfBrowser.close = CreateFrame("Button", "pfQuestBrowserClose", pfBrowser)
pfBrowser.close:SetPoint("TOPRIGHT", -5, -5)
pfBrowser.close:SetHeight(12)
pfBrowser.close:SetWidth(12)
pfBrowser.close.texture = pfBrowser.close:CreateTexture("pfQuestionDialogCloseTex")
pfBrowser.close.texture:SetTexture("Interface\\AddOns\\pfQuest\\compat\\close")
pfBrowser.close.texture:ClearAllPoints()
pfBrowser.close.texture:SetAllPoints(pfBrowser.close)
pfBrowser.close.texture:SetVertexColor(1,.25,.25,1)
pfUI.api.SkinButton(pfBrowser.close, 1, .5, .5)
pfBrowser.close:SetScript("OnClick", function()
this:GetParent():Hide()
end)
pfBrowser.clean = CreateFrame("Button", "pfQuestBrowserClean", pfBrowser)
pfBrowser.clean:SetPoint("TOPLEFT", pfBrowser, "TOPLEFT", 545, -30)
pfBrowser.clean:SetPoint("BOTTOMRIGHT", pfBrowser, "TOPRIGHT", -5, -55)
pfBrowser.clean:SetScript("OnClick", function()
pfMap:DeleteNode("PFDB")
pfMap:UpdateNodes()
end)
pfBrowser.clean.text = pfBrowser.clean:CreateFontString("Caption", "LOW", "GameFontWhite")
pfBrowser.clean.text:SetAllPoints(pfBrowser.clean)
pfBrowser.clean.text:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE")
pfBrowser.clean.text:SetText("Clean Map")
pfUI.api.SkinButton(pfBrowser.clean)
CreateBrowseWindow("spawn", "pfQuestBrowserSpawn", pfBrowser, "BOTTOMLEFT", 5, 5)
CreateBrowseWindow("item", "pfQuestBrowserItems", pfBrowser, "BOTTOM", 0, 5)
CreateBrowseWindow("quest", "pfQuestBrowserQuests", pfBrowser, "BOTTOMRIGHT", -5, 5)
SelectView(pfBrowser.tabs["spawn"])
pfBrowser.input = CreateFrame("EditBox", "pfQuestBrowserSearch", pfBrowser)
pfBrowser.input:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE")
pfBrowser.input:SetAutoFocus(false)
pfBrowser.input:SetText("Search")
pfBrowser.input:SetJustifyH("LEFT")
pfBrowser.input:SetPoint("TOPLEFT", pfBrowser, "TOPLEFT", 5, -30)
pfBrowser.input:SetPoint("BOTTOMRIGHT", pfBrowser, "TOPRIGHT", -100, -55)
pfBrowser.input:SetTextInsets(10,10,5,5)
pfBrowser.input:SetScript("OnEscapePressed", function() this:ClearFocus() end)
pfBrowser.input:SetScript("OnEditFocusGained", function()
if this:GetText() == "Search" then this:SetText("") end
end)
pfBrowser.input:SetScript("OnEditFocusLost", function()
if this:GetText() == "" then this:SetText("Search") end
end)
pfBrowser.input:SetScript("OnTextChanged", function()
local text = this:GetText()
if text ~= "Search" then
pfBrowser:SearchSpawn(text)
pfBrowser:SearchItem(text)
pfBrowser:SearchQuest(text)
else
pfBrowser:SearchSpawn("")
pfBrowser:SearchItem("")
pfBrowser:SearchQuest("")
end
end)
pfUI.api.CreateBackdrop(pfBrowser.input, nil, true)
function pfBrowser:SearchSpawn(search)
-- database selection
local database = pfDatabase_fav["spawn"]
if strlen(search) > 2 then database = spawns end
local i = 0
for name, object in pairs(database) do
if (strfind(strlower(name), strlower(search))) then
i = i + 1
if i >= search_limit then break end
local level, faction, zone
if spawns[name] then
level = object == true and spawns[name]['level'] or object.level
faction = object == true and spawns[name]['faction'] or object.faction
zone = tonumber(spawns[name]['zone'])
else
level = "??"
faction = ""
zone = ""
end
-- craeate button if necessary
if not pfBrowser.tabs.spawn.buttons[i] then
pfBrowser.tabs.spawn.buttons[i] = CreateSpawnEntry(i)
end
local button = pfBrowser.tabs.spawn.buttons[i]
button.text:SetText(name .. "|cffaaaaaa (" .. level .. ")")
button.text:SetWidth(button.text:GetStringWidth())
if zone and pfMap:IsValidMap(zone) then
button.text:SetTextColor(1,1,1)
else
button.text:SetTextColor(.5,.5,.5)
end
button.name = name
-- set faction icon
button.factionH:Hide()
button.factionA:Hide()
if faction ~= "HA" and faction ~= "AH" then
if strfind(faction, "H") then
button.factionH:Show()
else
button.factionH:Hide()
end
if strfind(faction, "A") then
button.factionA:Show()
else
button.factionA:Hide()
end
end
-- set fav
if pfDatabase_fav["spawn"][name] then
button.fav.icon:SetVertexColor(1,1,1,1)
else
button.fav.icon:SetVertexColor(1,1,1,.1)
end
button:Show()
end
end
RefreshView(i, "spawn", "Mobs & Objects")
end
function pfBrowser:SearchItem(search)
-- database selection
local database = pfDatabase_fav["item"]
if strlen(search) > 2 then database = items end
local i = 0
for item, object in pairs(database) do
if (strfind(strlower(item), strlower(search))) then
i = i + 1
if i >= search_limit then break end
-- determine if fav or default database is in use
local id = object == true and items[item]['id'] or object.id
local itemColor = "|cffffffff"
-- trigger item scan
GameTooltip:SetHyperlink("item:" .. id .. ":0:0:0")
GameTooltip:Hide()
-- craeate button if necessary
if not pfBrowser.tabs.item.buttons[i] then
pfBrowser.tabs.item.buttons[i] = CreateItemEntry(i)
end
local button = pfBrowser.tabs.item.buttons[i]
button.text:SetText("|cffff5555[?] |cffffffff" .. item)
button.text:SetWidth(button.text:GetStringWidth())
button.itemID = id
button.itemName = item
if items[item][1] then
local _, _, npc = strfind(items[item][1], "(.*),(.*)")
if spawns[npc] and spawns[npc]['type'] == "NPC" then
button.loot.icon:SetTexture("Interface\\AddOns\\pfQuest\\img\\icon_npc")
else
button.loot.icon:SetTexture("Interface\\AddOns\\pfQuest\\img\\icon_object")
end
button.loot:Show()
else
button.loot:Hide()
end
if vendors[item] then
button.vendor:Show()
else
button.vendor:Hide()
end
if pfDatabase_fav["item"][item] then
button.fav.icon:SetVertexColor(1,1,1,1)
else
button.fav.icon:SetVertexColor(1,1,1,.1)
end
-- refresh item quality
button:SetScript("OnUpdate", function()
local _, _, itemQuality = GetItemInfo(this.itemID)
if itemQuality then
this.itemColor = "|c" .. string.format("%02x%02x%02x%02x", 255,
ITEM_QUALITY_COLORS[itemQuality].r * 255,
ITEM_QUALITY_COLORS[itemQuality].g * 255,
ITEM_QUALITY_COLORS[itemQuality].b * 255)
this.text:SetText(this.itemColor .."|Hitem:"..this.itemID..":0:0:0|h[".. this.itemName.."]|h|r")
this.text:SetWidth(this.text:GetStringWidth())
this:SetScript("OnUpdate", nil)
end
end)
button:Show()
end
end
RefreshView(i, "item", "Items")
end
function pfBrowser:SearchQuest(search)
-- database selection
local database = pfDatabase_fav["quest"]
if strlen(search) > 2 then database = quests end
local i = 0
for quest, object in pairs(database) do
local f, t, questname, _ = strfind(quest, "(.*),.*")
if questname and (strfind(strlower(questname), strlower(search))) then
i = i + 1
if i >= search_limit then break end
-- craeate button if necessary
if not pfBrowser.tabs.quest.buttons[i] then
pfBrowser.tabs.quest.buttons[i] = CreateQuestEntry(i)
end
local button = pfBrowser.tabs.quest.buttons[i]
-- read faction
local faction = ""
button.factionA:Hide()
button.factionH:Hide()
if quests[quest] then
for npc, monsterDrop in pairs(quests[quest]) do
if spawns[npc] and spawns[npc]['faction'] then
faction = faction .. spawns[npc]['faction']
end
end
end
if strfind(faction, "H") then
button.factionH:Show()
end
if strfind(faction, "A") then
button.factionA:Show()
end
if quests[quest] then
button.text:SetText("|cffffcc00|Hquest:0:0:0:0|h[" .. questname .. "]|h|r")
else
button.text:SetText("|cffff5555[?] |cffffcc00|Hquest:0:0:0:0|h[" .. questname .. "]|h|r")
end
button.text:SetWidth(button.text:GetStringWidth())
button.quest = quest
button.questname = questname
if pfDatabase_fav["quest"][questname] then
button.fav.icon:SetVertexColor(1,1,1,1)
else
button.fav.icon:SetVertexColor(1,1,1,.1)
end
button:Show()
end
end
RefreshView(i, "quest", "Quests")
end