vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | FLIGHTMAP_MAX_TAXIPATHS = 48; |
2 | FLIGHTMAP_MAX_TAXINODES = 32; |
||
3 | |||
4 | function FlightMapTaxi_SetContinent(cont) |
||
5 | local cname = FlightMapUtil.getContinentName(cont); |
||
6 | TaxiMerchant:SetText(cname); |
||
7 | local tname = "Interface\\TaxiFrame\\TAXIMAP" .. 2-cont; |
||
8 | TaxiMap:SetTexture(tname); |
||
9 | FlightMapTaxiFrame_OnEvent(cont); |
||
10 | end |
||
11 | |||
12 | function FlightMapTaxi_ShowContinent() |
||
13 | if TaxiFrame:IsVisible() then |
||
14 | HideUIPanel(TaxiFrame); |
||
15 | return; |
||
16 | end |
||
17 | |||
18 | TaxiPortrait:SetTexture("Interface\\WorldMap\\WorldMap-Icon"); |
||
19 | for i = 1, NUM_TAXI_BUTTONS, 1 do |
||
20 | local btn = getglobal("TaxiButton" .. i); |
||
21 | if btn then btn:Hide(); end |
||
22 | end |
||
23 | |||
24 | -- Get a (non-instanced) continent number |
||
25 | local cont = FlightMapUtil.getContinent(); |
||
26 | if cont == 0 then cont = 1; end |
||
27 | |||
28 | -- Must kill "OnShow" handler briefly |
||
29 | local onshow = TaxiFrame:GetScript("OnShow"); |
||
30 | TaxiFrame:SetScript("OnShow", function() |
||
31 | PlaySound("igMainMenuOpen"); |
||
32 | end); |
||
33 | ShowUIPanel(TaxiFrame, 1); |
||
34 | TaxiFrame:SetScript("OnShow", onshow); |
||
35 | |||
36 | -- Toggle FlightMap/Blizzard stuff |
||
37 | TaxiRouteMap:Hide(); |
||
38 | FlightMapTaxiContinents:Show(); |
||
39 | |||
40 | -- Then set the continent display |
||
41 | FlightMapTaxi_SetContinent(cont); |
||
42 | |||
43 | UIDropDownMenu_SetSelectedID(FlightMapTaxiContinents, cont); |
||
44 | end |
||
45 | |||
46 | function FlightMapTaxiButton_OnEnter(button) |
||
47 | GameTooltip:SetOwner(button, "ANCHOR_RIGHT"); |
||
48 | FlightMapUtil.addFlightsForNode(GameTooltip, button.nodeKey, '', |
||
49 | FlightMapTaxiFrame.sourceKey); |
||
50 | if FlightMapTaxiFrame.sourceNode then |
||
51 | local costs = FlightMapTaxiFrame.sourceNode.Costs; |
||
52 | if costs[button.nodeKey] and costs[button.nodeKey] > 0 then |
||
53 | SetTooltipMoney(GameTooltip, costs[button.nodeKey]); |
||
54 | end |
||
55 | end |
||
56 | GameTooltip:Show(); |
||
57 | end |
||
58 | |||
59 | function FlightMapTaxiButton_OnLeave(button) |
||
60 | GameTooltip:Hide(); |
||
61 | end |
||
62 | |||
63 | function FlightMapTaxiFrame_OnLoad() |
||
64 | this:RegisterEvent("TAXIMAP_OPENED"); |
||
65 | TaxiButtonTypes["UNKNOWN"] = { |
||
66 | file = "Interface\\TaxiFrame\\UI-Taxi-Icon-Gray" |
||
67 | }; |
||
68 | end |
||
69 | |||
70 | function FlightMapTaxiFrame_OnEvent(event) |
||
71 | -- Hide any unused lines left over from a previous flight master visit |
||
72 | for i = 1, FLIGHTMAP_MAX_TAXIPATHS, 1 do |
||
73 | getglobal("FlightMapTaxiPath" .. i):Hide(); |
||
74 | end |
||
75 | |||
76 | -- Hide any unused icons too |
||
77 | for i = 1, FLIGHTMAP_MAX_TAXINODES, 1 do |
||
78 | getglobal("FlightMapTaxiButton" .. i):Hide(); |
||
79 | end |
||
80 | |||
81 | -- If the event isn't "TAXIMAP_OPENED" then this is an |
||
82 | -- anywhere-display map. |
||
83 | local thiscont = event; |
||
84 | if event == "TAXIMAP_OPENED" then |
||
85 | -- Turn the route map back on |
||
86 | TaxiRouteMap:Show(); |
||
87 | -- Turn the continent select off |
||
88 | FlightMapTaxiContinents:Hide(); |
||
89 | -- Check option is on |
||
90 | if not FlightMap.Opts.fullTaxiMap then return; end |
||
91 | thiscont = FlightMapUtil.getContinent(); |
||
92 | end |
||
93 | |||
94 | local map = FlightMapUtil.getFlightMap(); |
||
95 | |||
96 | -- Reset these... |
||
97 | FlightMapTaxiFrame.sourceKey = nil; |
||
98 | FlightMapTaxiFrame.sourceNode = nil; |
||
99 | |||
100 | -- So, NumTaxiNodes() returns a value all the time... |
||
101 | local numNodes = NumTaxiNodes(); |
||
102 | if event ~= "TAXIMAP_OPENED" then |
||
103 | numNodes = 0; |
||
104 | end |
||
105 | |||
106 | -- Build a list of nodes the Blizzard client has dealt with |
||
107 | local shownNodes = {}; |
||
108 | local dontShow = {}; |
||
109 | FlightMapTaxiFrame.Destinations = {}; |
||
110 | for i = 1, numNodes do |
||
111 | local tx, ty = TaxiNodePosition(i); |
||
112 | local node = FlightMapUtil.makeNodeName(thiscont, tx, ty); |
||
113 | shownNodes[node] = true; |
||
114 | if TaxiNodeGetType(i) == "CURRENT" then |
||
115 | FlightMapTaxiFrame.sourceKey = node; |
||
116 | FlightMapTaxiFrame.sourceNode = map[node]; |
||
117 | end |
||
118 | if TaxiNodeGetType(i) == "NONE" then |
||
119 | dontShow[node] = true; |
||
120 | end |
||
121 | FlightMapTaxiFrame.Destinations[node] = i; |
||
122 | end |
||
123 | |||
124 | -- Show the entire flight map as a faint overlay |
||
125 | local seen = {}; |
||
126 | local linenum = 1; |
||
127 | local nodenum = 1; |
||
128 | for key, node in map do |
||
129 | -- If it's on this continent, and hasn't been drawn, fill it in |
||
130 | if not shownNodes[key] and node.Continent == thiscont |
||
131 | and (FlightMap.Opts.showAllInfo or FlightMapUtil.knownNode(key)) then |
||
132 | local button = getglobal("FlightMapTaxiButton" .. nodenum); |
||
133 | if button then |
||
134 | nodenum = nodenum + 1; |
||
135 | button:ClearAllPoints(); |
||
136 | button:SetPoint("CENTER", "TaxiMap", "BOTTOMLEFT", |
||
137 | node.Location.Taxi.x * TAXI_MAP_WIDTH, |
||
138 | node.Location.Taxi.y * TAXI_MAP_HEIGHT); |
||
139 | button.nodeKey = key; |
||
140 | button.node = node; |
||
141 | if FlightMapUtil.knownNode(key) then |
||
142 | button:SetNormalTexture(TaxiButtonTypes["REACHABLE"].file); |
||
143 | else |
||
144 | button:SetNormalTexture(TaxiButtonTypes["UNKNOWN"].file); |
||
145 | end |
||
146 | button:Show(); |
||
147 | end |
||
148 | end |
||
149 | |||
150 | -- Draw all single-hop lines |
||
151 | for k, v in node.Flights do |
||
152 | local tex = getglobal("FlightMapTaxiPath" .. linenum); |
||
153 | if tex and not seen[key .. "-" .. k] |
||
154 | and node.Continent == thiscont and map[k] |
||
155 | and not dontShow[k] and not dontShow[key] |
||
156 | and not (node.Routes and node.Routes[k]) then |
||
157 | linenum = linenum + 1; |
||
158 | seen[key .. "-" .. k] = true; |
||
159 | seen[k .. "-" .. key] = true; |
||
160 | if FlightMap.Opts.showAllInfo |
||
161 | or (FlightMapUtil.knownNode(k) |
||
162 | and FlightMapUtil.knownNode(key)) then |
||
163 | FlightMapUtil.drawLine(TaxiMap, tex, |
||
164 | node.Location.Taxi.x, 1 - node.Location.Taxi.y, |
||
165 | map[k].Location.Taxi.x, 1 - map[k].Location.Taxi.y); |
||
166 | tex:SetAlpha(0.5); |
||
167 | end |
||
168 | end |
||
169 | end |
||
170 | end |
||
171 | end |
||
172 | |||
173 | function FlightMapTaxiContinents_OnLoad() |
||
174 | UIDropDownMenu_Initialize(this, FlightMapTaxiContinents_Initialize); |
||
175 | UIDropDownMenu_SetWidth(130); |
||
176 | end |
||
177 | |||
178 | function FlightMapTaxiContinents_Initialize() |
||
179 | local function init(...) |
||
180 | local info; |
||
181 | for i = 1, arg.n, 1 do |
||
182 | info = { |
||
183 | text = arg[i], |
||
184 | func = FlightMapTaxiContinents_OnClick, |
||
185 | }; |
||
186 | UIDropDownMenu_AddButton(info); |
||
187 | end |
||
188 | end |
||
189 | init(GetMapContinents()); |
||
190 | end |
||
191 | |||
192 | function FlightMapTaxiContinents_OnClick() |
||
193 | UIDropDownMenu_SetSelectedID(FlightMapTaxiContinents, this:GetID()); |
||
194 | FlightMapTaxi_SetContinent(this:GetID()); |
||
195 | end |