forked from alexqu0822/CodexLite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.lua
1714 lines (1706 loc) · 56.3 KB
/
map.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
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[--
by ALA @ 163UI/网易有爱, http://wowui.w.163.com/163ui/
CREDIT shagu/pfQuest(MIT LICENSE) @ https://github.com/shagu
--]]--
local __addon, __private = ...;
local MT = __private.MT;
local CT = __private.CT;
local VT = __private.VT;
local DT = __private.DT;
--> upvalue
local hooksecurefunc = hooksecurefunc;
local next = next;
local tremove, wipe = table.remove, table.wipe;
local _radius_sin, _radius_cos = math.cos, math.sin;
local GetCVar = GetCVar;
local GetTime = GetTime;
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown;
local GetPlayerFacing = GetPlayerFacing;
local C_Map = C_Map;
local CreateFrame = CreateFrame;
local WorldMapFrame = WorldMapFrame; --> WorldMapFrame:WorldMapFrameTemplate interiting MapCanvasFrameTemplate:MapCanvasMixin
local mapCanvas = WorldMapFrame:GetCanvas(); --> equal WorldMapFrame.ScrollContainer.Child -- not implementation of MapCanvasMixin!!!
local CreateFromMixins, MapCanvasDataProviderMixin = CreateFromMixins, MapCanvasDataProviderMixin;
local Minimap = Minimap;
local GameTooltip = GameTooltip;
local _G = _G;
-->
local DataAgent = DT.DB;
local l10n = CT.l10n;
local EventAgent = VT.EventAgent;
local __MAIN_META = VT.MAIN_META;
-- local pinFrameLevel = WorldMapFrame:GetPinFrameLevelsManager():GetValidFrameLevel("PIN_FRAME_LEVEL_AREA_POI");
local wm_wrap = CreateFrame('FRAME', nil, mapCanvas);
wm_wrap:SetSize(1, 1);
wm_wrap:SetPoint("CENTER");
local mm_wrap = CreateFrame('FRAME', nil, Minimap);
mm_wrap:SetSize(1, 1);
mm_wrap:SetPoint("CENTER");
local CommonPinFrameLevel, LargePinFrameLevel = 1, 1;
local function ReCalcFrameLevel(pinFrameLevelsManager)
local base = pinFrameLevelsManager:GetValidFrameLevel("PIN_FRAME_LEVEL_AREA_POI", 9999);
wm_wrap:SetFrameLevel(base);
mm_wrap:SetFrameLevel(base);
CommonPinFrameLevel = base;
LargePinFrameLevel = base + 1;
for index, texture in next, CT.IMG_LIST do
texture[7] = base + texture[6];
end
end
local pinFrameLevelsManager = WorldMapFrame:GetPinFrameLevelsManager(); -- WorldMapFrame.pinFrameLevelsManager;
hooksecurefunc(pinFrameLevelsManager, "AddFrameLevel", ReCalcFrameLevel);
ReCalcFrameLevel(pinFrameLevelsManager);
-->
MT.BuildEnv("map");
--> MAP
--> -- count
local __popt = { 0, 0, 0, 0, };
local function __opt_prompt()
MT.Debug('map.opt', __popt[1], __popt[2], __popt[3], __popt[4]);
end
function __popt:count(index, count)
__popt[index] = __popt[index] + count;
if VT.__is_dev then MT._TimerStart(__opt_prompt, 0.2, 1); end
end
function __popt:reset(index)
__popt[index] = 0;
if VT.__is_dev then MT._TimerStart(__opt_prompt, 0.2, 1); end
end
function __popt:echo(index)
return __popt[index];
end
-->
local wm_map = WorldMapFrame:GetMapID();
local mm_map = C_Map.GetBestMapForUnit('player');
local map_canvas_scale = mapCanvas:GetScale();
local wm_normal_size, wm_large_size, wm_varied_size = nil, nil, nil;
local mm_normal_size, mm_large_size, mm_varied_size = nil, nil, nil;
local node_menu_modifier = IsShiftKeyDown;
local META_COMMON = { }; --> [map] = { [uuid] = { 1{ coord }, 2{ pin }, 3nil, 4nil, }, }
local META_LARGE = { }; --> [map] = { [uuid] = { 1{ coord }, 2{ pin }, 3nil, 4nil, }, }
local META_VARIED = { }; --> [map] = { [uuid] = { 1{ coord }, 2{ pin }, 3nil, 4nil, }, }
local MM_COMMON_PINS = { }; --> [map] = { coord = pin, }
local MM_LARGE_PINS = { }; --> [map] = { coord = pin, }
local MM_VARIED_PINS = { }; --> [map] = { coord = pin, }
VT.MAP_META = { META_COMMON, META_LARGE, META_VARIED, };
local QUEST_TEMPORARILY_BLOCKED = { };
local QUEST_PERMANENTLY_BLOCKED = { };
local QUEST_PERMANENTLY_BL_LIST = { };
--> function predef
local Pin_OnEnter, Pin_OnClick;
local NewWorldMapPin, RelWorldMapCommonPin, AddWorldMapCommonPin, RelWorldMapLargePin, AddWorldMapLargePin, RelWorldMapVariedPin, AddWorldMapVariedPin;
local IterateWorldMapPinSetSize, ResetWMPin;
local WorldMap_HideCommonNodesMapUUID, WorldMap_HideLargeNodesMapUUID, WorldMap_HideVariedNodesMapUUID;
local WorldMap_ChangeCommonLargeNodesMapUUID, WorldMap_ChangeVariedNodesMapUUID;
local WorldMap_ShowNodesQuest, WorldMap_HideNodesQuest;
local WorldMap_DrawNodesMap, WorldMap_HideNodesMap;
local NewMinimapPin, RelMinimapPin, AddMinimapPin, ResetMMPin;
local Minimap_HideCommonNodesMapUUID, Minimap_HideLargeNodesMapUUID, Minimap_HideVariedNodesMapUUID;
local Minimap_ChangeCommonLargeNodesMapUUID, Minimap_ChangeVariedNodesMapUUID;
local Minimap_ShowNodesMapQuest, Minimap_HideNodesQuest;
local Minimap_DrawNodesMap, Minimap_HideNodes, Minimap_OnUpdate;
local MapAddCommonNodes, MapDelCommonNodes, MapUpdCommonNodes;
local MapAddLargeNodes, MapDelLargeNodes, MapUpdLargeNodes;
local MapAddVariedNodes, MapDelVariedNodes, MapUpdVariedNodes;
local MapTemporarilyShowQuestNodes, MapTemporarilyHideQuestNodes, MapResetTemporarilyQuestNodesFilter;
local MapPermanentlyShowQuestNodes, MapPermanentlyHideQuestNodes, MapPermanentlyToggleQuestNodes;
local MapHideNodes, MapDrawNodes;
-- setting
local SetShowPinInContinent, SetNodeMenuModifier;
local SetWorldmapAlpha;
local SetWorldmapCommonPinSize, SetWorldmapLargePinSize, SetWorldmapVariedPinSize;
local SetMinimapAlpha;
local SetMinimapCommonPinSize, SetMinimapLargePinSize, SetMinimapVariedPinSize;
local SetMinimapNodeInset, SetMinimapPlayerArrowOnTop;
-->
--> -- Pin Handler
function Pin_OnEnter(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
local uuid = self.uuid;
local _type = uuid[1];
local _id = uuid[2];
MT.TooltipSetInfo(GameTooltip, _type, _id);
GameTooltip:Show();
end
local TomTom = nil;
function Pin_OnClick(self, button)
local uuid = self.uuid;
if uuid ~= nil then
if button == "RightButton" then
TomTom = TomTom or _G.TomTom;
local coord = self.coord;
if coord ~= nil and TomTom ~= nil then
local _type = uuid[1];
local _id = uuid[2];
local _loc = l10n[_type];
local uid = TomTom:AddWaypoint(coord[3], coord[1] * 0.01, coord[2] * 0.01, {
title = _loc ~= nil and _loc[_id] or (_type .. ":" .. _id),
persistent = false,
minimap = true,
world = true,
from = "CodexLite",
});
return TomTom:SetCrazyArrow(uid, TomTom.profile.arrow.arrival, uid.title or "TomTom waypoint");
end
end
if node_menu_modifier() then
if MT.NodeOnModifiedClick(self, uuid) then
return;
end
end
MT.RelColor3(uuid[3]);
uuid[3], uuid[6] = MT.GetColor3NextIndex(uuid[6]);
WorldMap_ChangeCommonLargeNodesMapUUID(wm_map, uuid);
Minimap_ChangeCommonLargeNodesMapUUID(mm_map, uuid);
end
end
-->
--> -- WorldMapFrame Pin
function NewWorldMapPin(__PIN_TAG, pool_inuse, pool_unused, size, Release, frameLevel)
local pin = next(pool_unused);
if pin == nil then
pin = CreateFrame('FRAME', nil, wm_wrap);
pin:SetScript("OnEnter", Pin_OnEnter);
pin:SetScript("OnLeave", MT.OnLeave);
pin:SetScript("OnMouseUp", Pin_OnClick);
pin:SetFrameLevel(frameLevel or CommonPinFrameLevel);
pin.Release = Release;
pin.__PIN_TAG = __PIN_TAG;
local icon = pin:CreateTexture(nil, "ARTWORK");
icon:SetAllPoints();
icon:SetTexture(CT.IMG_PATH_PIN);
pin.icon = icon;
else
pool_unused[pin] = nil;
end
pin:SetSize(size, size);
pool_inuse[pin] = 1;
return pin;
end
--
local pool_worldmap_common_pin_inuse = { };
local pool_worldmap_common_pin_unused = { };
function RelWorldMapCommonPin(pin)
pool_worldmap_common_pin_unused[pin] = 1;
pool_worldmap_common_pin_inuse[pin] = nil;
pin:Hide();
end
function AddWorldMapCommonPin(x, y, color3)
local pin = NewWorldMapPin(CT.TAG_WM_COMMON, pool_worldmap_common_pin_inuse, pool_worldmap_common_pin_unused, wm_normal_size, RelWorldMapCommonPin, CommonPinFrameLevel);
-- MapCanvasPinMixin:SetPosition(x, y)
-- >> MapCanvasMixin:SetPinPosition(pin, x, y)
-- >> MapCanvasMixin:ApplyPinPosition(pin, x, y) mainly implemented below
-- and lots of bullshit about 'nudge'
local rscale = 0.01 / pin:GetScale();
pin:SetPoint("CENTER", mapCanvas, "TOPLEFT", mapCanvas:GetWidth() * x * rscale, -mapCanvas:GetHeight() * y * rscale);
pin.icon:SetVertexColor(color3[1], color3[2], color3[3]);
pin:Show();
return pin;
end
--
local pool_worldmap_large_pin_inuse = { };
local pool_worldmap_large_pin_unused = { };
function RelWorldMapLargePin(pin)
pool_worldmap_large_pin_unused[pin] = 1;
pool_worldmap_large_pin_inuse[pin] = nil;
pin:Hide();
end
function AddWorldMapLargePin(x, y, color3)
local pin = NewWorldMapPin(CT.TAG_WM_LARGE, pool_worldmap_large_pin_inuse, pool_worldmap_large_pin_unused, wm_large_size, RelWorldMapLargePin, LargePinFrameLevel);
-- MapCanvasPinMixin:SetPosition(x, y)
-- >> MapCanvasMixin:SetPinPosition(pin, x, y)
-- >> MapCanvasMixin:ApplyPinPosition(pin, x, y) mainly implemented below
-- and lots of bullshit about 'nudge'
local rscale = 0.01 / pin:GetScale();
pin:SetPoint("CENTER", mapCanvas, "TOPLEFT", mapCanvas:GetWidth() * x * rscale, -mapCanvas:GetHeight() * y * rscale);
pin.icon:SetVertexColor(color3[1], color3[2], color3[3]);
pin:Show();
return pin;
end
--
local pool_worldmap_varied_pin_inuse = { };
local pool_worldmap_varied_pin_unused = { };
function RelWorldMapVariedPin(pin)
pool_worldmap_varied_pin_unused[pin] = 1;
pool_worldmap_varied_pin_inuse[pin] = nil;
pin:Hide();
end
function AddWorldMapVariedPin(x, y, color3, TEXTURE)
local texture = CT.IMG_LIST[TEXTURE] or CT.IMG_LIST[CT.IMG_INDEX.IMG_DEF];
local pin = NewWorldMapPin(CT.TAG_WM_VARIED, pool_worldmap_varied_pin_inuse, pool_worldmap_varied_pin_unused, wm_varied_size, RelWorldMapVariedPin, texture[7]);
pin:SetFrameLevel(texture[7]);
-- MapCanvasPinMixin:SetPosition(x, y)
-- >> MapCanvasMixin:SetPinPosition(pin, x, y)
-- >> MapCanvasMixin:ApplyPinPosition(pin, x, y) mainly implemented below
-- and lots of bullshit about 'nudge'
local rscale = 0.01 / pin:GetScale();
pin:SetPoint("CENTER", mapCanvas, "TOPLEFT", mapCanvas:GetWidth() * x * rscale, -mapCanvas:GetHeight() * y * rscale);
pin.icon:SetTexture(texture[1]);
pin.icon:SetVertexColor(texture[2] or color3[1] or 1.0, texture[3] or color3[2] or 1.0, texture[4] or color3[3] or 1.0);
-- if color3 ~= nil then
-- pin.icon:SetVertexColor(color3[1] or 1.0, color3[2] or 1.0, color3[3] or 1.0);
-- else
-- pin.icon:SetVertexColor(texture[2] or 1.0, texture[3] or 1.0, texture[4] or 1.0);
-- end
pin:Show();
return pin;
end
--
function IterateWorldMapPinSetSize()
for pin, _ in next, pool_worldmap_common_pin_inuse do
pin:SetSize(wm_normal_size, wm_normal_size);
end
for pin, _ in next, pool_worldmap_large_pin_inuse do
pin:SetSize(wm_large_size, wm_large_size);
end
for pin, _ in next, pool_worldmap_varied_pin_inuse do
pin:SetSize(wm_varied_size, wm_varied_size);
end
end
--
function ResetWMPin()
for pin, _ in next, pool_worldmap_common_pin_inuse do
pin:Release();
end
for pin, _ in next, pool_worldmap_large_pin_inuse do
pin:Release();
end
for pin, _ in next, pool_worldmap_varied_pin_inuse do
pin:Release();
end
__popt:reset(1);
__popt:reset(2);
__popt:reset(3);
end
-->
local function UUIDCheckState(uuid, val)
for quest, refs in next, uuid[4] do
local meta = __MAIN_META[quest];
if meta ~= nil and QUEST_TEMPORARILY_BLOCKED[quest] ~= true and QUEST_PERMANENTLY_BLOCKED[quest] ~= true then
for line, texture in next, refs do
if line == 'extra' then
return true;
end
local meta_line = meta[line];
if meta_line ~= nil and not meta_line[5] and texture == val then
return true;
end
end
end
end
return false;
end
local function UUIDCheckStateVaried(uuid)
for quest, refs in next, uuid[4] do
if QUEST_TEMPORARILY_BLOCKED[quest] ~= true and QUEST_PERMANENTLY_BLOCKED[quest] ~= true then
if refs['start'] ~= nil or refs['end'] ~= nil then
return true;
end
end
end
return false;
end
--> -- draw on WorldMap -- 当前地图每个点都要显示,所以大地图标记表存储为为数据元表的子表与coord一一对应
function WorldMap_HideCommonNodesMapUUID(map, uuid)
local meta = META_COMMON[map];
if meta ~= nil then
local data = meta[uuid];
if data ~= nil then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(1, -num_pins);
end
end
end
end
function WorldMap_HideLargeNodesMapUUID(map, uuid)
local large = META_LARGE[map];
if large ~= nil then
local data = large[uuid];
if data ~= nil then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(2, -num_pins);
end
end
end
end
function WorldMap_HideVariedNodesMapUUID(map, uuid)
local varied = META_VARIED[map];
if varied ~= nil then
local data = varied[uuid];
if data ~= nil then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(3, -num_pins);
end
end
end
end
function WorldMap_ChangeCommonLargeNodesMapUUID(map, uuid)
local color3 = uuid[3];
local meta = META_COMMON[map];
if meta ~= nil then
local data = meta[uuid];
if data ~= nil then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index].icon:SetVertexColor(color3[1], color3[2], color3[3]);
end
end
end
end
local large = META_LARGE[map];
if large ~= nil then
local data = large[uuid];
if data ~= nil then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index].icon:SetVertexColor(color3[1], color3[2], color3[3]);
end
end
end
end
end
function WorldMap_ChangeVariedNodesMapUUID(map, uuid)
local varied = META_VARIED[map];
if varied ~= nil then
local data = varied[uuid];
if data ~= nil then
local TEXTURE = uuid[5];
local pins = data[2];
for index = 1, #pins do
local pin = pins[index];
local texture = CT.IMG_LIST[TEXTURE] or CT.IMG_LIST[CT.IMG_INDEX.IMG_DEF];
pin.icon:SetTexture(texture[1]);
pin.icon:SetVertexColor(texture[2], texture[3], texture[4]);
pin:SetFrameLevel(texture[7]);
end
end
end
end
function WorldMap_ShowNodesQuest(map, quest)
local meta = META_COMMON[map];
if meta ~= nil then
for uuid, data in next, meta do
if uuid[4][quest] ~= nil then
local coords = data[1];
local pins = data[2];
local color3 = uuid[3];
local num_coords = #coords;
local num_pins = #pins;
if num_pins < num_coords then
for index = num_pins + 1, num_coords do
local coord = coords[index];
local pin = AddWorldMapCommonPin(coord[1], coord[2], color3);
pins[index] = pin;
pin.uuid = uuid;
pin.coord = coord;
end
__popt:count(1, num_coords - num_pins);
end
end
end
end
local large = META_LARGE[map];
if large ~= nil then
for uuid, data in next, large do
if uuid[4][quest] ~= nil then
local coords = data[1];
local pins = data[2];
local color3 = uuid[3];
local num_coords = #coords;
local num_pins = #pins;
if num_pins < num_coords then
for index = num_pins + 1, num_coords do
local coord = coords[index];
local pin = AddWorldMapLargePin(coord[1], coord[2], color3);
pins[index] = pin;
pin.uuid = uuid;
pin.coord = coord;
end
__popt:count(2, num_coords - num_pins);
end
end
end
end
local varied = META_VARIED[map];
if varied ~= nil then
for uuid, data in next, varied do
if uuid[4][quest] ~= nil then
local coords = data[1];
local pins = data[2];
local color3 = uuid[3];
local TEXTURE = uuid[5];
local num_coords = #coords;
local num_pins = #pins;
if num_pins < num_coords then
for index = num_pins + 1, num_coords do
local coord = coords[index];
local pin = AddWorldMapVariedPin(coord[1], coord[2], color3, TEXTURE);
pins[index] = pin;
pin.uuid = uuid;
pin.coord = coord;
end
__popt:count(3, num_coords - num_pins);
end
end
end
end
end
function WorldMap_HideNodesQuest(map, quest)
local meta = META_COMMON[map];
if meta ~= nil then
for uuid, data in next, meta do
if not UUIDCheckState(uuid, -9998) then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(1, -num_pins);
end
end
end
end
local large = META_LARGE[map];
if large ~= nil then
for uuid, data in next, large do
if not UUIDCheckState(uuid, -9999) then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(2, -num_pins);
end
end
end
end
local varied = META_VARIED[map];
if varied ~= nil then
for uuid, data in next, varied do
if not UUIDCheckStateVaried(uuid) then
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(3, -num_pins);
end
end
end
end
end
function WorldMap_DrawNodesMap(map)
if not VT.SETTING.show_in_continent and CT.ContinentMapID[map] ~= nil then
return;
end
local meta = META_COMMON[map];
if meta ~= nil then
for uuid, data in next, meta do
if UUIDCheckState(uuid, -9998) then
local coords = data[1];
local pins = data[2];
local color3 = uuid[3];
local num_coords = #coords;
local num_pins = #pins;
if num_pins < num_coords then
for index = num_pins + 1, num_coords do
local coord = coords[index];
local pin = AddWorldMapCommonPin(coord[1], coord[2], color3);
pins[index] = pin;
pin.uuid = uuid;
pin.coord = coord;
end
__popt:count(1, num_coords - num_pins);
end
end
end
end
local large = META_LARGE[map];
if large ~= nil then
for uuid, data in next, large do
if UUIDCheckState(uuid, -9999) then
local coords = data[1];
local pins = data[2];
local color3 = uuid[3];
local num_coords = #coords;
local num_pins = #pins;
if num_pins < num_coords then
for index = num_pins + 1, num_coords do
local coord = coords[index];
local pin = AddWorldMapLargePin(coord[1], coord[2], color3);
pins[index] = pin;
pin.uuid = uuid;
pin.coord = coord;
end
__popt:count(2, num_coords - num_pins);
end
end
end
end
local varied = META_VARIED[map];
if varied ~= nil then
for uuid, data in next, varied do
if UUIDCheckStateVaried(uuid) then
local coords = data[1];
local pins = data[2];
local color3 = uuid[3];
local TEXTURE = uuid[5];
local num_coords = #coords;
local num_pins = #pins;
if num_pins < num_coords then
for index = num_pins + 1, num_coords do
local coord = coords[index];
local pin = AddWorldMapVariedPin(coord[1], coord[2], color3, TEXTURE);
pins[index] = pin;
pin.uuid = uuid;
pin.coord = coord;
end
__popt:count(3, num_coords - num_pins);
end
end
end
end
end
function WorldMap_HideNodesMap(map)
local meta = META_COMMON[map];
if meta ~= nil then
for uuid, data in next, meta do
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(1, -num_pins);
end
end
end
local large = META_LARGE[map];
if large ~= nil then
for uuid, data in next, large do
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(2, -num_pins);
end
end
end
local varied = META_VARIED[map];
if varied ~= nil then
for uuid, data in next, varied do
local pins = data[2];
local num_pins = #pins;
if num_pins > 0 then
for index = 1, num_pins do
pins[index]:Release();
end
data[2] = { };
__popt:count(3, -num_pins);
end
end
end
end
-->
--> -- Minimap Pin
function NewMinimapPin(__PIN_TAG, pool_inuse, pool_unused, size, Release, frameLevel)
local pin = next(pool_unused);
if pin == nil then
pin = CreateFrame('FRAME', nil, mm_wrap);
pin:SetScript("OnEnter", Pin_OnEnter);
pin:SetScript("OnLeave", MT.OnLeave);
pin:SetScript("OnMouseUp", Pin_OnClick);
pin.Release = Release;
pin.__PIN_TAG = __PIN_TAG;
local icon = pin:CreateTexture(nil, "ARTWORK");
icon:SetAllPoints();
icon:SetTexture(CT.IMG_PATH_PIN);
pin.icon = icon;
else
pool_unused[pin] = nil;
end
pin:SetSize(size, size);
pin:SetFrameLevel(frameLevel or CommonPinFrameLevel);
pool_inuse[pin] = 1;
return pin;
end
--
local pool_minimap_pin_inuse = { };
local pool_minimap_pin_unused = { };
function RelMinimapPin(pin)
pool_minimap_pin_unused[pin] = 1;
pool_minimap_pin_inuse[pin] = nil;
pin:Hide();
end
function AddMinimapPin(__PIN_TAG, img, r, g, b, size, frameLevel)
local pin = NewMinimapPin(__PIN_TAG, pool_minimap_pin_inuse, pool_minimap_pin_unused, size, RelMinimapPin, frameLevel);
-- MapCanvasPinMixin:SetPosition(x, y)
-- >> MapCanvasMixin:SetPinPosition(pin, x, y)
-- >> MapCanvasMixin:ApplyPinPosition(pin, x, y) mainly implemented below
-- and lots of bullshit about 'nudge'
pin.icon:SetTexture(img);
pin.icon:SetVertexColor(r, g, b);
pin:Show();
return pin;
end
--
function ResetMMPin()
for pin, _ in next, pool_minimap_pin_inuse do
pin:Release();
end
__popt:reset(4);
end
-->
--> -- draw on Minimap -- 只有少部分点显示在小地图,所以单独建表
-- variables
local minimap_size = {
indoor = {
[0] = 300, -- scale
[1] = 240, -- 1.25
[2] = 180, -- 5/3
[3] = 120, -- 2.5
[4] = 80, -- 3.75
[5] = 50, -- 6
},
outdoor = {
[0] = 466 + 2/3, -- scale
[1] = 400, -- 7/6
[2] = 333 + 1/3, -- 1.4
[3] = 266 + 2/6, -- 1.75
[4] = 200, -- 7/3
[5] = 133 + 1/3, -- 3.5
},
};
local mm_check_func_table = {
CIRCLE = function(dx, dy, range)
return dx * dx + dy * dy < range * range;
end,
};
local mm_shape = "CIRCLE";
local GetMinimapShape = _G.GetMinimapShape;
if GetMinimapShape ~= nil then
mm_shape = GetMinimapShape() or "CIRCLE";
else
mm_shape = "CIRCLE";
end
local mm_indoor = GetCVar("minimapZoom") + 0 == Minimap:GetZoom() and "outdoor" or "indoor";
local mm_zoom = Minimap:GetZoom();
local mm_hsize = minimap_size[mm_indoor][mm_zoom] * 0.5;
local mm_hheight = Minimap:GetHeight() * 0.5;
local mm_hwidth = Minimap:GetWidth() * 0.5;
local mm_is_rotate = GetCVar("rotateMinimap") == "1";
local mm_rotate = GetPlayerFacing();
local mm_rotate_sin = mm_rotate ~= nil and _radius_sin(mm_rotate) or nil;
local mm_rotate_cos = mm_rotate ~= nil and _radius_cos(mm_rotate) or nil;
local mm_check_func = mm_check_func_table[mm_shape];
local mm_force_update = false;
local mm_player_map, mm_player_x, mm_player_y = MT.GetUnitPosition('player');
if mm_player_y == nil then mm_player_y = 0.0; end
if mm_player_x == nil then mm_player_x = 0.0; end
local mm_dynamic_update_interval = 0.05;
--
local mm_arrow_wrap = CreateFrame('FRAME', nil, Minimap);
mm_arrow_wrap:SetSize(1, 1);
mm_arrow_wrap:SetPoint("CENTER");
mm_arrow_wrap:EnableMouse(false);
mm_arrow_wrap:SetFrameLevel(9999);
local mm_arrow = mm_arrow_wrap:CreateTexture(nil, "OVERLAY", nil, 7);
mm_arrow:SetSize(24, 24);
mm_arrow:SetPoint("CENTER");
mm_arrow:SetTexture([[Interface\Minimap\MinimapArrow]]);
hooksecurefunc(Minimap, "SetPlayerTexture", function(_, Texture)
mm_arrow:SetTexture(Texture);
end);
mm_arrow_wrap:SetScript("OnUpdate", function()
if mm_is_rotate then
mm_arrow:SetTexCoord(0.0, 1.0, 0.0, 1.0);
else
local facing = GetPlayerFacing();
if facing ~= nil then
mm_arrow:Show();
local r = facing - 0.78539816339745; -- rad(45)
local c = _radius_cos(r) * 0.70710678118655; -- sqrt(0.5)
local s = _radius_sin(r) * 0.70710678118655; -- sqrt(0.5)
mm_arrow:SetTexCoord(
0.5 + c, 0.5 - s,
0.5 - s, 0.5 - c,
0.5 + s, 0.5 + c,
0.5 - c, 0.5 + s
);
else
mm_arrow:Hide();
end
end
end);
function Minimap_HideCommonNodesMapUUID(map, uuid)
local num_changed = 0;
local meta = META_COMMON[map];
if meta ~= nil then
local data = meta[uuid];
if data ~= nil then
local coords = data[1];
for index = 1, #coords do
local coord = coords[index];
local pin = MM_COMMON_PINS[coord];
if pin ~= nil then
pin:Release();
MM_COMMON_PINS[coord] = nil;
num_changed = num_changed - 1;
end
end
end
end
if num_changed ~= 0 then
__popt:count(4, num_changed);
end
end
function Minimap_HideLargeNodesMapUUID(map, uuid)
local num_changed = 0;
local large = META_LARGE[map];
if large ~= nil then
local data = large[uuid];
if data ~= nil then
local coords = data[1];
for index = 1, #coords do
local coord = coords[index];
local pin = MM_LARGE_PINS[coord];
if pin ~= nil then
pin:Release();
MM_LARGE_PINS[coord] = nil;
num_changed = num_changed - 1;
end
end
end
end
if num_changed ~= 0 then
__popt:count(4, num_changed);
end
end
function Minimap_HideVariedNodesMapUUID(map, uuid)
local num_changed = 0;
local varied = META_VARIED[map];
if varied ~= nil then
local data = varied[uuid];
if data ~= nil then
local coords = data[1];
for index = 1, #coords do
local coord = coords[index];
local pin = MM_VARIED_PINS[coord];
if pin ~= nil then
pin:Release();
MM_VARIED_PINS[coord] = nil;
num_changed = num_changed - 1;
end
end
end
end
if num_changed ~= 0 then
__popt:count(4, num_changed);
end
end
function Minimap_ChangeCommonLargeNodesMapUUID(map, uuid)
local color3 = uuid[3];
local meta = META_COMMON[map];
if meta ~= nil then
local data = meta[uuid];
if data ~= nil then
local coords = data[1];
for index = 1, #coords do
local pin = MM_COMMON_PINS[coords[index]];
if pin ~= nil then
pin.icon:SetVertexColor(color3[1], color3[2], color3[3]);
end
end
end
end
local large = META_LARGE[map];
if large ~= nil then
local data = large[uuid];
if data ~= nil then
local coords = data[1];
for index = 1, #coords do
local pin = MM_LARGE_PINS[coords[index]];
if pin ~= nil then
pin.icon:SetVertexColor(color3[1], color3[2], color3[3]);
end
end
end
end
end
function Minimap_ChangeVariedNodesMapUUID(map, uuid)
local varied = META_VARIED[mm_map];
if varied ~= nil then
local data = varied[uuid];
if data ~= nil then
local TEXTURE = uuid[5];
local coords = data[1];
for index = 1, #coords do
local coord = coords[index];
local texture = CT.IMG_LIST[TEXTURE] or CT.IMG_LIST[CT.IMG_INDEX.IMG_DEF];
local pin = MM_VARIED_PINS[coord];
if pin ~= nil then
pin.icon:SetTexture(texture[1]);
pin.icon:SetVertexColor(texture[2], texture[3], texture[4]);
pin:SetFrameLevel(texture[7]);
end
end
end
end
end
function Minimap_ShowNodesMapQuest(map, quest)
local Tick = MT.GetUnifiedTime();
local num_changed = 0;
local meta = META_COMMON[map];
if meta ~= nil then
for uuid, data in next, meta do
if uuid[4][quest] ~= nil then
local color3 = uuid[3];
local coords = data[1];
for index = 1, #coords do
local coord = coords[index];
local val = coord[5]; -- world
local dx = val[1] - mm_player_x;
local dy = val[2] - mm_player_y;
if dx > -mm_hsize and dx < mm_hsize and dy > -mm_hsize and dy < mm_hsize and (mm_check_func == nil or mm_check_func(dx, dy, mm_hsize)) then
local pin = MM_COMMON_PINS[coord];
if pin == nil then
pin = AddMinimapPin(CT.TAG_MM_COMMON, CT.IMG_PATH_PIN, color3[1], color3[2], color3[3], mm_normal_size, CommonPinFrameLevel);
MM_COMMON_PINS[coord] = pin;
num_changed = num_changed + 1;
else
pin.icon:SetTexture(CT.IMG_PATH_PIN);
pin.icon:SetVertexColor(color3[1], color3[2], color3[3]);
end
pin:ClearAllPoints();
if mm_is_rotate then
dx, dy = dx * mm_rotate_sin - dy * mm_rotate_cos, dx * mm_rotate_cos + dy * mm_rotate_sin;
end
pin:SetPoint("CENTER", Minimap, "CENTER", - mm_hwidth * dx / mm_hsize, mm_hheight * dy / mm_hsize);
-- transform from world-coord[bottomleft->topright] to UI-coord[bottomleft->topright]
pin.uuid = uuid;
-- pin.coord = coord;
else
local pin = MM_COMMON_PINS[coord];
if pin ~= nil then
pin:Release();
MM_COMMON_PINS[coord] = nil;
num_changed = num_changed - 1;
end
end
end
end
end
end
local large = META_LARGE[map];
if large ~= nil then
for uuid, data in next, large do
if uuid[4][quest] ~= nil then
local color3 = uuid[3];
local coords = data[1];
for index = 1, #coords do
local coord = coords[index];
local val = coord[5]; -- world
local dx = val[1] - mm_player_x;
local dy = val[2] - mm_player_y;
if dx > -mm_hsize and dx < mm_hsize and dy > -mm_hsize and dy < mm_hsize and (mm_check_func == nil or mm_check_func(dx, dy, mm_hsize)) then
local pin = MM_LARGE_PINS[coord];
if pin == nil then
pin = AddMinimapPin(CT.TAG_MM_LARGE, CT.IMG_PATH_PIN, color3[1], color3[2], color3[3], mm_large_size, LargePinFrameLevel);
MM_LARGE_PINS[coord] = pin;
num_changed = num_changed + 1;
else
pin.icon:SetTexture(CT.IMG_PATH_PIN);
pin.icon:SetVertexColor(color3[1], color3[2], color3[3]);
end
pin:ClearAllPoints();
if mm_is_rotate then
dx, dy = dx * mm_rotate_sin - dy * mm_rotate_cos, dx * mm_rotate_cos + dy * mm_rotate_sin;
end
pin:SetPoint("CENTER", Minimap, "CENTER", - mm_hwidth * dx / mm_hsize, mm_hheight * dy / mm_hsize);
-- transform from world-coord[bottomleft->topright] to UI-coord[bottomleft->topright]
pin.uuid = uuid;
-- pin.coord = coord;
else
local pin = MM_LARGE_PINS[coord];
if pin ~= nil then
pin:Release();
MM_LARGE_PINS[coord] = nil;
num_changed = num_changed - 1;
end
end
end
end
end
end
local varied = META_VARIED[map];
if varied ~= nil then
for uuid, data in next, varied do
if uuid[4][quest] ~= nil then
local color3 = uuid[3];
local TEXTURE = uuid[5];
local coords = data[1];
for index = 1, #coords do
local coord = coords[index];
local val = coord[5]; -- world
local dx = val[1] - mm_player_x;
local dy = val[2] - mm_player_y;
if dx > -mm_hsize and dx < mm_hsize and dy > -mm_hsize and dy < mm_hsize and (mm_check_func == nil or mm_check_func(dx, dy, mm_hsize)) then
local pin = MM_VARIED_PINS[coord];
local texture = CT.IMG_LIST[TEXTURE] or CT.IMG_LIST[CT.IMG_INDEX.IMG_DEF];
if pin == nil then
pin = AddMinimapPin(CT.TAG_MM_VARIED, texture[1], texture[2] or color3[1], texture[3] or color3[2], texture[4] or color3[3], mm_varied_size, texture[7]);
MM_VARIED_PINS[coord] = pin;
num_changed = num_changed + 1;
else
pin.icon:SetTexture(texture[1]);
pin.icon:SetVertexColor(texture[2], texture[3], texture[4]);
end
pin:ClearAllPoints();
if mm_is_rotate then
dx, dy = dx * mm_rotate_sin - dy * mm_rotate_cos, dx * mm_rotate_cos + dy * mm_rotate_sin;
end