vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- Global Channel Variable |
2 | CT_CHAT_CHANNEL = "CTGlobalChat"; |
||
3 | CT_UserMap_Notes = { }; |
||
4 | CT_UserMap_Zone = { }; |
||
5 | CT_UserMap_Zone["Blackrock Spire"] = 4; |
||
6 | CT_UserMap_Zone["Alterac Mountains"] = 1; |
||
7 | CT_UserMap_Zone["Arathi Highlands"] = 2; |
||
8 | CT_UserMap_Zone["Badlands"] = 3; |
||
9 | CT_UserMap_Zone["Blasted Lands"] = 5; |
||
10 | CT_UserMap_Zone["Tirisfal Glades"] = 6; |
||
11 | CT_UserMap_Zone["Silverpine Forest"] = 7; |
||
12 | CT_UserMap_Zone["Western Plaguelands"] = 8; |
||
13 | CT_UserMap_Zone["Eastern Plaguelands"] = 9; |
||
14 | CT_UserMap_Zone["Hillsbrad Foothills"] = 10; |
||
15 | CT_UserMap_Zone["The Hinterlands"] = 11; |
||
16 | CT_UserMap_Zone["Dun Morogh"] = 12; |
||
17 | CT_UserMap_Zone["Searing Gorge"] = 13; |
||
18 | CT_UserMap_Zone["Burning Steppes"] = 14; |
||
19 | CT_UserMap_Zone["Elwynn Forest"] = 15; |
||
20 | CT_UserMap_Zone["Darrowmere Lake"] = 16; |
||
21 | CT_UserMap_Zone["Deadwind Pass"] = 17; |
||
22 | CT_UserMap_Zone["Duskwood"] = 18; |
||
23 | CT_UserMap_Zone["Loch Modan"] = 19; |
||
24 | CT_UserMap_Zone["Redridge Mountains"] = 20; |
||
25 | CT_UserMap_Zone["Stranglethorn Vale"] = 21; |
||
26 | CT_UserMap_Zone["Swamp of Sorrows"] = 22; |
||
27 | CT_UserMap_Zone["Westfall"] = 23; |
||
28 | CT_UserMap_Zone["Wetlands"] = 24; |
||
29 | CT_UserMap_Zone["Stonetalon Mountains"] = 25; |
||
30 | CT_UserMap_Zone["Dustwallow Marsh"] = 26; |
||
31 | CT_UserMap_Zone["Feralas"] = 27; |
||
32 | CT_UserMap_Zone["Tanaris"] = 28; |
||
33 | CT_UserMap_Zone["Durotar"] = 29; |
||
34 | CT_UserMap_Zone["Mulgore"] = 30; |
||
35 | CT_UserMap_Zone["The Barrens"] = 31; |
||
36 | CT_UserMap_Zone["Teldrassil"] = 32; |
||
37 | CT_UserMap_Zone["Darkshore"] = 33; |
||
38 | CT_UserMap_Zone["Ashenvale"] = 34; |
||
39 | CT_UserMap_Zone["Desolace"] = 35; |
||
40 | CT_UserMap_Zone["Thousand Needles"] = 36; |
||
41 | CT_UserMap_Zone["Azshara"] = 37; |
||
42 | CT_UserMap_Zone["Felwood"] = 38; |
||
43 | CT_UserMap_Zone["Un'Goro Crater"] = 39; |
||
44 | CT_UserMap_Zone["Moonglade"] = 40; |
||
45 | CT_UserMap_Zone["Stormwind City"] = 41; |
||
46 | CT_UserMap_Zone["Ironforge"] = 42; |
||
47 | CT_UserMap_Zone["Undercity"] = 43; |
||
48 | CT_UserMap_Zone["Darnassus"] = 44; |
||
49 | CT_UserMap_Zone["Durotar"] = 45; |
||
50 | CT_UserMap_Zone["Orgrimmar"] = 46; |
||
51 | CT_UserMap_Zone["Silithus"] = 47; |
||
52 | CT_UserMap_Zone["Thunder Bluff"] = 48; |
||
53 | CT_UserMap_Zone["Winterspring"] = 49; |
||
54 | CT_MapMod_Options = { }; |
||
55 | |||
56 | CT_UserMap_Icons = { "GreyNote", "BlueShield", "RedDot", "WhiteCircle", "GreenSquare", "RedCross", "Herb", "Ore" }; |
||
57 | CT_UserMap_HerbIcons = { |
||
58 | "Herb_Bruiseweed", "Herb_ArthasTears", "Herb_BlackLotus", "Herb_Blindweed", "Herb_Briarthorn", |
||
59 | "Herb_Dreamfoil", "Herb_Earthroot", "Herb_Fadeleaf", "Herb_Firebloom", "Herb_GhostMushroom", |
||
60 | "Herb_GoldenSansam", "Herb_Goldthorn", "Herb_GraveMoss", "Herb_Gromsblood", "Herb_Icecap", |
||
61 | "Herb_KhadgarsWhisker", "Herb_Kingsblood", "Herb_Liferoot", "Herb_Mageroyal", "Herb_MountainSilversage", |
||
62 | "Herb_Peacebloom", "Herb_Plaguebloom", "Herb_PurpleLotus", "Herb_Silverleaf", "Herb_Stranglekelp", |
||
63 | "Herb_Sungrass", "Herb_Swiftthistle", "Herb_WildSteelbloom", "Herb_Wintersbite", "Ore_CopperVein", |
||
64 | "Ore_GoldVein", "Ore_IronVein", "Ore_MithrilVein", "Ore_SilverVein", "Ore_ThoriumVein", "Ore_TinVein", "Ore_TruesilverVein" |
||
65 | }; |
||
66 | |||
67 | |||
68 | CT_NUM_USERMAP_NOTES = 250; |
||
69 | CT_UserMap_CreateNote = 1; |
||
70 | CT_LastMessage = {}; |
||
71 | |||
72 | CT_Hooked_WorldMapButton_OnClick = WorldMapButton_OnClick; |
||
73 | function CT_WorldMapButton_OnClickHook(mouseButton, button) |
||
74 | if ( mouseButton == "LeftButton" ) then |
||
75 | if ( not button ) then |
||
76 | button = this; |
||
77 | end |
||
78 | local zone = WorldMapZoneDropDownText:GetText(); |
||
79 | local cX, cY = GetCursorPosition(); |
||
80 | local ceX, ceY = WorldMapFrame:GetCenter(); |
||
81 | local wmfw, wmfh = WorldMapButton:GetWidth(), WorldMapButton:GetHeight(); |
||
82 | |||
83 | cX = ( ( ( cX / WorldMapFrame:GetScale() ) - ( ceX - wmfw / 2 ) ) / wmfw + 22/10000 ); |
||
84 | cY = ( ( ( ( ceY + wmfh / 2 ) - ( cY / WorldMapFrame:GetScale() ) ) / wmfh ) - 262/10000 ); |
||
85 | |||
86 | local zone = WorldMapZoneDropDownText:GetText(); |
||
87 | |||
88 | if ( IsControlKeyDown() ) then |
||
89 | local id = CT_MapMod_AddNote(cX, cY, zone, "New note", "", 1, 1); |
||
90 | CT_UserMap_OptionsMenu.note = id; |
||
91 | CT_UserMap_OptionsMenu.zone = zone; |
||
92 | CT_UserMap_OptionsMenu:Show(); |
||
93 | else |
||
94 | CT_Hooked_WorldMapButton_OnClick(mouseButton, button); |
||
95 | end |
||
96 | else |
||
97 | CT_Hooked_WorldMapButton_OnClick(mouseButton, button); |
||
98 | end |
||
99 | end |
||
100 | |||
101 | function CT_MapMod_CreateNoteOnPlayer() |
||
102 | local x, y = GetPlayerMapPosition("player"); |
||
103 | if ( x ~= 0 and y ~= 0 ) then |
||
104 | local id = CT_MapMod_AddNote(x, y, WorldMapZoneDropDownText:GetText(), "New note", "", 1, 1); |
||
105 | CT_UserMap_OptionsMenu.note = id; |
||
106 | CT_UserMap_OptionsMenu.zone = WorldMapZoneDropDownText:GetText(); |
||
107 | CT_UserMap_OptionsMenu:Show(); |
||
108 | end |
||
109 | end |
||
110 | |||
111 | WorldMapButton_OnClick = CT_WorldMapButton_OnClickHook; |
||
112 | |||
113 | CT_Hooked_WorldMapButton_OnUpdate = WorldMapButton_OnUpdate; |
||
114 | function CT_WorldMapButton_OnUpdateHook(arg) |
||
115 | CT_Hooked_WorldMapButton_OnUpdate(arg); |
||
116 | local i, y = 0; |
||
117 | |||
118 | |||
119 | if ( not CT_UserMap_Notes[WorldMapZoneDropDownText:GetText()] ) then |
||
120 | for i = 1, CT_NUM_USERMAP_NOTES, 1 do |
||
121 | getglobal("CT_UserMap_Note" .. i):Hide(); |
||
122 | end |
||
123 | CT_NumNotes:SetText("Map Notes: |c00FFFFFF0|r/|c00FFFFFF250|r"); |
||
124 | return; |
||
125 | end |
||
126 | |||
127 | -- Calculate what notes to show |
||
128 | local y = 1; |
||
129 | for i, var in CT_UserMap_Notes[WorldMapZoneDropDownText:GetText()] do |
||
130 | if ( y > CT_NUM_USERMAP_NOTES ) then |
||
131 | break; |
||
132 | end |
||
133 | if ( not CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].hideGroups[CT_MAPMOD_SETS[(var.set or 1)]] and ( not CT_MapMod_Filter or string.find(strlower(var.name), strlower(CT_MapMod_Filter)) or string.find(strlower(var.descript), strlower(CT_MapMod_Filter)) ) ) then |
||
134 | local note = getglobal("CT_UserMap_Note" .. y); |
||
135 | local IconTexture = getglobal("CT_UserMap_Note" .. y .."Icon"); |
||
136 | |||
137 | if ( var.set == 7 or var.set == 8 ) then |
||
138 | local offset = 0; |
||
139 | if ( var.set == 8 ) then |
||
140 | offset = 29; |
||
141 | end |
||
142 | if ( CT_UserMap_HerbIcons[var.icon+offset] ) then |
||
143 | IconTexture:SetTexture("Interface\\AddOns\\CT_MapMod\\Resource\\" .. CT_UserMap_HerbIcons[var.icon+offset]); |
||
144 | else |
||
145 | IconTexture:SetTexture("Interface\\AddOns\\CT_MapMod\\Resource\\Herb_Bruiseweed"); |
||
146 | end |
||
147 | else |
||
148 | IconTexture:SetTexture("Interface\\AddOns\\CT_MapMod\\Skin\\" .. CT_UserMap_Icons[var.set]); |
||
149 | end |
||
150 | note:SetPoint("CENTER", "WorldMapDetailFrame", "TOPLEFT", var.x*WorldMapButton:GetWidth(), -var.y*WorldMapButton:GetHeight()); |
||
151 | note:Show(); |
||
152 | |||
153 | if ( not var.name ) then var.name = ""; end |
||
154 | if ( not var.set or not CT_MAPMOD_SETS[var.set] ) then var.set = 1; end |
||
155 | if ( not var.descript ) then var.descript = ""; end |
||
156 | |||
157 | note.name = var.name; |
||
158 | note.set = CT_MAPMOD_SETS[var.set]; |
||
159 | note.descript = var.descript; |
||
160 | note.id = i; |
||
161 | note.x = var.x; |
||
162 | note.y = var.y; |
||
163 | y = y + 1; |
||
164 | end |
||
165 | end |
||
166 | CT_NumNotes:SetText("Map Notes: |c00FFFFFF" .. y-1 .. "|r/|c00FFFFFF250|r"); |
||
167 | for i = y, CT_NUM_USERMAP_NOTES, 1 do |
||
168 | getglobal("CT_UserMap_Note" .. i):Hide(); |
||
169 | end |
||
170 | end |
||
171 | WorldMapButton_OnUpdate = CT_WorldMapButton_OnUpdateHook; |
||
172 | |||
173 | function CT_MapMod_AddNote(x, y, zone, text, descript, icon, set) |
||
174 | local group; |
||
175 | if ( tonumber(set) ) then |
||
176 | group = tonumber(set); |
||
177 | else |
||
178 | group = set; |
||
179 | end |
||
180 | if ( not CT_UserMap_Notes[zone] ) then |
||
181 | CT_UserMap_Notes[zone] = { }; |
||
182 | end |
||
183 | local temp = { ["x"] = x, ["y"] = y, ["name"] = text, ["descript"] = descript, ["icon"] = icon, ["set"] = group }; |
||
184 | tinsert(CT_UserMap_Notes[zone], temp); |
||
185 | return getn(CT_UserMap_Notes[zone]); |
||
186 | end |
||
187 | |||
188 | function CT_MapMod_OnNoteOver() |
||
189 | local x, y = this:GetCenter(); |
||
190 | local parentX, parentY = WorldMapButton:GetCenter(); |
||
191 | if ( x > parentX ) then |
||
192 | WorldMapTooltip:SetOwner(this, "ANCHOR_LEFT"); |
||
193 | else |
||
194 | WorldMapTooltip:SetOwner(this, "ANCHOR_RIGHT"); |
||
195 | end |
||
196 | WorldMapTooltip:ClearLines(); |
||
197 | |||
198 | WorldMapTooltip:AddDoubleLine(this.name, this.set, 0, 1, 0, 0.6, 0.6, 0.6); |
||
199 | if ( this.descript ) then |
||
200 | WorldMapTooltip:AddLine(this.descript, nil, nil, nil, 1); |
||
201 | end |
||
202 | WorldMapTooltip:Show(); |
||
203 | end |
||
204 | |||
205 | function CT_MapMod_OnClick(btn) |
||
206 | if ( btn == "LeftButton" ) then return; end |
||
207 | CT_UserMap_OptionsMenu.note = this.id; |
||
208 | CT_UserMap_OptionsMenu.zone = WorldMapZoneDropDownText:GetText(); |
||
209 | CT_UserMap_OptionsMenu:Show(); |
||
210 | end |
||
211 | |||
212 | function CT_MapMod_OptionsMenu_OnShow() |
||
213 | CT_UserMapFrame:Hide(); |
||
214 | if ( not UIDROPDOWNMENU_OPEN_MENU ) then |
||
215 | UIDROPDOWNMENU_OPEN_MENU = "CT_UserMap_OptionsMenuGroupDropDown"; |
||
216 | end |
||
217 | local note = CT_UserMap_Notes[this.zone][this.note]; |
||
218 | CT_UserMap_OptionsMenuNameEB:SetText(note["name"]); |
||
219 | CT_UserMap_OptionsMenuNameEB:HighlightText(); |
||
220 | CT_UserMap_OptionsMenuDescriptEB:SetText(note["descript"]); |
||
221 | CT_UserMap_OptionsMenuSendButton:Disable(); |
||
222 | CT_UserMap_OptionsMenuSendEB.lastsend = ""; |
||
223 | CT_UserMap_OptionsMenuSendEB:SetText(""); |
||
224 | |||
225 | PlaySound("UChatScrollButton"); |
||
226 | end |
||
227 | |||
228 | function CT_MapMod_UpdateNote() |
||
229 | local name, descript, set, icon; |
||
230 | name = CT_UserMap_OptionsMenuNameEB:GetText(); |
||
231 | descript = CT_UserMap_OptionsMenuDescriptEB:GetText(); |
||
232 | icon = CT_UserMap_Notes[this:GetParent().zone][this:GetParent().note]["icon"]; |
||
233 | |||
234 | if ( UIDropDownMenu_GetSelectedName(CT_UserMap_OptionsMenuGroupDropDown) ) then |
||
235 | set = CT_UserMap_Notes[this:GetParent().zone][this:GetParent().note]["set"]; |
||
236 | else |
||
237 | set = UIDropDownMenu_GetSelectedID(CT_UserMap_OptionsMenuGroupDropDown); |
||
238 | end |
||
239 | |||
240 | |||
241 | CT_UserMap_Notes[this:GetParent().zone][this:GetParent().note]["name"] = name; |
||
242 | CT_UserMap_Notes[this:GetParent().zone][this:GetParent().note]["descript"] = descript; |
||
243 | CT_UserMap_Notes[this:GetParent().zone][this:GetParent().note]["set"] = set; |
||
244 | CT_UserMap_Notes[this:GetParent().zone][this:GetParent().note]["icon"] = icon; |
||
245 | end |
||
246 | |||
247 | function CT_MapModDropDown_OnClick() |
||
248 | UIDropDownMenu_SetSelectedID(CT_UserMap_OptionsMenuGroupDropDown, this:GetID(), 1); |
||
249 | end |
||
250 | |||
251 | function CT_MapModDropDown_OnShow() |
||
252 | local set = CT_UserMap_Notes[this.zone][this.note]["set"]; |
||
253 | if ( this.zone and this.note ) then |
||
254 | if ( tonumber(set) and tonumber(set) == set ) then |
||
255 | UIDropDownMenu_SetSelectedName(CT_UserMap_OptionsMenuGroupDropDown, CT_MAPMOD_SETS[set], nil); |
||
256 | else |
||
257 | UIDropDownMenu_SetSelectedName(CT_UserMap_OptionsMenuGroupDropDown, set, nil); |
||
258 | end |
||
259 | end |
||
260 | UIDropDownMenu_SetText(CT_MAPMOD_SETS[set], CT_UserMap_OptionsMenuGroupDropDown); |
||
261 | end |
||
262 | |||
263 | function CT_MapModDropDown_OnInit() |
||
264 | UIDROPDOWNMENU_INIT_MENU = "CT_UserMap_OptionsMenuGroupDropDown"; |
||
265 | for key, val in CT_MAPMOD_SETS do |
||
266 | local info = { }; |
||
267 | info.text = val; |
||
268 | info.value = val; |
||
269 | info.owner = this; |
||
270 | info.func = CT_MapModDropDown_OnClick; |
||
271 | |||
272 | UIDropDownMenu_AddButton(info); |
||
273 | end |
||
274 | end |
||
275 | |||
276 | function CT_MapModDropDown_Initialize() |
||
277 | CT_MapModDropDown_OnInit(); |
||
278 | end |
||
279 | |||
280 | function CT_MapModDropDown_OnLoad() |
||
281 | UIDropDownMenu_Initialize(this, CT_MapModDropDown_Initialize); |
||
282 | UIDropDownMenu_SetWidth(130); |
||
283 | end |
||
284 | |||
285 | function CT_MapModSelectDropDown_OnLoad() |
||
286 | UIDropDownMenu_Initialize(this, CT_MapModSelectDropDown_Initialize); |
||
287 | UIDropDownMenu_SetWidth(130); |
||
288 | end |
||
289 | |||
290 | function CT_MapModSelectDropDown_OnClick() |
||
291 | CT_GroupSelectDropDownText:SetText("Display Groups"); |
||
292 | if ( not CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].hideGroups ) then |
||
293 | CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].hideGroups = { }; |
||
294 | end |
||
295 | CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].hideGroups[this.value] = not CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].hideGroups[this.value]; |
||
296 | end |
||
297 | |||
298 | function CT_MapModSelectDropDown_Initialize() |
||
299 | UIDROPDOWNMENU_INIT_MENU = "CT_GroupSelectDropDown"; |
||
300 | for key, val in CT_MAPMOD_SETS do |
||
301 | local info = { }; |
||
302 | info.text = val; |
||
303 | info.value = val; |
||
304 | if ( CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")] and ( not CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].hideGroups or not CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].hideGroups[val] ) ) then |
||
305 | info.checked = 1; |
||
306 | end |
||
307 | info.owner = this; |
||
308 | info.func = CT_MapModSelectDropDown_OnClick; |
||
309 | |||
310 | UIDropDownMenu_AddButton(info); |
||
311 | end |
||
312 | end |
||
313 | |||
314 | function CT_MapMod_DeleteNote() |
||
315 | tremove(CT_UserMap_Notes[this:GetParent().zone], this:GetParent().note); |
||
316 | end |
||
317 | |||
318 | function CT_MapMod_ProcessMessage(msg, user) |
||
319 | if (msg == CT_LastMessage.msg and CT_LastMessage.user == user) then return nil; end |
||
320 | |||
321 | CT_LastMessage.msg = msg; |
||
322 | CT_LastMessage.user = user; |
||
323 | |||
324 | if ( not msg ) then return nil; end |
||
325 | local Useless, Useless, xpos, ypos, zone, name, descript, group, icon = string.find(msg, "^<CTModUM> New map note received: x=(.+) y=(.+) z=(.+) n=(.*) d=(.*) g=(.+) i=(.+)$"); |
||
326 | |||
327 | if ( strsub(msg, 1, 9) ~= "<CTModUM>" ) then return nil; end |
||
328 | if ( not zone or Useless == msg ) then |
||
329 | Useless, Useless, name, xpos, ypos, zone = string.find(msg, "^<CTModUM> New map note: (.*) x=(.+) y=(.+) z=(.+) v=.+$"); |
||
330 | descript = "Received from " .. user; |
||
331 | icon = 1; |
||
332 | group = 1; |
||
333 | if ( not zone or Useless == msg ) then return nil; end |
||
334 | end |
||
335 | |||
336 | local zonename = CT_MapMod_GetZone(zone); |
||
337 | |||
338 | CT_Print("<CTMod> User Note received in zone '" .. zonename .. "' from '" .. user .. "'!", 1.0, 0.5, 0.0); |
||
339 | |||
340 | ChatEdit_SetLastTellTarget(DEFAULT_CHAT_FRAME.editBox, user); |
||
341 | |||
342 | CT_MapMod_AddNote(xpos, ypos, zonename, name, descript, tonumber(icon), group); |
||
343 | |||
344 | return 1; |
||
345 | end |
||
346 | |||
347 | function CT_MapMod_GetZone(zoneid) |
||
348 | if ( not tonumber(zoneid) ) then |
||
349 | return "Error, please report zoneid " .. zoneid; |
||
350 | end |
||
351 | |||
352 | local zone = tonumber(zoneid); |
||
353 | for key, val in CT_UserMap_Zone do |
||
354 | if ( val == zone ) then |
||
355 | return key; |
||
356 | end |
||
357 | end |
||
358 | return "Error, please report zone " .. zoneid; |
||
359 | end |
||
360 | |||
361 | CT_MapMod_OldChatFrameHook = ChatFrame_OnEvent; |
||
362 | |||
363 | function CT_MapMod_ChatFrameHook(event) |
||
364 | if ( event == "CHAT_MSG_WHISPER" and CT_MapMod_ProcessMessage(arg1, arg2) ) then |
||
365 | return; |
||
366 | end |
||
367 | CT_MapMod_OldChatFrameHook(event); |
||
368 | end |
||
369 | |||
370 | ChatFrame_OnEvent = CT_MapMod_ChatFrameHook; |
||
371 | |||
372 | function CT_MapMod_SendNote() |
||
373 | if ( not CT_UserMap_OptionsMenu:IsVisible() or strlen(CT_UserMap_OptionsMenuSendEB:GetText()) == 0 ) then |
||
374 | return; |
||
375 | end |
||
376 | |||
377 | local name, descript, zone, group, x, y, icon; |
||
378 | name = CT_UserMap_OptionsMenuNameEB:GetText(); |
||
379 | descript = CT_UserMap_OptionsMenuDescriptEB:GetText(); |
||
380 | zone = CT_UserMap_OptionsMenu.zone; |
||
381 | |||
382 | if ( UIDropDownMenu_GetSelectedName(CT_UserMap_OptionsMenuGroupDropDown) ) then |
||
383 | group = CT_UserMap_Notes[zone][CT_UserMap_OptionsMenu.note]["set"]; |
||
384 | else |
||
385 | group = UIDropDownMenu_GetSelectedID(CT_UserMap_OptionsMenuGroupDropDown); |
||
386 | end |
||
387 | |||
388 | x = CT_UserMap_Notes[zone][CT_UserMap_OptionsMenu.note]["x"]; |
||
389 | y = CT_UserMap_Notes[zone][CT_UserMap_OptionsMenu.note]["y"]; |
||
390 | |||
391 | icon = CT_UserMap_Notes[zone][CT_UserMap_OptionsMenu.note]["icon"]; |
||
392 | |||
393 | SendChatMessage("<CTModUM> New map note received: x="..x.." y="..y.." z="..CT_UserMap_Zone[zone].." n="..name.." d="..descript.." g="..group .. " i=" .. icon, "WHISPER", nil, CT_UserMap_OptionsMenuSendEB:GetText()); |
||
394 | CT_UserMap_OptionsMenuSendEB.lastsend = CT_UserMap_OptionsMenuSendEB:GetText(); |
||
395 | CT_UserMap_OptionsMenuSendEB:SetText(""); |
||
396 | CT_UserMap_OptionsMenuSendButton:Disable(); |
||
397 | end |
||
398 | |||
399 | function CT_MapMod_ShowEditGroups() |
||
400 | CT_UserMap_OptionsMenuEditGroups:Show(); |
||
401 | end |
||
402 | |||
403 | function CT_MapMod_EditGroups_Update() |
||
404 | local numGroups = getn(CT_MAPMOD_SETS); |
||
405 | FauxScrollFrame_Update(CT_UserMap_OptionsMenuEditGroupsScrollFrame, numGroups, 6, 16, CT_UserMap_OptionsMenuEditGroupsgHighlightFrame, 293, 316 ); |
||
406 | |||
407 | local i; |
||
408 | for i = 1, 6, 1 do |
||
409 | local btn = getglobal("CT_UserMap_OptionsMenuEditGroupsTitle" .. i); |
||
410 | if ( i <= numGroups ) then |
||
411 | btn:Show(); |
||
412 | btn:SetText(" " .. CT_MAPMOD_SETS[FauxScrollFrame_GetOffset(CT_UserMap_OptionsMenuEditGroupsScrollFrame)+i]); |
||
413 | else |
||
414 | btn:Hide(); |
||
415 | end |
||
416 | end |
||
417 | end |
||
418 | |||
419 | function CT_UserMapEditGroup_SetSelection(id) |
||
420 | |||
421 | local i; |
||
422 | for i = 1, 6, 1 do |
||
423 | getglobal("CT_UserMap_OptionsMenuEditGroupsTitle"..i):UnlockHighlight(); |
||
424 | end |
||
425 | |||
426 | -- Get xml id |
||
427 | local xmlid = id - FauxScrollFrame_GetOffset(CT_UserMap_OptionsMenuEditGroupsScrollFrame); |
||
428 | local titleButton = getglobal("CT_UserMap_OptionsMenuEditGroupsTitle"..xmlid); |
||
429 | |||
430 | -- Set newly selected quest and highlight it |
||
431 | CT_UserMap_OptionsMenuEditGroups.selectedButtonID = xmlid; |
||
432 | local scrollFrameOffset = FauxScrollFrame_GetOffset(CT_UserMap_OptionsMenuEditGroupsScrollFrame); |
||
433 | if ( id > scrollFrameOffset and id <= (scrollFrameOffset + 6) and id <= getn(CT_MAPMOD_SETS) ) then |
||
434 | titleButton:LockHighlight(); |
||
435 | end |
||
436 | end |
||
437 | |||
438 | function CT_MapMod_TitleButton_OnClick(button) |
||
439 | if ( button == "LeftButton" ) then |
||
440 | CT_UserMapEditGroup_SetSelection(this:GetID() + FauxScrollFrame_GetOffset(CT_UserMap_OptionsMenuEditGroupsScrollFrame)) |
||
441 | CT_MapMod_EditGroups_Update(); |
||
442 | end |
||
443 | end |
||
444 | |||
445 | -- Get old notes |
||
446 | |||
447 | function CT_MapMod_UpdateOldNotes() |
||
448 | local temp = { }; |
||
449 | local update = false; |
||
450 | for key, val in CT_UserMap_Notes do |
||
451 | if ( type(key) == "number" and type(val) == "table" ) then |
||
452 | update = true; |
||
453 | -- Old notes |
||
454 | local tempvar = { |
||
455 | ["name"] = val["desc"], |
||
456 | ["x"] = val["x"], |
||
457 | ["y"] = val["y"], |
||
458 | ["icon"] = 1, |
||
459 | ["set"] = 1, |
||
460 | }; |
||
461 | if ( val["zone"] ) then |
||
462 | if ( not temp[val["zone"]]) then |
||
463 | temp[val["zone"]] = { }; |
||
464 | end |
||
465 | temp[val["zone"]][getn(temp[val["zone"]])+1] = tempvar; |
||
466 | end |
||
467 | CT_UserMap_Notes[key] = nil; |
||
468 | end |
||
469 | end |
||
470 | if ( update ) then |
||
471 | for key, val in temp do |
||
472 | if ( not CT_UserMap_Notes[key] ) then |
||
473 | CT_UserMap_Notes[key] = { }; |
||
474 | end |
||
475 | for k, v in val do |
||
476 | tinsert(CT_UserMap_Notes[key], v); |
||
477 | end |
||
478 | end |
||
479 | CT_Print("<CTMod> Updated old notes to new format.", 1, 0.5, 0); |
||
480 | end |
||
481 | end |
||
482 | |||
483 | function CT_MapMod_OnLoad() |
||
484 | WorldMapMagnifyingGlassButton:SetText(ZOOM_OUT_BUTTON_TEXT .. "\nControl+click to add note"); |
||
485 | -- Set names |
||
486 | CT_UserMap_OptionsMenuTitle:SetText(CT_MAPMOD_TEXT_TITLE); |
||
487 | CT_UserMap_OptionsMenuNameText:SetText(CT_MAPMOD_TEXT_NAME); |
||
488 | CT_UserMap_OptionsMenuDescriptText:SetText(CT_MAPMOD_TEXT_DESC); |
||
489 | CT_UserMap_OptionsMenuGroupText:SetText(CT_MAPMOD_TEXT_GROUP); |
||
490 | CT_UserMap_OptionsMenuSendText:SetText(CT_MAPMOD_TEXT_SEND); |
||
491 | CT_UserMap_OptionsMenuOkayButton:SetText(CT_MAPMOD_BUTTON_OKAY); |
||
492 | CT_UserMap_OptionsMenuCancelButton:SetText(CT_MAPMOD_BUTTON_CANCEL); |
||
493 | CT_UserMap_OptionsMenuDeleteButton:SetText(CT_MAPMOD_BUTTON_DELETE); |
||
494 | CT_UserMap_OptionsMenuEditButton:SetText(CT_MAPMOD_BUTTON_EDITGROUPS); |
||
495 | CT_UserMap_OptionsMenuSendButton:SetText(CT_MAPMOD_BUTTON_SEND); |
||
496 | end |
||
497 | |||
498 | function CT_MapMod_OnEvent(event) |
||
499 | if ( event == "CHAT_MSG_SPELL_SELF_BUFF" ) then |
||
500 | CT_MapMod_ParseResource(event); |
||
501 | elseif ( event == "UI_ERROR_MESSAGE" ) then |
||
502 | if ( arg1 and ( string.find(arg1, "Requires Herbalism") or string.find(arg1, "Requires Mining") ) ) then |
||
503 | CT_MapMod_ParseResource(event); |
||
504 | end |
||
505 | elseif ( event == "PLAYER_ENTERING_WORLD" ) then |
||
506 | if ( not CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")] ) then |
||
507 | CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")] = { |
||
508 | ["autoGather"] = 1, |
||
509 | ["hideGroups"] = { } |
||
510 | }; |
||
511 | else |
||
512 | CT_GatherNotesButton:SetChecked(CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].autoGather); |
||
513 | end |
||
514 | end |
||
515 | end |
||
516 | |||
517 | function CT_MapMod_FindResourceIcon(oldName, prefix) |
||
518 | local _, _, endPoint = string.find(oldName, "([^%s]+%sVein)$"); |
||
519 | if ( endPoint ) then |
||
520 | oldName = endPoint; |
||
521 | else |
||
522 | local _, _, endPoint = string.find(oldName, "([^%s]+)%sDeposit$"); |
||
523 | if ( endPoint ) then |
||
524 | oldName = endPoint .. "Vein"; |
||
525 | end |
||
526 | end |
||
527 | local name = ""; |
||
528 | for i = 1, strlen(oldName), 1 do |
||
529 | local l = strsub(oldName, i, i); |
||
530 | if ( string.find(l, "%w") ) then |
||
531 | name = name .. l; |
||
532 | end |
||
533 | end |
||
534 | for k, v in CT_UserMap_HerbIcons do |
||
535 | if ( v == prefix .. name ) then |
||
536 | if ( prefix == "Herb_" ) then |
||
537 | return k; |
||
538 | else |
||
539 | return k-29; |
||
540 | end |
||
541 | end |
||
542 | end |
||
543 | return 1; |
||
544 | end |
||
545 | |||
546 | function CT_MapMod_ExecuteFilter(filter) |
||
547 | CT_MapMod_Filter = filter; |
||
548 | end |
||
549 | |||
550 | function CT_MapMod_ParseResource(event) |
||
551 | if ( not CT_MapMod_Options[UnitName("player") .. "@" .. GetCVar("realmName")].autoGather ) then |
||
552 | return; |
||
553 | end |
||
554 | local x, y = GetPlayerMapPosition("player"); |
||
555 | if ( x == 0 and y == 0 ) then |
||
556 | return; |
||
557 | end |
||
558 | local zone = CT_MapMod_GetCurrentZone(); |
||
559 | if ( not zone or not CT_UserMap_Zone[zone] ) then |
||
560 | return; |
||
561 | end |
||
562 | if ( not CT_UserMap_Notes[zone] ) then |
||
563 | CT_UserMap_Notes[zone] = { }; |
||
564 | end |
||
565 | for k, v in CT_UserMap_Notes[zone] do |
||
566 | if ( k > CT_NUM_USERMAP_NOTES ) then |
||
567 | break; |
||
568 | end |
||
569 | if ( abs(v.x-x) <= 0.01 and abs(v.y-y) <= 0.01 ) then |
||
570 | -- Two very close herbs, most likely the same herb, we don't want to add another note then |
||
571 | return; |
||
572 | end |
||
573 | end |
||
574 | if ( string.find(event, "^CHAT_MSG" ) ) then |
||
575 | if ( string.find(arg1, "^You perform Herb Gathering on") ) then |
||
576 | local _,_, name = string.find(arg1, "^You perform Herb Gathering on (.+)%.$"); |
||
577 | if ( name ) then |
||
578 | CT_MapMod_AddNote(x, y, zone, name, "", CT_MapMod_FindResourceIcon(name, "Herb_"), 7); |
||
579 | end |
||
580 | elseif ( string.find(arg1, "^You perform Mining on") ) then |
||
581 | local _,_, name = string.find(arg1, "^You perform Mining on (.+)%.$"); |
||
582 | if ( name ) then |
||
583 | CT_MapMod_AddNote(x, y, zone, name, "", CT_MapMod_FindResourceIcon(name, "Ore_"), 8); |
||
584 | end |
||
585 | end |
||
586 | elseif ( string.find(event, "UI_ERROR_MESSAGE") ) then |
||
587 | local name = GameTooltipTextLeft1:GetText(); |
||
588 | if ( name and strlen(name) > 0 ) then |
||
589 | if ( string.find(arg1, "Herbalism" ) ) then |
||
590 | CT_MapMod_AddNote(x, y, zone, name, "", CT_MapMod_FindResourceIcon(name, "Herb_"), 7); |
||
591 | else |
||
592 | CT_MapMod_AddNote(x, y, zone, name, "", CT_MapMod_FindResourceIcon(name, "Ore_"), 8); |
||
593 | end |
||
594 | end |
||
595 | end |
||
596 | end |
||
597 | |||
598 | function CT_MapMod_GetZoneName(id, ...) |
||
599 | return arg[id]; |
||
600 | end |
||
601 | |||
602 | function CT_MapMod_GetCurrentZone() |
||
603 | local x, y = GetPlayerMapPosition("player"); |
||
604 | local currC, currZ = GetCurrentMapContinent(), GetCurrentMapZone(); |
||
605 | SetMapToCurrentZone(); |
||
606 | local name = CT_MapMod_GetZoneName(GetCurrentMapZone(), GetMapZones(GetCurrentMapContinent())); |
||
607 | if ( x == 0 and y == 0 ) then |
||
608 | SetMapZoom(currC, currZ); |
||
609 | end |
||
610 | return name; |
||
611 | end |