Repository navigation
Expand file tree
/
Copy pathGuideUI.lua
More file actions
308 lines (288 loc) · 14 KB
/
Copy pathGuideUI.lua
File metadata and controls
308 lines (288 loc) · 14 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
local _, FR = ...
local WHITE = 'Interface\\Buttons\\WHITE8X8'
local WIDTH = 404
local COMPACT_HEIGHT = 38
local PAD = 12
local palette = FR.Theme.colors
local function apply(widget,method,color)
widget[method](widget,unpack(color))
end
local function surface(frame,fill,border)
if border then
frame:SetBackdrop({bgFile=WHITE,edgeFile=WHITE,edgeSize=1,
insets={left=1,right=1,top=1,bottom=1}})
apply(frame,'SetBackdropBorderColor',border)
else
frame:SetBackdrop({bgFile=WHITE})
end
apply(frame,'SetBackdropColor',fill)
end
local function box(parent,x,y,width,height,fill,border)
local frame=CreateFrame('Frame',nil,parent,'BackdropTemplate')
frame:SetSize(width,height)
frame:SetPoint('TOPLEFT',parent,'TOPLEFT',x,-y)
surface(frame,fill,border)
return frame
end
local function text(parent,x,y,width,lineCount,font,color)
local label=parent:CreateFontString(nil,'OVERLAY',font or 'GameFontHighlightSmall')
label:SetPoint('TOPLEFT',parent,'TOPLEFT',x,-y)
label:SetWidth(width)
label:SetHeight(lineCount*(font=='GameFontNormalLarge' and 19 or 14))
label:SetJustifyH('LEFT')
label:SetJustifyV('TOP')
label:SetWordWrap(lineCount>1)
if label.SetMaxLines then label:SetMaxLines(lineCount) end
apply(label,'SetTextColor',color or palette.text)
return label
end
local function buttonStyle(button,state)
local fill=palette.base
local color=button.emphasis and palette.accent or palette.text
local border=button.emphasis and palette.accent or palette.border
if button.selected then
fill=palette.selected
color=palette.class
border=palette.violet
end
if state=='hover' then
fill=button.selected and palette.selectedHover or palette.hover
border=palette.focus
elseif state=='pressed' then fill,border=palette.pressed,palette.focus
elseif state=='disabled' then fill,color,border=palette.disabled,palette.dim,palette.border end
apply(button,'SetBackdropColor',fill)
apply(button.label,'SetTextColor',color)
apply(button,'SetBackdropBorderColor',border)
end
function FR.CreateGuideButton(parent,label,x,y,width,height,click,hint,emphasis)
local button=CreateFrame('Button',nil,parent,'BackdropTemplate')
button:SetSize(width,height)
button:SetPoint('TOPLEFT',parent,'TOPLEFT',x,-y)
button:RegisterForClicks('LeftButtonUp')
surface(button,palette.base,palette.border)
button.label=button:CreateFontString(nil,'OVERLAY','GameFontHighlightSmall')
button.label:SetPoint('TOPLEFT',button,'TOPLEFT',6,-1)
button.label:SetPoint('BOTTOMRIGHT',button,'BOTTOMRIGHT',-6,1)
button.label:SetJustifyH('CENTER')
button.label:SetJustifyV('MIDDLE')
button.label:SetWordWrap(false)
button.SetText=function(self,value) self.label:SetText(value) end
button.GetText=function(self) return self.label:GetText() end
button:SetText(label)
button.emphasis=emphasis
buttonStyle(button)
button:SetScript('OnClick',click)
button:SetScript('OnEnable',function(self) buttonStyle(self) end)
button:SetScript('OnDisable',function(self) buttonStyle(self,'disabled') end)
button:SetScript('OnMouseDown',function(self)
if self:IsEnabled() then buttonStyle(self,'pressed') end
end)
button:SetScript('OnMouseUp',function(self)
if self:IsEnabled() then buttonStyle(self,'hover') end
end)
button:SetScript('OnEnter',function(self)
if self:IsEnabled() then buttonStyle(self,'hover') end
if not hint or not GameTooltip then return end
GameTooltip:SetOwner(self,'ANCHOR_TOP')
GameTooltip:SetText(FR.Theme.Paint('accent',self:GetText() or ''))
local color=palette.muted
GameTooltip:AddLine(hint,color[1],color[2],color[3],true)
GameTooltip:Show()
end)
button:SetScript('OnLeave',function(self)
if self:IsEnabled() then buttonStyle(self) else buttonStyle(self,'disabled') end
if hint and GameTooltip then GameTooltip:Hide() end
end)
button.SetSelected=function(self,selected)
if self.selected==selected then return end
self.selected=selected
buttonStyle(self,not self:IsEnabled() and 'disabled' or nil)
end
return button
end
function FR.StyleItineraryFrame(frame)
surface(frame,palette.background,palette.border)
if frame.title then apply(frame.title,'SetTextColor',palette.accent) end
if frame.empty then apply(frame.empty,'SetTextColor',palette.muted) end
end
function FR.CreateGuidePanel(actions,anchor)
local f=CreateFrame('Frame','AtrivellisSmartRouteGuide',UIParent,'BackdropTemplate')
f:SetSize(WIDTH,338)
f:SetPoint('TOP',UIParent,'CENTER',238,178)
f:SetClampedToScreen(true)
f:SetMovable(true)
f:EnableMouse(true)
surface(f,palette.background,palette.border)
if type(anchor)=='table' and type(anchor[1])=='string' then
f:ClearAllPoints()
local ok=pcall(f.SetPoint,f,anchor[1],UIParent,anchor[2] or anchor[1],anchor[3] or 0,anchor[4] or 0)
if not ok then f:SetPoint('TOP',UIParent,'CENTER',238,178) end
end
local function startMove() f:StartMoving() end
local function stopMove()
f:StopMovingOrSizing()
local point,_,relative,x,y=f:GetPoint(1)
if actions.move and point then actions.move({point,relative,x,y}) end
end
f:RegisterForDrag('LeftButton')
f:SetScript('OnDragStart',startMove)
f:SetScript('OnDragStop',stopMove)
if actions.tick then f:SetScript('OnUpdate',actions.tick) end
f.flightElapsed=0
local function control(label,x,y,width,action,hint,emphasis)
return FR.CreateGuideButton(f,label,x,y,width,25,actions[action],hint,emphasis)
end
f.title=text(f,14,12,238,1,'GameFontNormalLarge',palette.accent)
f.title:SetText(FR.ProductName)
f.version=text(f,262,14,69,1,nil,palette.dim)
f.version:SetText(FR.DisplayVersion)
f.itinerary=control('Route',208,35,52,'itinerary','Browse route stops and restore deferred quests.')
f.advanced={}
f.advanced.class=control('Classes',266,35,actions.map and 72 or 126,'class','Open your class quests and check when a detour fits.')
if actions.map then f.targetMap=control('Map',344,35,48,'map','Open the world map for the selected stop and show its coordinates in chat.') end
f.fold=control('-',338,8,24,'mini','Collapse the guide to a draggable bar.')
f.close=control('×',368,8,24,'close','Hide the guide. Type /asr to reopen it.')
f.mode=text(f,14,40,188,1,nil,palette.accent)
f.xpInfo=text(f,14,56,188,1,nil,palette.muted)
f.xp=CreateFrame('StatusBar',nil,f)
f.xp:SetSize(WIDTH-28,4)
f.xp:SetPoint('TOPLEFT',f,'TOPLEFT',14,-74)
f.xp:SetStatusBarTexture(WHITE)
f.xp:SetStatusBarColor(unpack(palette.accent))
f.xp:SetMinMaxValues(0,1)
f.xp:SetValue(0)
f.xpTrack=box(f,14,74,WIDTH-28,4,palette.border)
f.xpTrack:SetFrameLevel(f:GetFrameLevel() or 0)
f.xp:SetFrameLevel((f:GetFrameLevel() or 0)+1)
f.zone=text(f,14,84,WIDTH-28,1,nil,palette.muted)
f.action=box(f,PAD,102,WIDTH-PAD*2,125,palette.panel,palette.border)
f.accent=box(f.action,0,0,2,125,palette.accent)
f.kind=text(f.action,13,11,actions.journal and 292 or 354,1,nil,palette.accent)
if actions.journal then
f.journal=FR.CreateGuideButton(f.action,'Journal',WIDTH-PAD*2-68,5,56,22,actions.journal,
'Open the accepted quest in the game journal. For a grouped stop, open the first quest.')
f.journal:SetShown(false)
end
f.quest=text(f.action,13,31,354,2,'GameFontNormalLarge')
f.detail=text(f.action,13,73,354,3,nil,palette.muted)
f.reason=text(f.action,13,119,354,2,nil,palette.travel)
f.gear=text(f,14,235,WIDTH-28,2,nil,palette.success)
f.classStatus=text(f,14,235,WIDTH-28,2,nil,palette.class)
f.upcoming=box(f,PAD,235,WIDTH-PAD*2,43,palette.panel,palette.border)
f.next=text(f.upcoming,12,7,WIDTH-48,1,nil,palette.muted)
f.following=text(f.upcoming,12,23,WIDTH-48,1,nil,palette.muted)
f.later=text(f,14,284,WIDTH-28,2,nil,palette.dim)
f.footer=text(f,14,285,WIDTH-28,1,nil,palette.dim)
f.back=control('Back',12,305,46,'back','Preview the previous stop or undo the last skip.')
f.forward=control('Next',64,305,68,'forward','Preview the upcoming stop. The waypoint follows the active stop.')
f.skip=control('Skip',138,305,44,'skip','Set aside this stop for this session. Undo restores the last skip.')
f.recheck=control('Recheck',188,305,84,'recheck','Update the route, leave a preview, or flag a missing quest offer.',true)
f.details=control('Details',278,305,53,'details','Show instructions and coordinates in chat. Use /asr why for the route reason.')
f.more=control('Options',337,305,55,'options','Toggle guide preferences and route actions.')
f.navigation={f.back,f.forward,f.skip,f.recheck,f.details,f.more}
f.optionsBox=box(f,PAD,338,WIDTH-PAD*2,104,palette.panel,palette.border)
local function option(label,x,y,width,action,hint)
return FR.CreateGuideButton(f.optionsBox,label,x,y,width,25,actions[action],hint)
end
f.advanced.restore=option('Restore Steps',8,8,109,'restore','Return skipped stops to the route.')
f.advanced.pin=option('Pin this stop',123,8,109,'pin','Keep this stop active while it remains in your route.')
f.advanced.zone=option('Auto Zone',238,8,109,'zone','Let the guide choose a suitable zone again.')
f.advanced.fp=option('FP Visited',8,39,109,'fp','Acknowledge the flight point after unlocking it in game.')
f.advanced.help=option('Pickup Batches',123,39,109,'help','List nearby quests grouped by pickup location.')
if actions.classRouting then
f.advanced.classRouting=option('Class Tips: ON',238,39,109,'classRouting','Toggle class detours in the leveling route. The Classes tab stays available.')
end
if actions.professions then
f.advanced.sparkles=option('Sparkles: OFF',8,70,109,'sparkles','Toggle native quest-object sparkles when supported by the client.')
f.advanced.groups=option('Routing: Solo',123,70,109,'groups','Toggle Solo or Group. Group uses verified party size and levels and your own quest progress.')
f.advanced.professions=option('Professions: OFF',238,70,109,'professions','Include eligible profession quest detours when enabled.')
else
f.advanced.sparkles=option('Quest Sparkles: OFF',8,70,165,'sparkles','Toggle native quest-object sparkles when supported by the client.')
f.advanced.groups=option('Routing: Solo',179,70,168,'groups','Toggle Solo or Group. Group uses verified party size and levels and your own quest progress.')
end
f.mini=control('Smart Route · Waiting for route',6,6,WIDTH-12,'mini','Click to expand Smart Route or drag to move it.')
f.mini.label:SetJustifyH('LEFT')
f.mini.label:ClearAllPoints()
f.mini.label:SetPoint('TOPLEFT',f.mini,'TOPLEFT',10,-1)
f.mini.label:SetPoint('BOTTOMRIGHT',f.mini,'BOTTOMRIGHT',-30,1)
local expand=text(f.mini,WIDTH-37,5,16,1,nil,palette.accent)
expand:SetText('+')
f.mini:RegisterForDrag('LeftButton')
f.mini:SetScript('OnDragStart',startMove)
f.mini:SetScript('OnDragStop',stopMove)
if actions.miniTick then f.mini:SetScript('OnUpdate',actions.miniTick) end
f.mini.elapsed=0
f.full={f.title,f.version,f.mode,f.xpInfo,f.xpTrack,f.xp,f.zone,f.action,f.itinerary,f.fold,f.close,f.advanced.class,
f.upcoming,f.footer,f.back,f.forward,f.skip,f.recheck,f.details,f.more}
if f.targetMap then f.full[#f.full+1]=f.targetMap end
f.expanded=false
FR.SetGuidePanelLayout(f,false,false)
return f
end
function FR.SetGuidePanelLayout(f,mini,expanded)
f.expanded=expanded==true
f.isMini=mini==true
local reasonOffset=f.hasReason and 31 or 0
local gearOffset=f.hasGear and 32 or 0
local hintOffset=reasonOffset+gearOffset+(f.hasClassStatus and 32 or 0)
local lowerOffset=hintOffset+(f.hasLater and 32 or 0)
f:SetHeight(f.isMini and COMPACT_HEIGHT or (f.expanded and 450 or 338)+lowerOffset)
f.more:SetText(f.expanded and 'Less' or 'Options')
for _,widget in ipairs(f.full) do widget:SetShown(not f.isMini) end
f.action:SetHeight(125+reasonOffset)
f.accent:SetHeight(125+reasonOffset)
f.reason:SetShown(f.hasReason==true)
f.gear:SetShown(not f.isMini and f.hasGear==true)
f.classStatus:SetShown(not f.isMini and f.hasClassStatus==true)
f.later:SetShown(not f.isMini and f.hasLater==true)
f.optionsBox:SetShown(not f.isMini and f.expanded)
f.mini:SetShown(f.isMini)
f.upcoming:ClearAllPoints()
f.upcoming:SetPoint('TOPLEFT',f,'TOPLEFT',PAD,-235-hintOffset)
f.gear:ClearAllPoints()
f.gear:SetPoint('TOPLEFT',f,'TOPLEFT',14,-235-reasonOffset)
f.classStatus:ClearAllPoints()
f.classStatus:SetPoint('TOPLEFT',f,'TOPLEFT',14,-235-reasonOffset-gearOffset)
f.later:ClearAllPoints()
f.later:SetPoint('TOPLEFT',f,'TOPLEFT',14,-284-hintOffset)
f.footer:ClearAllPoints()
f.footer:SetPoint('TOPLEFT',f,'TOPLEFT',14,-285-lowerOffset)
local lefts={12,64,138,188,278,337}
for i,button in ipairs(f.navigation) do
button:ClearAllPoints()
button:SetPoint('TOPLEFT',f,'TOPLEFT',lefts[i],-305-lowerOffset)
end
f.optionsBox:ClearAllPoints()
f.optionsBox:SetPoint('TOPLEFT',f,'TOPLEFT',PAD,-338-lowerOffset)
end
function FR.StyleGuidePanel(f,state)
local color=state.preview and palette.travel or ((state.classMode or state.classStep) and palette.class) or
palette[FR.Theme.StepColor[state.kind]] or palette.accent
local stripe=(state.preview or state.kind=='travel' or state.kind=='flight') and palette.cobalt or color
apply(f.accent,'SetBackdropColor',stripe)
apply(f.kind,'SetTextColor',color)
apply(f.quest,'SetTextColor',palette.text)
f.advanced.class:SetSelected(state.classMode==true)
local timing=state.classStatus or ''
f.classStatus:SetText(timing)
local gear,later=state.gear or '',state.later or ''
local reason=state.reason or ''
f.reason:SetText(reason)
f.gear:SetText(gear)
f.later:SetText(later)
local hasClassStatus=timing~=''
local hasGear,hasLater=gear~='',later~=''
local hasReason=reason~=''
if f.hasClassStatus~=hasClassStatus or f.hasGear~=hasGear or f.hasLater~=hasLater or f.hasReason~=hasReason then
f.hasClassStatus=hasClassStatus
f.hasGear,f.hasLater=hasGear,hasLater
f.hasReason=hasReason
FR.SetGuidePanelLayout(f,f.isMini,f.expanded)
end
if type(state.xpFraction)=='number' then
f.xp:SetValue(math.max(0,math.min(1,state.xpFraction)))
end
if f.advanced.classRouting and state.classRouting~=nil then
f.advanced.classRouting:SetText(state.classRouting and 'Class Tips: ON' or 'Class Tips: OFF')
end
end