├── Localization.lua
├── img
├── bar.tga
├── Arrow.blp
├── Icon-1.tga
├── Icon-3.tga
├── Icon.tga
├── handin.tga
├── pickup.tga
└── RedIcon.tga
├── .gitattributes
├── OptionsPanel.lua
├── QuestAccepts.lua
├── lib
├── CallbackHandler-1.0
│ ├── CallbackHandler-1.0.xml
│ └── CallbackHandler-1.0.lua
├── HereBeDragons
│ ├── CallbackHandler-1.0
│ │ ├── CallbackHandler-1.0.xml
│ │ └── CallbackHandler-1.0.lua
│ ├── CHANGES.txt
│ ├── LibStub
│ │ ├── LibStub.toc
│ │ └── LibStub.lua
│ ├── HereBeDragons.toc
│ ├── HereBeDragons-2.0.lua
│ ├── HereBeDragons-Pins-1.0.lua
│ └── HereBeDragons-Pins-2.0.lua
├── LibStub
│ ├── LibStub.toc
│ └── LibStub.lua
└── HereBeDragons-1.0
│ └── HereBeDragons-1.0.toc
├── AAP-Classic.toc
├── Core.lua
├── Arrow.lua
├── QuestList.lua
├── QuestListFunctions.lua
├── QuestFunctions.lua
├── ZoneOrders.lua
└── DBfunctions.lua
/Localization.lua:
--------------------------------------------------------------------------------
1 | AAPClassic.Locale = {}
--------------------------------------------------------------------------------
/img/bar.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/bar.tga
--------------------------------------------------------------------------------
/img/Arrow.blp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/Arrow.blp
--------------------------------------------------------------------------------
/img/Icon-1.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/Icon-1.tga
--------------------------------------------------------------------------------
/img/Icon-3.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/Icon-3.tga
--------------------------------------------------------------------------------
/img/Icon.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/Icon.tga
--------------------------------------------------------------------------------
/img/handin.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/handin.tga
--------------------------------------------------------------------------------
/img/pickup.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/pickup.tga
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/img/RedIcon.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zyrrael/AAP-Classic/HEAD/img/RedIcon.tga
--------------------------------------------------------------------------------
/OptionsPanel.lua:
--------------------------------------------------------------------------------
1 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
2 | --return
3 | end
4 | AAPClassic.Panel = {}
--------------------------------------------------------------------------------
/QuestAccepts.lua:
--------------------------------------------------------------------------------
1 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
2 | --return
3 | end
4 | AAPClassic.QL = {}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/lib/CallbackHandler-1.0/CallbackHandler-1.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/CallbackHandler-1.0/CallbackHandler-1.0.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/lib/LibStub/LibStub.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 20400
2 | ## Title: Lib: LibStub
3 | ## Notes: Universal Library Stub
4 | ## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
5 | ## X-Website: http://jira.wowace.com/browse/LS
6 | ## X-Category: Library
7 | ## X-License: Public Domain
8 |
9 | LibStub.lua
10 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/CHANGES.txt:
--------------------------------------------------------------------------------
1 | Changes since tag 2.01-release
2 |
3 | commit 6b0e857506f78e24184cdbf61e4c0ef3f66401e6
4 | Author: Hendrik Leppkes
5 | Date: Sat Mar 16 12:40:36 2019 +0100
6 |
7 | Fill in the map list by iterating over all known maps, in addition to processing the child tree
8 |
9 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/LibStub/LibStub.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 20400
2 | ## Title: Lib: LibStub
3 | ## Notes: Universal Library Stub
4 | ## Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel
5 | ## X-Website: http://jira.wowace.com/browse/LS
6 | ## X-Category: Library
7 | ## X-License: Public Domain
8 |
9 | LibStub.lua
10 |
--------------------------------------------------------------------------------
/lib/HereBeDragons-1.0/HereBeDragons-1.0.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 70300
2 | ## Title: Lib: HereBeDragons-1.0
3 | ## Notes: HereBeDragons-1.0 compat wrapper
4 | ## Author: Nevcairiel
5 | ## X-eMail: h.leppkes@gmail.com
6 | ## X-Category: Library
7 | ## X-License: BSD
8 | ## X-Website: http://www.wowace.com/addons/herebedragons/
9 | ## Version: 2.01-release-1-g6b0e857
10 | ## Dependencies: HereBeDragons
11 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/HereBeDragons.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 80100
2 | ## Title: Lib: HereBeDragons
3 | ## Notes: HereBeDragons is a data API for the World of Warcraft mapping system
4 | ## Author: Nevcairiel
5 | ## X-eMail: h.leppkes@gmail.com
6 | ## X-Category: Library
7 | ## X-License: BSD
8 | ## X-Website: http://www.wowace.com/addons/herebedragons/
9 | ## Version: 2.01-release-1-g6b0e857
10 |
11 | LibStub\LibStub.lua
12 | CallbackHandler-1.0\CallbackHandler-1.0.lua
13 |
14 | # WoW 8.0+ version
15 | HereBeDragons-2.0.lua
16 | HereBeDragons-Pins-2.0.lua
17 |
18 | # Migration Data for 7.x -> 8.0 migration
19 | HereBeDragons-Migrate.lua
20 |
--------------------------------------------------------------------------------
/AAP-Classic.toc:
--------------------------------------------------------------------------------
1 | ## Interface: 11302
2 |
3 | ## Title: Azeroth Auto Pilot 1-60
4 | ## Notes: AAP Classic
5 | ## Author: Zyrrael
6 | ## Version: 0.12
7 | ## SavedVariables: AAPC1, AAPC2, AAPC3, AAPCQuestNames, AAPC_HoldZoneVar
8 | lib\LibStub\LibStub.lua
9 | lib\CallbackHandler-1.0\CallbackHandler-1.0.xml
10 | lib\HereBeDragons\HereBeDragons-2.0.lua
11 | lib\HereBeDragons\HereBeDragons-Pins-2.0.lua
12 | Core.lua
13 | Arrow.lua
14 | OptionsPanel.lua
15 | QuestList.lua
16 | QuestHandler.lua
17 | QuestFunctions.lua
18 | QuestListFunctions.lua
19 | DBfunctions.lua
20 | MapFunctions.lua
21 | ZoneOrders.lua
22 | A1-30.lua
23 | A30-60.lua
24 | H1-30.lua
25 | H30-60.lua
26 | db\items.lua
27 | db\objects.lua
28 | db\quests.lua
29 | db\units.lua
30 | db\unitsNames.lua
31 | db\itemsNames.lua
32 | db\questsNames.lua
33 | db\objectsNames.lua
--------------------------------------------------------------------------------
/lib/LibStub/LibStub.lua:
--------------------------------------------------------------------------------
1 | -- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
2 | -- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
3 | local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
4 | local LibStub = _G[LIBSTUB_MAJOR]
5 |
6 | if not LibStub or LibStub.minor < LIBSTUB_MINOR then
7 | LibStub = LibStub or {libs = {}, minors = {} }
8 | _G[LIBSTUB_MAJOR] = LibStub
9 | LibStub.minor = LIBSTUB_MINOR
10 |
11 | function LibStub:NewLibrary(major, minor)
12 | assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
13 | minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
14 |
15 | local oldminor = self.minors[major]
16 | if oldminor and oldminor >= minor then return nil end
17 | self.minors[major], self.libs[major] = minor, self.libs[major] or {}
18 | return self.libs[major], oldminor
19 | end
20 |
21 | function LibStub:GetLibrary(major, silent)
22 | if not self.libs[major] and not silent then
23 | error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
24 | end
25 | return self.libs[major], self.minors[major]
26 | end
27 |
28 | function LibStub:IterateLibraries() return pairs(self.libs) end
29 | setmetatable(LibStub, { __call = LibStub.GetLibrary })
30 | end
31 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/LibStub/LibStub.lua:
--------------------------------------------------------------------------------
1 | -- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
2 | -- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
3 | local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
4 | local LibStub = _G[LIBSTUB_MAJOR]
5 |
6 | if not LibStub or LibStub.minor < LIBSTUB_MINOR then
7 | LibStub = LibStub or {libs = {}, minors = {} }
8 | _G[LIBSTUB_MAJOR] = LibStub
9 | LibStub.minor = LIBSTUB_MINOR
10 |
11 | function LibStub:NewLibrary(major, minor)
12 | assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
13 | minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
14 |
15 | local oldminor = self.minors[major]
16 | if oldminor and oldminor >= minor then return nil end
17 | self.minors[major], self.libs[major] = minor, self.libs[major] or {}
18 | return self.libs[major], oldminor
19 | end
20 |
21 | function LibStub:GetLibrary(major, silent)
22 | if not self.libs[major] and not silent then
23 | error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
24 | end
25 | return self.libs[major], self.minors[major]
26 | end
27 |
28 | function LibStub:IterateLibraries() return pairs(self.libs) end
29 | setmetatable(LibStub, { __call = LibStub.GetLibrary })
30 | end
31 |
--------------------------------------------------------------------------------
/Core.lua:
--------------------------------------------------------------------------------
1 | AAPClassic = {}
2 | AAPClassic.Explored = {}
3 | AAPClassic.Build = GetBuildInfo()
4 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
5 | print("AAP-Classic - Error - This is not Classic! Not Loading")
6 | --return
7 | end
8 | AAPClassic.Name = UnitName("player")
9 | AAPClassic.Realm = string.gsub(GetRealmName(), " ", "")
10 | AAPClassic.Faction = UnitFactionGroup("player")
11 | AAPClassic.Level = UnitLevel("player")
12 | AAPClassic.experience = UnitXP("player")
13 | AAPClassic.Version = tonumber(GetAddOnMetadata("AAP-Classic", "Version"))
14 | AAPClassic.Class = {}
15 | AAPClassic.RaceLocale, AAPClassic.Race = UnitRace("player")
16 | AAPClassic.Class[1],AAPClassic.Class[2],AAPClassic.Class[3] = UnitClass("player")
17 | AAPClassic.QuestHelperEnable = "off"
18 | AAPClassic.HBDP = LibStub("HereBeDragons-Pins-2.0")
19 | AAPClassic.HBD = LibStub("HereBeDragons-2.0")
20 | AAPClassic.Locale = GetLocale()
21 | AAPClassic.NotRepeatList = {
22 | [813] = 813,
23 | }
24 | AAPClassic.ClassDBConv = {
25 | [1] = 1,
26 | [2] = 2,
27 | [3] = 4,
28 | [4] = 8,
29 | [5] = 16,
30 | [6] = 6,
31 | [7] = 64,
32 | [8] = 128,
33 | [9] = 256,
34 | [10] = 10,
35 | [11] = 1024,
36 | [12] = 12,
37 | }
38 | AAPClassic.QStarterList = {
39 | 1972,
40 | 1307,
41 | 1971,
42 | 5352,
43 | 4881,
44 | 4891,
45 | 16305,
46 | 16304,
47 | 16303,
48 | }
49 | function AAPClassic.getContinent()
50 | local mapID = C_Map.GetBestMapForUnit("player")
51 | if(mapID) then
52 | local info = C_Map.GetMapInfo(mapID)
53 | if(info) then
54 | while(info['mapType'] and info['mapType'] > 2) do
55 | info = C_Map.GetMapInfo(info['parentMapID'])
56 | end
57 | if(info['mapType'] == 2) then
58 | return info['mapID']
59 | end
60 | end
61 | end
62 | end
63 | local function AAP_SlashCmd(AAP_index)
64 | if (AAP_index == "reset") then
65 | print("AAP: Resetting Zone.")
66 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
67 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
68 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = 1
69 | AAPClassic.QH.FuncLoopNumber = 1
70 | elseif (AAP_index == "skip") then
71 | print("AAP: Skipping QuestStep.")
72 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
73 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
74 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
75 | AAPClassic.QH.FuncLoopNumber = 1
76 | elseif (AAP_index == "helper") then
77 | if (AAPClassic.QuestHelperEnable == "off") then
78 | print("AAP: Route OFF, Helper ON!")
79 | AAPClassic.QuestHelperEnable = "on"
80 | AAPClassic.RemoveIcons()
81 | AAPClassic.QuestList = nil
82 | AAPClassic.QuestList = {}
83 | AAPClassic.QH.BookingList.UpdateMapId = 1
84 | AAPClassic.QH.FuncLoopNumber = 1
85 | AAPClassic.QH.BookingList.UpdateQuestList = 1
86 | AAPClassic.QH.REprintzQuestList()
87 | else
88 | print("AAP: Route ON, Helper OFF!")
89 | AAPClassic.QuestHelperEnable = "off"
90 | AAPClassic.QH.BookingList.UpdateMapId = 1
91 | AAPClassic.QH.FuncLoopNumber = 1
92 | end
93 | elseif (AAP_index == "explore") then
94 | if (AAPClassic.ExploreEnable and AAPClassic.ExploreEnable == "on" and AAPClassic.Race == "Human") then
95 | print("AAP: Human Exploration OFF!")
96 | AAPClassic.ExploreEnable = "off"
97 | AAPClassic.QH.BookingList.UpdateMapId = 1
98 | AAPClassic.QH.FuncLoopNumber = 1
99 | elseif (AAPClassic.Race == "Human") then
100 | print("AAP: Human Exploration ON!")
101 | AAPClassic.ExploreEnable = "on"
102 | AAPClassic.QuestHelperEnable = "off"
103 | AAPClassic.QH.BookingList.UpdateMapId = 1
104 | AAPClassic.QH.FuncLoopNumber = 1
105 | end
106 | if (AAPClassic.ExploreEnable and AAPClassic.ExploreEnable == "on" and (AAPClassic.Race == "Dwarf" or AAPClassic.Race == "Gnome")) then
107 | print("AAP: Dwarf&Gnome Exploration OFF!")
108 | AAPClassic.ExploreEnable = "off"
109 | AAPClassic.QH.BookingList.UpdateMapId = 1
110 | AAPClassic.QH.FuncLoopNumber = 1
111 | elseif (AAPClassic.Race == "Dwarf" or AAPClassic.Race == "Gnome") then
112 | print("AAP: Dwarf&Gnome Exploration ON!")
113 | AAPClassic.ExploreEnable = "on"
114 | AAPClassic.QuestHelperEnable = "off"
115 | AAPClassic.QH.BookingList.UpdateMapId = 1
116 | AAPClassic.QH.FuncLoopNumber = 1
117 | end
118 | else
119 |
120 | end
121 | end
122 | AAPClassic.EventFrame = CreateFrame("Frame")
123 | AAPClassic.EventFrame:RegisterEvent ("ADDON_LOADED")
124 |
125 | AAPClassic.EventFrame:SetScript("OnEvent", function(self, event, ...)
126 | if (event=="ADDON_LOADED") then
127 | local arg1, arg2, arg3, arg4, arg5 = ...;
128 | if (arg1 == "AAP-Classic") then
129 | if (not AAPC1) then
130 | AAPC1 = {}
131 | end
132 | if (not AAPC1[AAPClassic.Realm]) then
133 | AAPC1[AAPClassic.Realm] = {}
134 | end
135 | if (not AAPC1[AAPClassic.Realm][AAPClassic.Name]) then
136 | AAPC1[AAPClassic.Realm][AAPClassic.Name] = {}
137 | end
138 | if (not AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"]) then
139 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"] = {}
140 | end
141 | if (not AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"]) then
142 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"] = {}
143 | end
144 | if (not AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"]) then
145 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"] = {}
146 | end
147 | SlashCmdList["AAP_Cmd"] = AAP_SlashCmd
148 | SLASH_AAP_Cmd1 = "/aap"
149 | AAPClassic.ReupdateQlistTimer = AAPClassic.EventFrame:CreateAnimationGroup()
150 | AAPClassic.ReupdateQlistTimer.anim = AAPClassic.ReupdateQlistTimer:CreateAnimation()
151 | AAPClassic.ReupdateQlistTimer.anim:SetDuration(5)
152 | AAPClassic.ReupdateQlistTimer:SetLooping("REPEAT")
153 | AAPClassic.ReupdateQlistTimer:SetScript("OnLoop", function(self, event, ...)
154 | AAPClassic.QH.BookingList.UpdateQuestList = 1
155 | AAPClassic.ReupdateQlistTimer:Stop()
156 | end)
157 | AAPClassic.CheckQcountTimer = AAPClassic.EventFrame:CreateAnimationGroup()
158 | AAPClassic.CheckQcountTimer.anim = AAPClassic.CheckQcountTimer:CreateAnimation()
159 | AAPClassic.CheckQcountTimer.anim:SetDuration(2)
160 | AAPClassic.CheckQcountTimer:SetLooping("REPEAT")
161 | AAPClassic.CheckQcountTimer:SetScript("OnLoop", function(self, event, ...)
162 | AAPClassic.QH.BookingList.ExtraQ = 1
163 | AAPClassic.CheckQcountTimer:Stop()
164 | end)
165 | end
166 | end
167 | end)
168 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/CallbackHandler-1.0/CallbackHandler-1.0.lua:
--------------------------------------------------------------------------------
1 | --[[ $Id: CallbackHandler-1.0.lua 22 2018-07-21 14:17:22Z nevcairiel $ ]]
2 | local MAJOR, MINOR = "CallbackHandler-1.0", 7
3 | local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
4 |
5 | if not CallbackHandler then return end -- No upgrade needed
6 |
7 | local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
8 |
9 | -- Lua APIs
10 | local tconcat = table.concat
11 | local assert, error, loadstring = assert, error, loadstring
12 | local setmetatable, rawset, rawget = setmetatable, rawset, rawget
13 | local next, select, pairs, type, tostring = next, select, pairs, type, tostring
14 |
15 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
16 | -- List them here for Mikk's FindGlobals script
17 | -- GLOBALS: geterrorhandler
18 |
19 | local xpcall = xpcall
20 |
21 | local function errorhandler(err)
22 | return geterrorhandler()(err)
23 | end
24 |
25 | local function Dispatch(handlers, ...)
26 | local index, method = next(handlers)
27 | if not method then return end
28 | repeat
29 | xpcall(method, errorhandler, ...)
30 | index, method = next(handlers, index)
31 | until not method
32 | end
33 |
34 | --------------------------------------------------------------------------
35 | -- CallbackHandler:New
36 | --
37 | -- target - target object to embed public APIs in
38 | -- RegisterName - name of the callback registration API, default "RegisterCallback"
39 | -- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
40 | -- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
41 |
42 | function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName)
43 |
44 | RegisterName = RegisterName or "RegisterCallback"
45 | UnregisterName = UnregisterName or "UnregisterCallback"
46 | if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
47 | UnregisterAllName = "UnregisterAllCallbacks"
48 | end
49 |
50 | -- we declare all objects and exported APIs inside this closure to quickly gain access
51 | -- to e.g. function names, the "target" parameter, etc
52 |
53 |
54 | -- Create the registry object
55 | local events = setmetatable({}, meta)
56 | local registry = { recurse=0, events=events }
57 |
58 | -- registry:Fire() - fires the given event/message into the registry
59 | function registry:Fire(eventname, ...)
60 | if not rawget(events, eventname) or not next(events[eventname]) then return end
61 | local oldrecurse = registry.recurse
62 | registry.recurse = oldrecurse + 1
63 |
64 | Dispatch(events[eventname], eventname, ...)
65 |
66 | registry.recurse = oldrecurse
67 |
68 | if registry.insertQueue and oldrecurse==0 then
69 | -- Something in one of our callbacks wanted to register more callbacks; they got queued
70 | for eventname,callbacks in pairs(registry.insertQueue) do
71 | local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
72 | for self,func in pairs(callbacks) do
73 | events[eventname][self] = func
74 | -- fire OnUsed callback?
75 | if first and registry.OnUsed then
76 | registry.OnUsed(registry, target, eventname)
77 | first = nil
78 | end
79 | end
80 | end
81 | registry.insertQueue = nil
82 | end
83 | end
84 |
85 | -- Registration of a callback, handles:
86 | -- self["method"], leads to self["method"](self, ...)
87 | -- self with function ref, leads to functionref(...)
88 | -- "addonId" (instead of self) with function ref, leads to functionref(...)
89 | -- all with an optional arg, which, if present, gets passed as first argument (after self if present)
90 | target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
91 | if type(eventname) ~= "string" then
92 | error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
93 | end
94 |
95 | method = method or eventname
96 |
97 | local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
98 |
99 | if type(method) ~= "string" and type(method) ~= "function" then
100 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
101 | end
102 |
103 | local regfunc
104 |
105 | if type(method) == "string" then
106 | -- self["method"] calling style
107 | if type(self) ~= "table" then
108 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
109 | elseif self==target then
110 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
111 | elseif type(self[method]) ~= "function" then
112 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
113 | end
114 |
115 | if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
116 | local arg=select(1,...)
117 | regfunc = function(...) self[method](self,arg,...) end
118 | else
119 | regfunc = function(...) self[method](self,...) end
120 | end
121 | else
122 | -- function ref with self=object or self="addonId" or self=thread
123 | if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
124 | error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
125 | end
126 |
127 | if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
128 | local arg=select(1,...)
129 | regfunc = function(...) method(arg,...) end
130 | else
131 | regfunc = method
132 | end
133 | end
134 |
135 |
136 | if events[eventname][self] or registry.recurse<1 then
137 | -- if registry.recurse<1 then
138 | -- we're overwriting an existing entry, or not currently recursing. just set it.
139 | events[eventname][self] = regfunc
140 | -- fire OnUsed callback?
141 | if registry.OnUsed and first then
142 | registry.OnUsed(registry, target, eventname)
143 | end
144 | else
145 | -- we're currently processing a callback in this registry, so delay the registration of this new entry!
146 | -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
147 | registry.insertQueue = registry.insertQueue or setmetatable({},meta)
148 | registry.insertQueue[eventname][self] = regfunc
149 | end
150 | end
151 |
152 | -- Unregister a callback
153 | target[UnregisterName] = function(self, eventname)
154 | if not self or self==target then
155 | error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
156 | end
157 | if type(eventname) ~= "string" then
158 | error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
159 | end
160 | if rawget(events, eventname) and events[eventname][self] then
161 | events[eventname][self] = nil
162 | -- Fire OnUnused callback?
163 | if registry.OnUnused and not next(events[eventname]) then
164 | registry.OnUnused(registry, target, eventname)
165 | end
166 | end
167 | if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
168 | registry.insertQueue[eventname][self] = nil
169 | end
170 | end
171 |
172 | -- OPTIONAL: Unregister all callbacks for given selfs/addonIds
173 | if UnregisterAllName then
174 | target[UnregisterAllName] = function(...)
175 | if select("#",...)<1 then
176 | error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
177 | end
178 | if select("#",...)==1 and ...==target then
179 | error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
180 | end
181 |
182 |
183 | for i=1,select("#",...) do
184 | local self = select(i,...)
185 | if registry.insertQueue then
186 | for eventname, callbacks in pairs(registry.insertQueue) do
187 | if callbacks[self] then
188 | callbacks[self] = nil
189 | end
190 | end
191 | end
192 | for eventname, callbacks in pairs(events) do
193 | if callbacks[self] then
194 | callbacks[self] = nil
195 | -- Fire OnUnused callback?
196 | if registry.OnUnused and not next(callbacks) then
197 | registry.OnUnused(registry, target, eventname)
198 | end
199 | end
200 | end
201 | end
202 | end
203 | end
204 |
205 | return registry
206 | end
207 |
208 |
209 | -- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
210 | -- try to upgrade old implicit embeds since the system is selfcontained and
211 | -- relies on closures to work.
212 |
213 |
--------------------------------------------------------------------------------
/lib/CallbackHandler-1.0/CallbackHandler-1.0.lua:
--------------------------------------------------------------------------------
1 | --[[ $Id: CallbackHandler-1.0.lua 18 2014-10-16 02:52:20Z mikk $ ]]
2 | local MAJOR, MINOR = "CallbackHandler-1.0", 6
3 | local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR)
4 |
5 | if not CallbackHandler then return end -- No upgrade needed
6 |
7 | local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end}
8 |
9 | -- Lua APIs
10 | local tconcat = table.concat
11 | local assert, error, loadstring = assert, error, loadstring
12 | local setmetatable, rawset, rawget = setmetatable, rawset, rawget
13 | local next, select, pairs, type, tostring = next, select, pairs, type, tostring
14 |
15 | -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
16 | -- List them here for Mikk's FindGlobals script
17 | -- GLOBALS: geterrorhandler
18 |
19 | local xpcall = xpcall
20 |
21 | local function errorhandler(err)
22 | return geterrorhandler()(err)
23 | end
24 |
25 | local function CreateDispatcher(argCount)
26 | local code = [[
27 | local next, xpcall, eh = ...
28 |
29 | local method, ARGS
30 | local function call() method(ARGS) end
31 |
32 | local function dispatch(handlers, ...)
33 | local index
34 | index, method = next(handlers)
35 | if not method then return end
36 | local OLD_ARGS = ARGS
37 | ARGS = ...
38 | repeat
39 | xpcall(call, eh)
40 | index, method = next(handlers, index)
41 | until not method
42 | ARGS = OLD_ARGS
43 | end
44 |
45 | return dispatch
46 | ]]
47 |
48 | local ARGS, OLD_ARGS = {}, {}
49 | for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
50 | code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
51 | return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
52 | end
53 |
54 | local Dispatchers = setmetatable({}, {__index=function(self, argCount)
55 | local dispatcher = CreateDispatcher(argCount)
56 | rawset(self, argCount, dispatcher)
57 | return dispatcher
58 | end})
59 |
60 | --------------------------------------------------------------------------
61 | -- CallbackHandler:New
62 | --
63 | -- target - target object to embed public APIs in
64 | -- RegisterName - name of the callback registration API, default "RegisterCallback"
65 | -- UnregisterName - name of the callback unregistration API, default "UnregisterCallback"
66 | -- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API.
67 |
68 | function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName)
69 |
70 | RegisterName = RegisterName or "RegisterCallback"
71 | UnregisterName = UnregisterName or "UnregisterCallback"
72 | if UnregisterAllName==nil then -- false is used to indicate "don't want this method"
73 | UnregisterAllName = "UnregisterAllCallbacks"
74 | end
75 |
76 | -- we declare all objects and exported APIs inside this closure to quickly gain access
77 | -- to e.g. function names, the "target" parameter, etc
78 |
79 |
80 | -- Create the registry object
81 | local events = setmetatable({}, meta)
82 | local registry = { recurse=0, events=events }
83 |
84 | -- registry:Fire() - fires the given event/message into the registry
85 | function registry:Fire(eventname, ...)
86 | if not rawget(events, eventname) or not next(events[eventname]) then return end
87 | local oldrecurse = registry.recurse
88 | registry.recurse = oldrecurse + 1
89 |
90 | Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
91 |
92 | registry.recurse = oldrecurse
93 |
94 | if registry.insertQueue and oldrecurse==0 then
95 | -- Something in one of our callbacks wanted to register more callbacks; they got queued
96 | for eventname,callbacks in pairs(registry.insertQueue) do
97 | local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
98 | for self,func in pairs(callbacks) do
99 | events[eventname][self] = func
100 | -- fire OnUsed callback?
101 | if first and registry.OnUsed then
102 | registry.OnUsed(registry, target, eventname)
103 | first = nil
104 | end
105 | end
106 | end
107 | registry.insertQueue = nil
108 | end
109 | end
110 |
111 | -- Registration of a callback, handles:
112 | -- self["method"], leads to self["method"](self, ...)
113 | -- self with function ref, leads to functionref(...)
114 | -- "addonId" (instead of self) with function ref, leads to functionref(...)
115 | -- all with an optional arg, which, if present, gets passed as first argument (after self if present)
116 | target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]])
117 | if type(eventname) ~= "string" then
118 | error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2)
119 | end
120 |
121 | method = method or eventname
122 |
123 | local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten.
124 |
125 | if type(method) ~= "string" and type(method) ~= "function" then
126 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2)
127 | end
128 |
129 | local regfunc
130 |
131 | if type(method) == "string" then
132 | -- self["method"] calling style
133 | if type(self) ~= "table" then
134 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2)
135 | elseif self==target then
136 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2)
137 | elseif type(self[method]) ~= "function" then
138 | error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2)
139 | end
140 |
141 | if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
142 | local arg=select(1,...)
143 | regfunc = function(...) self[method](self,arg,...) end
144 | else
145 | regfunc = function(...) self[method](self,...) end
146 | end
147 | else
148 | -- function ref with self=object or self="addonId" or self=thread
149 | if type(self)~="table" and type(self)~="string" and type(self)~="thread" then
150 | error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string or thread expected.", 2)
151 | end
152 |
153 | if select("#",...)>=1 then -- this is not the same as testing for arg==nil!
154 | local arg=select(1,...)
155 | regfunc = function(...) method(arg,...) end
156 | else
157 | regfunc = method
158 | end
159 | end
160 |
161 |
162 | if events[eventname][self] or registry.recurse<1 then
163 | -- if registry.recurse<1 then
164 | -- we're overwriting an existing entry, or not currently recursing. just set it.
165 | events[eventname][self] = regfunc
166 | -- fire OnUsed callback?
167 | if registry.OnUsed and first then
168 | registry.OnUsed(registry, target, eventname)
169 | end
170 | else
171 | -- we're currently processing a callback in this registry, so delay the registration of this new entry!
172 | -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency
173 | registry.insertQueue = registry.insertQueue or setmetatable({},meta)
174 | registry.insertQueue[eventname][self] = regfunc
175 | end
176 | end
177 |
178 | -- Unregister a callback
179 | target[UnregisterName] = function(self, eventname)
180 | if not self or self==target then
181 | error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2)
182 | end
183 | if type(eventname) ~= "string" then
184 | error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2)
185 | end
186 | if rawget(events, eventname) and events[eventname][self] then
187 | events[eventname][self] = nil
188 | -- Fire OnUnused callback?
189 | if registry.OnUnused and not next(events[eventname]) then
190 | registry.OnUnused(registry, target, eventname)
191 | end
192 | end
193 | if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then
194 | registry.insertQueue[eventname][self] = nil
195 | end
196 | end
197 |
198 | -- OPTIONAL: Unregister all callbacks for given selfs/addonIds
199 | if UnregisterAllName then
200 | target[UnregisterAllName] = function(...)
201 | if select("#",...)<1 then
202 | error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2)
203 | end
204 | if select("#",...)==1 and ...==target then
205 | error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2)
206 | end
207 |
208 |
209 | for i=1,select("#",...) do
210 | local self = select(i,...)
211 | if registry.insertQueue then
212 | for eventname, callbacks in pairs(registry.insertQueue) do
213 | if callbacks[self] then
214 | callbacks[self] = nil
215 | end
216 | end
217 | end
218 | for eventname, callbacks in pairs(events) do
219 | if callbacks[self] then
220 | callbacks[self] = nil
221 | -- Fire OnUnused callback?
222 | if registry.OnUnused and not next(callbacks) then
223 | registry.OnUnused(registry, target, eventname)
224 | end
225 | end
226 | end
227 | end
228 | end
229 | end
230 |
231 | return registry
232 | end
233 |
234 |
235 | -- CallbackHandler purposefully does NOT do explicit embedding. Nor does it
236 | -- try to upgrade old implicit embeds since the system is selfcontained and
237 | -- relies on closures to work.
238 |
239 |
--------------------------------------------------------------------------------
/Arrow.lua:
--------------------------------------------------------------------------------
1 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
2 | --return
3 | end
4 | AAPClassic.Arrow = {}
5 | AAPClassic.ArrowActive = 0
6 | AAPClassic.ArrowActive_X = 0
7 | AAPClassic.ArrowActive_Y = 0
8 | AAPClassic.SetArrowStep = 0
9 | local AAPClassic_ArrowUpdateNr = 0
10 |
11 | AAPClassic.ArrowFrameM = CreateFrame("Button", "AAPClassic_ArrowFrame", UIParent)
12 | AAPClassic.ArrowFrameM:SetHeight(1)
13 | AAPClassic.ArrowFrameM:SetWidth(1)
14 | AAPClassic.ArrowFrameM:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 0, 0)
15 | AAPClassic.ArrowFrameM:EnableMouse(true)
16 | AAPClassic.ArrowFrameM:SetMovable(true)
17 |
18 | AAPClassic.ArrowFrame = CreateFrame("Button", "AAPClassic_ArrowFrame2", UIParent)
19 | AAPClassic.ArrowFrame:SetHeight(42)
20 | AAPClassic.ArrowFrame:SetWidth(56)
21 | AAPClassic.ArrowFrame:SetPoint("TOPLEFT", AAPClassic.ArrowFrameM, "TOPLEFT", 0, 0)
22 | AAPClassic.ArrowFrame:EnableMouse(true)
23 | AAPClassic.ArrowFrame:SetMovable(true)
24 | AAPClassic.ArrowFrame.arrow = AAPClassic.ArrowFrame:CreateTexture(nil, "OVERLAY")
25 | AAPClassic.ArrowFrame.arrow:SetTexture("Interface\\Addons\\AAP-Classic\\Img\\Arrow.blp")
26 | AAPClassic.ArrowFrame.arrow:SetAllPoints()
27 | AAPClassic.ArrowFrame.distance = AAPClassic.ArrowFrame:CreateFontString("ARTWORK", "ChatFontNormal")
28 | AAPClassic.ArrowFrame.distance:SetFontObject("GameFontNormalSmall")
29 | AAPClassic.ArrowFrame.distance:SetPoint("TOP", AAPClassic.ArrowFrame, "BOTTOM", 0, 0)
30 | AAPClassic.ArrowFrame:Hide()
31 | AAPClassic.ArrowFrame:SetScript("OnMouseDown", function(self, button)
32 | if button == "LeftButton" and not AAPClassic.ArrowFrameM.isMoving then
33 | AAPClassic.ArrowFrameM:StartMoving();
34 | AAPClassic.ArrowFrameM.isMoving = true;
35 | end
36 | end)
37 | AAPClassic.ArrowFrame:SetScript("OnMouseUp", function(self, button)
38 | if button == "LeftButton" and AAPClassic.ArrowFrameM.isMoving then
39 | AAPClassic.ArrowFrameM:StopMovingOrSizing();
40 | AAPClassic.ArrowFrameM.isMoving = false;
41 | end
42 | end)
43 | AAPClassic.ArrowFrame:SetScript("OnHide", function(self)
44 | if ( AAPClassic.ArrowFrameM.isMoving ) then
45 | AAPClassic.ArrowFrameM:StopMovingOrSizing();
46 | AAPClassic.ArrowFrameM.isMoving = false;
47 | end
48 | end)
49 |
50 | AAPClassic.ArrowFrame.Button = CreateFrame("Button", "AAPClassic_ArrowFrame_Button", AAP_ArrowFrame)
51 | AAPClassic.ArrowFrame.Button:SetWidth(85)
52 | AAPClassic.ArrowFrame.Button:SetHeight(17)
53 | AAPClassic.ArrowFrame.Button:SetParent(AAPClassic.ArrowFrame)
54 | AAPClassic.ArrowFrame.Button:SetPoint("BOTTOM", AAPClassic.ArrowFrame, "BOTTOM", 0, -30)
55 | AAPClassic.ArrowFrame.Button:SetScript("OnMouseDown", function(self, button)
56 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
57 | print("AAP - Skipped Waypoint")
58 | AAPClassic.QH.FuncLoopNumber = 1
59 | end)
60 | AAPClassic.ArrowFrame.Button:SetBackdrop( {
61 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
62 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
63 | tile = true, tileSize = 10, edgeSize = 10, insets = { left = 2, right = 2, top = 2, bottom = 2 }
64 | });
65 | AAPClassic.ArrowFrame.Fontstring = AAPClassic.ArrowFrame:CreateFontString("AAPClassic_ArrowFrame_Fontstring ","ARTWORK", "ChatFontNormal")
66 | AAPClassic.ArrowFrame.Fontstring:SetParent(AAPClassic.ArrowFrame.Button)
67 | AAPClassic.ArrowFrame.Fontstring:SetPoint("CENTER", AAPClassic.ArrowFrame.Button, "CENTER", 0, 0)
68 |
69 | AAPClassic.ArrowFrame.Fontstring:SetFontObject("GameFontNormalSmall")
70 | AAPClassic.ArrowFrame.Fontstring:SetText("Skip waypoint")
71 | AAPClassic.ArrowFrame.Fontstring:SetTextColor(1, 1, 0)
72 | AAPClassic.ArrowFrame.Button:Hide()
73 |
74 | function AAPClassic.SetQPTT()
75 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
76 | if (CurStep and AAPClassic.Path[AAPClassic.QH.ZoneNr] and AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep] and AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["TT"] and AAPClassic.SetArrowStep ~= CurStep) then
77 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
78 | AAPClassic.SetArrowStep = CurStep
79 | if (Step and Step["DoneClass"]) then
80 | local Class = AAPClassic.Class[3]
81 | if (Step["DoneClass"][Class] and Step["DoneClass"][Class][AAPClassic.Race]) then
82 | AAPClassic.ArrowActive = 1
83 | AAPClassic.ArrowActive_X = Step["DoneClass"][Class][AAPClassic.Race]["x"]
84 | AAPClassic.ArrowActive_Y = Step["DoneClass"][Class][AAPClassic.Race]["y"]
85 | end
86 | elseif (Step and Step["PickUpClass"]) then
87 | local Class = AAPClassic.Class[3]
88 | if (Step["PickUpClass"][Class] and Step["PickUpClass"][Class][AAPClassic.Race]) then
89 | AAPClassic.ArrowActive = 1
90 | AAPClassic.ArrowActive_X = Step["PickUpClass"][Class][AAPClassic.Race]["x"]
91 | AAPClassic.ArrowActive_Y = Step["PickUpClass"][Class][AAPClassic.Race]["y"]
92 | end
93 | else
94 | AAPClassic.ArrowActive = 1
95 | AAPClassic.ArrowActive_X = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["TT"]["x"]
96 | AAPClassic.ArrowActive_Y = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["TT"]["y"]
97 | end
98 | end
99 | end
100 | function AAPClassic.ArrowFrame.CheckDistance()
101 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
102 | if (CurStep and AAPClassic.Path[AAPClassic.QH.ZoneNr] and AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]) then
103 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
104 | if (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["CRange"]) then
105 | AAPClassic.ArrowFrame.Button:Show()
106 | local plusnr = CurStep
107 | local Distancenr = 0
108 | local testad = true
109 | if (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["NoExtraRange"]) then
110 | testad = false
111 | end
112 | while testad do
113 | local oldx = AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["TT"]["x"]
114 | local oldy = AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["TT"]["y"]
115 | plusnr = plusnr + 1
116 | if (AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr] and AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["CRange"]) then
117 | local newx = AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["TT"]["x"]
118 | local newy = AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["TT"]["y"]
119 | local deltaX, deltaY = oldx - newx, newy - oldy
120 | local distance = (deltaX * deltaX + deltaY * deltaY)^0.5
121 | Distancenr = Distancenr + distance
122 | else
123 | if (AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr] and AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["TT"]) then
124 | local newx = AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["TT"]["x"]
125 | local newy = AAPClassic.Path[AAPClassic.QH.ZoneNr][plusnr]["TT"]["y"]
126 | local deltaX, deltaY = oldx - newx, newy - oldy
127 | local distance = (deltaX * deltaX + deltaY * deltaY)^0.5
128 | Distancenr = Distancenr + distance
129 | end
130 | return floor(Distancenr + 0.5)
131 | end
132 | end
133 | end
134 | end
135 | return 0
136 | end
137 | function AAPClassic.ArrowFrame.ArrowPosTest()
138 | if (1 == 0) then
139 | AAPClassic.ArrowActive = 0
140 | AAPClassic.ArrowFrame:Hide()
141 | else
142 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
143 | if ((AAPClassic.ArrowActive == 0) or (AAPClassic.ArrowActive_X == 0) or (IsInInstance()) or not AAPClassic.Path[AAPClassic.QH.ZoneNr] or AAPClassic.QuestHelperEnable == "on") then
144 | AAPClassic.ArrowActive = 0
145 | AAPClassic.ArrowFrame:Hide()
146 | else
147 | AAPClassic.ArrowFrame:Show()
148 | AAPClassic.ArrowFrame.Button:Hide()
149 | local d_y, d_x = UnitPosition("player")
150 | if (d_x and d_y) then
151 | x = AAPClassic.ArrowActive_X
152 | y = AAPClassic.ArrowActive_Y
153 | local AAP_ArrowActive_TrigDistance
154 | local PI2 = math.pi * 2
155 | local atan2 = math.atan2
156 | local twopi = math.pi * 2
157 | local deltaX, deltaY = d_x - x, y - d_y
158 | local distance = (deltaX * deltaX + deltaY * deltaY)^0.5
159 | local angle = atan2(-deltaX, deltaY)
160 | local player = GetPlayerFacing()
161 | angle = angle - player
162 | local perc = math.abs((math.pi - math.abs(angle)) / math.pi)
163 | if perc > 0.98 and perc < 1.02 then
164 | AAPClassic.ArrowFrame.arrow:SetVertexColor(0,1,0)
165 | elseif perc >= 1.02 and perc < 1.49 then
166 | AAPClassic.ArrowFrame.arrow:SetVertexColor((perc-1)*2,1,0)
167 | elseif perc > 1.49 then
168 | perc = 2-perc
169 | AAPClassic.ArrowFrame.arrow:SetVertexColor(1,perc*2,0)
170 | elseif perc > 0.49 then
171 | AAPClassic.ArrowFrame.arrow:SetVertexColor((1-perc)*2,1,0)
172 | else
173 | AAPClassic.ArrowFrame.arrow:SetVertexColor(1,perc*2,0)
174 | end
175 | local cell = floor(angle / twopi * 108 + 0.5) % 108
176 | local cell = floor(angle / twopi * 108 + 0.5) % 108
177 | local col = cell % 9
178 | local row = floor(cell / 9)
179 | AAPClassic.ArrowFrame.arrow:SetTexCoord((col * 56) / 512,((col + 1) * 56) / 512,(row * 42) / 512,((row + 1) * 42) / 512)
180 | AAPClassic.ArrowFrame.distance:SetText(floor(distance + AAPClassic.ArrowFrame.CheckDistance()) .. " yards")
181 | local Classic_ArrowActive_Distance = 0
182 | if (CurStep and AAPClassic.QH.ZoneNr and AAPClassic.Path[AAPClassic.QH.ZoneNr] and AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]) then
183 | if (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["Trigger"]) then
184 | local d_y, d_x = UnitPosition("player")
185 | local AAP_ArrowActive_Trigger_X = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["Trigger"]["x"]
186 | local AAP_ArrowActive_Trigger_Y = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["Trigger"]["y"]
187 | local deltaX, deltaY = d_x - AAP_ArrowActive_Trigger_X, AAP_ArrowActive_Trigger_Y - d_y
188 | Classic_ArrowActive_Distance = (deltaX * deltaX + deltaY * deltaY)^0.5
189 | AAP_ArrowActive_TrigDistance = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["Range"]
190 | if (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["HIDEME"]) then
191 | AAPClassic.ArrowActive = 0
192 | end
193 | end
194 | end
195 | if (distance < 5 and Classic_ArrowActive_Distance == 0) then
196 | AAPClassic.ArrowActive_X = 0
197 | elseif (Classic_ArrowActive_Distance and AAP_ArrowActive_TrigDistance and Classic_ArrowActive_Distance < AAP_ArrowActive_TrigDistance) then
198 | AAPClassic.ArrowActive_X = 0
199 | if (CurStep and AAPClassic.QH.ZoneNr and AAPClassic.Path[AAPClassic.QH.ZoneNr] and AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]) then
200 | if (AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]["CRange"]) then
201 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
202 | AAPClassic.QH.FuncLoopNumber = 1
203 | end
204 | end
205 | end
206 | end
207 | end
208 | end
209 | end
210 | function AAPClassic.ArrowUpdate()
211 | if (AAPClassic_ArrowUpdateNr >= 2) then
212 | AAPClassic.ArrowFrame.ArrowPosTest()
213 | AAPClassic_ArrowUpdateNr = 0
214 | else
215 | AAPClassic_ArrowUpdateNr = AAPClassic_ArrowUpdateNr + 1
216 | end
217 | end
218 |
219 | AAPClassic.ArrowFrame.LoopUpdate = CreateFrame("frame")
220 | AAPClassic.ArrowFrame.LoopUpdate:SetScript("OnUpdate", AAPClassic.ArrowUpdate)
221 |
222 |
223 |
--------------------------------------------------------------------------------
/QuestList.lua:
--------------------------------------------------------------------------------
1 | AAPClassic.QL = {}
2 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
3 | --return
4 | end
5 |
6 |
7 | function AAPClassic.MakeQuestList()
8 |
9 |
10 | AAPClassic.GroupQuestFrame = {}
11 | AAPClassic.GroupQuestFrame = CreateFrame("frame", "AAP_SugQuestFrameFrame", UIParent)
12 | AAPClassic.GroupQuestFrame:SetWidth(300)
13 | AAPClassic.GroupQuestFrame:SetHeight(150)
14 | AAPClassic.GroupQuestFrame:SetMovable(true)
15 | AAPClassic.GroupQuestFrame:EnableMouse(true)
16 | AAPClassic.GroupQuestFrame:SetFrameStrata("LOW")
17 | AAPClassic.GroupQuestFrame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
18 | AAPClassic.GroupQuestFrame:SetBackdrop( {
19 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
20 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
21 | tile = true, tileSize = 10, edgeSize = 10, insets = { left = 2, right = 2, top = 2, bottom = 2 }
22 | });
23 | AAPClassic.GroupQuestFrame:SetScript("OnMouseDown", function(self, button)
24 | if button == "LeftButton" then
25 | AAPClassic.GroupQuestFrame:StartMoving();
26 | AAPClassic.GroupQuestFrame.isMoving = true;
27 | end
28 | end)
29 | AAPClassic.GroupQuestFrame:SetScript("OnMouseUp", function(self, button)
30 | if button == "LeftButton" and AAPClassic.GroupQuestFrame.isMoving then
31 | AAPClassic.GroupQuestFrame:StopMovingOrSizing();
32 | AAPClassic.GroupQuestFrame.isMoving = false;
33 | end
34 | end)
35 | AAPClassic.GroupQuestFrame:SetScript("OnHide", function(self)
36 | if ( AAPClassic.GroupQuestFrame.isMoving ) then
37 | AAPClassic.GroupQuestFrame:StopMovingOrSizing();
38 | AAPClassic.GroupQuestFrame.isMoving = false;
39 | end
40 | end)
41 | AAPClassic.GroupQuestFrame:Hide()
42 |
43 | AAPClassic.GroupQuestFrameFS1 = AAPClassic.GroupQuestFrame:CreateFontString("CLQaaFS1","ARTWORK", "ChatFontNormal")
44 | AAPClassic.GroupQuestFrameFS1:SetParent(AAPClassic.GroupQuestFrame)
45 | AAPClassic.GroupQuestFrameFS1:SetPoint("TOPLEFT",AAPClassic.GroupQuestFrame,"TOPLEFT",0,0)
46 | AAPClassic.GroupQuestFrameFS1:SetWidth(300)
47 | AAPClassic.GroupQuestFrameFS1:SetHeight(38)
48 | AAPClassic.GroupQuestFrameFS1:SetJustifyH("CENTER")
49 | AAPClassic.GroupQuestFrameFS1:SetFontObject("GameFontNormalLarge")
50 | AAPClassic.GroupQuestFrameFS1:SetText("Quests Text")
51 | AAPClassic.GroupQuestFrameFS1:SetTextColor(1, 1, 0)
52 | AAPClassic.GroupQuestFrameFS2 = AAPClassic.GroupQuestFrame:CreateFontString("CLQaaFS2","ARTWORK", "ChatFontNormal")
53 | AAPClassic.GroupQuestFrameFS2:SetParent(AAPClassic.GroupQuestFrame)
54 | AAPClassic.GroupQuestFrameFS2:SetPoint("TOPLEFT",AAPClassic.GroupQuestFrame,"TOPLEFT",0,-30)
55 | AAPClassic.GroupQuestFrameFS2:SetWidth(300)
56 | AAPClassic.GroupQuestFrameFS2:SetHeight(38)
57 | AAPClassic.GroupQuestFrameFS2:SetJustifyH("CENTER")
58 | AAPClassic.GroupQuestFrameFS2:SetFontObject("GameFontNormalLarge")
59 | AAPClassic.GroupQuestFrameFS2:SetText("Suggested Players: ")
60 | AAPClassic.GroupQuestFrameFS2:SetTextColor(1, 1, 0)
61 |
62 | AAPClassic.GroupQuestFrame["Button1"] = CreateFrame("Button", "AAP_SBX1", UIParent, "SecureActionButtonTemplate")
63 | AAPClassic.GroupQuestFrame["Button1"]:SetPoint("BOTTOMLEFT",AAPClassic.GroupQuestFrame,"BOTTOMLEFT",15,5)
64 | AAPClassic.GroupQuestFrame["Button1"]:SetWidth(110)
65 | AAPClassic.GroupQuestFrame["Button1"]:SetHeight(30)
66 | AAPClassic.GroupQuestFrame["Button1"]:SetText("Accept Quest")
67 | AAPClassic.GroupQuestFrame["Button1"]:SetParent(AAPClassic.GroupQuestFrame)
68 | AAPClassic.GroupQuestFrame.Button1:SetNormalFontObject("GameFontNormal")
69 | AAPClassic.GroupQuestFrame.Button1ntex = AAPClassic.GroupQuestFrame.Button1:CreateTexture()
70 | AAPClassic.GroupQuestFrame.Button1ntex:SetTexture("Interface/Buttons/UI-Panel-Button-Up")
71 | AAPClassic.GroupQuestFrame.Button1ntex:SetTexCoord(0, 0.625, 0, 0.6875)
72 | AAPClassic.GroupQuestFrame.Button1ntex:SetAllPoints()
73 | AAPClassic.GroupQuestFrame.Button1:SetNormalTexture(AAPClassic.GroupQuestFrame.Button1ntex)
74 | AAPClassic.GroupQuestFrame.Button1htex = AAPClassic.GroupQuestFrame.Button1:CreateTexture()
75 | AAPClassic.GroupQuestFrame.Button1htex:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
76 | AAPClassic.GroupQuestFrame.Button1htex:SetTexCoord(0, 0.625, 0, 0.6875)
77 | AAPClassic.GroupQuestFrame.Button1htex:SetAllPoints()
78 | AAPClassic.GroupQuestFrame.Button1:SetHighlightTexture(AAPClassic.GroupQuestFrame.Button1htex)
79 | AAPClassic.GroupQuestFrame.Button1ptex = AAPClassic.GroupQuestFrame.Button1:CreateTexture()
80 | AAPClassic.GroupQuestFrame.Button1ptex:SetTexture("Interface/Buttons/UI-Panel-Button-Down")
81 | AAPClassic.GroupQuestFrame.Button1ptex:SetTexCoord(0, 0.625, 0, 0.6875)
82 | AAPClassic.GroupQuestFrame.Button1ptex:SetAllPoints()
83 | AAPClassic.GroupQuestFrame.Button1:SetPushedTexture(AAPClassic.GroupQuestFrame.Button1ptex)
84 | AAPClassic.GroupQuestFrame["Button1"]:SetScript("OnClick", function(self, arg1)
85 | AAPClassic.QAskPopWantedAsk("yes")
86 | end)
87 | AAPClassic.GroupQuestFrame["Button2"] = CreateFrame("Button", "AAP_SBX2", UIParent, "SecureActionButtonTemplate")
88 | AAPClassic.GroupQuestFrame["Button2"]:SetPoint("BOTTOMRIGHT",AAPClassic.GroupQuestFrame,"BOTTOMRIGHT",-15,5)
89 | AAPClassic.GroupQuestFrame["Button2"]:SetWidth(110)
90 | AAPClassic.GroupQuestFrame["Button2"]:SetHeight(30)
91 | AAPClassic.GroupQuestFrame["Button2"]:SetText("Decline Quest")
92 | AAPClassic.GroupQuestFrame["Button2"]:SetParent(AAPClassic.GroupQuestFrame)
93 | AAPClassic.GroupQuestFrame.Button2:SetNormalFontObject("GameFontNormal")
94 | AAPClassic.GroupQuestFrame.Button2ntex = AAPClassic.GroupQuestFrame.Button2:CreateTexture()
95 | AAPClassic.GroupQuestFrame.Button2ntex:SetTexture("Interface/Buttons/UI-Panel-Button-Up")
96 | AAPClassic.GroupQuestFrame.Button2ntex:SetTexCoord(0, 0.625, 0, 0.6875)
97 | AAPClassic.GroupQuestFrame.Button2ntex:SetAllPoints()
98 | AAPClassic.GroupQuestFrame.Button2:SetNormalTexture(AAPClassic.GroupQuestFrame.Button2ntex)
99 | AAPClassic.GroupQuestFrame.Button2htex = AAPClassic.GroupQuestFrame.Button2:CreateTexture()
100 | AAPClassic.GroupQuestFrame.Button2htex:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
101 | AAPClassic.GroupQuestFrame.Button2htex:SetTexCoord(0, 0.625, 0, 0.6875)
102 | AAPClassic.GroupQuestFrame.Button2htex:SetAllPoints()
103 | AAPClassic.GroupQuestFrame.Button2:SetHighlightTexture(AAPClassic.GroupQuestFrame.Button2htex)
104 | AAPClassic.GroupQuestFrame.Button2ptex = AAPClassic.GroupQuestFrame.Button2:CreateTexture()
105 | AAPClassic.GroupQuestFrame.Button2ptex:SetTexture("Interface/Buttons/UI-Panel-Button-Down")
106 | AAPClassic.GroupQuestFrame.Button2ptex:SetTexCoord(0, 0.625, 0, 0.6875)
107 | AAPClassic.GroupQuestFrame.Button2ptex:SetAllPoints()
108 | AAPClassic.GroupQuestFrame.Button2:SetPushedTexture(AAPClassic.GroupQuestFrame.Button2ptex)
109 | AAPClassic.GroupQuestFrame["Button2"]:SetScript("OnClick", function(self, arg1)
110 | AAPClassic.QAskPopWantedAsk("no")
111 | end)
112 |
113 |
114 |
115 |
116 |
117 | AAPClassic.QL.MainFrame = CreateFrame("frame", "AAPClassic_QL_QButtonMi_MainFrame", UIParent)
118 | AAPClassic.QL.MainFrame:SetWidth(1)
119 | AAPClassic.QL.MainFrame:SetHeight(1)
120 | AAPClassic.QL.MainFrame:SetMovable(true)
121 | AAPClassic.QL.MainFrame:EnableMouse(true)
122 | AAPClassic.QL.MainFrame:SetFrameStrata("MEDIUM")
123 | AAPClassic.QL.MainFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 1, 1)
124 |
125 | AAPClassic.QL.QButtonFrame = CreateFrame("frame", "AAPClassic_QL_QButton_ListFrame", UIParent)
126 | AAPClassic.QL.QButtonFrame:SetWidth(55)
127 | AAPClassic.QL.QButtonFrame:SetHeight(55)
128 | AAPClassic.QL.QButtonFrame:SetFrameStrata("MEDIUM")
129 | AAPClassic.QL.QButtonFrame:SetPoint("CENTER", UIParent, "CENTER",0,0)
130 | AAPClassic.QL.QButtonFrame:SetMovable(true)
131 | AAPClassic.QL.QButtonFrame:EnableMouse(true)
132 | AAPClassic.QL.QButtonFrame:SetScript("OnMouseDown", function(self, button)
133 | if (button == "LeftButton" and not AAPClassic.QL.QButtonFrame.isMoving) then
134 | AAPClassic.QL.QButtonFrame:StartMoving();
135 | AAPClassic.QL.QButtonFrame.isMoving = true;
136 | end
137 | end)
138 | AAPClassic.QL.QButtonFrame:SetScript("OnMouseUp", function(self, button)
139 | if (button == "LeftButton" and AAPClassic.QL.QButtonFrame.isMoving) then
140 | AAPClassic.QL.QButtonFrame:StopMovingOrSizing();
141 | AAPClassic.QL.QButtonFrame.isMoving = false;
142 | end
143 | end)
144 | AAPClassic.QL.QButtonFrame:SetScript("OnHide", function(self)
145 | if ( AAPClassic.QL.QButtonFrame.isMoving ) then
146 | AAPClassic.QL.QButtonFrame:StopMovingOrSizing();
147 | AAPClassic.QL.QButtonFrame.isMoving = false;
148 | end
149 | end)
150 | AAPClassic.QL.QButtonFrame:SetBackdrop( {
151 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
152 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
153 | tile = true, tileSize = 10, edgeSize = 10, insets = { left = 2, right = 2, top = 2, bottom = 2 }
154 | });
155 |
156 | AAPClassic.QL.QButtonFrame["Button"] = CreateFrame("Button", "AAPClassic_QL_QButtonFrame_Button", AAPClassic.QL.QButtonFrame, "SecureActionButtonTemplate")
157 | AAPClassic.QL.QButtonFrame["Button"]:SetWidth(37)
158 | AAPClassic.QL.QButtonFrame["Button"]:SetHeight(37)
159 | AAPClassic.QL.QButtonFrame["Button"]:SetText("X")
160 | AAPClassic.QL.QButtonFrame["Button"]:SetPoint("CENTER",AAPClassic.QL.QButtonFrame,"CENTER",0,0)
161 | AAPClassic.QL.QButtonFrame["Button"]:SetNormalFontObject("GameFontNormalLarge")
162 | AAPClassic.QL.QButtonFrame["Buttonntex"] = AAPClassic.QL.QButtonFrame["Button"]:CreateTexture()
163 | AAPClassic.QL.QButtonFrame["Buttonntex"]:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
164 | AAPClassic.QL.QButtonFrame["Buttonntex"]:SetTexCoord(0, 0.625, 0, 0.6875)
165 | AAPClassic.QL.QButtonFrame["Buttonntex"]:SetAllPoints()
166 | AAPClassic.QL.QButtonFrame["Button"]:SetNormalTexture("Interface/Buttons/UI-Panel-Button-Highlight")
167 | AAPClassic.QL.QButtonFrame["Buttonhtex"] = AAPClassic.QL.QButtonFrame["Button"]:CreateTexture()
168 | AAPClassic.QL.QButtonFrame["Buttonhtex"]:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
169 | AAPClassic.QL.QButtonFrame["Buttonhtex"]:SetTexCoord(0, 0.625, 0, 0.6875)
170 | AAPClassic.QL.QButtonFrame["Buttonhtex"]:SetAllPoints()
171 | AAPClassic.QL.QButtonFrame["Button"]:SetHighlightTexture(AAPClassic.QL.QButtonFrame["Buttonhtex"])
172 | AAPClassic.QL.QButtonFrame["Buttonptex"] = AAPClassic.QL.QButtonFrame["Button"]:CreateTexture()
173 | AAPClassic.QL.QButtonFrame["Buttonptex"]:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
174 | AAPClassic.QL.QButtonFrame["Buttonptex"]:SetTexCoord(0, 0.625, 0, 0.6875)
175 | AAPClassic.QL.QButtonFrame["Buttonptex"]:SetAllPoints()
176 | AAPClassic.QL.QButtonFrame["Button"]:SetPushedTexture(AAPClassic.QL.QButtonFrame["Buttonptex"])
177 | AAPClassic.QL.QButtonFrame["ButtonCD"] = CreateFrame("Cooldown", "AAPClassic_QL_QButtonFrame_ButtonCooldown", AAPClassic.QL.QButtonFrame["Button"], "CooldownFrameTemplate")
178 | AAPClassic.QL.QButtonFrame["ButtonCD"]:SetAllPoints()
179 | AAPClassic.QL.QButtonFrame:Hide()
180 |
181 |
182 |
183 | AAPClassic.QL.ListFrame = CreateFrame("frame", "AAPClassic_QL_QuestList_ListFrame", UIParent)
184 | AAPClassic.QL.ListFrame:SetWidth(1)
185 | AAPClassic.QL.ListFrame:SetHeight(1)
186 | AAPClassic.QL.ListFrame:SetFrameStrata("MEDIUM")
187 | AAPClassic.QL.ListFrame:SetPoint("TOPLEFT", AAPClassic.QL.MainFrame, "TOPLEFT",0,0)
188 | AAPClassic.QL.ListFrame:SetMovable(true)
189 | AAPClassic.QL.ListFrame:EnableMouse(true)
190 | AAPClassic.QL.ListFrame:SetScript("OnMouseDown", function(self, button)
191 | if (button == "LeftButton" and not AAPClassic.QL.MainFrame.isMoving) then
192 | AAPClassic.QL.MainFrame:StartMoving();
193 | AAPClassic.QL.MainFrame.isMoving = true;
194 | end
195 | end)
196 | AAPClassic.QL.ListFrame:SetScript("OnMouseUp", function(self, button)
197 | if (button == "LeftButton" and AAPClassic.QL.MainFrame.isMoving) then
198 | AAPClassic.QL.MainFrame:StopMovingOrSizing();
199 | AAPClassic.QL.MainFrame.isMoving = false;
200 | end
201 | end)
202 | AAPClassic.QL.ListFrame:SetScript("OnHide", function(self)
203 | if ( AAPClassic.QL.MainFrame.isMoving ) then
204 | AAPClassic.QL.MainFrame:StopMovingOrSizing();
205 | AAPClassic.QL.MainFrame.isMoving = false;
206 | end
207 | end)
208 | AAPClassic.QL.QuestFrames = {}
209 | local CLi
210 | for CLi = 1, 20 do
211 | AAPClassic.QL.QuestFrames[CLi] = CreateFrame("frame", "AAPClassic_QL_QuestFrames"..CLi, AAPClassic.QL.ListFrame)
212 | AAPClassic.QL.QuestFrames[CLi]:SetWidth(250)
213 |
214 | AAPClassic.QL.QuestFrames[CLi]:SetHeight(20)
215 | AAPClassic.QL.QuestFrames[CLi]:SetPoint("BOTTOMLEFT", AAPClassic.QL.ListFrame, "BOTTOMLEFT",0,-((CLi * 20)+CLi))
216 | AAPClassic.QL.QuestFrames[CLi]:SetBackdrop( {
217 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
218 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
219 | tile = true, tileSize = 10, edgeSize = 10, insets = { left = 2, right = 2, top = 2, bottom = 2 }
220 | });
221 | AAPClassic.QL.QuestFrames[CLi]:SetScript("OnMouseDown", function(self, button)
222 | if button == "LeftButton" then
223 | AAPClassic.QL.MainFrame:StartMoving();
224 | AAPClassic.QL.MainFrame.isMoving = true;
225 | end
226 | end)
227 | AAPClassic.QL.QuestFrames[CLi]:SetScript("OnMouseUp", function(self, button)
228 | if button == "LeftButton" and AAPClassic.QL.MainFrame.isMoving then
229 | AAPClassic.QL.MainFrame:StopMovingOrSizing();
230 | AAPClassic.QL.MainFrame.isMoving = false;
231 | end
232 | end)
233 | AAPClassic.QL.QuestFrames[CLi]:SetScript("OnHide", function(self)
234 | if ( AAPClassic.QL.MainFrame.isMoving ) then
235 | AAPClassic.QL.MainFrame:StopMovingOrSizing();
236 | AAPClassic.QL.MainFrame.isMoving = false;
237 | end
238 | end)
239 | AAPClassic.QL.QuestFrames[CLi]:Hide()
240 | AAPClassic.QL.QuestFrames["FS"..CLi] = AAPClassic.QL.ListFrame:CreateFontString("CLQFS"..CLi,"ARTWORK", "ChatFontNormal")
241 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetParent(AAPClassic.QL.QuestFrames[CLi])
242 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetPoint("TOPLEFT",AAPClassic.QL.QuestFrames[CLi],"TOPLEFT",5,0)
243 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetWidth(600)
244 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetHeight(20)
245 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetJustifyH("LEFT")
246 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetFontObject("GameFontNormal")
247 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetText("")
248 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetTextColor(1, 1, 0)
249 |
250 |
251 |
252 | end
253 |
254 | end
255 |
256 | AAPClassic.QL.QuestListEventFrame = CreateFrame("Frame")
257 | AAPClassic.QL.QuestListEventFrame:RegisterEvent ("ADDON_LOADED")
258 |
259 | AAPClassic.QL.QuestListEventFrame:SetScript("OnEvent", function(self, event, ...)
260 | if (event=="ADDON_LOADED") then
261 | local arg1, arg2, arg3, arg4, arg5 = ...;
262 | if (arg1 == "AAP-Classic") then
263 | AAPClassic.MakeQuestList()
264 | end
265 | end
266 | end)
--------------------------------------------------------------------------------
/QuestListFunctions.lua:
--------------------------------------------------------------------------------
1 | AAPClassic.QLF = {}
2 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
3 | --return
4 | end
5 | local LineNumber = 0
6 | AAPClassic.CurZoneQListed = 0
7 | AAPClassic.XpLine = 0
8 | AAPClassic.CurZoneQListedList = {}
9 | function AAPClassic.QLF.ResetList()
10 | LineNumber = 0
11 | local CLi
12 | for CLi = 1, 20 do
13 | AAPClassic.QL.QuestFrames[CLi]:Hide()
14 | AAPClassic.QL.QuestFrames["FS"..CLi]:SetText("")
15 | end
16 |
17 | end
18 | function AAPClassic.SetWidthFrames()
19 | local CLi
20 | for CLi = 1, 20 do
21 | if (AAPClassic.QL.QuestFrames[CLi]:IsShown()) then
22 | local aapwidth = AAPClassic.QL.QuestFrames["FS"..CLi]:GetStringWidth()
23 | if (aapwidth and aapwidth > 250) then
24 | AAPClassic.QL.QuestFrames[CLi]:SetWidth(aapwidth+10)
25 | else
26 | AAPClassic.QL.QuestFrames[CLi]:SetWidth(250)
27 | end
28 | end
29 | end
30 | end
31 | function AAPClassic.QLF.PrintText(ExtralineText)
32 | if (LineNumber ~= 20) then
33 | LineNumber = LineNumber + 1
34 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText(ExtralineText)
35 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
36 | end
37 | end
38 | function AAPClassic.QLF.SetButton(ItemIdz, stuck)
39 | if (stuck and stuck == "HS") then
40 | local CL_Items, itemLink, clt3, clt4, clt5, clt6, clt7, clt8, clt9, CL_ItemTex = GetItemInfo(6948)
41 | if (CL_Items and string.sub(CL_Items, 1, 1) and CL_ItemTex) then
42 | AAPClassic.QL.QButtonFrame["Buttonptex"]:SetTexture(CL_ItemTex)
43 | AAPClassic.QL.QButtonFrame["Buttonntex"]:SetTexture(CL_ItemTex)
44 | AAPClassic.QL.QButtonFrame["Button"]:SetNormalTexture(CL_ItemTex)
45 | AAPClassic.QL.QButtonFrame["Button"]:SetText("")
46 | AAPClassic.QL.QButtonFrame["Button"]:SetAttribute("type", "item");
47 | AAPClassic.QL.QButtonFrame["Button"]:SetAttribute("item", "item:"..6948);
48 | AAPClassic.QL.QButtonFrame["Button"]:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_CURSOR"); GameTooltip:SetItemByID(6948); GameTooltip:Show() end)
49 | AAPClassic.QL.QButtonFrame["Button"]:SetScript("OnLeave", function(self) GameTooltip:Hide() end)
50 | AAPClassic.QL.QButtonFrame:Show()
51 | end
52 | elseif (stuck) then
53 | AAPClassic.QL.QButtonFrame["Buttonptex"]:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp")
54 | AAPClassic.QL.QButtonFrame["Buttonntex"]:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp")
55 | AAPClassic.QL.QButtonFrame["Button"]:SetNormalTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp")
56 | AAPClassic.QL.QButtonFrame["Button"]:SetText("")
57 | AAPClassic.QL.QButtonFrame["Button"]:SetAttribute("type", "macro")
58 | AAPClassic.QL.QButtonFrame["Button"]:SetAttribute("macrotext", "/target "..stuck)
59 | AAPClassic.QL.QButtonFrame["Button"]:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_CURSOR"); GameTooltip:SetText("Target "..stuck.."!", 1, 1, 1, 1, true); GameTooltip:Show() end)
60 | AAPClassic.QL.QButtonFrame["Button"]:SetScript("OnLeave", function(self) GameTooltip:Hide() end)
61 | AAPClassic.QL.QButtonFrame:Show()
62 | else
63 | local CL_Items, itemLink, clt3, clt4, clt5, clt6, clt7, clt8, clt9, CL_ItemTex = GetItemInfo(ItemIdz)
64 | if (CL_Items and string.sub(CL_Items, 1, 1) and CL_ItemTex) then
65 | AAPClassic.QL.QButtonFrame["Buttonptex"]:SetTexture(CL_ItemTex)
66 | AAPClassic.QL.QButtonFrame["Buttonntex"]:SetTexture(CL_ItemTex)
67 | AAPClassic.QL.QButtonFrame["Button"]:SetNormalTexture(CL_ItemTex)
68 | AAPClassic.QL.QButtonFrame["Button"]:SetText("")
69 | AAPClassic.QL.QButtonFrame["Button"]:SetAttribute("type", "item");
70 | AAPClassic.QL.QButtonFrame["Button"]:SetAttribute("item", "item:"..ItemIdz);
71 | AAPClassic.QL.QButtonFrame["Button"]:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_CURSOR"); GameTooltip:SetItemByID(ItemIdz); GameTooltip:Show() end)
72 | AAPClassic.QL.QButtonFrame["Button"]:SetScript("OnLeave", function(self) GameTooltip:Hide() end)
73 | AAPClassic.QL.QButtonFrame:Show()
74 | end
75 | end
76 |
77 |
78 | end
79 | function AAPClassic.QLF.QuestText(Step)
80 | AAPClassic.RemoveQuestIcons()
81 | if (AAPClassic.QuestHelperEnable ~= "on") then
82 | --AAPClassic.RemoveIcons()
83 | AAPClassic.CheckShowedDBz()
84 | --AAPClassic.RemoveMapIcons()
85 | end
86 | if (Step["LeaveQuests"]) then
87 | for AAP_index,AAP_value in pairs(Step["LeaveQuests"]) do
88 | AAPClassic.QH.LeaveQuest(AAP_value)
89 | end
90 | end
91 | if (Step["PickUp"]) then
92 | AAPClassic.AddQuestPickUpIconFunc()
93 | local IdList = Step["PickUp"]
94 | for AAP_index,AAP_value in pairs(IdList) do
95 | if (IsQuestFlaggedCompleted(AAP_value) == false and LineNumber ~= 20) then
96 | LineNumber = LineNumber + 1
97 | if (AAPClassic["questsNames"][AAP_value] and AAPClassic["questsNames"][AAP_value]["T"]) then
98 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Pick up: "..AAPClassic["questsNames"][AAP_value]["T"])
99 | else
100 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Pick up: "..AAP_value)
101 | end
102 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
103 | end
104 | end
105 | if (Step["ShowMobsOnMap"]) then
106 | AAPClassic.QuestDBShowMob(Step["ShowMobsOnMap"],Step["ShowMobsOnMap2"],Step["ShowMobsOnMap3"])
107 | end
108 | end
109 | if (Step["Explore"]) then
110 | LineNumber = LineNumber + 1
111 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText(Step["Explore"])
112 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
113 | end
114 | if (Step["Qpart"]) then
115 | local IdList = Step["Qpart"]
116 | local Missing
117 | local AAP_index, AAP_value, AAP_index2, AAP_value2
118 | for AAP_index,AAP_value in pairs(IdList) do
119 | local qidnbs = AAP_index
120 | if (Step["Qpart2"] and AAPClassic.QuestList[Step["Qpart2"]]) then
121 | qidnbs = Step["Qpart2"]
122 | end
123 | if (not AAPClassic.QuestList[qidnbs]) then
124 | if (Step["Qpart2"] and AAPClassic.QuestList[Step["Qpart2"]]) then
125 | else
126 | if (not Missing) then
127 | Missing = qidnbs
128 | else
129 | Missing = qidnbs..", "..Missing
130 | end
131 | end
132 | end
133 | for AAP_index2,AAP_value2 in pairs(AAP_value) do
134 | local Indnumb = AAP_index2
135 | if (IsQuestFlaggedCompleted(qidnbs)) then
136 | elseif (AAPClassic.QuestList[qidnbs] and AAPClassic.QuestList[qidnbs]["Objectives"] and AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(Indnumb)] and AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(Indnumb)]["isComplete"] == 1) then
137 | elseif (LineNumber ~= 20 and AAPClassic.QuestList[qidnbs] and AAPClassic.QuestList[qidnbs]["Objectives"] and AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(Indnumb)] and AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(Indnumb)] and AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(Indnumb)]["text"]) then
138 | LineNumber = LineNumber + 1
139 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText(AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(Indnumb)]["text"])
140 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
141 | if (AAPClassic.QuestHelperEnable ~= "on") then
142 | --if (not AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(nmb)]["Listed"]) then
143 | AAPClassic.QuestDBcheck(qidnbs, tonumber(Indnumb), AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(Indnumb)]["text"])
144 | -- AAPClassic.QuestList[qidnbs]["Objectives"][tonumber(nmb)]["Listed"] = 1
145 | --end
146 | end
147 | end
148 | end
149 | end
150 | if (Step["ShowMobsOnMap"]) then
151 | AAPClassic.QuestDBShowMob(Step["ShowMobsOnMap"],Step["ShowMobsOnMap2"],Step["ShowMobsOnMap3"])
152 | end
153 | if (Step["ShowObjectOnMap"]) then
154 | AAPClassic.QuestDBShowObj(Step["ShowObjectOnMap"], Step["ExtraQpart"],Step["ShowObjectOnMap2"],Step["ShowObjectOnMap3"])
155 | end
156 | if (Missing and LineNumber ~= 20) then
157 | LineNumber = LineNumber + 1
158 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Quests Missing: "..Missing)
159 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
160 | end
161 | end
162 | if (Step["DoneClass"]) then
163 | local IdList = Step["DoneClass"]
164 | local Class = AAPClassic.Class[3]
165 | if (Step["DoneClass"][Class] and LineNumber ~= 20 and Step["DoneClass"][Class][AAPClassic.Race] and Step["DoneClass"][Class][AAPClassic.Race]["Qid"]) then
166 | local qidz = Step["DoneClass"][Class][AAPClassic.Race]["Qid"]
167 | LineNumber = LineNumber + 1
168 | if (AAPClassic.QuestList[qidz]) then
169 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Hand in: "..AAPClassic.QuestList[qidz]["title"])
170 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
171 | end
172 | end
173 | end
174 | if (Step["Done"]) then
175 | AAPClassic.AddQuestHandinIconFunc()
176 | local IdList = Step["Done"]
177 | local Missing
178 | for AAP_index,AAP_value in pairs(IdList) do
179 | local Derpster = AAP_value
180 | if (Step["Done2"] and AAPClassic.QuestList[Step["Done2"]]) then
181 | Derpster = Step["Done2"]
182 | end
183 | if (AAPClassic.QuestList[Derpster] and LineNumber ~= 20) then
184 | LineNumber = LineNumber + 1
185 | --print(LineNumber)
186 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Hand in: "..AAPClassic.QuestList[Derpster]["title"])
187 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
188 | end
189 | if (not AAPClassic.QuestList[Derpster] and not IsQuestFlaggedCompleted(Derpster)) then
190 | Missing = Derpster
191 | end
192 | end
193 | if (Missing and LineNumber ~= 20) then
194 | LineNumber = LineNumber + 1
195 | if (AAPClassic["questsNames"][Missing] and AAPClassic["questsNames"][Missing]["T"]) then
196 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Quests Missing: "..AAPClassic["questsNames"][Missing]["T"].." ("..Missing..")")
197 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
198 | else
199 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Quests Missing: "..Missing)
200 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
201 | end
202 | end
203 | end
204 | if (Step["CRange"] and LineNumber ~= 20) then
205 | LineNumber = LineNumber + 1
206 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Run to Waypoint ("..AAPClassic.CheckCRangeText()..")")
207 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
208 | end
209 | if (Step["SetHS"] and LineNumber ~= 20) then
210 | LineNumber = LineNumber + 1
211 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Set Hearthstone")
212 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
213 | end
214 | if (Step["UseFlightPath"] and LineNumber ~= 20) then
215 | LineNumber = LineNumber + 1
216 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Use Flightpath: "..Step["Name"])
217 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
218 | end
219 | if (Step["GetFP"] and LineNumber ~= 20) then
220 | LineNumber = LineNumber + 1
221 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Get Flightpath")
222 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
223 | end
224 | if (Step["UseHS"] and LineNumber ~= 20) then
225 | LineNumber = LineNumber + 1
226 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Use Hearthstone")
227 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
228 | end
229 | if (Step["ExtraQpart"] and LineNumber ~= 20) then
230 | LineNumber = LineNumber + 1
231 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText(Step["ExtraQpart"].." "..GetItemCount(Step["ItemID"]).."/"..Step["Ammount"])
232 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
233 | if (Step["ItemID"] and Step["ExtraLine"] and Step["ItemID2"] and Step["ItemID3"]) then
234 | AAPClassic.ItemDBcheck(Step["ItemID"], Step["ExtraLine"],Step["ItemID2"],Step["ItemID3"])
235 | elseif (Step["ItemID"] and Step["ExtraLine"] and Step["Qid"]) then
236 | AAPClassic.ItemDBcheck(Step["ItemID"], Step["ExtraLine"],Step["Qid"],1)
237 | end
238 | if (Step["ShowObjectOnMap"]) then
239 | AAPClassic.QuestDBShowObj(Step["ShowObjectOnMap"], Step["ExtraQpart"],Step["ShowObjectOnMap2"],Step["ShowObjectOnMap3"])
240 | end
241 | end
242 | if (Step["Grind"] and LineNumber ~= 20) then
243 | LineNumber = LineNumber + 1
244 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Grind Mobs to "..Step["xp"].."xp into lvl"..Step["level"])
245 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
246 |
247 | AAPClassic.Level = UnitLevel("player")
248 | AAPClassic.experience = UnitXP("player")
249 | if (AAPClassic.Level == Step["level"] or AAPClassic.Level == Step["level"]-1) then
250 | local xps = Step["xp"] - AAPClassic.experience
251 | if (AAPClassic.Level == Step["level"]-1) then
252 | xps = (UnitXPMax("player")-AAPClassic.experience)+Step["xp"]
253 | end
254 | LineNumber = LineNumber + 1
255 | AAPClassic.XpLine = LineNumber
256 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText(xps.." exp to go!")
257 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
258 | end
259 | if (Step["ShowMobsOnMap"]) then
260 | AAPClassic.QuestDBShowMob(Step["ShowMobsOnMap"],Step["ShowMobsOnMap2"],Step["ShowMobsOnMap3"])
261 | end
262 | end
263 | if (Step["LearnCooking"] and LineNumber ~= 20) then
264 | LineNumber = LineNumber + 1
265 | if (Step["Skinning"]) then
266 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Learn Skinning (for cash)!")
267 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
268 | else
269 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Learn Cooking!")
270 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
271 | end
272 | end
273 | if (Step["TrainAbilitys"] and LineNumber ~= 20) then
274 | LineNumber = LineNumber + 1
275 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText("Train abilitys at Class Trainer!")
276 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
277 |
278 | end
279 | end
280 | function AAPClassic.QLF.FillerText(TheFillers)
281 | for AAP_index,AAP_value in pairs(TheFillers) do
282 | for AAP_index2,AAP_value2 in pairs(AAP_value) do
283 | if (IsQuestFlaggedCompleted(AAP_index)) then
284 | elseif (AAPClassic.QuestList[AAP_index] and AAPClassic.QuestList[AAP_index]["Objectives"] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)]["isComplete"] == 1) then
285 | elseif (AAPClassic.QuestList[AAP_index] and AAPClassic.QuestList[AAP_index]["Objectives"] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)]["text"] and LineNumber ~= 20) then
286 | LineNumber = LineNumber + 1
287 | AAPClassic.QL.QuestFrames["FS"..LineNumber]:SetText(AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)]["text"])
288 | AAPClassic.QL.QuestFrames[LineNumber]:Show()
289 | AAPClassic.QuestDBcheck(AAP_index, tonumber(AAP_index2), AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)]["text"], "Filler")
290 | end
291 | end
292 | end
293 | end
294 |
295 |
296 |
297 |
298 | function AAPClassic.QLF.ReprintList()
299 | --print("AAPClassic.QLF.ReprintList()")
300 | if (AAPClassic.QH.ZoneNr and AAPC1 and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]) then
301 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
302 | if (CurStep and AAPClassic.Path and AAPClassic.Path[AAPClassic.QH.ZoneNr] and AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]) then
303 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
304 | AAPClassic.QLF.ResetList()
305 | if (Step["ExtraLine"]) then
306 | AAPClassic.QLF.PrintText(Step["ExtraLine"])
307 | end
308 | if (Step["ExtraLine2"]) then
309 | AAPClassic.QLF.PrintText(Step["ExtraLine2"])
310 | end
311 | if (Step["ExtraLine3"]) then
312 | AAPClassic.QLF.PrintText(Step["ExtraLine3"])
313 | end
314 | AAPClassic.QLF.QuestText(Step)
315 | if (Step["Fillers"]) then
316 | AAPClassic.QLF.FillerText(Step["Fillers"])
317 | end
318 | AAPClassic.SetWidthFrames()
319 | end
320 | end
321 | end
--------------------------------------------------------------------------------
/QuestFunctions.lua:
--------------------------------------------------------------------------------
1 | AAPClassic.QF = {}
2 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
3 | --return
4 | end
5 | function AAPClassic.QF.GroupQuestFrame()
6 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
7 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
8 | local IdList = Step["QaskPopup"]
9 | local gnr = Step["Group"]
10 | if (IdList and AAPClassic["questsNames"][IdList]) then
11 | if (AAPClassic["quests"][IdList] and AAPClassic["quests"][IdList]["lvl"]) then
12 | AAPClassic.GroupQuestFrameFS1:SetText("["..AAPClassic["quests"][IdList]["lvl"].."] "..AAPClassic["questsNames"][IdList]["T"])
13 | else
14 | AAPClassic.GroupQuestFrameFS1:SetText(AAPClassic["questsNames"][IdList])
15 | end
16 | AAPClassic.GroupQuestFrameFS2:SetText("Suggested Players: "..gnr)
17 | end
18 | AAPClassic.GroupQuestFrame:Show()
19 | end
20 | function AAPClassic.QF.PickUp()
21 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
22 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
23 | local IdList = Step["PickUp"]
24 | --print("PickUp!")
25 | local NrLeft = 0
26 | local Flagged = 0
27 | local Total = 0
28 | for h=1, getn(IdList) do
29 | local theqid = IdList[h]
30 | Total = Total + 1
31 | if (not AAPClassic.QuestList[theqid] and IsQuestFlaggedCompleted(theqid) == false) then
32 | NrLeft = NrLeft + 1
33 | end
34 | if (IsQuestFlaggedCompleted(theqid) or AAPClassic.QuestList[theqid] or (AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"] and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"][theqid])) then
35 | Flagged = Flagged + 1
36 | end
37 | end
38 | if (Step["PickUp2"] and (AAPClassic.QuestList[Step["PickUp2"]] or IsQuestFlaggedCompleted(Step["PickUp2"]))) then
39 | Total = Flagged
40 | end
41 | if (Total == Flagged) then
42 | --print("PickUp Done!")
43 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
44 | AAPClassic.QH.FuncLoopNumber = 1
45 | elseif (Step["GroupTask"] and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"][Step["GroupTask"]]) then
46 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
47 | AAPClassic.QH.FuncLoopNumber = 1
48 | else
49 | AAPClassic.QH.BookingList.SetQPTT = 1
50 | --print("PickUp: "..Flagged.."/"..Total)
51 | end
52 | if (Step and Step["Button"]) then
53 | AAPClassic.QH.BookingList.ShowButton = Step["Button"]
54 | end
55 | if (Step["PickUpClass"]) then
56 | local Class = AAPClassic.Class[3]
57 | if (Step["PickUpClass"][Class] and Step["PickUpClass"][Class][AAPClassic.Race]) then
58 | local Questids = Step["PickUpClass"][Class][AAPClassic.Race]["Qid"]
59 | if (IsQuestFlaggedCompleted(Questids) or AAPClassic.QuestList[Questids]) then
60 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
61 | AAPClassic.QH.FuncLoopNumber = 1
62 | end
63 | end
64 | end
65 | end
66 | function AAPClassic.QF.Qpart()
67 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
68 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
69 | local IdList = Step["Qpart"]
70 | local Flagged = 0
71 | local Total = 0
72 | local Missing = 0
73 | if (Step and Step["Button"]) then
74 | AAPClassic.QH.BookingList.ShowButton = Step["Button"]
75 | end
76 | local AAP_index, AAP_value, AAP_index2, AAP_value2
77 | for AAP_index,AAP_value in pairs(IdList) do
78 | for AAP_index2,AAP_value2 in pairs(AAP_value) do
79 | Total = Total + 1
80 | if (IsQuestFlaggedCompleted(AAP_index) or (AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"] and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"][AAP_index])) then
81 | Flagged = Flagged + 1
82 | elseif (AAPClassic.QuestList[AAP_index] and AAPClassic.QuestList[AAP_index]["Objectives"] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)]["isComplete"] == 1) then
83 | Flagged = Flagged + 1
84 | elseif (AAPClassic.QuestList[AAP_index] and AAPClassic.QuestList[AAP_index]["Objectives"] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)] and AAPClassic.QuestList[AAP_index]["Objectives"][tonumber(AAP_index2)]) then
85 | elseif (not AAPClassic.QuestList[AAP_index]) then
86 | Missing = 1
87 | end
88 | end
89 | end
90 | AAPClassic.Level = UnitLevel("player")
91 | if (Step["Qpart2"] and (AAPClassic.QuestList[Step["Qpart2"]] or IsQuestFlaggedCompleted(Step["Qpart2"]))) then
92 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
93 | AAPClassic.QH.FuncLoopNumber = 1
94 | elseif (Step["AutoSkipLevel"] and AAPClassic.Level >= Step["AutoSkipLevel"]) then
95 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
96 | AAPClassic.QH.FuncLoopNumber = 1
97 | elseif (Missing == 1) then
98 | -- print("Qpart: Quest Missing!")
99 | elseif (Total == Flagged) then
100 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
101 | AAPClassic.QH.FuncLoopNumber = 1
102 | elseif (Step["GroupTask"] and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"][Step["GroupTask"]]) then
103 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
104 | AAPClassic.QH.FuncLoopNumber = 1
105 | else
106 | --print("Qpart "..Flagged.."/"..Total)
107 | AAPClassic.QH.BookingList.SetQPTT = 1
108 | end
109 | end
110 | function AAPClassic.QF.Done()
111 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
112 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
113 | local IdList = Step["Done"]
114 | --print("Done!")
115 | local Flagged = 0
116 | local Total = 0
117 | local Missing = 0
118 | if (Step and Step["Button"]) then
119 | AAPClassic.QH.BookingList.ShowButton = Step["Button"]
120 | end
121 | for h=1, getn(IdList) do
122 | local theqid = IdList[h]
123 | Total = Total + 1
124 | if (not AAPClassic.QuestList[theqid] and IsQuestFlaggedCompleted(theqid) == false) then
125 | Missing = 1
126 | end
127 | if (IsQuestFlaggedCompleted(theqid)) then
128 | Flagged = Flagged + 1
129 | elseif (AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"] and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Completed"][theqid]) then
130 | Flagged = Flagged + 1
131 | end
132 | end
133 | if (Step["Done2"] and (AAPClassic.QuestList[Step["Done2"]] or IsQuestFlaggedCompleted(Step["Done2"]))) then
134 | Total = Flagged
135 | Missing = 0
136 | end
137 | if (Missing == 1) then
138 | --print("Done: Quest Missing")
139 | elseif (Total == Flagged) then
140 | --print("Done Done!")
141 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
142 | AAPClassic.QH.FuncLoopNumber = 1
143 | elseif (Step["GroupTask"] and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"][Step["GroupTask"]]) then
144 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
145 | AAPClassic.QH.FuncLoopNumber = 1
146 | end
147 | if (Step["DoneClass"]) then
148 | local Class = AAPClassic.Class[3]
149 | if (Step["DoneClass"][Class] and Step["DoneClass"][Class][AAPClassic.Race]) then
150 | local Questids = Step["DoneClass"][Class][AAPClassic.Race]["Qid"]
151 | if (IsQuestFlaggedCompleted(Questids)) then
152 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
153 | AAPClassic.QH.FuncLoopNumber = 1
154 | end
155 | end
156 | end
157 | AAPClassic.QH.BookingList.SetQPTT = 1
158 | end
159 | function AAPClassic.QF.SetHS()
160 | --print("SetHS!")
161 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
162 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
163 | local IdList = Step["SetHS"]
164 | if (IsQuestFlaggedCompleted(IdList)) then
165 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
166 | AAPClassic.QH.FuncLoopNumber = 1
167 | end
168 | AAPClassic.QH.BookingList.SetQPTT = 1
169 | end
170 | function AAPClassic.QF.TrainAbilitys()
171 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
172 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
173 | local IdList = Step["TrainAbilitys"]
174 | if (IsQuestFlaggedCompleted(IdList)) then
175 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
176 | AAPClassic.QH.FuncLoopNumber = 1
177 | end
178 | AAPClassic.QH.BookingList.SetQPTT = 1
179 | end
180 | function AAPClassic.QF.LearnCooking()
181 | --print("Cooking!")
182 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
183 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
184 | local IdList = Step["LearnCooking"]
185 | if (IsQuestFlaggedCompleted(IdList)) then
186 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
187 | AAPClassic.QH.FuncLoopNumber = 1
188 | end
189 | AAPClassic.QH.BookingList.SetQPTT = 1
190 | end
191 | function AAPClassic.QF.Explore()
192 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
193 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
194 | local IdList = Step["Explore"]
195 | if (AAPClassic.Explored[IdList]) then
196 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
197 | AAPClassic.QH.FuncLoopNumber = 1
198 | end
199 | AAPClassic.QH.BookingList.SetQPTT = 1
200 | end
201 | function AAPClassic.QF.UseHS()
202 | --print("UseHS!")
203 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
204 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
205 | local IdList = Step["UseHS"]
206 | if (IsQuestFlaggedCompleted(IdList)) then
207 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
208 | AAPClassic.QH.FuncLoopNumber = 1
209 | else
210 | AAPClassic.QH.BookingList.ShowButton = "HS"
211 | end
212 | AAPClassic.QH.BookingList.SetQPTT = 1
213 | end
214 | function AAPClassic.QAskPopWantedAsk(Answer)
215 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
216 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
217 | if (Step["QaskPopup"]) then
218 | if (Answer == "no") then
219 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"][Step["GroupTask"]] = 1
220 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
221 | AAPClassic.QH.FuncLoopNumber = 1
222 | else
223 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"][Step["GroupTask"]] = nil
224 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"][Step["GroupTask"]] = 1
225 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
226 | AAPClassic.QH.FuncLoopNumber = 1
227 | end
228 | end
229 | AAPClassic.GroupQuestFrame:Hide()
230 | end
231 | function AAPClassic.QF.Treasure()
232 | --print("Treasure!")
233 | AAPClassic.QH.BookingList.SetQPTT = 1
234 | end
235 | function AAPClassic.QF.Grind()
236 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
237 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
238 | AAPClassic.Level = UnitLevel("player")
239 | AAPClassic.experience = UnitXP("player")
240 | local IdList = Step["Grind"]
241 | if ((AAPClassic.Level > Step["level"]) or (AAPClassic.Level == Step["level"] and AAPClassic.experience > Step["xp"])) then
242 | AAPClassic.XpLine = 0
243 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
244 | AAPClassic.QH.FuncLoopNumber = 1
245 | elseif (AAPClassic.XpLine ~= 0) then
246 | AAPClassic.Level = UnitLevel("player")
247 | AAPClassic.experience = UnitXP("player")
248 | local xps = Step["xp"] - AAPClassic.experience
249 | if (AAPClassic.Level == Step["level"]-1) then
250 | xps = (UnitXPMax("player")-AAPClassic.experience)+Step["xp"]
251 | end
252 | AAPClassic.QL.QuestFrames["FS"..AAPClassic.XpLine]:SetText(xps.." exp to go!")
253 | end
254 | AAPClassic.QH.BookingList.SetQPTT = 1
255 | end
256 | function AAPClassic.QF.Cookingupdate()
257 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
258 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
259 | local IdList = Step["Cookingupdate"]
260 | if (IdList and IsQuestFlaggedCompleted(IdList)) then
261 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
262 | AAPClassic.QH.FuncLoopNumber = 1
263 | end
264 | AAPClassic.QH.BookingList.SetQPTT = 1
265 | end
266 | function AAPClassic.QF.CRange()
267 | --print("CRange!")
268 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
269 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
270 | local IdList
271 | if (Step) then
272 | IdList = Step["CRange"]
273 | end
274 | if (Step and Step["Button"]) then
275 | AAPClassic.QH.BookingList.ShowButton = Step["Button"]
276 | end
277 | if (IdList and IsQuestFlaggedCompleted(IdList)) then
278 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
279 | AAPClassic.QH.FuncLoopNumber = 1
280 | elseif (Step and Step["GroupTask"] and AAPC1[AAPClassic.Realm][AAPClassic.Name]["Elite"][Step["GroupTask"]]) then
281 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
282 | AAPClassic.QH.FuncLoopNumber = 1
283 | end
284 | AAPClassic.QH.BookingList.SetQPTT = 1
285 | end
286 | function AAPClassic.QF.GetFP()
287 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
288 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
289 | local IdList = Step["GetFP"]
290 | if (IsQuestFlaggedCompleted(IdList)) then
291 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
292 | AAPClassic.QH.FuncLoopNumber = 1
293 | end
294 | AAPClassic.QH.BookingList.SetQPTT = 1
295 | end
296 | function AAPClassic.QF.UseFP()
297 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
298 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
299 | local IdList = Step["UseFlightPath"]
300 | if (IsQuestFlaggedCompleted(IdList)) then
301 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
302 | AAPClassic.QH.FuncLoopNumber = 1
303 | end
304 | AAPClassic.QH.BookingList.SetQPTT = 1
305 | end
306 | function AAPClassic.QF.DropQ()
307 | --print("DropQ!")
308 | AAPClassic.QH.BookingList.SetQPTT = 1
309 | end
310 | function AAPClassic.QF.ExtraQ()
311 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
312 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
313 | if (Step and Step["Button"]) then
314 | AAPClassic.QH.BookingList.ShowButton = Step["Button"]
315 | end
316 | if (Step) then
317 | local ammountz = GetItemCount(Step["ItemID"])
318 | --print(IsQuestFlaggedCompleted(Step["Qid"]))
319 | if ((Step and Step["Qid"] and IsQuestFlaggedCompleted(Step["Qid"])) or (Step and ammountz and Step["Ammount"] and ammountz >= Step["Ammount"])) then
320 | AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr] + 1
321 | AAPClassic.QH.FuncLoopNumber = 1
322 | end
323 | AAPClassic.QH.BookingList.SetQPTT = 1
324 | end
325 | end
326 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/HereBeDragons-2.0.lua:
--------------------------------------------------------------------------------
1 | -- HereBeDragons is a data API for the World of Warcraft mapping system
2 |
3 | local MAJOR, MINOR = "HereBeDragons-2.0", 8
4 | assert(LibStub, MAJOR .. " requires LibStub")
5 |
6 | local HereBeDragons, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
7 | if not HereBeDragons then return end
8 |
9 | local CBH = LibStub("CallbackHandler-1.0")
10 |
11 | HereBeDragons.eventFrame = HereBeDragons.eventFrame or CreateFrame("Frame")
12 |
13 | HereBeDragons.mapData = HereBeDragons.mapData or {}
14 | HereBeDragons.worldMapData = HereBeDragons.worldMapData or {}
15 | HereBeDragons.transforms = HereBeDragons.transforms or {}
16 | HereBeDragons.callbacks = HereBeDragons.callbacks or CBH:New(HereBeDragons, nil, nil, false)
17 |
18 | -- Data Constants
19 | local COSMIC_MAP_ID = 946
20 | local WORLD_MAP_ID = 947
21 |
22 | -- Lua upvalues
23 | local PI2 = math.pi * 2
24 | local atan2 = math.atan2
25 | local pairs, ipairs = pairs, ipairs
26 | local type = type
27 | local band = bit.band
28 |
29 | -- WoW API upvalues
30 | local UnitPosition = UnitPosition
31 | local C_Map = C_Map
32 |
33 | -- data table upvalues
34 | local mapData = HereBeDragons.mapData -- table { width, height, left, top, .instance, .name, .mapType }
35 | local worldMapData = HereBeDragons.worldMapData -- table { width, height, left, top }
36 | local transforms = HereBeDragons.transforms
37 |
38 | local currentPlayerUIMapID, currentPlayerUIMapType
39 |
40 | -- Override instance ids for phased content
41 | local instanceIDOverrides = {
42 | -- Draenor
43 | [1152] = 1116, -- Horde Garrison 1
44 | [1330] = 1116, -- Horde Garrison 2
45 | [1153] = 1116, -- Horde Garrison 3
46 | [1154] = 1116, -- Horde Garrison 4 (unused)
47 | [1158] = 1116, -- Alliance Garrison 1
48 | [1331] = 1116, -- Alliance Garrison 2
49 | [1159] = 1116, -- Alliance Garrison 3
50 | [1160] = 1116, -- Alliance Garrison 4 (unused)
51 | [1191] = 1116, -- Ashran PvP Zone
52 | [1203] = 1116, -- Frostfire Finale Scenario
53 | [1207] = 1116, -- Talador Finale Scenario
54 | [1277] = 1116, -- Defense of Karabor Scenario (SMV)
55 | [1402] = 1116, -- Gorgrond Finale Scenario
56 | [1464] = 1116, -- Tanaan
57 | [1465] = 1116, -- Tanaan
58 | -- Legion
59 | [1478] = 1220, -- Temple of Elune Scenario (Val'Sharah)
60 | [1495] = 1220, -- Protection Paladin Artifact Scenario (Stormheim)
61 | [1498] = 1220, -- Havoc Demon Hunter Artifact Scenario (Suramar)
62 | [1502] = 1220, -- Dalaran Underbelly
63 | [1533] = 0, -- Karazhan Artifact Scenario
64 | [1612] = 1220, -- Feral Druid Artifact Scenario (Suramar)
65 | [1626] = 1220, -- Suramar Withered Scenario
66 | [1662] = 1220, -- Suramar Invasion Scenario
67 | }
68 |
69 | -- gather map info, but only if this isn't an upgrade (or the upgrade version forces a re-map)
70 | if not oldversion or oldversion < 7 then
71 | -- wipe old data, if required, otherwise the upgrade path isn't triggered
72 | if oldversion then
73 | wipe(mapData)
74 | wipe(worldMapData)
75 | wipe(transforms)
76 | end
77 |
78 | -- map transform data extracted from UIMapAssignment.db2 (see HereBeDragons-Scripts on GitHub)
79 | -- format: instanceID, newInstanceID, minY, maxY, minX, maxX, offsetY, offsetX
80 | local transformData = {
81 | { 530, 0, 4800, 16000, -10133.3, -2666.67, -2400, 2400 },
82 | { 530, 1, -6933.33, 533.33, -16000, -8000, 10133.3, 17600 },
83 | { 732, 0, -3200, 533.3, -533.3, 2666.7, -611.8, 3904.3 },
84 | { 1064, 870, 5391, 8148, 3518, 7655, -2134.2, -2286.6 },
85 | { 1208, 1116, -2666, -2133, -2133, -1600, 10210, 2410 },
86 | { 1460, 1220, -1066.7, 2133.3, 0, 3200, -2333.9, 966.7 },
87 | }
88 |
89 | local function processTransforms()
90 | for _, transform in pairs(transformData) do
91 | local instanceID, newInstanceID, minY, maxY, minX, maxX, offsetY, offsetX = unpack(transform)
92 | if not transforms[instanceID] then
93 | transforms[instanceID] = {}
94 | end
95 | table.insert(transforms[instanceID], { newInstanceID = newInstanceID, minY = minY, maxY = maxY, minX = minX, maxX = maxX, offsetY = offsetY, offsetX = offsetX })
96 | end
97 | end
98 |
99 | local function applyMapTransforms(instanceID, left, right, top, bottom)
100 | if transforms[instanceID] then
101 | for _, transformData in ipairs(transforms[instanceID]) do
102 | if left <= transformData.maxX and right >= transformData.minX and top <= transformData.maxY and bottom >= transformData.minY then
103 | instanceID = transformData.newInstanceID
104 | left = left + transformData.offsetX
105 | right = right + transformData.offsetX
106 | top = top + transformData.offsetY
107 | bottom = bottom + transformData.offsetY
108 | break
109 | end
110 | end
111 | end
112 | return instanceID, left, right, top, bottom
113 | end
114 |
115 | local vector00, vector05 = CreateVector2D(0, 0), CreateVector2D(0.5, 0.5)
116 | -- gather the data of one map (by uiMapID)
117 | local function processMap(id, data, parent)
118 | if not id or not data or mapData[id] then return end
119 |
120 | if data.parentMapID and data.parentMapID ~= 0 then
121 | parent = data.parentMapID
122 | elseif not parent then
123 | parent = 0
124 | end
125 |
126 | -- get two positions from the map, we use 0/0 and 0.5/0.5 to avoid issues on some maps where 1/1 is translated inaccurately
127 | local instance, topLeft = C_Map.GetWorldPosFromMapPos(id, vector00)
128 | local _, bottomRight = C_Map.GetWorldPosFromMapPos(id, vector05)
129 | if topLeft and bottomRight then
130 | local top, left = topLeft:GetXY()
131 | local bottom, right = bottomRight:GetXY()
132 | bottom = top + (bottom - top) * 2
133 | right = left + (right - left) * 2
134 |
135 | instance, left, right, top, bottom = applyMapTransforms(instance, left, right, top, bottom)
136 | mapData[id] = {left - right, top - bottom, left, top, instance = instance, name = data.name, mapType = data.mapType, parent = parent }
137 | else
138 | mapData[id] = {0, 0, 0, 0, instance = instance or -1, name = data.name, mapType = data.mapType, parent = parent }
139 | end
140 | end
141 |
142 | local function processMapChildrenRecursive(parent)
143 | local children = C_Map.GetMapChildrenInfo(parent)
144 | if children and #children > 0 then
145 | for i = 1, #children do
146 | local id = children[i].mapID
147 | if id and not mapData[id] then
148 | processMap(id, children[i], parent)
149 | processMapChildrenRecursive(id)
150 |
151 | -- process sibling maps (in the same group)
152 | -- in some cases these are not discovered by GetMapChildrenInfo above
153 | local groupID = C_Map.GetMapGroupID(id)
154 | if groupID then
155 | local groupMembers = C_Map.GetMapGroupMembersInfo(groupID)
156 | if groupMembers then
157 | for k = 1, #groupMembers do
158 | local memberId = groupMembers[k].mapID
159 | if memberId and not mapData[memberId] then
160 | processMap(memberId, C_Map.GetMapInfo(memberId), parent)
161 | processMapChildrenRecursive(memberId)
162 | end
163 | end
164 | end
165 | end
166 | end
167 | end
168 | end
169 | end
170 |
171 | local function fixupZones()
172 | local cosmic = C_Map.GetMapInfo(COSMIC_MAP_ID)
173 | mapData[COSMIC_MAP_ID] = {0, 0, 0, 0}
174 | mapData[COSMIC_MAP_ID].instance = -1
175 | mapData[COSMIC_MAP_ID].name = cosmic.name
176 | mapData[COSMIC_MAP_ID].mapType = cosmic.mapType
177 |
178 | -- data for the azeroth world map
179 | worldMapData[0] = { 76153.14, 50748.62, 65008.24, 23827.51 }
180 | worldMapData[1] = { 77803.77, 51854.98, 13157.6, 28030.61 }
181 | worldMapData[571] = { 71773.64, 50054.05, 36205.94, 12366.81 }
182 | worldMapData[870] = { 67710.54, 45118.08, 33565.89, 38020.67 }
183 | worldMapData[1220] = { 82758.64, 55151.28, 52943.46, 24484.72 }
184 | worldMapData[1642] = { 77933.3, 51988.91, 44262.36, 32835.1 }
185 | worldMapData[1643] = { 76060.47, 50696.96, 55384.8, 25774.35 }
186 | end
187 |
188 | local function gatherMapData()
189 | processTransforms()
190 |
191 | -- find all maps in well known structures
192 | processMapChildrenRecursive(COSMIC_MAP_ID)
193 |
194 | -- fixupZones()
195 |
196 | -- try to fill in holes in the map list
197 | for i = 1, 2000 do
198 | if not mapData[i] then
199 | local mapInfo = C_Map.GetMapInfo(i)
200 | if mapInfo and mapInfo.name then
201 | processMap(i, mapInfo, nil)
202 | end
203 | end
204 | end
205 | end
206 |
207 | gatherMapData()
208 | end
209 |
210 | -- Transform a set of coordinates based on the defined map transformations
211 | local function applyCoordinateTransforms(x, y, instanceID)
212 | if transforms[instanceID] then
213 | for _, transformData in ipairs(transforms[instanceID]) do
214 | if transformData.minX <= x and transformData.maxX >= x and transformData.minY <= y and transformData.maxY >= y then
215 | instanceID = transformData.newInstanceID
216 | x = x + transformData.offsetX
217 | y = y + transformData.offsetY
218 | break
219 | end
220 | end
221 | end
222 | if instanceIDOverrides[instanceID] then
223 | instanceID = instanceIDOverrides[instanceID]
224 | end
225 | return x, y, instanceID
226 | end
227 |
228 | local StartUpdateTimer
229 | local function UpdateCurrentPosition()
230 | -- retrieve current zone
231 | local uiMapID = C_Map.GetBestMapForUnit("player")
232 |
233 | if uiMapID ~= currentPlayerUIMapID then
234 | -- update upvalues and signal callback
235 | currentPlayerUIMapID, currentPlayerUIMapType = uiMapID, mapData[uiMapID] and mapData[uiMapID].mapType or 0
236 | HereBeDragons.callbacks:Fire("PlayerZoneChanged", currentPlayerUIMapID, currentPlayerUIMapType)
237 | end
238 |
239 | -- start a timer to update in micro dungeons since multi-level micro dungeons do not reliably fire events
240 | if currentPlayerUIMapType == Enum.UIMapType.Micro then
241 | StartUpdateTimer()
242 | end
243 | end
244 |
245 | -- upgradeable timer callback, don't want to keep calling the old function if the library is upgraded
246 | HereBeDragons.UpdateCurrentPosition = UpdateCurrentPosition
247 | local function UpdateTimerCallback()
248 | -- signal that the timer ran
249 | HereBeDragons.updateTimerActive = nil
250 |
251 | -- run update now
252 | HereBeDragons.UpdateCurrentPosition()
253 | end
254 |
255 | function StartUpdateTimer()
256 | if not HereBeDragons.updateTimerActive then
257 | -- prevent running multiple timers
258 | HereBeDragons.updateTimerActive = true
259 |
260 | -- and queue an update
261 | C_Timer.After(1, UpdateTimerCallback)
262 | end
263 | end
264 |
265 | local function OnEvent(frame, event, ...)
266 | UpdateCurrentPosition()
267 | end
268 |
269 | HereBeDragons.eventFrame:SetScript("OnEvent", OnEvent)
270 | HereBeDragons.eventFrame:UnregisterAllEvents()
271 | HereBeDragons.eventFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
272 | HereBeDragons.eventFrame:RegisterEvent("ZONE_CHANGED")
273 | HereBeDragons.eventFrame:RegisterEvent("ZONE_CHANGED_INDOORS")
274 | HereBeDragons.eventFrame:RegisterEvent("NEW_WMO_CHUNK")
275 | HereBeDragons.eventFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
276 |
277 | -- if we're loading after entering the world (ie. on demand), update position now
278 | if IsLoggedIn() then
279 | UpdateCurrentPosition()
280 | end
281 |
282 | --- Return the localized zone name for a given uiMapID
283 | -- @param uiMapID uiMapID of the zone
284 | function HereBeDragons:GetLocalizedMap(uiMapID)
285 | return mapData[uiMapID] and mapData[uiMapID].name or nil
286 | end
287 |
288 | --- Get the size of the zone
289 | -- @param uiMapID uiMapID of the zone
290 | -- @return width, height of the zone, in yards
291 | function HereBeDragons:GetZoneSize(uiMapID)
292 | local data = mapData[uiMapID]
293 | if not data then return 0, 0 end
294 |
295 | return data[1], data[2]
296 | end
297 |
298 | --- Get a list of all map IDs
299 | -- @return array-style table with all known/valid map IDs
300 | function HereBeDragons:GetAllMapIDs()
301 | local t = {}
302 | for id in pairs(mapData) do
303 | table.insert(t, id)
304 | end
305 | return t
306 | end
307 |
308 | --- Convert local/point coordinates to world coordinates in yards
309 | -- @param x X position in 0-1 point coordinates
310 | -- @param y Y position in 0-1 point coordinates
311 | -- @param zone uiMapID of the zone
312 | function HereBeDragons:GetWorldCoordinatesFromZone(x, y, zone)
313 | local data = mapData[zone]
314 | if not data or data[1] == 0 or data[2] == 0 then return nil, nil, nil end
315 | if not x or not y then return nil, nil, nil end
316 |
317 | local width, height, left, top = data[1], data[2], data[3], data[4]
318 | x, y = left - width * x, top - height * y
319 |
320 | return x, y, data.instance
321 | end
322 |
323 | --- Convert local/point coordinates to world coordinates in yards. The coordinates have to come from the Azeroth World Map
324 | -- @param x X position in 0-1 point coordinates
325 | -- @param y Y position in 0-1 point coordinates
326 | -- @param instance Instance to use for the world coordinates
327 | function HereBeDragons:GetWorldCoordinatesFromAzerothWorldMap(x, y, instance)
328 | local data = worldMapData[instance]
329 | if not data or data[1] == 0 or data[2] == 0 then return nil, nil, nil end
330 | if not x or not y then return nil, nil, nil end
331 |
332 | local width, height, left, top = data[1], data[2], data[3], data[4]
333 | x, y = left - width * x, top - height * y
334 |
335 | return x, y, instance
336 | end
337 |
338 |
339 | --- Convert world coordinates to local/point zone coordinates
340 | -- @param x Global X position
341 | -- @param y Global Y position
342 | -- @param zone uiMapID of the zone
343 | -- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned
344 | function HereBeDragons:GetZoneCoordinatesFromWorld(x, y, zone, allowOutOfBounds)
345 | local data = mapData[zone]
346 | if not data or data[1] == 0 or data[2] == 0 then return nil, nil end
347 | if not x or not y then return nil, nil end
348 |
349 | local width, height, left, top = data[1], data[2], data[3], data[4]
350 | x, y = (left - x) / width, (top - y) / height
351 |
352 | -- verify the coordinates fall into the zone
353 | if not allowOutOfBounds and (x < 0 or x > 1 or y < 0 or y > 1) then return nil, nil end
354 |
355 | return x, y
356 | end
357 |
358 | --- Convert world coordinates to local/point zone coordinates on the azeroth world map
359 | -- @param x Global X position
360 | -- @param y Global Y position
361 | -- @param instance Instance to translate coordinates from
362 | -- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned
363 | function HereBeDragons:GetAzerothWorldMapCoordinatesFromWorld(x, y, instance, allowOutOfBounds)
364 | local data = worldMapData[instance]
365 | if not data or data[1] == 0 or data[2] == 0 then return nil, nil end
366 | if not x or not y then return nil, nil end
367 |
368 | local width, height, left, top = data[1], data[2], data[3], data[4]
369 | x, y = (left - x) / width, (top - y) / height
370 |
371 | -- verify the coordinates fall into the zone
372 | if not allowOutOfBounds and (x < 0 or x > 1 or y < 0 or y > 1) then return nil, nil end
373 |
374 | return x, y
375 | end
376 |
377 | -- Helper function to handle world map coordinate translation
378 | local function TranslateAzerothWorldMapCoordinates(self, x, y, oZone, dZone, allowOutOfBounds)
379 | if (oZone ~= WORLD_MAP_ID and not mapData[oZone]) or (dZone ~= WORLD_MAP_ID and not mapData[dZone]) then return nil, nil end
380 | -- determine the instance we're working with
381 | local instance = (oZone == WORLD_MAP_ID) and mapData[dZone].instance or mapData[oZone].instance
382 | if not worldMapData[instance] then return nil, nil end
383 |
384 | local data = worldMapData[instance]
385 | local width, height, left, top = data[1], data[2], data[3], data[4]
386 |
387 | if oZone == WORLD_MAP_ID then
388 | x, y = self:GetWorldCoordinatesFromAzerothWorldMap(x, y, instance)
389 | return self:GetZoneCoordinatesFromWorld(x, y, dZone, allowOutOfBounds)
390 | else
391 | x, y = self:GetWorldCoordinatesFromZone(x, y, oZone)
392 | return self:GetAzerothWorldMapCoordinatesFromWorld(x, y, instance, allowOutOfBounds)
393 | end
394 | end
395 |
396 | --- Translate zone coordinates from one zone to another
397 | -- @param x X position in 0-1 point coordinates, relative to the origin zone
398 | -- @param y Y position in 0-1 point coordinates, relative to the origin zone
399 | -- @param oZone Origin Zone, uiMapID
400 | -- @param dZone Destination Zone, uiMapID
401 | -- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned
402 | function HereBeDragons:TranslateZoneCoordinates(x, y, oZone, dZone, allowOutOfBounds)
403 | if oZone == dZone then return x, y end
404 |
405 | if oZone == WORLD_MAP_ID or dZone == WORLD_MAP_ID then
406 | return TranslateAzerothWorldMapCoordinates(self, x, y, oZone, dZone, allowOutOfBounds)
407 | end
408 |
409 | local xCoord, yCoord, instance = self:GetWorldCoordinatesFromZone(x, y, oZone)
410 | if not xCoord then return nil, nil end
411 |
412 | local data = mapData[dZone]
413 | if not data or data.instance ~= instance then return nil, nil end
414 |
415 | return self:GetZoneCoordinatesFromWorld(xCoord, yCoord, dZone, allowOutOfBounds)
416 | end
417 |
418 | --- Return the distance from an origin position to a destination position in the same instance/continent.
419 | -- @param instanceID instance ID
420 | -- @param oX origin X
421 | -- @param oY origin Y
422 | -- @param dX destination X
423 | -- @param dY destination Y
424 | -- @return distance, deltaX, deltaY
425 | function HereBeDragons:GetWorldDistance(instanceID, oX, oY, dX, dY)
426 | if not oX or not oY or not dX or not dY then return nil, nil, nil end
427 | local deltaX, deltaY = dX - oX, dY - oY
428 | return (deltaX * deltaX + deltaY * deltaY)^0.5, deltaX, deltaY
429 | end
430 |
431 | --- Return the distance between two points on the same continent
432 | -- @param oZone origin zone uiMapID
433 | -- @param oX origin X, in local zone/point coordinates
434 | -- @param oY origin Y, in local zone/point coordinates
435 | -- @param dZone destination zone uiMapID
436 | -- @param dX destination X, in local zone/point coordinates
437 | -- @param dY destination Y, in local zone/point coordinates
438 | -- @return distance, deltaX, deltaY in yards
439 | function HereBeDragons:GetZoneDistance(oZone, oX, oY, dZone, dX, dY)
440 | local oX, oY, oInstance = self:GetWorldCoordinatesFromZone(oX, oY, oZone)
441 | if not oX then return nil, nil, nil end
442 |
443 | -- translate dX, dY to the origin zone
444 | local dX, dY, dInstance = self:GetWorldCoordinatesFromZone(dX, dY, dZone)
445 | if not dX then return nil, nil, nil end
446 |
447 | if oInstance ~= dInstance then return nil, nil, nil end
448 |
449 | return self:GetWorldDistance(oInstance, oX, oY, dX, dY)
450 | end
451 |
452 | --- Return the angle and distance from an origin position to a destination position in the same instance/continent.
453 | -- @param instanceID instance ID
454 | -- @param oX origin X
455 | -- @param oY origin Y
456 | -- @param dX destination X
457 | -- @param dY destination Y
458 | -- @return angle, distance where angle is in radians and distance in yards
459 | function HereBeDragons:GetWorldVector(instanceID, oX, oY, dX, dY)
460 | local distance, deltaX, deltaY = self:GetWorldDistance(instanceID, oX, oY, dX, dY)
461 | if not distance then return nil, nil end
462 |
463 | -- calculate the angle from deltaY and deltaX
464 | local angle = atan2(-deltaX, deltaY)
465 |
466 | -- normalize the angle
467 | if angle > 0 then
468 | angle = PI2 - angle
469 | else
470 | angle = -angle
471 | end
472 |
473 | return angle, distance
474 | end
475 |
476 | --- Get the current world position of the specified unit
477 | -- The position is transformed to the current continent, if applicable
478 | -- NOTE: The same restrictions as for the UnitPosition() API apply,
479 | -- which means a very limited set of unit ids will actually work.
480 | -- @param unitId Unit Id
481 | -- @return x, y, instanceID
482 | function HereBeDragons:GetUnitWorldPosition(unitId)
483 | -- get the current position
484 | local y, x, z, instanceID = UnitPosition(unitId)
485 | if not x or not y then return nil, nil, instanceIDOverrides[instanceID] or instanceID end
486 |
487 | -- return transformed coordinates
488 | return applyCoordinateTransforms(x, y, instanceID)
489 | end
490 |
491 | --- Get the current world position of the player
492 | -- The position is transformed to the current continent, if applicable
493 | -- @return x, y, instanceID
494 | function HereBeDragons:GetPlayerWorldPosition()
495 | -- get the current position
496 | local y, x, z, instanceID = UnitPosition("player")
497 | if not x or not y then return nil, nil, instanceIDOverrides[instanceID] or instanceID end
498 |
499 | -- return transformed coordinates
500 | return applyCoordinateTransforms(x, y, instanceID)
501 | end
502 |
503 | --- Get the current zone and level of the player
504 | -- The returned mapFile can represent a micro dungeon, if the player currently is inside one.
505 | -- @return uiMapID, mapType
506 | function HereBeDragons:GetPlayerZone()
507 | return currentPlayerUIMapID, currentPlayerUIMapType
508 | end
509 |
510 | --- Get the current position of the player on a zone level
511 | -- The returned values are local point coordinates, 0-1. The mapFile can represent a micro dungeon.
512 | -- @param allowOutOfBounds Allow coordinates to go beyond the current map (ie. outside of the 0-1 range), otherwise nil will be returned
513 | -- @return x, y, uiMapID, mapType
514 | function HereBeDragons:GetPlayerZonePosition(allowOutOfBounds)
515 | if not currentPlayerUIMapID then return nil, nil, nil, nil end
516 | local x, y, instanceID = self:GetPlayerWorldPosition()
517 | if not x or not y then return nil, nil, nil, nil end
518 |
519 | x, y = self:GetZoneCoordinatesFromWorld(x, y, currentPlayerUIMapID, allowOutOfBounds)
520 | if x and y then
521 | return x, y, currentPlayerUIMapID, currentPlayerUIMapType
522 | end
523 | return nil, nil, nil, nil
524 | end
525 |
--------------------------------------------------------------------------------
/lib/HereBeDragons/HereBeDragons-Pins-1.0.lua:
--------------------------------------------------------------------------------
1 | -- HereBeDragons-Pins is a library to show pins/icons on the world map and minimap
2 |
3 | -- HereBeDragons-Pins-1.0 is not supported on WoW 8.0
4 | if select(4, GetBuildInfo()) >= 80000 then
5 | return
6 | end
7 |
8 |
9 | local MAJOR, MINOR = "HereBeDragons-Pins-1.0", 16
10 | assert(LibStub, MAJOR .. " requires LibStub")
11 |
12 | local pins, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
13 | if not pins then return end
14 |
15 | local HBD = LibStub("HereBeDragons-1.0")
16 |
17 | pins.updateFrame = pins.updateFrame or CreateFrame("Frame")
18 |
19 | -- storage for minimap pins
20 | pins.minimapPins = pins.minimapPins or {}
21 | pins.activeMinimapPins = pins.activeMinimapPins or {}
22 | pins.minimapPinRegistry = pins.minimapPinRegistry or {}
23 |
24 | -- and worldmap pins
25 | pins.worldmapPins = pins.worldmapPins or {}
26 | pins.worldmapPinRegistry = pins.worldmapPinRegistry or {}
27 |
28 | -- store a reference to the active minimap object
29 | pins.Minimap = pins.Minimap or Minimap
30 |
31 | -- upvalue lua api
32 | local cos, sin, max = math.cos, math.sin, math.max
33 | local type, pairs = type, pairs
34 |
35 | -- upvalue wow api
36 | local GetPlayerFacing = GetPlayerFacing
37 |
38 | -- upvalue data tables
39 | local minimapPins = pins.minimapPins
40 | local activeMinimapPins = pins.activeMinimapPins
41 | local minimapPinRegistry = pins.minimapPinRegistry
42 |
43 | local worldmapPins = pins.worldmapPins
44 | local worldmapPinRegistry = pins.worldmapPinRegistry
45 |
46 | local minimap_size = {
47 | indoor = {
48 | [0] = 300, -- scale
49 | [1] = 240, -- 1.25
50 | [2] = 180, -- 5/3
51 | [3] = 120, -- 2.5
52 | [4] = 80, -- 3.75
53 | [5] = 50, -- 6
54 | },
55 | outdoor = {
56 | [0] = 466 + 2/3, -- scale
57 | [1] = 400, -- 7/6
58 | [2] = 333 + 1/3, -- 1.4
59 | [3] = 266 + 2/6, -- 1.75
60 | [4] = 200, -- 7/3
61 | [5] = 133 + 1/3, -- 3.5
62 | },
63 | }
64 |
65 | local minimap_shapes = {
66 | -- { upper-left, lower-left, upper-right, lower-right }
67 | ["SQUARE"] = { false, false, false, false },
68 | ["CORNER-TOPLEFT"] = { true, false, false, false },
69 | ["CORNER-TOPRIGHT"] = { false, false, true, false },
70 | ["CORNER-BOTTOMLEFT"] = { false, true, false, false },
71 | ["CORNER-BOTTOMRIGHT"] = { false, false, false, true },
72 | ["SIDE-LEFT"] = { true, true, false, false },
73 | ["SIDE-RIGHT"] = { false, false, true, true },
74 | ["SIDE-TOP"] = { true, false, true, false },
75 | ["SIDE-BOTTOM"] = { false, true, false, true },
76 | ["TRICORNER-TOPLEFT"] = { true, true, true, false },
77 | ["TRICORNER-TOPRIGHT"] = { true, false, true, true },
78 | ["TRICORNER-BOTTOMLEFT"] = { true, true, false, true },
79 | ["TRICORNER-BOTTOMRIGHT"] = { false, true, true, true },
80 | }
81 |
82 | local tableCache = setmetatable({}, {__mode='k'})
83 |
84 | local function newCachedTable()
85 | local t = next(tableCache)
86 | if t then
87 | tableCache[t] = nil
88 | else
89 | t = {}
90 | end
91 | return t
92 | end
93 |
94 | local function recycle(t)
95 | tableCache[t] = true
96 | end
97 |
98 | -- minimap rotation
99 | local rotateMinimap = GetCVar("rotateMinimap") == "1"
100 |
101 | -- is the minimap indoors or outdoors
102 | local indoors = GetCVar("minimapZoom")+0 == pins.Minimap:GetZoom() and "outdoor" or "indoor"
103 |
104 | local minimapPinCount, queueFullUpdate = 0, false
105 | local minimapScale, minimapShape, mapRadius, minimapWidth, minimapHeight, mapSin, mapCos
106 | local lastZoom, lastFacing, lastXY, lastYY
107 |
108 | local worldmapWidth, worldmapHeight = WorldMapButton:GetWidth(), WorldMapButton:GetHeight()
109 |
110 | local function drawMinimapPin(pin, data)
111 | local xDist, yDist = lastXY - data.x, lastYY - data.y
112 |
113 | -- handle rotation
114 | if rotateMinimap then
115 | local dx, dy = xDist, yDist
116 | xDist = dx*mapCos - dy*mapSin
117 | yDist = dx*mapSin + dy*mapCos
118 | end
119 |
120 | -- adapt delta position to the map radius
121 | local diffX = xDist / mapRadius
122 | local diffY = yDist / mapRadius
123 |
124 | -- different minimap shapes
125 | local isRound = true
126 | if minimapShape and not (xDist == 0 or yDist == 0) then
127 | isRound = (xDist < 0) and 1 or 3
128 | if yDist < 0 then
129 | isRound = minimapShape[isRound]
130 | else
131 | isRound = minimapShape[isRound + 1]
132 | end
133 | end
134 |
135 | -- calculate distance from the center of the map
136 | local dist
137 | if isRound then
138 | dist = (diffX*diffX + diffY*diffY) / 0.9^2
139 | else
140 | dist = max(diffX*diffX, diffY*diffY) / 0.9^2
141 | end
142 |
143 | -- if distance > 1, then adapt node position to slide on the border
144 | if dist > 1 and data.floatOnEdge then
145 | dist = dist^0.5
146 | diffX = diffX/dist
147 | diffY = diffY/dist
148 | end
149 |
150 | if dist <= 1 or data.floatOnEdge then
151 | pin:Show()
152 | pin:ClearAllPoints()
153 | pin:SetPoint("CENTER", pins.Minimap, "CENTER", diffX * minimapWidth, -diffY * minimapHeight)
154 | data.onEdge = (dist > 1)
155 | else
156 | pin:Hide()
157 | data.onEdge = nil
158 | pin.keep = nil
159 | end
160 | end
161 |
162 | local function UpdateMinimapPins(force)
163 | -- get the current player position
164 | local x, y, instanceID = HBD:GetPlayerWorldPosition()
165 | local mapID, mapFloor = HBD:GetPlayerZone()
166 |
167 | -- get data from the API for calculations
168 | local zoom = pins.Minimap:GetZoom()
169 | local diffZoom = zoom ~= lastZoom
170 |
171 | -- for rotating minimap support
172 | local facing
173 | if rotateMinimap then
174 | facing = GetPlayerFacing()
175 | else
176 | facing = lastFacing
177 | end
178 |
179 | -- check for all values to be available (starting with 7.1.0, instances don't report coordinates)
180 | if not x or not y or (rotateMinimap and not facing) then
181 | minimapPinCount = 0
182 | for pin, data in pairs(activeMinimapPins) do
183 | pin:Hide()
184 | activeMinimapPins[pin] = nil
185 | end
186 | return
187 | end
188 |
189 | local newScale = pins.Minimap:GetScale()
190 | if minimapScale ~= newScale then
191 | minimapScale = newScale
192 | force = true
193 | end
194 |
195 | if x ~= lastXY or y ~= lastYY or diffZoom or facing ~= lastFacing or force then
196 | -- minimap information
197 | minimapShape = GetMinimapShape and minimap_shapes[GetMinimapShape() or "ROUND"]
198 | mapRadius = minimap_size[indoors][zoom] / 2
199 | minimapWidth = pins.Minimap:GetWidth() / 2
200 | minimapHeight = pins.Minimap:GetHeight() / 2
201 |
202 | -- update upvalues for icon placement
203 | lastZoom = zoom
204 | lastFacing = facing
205 | lastXY, lastYY = x, y
206 |
207 | if rotateMinimap then
208 | mapSin = sin(facing)
209 | mapCos = cos(facing)
210 | end
211 |
212 | for pin, data in pairs(minimapPins) do
213 | if data.instanceID == instanceID and (not data.floor or (data.floor == mapFloor and (data.floor == 0 or data.mapID == mapID))) then
214 | activeMinimapPins[pin] = data
215 | data.keep = true
216 | -- draw the pin (this may reset data.keep if outside of the map)
217 | drawMinimapPin(pin, data)
218 | end
219 | end
220 |
221 | minimapPinCount = 0
222 | for pin, data in pairs(activeMinimapPins) do
223 | if not data.keep then
224 | pin:Hide()
225 | activeMinimapPins[pin] = nil
226 | else
227 | minimapPinCount = minimapPinCount + 1
228 | data.keep = nil
229 | end
230 | end
231 | end
232 | end
233 |
234 | local function UpdateMinimapIconPosition()
235 |
236 | -- get the current map zoom
237 | local zoom = pins.Minimap:GetZoom()
238 | local diffZoom = zoom ~= lastZoom
239 | -- if the map zoom changed, run a full update sweep
240 | if diffZoom then
241 | UpdateMinimapPins()
242 | return
243 | end
244 |
245 | -- we have no active minimap pins, just return early
246 | if minimapPinCount == 0 then return end
247 |
248 | local x, y = HBD:GetPlayerWorldPosition()
249 |
250 | -- for rotating minimap support
251 | local facing
252 | if rotateMinimap then
253 | facing = GetPlayerFacing()
254 | else
255 | facing = lastFacing
256 | end
257 |
258 | -- check for all values to be available (starting with 7.1.0, instances don't report coordinates)
259 | if not x or not y or (rotateMinimap and not facing) then
260 | UpdateMinimapPins()
261 | return
262 | end
263 |
264 | local refresh
265 | local newScale = pins.Minimap:GetScale()
266 | if minimapScale ~= newScale then
267 | minimapScale = newScale
268 | refresh = true
269 | end
270 |
271 | if x ~= lastXY or y ~= lastYY or facing ~= lastFacing or refresh then
272 | -- update radius of the map
273 | mapRadius = minimap_size[indoors][zoom] / 2
274 | -- update upvalues for icon placement
275 | lastXY, lastYY = x, y
276 | lastFacing = facing
277 |
278 | if rotateMinimap then
279 | mapSin = sin(facing)
280 | mapCos = cos(facing)
281 | end
282 |
283 | -- iterate all nodes and check if they are still in range of our minimap display
284 | for pin, data in pairs(activeMinimapPins) do
285 | -- update the position of the node
286 | drawMinimapPin(pin, data)
287 | end
288 | end
289 | end
290 |
291 | local function UpdateMinimapZoom()
292 | local zoom = pins.Minimap:GetZoom()
293 | if GetCVar("minimapZoom") == GetCVar("minimapInsideZoom") then
294 | pins.Minimap:SetZoom(zoom < 2 and zoom + 1 or zoom - 1)
295 | end
296 | indoors = GetCVar("minimapZoom")+0 == pins.Minimap:GetZoom() and "outdoor" or "indoor"
297 | pins.Minimap:SetZoom(zoom)
298 | end
299 |
300 | local function PositionWorldMapIcon(icon, data, currentMapID, currentMapFloor)
301 | -- special handling for the azeroth world map
302 | -- translating coordinates to the azeroth map requires passing the instance ID
303 | -- of the origin continent, so the appropriate coordinates can be calculated
304 | if currentMapID == WORLDMAP_AZEROTH_ID then
305 | currentMapFloor = data.instanceID
306 | end
307 |
308 | local x, y = HBD:GetZoneCoordinatesFromWorld(data.x, data.y, currentMapID, currentMapFloor)
309 | if x and y then
310 | icon:ClearAllPoints()
311 | icon:SetPoint("CENTER", WorldMapButton, "TOPLEFT", x * worldmapWidth, -y * worldmapHeight)
312 | icon:Show()
313 | else
314 | icon:Hide()
315 | end
316 | end
317 |
318 | local function GetWorldMapLocation()
319 | local mapID, mapFloor = GetCurrentMapAreaID(), GetCurrentMapDungeonLevel()
320 |
321 | -- override the mapID for the azeroth world map
322 | if mapID == -1 and GetCurrentMapContinent() == 0 and GetCurrentMapZone() == 0 then
323 | mapID = WORLDMAP_AZEROTH_ID
324 | mapFloor = 0
325 | end
326 |
327 | return mapID, mapFloor
328 | end
329 |
330 | local function UpdateWorldMap()
331 | if not WorldMapButton:IsVisible() then return end
332 |
333 | local mapID, mapFloor = GetWorldMapLocation()
334 |
335 | -- not viewing a valid map
336 | if not mapID or mapID == -1 then
337 | for icon in pairs(worldmapPins) do
338 | icon:Hide()
339 | end
340 | return
341 | end
342 |
343 | local instanceID = HBD.mapData[mapID] and HBD.mapData[mapID].instance or -1
344 |
345 | worldmapWidth = WorldMapButton:GetWidth()
346 | worldmapHeight = WorldMapButton:GetHeight()
347 |
348 | for icon, data in pairs(worldmapPins) do
349 | if (instanceID == data.instanceID or mapID == WORLDMAP_AZEROTH_ID) and (not data.floor or (data.floor == mapFloor and (data.floor == 0 or data.mapID == mapID))) then
350 | PositionWorldMapIcon(icon, data, mapID, mapFloor)
351 | else
352 | icon:Hide()
353 | end
354 | end
355 | end
356 |
357 | local function UpdateMaps()
358 | UpdateMinimapZoom()
359 | UpdateMinimapPins()
360 | UpdateWorldMap()
361 | end
362 |
363 | local last_update = 0
364 | local function OnUpdateHandler(frame, elapsed)
365 | last_update = last_update + elapsed
366 | if last_update > 1 or queueFullUpdate then
367 | UpdateMinimapPins(queueFullUpdate)
368 | last_update = 0
369 | queueFullUpdate = false
370 | else
371 | UpdateMinimapIconPosition()
372 | end
373 | end
374 | pins.updateFrame:SetScript("OnUpdate", OnUpdateHandler)
375 |
376 | local function OnEventHandler(frame, event, ...)
377 | if event == "CVAR_UPDATE" then
378 | local cvar, value = ...
379 | if cvar == "ROTATE_MINIMAP" then
380 | rotateMinimap = (value == "1")
381 | queueFullUpdate = true
382 | end
383 | elseif event == "MINIMAP_UPDATE_ZOOM" then
384 | UpdateMinimapZoom()
385 | UpdateMinimapPins()
386 | elseif event == "PLAYER_LOGIN" then
387 | -- recheck cvars after login
388 | rotateMinimap = GetCVar("rotateMinimap") == "1"
389 | elseif event == "PLAYER_ENTERING_WORLD" then
390 | UpdateMaps()
391 | elseif event == "WORLD_MAP_UPDATE" then
392 | UpdateWorldMap()
393 | end
394 | end
395 |
396 | pins.updateFrame:SetScript("OnEvent", OnEventHandler)
397 | pins.updateFrame:UnregisterAllEvents()
398 | pins.updateFrame:RegisterEvent("CVAR_UPDATE")
399 | pins.updateFrame:RegisterEvent("MINIMAP_UPDATE_ZOOM")
400 | pins.updateFrame:RegisterEvent("PLAYER_LOGIN")
401 | pins.updateFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
402 | pins.updateFrame:RegisterEvent("WORLD_MAP_UPDATE")
403 |
404 | HBD.RegisterCallback(pins, "PlayerZoneChanged", UpdateMaps)
405 |
406 |
407 | --- Add a icon to the minimap (x/y world coordinate version)
408 | -- Note: This API does not let you specify a floor, as floors are map-specific, not instance/world wide. Use the Map/Floor API to specify a floor.
409 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
410 | -- @param icon Icon Frame
411 | -- @param instanceID Instance ID of the map to add the icon to
412 | -- @param x X position in world coordinates
413 | -- @param y Y position in world coordinates
414 | -- @param floatOnEdge flag if the icon should float on the edge of the minimap when going out of range, or hide immediately (default false)
415 | function pins:AddMinimapIconWorld(ref, icon, instanceID, x, y, floatOnEdge)
416 | if not ref then
417 | error(MAJOR..": AddMinimapIconWorld: 'ref' must not be nil")
418 | end
419 | if type(icon) ~= "table" or not icon.SetPoint then
420 | error(MAJOR..": AddMinimapIconWorld: 'icon' must be a frame", 2)
421 | end
422 | if type(instanceID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
423 | error(MAJOR..": AddMinimapIconWorld: 'instanceID', 'x' and 'y' must be numbers", 2)
424 | end
425 |
426 | if not minimapPinRegistry[ref] then
427 | minimapPinRegistry[ref] = {}
428 | end
429 |
430 | minimapPinRegistry[ref][icon] = true
431 |
432 | local t = minimapPins[icon] or newCachedTable()
433 | t.instanceID = instanceID
434 | t.x = x
435 | t.y = y
436 | t.floatOnEdge = floatOnEdge
437 | t.mapID = nil
438 | t.floor = nil
439 |
440 | minimapPins[icon] = t
441 | queueFullUpdate = true
442 |
443 | icon:SetParent(pins.Minimap)
444 | end
445 |
446 | --- Add a icon to the minimap (mapid/floor coordinate version)
447 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
448 | -- @param icon Icon Frame
449 | -- @param mapID Map ID of the map to place the icon on
450 | -- @param mapFloor Floor to place the icon on (or nil for all floors)
451 | -- @param x X position in local/point coordinates (0-1), relative to the zone
452 | -- @param y Y position in local/point coordinates (0-1), relative to the zone
453 | -- @param floatOnEdge flag if the icon should float on the edge of the minimap when going out of range, or hide immediately (default false)
454 | function pins:AddMinimapIconMF(ref, icon, mapID, mapFloor, x, y, floatOnEdge)
455 | if not ref then
456 | error(MAJOR..": AddMinimapIconMF: 'ref' must not be nil")
457 | end
458 | if type(icon) ~= "table" or not icon.SetPoint then
459 | error(MAJOR..": AddMinimapIconMF: 'icon' must be a frame")
460 | end
461 | if type(mapID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
462 | error(MAJOR..": AddMinimapIconMF: 'mapID', 'x' and 'y' must be numbers")
463 | end
464 |
465 | -- convert to world coordinates and use our known adding function
466 | local xCoord, yCoord, instanceID = HBD:GetWorldCoordinatesFromZone(x, y, mapID, mapFloor)
467 | if not xCoord then return end
468 |
469 | self:AddMinimapIconWorld(ref, icon, instanceID, xCoord, yCoord, floatOnEdge)
470 |
471 | -- store extra information
472 | minimapPins[icon].mapID = mapID
473 | minimapPins[icon].floor = mapFloor
474 | end
475 |
476 | --- Check if a floating minimap icon is on the edge of the map
477 | -- @param icon the minimap icon
478 | function pins:IsMinimapIconOnEdge(icon)
479 | if not icon then return false end
480 | local data = minimapPins[icon]
481 | if not data then return nil end
482 |
483 | return data.onEdge
484 | end
485 |
486 | --- Remove a minimap icon
487 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
488 | -- @param icon Icon Frame
489 | function pins:RemoveMinimapIcon(ref, icon)
490 | if not ref or not icon or not minimapPinRegistry[ref] then return end
491 | minimapPinRegistry[ref][icon] = nil
492 | if minimapPins[icon] then
493 | recycle(minimapPins[icon])
494 | minimapPins[icon] = nil
495 | activeMinimapPins[icon] = nil
496 | end
497 | icon:Hide()
498 | end
499 |
500 | --- Remove all minimap icons belonging to your addon (as tracked by "ref")
501 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
502 | function pins:RemoveAllMinimapIcons(ref)
503 | if not ref or not minimapPinRegistry[ref] then return end
504 | for icon in pairs(minimapPinRegistry[ref]) do
505 | recycle(minimapPins[icon])
506 | minimapPins[icon] = nil
507 | activeMinimapPins[icon] = nil
508 | icon:Hide()
509 | end
510 | wipe(minimapPinRegistry[ref])
511 | end
512 |
513 | --- Set the minimap object to position the pins on. Needs to support the usual functions a Minimap-type object exposes.
514 | -- @param minimapObject The new minimap object, or nil to restore the default
515 | function pins:SetMinimapObject(minimapObject)
516 | pins.Minimap = minimapObject or Minimap
517 | for pin in pairs(minimapPins) do
518 | pin:SetParent(pins.Minimap)
519 | end
520 | UpdateMinimapPins(true)
521 | end
522 |
523 | --- Add a icon to the world map (x/y world coordinate version)
524 | -- Note: This API does not let you specify a floor, as floors are map-specific, not instance/world wide. Use the Map/Floor API to specify a floor.
525 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
526 | -- @param icon Icon Frame
527 | -- @param instanceID Instance ID of the map to add the icon to
528 | -- @param x X position in world coordinates
529 | -- @param y Y position in world coordinates
530 | function pins:AddWorldMapIconWorld(ref, icon, instanceID, x, y)
531 | if not ref then
532 | error(MAJOR..": AddWorldMapIconWorld: 'ref' must not be nil")
533 | end
534 | if type(icon) ~= "table" or not icon.SetPoint then
535 | error(MAJOR..": AddWorldMapIconWorld: 'icon' must be a frame", 2)
536 | end
537 | if type(instanceID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
538 | error(MAJOR..": AddWorldMapIconWorld: 'instanceID', 'x' and 'y' must be numbers", 2)
539 | end
540 |
541 | if not worldmapPinRegistry[ref] then
542 | worldmapPinRegistry[ref] = {}
543 | end
544 |
545 | worldmapPinRegistry[ref][icon] = true
546 |
547 | local t = worldmapPins[icon] or newCachedTable()
548 | t.instanceID = instanceID
549 | t.x = x
550 | t.y = y
551 | t.mapID = nil
552 | t.floor = nil
553 |
554 | worldmapPins[icon] = t
555 |
556 | if WorldMapButton:IsVisible() then
557 | local currentMapID, currentMapFloor = GetWorldMapLocation()
558 | if currentMapID and HBD.mapData[currentMapID] and (HBD.mapData[currentMapID].instance == instanceID or currentMapID == WORLDMAP_AZEROTH_ID) then
559 | PositionWorldMapIcon(icon, t, currentMapID, currentMapFloor)
560 | else
561 | icon:Hide()
562 | end
563 | end
564 | end
565 |
566 | --- Add a icon to the world map (mapid/floor coordinate version)
567 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
568 | -- @param icon Icon Frame
569 | -- @param mapID Map ID of the map to place the icon on
570 | -- @param mapFloor Floor to place the icon on (or nil for all floors)
571 | -- @param x X position in local/point coordinates (0-1), relative to the zone
572 | -- @param y Y position in local/point coordinates (0-1), relative to the zone
573 | function pins:AddWorldMapIconMF(ref, icon, mapID, mapFloor, x, y)
574 | if not ref then
575 | error(MAJOR..": AddWorldMapIconMF: 'ref' must not be nil")
576 | end
577 | if type(icon) ~= "table" or not icon.SetPoint then
578 | error(MAJOR..": AddWorldMapIconMF: 'icon' must be a frame")
579 | end
580 | if type(mapID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
581 | error(MAJOR..": AddWorldMapIconMF: 'mapID', 'x' and 'y' must be numbers")
582 | end
583 |
584 | -- convert to world coordinates
585 | local xCoord, yCoord, instanceID = HBD:GetWorldCoordinatesFromZone(x, y, mapID, mapFloor)
586 | if not xCoord then return end
587 |
588 | if not worldmapPinRegistry[ref] then
589 | worldmapPinRegistry[ref] = {}
590 | end
591 |
592 | worldmapPinRegistry[ref][icon] = true
593 |
594 | local t = worldmapPins[icon] or newCachedTable()
595 | t.instanceID = instanceID
596 | t.x = xCoord
597 | t.y = yCoord
598 | t.mapID = mapID
599 | t.floor = mapFloor
600 |
601 | worldmapPins[icon] = t
602 |
603 | if WorldMapButton:IsVisible() then
604 | local currentMapID, currentMapFloor = GetWorldMapLocation()
605 | if currentMapID and HBD.mapData[currentMapID] and (HBD.mapData[currentMapID].instance == instanceID or currentMapID == WORLDMAP_AZEROTH_ID)
606 | and (not mapFloor or (currentMapFloor == mapFloor and (mapFloor == 0 or currentMapID == mapID))) then
607 | PositionWorldMapIcon(icon, t, currentMapID, currentMapFloor)
608 | else
609 | icon:Hide()
610 | end
611 | end
612 | end
613 |
614 | --- Remove a worldmap icon
615 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
616 | -- @param icon Icon Frame
617 | function pins:RemoveWorldMapIcon(ref, icon)
618 | if not ref or not icon or not worldmapPinRegistry[ref] then return end
619 | worldmapPinRegistry[ref][icon] = nil
620 | if worldmapPins[icon] then
621 | recycle(worldmapPins[icon])
622 | worldmapPins[icon] = nil
623 | end
624 | icon:Hide()
625 | end
626 |
627 | --- Remove all worldmap icons belonging to your addon (as tracked by "ref")
628 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
629 | function pins:RemoveAllWorldMapIcons(ref)
630 | if not ref or not worldmapPinRegistry[ref] then return end
631 | for icon in pairs(worldmapPinRegistry[ref]) do
632 | recycle(worldmapPins[icon])
633 | worldmapPins[icon] = nil
634 | icon:Hide()
635 | end
636 | wipe(worldmapPinRegistry[ref])
637 | end
638 |
639 | --- Return the angle and distance from the player to the specified pin
640 | -- @param icon icon object (minimap or worldmap)
641 | -- @return angle, distance where angle is in radians and distance in yards
642 | function pins:GetVectorToIcon(icon)
643 | if not icon then return nil, nil end
644 | local data = minimapPins[icon] or worldmapPins[icon]
645 | if not data then return nil, nil end
646 |
647 | local x, y, instance = HBD:GetPlayerWorldPosition()
648 | if not x or not y or instance ~= data.instanceID then return nil end
649 |
650 | return HBD:GetWorldVector(instance, x, y, data.x, data.y)
651 | end
652 |
--------------------------------------------------------------------------------
/ZoneOrders.lua:
--------------------------------------------------------------------------------
1 | AAPClassic.ZO = {}
2 | AAPClassic.ZO.Quests = {}
3 | AAPClassic.ZO.QuestsDB = {}
4 | AAPClassic.ZO.Scrollz = 0
5 | function AAPClassic.ZO.MakeZOList()
6 | AAPClassic.ZO.MainFrame = CreateFrame("frame", "AAPClassic_ZO_MainFrame", UIParent)
7 | AAPClassic.ZO.MainFrame:SetWidth(1)
8 | AAPClassic.ZO.MainFrame:SetHeight(1)
9 | AAPClassic.ZO.MainFrame:SetMovable(true)
10 | AAPClassic.ZO.MainFrame:EnableMouse(true)
11 | AAPClassic.ZO.MainFrame:SetFrameStrata("MEDIUM")
12 | AAPClassic.ZO.MainFrame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 1, 1)
13 |
14 | AAPClassic.ZO.OrderFrame = CreateFrame("frame", "AAPClassic_ZO_OrderFrame", AAPClassic.ZO.MainFrame)
15 | AAPClassic.ZO.OrderFrame:SetWidth(400)
16 | AAPClassic.ZO.OrderFrame:SetHeight(520)
17 | AAPClassic.ZO.OrderFrame:SetFrameStrata("MEDIUM")
18 | AAPClassic.ZO.OrderFrame:SetPoint("TOPLEFT", AAPClassic.ZO.MainFrame, "TOPLEFT",0,0)
19 | AAPClassic.ZO.OrderFrame:SetMovable(true)
20 | AAPClassic.ZO.OrderFrame:EnableMouse(true)
21 | AAPClassic.ZO.OrderFrame:SetScript("OnMouseDown", function(self, button)
22 | if (button == "LeftButton" and not AAPClassic.ZO.MainFrame.isMoving) then
23 | AAPClassic.ZO.MainFrame:StartMoving();
24 | AAPClassic.ZO.MainFrame.isMoving = true;
25 | end
26 | end)
27 | AAPClassic.ZO.OrderFrame:SetScript("OnMouseUp", function(self, button)
28 | if (button == "LeftButton" and AAPClassic.ZO.MainFrame.isMoving) then
29 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
30 | AAPClassic.ZO.MainFrame.isMoving = false;
31 | end
32 | end)
33 | AAPClassic.ZO.OrderFrame:SetScript("OnHide", function(self)
34 | if ( AAPClassic.ZO.MainFrame.isMoving ) then
35 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
36 | AAPClassic.ZO.MainFrame.isMoving = false;
37 | end
38 | end)
39 | AAPClassic.ZO.OrderFrame:SetScript("OnMouseWheel", function(self, arg1)
40 | if (arg1 == 1) then
41 | if (AAPClassic.ZO.Scrollz ~= 0) then
42 | AAPClassic.ZO.Scrollz = AAPClassic.ZO.Scrollz - 1
43 | AAPClassic.ZO.PrintOrder()
44 | end
45 | else
46 | AAPClassic.ZO.Scrollz = AAPClassic.ZO.Scrollz + 1
47 | AAPClassic.ZO.PrintOrder()
48 | end
49 | end)
50 | AAPClassic.ZO.OrderFrame:SetBackdrop( {
51 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
52 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
53 | tile = true, tileSize = 10, edgeSize = 10, insets = { left = 2, right = 2, top = 2, bottom = 2 }
54 | });
55 | local CLi
56 | for CLi = 1, 20 do
57 | AAPClassic.ZO.OrderFrame["Line"..CLi] = CreateFrame("frame", "AAPClassic_QL_QButton_ListFrameLine"..CLi, AAPClassic.ZO.MainFrame)
58 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetWidth(496)
59 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetHeight(20)
60 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetFrameStrata("MEDIUM")
61 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetPoint("TOPLEFT", AAPClassic.ZO.MainFrame, "TOPLEFT",5,-((CLi * 25)+CLi-15))
62 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetMovable(true)
63 | AAPClassic.ZO.OrderFrame["Line"..CLi]:EnableMouse(true)
64 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetScript("OnMouseDown", function(self, button)
65 | if (button == "LeftButton" and not AAPClassic.ZO.MainFrame.isMoving) then
66 | AAPClassic.ZO.MainFrame:StartMoving();
67 | AAPClassic.ZO.MainFrame.isMoving = true;
68 | end
69 | end)
70 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetScript("OnMouseUp", function(self, button)
71 | if (button == "LeftButton" and AAPClassic.ZO.MainFrame.isMoving) then
72 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
73 | AAPClassic.ZO.MainFrame.isMoving = false;
74 | end
75 | end)
76 | AAPClassic.ZO.OrderFrame["Line"..CLi]:SetScript("OnHide", function(self)
77 | if ( AAPClassic.ZO.MainFrame.isMoving ) then
78 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
79 | AAPClassic.ZO.MainFrame.isMoving = false;
80 | end
81 | end)
82 |
83 | AAPClassic.ZO.OrderFrame["Line2s"..CLi] = CreateFrame("frame", "AAPClassic_QL_QButton_ListFrameLine2s"..CLi, AAPClassic.ZO.MainFrame)
84 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetWidth(496)
85 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetHeight(30)
86 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetFrameStrata("MEDIUM")
87 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetPoint("TOPLEFT", AAPClassic.ZO.MainFrame, "TOPLEFT",-35,-((CLi * 25)+CLi-25))
88 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetMovable(true)
89 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:EnableMouse(true)
90 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetScript("OnMouseDown", function(self, button)
91 | if (button == "LeftButton" and not AAPClassic.ZO.MainFrame.isMoving) then
92 | AAPClassic.ZO.MainFrame:StartMoving();
93 | AAPClassic.ZO.MainFrame.isMoving = true;
94 | end
95 | end)
96 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetScript("OnMouseUp", function(self, button)
97 | if (button == "LeftButton" and AAPClassic.ZO.MainFrame.isMoving) then
98 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
99 | AAPClassic.ZO.MainFrame.isMoving = false;
100 | end
101 | end)
102 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetScript("OnHide", function(self)
103 | if ( AAPClassic.ZO.MainFrame.isMoving ) then
104 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
105 | AAPClassic.ZO.MainFrame.isMoving = false;
106 | end
107 | end)
108 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetBackdrop( {
109 | bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
110 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
111 | tile = true, tileSize = 10, edgeSize = 10, insets = { left = 2, right = 2, top = 2, bottom = 2 }
112 | });
113 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"] = AAPClassic.QL.ListFrame:CreateFontString("AAPClassic_ZO_OrderFrameLine2s"..CLi.."FS","ARTWORK", "ChatFontNormal")
114 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetParent(AAPClassic.ZO.OrderFrame["Line2s"..CLi])
115 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetPoint("LEFT",AAPClassic.ZO.OrderFrame["Line2s"..CLi],"LEFT",2,0)
116 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetWidth(50)
117 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetHeight(16)
118 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetJustifyH("LEFT")
119 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetFontObject("GameFontNormal")
120 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetText("123")
121 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]["FS"]:SetTextColor(1, 1, 0)
122 |
123 | local CLi2
124 | for CLi2 = 1, 25 do
125 |
126 |
127 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2] = CreateFrame("frame", "AAPClassic_QL_QButton_ListFrameLine"..CLi.."Frame"..CLi2, AAPClassic.ZO.OrderFrame["Line"..CLi])
128 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetWidth(60)
129 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetHeight(16)
130 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetFrameStrata("HIGH")
131 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetPoint("TOPLEFT", AAPClassic.ZO.OrderFrame["Line"..CLi], "TOPLEFT",((CLi2 * 60)+CLi2-60),0)
132 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetMovable(true)
133 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:EnableMouse(true)
134 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetScript("OnMouseDown", function(self, button)
135 | if (button == "LeftButton" and not AAPClassic.ZO.MainFrame.isMoving) then
136 | AAPClassic.ZO.MainFrame:StartMoving();
137 | AAPClassic.ZO.MainFrame.isMoving = true;
138 | end
139 | end)
140 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetScript("OnMouseUp", function(self, button)
141 | if (button == "LeftButton" and AAPClassic.ZO.MainFrame.isMoving) then
142 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
143 | AAPClassic.ZO.MainFrame.isMoving = false;
144 | end
145 | end)
146 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetScript("OnHide", function(self)
147 | if ( AAPClassic.ZO.MainFrame.isMoving ) then
148 | AAPClassic.ZO.MainFrame:StopMovingOrSizing();
149 | AAPClassic.ZO.MainFrame.isMoving = false;
150 | end
151 | end)
152 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetBackdrop( {
153 | bgFile = "Interface\\Addons\\AAP-Classic\\Img\\bar.tga",
154 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
155 | tile = true, tileSize = 10, edgeSize = 10, insets = { left = 2, right = 2, top = 2, bottom = 2 }
156 | });
157 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:SetBackdropColor(0,0,0,1)
158 |
159 |
160 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"] = CreateFrame("frame", "AAPClassic_QL_QButton_ListFrameLine"..CLi.."Frame"..CLi2, AAPClassic.ZO.OrderFrame["Line"..CLi])
161 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]:SetWidth(2)
162 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]:SetFrameStrata("MEDIUM")
163 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]:SetHeight(26)
164 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]:SetPoint("TOP",AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2],"TOP",0,13)
165 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]["L"] = AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]:CreateTexture(nil, "OVERLAY")
166 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]["L"]:SetTexture("Interface\\Addons\\AAP-Classic\\Img\\bar.tga")
167 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]["L"]:SetAllPoints()
168 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]:Hide()
169 |
170 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"] = AAPClassic.QL.ListFrame:CreateFontString("AAPClassic_ZO_OrderFrameLine"..CLi.."Frame"..CLi2.."FS","ARTWORK", "ChatFontNormal")
171 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetParent(AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2])
172 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetPoint("TOPLEFT",AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2],"TOPLEFT",2,11)
173 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetWidth(50)
174 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetHeight(16)
175 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetJustifyH("LEFT")
176 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetFontObject("GameFontNormalSmall")
177 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetText("Pick Up")
178 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS"]:SetTextColor(1, 1, 0)
179 |
180 |
181 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"] = AAPClassic.QL.ListFrame:CreateFontString("AAPClassic_ZO_OrderFrameLine"..CLi.."Frame"..CLi2.."FS2","ARTWORK", "ChatFontNormal")
182 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetParent(AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2])
183 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetPoint("TOP",AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2],"TOP",0,0)
184 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetWidth(60)
185 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetHeight(16)
186 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetJustifyH("CENTER")
187 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetFontObject("GameFontNormalSmall")
188 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetText("Testing Quests")
189 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["FS2"]:SetTextColor(1, 1, 0)
190 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:Hide()
191 | end
192 | end
193 | end
194 | function AAPClassic.ZO.MakeDB()
195 | local Numbz = 0
196 | if (AAPClassic.Faction == "Alliance") then
197 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["1-5Human-Warrior"], Numbz)
198 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["5-12Human-Warrior"], Numbz)
199 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["12-13Human-LochModan-Darkshore"], Numbz)
200 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["12-17Darkshore"], Numbz)
201 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["17-18HumanDwarfGnome-LochModan"], Numbz)
202 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["18-Human-IronforgeRedridge"], Numbz)
203 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["18-20RedridgeMountains"], Numbz)
204 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["20-RedridgeDarkshore"], Numbz)
205 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["20-21Darkshore"], Numbz)
206 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["21-22AshenvaleStonetalon"], Numbz)
207 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["22-24Darkshore"], Numbz)
208 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["24-Ashenvale"], Numbz)
209 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["24-27Wetlands"], Numbz)
210 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["27-28RedridgeMountains"], Numbz)
211 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["28-30Duskwood"], Numbz)
212 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["30-Ashenvale"], Numbz)
213 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["30-31Wetlands"], Numbz)
214 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["31-32HillsbradFoothills"], Numbz)
215 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["32-RunAbout"], Numbz)
216 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["32-33StranglethornVale"], Numbz)
217 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["33-34Thousand Needles"], Numbz)
218 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["34-36Desolace"], Numbz)
219 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["36-37StranglethornVale"], Numbz)
220 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["37-AlteracMountains"], Numbz)
221 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["37-38ArathiHighlands"], Numbz)
222 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["38-39DustwallowMarsh"], Numbz)
223 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["39-40StranglethornVale"], Numbz)
224 | else
225 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["1-12OrcTroll-Warrior"], Numbz)
226 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["12-15TheBarrens"], Numbz)
227 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["15-16StonetalonMountains"], Numbz)
228 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["16TheBarrens"], Numbz)
229 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["16GotoTB-Rest"], Numbz)
230 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["16-20TheBarrens"], Numbz)
231 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["20-TB-Prep"], Numbz)
232 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["20-23Ashenvale-SouthBarrens"], Numbz)
233 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["23-25StonetalonMountains"], Numbz)
234 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["25-SouthernBarrens"], Numbz)
235 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["25-26ThousandNeedles"], Numbz)
236 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["26-28Ashenvale"], Numbz)
237 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["28-30TN-Hillsbrad"], Numbz)
238 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["30-Arathi-STV"], Numbz)
239 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["30-32STV-TN"], Numbz)
240 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["32-34Desolace"], Numbz)
241 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["34-37"], Numbz)
242 | Numbz = AAPClassic.ZO.MakeDBz(AAPClassic.Path["37-40"], Numbz)
243 |
244 | end
245 | end
246 | function AAPClassic.ZO.MakeDBz(Pathz, Number)
247 | local Numbzs = 0
248 | for AAPC_index,AAPC_value in pairs(Pathz) do
249 | Number = Number + 1
250 | Numbzs = Numbzs + 1
251 | if (not AAPClassic.ZO.QuestsDB["ShowLines"]) then
252 | AAPClassic.ZO.QuestsDB["ShowLines"] = {}
253 | end
254 | if (not AAPClassic.ZO.QuestsDB["ShowLines"][Number]) then
255 | AAPClassic.ZO.QuestsDB["ShowLines"][Number] = {}
256 | end
257 | if (not AAPClassic.ZO.QuestsDB["Quests"]) then
258 | AAPClassic.ZO.QuestsDB["Quests"] = {}
259 | end
260 | if (not AAPClassic.ZO.QuestsDB["Quests"][Number]) then
261 | AAPClassic.ZO.QuestsDB["Quests"][Number] = {}
262 | end
263 | if (Pathz[Numbzs]) then
264 | if (Pathz[Numbzs]["LeaveQuests"]) then
265 | for AAPC_index2,AAPC_value2 in pairs(Pathz[Numbzs]["LeaveQuests"]) do
266 | for AAPC_index3,AAPC_value3 in pairs(AAPClassic.ZO.Quests) do
267 | if (AAPC_value3 == AAPC_value2) then
268 | print("Removed:"..AAPC_value3)
269 | AAPClassic.ZO.Quests[tonumber(AAPC_index3)] = nil
270 | end
271 | end
272 | end
273 | end
274 | for AAPC_index,AAPC_value in pairs(AAPClassic.ZO.Quests) do
275 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][AAPC_index] = 1
276 | end
277 | if (Pathz[Numbzs]["PickUp"]) then
278 | for AAPC_index2,AAPC_value2 in pairs(Pathz[Numbzs]["PickUp"]) do
279 | local qNumb = AAPClassic.ZO.CheckQuests(AAPC_value2)
280 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 0
281 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
282 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["PickUp"] = AAPC_value2
283 | end
284 | elseif (Pathz[Numbzs]["Qpart"]) then
285 | for AAPC_index2,AAPC_value2 in pairs(Pathz[Numbzs]["Qpart"]) do
286 | if (995 == AAPC_index2) then
287 | Number = Number - 1
288 | else
289 | local qNumb = AAPClassic.ZO.CheckQuests(AAPC_index2)
290 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
291 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
292 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["Qpart"] = AAPC_index2
293 | end
294 | end
295 | elseif (Pathz[Numbzs]["Done"]) then
296 | for AAPC_index2,AAPC_value2 in pairs(Pathz[Numbzs]["Done"]) do
297 | local qNumb = AAPClassic.ZO.CheckQuests(AAPC_value2)
298 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
299 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
300 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["Done"] = AAPC_value2
301 | AAPClassic.ZO.Quests[qNumb] = nil
302 | end
303 | elseif (Pathz[Numbzs]["CRange"]) then
304 | local qNumb,zderps = AAPClassic.ZO.CheckQuests(Pathz[Numbzs]["CRange"])
305 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
306 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
307 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["CRange"] = Pathz[Numbzs]["CRange"]
308 | if (zderps == 1) then
309 | AAPClassic.ZO.Quests[qNumb] = nil
310 | end
311 | elseif (Pathz[Numbzs]["SetHS"]) then
312 | local qNumb,zderps = AAPClassic.ZO.CheckQuests(Pathz[Numbzs]["SetHS"])
313 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
314 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
315 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["SetHS"] = Pathz[Numbzs]["SetHS"]
316 | if (zderps == 1) then
317 | AAPClassic.ZO.Quests[qNumb] = nil
318 | end
319 | elseif (Pathz[Numbzs]["UseHS"]) then
320 | local qNumb,zderps = AAPClassic.ZO.CheckQuests(Pathz[Numbzs]["UseHS"])
321 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
322 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
323 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["UseHS"] = Pathz[Numbzs]["UseHS"]
324 | if (zderps == 1) then
325 | AAPClassic.ZO.Quests[qNumb] = nil
326 | end
327 | elseif (Pathz[Numbzs]["GetFP"]) then
328 | local qNumb,zderps = AAPClassic.ZO.CheckQuests(Pathz[Numbzs]["GetFP"])
329 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
330 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
331 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["GetFP"] = Pathz[Numbzs]["GetFP"]
332 | if (zderps == 1) then
333 | AAPClassic.ZO.Quests[qNumb] = nil
334 | end
335 | elseif (Pathz[Numbzs]["UseFlightPath"]) then
336 | local qNumb,zderps = AAPClassic.ZO.CheckQuests(Pathz[Numbzs]["UseFlightPath"])
337 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
338 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
339 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["UseFlightPath"] = Pathz[Numbzs]["UseFlightPath"]
340 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["Name"] = Pathz[Numbzs]["Name"]
341 | if (zderps == 1) then
342 | AAPClassic.ZO.Quests[qNumb] = nil
343 | end
344 | elseif (Pathz[Numbzs]["QaskPopup"]) then
345 | local qNumb = AAPClassic.ZO.CheckQuests(Pathz[Numbzs]["QaskPopup"])
346 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
347 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
348 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["QaskPopup"] = Pathz[Numbzs]["QaskPopup"]
349 | elseif (Pathz[Numbzs]["UpdMapID"]) then
350 | local qNumb = AAPClassic.ZO.CheckQuests(98231)
351 | AAPClassic.ZO.QuestsDB["ShowLines"][Number][qNumb] = 1
352 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb] = {}
353 | AAPClassic.ZO.QuestsDB["Quests"][Number][qNumb]["UpdMapID"] = 1
354 | AAPClassic.ZO.Quests[qNumb] = nil
355 | end
356 | end
357 | end
358 | return Number
359 | end
360 |
361 | function AAPClassic.ZO.PrintOrder()
362 | local CLi
363 | for CLi = 1, 20 do
364 | local CLi2
365 | for CLi2 = 1, 25 do
366 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]:Hide()
367 | AAPClassic.ZO.OrderFrame["Line"..CLi]["Frame"..CLi2]["Line"]:Hide()
368 | end
369 | end
370 | local Number = 0
371 | local witdhtz = 0
372 | for AAPC_index,AAPC_value in pairs(AAPClassic.ZO.QuestsDB["ShowLines"]) do
373 | Number = Number + 1
374 | if (AAPClassic.ZO.QuestsDB["ShowLines"][Number+AAPClassic.ZO.Scrollz]) then
375 | for AAPC_index2,AAPC_value2 in pairs(AAPClassic.ZO.QuestsDB["ShowLines"][Number+AAPClassic.ZO.Scrollz]) do
376 | if (AAPC_value2 == 1) then
377 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..AAPC_index2]["Line"]:Show()
378 | else
379 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..AAPC_index2]["Line"]:Hide()
380 | end
381 | if (witdhtz < AAPC_index2) then
382 | witdhtz = AAPC_index2
383 | end
384 | end
385 | end
386 | if (Number == 20) then
387 | AAPClassic.ZO.OrderFrame:SetWidth(witdhtz * 60 + 20)
388 | local CLi
389 | for CLi = 1, 20 do
390 | AAPClassic.ZO.OrderFrame["Line2s"..CLi]:SetWidth(witdhtz * 60 + 55)
391 | end
392 | break
393 | end
394 | end
395 | Number = 0
396 | for AAPC_index,AAPC_value in pairs(AAPClassic.ZO.QuestsDB["Quests"]) do
397 | Number = Number + 1
398 | if (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz]) then
399 | AAPClassic.ZO.OrderFrame["Line2s"..Number]["FS"]:SetText(Number+AAPClassic.ZO.Scrollz)
400 | for AAPC_index2,AAPC_value2 in pairs(AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz]) do
401 | if (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["PickUp"]) then
402 | local qNumb = AAPC_index2
403 | local zename = AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["PickUp"]
404 | if (AAPClassic["questsNames"][zename]) then
405 | -- zename = AAPClassic["questsNames"][zename]["T"]
406 | end
407 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("Pick Up")
408 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText(zename)
409 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
410 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Hide()
411 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["Qpart"]) then
412 | local qNumb = AAPC_index2
413 | local zename = AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["Qpart"]
414 | if (AAPClassic["questsNames"][zename]) then
415 | -- zename = AAPClassic["questsNames"][zename]["T"]
416 | end
417 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("DoQuest")
418 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText(zename)
419 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
420 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
421 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["Done"]) then
422 | local qNumb = AAPC_index2
423 | local zename = AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["Done"]
424 | if (AAPClassic["questsNames"][zename]) then
425 | -- zename = AAPClassic["questsNames"][zename]["T"]
426 | end
427 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("Hand In")
428 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText(zename)
429 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
430 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
431 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["CRange"]) then
432 | local qNumb = AAPC_index2
433 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("")
434 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText("WayPoint")
435 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
436 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
437 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["UseFlightPath"]) then
438 | local qNumb = AAPC_index2
439 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("Use FP")
440 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText(AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["Name"])
441 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
442 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
443 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["GetFP"]) then
444 | local qNumb = AAPC_index2
445 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("")
446 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText("Get Flightpath")
447 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
448 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
449 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["SetHS"]) then
450 | local qNumb = AAPC_index2
451 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("")
452 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText("Set Hearthstone")
453 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
454 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
455 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["UseHS"]) then
456 | local qNumb = AAPC_index2
457 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("")
458 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText("Use Hearthstone")
459 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
460 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
461 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["UpdMapID"]) then
462 | local qNumb = AAPC_index2
463 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("")
464 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText("AAP-PathChange")
465 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
466 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
467 | elseif (AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["QaskPopup"]) then
468 | local qNumb = AAPC_index2
469 | local zename = AAPClassic.ZO.QuestsDB["Quests"][Number+AAPClassic.ZO.Scrollz][AAPC_index2]["QaskPopup"]
470 | if (AAPClassic["questsNames"][zename]) then
471 | -- zename = AAPClassic["questsNames"][zename]["T"]
472 | end
473 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS"]:SetText("Elite Quest")
474 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["FS2"]:SetText(zename)
475 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]:Show()
476 | AAPClassic.ZO.OrderFrame["Line"..Number]["Frame"..qNumb]["Line"]:Show()
477 | end
478 | end
479 | end
480 | if (Number == 20) then
481 | break
482 | end
483 | end
484 | end
485 |
486 | function AAPClassic.ZO.CheckQuests(Qid)
487 | local Numbz = 0
488 | local FreeNr = 0
489 | for AAPC_inde,AAPC_valu in pairs(AAPClassic.ZO.Quests) do
490 | Numbz = Numbz + 1
491 | if (AAPClassic.ZO.Quests[AAPC_inde] == Qid) then
492 | return AAPC_inde
493 | end
494 | if (not AAPClassic.ZO.Quests[Numbz] and FreeNr == 0) then
495 | FreeNr = Numbz
496 | end
497 | end
498 | if (FreeNr > 0) then
499 | AAPClassic.ZO.Quests[FreeNr] = Qid
500 | return FreeNr, 1
501 | else
502 | Numbz = Numbz + 1
503 | AAPClassic.ZO.Quests[Numbz] = Qid
504 | return Numbz, 1
505 | end
506 | end
507 | AAPClassic.ZO.QuestListEventFrame = CreateFrame("Frame")
508 | AAPClassic.ZO.QuestListEventFrame:RegisterEvent ("ADDON_LOADED")
509 |
510 | AAPClassic.ZO.QuestListEventFrame:SetScript("OnEvent", function(self, event, ...)
511 | if (event=="ADDON_LOADED") then
512 | local arg1, arg2, arg3, arg4, arg5 = ...;
513 | if (arg1 == "AAP-Classic") then
514 | --AAPClassic.ZO.MakeZOList()
515 | --AAPClassic.ZO.MakeDB()
516 | --AAPClassic.ZO.PrintOrder()
517 | end
518 | end
519 | end)
--------------------------------------------------------------------------------
/lib/HereBeDragons/HereBeDragons-Pins-2.0.lua:
--------------------------------------------------------------------------------
1 | -- HereBeDragons-Pins is a library to show pins/icons on the world map and minimap
2 |
3 | local MAJOR, MINOR = "HereBeDragons-Pins-2.0", 6
4 | assert(LibStub, MAJOR .. " requires LibStub")
5 |
6 | local pins, oldversion = LibStub:NewLibrary(MAJOR, MINOR)
7 | if not pins then return end
8 |
9 | local HBD = LibStub("HereBeDragons-2.0")
10 |
11 | pins.updateFrame = pins.updateFrame or CreateFrame("Frame")
12 |
13 | -- storage for minimap pins
14 | pins.minimapPins = pins.minimapPins or {}
15 | pins.activeMinimapPins = pins.activeMinimapPins or {}
16 | pins.minimapPinRegistry = pins.minimapPinRegistry or {}
17 |
18 | -- and worldmap pins
19 | pins.worldmapPins = pins.worldmapPins or {}
20 | pins.worldmapPinRegistry = pins.worldmapPinRegistry or {}
21 | pins.worldmapPinsPool = pins.worldmapPinsPool or CreateFramePool("FRAME")
22 | pins.worldmapProvider = pins.worldmapProvider or CreateFromMixins(MapCanvasDataProviderMixin)
23 | pins.worldmapProviderPin = pins.worldmapProviderPin or CreateFromMixins(MapCanvasPinMixin)
24 |
25 | -- store a reference to the active minimap object
26 | pins.Minimap = pins.Minimap or Minimap
27 |
28 | -- Data Constants
29 | local WORLD_MAP_ID = 947
30 |
31 | -- upvalue lua api
32 | local cos, sin, max = math.cos, math.sin, math.max
33 | local type, pairs = type, pairs
34 |
35 | -- upvalue wow api
36 | local GetPlayerFacing = GetPlayerFacing
37 |
38 | -- upvalue data tables
39 | local minimapPins = pins.minimapPins
40 | local activeMinimapPins = pins.activeMinimapPins
41 | local minimapPinRegistry = pins.minimapPinRegistry
42 |
43 | local worldmapPins = pins.worldmapPins
44 | local worldmapPinRegistry = pins.worldmapPinRegistry
45 | local worldmapPinsPool = pins.worldmapPinsPool
46 | local worldmapProvider = pins.worldmapProvider
47 | local worldmapProviderPin = pins.worldmapProviderPin
48 |
49 | local minimap_size = {
50 | indoor = {
51 | [0] = 300, -- scale
52 | [1] = 240, -- 1.25
53 | [2] = 180, -- 5/3
54 | [3] = 120, -- 2.5
55 | [4] = 80, -- 3.75
56 | [5] = 50, -- 6
57 | },
58 | outdoor = {
59 | [0] = 466 + 2/3, -- scale
60 | [1] = 400, -- 7/6
61 | [2] = 333 + 1/3, -- 1.4
62 | [3] = 266 + 2/6, -- 1.75
63 | [4] = 200, -- 7/3
64 | [5] = 133 + 1/3, -- 3.5
65 | },
66 | }
67 |
68 | local minimap_shapes = {
69 | -- { upper-left, lower-left, upper-right, lower-right }
70 | ["SQUARE"] = { false, false, false, false },
71 | ["CORNER-TOPLEFT"] = { true, false, false, false },
72 | ["CORNER-TOPRIGHT"] = { false, false, true, false },
73 | ["CORNER-BOTTOMLEFT"] = { false, true, false, false },
74 | ["CORNER-BOTTOMRIGHT"] = { false, false, false, true },
75 | ["SIDE-LEFT"] = { true, true, false, false },
76 | ["SIDE-RIGHT"] = { false, false, true, true },
77 | ["SIDE-TOP"] = { true, false, true, false },
78 | ["SIDE-BOTTOM"] = { false, true, false, true },
79 | ["TRICORNER-TOPLEFT"] = { true, true, true, false },
80 | ["TRICORNER-TOPRIGHT"] = { true, false, true, true },
81 | ["TRICORNER-BOTTOMLEFT"] = { true, true, false, true },
82 | ["TRICORNER-BOTTOMRIGHT"] = { false, true, true, true },
83 | }
84 |
85 | local tableCache = setmetatable({}, {__mode='k'})
86 |
87 | local function newCachedTable()
88 | local t = next(tableCache)
89 | if t then
90 | tableCache[t] = nil
91 | else
92 | t = {}
93 | end
94 | return t
95 | end
96 |
97 | local function recycle(t)
98 | tableCache[t] = true
99 | end
100 |
101 | -------------------------------------------------------------------------------------------
102 | -- Minimap pin position logic
103 |
104 | -- minimap rotation
105 | local rotateMinimap = GetCVar("rotateMinimap") == "1"
106 |
107 | -- is the minimap indoors or outdoors
108 | local indoors = GetCVar("minimapZoom")+0 == pins.Minimap:GetZoom() and "outdoor" or "indoor"
109 |
110 | local minimapPinCount, queueFullUpdate = 0, false
111 | local minimapScale, minimapShape, mapRadius, minimapWidth, minimapHeight, mapSin, mapCos
112 | local lastZoom, lastFacing, lastXY, lastYY
113 |
114 | local function drawMinimapPin(pin, data)
115 | local xDist, yDist = lastXY - data.x, lastYY - data.y
116 |
117 | -- handle rotation
118 | if rotateMinimap then
119 | local dx, dy = xDist, yDist
120 | xDist = dx*mapCos - dy*mapSin
121 | yDist = dx*mapSin + dy*mapCos
122 | end
123 |
124 | -- adapt delta position to the map radius
125 | local diffX = xDist / mapRadius
126 | local diffY = yDist / mapRadius
127 |
128 | -- different minimap shapes
129 | local isRound = true
130 | if minimapShape and not (xDist == 0 or yDist == 0) then
131 | isRound = (xDist < 0) and 1 or 3
132 | if yDist < 0 then
133 | isRound = minimapShape[isRound]
134 | else
135 | isRound = minimapShape[isRound + 1]
136 | end
137 | end
138 |
139 | -- calculate distance from the center of the map
140 | local dist
141 | if isRound then
142 | dist = (diffX*diffX + diffY*diffY) / 0.9^2
143 | else
144 | dist = max(diffX*diffX, diffY*diffY) / 0.9^2
145 | end
146 |
147 | -- if distance > 1, then adapt node position to slide on the border
148 | if dist > 1 and data.floatOnEdge then
149 | dist = dist^0.5
150 | diffX = diffX/dist
151 | diffY = diffY/dist
152 | end
153 |
154 | if dist <= 1 or data.floatOnEdge then
155 | pin:Show()
156 | pin:ClearAllPoints()
157 | pin:SetPoint("CENTER", pins.Minimap, "CENTER", diffX * minimapWidth, -diffY * minimapHeight)
158 | data.onEdge = (dist > 1)
159 | else
160 | pin:Hide()
161 | data.onEdge = nil
162 | pin.keep = nil
163 | end
164 | end
165 |
166 | local function IsParentMap(originMapId, toCheckMapId)
167 | local parentMapID = HBD.mapData[originMapId].parent
168 | while parentMapID and HBD.mapData[parentMapID] do
169 | local mapType = HBD.mapData[parentMapID].mapType
170 | if mapType ~= Enum.UIMapType.Zone and mapType ~= Enum.UIMapType.Dungeon and mapType ~= Enum.UIMapType.Micro then
171 | return false
172 | end
173 | if parentMapID == toCheckMapId then
174 | return true
175 | end
176 | parentMapID = HBD.mapData[parentMapID].parent
177 | end
178 | return false
179 | end
180 |
181 | local function UpdateMinimapPins(force)
182 | -- get the current player position
183 | local x, y, instanceID = HBD:GetPlayerWorldPosition()
184 | local mapID = HBD:GetPlayerZone()
185 |
186 | -- get data from the API for calculations
187 | local zoom = pins.Minimap:GetZoom()
188 | local diffZoom = zoom ~= lastZoom
189 |
190 | -- for rotating minimap support
191 | local facing
192 | if rotateMinimap then
193 | facing = GetPlayerFacing()
194 | else
195 | facing = lastFacing
196 | end
197 |
198 | -- check for all values to be available (starting with 7.1.0, instances don't report coordinates)
199 | if not x or not y or (rotateMinimap and not facing) then
200 | minimapPinCount = 0
201 | for pin, data in pairs(activeMinimapPins) do
202 | pin:Hide()
203 | activeMinimapPins[pin] = nil
204 | end
205 | return
206 | end
207 |
208 | local newScale = pins.Minimap:GetScale()
209 | if minimapScale ~= newScale then
210 | minimapScale = newScale
211 | force = true
212 | end
213 |
214 | if x ~= lastXY or y ~= lastYY or diffZoom or facing ~= lastFacing or force then
215 | -- minimap information
216 | minimapShape = GetMinimapShape and minimap_shapes[GetMinimapShape() or "ROUND"]
217 | mapRadius = minimap_size[indoors][zoom] / 2
218 | minimapWidth = pins.Minimap:GetWidth() / 2
219 | minimapHeight = pins.Minimap:GetHeight() / 2
220 |
221 | -- update upvalues for icon placement
222 | lastZoom = zoom
223 | lastFacing = facing
224 | lastXY, lastYY = x, y
225 |
226 | if rotateMinimap then
227 | mapSin = sin(facing)
228 | mapCos = cos(facing)
229 | end
230 |
231 | for pin, data in pairs(minimapPins) do
232 | if data.instanceID == instanceID and (not data.uiMapID or data.uiMapID == mapID or (data.showInParentZone and IsParentMap(data.uiMapID, mapID))) then
233 | activeMinimapPins[pin] = data
234 | data.keep = true
235 | -- draw the pin (this may reset data.keep if outside of the map)
236 | drawMinimapPin(pin, data)
237 | end
238 | end
239 |
240 | minimapPinCount = 0
241 | for pin, data in pairs(activeMinimapPins) do
242 | if not data.keep then
243 | pin:Hide()
244 | activeMinimapPins[pin] = nil
245 | else
246 | minimapPinCount = minimapPinCount + 1
247 | data.keep = nil
248 | end
249 | end
250 | end
251 | end
252 |
253 | local function UpdateMinimapIconPosition()
254 |
255 | -- get the current map zoom
256 | local zoom = pins.Minimap:GetZoom()
257 | local diffZoom = zoom ~= lastZoom
258 | -- if the map zoom changed, run a full update sweep
259 | if diffZoom then
260 | UpdateMinimapPins()
261 | return
262 | end
263 |
264 | -- we have no active minimap pins, just return early
265 | if minimapPinCount == 0 then return end
266 |
267 | local x, y = HBD:GetPlayerWorldPosition()
268 |
269 | -- for rotating minimap support
270 | local facing
271 | if rotateMinimap then
272 | facing = GetPlayerFacing()
273 | else
274 | facing = lastFacing
275 | end
276 |
277 | -- check for all values to be available (starting with 7.1.0, instances don't report coordinates)
278 | if not x or not y or (rotateMinimap and not facing) then
279 | UpdateMinimapPins()
280 | return
281 | end
282 |
283 | local refresh
284 | local newScale = pins.Minimap:GetScale()
285 | if minimapScale ~= newScale then
286 | minimapScale = newScale
287 | refresh = true
288 | end
289 |
290 | if x ~= lastXY or y ~= lastYY or facing ~= lastFacing or refresh then
291 | -- update radius of the map
292 | mapRadius = minimap_size[indoors][zoom] / 2
293 | -- update upvalues for icon placement
294 | lastXY, lastYY = x, y
295 | lastFacing = facing
296 |
297 | if rotateMinimap then
298 | mapSin = sin(facing)
299 | mapCos = cos(facing)
300 | end
301 |
302 | -- iterate all nodes and check if they are still in range of our minimap display
303 | for pin, data in pairs(activeMinimapPins) do
304 | -- update the position of the node
305 | drawMinimapPin(pin, data)
306 | end
307 | end
308 | end
309 |
310 | local function UpdateMinimapZoom()
311 | local zoom = pins.Minimap:GetZoom()
312 | if GetCVar("minimapZoom") == GetCVar("minimapInsideZoom") then
313 | pins.Minimap:SetZoom(zoom < 2 and zoom + 1 or zoom - 1)
314 | end
315 | indoors = GetCVar("minimapZoom")+0 == pins.Minimap:GetZoom() and "outdoor" or "indoor"
316 | pins.Minimap:SetZoom(zoom)
317 | end
318 |
319 | -------------------------------------------------------------------------------------------
320 | -- WorldMap data provider
321 |
322 | -- setup pin pool
323 | worldmapPinsPool.parent = WorldMapFrame:GetCanvas()
324 | worldmapPinsPool.creationFunc = function(framePool)
325 | local frame = CreateFrame(framePool.frameType, nil, framePool.parent)
326 | frame:SetSize(1, 1)
327 | return Mixin(frame, worldmapProviderPin)
328 | end
329 | worldmapPinsPool.resetterFunc = function(pinPool, pin)
330 | FramePool_HideAndClearAnchors(pinPool, pin)
331 | pin:OnReleased()
332 |
333 | pin.pinTemplate = nil
334 | pin.owningMap = nil
335 | end
336 |
337 | -- register pin pool with the world map
338 | WorldMapFrame.pinPools["HereBeDragonsPinsTemplate"] = worldmapPinsPool
339 |
340 | -- provider base API
341 | function worldmapProvider:RemoveAllData()
342 | self:GetMap():RemoveAllPinsByTemplate("HereBeDragonsPinsTemplate")
343 | end
344 |
345 | function worldmapProvider:RemovePinByIcon(icon)
346 | for pin in self:GetMap():EnumeratePinsByTemplate("HereBeDragonsPinsTemplate") do
347 | if pin.icon == icon then
348 | self:GetMap():RemovePin(pin)
349 | end
350 | end
351 | end
352 |
353 | function worldmapProvider:RemovePinsByRef(ref)
354 | for pin in self:GetMap():EnumeratePinsByTemplate("HereBeDragonsPinsTemplate") do
355 | if pin.icon and worldmapPinRegistry[ref][pin.icon] then
356 | self:GetMap():RemovePin(pin)
357 | end
358 | end
359 | end
360 |
361 | function worldmapProvider:RefreshAllData(fromOnShow)
362 | self:RemoveAllData()
363 |
364 | for icon, data in pairs(worldmapPins) do
365 | self:HandlePin(icon, data)
366 | end
367 | end
368 |
369 | function worldmapProvider:HandlePin(icon, data)
370 | local uiMapID = self:GetMap():GetMapID()
371 |
372 | -- check for a valid map
373 | if not uiMapID then return end
374 |
375 | local x, y
376 | if uiMapID == WORLD_MAP_ID then
377 | -- should this pin show on the world map?
378 | if uiMapID ~= data.uiMapID and data.worldMapShowFlag ~= HBD_PINS_WORLDMAP_SHOW_WORLD then return end
379 |
380 | -- translate to the world map
381 | x, y = HBD:GetAzerothWorldMapCoordinatesFromWorld(data.x, data.y, data.instanceID)
382 | else
383 | -- check that it matches the instance
384 | if not HBD.mapData[uiMapID] or HBD.mapData[uiMapID].instance ~= data.instanceID then return end
385 |
386 | if uiMapID ~= data.uiMapID then
387 | local mapType = HBD.mapData[uiMapID].mapType
388 | if not data.uiMapID then
389 | if mapType == Enum.UIMapType.Continent and data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_CONTINENT then
390 | --pass
391 | elseif mapType ~= Enum.UIMapType.Zone and mapType ~= Enum.UIMapType.Dungeon and mapType ~= Enum.UIMapType.Micro then
392 | -- fail
393 | return
394 | end
395 | else
396 | local show = false
397 | local parentMapID = HBD.mapData[data.uiMapID].parent
398 | while parentMapID and HBD.mapData[parentMapID] do
399 | if parentMapID == uiMapID then
400 | local mapType = HBD.mapData[parentMapID].mapType
401 | -- show on any parent zones if they are normal zones
402 | if data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_PARENT and
403 | (mapType == Enum.UIMapType.Zone or mapType == Enum.UIMapType.Dungeon or mapType == Enum.UIMapType.Micro) then
404 | show = true
405 | -- show on the continent
406 | elseif data.worldMapShowFlag >= HBD_PINS_WORLDMAP_SHOW_CONTINENT and
407 | mapType == Enum.UIMapType.Continent then
408 | show = true
409 | end
410 | break
411 | -- worldmap is handled above already
412 | else
413 | parentMapID = HBD.mapData[parentMapID].parent
414 | end
415 | end
416 |
417 | if not show then return end
418 | end
419 | end
420 |
421 | -- translate coordinates
422 | x, y = HBD:GetZoneCoordinatesFromWorld(data.x, data.y, uiMapID)
423 | end
424 | if x and y then
425 | self:GetMap():AcquirePin("HereBeDragonsPinsTemplate", icon, x, y, data.frameLevelType)
426 | end
427 | end
428 |
429 | -- map pin base API
430 | function worldmapProviderPin:OnLoad()
431 | self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
432 | self:SetScalingLimits(1, 1.0, 1.2)
433 | end
434 |
435 | function worldmapProviderPin:OnAcquired(icon, x, y, frameLevelType)
436 | self:UseFrameLevelType(frameLevelType or "PIN_FRAME_LEVEL_AREA_POI")
437 | self:SetPosition(x, y)
438 |
439 | self.icon = icon
440 | icon:SetParent(self)
441 | icon:ClearAllPoints()
442 | icon:SetPoint("CENTER", self, "CENTER")
443 | icon:Show()
444 | end
445 |
446 | function worldmapProviderPin:OnReleased()
447 | if self.icon then
448 | self.icon:Hide()
449 | self.icon:SetParent(UIParent)
450 | self.icon:ClearAllPoints()
451 | self.icon = nil
452 | end
453 | end
454 |
455 | -- register with the world map
456 | WorldMapFrame:AddDataProvider(worldmapProvider)
457 |
458 | -- map event handling
459 | local function UpdateMinimap()
460 | UpdateMinimapZoom()
461 | UpdateMinimapPins()
462 | end
463 |
464 | local function UpdateWorldMap()
465 | worldmapProvider:RefreshAllData()
466 | end
467 |
468 | local last_update = 0
469 | local function OnUpdateHandler(frame, elapsed)
470 | last_update = last_update + elapsed
471 | if last_update > 1 or queueFullUpdate then
472 | UpdateMinimapPins(queueFullUpdate)
473 | last_update = 0
474 | queueFullUpdate = false
475 | else
476 | UpdateMinimapIconPosition()
477 | end
478 | end
479 | pins.updateFrame:SetScript("OnUpdate", OnUpdateHandler)
480 |
481 | local function OnEventHandler(frame, event, ...)
482 | if event == "CVAR_UPDATE" then
483 | local cvar, value = ...
484 | if cvar == "ROTATE_MINIMAP" then
485 | rotateMinimap = (value == "1")
486 | queueFullUpdate = true
487 | end
488 | elseif event == "MINIMAP_UPDATE_ZOOM" then
489 | UpdateMinimap()
490 | elseif event == "PLAYER_LOGIN" then
491 | -- recheck cvars after login
492 | rotateMinimap = GetCVar("rotateMinimap") == "1"
493 | elseif event == "PLAYER_ENTERING_WORLD" then
494 | UpdateMinimap()
495 | UpdateWorldMap()
496 | end
497 | end
498 |
499 | pins.updateFrame:SetScript("OnEvent", OnEventHandler)
500 | pins.updateFrame:UnregisterAllEvents()
501 | pins.updateFrame:RegisterEvent("CVAR_UPDATE")
502 | pins.updateFrame:RegisterEvent("MINIMAP_UPDATE_ZOOM")
503 | pins.updateFrame:RegisterEvent("PLAYER_LOGIN")
504 | pins.updateFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
505 |
506 | HBD.RegisterCallback(pins, "PlayerZoneChanged", UpdateMinimap)
507 |
508 |
509 | --- Add a icon to the minimap (x/y world coordinate version)
510 | -- Note: This API does not let you specify a map to limit the pin to, it'll be shown on all maps these coordinates are valid for.
511 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
512 | -- @param icon Icon Frame
513 | -- @param instanceID Instance ID of the map to add the icon to
514 | -- @param x X position in world coordinates
515 | -- @param y Y position in world coordinates
516 | -- @param floatOnEdge flag if the icon should float on the edge of the minimap when going out of range, or hide immediately (default false)
517 | function pins:AddMinimapIconWorld(ref, icon, instanceID, x, y, floatOnEdge)
518 | if not ref then
519 | error(MAJOR..": AddMinimapIconWorld: 'ref' must not be nil")
520 | end
521 | if type(icon) ~= "table" or not icon.SetPoint then
522 | error(MAJOR..": AddMinimapIconWorld: 'icon' must be a frame", 2)
523 | end
524 | if type(instanceID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
525 | error(MAJOR..": AddMinimapIconWorld: 'instanceID', 'x' and 'y' must be numbers", 2)
526 | end
527 |
528 | if not minimapPinRegistry[ref] then
529 | minimapPinRegistry[ref] = {}
530 | end
531 |
532 | minimapPinRegistry[ref][icon] = true
533 |
534 | local t = minimapPins[icon] or newCachedTable()
535 | t.instanceID = instanceID
536 | t.x = x
537 | t.y = y
538 | t.floatOnEdge = floatOnEdge
539 | t.uiMapID = nil
540 | t.showInParentZone = nil
541 |
542 | minimapPins[icon] = t
543 | queueFullUpdate = true
544 |
545 | icon:SetParent(pins.Minimap)
546 | end
547 |
548 | --- Add a icon to the minimap (UiMapID zone coordinate version)
549 | -- The pin will only be shown on the map specified, or optionally its parent map if specified
550 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
551 | -- @param icon Icon Frame
552 | -- @param uiMapID uiMapID of the map to place the icon on
553 | -- @param x X position in local/point coordinates (0-1), relative to the zone
554 | -- @param y Y position in local/point coordinates (0-1), relative to the zone
555 | -- @param showInParentZone flag if the icon should be shown in its parent zone - ie. an icon in a microdungeon in the outdoor zone itself (default false)
556 | -- @param floatOnEdge flag if the icon should float on the edge of the minimap when going out of range, or hide immediately (default false)
557 | function pins:AddMinimapIconMap(ref, icon, uiMapID, x, y, showInParentZone, floatOnEdge)
558 | if not ref then
559 | error(MAJOR..": AddMinimapIconMap: 'ref' must not be nil")
560 | end
561 | if type(icon) ~= "table" or not icon.SetPoint then
562 | error(MAJOR..": AddMinimapIconMap: 'icon' must be a frame")
563 | end
564 | if type(uiMapID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
565 | error(MAJOR..": AddMinimapIconMap: 'uiMapID', 'x' and 'y' must be numbers")
566 | end
567 |
568 | -- convert to world coordinates and use our known adding function
569 | local xCoord, yCoord, instanceID = HBD:GetWorldCoordinatesFromZone(x, y, uiMapID)
570 | if not xCoord then return end
571 |
572 | self:AddMinimapIconWorld(ref, icon, instanceID, xCoord, yCoord, floatOnEdge)
573 |
574 | -- store extra information
575 | minimapPins[icon].uiMapID = uiMapID
576 | minimapPins[icon].showInParentZone = showInParentZone
577 | end
578 |
579 | --- Check if a floating minimap icon is on the edge of the map
580 | -- @param icon the minimap icon
581 | function pins:IsMinimapIconOnEdge(icon)
582 | if not icon then return false end
583 | local data = minimapPins[icon]
584 | if not data then return nil end
585 |
586 | return data.onEdge
587 | end
588 |
589 | --- Remove a minimap icon
590 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
591 | -- @param icon Icon Frame
592 | function pins:RemoveMinimapIcon(ref, icon)
593 | if not ref or not icon or not minimapPinRegistry[ref] then return end
594 | minimapPinRegistry[ref][icon] = nil
595 | if minimapPins[icon] then
596 | recycle(minimapPins[icon])
597 | minimapPins[icon] = nil
598 | activeMinimapPins[icon] = nil
599 | end
600 | icon:Hide()
601 | end
602 |
603 | --- Remove all minimap icons belonging to your addon (as tracked by "ref")
604 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
605 | function pins:RemoveAllMinimapIcons(ref)
606 | if not ref or not minimapPinRegistry[ref] then return end
607 | for icon in pairs(minimapPinRegistry[ref]) do
608 | recycle(minimapPins[icon])
609 | minimapPins[icon] = nil
610 | activeMinimapPins[icon] = nil
611 | icon:Hide()
612 | end
613 | wipe(minimapPinRegistry[ref])
614 | end
615 |
616 | --- Set the minimap object to position the pins on. Needs to support the usual functions a Minimap-type object exposes.
617 | -- @param minimapObject The new minimap object, or nil to restore the default
618 | function pins:SetMinimapObject(minimapObject)
619 | pins.Minimap = minimapObject or Minimap
620 | for pin in pairs(minimapPins) do
621 | pin:SetParent(pins.Minimap)
622 | end
623 | UpdateMinimapPins(true)
624 | end
625 |
626 | -- world map constants
627 | -- show worldmap pin on its parent zone map (if any)
628 | HBD_PINS_WORLDMAP_SHOW_PARENT = 1
629 | -- show worldmap pin on the continent map
630 | HBD_PINS_WORLDMAP_SHOW_CONTINENT = 2
631 | -- show worldmap pin on the continent and world map
632 | HBD_PINS_WORLDMAP_SHOW_WORLD = 3
633 |
634 | --- Add a icon to the world map (x/y world coordinate version)
635 | -- Note: This API does not let you specify a map to limit the pin to, it'll be shown on all maps these coordinates are valid for.
636 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
637 | -- @param icon Icon Frame
638 | -- @param instanceID Instance ID of the map to add the icon to
639 | -- @param x X position in world coordinates
640 | -- @param y Y position in world coordinates
641 | -- @param showFlag Flag to control on which maps this pin will be shown
642 | -- @param frameLevel Optional Frame Level type registered with the WorldMapFrame, defaults to PIN_FRAME_LEVEL_AREA_POI
643 | function pins:AddWorldMapIconWorld(ref, icon, instanceID, x, y, showFlag, frameLevel)
644 | if not ref then
645 | error(MAJOR..": AddWorldMapIconWorld: 'ref' must not be nil")
646 | end
647 | if type(icon) ~= "table" or not icon.SetPoint then
648 | error(MAJOR..": AddWorldMapIconWorld: 'icon' must be a frame", 2)
649 | end
650 | if type(instanceID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
651 | error(MAJOR..": AddWorldMapIconWorld: 'instanceID', 'x' and 'y' must be numbers", 2)
652 | end
653 |
654 | if not worldmapPinRegistry[ref] then
655 | worldmapPinRegistry[ref] = {}
656 | end
657 |
658 | worldmapPinRegistry[ref][icon] = true
659 |
660 | local t = worldmapPins[icon] or newCachedTable()
661 | t.instanceID = instanceID
662 | t.x = x
663 | t.y = y
664 | t.uiMapID = nil
665 | t.worldMapShowFlag = showFlag or 0
666 | t.frameLevelType = frameLevel
667 |
668 | worldmapPins[icon] = t
669 |
670 | worldmapProvider:HandlePin(icon, t)
671 | end
672 |
673 | --- Add a icon to the world map (uiMapID zone coordinate version)
674 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
675 | -- @param icon Icon Frame
676 | -- @param uiMapID uiMapID of the map to place the icon on
677 | -- @param x X position in local/point coordinates (0-1), relative to the zone
678 | -- @param y Y position in local/point coordinates (0-1), relative to the zone
679 | -- @param showFlag Flag to control on which maps this pin will be shown
680 | -- @param frameLevel Optional Frame Level type registered with the WorldMapFrame, defaults to PIN_FRAME_LEVEL_AREA_POI
681 | function pins:AddWorldMapIconMap(ref, icon, uiMapID, x, y, showFlag, frameLevel)
682 | if not ref then
683 | error(MAJOR..": AddWorldMapIconMap: 'ref' must not be nil")
684 | end
685 | if type(icon) ~= "table" or not icon.SetPoint then
686 | error(MAJOR..": AddWorldMapIconMap: 'icon' must be a frame")
687 | end
688 | if type(uiMapID) ~= "number" or type(x) ~= "number" or type(y) ~= "number" then
689 | error(MAJOR..": AddWorldMapIconMap: 'uiMapID', 'x' and 'y' must be numbers")
690 | end
691 |
692 | -- convert to world coordinates
693 | local xCoord, yCoord, instanceID = HBD:GetWorldCoordinatesFromZone(x, y, uiMapID)
694 | if not xCoord then return end
695 |
696 | if not worldmapPinRegistry[ref] then
697 | worldmapPinRegistry[ref] = {}
698 | end
699 |
700 | worldmapPinRegistry[ref][icon] = true
701 |
702 | local t = worldmapPins[icon] or newCachedTable()
703 | t.instanceID = instanceID
704 | t.x = xCoord
705 | t.y = yCoord
706 | t.uiMapID = uiMapID
707 | t.worldMapShowFlag = showFlag or 0
708 | t.frameLevelType = frameLevel
709 |
710 | worldmapPins[icon] = t
711 |
712 | worldmapProvider:HandlePin(icon, t)
713 | end
714 |
715 | --- Remove a worldmap icon
716 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
717 | -- @param icon Icon Frame
718 | function pins:RemoveWorldMapIcon(ref, icon)
719 | if not ref or not icon or not worldmapPinRegistry[ref] then return end
720 | worldmapPinRegistry[ref][icon] = nil
721 | if worldmapPins[icon] then
722 | recycle(worldmapPins[icon])
723 | worldmapPins[icon] = nil
724 | end
725 | worldmapProvider:RemovePinByIcon(icon)
726 | end
727 |
728 | --- Remove all worldmap icons belonging to your addon (as tracked by "ref")
729 | -- @param ref Reference to your addon to track the icon under (ie. your "self" or string identifier)
730 | function pins:RemoveAllWorldMapIcons(ref)
731 | if not ref or not worldmapPinRegistry[ref] then return end
732 | for icon in pairs(worldmapPinRegistry[ref]) do
733 | recycle(worldmapPins[icon])
734 | worldmapPins[icon] = nil
735 | end
736 | worldmapProvider:RemovePinsByRef(ref)
737 | wipe(worldmapPinRegistry[ref])
738 | end
739 |
740 | --- Return the angle and distance from the player to the specified pin
741 | -- @param icon icon object (minimap or worldmap)
742 | -- @return angle, distance where angle is in radians and distance in yards
743 | function pins:GetVectorToIcon(icon)
744 | if not icon then return nil, nil end
745 | local data = minimapPins[icon] or worldmapPins[icon]
746 | if not data then return nil, nil end
747 |
748 | local x, y, instance = HBD:GetPlayerWorldPosition()
749 | if not x or not y or instance ~= data.instanceID then return nil end
750 |
751 | return HBD:GetWorldVector(instance, x, y, data.x, data.y)
752 | end
753 |
--------------------------------------------------------------------------------
/DBfunctions.lua:
--------------------------------------------------------------------------------
1 | if (tonumber(string.sub(AAPClassic.Build, 1,1)) > 2) then
2 | --return
3 | end
4 | AAPClassic.ShowedDB = {}
5 | AAPClassic.DB = {}
6 | AAPClassic.TooltipsMapDB = {}
7 | AAPClassic.TooltipsMapDBPlace = {}
8 | AAPClassic.TooltipsList = {}
9 |
10 | function AAPClassic.CheckShowedDBz()
11 | local CurStep = AAPC1[AAPClassic.Realm][AAPClassic.Name]["Zones"][AAPClassic.QH.ZoneNr]
12 | local Step = AAPClassic.Path[AAPClassic.QH.ZoneNr][CurStep]
13 | local Remoced = 0
14 | for AAP_index,AAP_value in pairs(AAPClassic.ShowedDB) do
15 | for AAP_index2,AAP_value2 in pairs(AAPClassic.ShowedDB[AAP_index]) do
16 | if (Step["Qpart"] and Step["Qpart"][AAP_index] and Step["Qpart"][AAP_index][tostring(AAP_index2)]) then
17 | elseif (Step["Fillers"] and Step["Fillers"][AAP_index] and Step["Fillers"][AAP_index][tostring(AAP_index2)]) then
18 | else
19 | Remoced = 1
20 | end
21 | end
22 | end
23 | if (Remoced == 1) then
24 | AAPClassic.RemoveIcons()
25 | end
26 | end
27 |
28 | function AAPClassic.ItemDBcheck(Itemid, Tooltipz,Qid,PartNr)
29 | if (AAPClassic["items"][Itemid]) then
30 | if (AAPClassic["items"][Itemid]["U"]) then
31 | local Mobs = AAPClassic["items"][Itemid]["U"]
32 | for AAP_index,AAP_value in pairs(Mobs) do
33 | if (AAPClassic["units"][AAP_index] and AAPClassic["units"][AAP_index]["coords"]) then
34 | local coords = AAPClassic["units"][AAP_index]["coords"]
35 | for AAP_index2,AAP_value2 in pairs(coords) do
36 | local x = coords[AAP_index2][1] / 100
37 | local y = coords[AAP_index2][2] / 100
38 | local z = coords[AAP_index2][3]
39 | local mz = C_Map.GetBestMapForUnit("player")
40 | if (AAPClassic["TranslateZones"][z] == mz) then
41 | Coloridz = AAP_index
42 | if (AAPClassic["unitsNames"][AAP_index] and Qid and PartNr) then
43 | AAPClassic.ActiveMobIds[AAPClassic["unitsNames"][AAP_index]] = Qid.."-"..PartNr
44 | end
45 | local numberfortool = AAPClassic.AddIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz)
46 | AAPClassic.Tooltips[numberfortool] = Tooltipz
47 | if (not AAPClassic.TooltipsList[AAP_index]) then
48 | AAPClassic.TooltipsList[AAP_index] = {}
49 | end
50 | if (PartNr and Qid and not AAPClassic.TooltipsList[AAP_index][Qid.."-"..PartNr]) then
51 | AAPClassic.TooltipsList[AAP_index][Qid.."-"..PartNr] = Qid.."-"..PartNr
52 | end
53 | local numberfortool2 = AAPClassic.AddMapIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz)
54 | AAPClassic.TooltipsMap[numberfortool2] = Tooltipz
55 | end
56 | end
57 | end
58 | end
59 | end
60 | end
61 | end
62 | function AAPClassic.ListDBOnMap()
63 | local CurZoneID = C_Map.GetBestMapForUnit("player")
64 | local currentMapId, TOP_MOST = C_Map.GetBestMapForUnit('player'), true
65 | if (Enum and Enum.UIMapType and Enum.UIMapType.Continent and currentMapId) then
66 | CurZoneID = MapUtil.GetMapParentInfo(currentMapId, Enum.UIMapType.Continent+1, TOP_MOST)
67 | end
68 | if (CurZoneID and CurZoneID["mapID"]) then
69 | CurZoneID = CurZoneID["mapID"]
70 | else
71 | CurZoneID = C_Map.GetBestMapForUnit("player")
72 | end
73 | AAPClassic.Level = UnitLevel("player")
74 | local AllyZeRace = {
75 | [1] = "Human",
76 | [2] = "Orc",
77 | [4] = "Dwarf",
78 | [8] = "NightElf",
79 | [77] = "Ally",
80 | [255] = "Both",
81 | }
82 | local HordeZeRace = {
83 | [16] = "Scourge",
84 | [32] = "Tauren",
85 | [64] = "Gnome",
86 | [128] = "Troll",
87 | [178] = "Horde",
88 | [255] = "Both",
89 | }
90 | if (AAPClassic.CurZoneQListed ~= CurZoneID or not AAPClassic.CurZoneQListedList) then
91 | AAPClassic.PreListDBOnMap(CurZoneID)
92 | AAPClassic.CurZoneQListed = CurZoneID
93 | end
94 | local derpcount = 0
95 | for AAP_index2,AAP_value2 in pairs(AAPClassic.CurZoneQListedList) do
96 | local CurQuest = AAPClassic["quests"][AAP_index2]
97 | if (not IsQuestFlaggedCompleted(AAP_index2) and not AAPClassic.QuestList[AAP_index2] and CurQuest["min"] and CurQuest["lvl"] and ((AAPClassic.Level-7) < CurQuest["lvl"]) and AAPClassic.Level >= CurQuest["min"] and CurQuest["min"] > 1) then
98 | if (UnitFactionGroup("player") == "Alliance") then
99 | local Continue = 0
100 |
101 | if (CurQuest["race"] and AllyZeRace[CurQuest["race"]]) then
102 | Continue = 1
103 | elseif (CurQuest["race"] and HordeZeRace[CurQuest["race"]]) then
104 | Continue = 0
105 | else
106 | Continue = 1
107 | end
108 | if (Continue == 1) then
109 | if ((not CurQuest["pre"] or IsQuestFlaggedCompleted(CurQuest["pre"])) and (not CurQuest["class"] or CurQuest["class"] == AAPClassic.ClassDBConv[AAPClassic.Class[3]])) then
110 | if (CurQuest["start"] and CurQuest["start"]["U"]) then
111 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["U"]) do
112 | local unitid = CurQuest["start"]["U"][AAP_a1]
113 | if (AAPClassic["units"][unitid] and AAPClassic["units"][unitid]["coords"]) then
114 | local amath = 0
115 | for AAP_a2,AAP_b2 in pairs(AAPClassic["units"][unitid]["coords"]) do
116 | amath = amath + 1
117 | local z = AAPClassic["units"][unitid]["coords"][amath][3]
118 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
119 | derpcount = derpcount + 1
120 | Ys, Xs = AAPClassic.GetPickUpDBCords(AAP_index2)
121 | if (Ys and Xs) then
122 | if (CurQuest["lvl"]) then
123 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),"["..CurQuest["lvl"].."] "..AAPClassic["questsNames"][AAP_index2]["T"])
124 | else
125 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),AAPClassic["questsNames"][AAP_index2]["T"])
126 | end
127 | break
128 | end
129 | end
130 | end
131 | end
132 | end
133 | elseif (CurQuest["start"] and CurQuest["start"]["O"] and "A" == "B") then
134 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["O"]) do
135 | local Objid = CurQuest["start"]["O"][AAP_a1]
136 | if (AAPClassic["objects"][Objid] and AAPClassic["objects"][Objid]["coords"] and (not AAPClassic["objects"][Objid]["fac"] or AAPClassic["objects"][Objid]["fac"] == "A")) then
137 | local amath = 0
138 | for AAP_a2,AAP_b2 in pairs(AAPClassic["objects"][Objid]["coords"]) do
139 | amath = amath + 1
140 | local z = AAPClassic["objects"][Objid]["coords"][amath][3]
141 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
142 | derpcount = derpcount + 1
143 | Ys, Xs = AAPClassic.GetPickUpDBCords(AAP_index2)
144 | local Tools2
145 | if (AAPClassic["objectsNames"][Objid]) then
146 | Tools2 = AAPClassic["objectsNames"][Objid]
147 | end
148 | if (Ys and Xs) then
149 | if (CurQuest["lvl"]) then
150 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),"["..CurQuest["lvl"].."] "..AAPClassic["questsNames"][AAP_index2]["T"],Tools2)
151 | else
152 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),AAPClassic["questsNames"][AAP_index2]["T"],Tools2)
153 | end
154 | break
155 | end
156 | end
157 | end
158 | end
159 | end
160 | end
161 | end
162 | end
163 | else
164 | local Continue = 0
165 | if (CurQuest["race"] and (CurQuest["race"] == 77 or CurQuest["race"] == 255)) then
166 | Continue = 0
167 | elseif (CurQuest["race"] and (CurQuest["race"] == 178)) then
168 | Continue = 1
169 | else
170 | Continue = 1
171 | end
172 | if (Continue == 1) then
173 | if ((not CurQuest["pre"] or IsQuestFlaggedCompleted(CurQuest["pre"])) and (not CurQuest["class"] or CurQuest["class"] == AAPClassic.ClassDBConv[AAPClassic.Class[3]])) then
174 | if (CurQuest["start"] and CurQuest["start"]["U"]) then
175 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["U"]) do
176 | local unitid = CurQuest["start"]["U"][AAP_a1]
177 | if (AAPClassic["units"][unitid] and AAPClassic["units"][unitid]["coords"]) then
178 | local amath = 0
179 | for AAP_a2,AAP_b2 in pairs(AAPClassic["units"][unitid]["coords"]) do
180 | amath = amath + 1
181 | local z = AAPClassic["units"][unitid]["coords"][amath][3]
182 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
183 | derpcount = derpcount + 1
184 | Ys, Xs = AAPClassic.GetPickUpDBCords(AAP_index2)
185 | if (Ys and Xs) then
186 | if (CurQuest["lvl"]) then
187 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),"["..CurQuest["lvl"].."] "..AAPClassic["questsNames"][AAP_index2]["T"])
188 | else
189 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),AAPClassic["questsNames"][AAP_index2]["T"])
190 | end
191 | break
192 | end
193 | end
194 | end
195 | end
196 | end
197 | elseif (CurQuest["start"] and CurQuest["start"]["O"] and "A" == "B") then
198 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["O"]) do
199 | local Objid = CurQuest["start"]["O"][AAP_a1]
200 | if (AAPClassic["objects"][Objid] and AAPClassic["objects"][Objid]["coords"] and (not AAPClassic["objects"][Objid]["fac"] or AAPClassic["objects"][Objid]["fac"] == "A")) then
201 | local amath = 0
202 | for AAP_a2,AAP_b2 in pairs(AAPClassic["objects"][Objid]["coords"]) do
203 | amath = amath + 1
204 | local z = AAPClassic["objects"][Objid]["coords"][amath][3]
205 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
206 | derpcount = derpcount + 1
207 | Ys, Xs = AAPClassic.GetPickUpDBCords(AAP_index2)
208 | local Tools2
209 | if (AAPClassic["objectsNames"][Objid]) then
210 | Tools2 = AAPClassic["objectsNames"][Objid]
211 | end
212 | if (Ys and Xs) then
213 | if (CurQuest["lvl"]) then
214 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),"["..CurQuest["lvl"].."] "..AAPClassic["questsNames"][AAP_index2]["T"],Tools2)
215 | else
216 | AAPClassic.AddQuestPickUpIcon(CurZoneID, (Ys/100), (Xs/100),AAPClassic["questsNames"][AAP_index2]["T"],Tools2)
217 | end
218 | break
219 | end
220 | end
221 | end
222 | end
223 | end
224 | end
225 | end
226 | end
227 | end
228 | end
229 | end
230 | end
231 | function AAPClassic.PreListDBOnMap(CurZoneID)
232 | AAPClassic.CurZoneQListedList = nil
233 | AAPClassic.CurZoneQListedList = {}
234 | local derpcount = 0
235 | for AAP_index2,AAP_value2 in pairs(AAPClassic["quests"]) do
236 | local CurQuest = AAPClassic["quests"][AAP_index2]
237 | if (not IsQuestFlaggedCompleted(AAP_index2) and not AAPClassic.QuestList[AAP_index2] and CurQuest["min"] and ((AAPClassic.Level-7) < CurQuest["lvl"]) and AAPClassic.Level >= CurQuest["min"] and CurQuest["min"] > 1) then
238 | if (UnitFactionGroup("player") == "Alliance") then
239 | local Continue = 0
240 |
241 | if (CurQuest["race"] and AllyZeRace[CurQuest["race"]]) then
242 | Continue = 1
243 | elseif (CurQuest["race"] and HordeZeRace[CurQuest["race"]]) then
244 | Continue = 0
245 | else
246 | Continue = 1
247 | end
248 | if (Continue == 1) then
249 | if ((not CurQuest["pre"] or IsQuestFlaggedCompleted(CurQuest["pre"])) and (not CurQuest["class"] or CurQuest["class"] == AAPClassic.ClassDBConv[AAPClassic.Class[3]])) then
250 | if (CurQuest["start"] and CurQuest["start"]["U"]) then
251 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["U"]) do
252 | local unitid = CurQuest["start"]["U"][AAP_a1]
253 | if (AAPClassic["units"][unitid] and AAPClassic["units"][unitid]["coords"]) then
254 | local amath = 0
255 | for AAP_a2,AAP_b2 in pairs(AAPClassic["units"][unitid]["coords"]) do
256 | amath = amath + 1
257 | local z = AAPClassic["units"][unitid]["coords"][amath][3]
258 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
259 | AAPClassic.CurZoneQListedList[AAP_index2] = AAPClassic["quests"][AAP_index2]
260 | break
261 | end
262 | end
263 | end
264 | end
265 | elseif (CurQuest["start"] and CurQuest["start"]["O"] and "A" == "B") then
266 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["O"]) do
267 | local Objid = CurQuest["start"]["O"][AAP_a1]
268 | if (AAPClassic["objects"][Objid] and AAPClassic["objects"][Objid]["coords"] and (not AAPClassic["objects"][Objid]["fac"] or AAPClassic["objects"][Objid]["fac"] == "A")) then
269 | local amath = 0
270 | for AAP_a2,AAP_b2 in pairs(AAPClassic["objects"][Objid]["coords"]) do
271 | amath = amath + 1
272 | local z = AAPClassic["objects"][Objid]["coords"][amath][3]
273 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
274 | AAPClassic.CurZoneQListedList[AAP_index2] = AAPClassic["quests"][AAP_index2]
275 | break
276 | end
277 | end
278 | end
279 | end
280 | end
281 | end
282 | end
283 | else
284 | local Continue = 0
285 | if (CurQuest["race"] and (CurQuest["race"] == 77 or CurQuest["race"] == 255)) then
286 | Continue = 0
287 | elseif (CurQuest["race"] and (CurQuest["race"] == 178)) then
288 | Continue = 1
289 | else
290 | Continue = 1
291 | end
292 | if (Continue == 1) then
293 | if ((not CurQuest["pre"] or IsQuestFlaggedCompleted(CurQuest["pre"])) and (not CurQuest["class"] or CurQuest["class"] == AAPClassic.ClassDBConv[AAPClassic.Class[3]])) then
294 | if (CurQuest["start"] and CurQuest["start"]["U"]) then
295 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["U"]) do
296 | local unitid = CurQuest["start"]["U"][AAP_a1]
297 | if (AAPClassic["units"][unitid] and AAPClassic["units"][unitid]["coords"]) then
298 | local amath = 0
299 | for AAP_a2,AAP_b2 in pairs(AAPClassic["units"][unitid]["coords"]) do
300 | amath = amath + 1
301 | local z = AAPClassic["units"][unitid]["coords"][amath][3]
302 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
303 | AAPClassic.CurZoneQListedList[AAP_index2] = AAPClassic["quests"][AAP_index2]
304 | break
305 | end
306 | end
307 | end
308 | end
309 | elseif (CurQuest["start"] and CurQuest["start"]["O"] and "A" == "B") then
310 | for AAP_a1,AAP_b1 in pairs(CurQuest["start"]["O"]) do
311 | local Objid = CurQuest["start"]["O"][AAP_a1]
312 | if (AAPClassic["objects"][Objid] and AAPClassic["objects"][Objid]["coords"] and (not AAPClassic["objects"][Objid]["fac"] or AAPClassic["objects"][Objid]["fac"] == "A")) then
313 | local amath = 0
314 | for AAP_a2,AAP_b2 in pairs(AAPClassic["objects"][Objid]["coords"]) do
315 | amath = amath + 1
316 | local z = AAPClassic["objects"][Objid]["coords"][amath][3]
317 | if (AAPClassic["TranslateZones"][z] and CurZoneID == AAPClassic["TranslateZones"][z]) then
318 | AAPClassic.CurZoneQListedList[AAP_index2] = AAPClassic["quests"][AAP_index2]
319 | break
320 | end
321 | end
322 | end
323 | end
324 | end
325 | end
326 | end
327 | end
328 | end
329 | end
330 | end
331 | function AAPClassic.QuestDBcheck(Qid, PartNr, Tooltipz, Fillerz)
332 | local PartNr2 = PartNr
333 | if (AAPClassic["quests"][Qid]) then
334 | if (AAPClassic["quests"][Qid]["obj"]) then
335 | if (AAPClassic["quests"][Qid]["obj"]["i"]) then
336 | if (AAPClassic["quests"][Qid]["obj"]["i"][PartNr]) then
337 | if (AAPClassic.Locale == "enUS") then
338 | for AAP_index3,AAP_value3 in pairs(AAPClassic["quests"][Qid]["obj"]["i"]) do
339 | if (Tooltipz and AAPClassic["itemsNames"][AAP_value3] and string.find(Tooltipz, AAPClassic["itemsNames"][AAP_value3])) then
340 | PartNr = AAP_index3
341 | end
342 | end
343 | end
344 | if (not AAPClassic.ShowedDB[Qid]) then
345 | AAPClassic.ShowedDB[Qid] = {}
346 | end
347 | if (not AAPClassic.ShowedDB[Qid][PartNr]) then
348 | AAPClassic.ShowedDB[Qid][PartNr] = {}
349 | else
350 | return
351 | end
352 | local Itemid = AAPClassic["quests"][Qid]["obj"]["i"][PartNr]
353 | if (AAPClassic["items"][Itemid]) then
354 | if (AAPClassic["items"][Itemid]["O"]) then
355 | for AAP_index,AAP_value in pairs(AAPClassic["items"][Itemid]["O"]) do
356 | if (AAPClassic["objects"][AAP_index] and AAPClassic["objects"][AAP_index]["coords"]) then
357 | local coords = AAPClassic["objects"][AAP_index] and AAPClassic["objects"][AAP_index]["coords"]
358 | local amath = 0
359 | for AAP_index2,AAP_value2 in pairs(coords) do
360 | amath = amath + 1
361 | local x = coords[amath][1] / 100
362 | local y = coords[amath][2] / 100
363 | local z = coords[amath][3]
364 | if (not AAPClassic.TooltipsMapDB[x..y..z]) then
365 | AAPClassic.TooltipsMapDB[x..y..z] = {}
366 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
367 | else
368 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
369 | break
370 | end
371 | local mz = C_Map.GetBestMapForUnit("player")
372 | if (AAPClassic["TranslateZones"][z] == mz) then
373 | Coloridz = AAP_index
374 | if (AAPClassic["unitsNames"][AAP_index]) then
375 | AAPClassic.ActiveMobIds[AAPClassic["unitsNames"][AAP_index]] = Qid.."-"..PartNr
376 | end
377 | local numberfortool = AAPClassic.AddIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
378 | AAPClassic.ShowedDB[Qid][PartNr][numberfortool] = numberfortool
379 | if (not AAPClassic.TooltipsList[AAP_index]) then
380 | AAPClassic.TooltipsList[AAP_index] = {}
381 | end
382 | if (not AAPClassic.TooltipsList[AAP_index][Qid.."-"..PartNr]) then
383 | AAPClassic.TooltipsList[AAP_index][Qid.."-"..PartNr] = Qid.."-"..PartNr
384 | end
385 | AAPClassic.TooltipsMapDBPlace[numberfortool] = x..y..z
386 | AAPClassic.Tooltips[numberfortool] = Tooltipz
387 | AAPClassic.MapMobListFontstrings(Tooltipz, Coloridz)
388 | local numberfortool2 = AAPClassic.AddMapIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
389 | AAPClassic.TooltipsMap[numberfortool2] = Tooltipz
390 | end
391 | end
392 | end
393 | end
394 | end
395 | if (AAPClassic["items"][Itemid]["U"]) then
396 | local Mobs = AAPClassic["items"][Itemid]["U"]
397 | for AAP_index,AAP_value in pairs(Mobs) do
398 | if (AAPClassic["units"][AAP_index] and AAPClassic["units"][AAP_index]["coords"]) then
399 | if (AAPClassic["units"][AAP_index]["lvl"]) then
400 | if (string.find(AAPClassic["units"][AAP_index]["lvl"], "%d\-%d")) then
401 | local _, _, derp1, derp2 = string.find(AAPClassic["units"][AAP_index]["lvl"], "(%d)-(%d)")
402 | local lvlz = 0
403 | if (not derp1) then
404 | lvlz = tonumber(AAPClassic["units"][AAP_index]["lvl"])
405 | else
406 | lvlz = tonumber(derp1)
407 | end
408 | if (AAPClassic.Level+2 < lvlz) then
409 | break
410 | end
411 | end
412 | end
413 | local coords = AAPClassic["units"][AAP_index]["coords"]
414 | local amath = 0
415 | for AAP_index2,AAP_value2 in pairs(coords) do
416 | amath = amath + 1
417 | local x = coords[amath][1] / 100
418 | local y = coords[amath][2] / 100
419 | local z = coords[amath][3]
420 | if (not AAPClassic.TooltipsMapDB[x..y..z]) then
421 | AAPClassic.TooltipsMapDB[x..y..z] = {}
422 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
423 | else
424 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
425 | break
426 | end
427 | local mz = C_Map.GetBestMapForUnit("player")
428 | if (AAPClassic["TranslateZones"][z] == mz) then
429 | Coloridz = AAP_index
430 | if (AAPClassic["unitsNames"][AAP_index]) then
431 | AAPClassic.ActiveMobIds[AAPClassic["unitsNames"][AAP_index]] = Qid.."-"..PartNr
432 | end
433 | local numberfortool = AAPClassic.AddIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
434 | AAPClassic.ShowedDB[Qid][PartNr][numberfortool] = numberfortool
435 | AAPClassic.TooltipsMapDBPlace[numberfortool] = x..y..z
436 | if (not AAPClassic.TooltipsList[AAP_index]) then
437 | AAPClassic.TooltipsList[AAP_index] = {}
438 | end
439 | AAPClassic.TooltipsList[AAP_index][Qid.."-"..PartNr] = Qid.."-"..PartNr
440 | AAPClassic.Tooltips[numberfortool] = Tooltipz
441 | AAPClassic.Tooltips2[numberfortool] = "["..AAPClassic["units"][AAP_index]["lvl"].."] "..AAPClassic["unitsNames"][AAP_index]
442 | AAPClassic.MapMobListFontstrings("["..AAPClassic["units"][AAP_index]["lvl"].."] "..AAPClassic["unitsNames"][AAP_index],Coloridz)
443 | local numberfortool2 = AAPClassic.AddMapIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
444 | AAPClassic.TooltipsMap[numberfortool2] = Tooltipz
445 | AAPClassic.TooltipsMap2[numberfortool] = "["..AAPClassic["units"][AAP_index]["lvl"].."] "..AAPClassic["unitsNames"][AAP_index]
446 | end
447 | end
448 | end
449 | end
450 | end
451 | end
452 | end
453 | end
454 | if (AAPClassic.Locale == "enUS" and AAPClassic["quests"][Qid] and AAPClassic["quests"][Qid]["obj"] and AAPClassic["quests"][Qid]["obj"]["U"]) then
455 | for AAP_index3,AAP_value3 in pairs(AAPClassic["quests"][Qid]["obj"]["U"]) do
456 | if (Tooltipz and AAPClassic["unitsNames"][AAP_value3] and string.find(Tooltipz, AAPClassic["unitsNames"][AAP_value3])) then
457 | PartNr = AAP_index3
458 | end
459 | end
460 | end
461 | if (AAPClassic["quests"][Qid]["obj"]["U"]) then
462 | if (not AAPClassic.ShowedDB[Qid]) then
463 | AAPClassic.ShowedDB[Qid] = {}
464 | end
465 | if (not AAPClassic.ShowedDB[Qid][PartNr]) then
466 | AAPClassic.ShowedDB[Qid][PartNr] = {}
467 | else
468 | return
469 | end
470 | if (AAPClassic["quests"][Qid]["obj"]["U"][PartNr]) then
471 | local Mobid = AAPClassic["quests"][Qid]["obj"]["U"][PartNr]
472 | if (AAPClassic["units"][Mobid] and AAPClassic["units"][Mobid]["coords"]) then
473 | local coords = AAPClassic["units"][Mobid]["coords"]
474 | for AAP_index2,AAP_value2 in pairs(coords) do
475 | local x = coords[AAP_index2][1] / 100
476 | local y = coords[AAP_index2][2] / 100
477 | local z = coords[AAP_index2][3]
478 | if (not AAPClassic.TooltipsMapDB[x..y..z]) then
479 | AAPClassic.TooltipsMapDB[x..y..z] = {}
480 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
481 | else
482 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
483 | break
484 | end
485 | local mz = C_Map.GetBestMapForUnit("player")
486 | if (AAPClassic["TranslateZones"][z] == mz) then
487 | Coloridz = Mobid
488 | if (AAPClassic["unitsNames"][Mobid]) then
489 | AAPClassic.ActiveMobIds[AAPClassic["unitsNames"][Mobid]] = Qid.."-"..PartNr
490 | end
491 | local numberfortool = AAPClassic.AddIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
492 | AAPClassic.ShowedDB[Qid][PartNr][numberfortool] = numberfortool
493 | AAPClassic.TooltipsMapDBPlace[numberfortool] = x..y..z
494 | AAPClassic.Tooltips[numberfortool] = Tooltipz
495 | AAPClassic.Tooltips2[numberfortool] = "["..AAPClassic["units"][Mobid]["lvl"].."] "..AAPClassic["unitsNames"][Mobid]
496 | AAPClassic.MapMobListFontstrings("["..AAPClassic["units"][Mobid]["lvl"].."] "..AAPClassic["unitsNames"][Mobid],Coloridz)
497 | local numberfortool2 = AAPClassic.AddMapIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
498 | AAPClassic.TooltipsMap2[numberfortool2] = "["..AAPClassic["units"][Mobid]["lvl"].."] "..AAPClassic["unitsNames"][Mobid]
499 | AAPClassic.TooltipsMap[numberfortool2] = Tooltipz
500 | end
501 | end
502 | end
503 | end
504 | end
505 | if (AAPClassic.Locale == "enUS" and AAPClassic["quests"][Qid] and AAPClassic["quests"][Qid]["obj"] and AAPClassic["quests"][Qid]["obj"]["U"]) then
506 | for AAP_index3,AAP_value3 in pairs(AAPClassic["quests"][Qid]["obj"]["U"]) do
507 | if (Tooltipz and AAPClassic["unitsNames"][AAP_value3] and string.find(Tooltipz, AAPClassic["unitsNames"][AAP_value3])) then
508 | PartNr = AAP_index3
509 | end
510 | end
511 | end
512 | if (AAPClassic["quests"][Qid]["obj"]["O"]) then
513 | for AAP_index,AAP_value in pairs(AAPClassic["quests"][Qid]["obj"]["O"]) do
514 | PartNr = AAP_index
515 | if (not AAPClassic.ShowedDB[Qid]) then
516 | AAPClassic.ShowedDB[Qid] = {}
517 | end
518 | if (not AAPClassic.ShowedDB[Qid][PartNr]) then
519 | AAPClassic.ShowedDB[Qid][PartNr] = {}
520 | end
521 | if (AAPClassic["quests"][Qid]["obj"]["O"][PartNr]) then
522 | local Object = AAPClassic["quests"][Qid]["obj"]["O"][PartNr]
523 | if (AAPClassic["objects"][Object] and AAPClassic["objects"][Object]["coords"]) then
524 | local coords = AAPClassic["objects"][Object]["coords"]
525 | for AAP_index2,AAP_value2 in pairs(coords) do
526 | local x = coords[AAP_index2][1] / 100
527 | local y = coords[AAP_index2][2] / 100
528 | local z = coords[AAP_index2][3]
529 | if (not AAPClassic.TooltipsMapDB[x..y..z]) then
530 | AAPClassic.TooltipsMapDB[x..y..z] = {}
531 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
532 | else
533 | tinsert(AAPClassic.TooltipsMapDB[x..y..z], Tooltipz)
534 | break
535 | end
536 | local mz = C_Map.GetBestMapForUnit("player")
537 | if (AAPClassic["TranslateZones"][z] == mz) then
538 | Coloridz = Object
539 | if (AAPClassic["unitsNames"][Object]) then
540 | AAPClassic.ActiveMobIds[AAPClassic["unitsNames"][Object]] = Qid.."-"..PartNr
541 | end
542 | local numberfortool = AAPClassic.AddIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
543 | AAPClassic.ShowedDB[Qid][PartNr][numberfortool] = numberfortool
544 | AAPClassic.TooltipsMapDBPlace[numberfortool] = x..y..z
545 | AAPClassic.Tooltips[numberfortool] = Tooltipz
546 | AAPClassic.MapMobListFontstrings(Tooltipz, Coloridz)
547 | local numberfortool2 = AAPClassic.AddMapIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz, Fillerz)
548 | AAPClassic.TooltipsMap[numberfortool2] = Tooltipz
549 | end
550 | end
551 | end
552 | end
553 | end
554 | end
555 | end
556 | end
557 |
558 | end
559 | function AAPClassic.QuestDBShowMob(MobIdz,Qid,PartNr)
560 | if (AAPClassic["units"][MobIdz] and AAPClassic["units"][MobIdz]["coords"]) then
561 | local coords = AAPClassic["units"][MobIdz]["coords"]
562 | for AAP_index2,AAP_value2 in pairs(coords) do
563 | local x = coords[AAP_index2][1] / 100
564 | local y = coords[AAP_index2][2] / 100
565 | local z = coords[AAP_index2][3]
566 | local mz = C_Map.GetBestMapForUnit("player")
567 | if (AAPClassic["TranslateZones"][z] == mz) then
568 | Coloridz = MobIdz
569 | if (AAPClassic["unitsNames"][MobIdz]) then
570 | AAPClassic.ActiveMobIds[AAPClassic["unitsNames"][MobIdz]] = Qid.."-"..PartNr
571 | end
572 | local numberfortool = AAPClassic.AddIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz)
573 | if (not AAPClassic.TooltipsList[MobIdz]) then
574 | AAPClassic.TooltipsList[MobIdz] = {}
575 | end
576 | if (not AAPClassic.TooltipsList[MobIdz][Qid.."-"..PartNr]) then
577 | AAPClassic.TooltipsList[MobIdz][Qid.."-"..PartNr] = Qid.."-"..PartNr
578 | end
579 | AAPClassic.Tooltips[numberfortool] = Tooltipz
580 | AAPClassic.Tooltips2[numberfortool] = AAPClassic["unitsNames"][MobIdz]
581 | local numberfortool2 = AAPClassic.AddMapIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz)
582 | AAPClassic.TooltipsMap[numberfortool2] = Tooltipz
583 | AAPClassic.TooltipsMap2[numberfortool] = AAPClassic["unitsNames"][MobIdz]
584 | end
585 | end
586 | end
587 | end
588 | function AAPClassic.QuestDBShowObj(MobIdz, Namez,Qid,PartNr)
589 | if (AAPClassic["objects"][MobIdz] and AAPClassic["objects"][MobIdz]["coords"]) then
590 | local coords = AAPClassic["objects"][MobIdz]["coords"]
591 | for AAP_index2,AAP_value2 in pairs(coords) do
592 | local x = coords[AAP_index2][1] / 100
593 | local y = coords[AAP_index2][2] / 100
594 | local z = coords[AAP_index2][3]
595 | local mz = C_Map.GetBestMapForUnit("player")
596 | if (AAPClassic["TranslateZones"][z] == mz) then
597 | Coloridz = MobIdz
598 | if (AAPClassic["unitsNames"][MobIdz]) then
599 | AAPClassic.ActiveMobIds[AAPClassic["unitsNames"][MobIdz]] = Qid.."-"..PartNr
600 | end
601 | local numberfortool = AAPClassic.AddIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz)
602 | if (not AAPClassic.TooltipsList[MobIdz]) then
603 | AAPClassic.TooltipsList[MobIdz] = {}
604 | end
605 | if (not AAPClassic.TooltipsList[MobIdz][Qid.."-"..PartNr]) then
606 | AAPClassic.TooltipsList[MobIdz][Qid.."-"..PartNr] = Qid.."-"..PartNr
607 | end
608 | AAPClassic.Tooltips[numberfortool] = Namez
609 | AAPClassic.Tooltips2[numberfortool] = AAPClassic["unitsNames"][MobIdz]
610 | local numberfortool2 = AAPClassic.AddMapIcon(C_Map.GetBestMapForUnit("player"), x, y, Coloridz)
611 | AAPClassic.TooltipsMap[numberfortool2] = Namez
612 | AAPClassic.TooltipsMap2[numberfortool] = AAPClassic["unitsNames"][MobIdz]
613 | end
614 | end
615 | end
616 | end
617 | function AAPClassic.GetPickUpDBCords(theqid)
618 | if (AAPClassic["quests"][theqid] and AAPClassic["quests"][theqid]["end"] and AAPClassic["quests"][theqid]["end"]["U"] and AAPClassic["quests"][theqid]["end"]["U"][1]) then
619 | local Uid = AAPClassic["quests"][theqid]["end"]["U"][1]
620 | if (AAPClassic["units"][Uid] and AAPClassic["units"][Uid]["coords"]) then
621 | local Zemapidz = C_Map.GetBestMapForUnit("player")
622 | local currentMapId, TOP_MOST = C_Map.GetBestMapForUnit('player'), true
623 | if (Enum and Enum.UIMapType and Enum.UIMapType.Continent and currentMapId) then
624 | Zemapidz = MapUtil.GetMapParentInfo(currentMapId, Enum.UIMapType.Continent+1, TOP_MOST)
625 | end
626 | if (Zemapidz and Zemapidz["mapID"]) then
627 | Zemapidz = Zemapidz["mapID"]
628 | else
629 | Zemapidz = C_Map.GetBestMapForUnit("player")
630 | end
631 | local ztable = AAPClassic["units"][Uid]["coords"][1]
632 | local translatez = AAPClassic["TranslateZones"][AAPClassic["units"][Uid]["coords"][1][3]]
633 | if (translatez == Zemapidz) then
634 | local Ys = AAPClassic["units"][Uid]["coords"][1][2]
635 | local Xs = AAPClassic["units"][Uid]["coords"][1][1]
636 | return Xs,Ys
637 | else
638 | return nil,nil
639 | end
640 | else
641 | return nil,nil
642 | end
643 | else
644 | return nil,nil
645 | end
646 | end
647 |
648 |
--------------------------------------------------------------------------------