comparison Main.lua @ 154:6c16692eebb0

If the WorldMapFrame is not open, set the map to the current zone every time we request coordinates from the game.
author James D. Callahan III <jcallahan@curse.com>
date Thu, 04 Oct 2012 14:10:39 -0500
parents d29109b5aaea
children 0c4a6ea88403
comparison
equal deleted inserted replaced
153:d29109b5aaea 154:6c16692eebb0
253 end 253 end
254 254
255 255
256 local function CurrentLocationData() 256 local function CurrentLocationData()
257 if _G.WorldMapFrame:IsVisible() then 257 if _G.WorldMapFrame:IsVisible() then
258 Debug("Map is opened. Returning 0, 0 for x, y")
258 return _G.GetRealZoneText(), current_area_id, 0, 0, 0, InstanceDifficultyToken() 259 return _G.GetRealZoneText(), current_area_id, 0, 0, 0, InstanceDifficultyToken()
259 end 260 end
261 WDP:SetCurrentAreaID()
262
260 local map_level = _G.GetCurrentMapDungeonLevel() or 0 263 local map_level = _G.GetCurrentMapDungeonLevel() or 0
261 local x, y = _G.GetPlayerMapPosition("player") 264 local x, y = _G.GetPlayerMapPosition("player")
262 265
263 x = x or 0 266 x = x or 0
264 y = y or 0 267 y = y or 0
287 end 290 end
288 291
289 if y % 2 ~= 0 then 292 if y % 2 ~= 0 then
290 y = y + 1 293 y = y + 1
291 end 294 end
295
296 Debug(("x: %d y: %d"):format(x, y))
292 return _G.GetRealZoneText(), current_area_id, x, y, map_level, InstanceDifficultyToken() 297 return _G.GetRealZoneText(), current_area_id, x, y, map_level, InstanceDifficultyToken()
293 end 298 end
294 299
295 300
296 local function ItemLinkToID(item_link) 301 local function ItemLinkToID(item_link)
592 return text 597 return text
593 end 598 end
594 end -- do-block 599 end -- do-block
595 600
596 601
602 -- Contains a dirty hack due to Blizzard's strange handling of Micro Dungeons; GetMapInfo() will not return correct information
603 -- unless the WorldMapFrame is shown.
597 do 604 do
598 -- MapFileName = MapAreaID 605 -- MapFileName = MapAreaID
599 local MICRO_DUNGEON_IDS = { 606 local MICRO_DUNGEON_IDS = {
600 ShrineofTwoMoons = 903, 607 ShrineofTwoMoons = 903,
601 ShrineofSevenStars = 905, 608 ShrineofSevenStars = 905,
602 } 609 }
603 610
604 -- Contains a dirty hack due to Blizzard's strange handling of Micro Dungeons; GetMapInfo() will not return correct information
605 -- unless the WorldMapFrame is shown.
606 function WDP:SetCurrentAreaID(event_name) 611 function WDP:SetCurrentAreaID(event_name)
607 local world_map = _G.WorldMapFrame 612 local world_map = _G.WorldMapFrame
608 local map_visible = world_map:IsVisible() 613 local map_visible = world_map:IsVisible()
614 local map_area_id = _G.GetCurrentMapAreaID()
609 local sfx_value = _G.tonumber(_G.GetCVar("Sound_EnableSFX")) 615 local sfx_value = _G.tonumber(_G.GetCVar("Sound_EnableSFX"))
610 616
611 if not map_visible then 617 if not map_visible then
612 _G.SetCVar("Sound_EnableSFX", 0) 618 _G.SetCVar("Sound_EnableSFX", 0)
613 world_map:Show() 619 world_map:Show()
614 end 620 end
615 local micro_dungeon_id = MICRO_DUNGEON_IDS[select(5, _G.GetMapInfo())] 621 local micro_dungeon_id = MICRO_DUNGEON_IDS[select(5, _G.GetMapInfo())]
616 622
623 _G.SetMapToCurrentZone()
624
617 if micro_dungeon_id then 625 if micro_dungeon_id then
618 current_area_id = micro_dungeon_id 626 current_area_id = micro_dungeon_id
619 else 627 else
620 local map_area_id = _G.GetCurrentMapAreaID()
621 _G.SetMapToCurrentZone()
622
623 current_area_id = _G.GetCurrentMapAreaID() 628 current_area_id = _G.GetCurrentMapAreaID()
629 end
630
631 if map_visible then
624 _G.SetMapByID(map_area_id) 632 _G.SetMapByID(map_area_id)
625 end 633 else
626
627 if not map_visible then
628 world_map:Hide() 634 world_map:Hide()
629 _G.SetCVar("Sound_EnableSFX", sfx_value) 635 _G.SetCVar("Sound_EnableSFX", sfx_value)
630 end 636 end
631 end 637 end
632 end -- do-block 638 end
633
634 639
635 ----------------------------------------------------------------------- 640 -----------------------------------------------------------------------
636 -- Methods. 641 -- Methods.
637 ----------------------------------------------------------------------- 642 -----------------------------------------------------------------------
638 function WDP:OnInitialize() 643 function WDP:OnInitialize()
655 660
656 function WDP:EventDispatcher(...) 661 function WDP:EventDispatcher(...)
657 local event_name = ... 662 local event_name = ...
658 663
659 if DEBUGGING then 664 if DEBUGGING then
660 if reputation_npc_id then 665 if event_name == "COMBAT_LOG_EVENT_UNFILTERED" then
661 if event_name == "COMBAT_LOG_EVENT_UNFILTERED" then 666 Debug(event_name)
662 Debug(event_name) 667 else
663 else 668 Debug(...)
664 Debug(...)
665 end
666 Debug(("reputation_npc_id == '%s'"):format(reputation_npc_id))
667 end 669 end
668 end 670 end
669 local func = EVENT_MAPPING[event_name] 671 local func = EVENT_MAPPING[event_name]
670 672
671 if _G.type(func) == "boolean" then 673 if _G.type(func) == "boolean" then