-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIPCore.lua
executable file
·210 lines (162 loc) · 5.91 KB
/
IPCore.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
local IPUIDebug=false
function InstancePortalUI_OnLoad(self)
local LoadAddOn = C_AddOns.LoadAddOn or LoadAddOn
LoadAddOn("Blizzard_WorldMap")
self:RegisterEvent("ADDON_LOADED")
IPUIPrintDebug("InstancePortalUI_OnLoad()")
WorldMapFrame:AddDataProvider(CreateFromMixins(IPInstancePortalMapDataProviderMixin));
hooksecurefunc("ToggleDropDownMenu", IPUIDropDownInit)
end
function InstancePortalUI_OnEvent(event, arg1)
if event == "ADDON_LOADED" then
if IPUITrackInstancePortals == nil then
IPUIPrintDebug("IPUISetDefaults()")
IPUITrackInstancePortals = true
IPUITrackInstancePortalsOnContinents = true
end
IPUIPrintDebug("ADDON_LOADED()")
RegisterCVar("IPUITrackInstancePortals")
RegisterCVar("IPUITrackInstancePortalsOnContinents")
end
end
function IPUIDropDownInit(_, _, dropDownFrame, _, _, _, _, clickedButton)
local trackingOptionsFrame = WorldMapFrame.overlayFrames[2]
local trackingOptionsMenu = trackingOptionsFrame.DropDown
local _, _, _, tocVersion = GetBuildInfo()
--Quick fix for issue with Skada and others
if tocVersion >= 110000 then
return
end
IPUIPrintDebug("IPUIDropDownInit")
local function OnSelection(button)
if button.value == "IPUITrackInstancePortals" then
IPUITrackInstancePortals = button.checked
else
IPUITrackInstancePortalsOnContinents = button.checked
end
SetCVar(button.value, button.checked and "1" or "0", "INSTANCE_PORTAL_REFRESH");
end
if dropDownFrame == trackingOptionsMenu then
local info = UIDropDownMenu_CreateInfo();
UIDropDownMenu_AddSeparator();
info.isTitle = true;
info.notCheckable = true;
info.text = DUNGEONS.." / "..RAIDS;
info.isNotRadio = true;
UIDropDownMenu_AddButton(info);
info = UIDropDownMenu_CreateInfo();
info.isTitle = nil;
info.notCheckable = nil;
info.text = "Show on Zone Map"; --BATTLEFIELD_MINIMAP
info.isNotRadio = true;
info.checked = IPUITrackInstancePortals;
info.func = OnSelection;
info.keepShownOnClick = true;
info.value = "IPUITrackInstancePortals";
--UIDropDownMenu_AddButton(info);
info = UIDropDownMenu_CreateInfo();
info.isTitle = nil;
info.notCheckable = nil;
info.text = "Show on Continent Map"; --WORLD_MAP
info.isNotRadio = true;
info.checked = IPUITrackInstancePortalsOnContinents;
info.func = OnSelection;
info.keepShownOnClick = true;
info.value = "IPUITrackInstancePortalsOnContinents";
UIDropDownMenu_AddButton(info);
end
end
function IPUIPrintDebug(t)
if (IPUIDebug) then
print("IPUIDEBUG - "..t)
end
end
function IPUIGetEntranceInfoForMapID(mapID, i)
IPUIPrintDebug("IPUIGetEntranceInfoForMapID:"..mapID)
instancePortal = IPUIPinDB[mapID][i]
if not (instancePortal) then
IPUIPrintDebug("No instances for map: "..mapID)
return nil
end
local x = instancePortal[1]/100
local y = instancePortal[2]/100
local subInstanceMapIDs = instancePortal[3]
local hubName = instancePortal[4]
local factionWhitelist = nil
local desired_IPUIInstanceMapDB = IPUIInstanceMapDB;
local playerFaction = UnitFactionGroup("player")
if hubName == "FactionSpecific" then
IPUIPrintDebug("FactionSpecific for map: "..mapID)
factionWhitelist = playerFaction;
desired_IPUIInstanceMapDB = IPUIInstanceFactionSpecificDB[factionWhitelist];
hubName = nil
elseif hubName == "Alliance" or hubName == "Horde" then
IPUIPrintDebug("HubName:"..hubName.." for map: "..mapID)
factionWhitelist = hubName;
desired_IPUIInstanceMapDB = IPUIInstanceFactionSpecificDB[factionWhitelist];
hubName = nil
end
IPUIPrintDebug("A")
if hubName then
entranceInfo = {};
entranceInfo["areaPoiID"] = C_AreaPoiInfo.GetAreaPOIForMap(mapID)[0];
entranceInfo["position"] = CreateVector2D(x, y);
entranceInfo["name"] = hubName;
local description = "";
local dungeonCount = 0
local raidCount = 0
for m = 1, #subInstanceMapIDs do
local instanceID = subInstanceMapIDs[m]
local localizedName = EJ_GetInstanceInfo(instanceID);
local requiredLevel = desired_IPUIInstanceMapDB[subInstanceMapIDs[m]][3]
local dungonType = desired_IPUIInstanceMapDB[subInstanceMapIDs[m]][2];
if dungonType == 1 then
dungeonCount=dungeonCount+1
description = description..localizedName.." |cFF888888("..LFG_TYPE_DUNGEON..")|r\n"
else
raidCount=raidCount+1
description = description..localizedName.." |cFF888888("..LFG_TYPE_RAID..")|r\n"
end
end
entranceInfo["description"] = description;
if dungeonCount > raidCount then
entranceInfo["atlasName"] = "Dungeon";
else
entranceInfo["atlasName"] = "Raid";
end
entranceInfo["journalInstanceID"] = 0;
entranceInfo["hub"] = 1;
entranceInfo["factionWhitelist"] = factionWhitelist;
IPUIPrintDebug("Hub: " .. entranceInfo["name"]);
return entranceInfo
end
IPUIPrintDebug("B")
local m = 1
if desired_IPUIInstanceMapDB[subInstanceMapIDs[m]] then
local name = desired_IPUIInstanceMapDB[subInstanceMapIDs[m]][1]
local type = desired_IPUIInstanceMapDB[subInstanceMapIDs[m]][2]
local requiredLevel = desired_IPUIInstanceMapDB[subInstanceMapIDs[m]][3]
local tier = desired_IPUIInstanceMapDB[subInstanceMapIDs[m]][4]
entranceInfo = {};
entranceInfo["areaPoiID"] = C_AreaPoiInfo.GetAreaPOIForMap(mapID)[0];
entranceInfo["position"] = CreateVector2D(x, y);
if (type == 1) then
entranceInfo["atlasName"] = "Dungeon";
entranceInfo["description"] = LFG_TYPE_DUNGEON;
else
entranceInfo["atlasName"] = "Raid";
entranceInfo["description"] = LFG_TYPE_RAID;
end
EJ_SelectTier(tier)
local instanceID = subInstanceMapIDs[m]
local localizedName = EJ_GetInstanceInfo(instanceID);
entranceInfo["name"] = localizedName.."|r";
entranceInfo["journalInstanceID"] = instanceID;
entranceInfo["tier"] = tier;
entranceInfo["hub"] = 0;
entranceInfo["factionWhitelist"] = factionWhitelist;
IPUIPrintDebug("Instance: " .. entranceInfo["name"].." id:"..instanceID);
return entranceInfo
end
IPUIPrintDebug("C")
end