-
Notifications
You must be signed in to change notification settings - Fork 8
/
quick.lua
119 lines (117 loc) · 3.01 KB
/
quick.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
local me, ns = ...
ns.Configure()
local addon=addon --#addon
local _G=_G
local GMF=GMF
local GSF=GSF
local qm=addon:NewSubModule("Quick") --#qm
local format=format
local ipairs=ipairs
local NavalDomination={
Alliance=39068,
Horde=39246
}
local questid=NavalDomination[UnitFactionGroup("player")]
function qm:OnInitialized()
ns.step="none"
end
local watchdog=0
local function HasShipTable()
return ns.quests[39068] or ns.quests[39246] -- Naval Domination
end
-- backported from LibInit 41
function addon:Popup(msg,timeout,OnAccept,OnCancel,data,StopCasting)
if InCombatLockdown() then
return self:ScheduleLeaveCombatAction("Popup",msg,timeout,OnAccept,OnCancel,data,StopCasting)
end
msg=msg or "Something strange happened"
if type(timeout)=="function" then
StopCasting=data
data=OnCancel
OnAccept=timeout
timeout=60
end
StaticPopupDialogs["LIBINIT_POPUP"] = StaticPopupDialogs["LIBINIT_POPUP"] or
{
text = msg,
showAlert = true,
timeout = timeout or 60,
exclusive = true,
whileDead = true,
interruptCinematic = true
};
local popup=StaticPopupDialogs["LIBINIT_POPUP"]
if StopCasting then
popup.OnShow=StopSpellCasting
popup.OnHide=StopSpellCastingCleanup
else
popup.OnShow=nil
popup.OnHide=nil
end
popup.timeout=timeout
popup.text=msg
popup.OnCancel=nil
popup.OnAccept=OnAccept
popup.button1=ACCEPT
popup.button2=nil
if (OnCancel) then
if (type(OnCancel)=="function") then
popup.OnCancel=OnCancel
end
popup.button2=CANCEL
else
popup.button1=OKAY
end
return StaticPopup_Show("LIBINIT_POPUP",timeout,SECONDS,data);
end
function addon:LogoutTimer(dialog,elapsed)
if dialog.which ~="LIBINIT_POPUP" then return end
local text = _G[dialog:GetName().."Text"];
local timeleft = ceil(dialog.timeleft);
local which=dialog.which
if ( timeleft < 60 ) then
text:SetFormattedText(StaticPopupDialogs[which].text, timeleft, SECONDS);
else
text:SetFormattedText(StaticPopupDialogs[which].text, ceil(timeleft / 60), MINUTES);
end
end
function qm:RunQuick()
local completeButton=GMF:IsVisible() and GarrisonCommanderQuickMissionComplete or GCQuickShipMissionCompletionButton
local main=GMF:IsVisible() and GMF or GSF
if not ns.quick then
HideUIPanel(main)
return
end
while not qm.Mission do
if completeButton and completeButton:IsVisible() then
completeButton:Click()
return -- Waits to be rescheduled by mission completion
end
if not main.MissionControlTab:IsVisible() then
if main.tabMC then main.tabMC:Click() end
break
end
if (main.MissionControlTab.runButton:IsEnabled()) then
main.MissionControlTab.runButton:Click()
end
break -- Never loop or we get stuck
end
watchdog=watchdog+1
if watchdog > 10 then
ns.quick=false
end
if ns.quick then
return addon.ScheduleTimer(qm,"RunQuick",1)
end
end
function addon:RunQuick(force)
local main=GMF:IsVisible() and GMF or GSF
if main.tabMC and main.tabMC:GetChecked() then
--self:OpenMissionControlTab()
self:ScheduleTimer("RunQuick",0.2)
return
end
ns.quick=true
qm.watchdog=0
return addon.ScheduleTimer(qm,"RunQuick",0.2)
end