-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFishingLocationsFrame.lua
805 lines (752 loc) · 28.6 KB
/
FishingLocationsFrame.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
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
-- Handle displaying all the fish in their habitats
FishingBuddy.Locations = {};
local FL = LibStub("LibFishing-1.0");
-- 5.0.4 has a problem with a global "_" (see some for loops below)
local _
local NUM_THINGIES_DISPLAYED = 22;
local FRAME_THINGIEHEIGHT = 16;
FishingBuddy.Locations.FRAME_THINGIEHEIGHT = FRAME_THINGIEHEIGHT;
local Collapsed = 0;
local LocationLineSelected = 0;
local LocationLines = {};
local LocationLastLine = 1;
local zmto = FishingBuddy.ZoneMarkerTo;
local zmex = FishingBuddy.ZoneMarkerEx;
--
-- ##### X X X
-- level
-- expanded
-- collapsible
--
-- number * 1000
-- negative --> zone marker
-- positive --> fish
-- level is 0 for zones
-- level is 1 for subzones, or 0 if not showing zones
-- level is 2 for fish, or 1 if not showing zones
local function pack(zonemarker, id, collapsible, expanded, level)
local val;
if ( zonemarker > 0 ) then
val = zonemarker;
else
val = id;
end
val = val * 10 + level;
val = val * 10 + collapsible;
val = val * 10 + expanded; -- expanded
if ( zonemarker > 0 ) then
val = val * -1;
end
return val;
end
local function unpack(marker)
if ( not marker ) then
return 0, 0, 0, 0, 0;
end
local val = marker;
if ( val < 0 ) then
val = val * -1;
end
local subzone, id, collapsible, expanded, level;
local mod = math.fmod;
expanded = mod(val, 10);
val = floor(val / 10);
collapsible = mod(val, 10);
val = floor(val / 10);
level = mod(val, 10);
val = floor(val / 10);
if ( marker < 0 ) then
return val, 0, collapsible, expanded, level;
else
return 0, val, collapsible, expanded, level;
end
end
local function toggle(marker)
local z,i,c,e,l = unpack(marker);
e = 1 - e;
return pack(z,i,c,e,l);
end
local function MakeInfo(line, zid, fid, collapsible, level)
LocationLines[line] = pack(zid, fid, collapsible, collapsible, level);
end
local function CountLocationLines()
local linecount = 0;
local j = 1;
for odx=1,LocationLastLine do
local check = LocationLines[j];
j = j + 1;
if ( check and check ~= 0 ) then
linecount = linecount + 1;
local c,e,level;
_,_,c,e,level = unpack(check);
if ( c == 1 and e == 0 ) then
local l;
_,_,_,_,l = unpack(LocationLines[j]);
while ( l > level ) do
j = j + 1;
_,_,_,_,l = unpack(LocationLines[j]);
end
end
end
end
return linecount;
end
local function FishCount(idx)
local count = 0;
local total = 0;
local fh = FishingBuddy_Info["FishingHoles"];
if ( fh[idx] ) then
for fishie,val in pairs(fh[idx]) do
count = count + 1;
total = total + val;
end
end
return count, total;
end
FishingBuddy.FishCount = FishCount;
local function FishiesChanged()
local fishcount = table.getn(FishingBuddy.SortedFishies);
local line = 1;
for i=1,fishcount,1 do
local fishid = FishingBuddy.SortedFishies[i].id;
local locsort = {};
for idx,count in pairs(FishingBuddy.ByFishie[fishid]) do
local info = {};
info.marker = idx;
info.count = count;
tinsert(locsort, info);
end
MakeInfo(line, 0, fishid, 1, 0);
line = line + 1;
FishingBuddy.FishSort(locsort);
for j=1,table.getn(locsort),1 do
MakeInfo(line, locsort[j].marker, 0, 0, 1);
line = line + 1;
end
end
LocationLastLine = line;
end
local function BothLocationsChanged()
local loc = GetLocale();
local fh = FishingBuddy_Info["FishingHoles"];
local ff = FishingBuddy_Info["Fishies"];
local sorted = FishingBuddy.SortedZones;
local line = 1;
local zonecount = table.getn(sorted);
for i=1,zonecount,1 do
local zone = sorted[i];
local mapId = FishingBuddy.MappedZones[zone];
if ( mapId ) then
local addedzone = false;
local subsorted = FishingBuddy.SortedByZone[zone];
local subcount = table.getn(subsorted);
for s=1,subcount,1 do
local subzone = subsorted[s];
local where = FishingBuddy.GetZoneIndex(mapId, subzone, true);
local count, total = FishCount(where);
if ( total > 0 ) then
if ( not addedzone ) then
MakeInfo(line, zmto(mapId, 0), 0, 1, 0);
line = line + 1;
addedzone = true;
end
if ( fh[where] ) then
MakeInfo(line, where, 0, 1, 1);
line = line + 1;
local fishsort = {};
for fishid,count in pairs(fh[where]) do
local info = {};
info.id = fishid;
_, _, _, _, _, info.text, _ = FishingBuddy.GetFishie(fishid, 1);
info.count = count;
tinsert(fishsort, info);
end
FishingBuddy.FishSort(fishsort);
for j=1,table.getn(fishsort),1 do
local id = fishsort[j].id;
MakeInfo(line, 0, id, 0, 2);
line = line + 1;
end
end
end
end
end
end
LocationLastLine = line;
end
local function SubZonesChanged()
local loc = GetLocale();
local fh = FishingBuddy_Info["FishingHoles"];
local ff = FishingBuddy_Info["Fishies"];
local line = 1;
local zonecount = table.getn(FishingBuddy.SortedSubZones);
for i=1,zonecount,1 do
local subzone = FishingBuddy.SortedSubZones[i];
local ztab = FishingBuddy.SubZoneMap[subzone];
if ( ztab ) then
local oneidx;
local uniquify = {};
local fishsort = {};
for idx,_ in pairs(ztab) do
if ( fh[idx] ) then
oneidx = idx;
for fishid,count in pairs(fh[idx]) do
if ( not uniquify[fishid] ) then
local _, _, _, _, _, name, _ = FishingBuddy.GetFishie(fishid, 1);
tinsert(fishsort, { id=fishid, text=name });
uniquify[fishid] = 1;
end
end
end
end
if ( oneidx ) then
MakeInfo(line, oneidx, 0, 1, 0);
line = line + 1;
FishingBuddy.FishSort(fishsort);
for j=1,table.getn(fishsort),1 do
local id = fishsort[j].id;
MakeInfo(line, 0, id, 0, 1);
line = line + 1;
end
end
end
end
LocationLastLine = line;
end
local function LinesChanged()
if ( FishingBuddy.GetSettingBool("GroupByLocation") ) then
if ( FishingBuddy.GetSettingBool("ShowLocationZones") ) then
BothLocationsChanged();
else
SubZonesChanged();
end
else
FishiesChanged();
end
for i=LocationLastLine,table.getn(LocationLines) do
LocationLines[i] = 0;
end
FishingLocationsFrame.valid = true;
end
-- local MOUSEWHEEL_DELAY = 0.1;
-- local lastScrollTime = nil;
-- function FishingLocationsFrame_OnMouseWheel(value)
-- local now = GetTime();
-- if ( not lastScrollTime ) then
-- lastScrollTime = now - 0.2;
-- end
-- if ( (now - lastScrollTime) > MOUSEWHEEL_DELAY ) then
-- -- call the old mouse wheel function somehow?
-- end
-- end
local function UpdateLocationScrollPosition()
local linecount = CountLocationLines();
local offset = FauxScrollFrame_GetOffset(FishingLocsScrollFrame);
if ( offset + NUM_THINGIES_DISPLAYED > linecount ) then
offset = linecount - NUM_THINGIES_DISPLAYED;
if ( offset < 0 ) then
offset = 0;
end
FishingLocsScrollFrameScrollBar:SetValue(offset);
end
FauxScrollFrame_Update( FishingLocsScrollFrame, linecount,
NUM_THINGIES_DISPLAYED,
FRAME_THINGIEHEIGHT,
nil, nil, nil,
FishingLocationHighlightFrame,
230, 230
);
end
local function SetSelectedLocLine(id, line)
local info = LocationLines[line];
FishingLocationHighlightFrame:Hide();
if ( info ~= 0 ) then
local z,i,c,e,l = unpack(info);
if ( c == 1 ) then
LocationLines[line] = toggle(info);
UpdateLocationScrollPosition();
else
LocationLineSelected = line;
FishingLocationHighlightFrame:SetPoint ("TOPLEFT" , _G["FishingLocations"..id]:GetName() , "TOPLEFT" , 5 , 0 )
FishingLocationHighlightFrame:Show()
end
end
end
local function UpdateLocLine(id, line, leveloffset, c, e, text, append, texture)
local locButton = _G["FishingLocations"..id];
local locButtonFS = _G["FishingLocations"..id.."NormalText"];
local locHilite = _G["FishingLocations"..id.."Highlight"];
local icon = _G["FishingLocations"..id.."Icon"];
local icontex = _G["FishingLocations"..id.."IconTexture"];
locButton.id = id;
locButton.line = line;
if ( id == 1 ) then
locButton:SetPoint("TOPLEFT", FishingBuddyFrameInset, "TOPLEFT", leveloffset+8, -4);
else
local t = id - 1;
locButton:SetPoint("TOPLEFT", "FishingLocations"..t, "BOTTOMLEFT", leveloffset, 0);
end
icon:ClearAllPoints();
locButton:GetNormalFontObject():SetTextColor( 1, 0.82, 0 );
local offset = 0;
if ( c == 1 ) then
offset = 21;
icon:SetPoint("LEFT", locButton, "LEFT", 21, 0);
if ( e == 1 ) then
locButton:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up");
else
locButton:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up");
end
locHilite:SetTexture("Interface\\Buttons\\UI-PlusButton-Hilight");
locButton:UnlockHighlight();
else
icon:SetPoint("LEFT", locButton, "LEFT", 0, 0);
locButton:SetNormalTexture("");
locHilite:SetTexture("");
-- Place the highlight and lock the highlight state
if ( LocationLineSelected == line ) then
FishingLocationHighlightFrame:SetPoint("TOPLEFT", locButton,
"TOPLEFT", 21, 0);
FishingLocationHighlightFrame:Show();
locButton:LockHighlight();
else
locButton:UnlockHighlight();
end
end
if( texture ) then
offset = offset + 18;
icontex:SetTexture(texture);
icon:Show();
icontex:Show();
else
icontex:SetTexture("");
icontex:Hide();
icon:Hide();
end
local textfield = _G["FishingLocations"..id.."NormalText"];
if ( textfield ~= nil ) then
textfield:SetPoint("LEFT", offset, 0);
end
FL:EllipsizeText(locButtonFS, text, FishingLocsScrollFrameScrollChildFrame:GetWidth() - leveloffset - 4, append)
locButton:Show();
end
FishingBuddy.Locations.Update = function(self, forced)
if ( not FishingLocationsFrame:IsVisible() ) then
return;
end
if ( forced or not FishingLocationsFrame.valid ) then
LinesChanged();
end
local IsQuestFish = FishingBuddy.IsQuestFish;
local offset = FauxScrollFrame_GetOffset(self);
local lastlevel = 0;
FishingLocationHighlightFrame:Hide();
UpdateLocationScrollPosition();
local append = ""
local j = 1;
local i = 1;
local limit = offset + NUM_THINGIES_DISPLAYED;
local totals = {};
local lastzid, lastfid;
local fh = FishingBuddy_Info["FishingHoles"];
local bf = FishingBuddy.ByFishie;
local ft = FishingBuddy_Info["FishTotals"];
local green = "ff"..FL.COLOR_HEX_GREEN;
local white = "ff"..FL.COLOR_HEX_WHITE;
for odx=0,LocationLastLine,1 do
local info = LocationLines[j];
if ( info and info ~= 0 ) then
local zid,fid,c,e,level = unpack(info);
local percent = nil;
local zidx, sidx;
if ( zid > 0 ) then
lastzid = zid;
zidx, sidx = zmex(zid);
if ( sidx > 0 ) then
local sz = FishingBuddy_Info["SubZones"][zid];
local ztab = FishingBuddy.SubZoneMap[sz];
if ( ztab ) then
local count = 0;
for idx,_ in pairs(ztab) do
local n = FishingBuddy_Info["FishTotals"][idx];
if ( n ) then
count = count + n;
end
end
totals[level] = count;
end
else
totals[level] = FishingBuddy_Info["FishTotals"][zid];
end
else
if ( level == 0 ) then
lastfid = fid;
else
lastfid = nil;
end
end
if ( odx >= offset and odx < limit ) then
local locButton = _G["FishingLocations"..i];
if ( zid > 0 or fid > 0 ) then
local text, texture;
locButton.tooltip = {};
if ( fid > 0 ) then
local item;
item, texture, _, _, _, text, _ = FishingBuddy.GetFishie(fid, 1);
locButton.item = item;
locButton.fishid = fid;
locButton.name = text;
if ( IsQuestFish(fid) ) then
tinsert(locButton.tooltip, ITEM_BIND_QUEST);
end
if ( level > 0 ) then
local zidx, sidx = zmex(lastzid);
local sz = FishingBuddy_Info["SubZones"][lastzid];
local ztab = FishingBuddy.SubZoneMap[sz];
local count = 0;
if ( ztab ) then
for idx,_ in pairs(ztab) do
if ( fh[idx] and fh[idx][fid] ) then
count = count + fh[idx][fid];
end
end
end
if ( count > 0 ) then
tinsert(locButton.tooltip,
{ { FBConstants.CAUGHTTHISMANY, green },
{ count, white } } );
if ( totals[level-1] ) then
tinsert(locButton.tooltip,
{ { FBConstants.CAUGHTTHISTOTAL, green },
{ totals[level-1], white } } );
percent = count/totals[level-1];
end
end
else
local total = 0;
for idx,count in pairs(bf[fid]) do
total = total + count;
end
totals[0] = total;
tinsert(locButton.tooltip,
{ { FBConstants.CAUGHTTHISTOTAL, green },
{ total, white } } );
end
else
if ( sidx > 0 ) then
text = FL:GetLocSubZone(FishingBuddy_Info["SubZones"][zid], 1);
tinsert(locButton.tooltip, text);
local ztab = FishingBuddy.SubZoneMap[text];
if ( ztab ) then
local inz = {};
for idx,_ in pairs(ztab) do
local tz,ts = zmex(idx);
-- need a non-ordered list of zone names
local n = FL:GetLocZone(tz)
tinsert(inz, n);
end
table.sort(inz);
tinsert(locButton.tooltip,
FL:Green(ZONE_COLON.." ")..FL:White(FishingBuddy.EnglishList(inz)));
end
if ( lastfid ) then
if ( bf[lastfid][zid] ) then
tinsert(locButton.tooltip,
{ { FBConstants.CAUGHTTHISTOTAL, green },
{ bf[lastfid][zid], white } } );
if ( level > 0 and totals[level-1] ) then
percent = bf[lastfid][zid]/totals[level-1];
end
end
elseif ( ft[zid] ) then
tinsert(locButton.tooltip,
{ { FBConstants.CAUGHTTHISTOTAL, green },
{ ft[zid], white } } );
if ( level > 0 and totals[level-1] ) then
percent = ft[zid]/totals[level-1];
end
end
else
text = FL:GetLocZone(zidx);
tinsert(locButton.tooltip, text);
local subsorted = FishingBuddy.SortedByZone[text];
local subcount = table.getn(subsorted or {});
local ins = {};
for s=1,subcount,1 do
tinsert(ins, subsorted[s]);
end
tinsert(locButton.tooltip,
FL:Green("Subzones: ")..FL:White(FishingBuddy.EnglishList(ins)));
tinsert(locButton.tooltip,
{ { FBConstants.CAUGHTTHISTOTAL, green },
{ totals[level], white } } );
if ( level > 0 and lastfid and bf[lastfid][zid] ) then
percent = bf[lastfid][zid]/totals[level-1];
end
end
locButton.item = nil;
locButton.fishid = nil;
locButton.name = nil;
texture = nil;
end
local leveloffset = (level - lastlevel)*16;
if ( percent ) then
percent = math.floor(percent*100);
append = " ("..percent.."%)";
percent = nil;
else
append = ""
end
UpdateLocLine(i, j, leveloffset, c, e, text, append, texture);
lastlevel = level;
else
locButton:Hide();
locButton.id = nil;
locButton.line = nil;
end
i = i + 1;
end
j = j + 1;
if ( c == 1 and e == 0 ) then
local i2 = LocationLines[j];
if ( i2 and i2 ~= 0 ) then
local l;
_,_,_,_,l = unpack(i2)
while ( i2 and i2 ~= 0 and l > level ) do
j = j + 1;
i2 = LocationLines[j];
_,_,_,_,l = unpack(i2)
end
end
end
end
end
while ( i <= NUM_THINGIES_DISPLAYED ) do
local locButton = _G["FishingLocations"..i];
locButton:Hide();
locButton.id = nil;
locButton.line = nil;
i = i + 1;
end
if ( LocationLines ) then
-- Set the expand/collapse all button texture
local numHeaders = 0;
local notExpanded = 0;
for j=1,table.getn(LocationLines),1 do
local info = LocationLines[j];
local _,_,c,e,_ = unpack(info);
if ( info and info ~= 0 and c == 1 ) then
numHeaders = numHeaders + 1;
if ( e == 0 ) then
notExpanded = notExpanded + 1;
end
end
end
FishingLocationsCollapseAllButton:Show();
-- If all headers are not expanded then show collapse button, otherwise show the expand button
if ( notExpanded ~= numHeaders ) then
Collapsed = 0;
FishingLocationsCollapseAllButton:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-Up");
else
Collapsed = 1;
FishingLocationsCollapseAllButton:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-Up");
end
else
FishingLocationsCollapseAllButton:Hide();
end
end
local OptionHandlers = {};
local function FishOptionsInitialize()
local menu = _G["FishingBuddyLocationsMenu"];
if ( menu.fishid ) then
local fishid = menu.fishid;
local info = {};
info.text = FBConstants.HIDEINWATCHER;
info.func = FishingBuddy.WatchFrame.MakeToggle(fishid);
info.checked = ( not FishingBuddy_Info["HiddenFishies"][fishid] );
UIDropDownMenu_AddButton(info);
for idx,handler in pairs(OptionHandlers) do
handler(fishid);
end
end
end
FishingBuddy.Locations.Button_OnClick = function(self, button, down)
if ( button == "LeftButton" ) then
if( IsShiftKeyDown() and self.item ) then
FL:ChatLink(self.item, self.name, self.color);
elseif ( self.id and self.line ) then
SetSelectedLocLine(self.id, self.line);
FishingBuddy.Locations.Update(FishingLocsScrollFrame);
end
elseif ( self.fishid and button == "RightButton" ) then
local menu = _G["FishingBuddyLocationsMenu"];
menu.fishid = self.fishid;
UIDropDownMenu_Initialize(menu, FishOptionsInitialize, "MENU");
FishingBuddy.ToggleDropDownMenu(1, nil, menu, self, 0, 0);
end
end
function FishingLocationsCollapseAllButton_OnClick()
if ( Collapsed == 0 ) then
FishingLocsScrollFrameScrollBar:SetValue(0);
LocationLineSelected = 1;
end
for j=1,table.getn(LocationLines) do
local check = LocationLines[j];
if ( check ~= 0 ) then
local z,i,c,e,l = unpack(check);
e = Collapsed;
LocationLines[j] = pack(z,i,c,e,l);
-- FishingBuddy.Debug(" j "..j.." pack "..check.." unpack "..LocationLines[j]);
end
end
Collapsed = 1 - Collapsed;
UpdateLocationScrollPosition();
FishingBuddy.Locations.Update(FishingLocsScrollFrame);
end
FishingBuddy.Locations.Button_OnEnter = function(self)
if( GameTooltip.locbutfini ) then
return;
end
if ( self.item or self.tooltip ) then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
end
local gottitle;
if( self.item or self.tooltip ) then
gottitle = true;
if ( self.item and self.item ~= "" ) then
if ( FL:IsLinkableItem(self.item) ) then
GameTooltip:SetHyperlink("item:"..self.item);
else
local tip = {};
tip[1] = self.name;
tip[2] = { FBConstants.NOTLINKABLE, "ff"..FL.COLOR_HEX_RED };
if ( self.tooltip ) then
if ( type(self.tooltip) == "table" ) then
for _,l in pairs(self.tooltip) do
tinsert(tip, l);
end
else
tinsert(tip, self.tooltip);
end
end
self.tooltip = tip;
self.item = nil;
end
end
if ( self.tooltip ) then
FL:AddTooltip(self.tooltip);
end
end
if ( self.item or self.tooltip or self.tipinfo ) then
GameTooltip.locbutfini = 1;
GameTooltip:Show();
end
end
FishingBuddy.Locations.Button_OnLeave = function(self)
if( self.item or self.tooltip ) then
GameTooltip:Hide();
end
GameTooltip.locbutfini = nil;
end
local function DisplayChanged()
FishingLocsScrollFrameScrollBar:SetValue(0);
LocationLineSelected = 1;
FishingBuddy.Locations.Update(FishingLocsScrollFrame, true);
end
local function UpdateButtonDisplay()
if ( FishingBuddy.GetSettingBool("GroupByLocation") ) then
FishingLocationsSwitchButton:SetText(FBConstants.SHOWFISHIES);
FishingBuddyOptionSLZ:Show();
else
FishingLocationsSwitchButton:SetText(FBConstants.SHOWLOCATIONS);
FishingBuddyOptionSLZ:Hide();
end
end
FishingBuddy.Locations.SwitchDisplay = function()
-- backwards logic check, we're about to change...
local setting = FishingBuddy.GetSetting("GroupByLocation");
setting = not setting;
FishingBuddy.SetSetting("GroupByLocation", setting);
UpdateButtonDisplay();
DisplayChanged();
end
FishingBuddy.Locations.SwitchButton_OnEnter = function()
if ( FishingBuddy.GetSettingBool("GroupByLocation") ) then
GameTooltip:SetText(FBConstants.SHOWFISHIES_INFO);
else
GameTooltip:SetText(FBConstants.SHOWLOCATIONS_INFO);
end
GameTooltip:Show();
end
local LocationEvents = {};
LocationEvents[FBConstants.ADD_FISHIE_EVT] = function()
FishingLocationsFrame.valid = false;
end
LocationEvents[FBConstants.RESET_FISHDATA_EVT] = function()
FishingLocationsFrame.valid = false;
end
local LocOptions = {
["ShowLocationZones"] = {
["text"] = FBConstants.CONFIG_SHOWLOCATIONZONES_ONOFF,
["tooltip"] = FBConstants.CONFIG_SHOWLOCATIONZONES_INFO,
["button"] = "FishingBuddyOptionSLZ",
["v"] = 1, -- process it as if it was displayed in the options frame
["update"] = DisplayChanged,
["setup"] = function(self)
self:SetPoint("TOPLEFT", "FishingLocationsSwitchButton", "BOTTOMLEFT", 0, 4);
end,
["default"] = true, },
};
FishingBuddy.Locations.OnLoad = function(self)
self:RegisterEvent("VARIABLES_LOADED");
FishingLocationsSwitchButton:SetText(FBConstants.SHOWFISHIES);
-- Set up checkbox
FishingBuddy.EmbeddedOptions(FishingLocationsFrame);
FishingBuddy.OptionsFrame.HandleOptions(nil, nil, LocOptions);
FishingBuddy.RegisterHandlers(LocationEvents);
FishingLocationsFrame:SetScript("OnHide", function(self) FishingBuddyOptionSLZ:Hide(); end)
end
FishingBuddy.Locations.OnShow = function(self)
if ( FishingBuddy.IsLoaded() ) then
FishingLocationsFrame:InitializeOptions(LocOptions)
FishingBuddy.Locations.Update(FishingLocsScrollFrame);
UpdateButtonDisplay();
end
end
FishingBuddy.Locations.OnEvent = function(self, event, ...)
-- this crashes the client when enabled
-- self:EnableMouseWheel(0);
if event == "VARIABLES_LOADED" then
local groups = {}
tinsert(groups, {
["name"] = FBConstants.LOCATIONS_TAB,
["icon"] = "Interface\\Icons\\INV_Misc_Note_01",
["frame"] = "FishingLocationsFrame"
})
local frame = FishingBuddy.CreateManagedFrameGroup(FBConstants.LOCATIONS_TAB,
FBConstants.LOCATIONS_INFO,
"_LOC",
groups);
FishingBuddyFrame:MakePrimary(frame);
end
end
FishingBuddy.Locations.DataChanged = function(zone, subzone, fishie)
FishingLocationsFrame.valid = false;
end
FishingBuddy.ShowLocLine = function(j)
FishingBuddy.Dump(LocationLines[j]);
end
FishingBuddy.Locations.PerFishOptions = function(handler)
local found = false;
for idx,h in pairs(OptionHandlers) do
if ( h == handler ) then
found = true;
end
end
if ( not found ) then
table.insert(OptionHandlers, handler);
end
end
FishingBuddy.DumpLocationLines = function()
FishingBuddy.Dump(LocationLines);
end