<<
path:
root/public/nswa.git/html/nswa_which_dungeon.lua
blob: 58eead9ca3f39c22396d607d8d64031cd713c734
[raw]
[clear marker]
3-- - When in a LFG group, get the ID first via `_, id = C_LFGList.GetActiveEntryInfo()`
4-- - Use the same id in `info = C_LFGList.GetActivityInfoTable(id)`
5-- - Then you have things like `info.name, info.mapID`
10-- TODO: Instead of having multiple frames, just put it in one or two frames and filter by event
11local frame = CreateFrame("Frame", "FrameActivity", UIParent)
12local frame_player = CreateFrame("Frame")
13local frame_lfg = CreateFrame("Frame")
14local frame_group = CreateFrame("Frame")
16local text = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
18local was_in_group = false
19local activity_label_is_moving = true
21local text_label = "init"
23local INSTACE_TYPES_TO_CHECK = {
37local function move_enable()
38 text:SetText("MOVING")
40 frame:EnableMouse(true)
41 frame:SetMovable(true)
44local function move_disable()
49 text:SetText(text_label)
50 frame:EnableMouse(false)
51 frame:SetMovable(false)
54function N.move_activity_label()
55 if activity_label_is_moving then
61 activity_label_is_moving = not activity_label_is_moving
64local function activity_get_try()
65 local active_entry_info = C_LFGList.GetActiveEntryInfo()
66 if active_entry_info == nil then
70 local _, first_id = next(active_entry_info.activity_ids)
71 if first_id == nil then
75 local activity_info = C_LFGList.GetActivityInfoTable(first_id)
76 if activity_info == nil then
80 return activity_info.fullName, activity_info.mapID
83local function activity_get()
88 local function try_once()
91 local name, map_id = activity_get_try()
92 if name ~= nil and map_id ~= nil then
96 if tries < max_tries then
97 C_Timer.After(delay, try_once)
106local function activity_text_update(message)
108 print("activity_text_update: nil")
114 text:SetText(message)
118local function activity_text_destroy()
120 print("activity_text_destroy: nil")
130local function frames_unregister()
131 frame_lfg:UnregisterEvent("LFG_LIST_APPLICATION_STATUS_UPDATED")
134local function lfg_info_get(callback)
135 frame_lfg:RegisterEvent("LFG_LIST_APPLICATION_STATUS_UPDATED")
136 frame_lfg:SetScript("OnEvent", function(self, event, search_result_id)
137 local search_result_data = C_LFGList.GetSearchResultInfo(search_result_id)
138 local activity_ids = search_result_data.activityIDs
140 if not activity_ids then return end
142 local activity_id = activity_ids[1]
143 assert(activity_id, "activity_id")
145 local activity_info = C_LFGList.GetActivityInfoTable(activity_id)
146 local ai = activity_info
147 assert(ai, "activity_info")
149 callback(ai.fullName, ai.mapID)
154local function dispatch_lfg_info(activity_name, map_id)
155 activity_text_update(activity_name)
156 N.portals_info_create(map_id)
163function N.destroy_activity_frame()
164 activity_text_destroy()
165 N.portals_info_destroy()
169function N.init_activity_frame()
173 -- Init hook for activity info
176 LFGListInviteDialog:HookScript("OnShow", function(self)
177 lfg_info_get(function(activity_name, map_id)
178 dispatch_lfg_info(activity_name, map_id)
182 LFGListInviteDialog.DeclineButton:HookScript("OnClick", function(self)
183 N.destroy_activity_frame()
189 frame_player:RegisterEvent("PLAYER_ENTERING_WORLD")
190 frame_group:RegisterEvent("GROUP_ROSTER_UPDATE");
192 frame_player:SetScript("OnEvent", function(self, event, ...)
193 C_Timer.After(1, function()
194 local in_instance, instance_type = IsInInstance()
196 if in_instance and INSTACE_TYPES_TO_CHECK[instance_type] then
197 N.destroy_activity_frame()
202 frame_group:SetScript("OnEvent", function(self, event, ...)
203 C_Timer.After(0.5, function()
204 if not IsInGroup() and not IsInRaid() then
205 N.destroy_activity_frame()
211 -- Save / Restore position of info text
214 frame:SetSize(300, 50)
215 frame:RegisterForDrag("LeftButton")
216 frame:SetClampedToScreen(true)
220 if DB.activity_state.pos.point then
222 DB.activity_state.pos.point,
224 DB.activity_state.pos.relPoint,
225 DB.activity_state.pos.x,
226 DB.activity_state.pos.y
229 frame:SetPoint("CENTER")
232 text:SetFont("Fonts\\FRIZQT__.TTF", 24)
233 text:SetTextColor(0, 1, 0)
234 text:SetPoint("CENTER")
235 text:SetText(text_label)
237 frame:SetScript("OnDragStop", function(self)
238 self:StopMovingOrSizing()
239 local point, _, relPoint, x, y = self:GetPoint()
240 DB.activity_state.pos.point = point
241 DB.activity_state.pos.relPoint = relPoint
242 DB.activity_state.pos.x = x
243 DB.activity_state.pos.y = y
244 -- DevTools_Dump(DB.activity_state)
247 frame:SetScript("OnDragStart", function(self)
251 frame:SetScript("OnEvent", frame.OnEvent)