Repository navigation
Expand file tree
/
Copy pathConfig.lua
More file actions
393 lines (367 loc) · 12.7 KB
/
Copy pathConfig.lua
File metadata and controls
393 lines (367 loc) · 12.7 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
FlightsimConfig = FlightsimConfig or {}
local abilitySettings = {
["Surge Forward"] = "showSurgeForward",
["Second Wind"] = "showSecondWind",
["Whirling Surge"] = "showWhirlingSurge",
}
local function GetAbilityOrder(db)
return FlightsimLogic.Visibility.GetAbilityOrder(db.profile.abilities and db.profile.abilities.order)
end
local function ListAbilities(db)
for i, token in ipairs(GetAbilityOrder(db)) do
local enabled = db.profile.abilityBars[abilitySettings[token]] ~= false
print(string.format(" %d. %s [%s]", i, token, enabled and "ON" or "OFF"))
end
end
local function IsFinite(value)
return value and value == value and value > -math.huge and value < math.huge
end
--- Create a button helper
local function CreateToolButton(parent, x, y, width, text, onClick)
local btn = CreateFrame("Button", nil, parent, "UIPanelButtonTemplate")
btn:SetPoint("TOPLEFT", parent, "TOPLEFT", x, y)
btn:SetSize(width, 24)
btn:SetText(text)
btn:SetScript("OnClick", onClick)
return btn
end
--- Create the Tools panel for Mechanic integration
function FlightsimConfig:CreateToolsPanel(container)
local title = container:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 10, -10)
title:SetText("Flightsim Tools")
local desc = container:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
desc:SetPoint("TOPLEFT", 10, -35)
desc:SetText("Quick actions for the Flightsim HUD.")
-- Row 1: Position & Lock
local row1Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row1Label:SetPoint("TOPLEFT", 10, -65)
row1Label:SetText("Position:")
CreateToolButton(container, 80, -60, 100, "Reset", function()
local db = Flightsim.db
if db and db.profile then
db.profile.x = 0
db.profile.y = 0
db.profile.scale = 1
-- Update View layer
if FlightsimView and FlightsimView.container then
FlightsimView.container:ClearAllPoints()
FlightsimView.container:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
FlightsimView:SetScale(1)
end
print("|cff00ff00Flightsim:|r Position reset to center.")
end
end)
CreateToolButton(container, 185, -60, 80, "Lock", function()
local db = Flightsim.db
if db and db.profile then
db.profile.locked = true
if FlightsimView and FlightsimView.SetClickThrough then
FlightsimView:SetClickThrough(true)
end
print("|cff00ff00Flightsim:|r HUD locked.")
end
end)
CreateToolButton(container, 270, -60, 80, "Unlock", function()
local db = Flightsim.db
if db and db.profile then
db.profile.locked = false
if FlightsimView and FlightsimView.SetClickThrough then
FlightsimView:SetClickThrough(false)
end
print("|cff00ff00Flightsim:|r HUD unlocked. Drag to reposition.")
end
end)
-- Row 2: Visibility
local row2Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row2Label:SetPoint("TOPLEFT", 10, -100)
row2Label:SetText("Visibility:")
CreateToolButton(container, 80, -95, 100, "Show Always", function()
local db = Flightsim.db
if db and db.profile and db.profile.visibility then
db.profile.visibility.hideWhenNotSkyriding = false
if FlightsimView and FlightsimView.ApplyVisibility then
FlightsimView:ApplyVisibility()
end
print("|cff00ff00Flightsim:|r Always visible.")
end
end)
CreateToolButton(container, 185, -95, 100, "Sky Only", function()
local db = Flightsim.db
if db and db.profile and db.profile.visibility then
db.profile.visibility.hideWhenNotSkyriding = true
if FlightsimView and FlightsimView.ApplyVisibility then
FlightsimView:ApplyVisibility()
end
print("|cff00ff00Flightsim:|r Visible only while Skyriding.")
end
end)
CreateToolButton(container, 290, -95, 100, "Force Show", function()
-- Temporarily show the HUD for testing (forces container visible)
if FlightsimView and FlightsimView.container then
FlightsimView.container:Show()
print("|cff00ff00Flightsim:|r HUD forced visible (until next update cycle).")
end
end)
-- Row 3: Debug
local row3Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row3Label:SetPoint("TOPLEFT", 10, -135)
row3Label:SetText("Debug:")
CreateToolButton(container, 80, -130, 100, "Toggle Debug", function()
local db = Flightsim.db
if db and db.profile then
db.profile.debugMode = not db.profile.debugMode
Flightsim.debugMode = db.profile.debugMode
print("|cff00ff00Flightsim:|r Debug mode " .. (Flightsim.debugMode and "ON" or "OFF"))
end
end)
CreateToolButton(container, 185, -130, 80, "Status", function()
local db = Flightsim.db
if db and db.profile then
print("|cff00ff00Flightsim Status:|r")
print(" Locked: " .. tostring(db.profile.locked))
print(" Scale: " .. tostring(db.profile.scale))
print(" Position: " .. tostring(db.profile.x) .. ", " .. tostring(db.profile.y))
print(" Hide when not skyriding: " .. tostring(db.profile.visibility.hideWhenNotSkyriding))
print(" Debug: " .. tostring(db.profile.debugMode))
if FlightsimView then
print(" View container: " .. (FlightsimView.container and "OK" or "nil"))
print(
" View visible: "
.. (FlightsimView.container and FlightsimView.container:IsShown() and "Yes" or "No")
)
end
end
end)
-- Row 4: Abilities
local row4Label = container:CreateFontString(nil, "OVERLAY", "GameFontNormal")
row4Label:SetPoint("TOPLEFT", 10, -170)
row4Label:SetText("Abilities:")
CreateToolButton(container, 80, -165, 100, "List All", function()
local db = Flightsim.db
if db and db.profile and db.profile.abilityBars then
print("|cff00ff00Flightsim:|r Ability bars:")
ListAbilities(db)
end
end)
-- Footer
local footer = container:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
footer:SetPoint("BOTTOM", 0, 10)
footer:SetText("Use /flightsim for more options.")
end
--- Legacy alias for backwards compatibility
function FlightsimConfig:CreateCompliancePanel(container)
self:CreateToolsPanel(container)
end
-- AceConsole owns both aliases; registering them twice makes dispatch ambiguous.
function Flightsim.HandleSlashCommand(msg)
local L = Flightsim.L
local db = Flightsim.db
msg = (msg or ""):lower():gsub("^%s+", ""):gsub("%s+$", "")
if not db or not db.profile then
print(L["NOT_INITIALIZED_YET"])
return
end
if msg == "lock" then
db.profile.locked = true
if FlightsimView and FlightsimView.SetClickThrough then
FlightsimView:SetClickThrough(true)
end
print(L["LOCKED"])
return
elseif msg == "unlock" then
db.profile.locked = false
if FlightsimView and FlightsimView.SetClickThrough then
FlightsimView:SetClickThrough(false)
end
print(L["UNLOCKED"])
return
elseif msg:match("^scale%s+") then
local val = tonumber(msg:match("^scale%s+([%d%.]+)$"))
if not IsFinite(val) then
print(L["USAGE_SCALE"])
return
end
val = math.max(0.5, math.min(2, val))
db.profile.scale = val
if FlightsimView and FlightsimView.SetScale then
FlightsimView:SetScale(val)
end
print(L["SCALE_SET"])
return
elseif msg:match("^width%s+") then
local val = tonumber(msg:match("^width%s+([%d%.]+)$"))
if not IsFinite(val) then
print(L["USAGE_WIDTH"])
return
end
val = math.max(50, math.min(800, val))
db.profile.ui.width = val
if FlightsimView and FlightsimView.SetWidth then
FlightsimView:SetWidth(val)
end
print(L["WIDTH_SET"])
return
elseif msg:match("^barmax%s+") then
local val = tonumber(msg:match("^barmax%s+([%d%.]+)$"))
if not IsFinite(val) or val <= 0 then
print(L["USAGE_BARMAX"])
return
end
db.profile.speedBar.maxSpeed = val
print(L["BARMAX_SET"])
return
elseif msg:match("^sustainable%s+") or msg:match("^optimal%s+") then
if msg:match("^sustainable%s+auto$") or msg:match("^optimal%s+auto$") then
db.profile.speedBar.useCustomSustainableSpeed = false
print(L["SUSTAINABLE_SET"])
return
end
local val = tonumber(msg:match("^sustainable%s+([%d%.]+)$") or msg:match("^optimal%s+([%d%.]+)$"))
if not IsFinite(val) or val < 0 then
print(L["USAGE_SUSTAINABLE"])
return
end
db.profile.speedBar.sustainableSpeed = val
db.profile.speedBar.useCustomSustainableSpeed = true
print(L["SUSTAINABLE_SET"])
return
elseif msg == "hidenot" then
db.profile.visibility.hideWhenNotSkyriding = true
if FlightsimView and FlightsimView.ApplyVisibility then
FlightsimView:ApplyVisibility()
end
print(L["HIDE_NOT_SKYRIDING"])
return
elseif msg == "hidesky" then
-- Note: hideWhileSkyriding is a legacy setting, keeping for backwards compatibility
db.profile.visibility.hideWhenNotSkyriding = false
if FlightsimView and FlightsimView.ApplyVisibility then
FlightsimView:ApplyVisibility()
end
print(L["SHOW_ALWAYS"])
return
elseif msg == "showalways" then
db.profile.visibility.hideWhenNotSkyriding = false
if FlightsimView and FlightsimView.ApplyVisibility then
FlightsimView:ApplyVisibility()
end
print(L["SHOW_ALWAYS"])
return
elseif msg:match("^toggle%s+") then
local query = msg:match("^toggle%s+(.+)$")
local found
for _, token in ipairs(GetAbilityOrder(db)) do
if token:lower():find(query, 1, true) then
local key = abilitySettings[token]
local enabled = db.profile.abilityBars[key] ~= false
db.profile.abilityBars[key] = not enabled
if FlightsimView and FlightsimView.ApplyVisibility then
FlightsimView:ApplyVisibility()
end
print(string.format(L["ABILITY_TOGGLED"], token, (not enabled) and "enabled" or "disabled"))
found = true
break
end
end
if not found then
print(L["ABILITY_NOT_FOUND"])
end
return
elseif msg == "list" then
print(L["ABILITIES_LIST"])
ListAbilities(db)
return
elseif msg:match("^move%s+") then
local a, b = msg:match("^move%s+(.+)%s+(%d+)$")
local newIndex = tonumber(b)
if not (a and newIndex) then
print(L["USAGE_MOVE"])
return
end
local order = GetAbilityOrder(db)
local fromIndex
for i, token in ipairs(order) do
if token:lower():find(a, 1, true) then
fromIndex = i
break
end
end
if not fromIndex then
print(L["ABILITY_NOT_FOUND"])
return
end
newIndex = math.max(1, math.min(#order, newIndex))
local item = table.remove(order, fromIndex)
table.insert(order, newIndex, item)
db.profile.abilities.order = order
if FlightsimView and FlightsimView.RebuildLayout then
FlightsimView:RebuildLayout()
end
print(L["ORDER_UPDATED"])
return
elseif msg == "debug" then
db.profile.debugMode = not db.profile.debugMode
Flightsim.debugMode = db.profile.debugMode
print("Flightsim debug mode:", Flightsim.debugMode and "ON" or "OFF")
return
elseif msg == "status" then
print("|cff00ff00Flightsim Status:|r")
print(" Locked: " .. tostring(db.profile.locked))
print(" Scale: " .. tostring(db.profile.scale))
print(" Position: " .. tostring(db.profile.x) .. ", " .. tostring(db.profile.y))
print(" Hide when not skyriding: " .. tostring(db.profile.visibility.hideWhenNotSkyriding))
print(" Debug: " .. tostring(db.profile.debugMode))
if FlightsimView then
print(" View container: " .. (FlightsimView.container and "OK" or "nil"))
print(
" View visible: " .. (FlightsimView.container and FlightsimView.container:IsShown() and "Yes" or "No")
)
end
return
elseif msg == "pos" then
-- Detailed position debugging
local profile = db:GetCurrentProfile()
print("|cff00ff00Flightsim Position Debug:|r")
print(" Current profile: " .. tostring(profile))
print(" db.profile.x: " .. tostring(db.profile.x))
print(" db.profile.y: " .. tostring(db.profile.y))
if FlightsimDB and FlightsimDB.profiles and FlightsimDB.profiles[profile] then
local raw = FlightsimDB.profiles[profile]
print(" RAW profiles[" .. profile .. "].x: " .. tostring(raw.x))
print(" RAW profiles[" .. profile .. "].y: " .. tostring(raw.y))
else
print(" RAW profiles[" .. profile .. "]: NOT FOUND")
end
if FlightsimView and FlightsimView.container then
local _, _, _, actualX, actualY = FlightsimView.container:GetPoint(1)
print(" Actual frame pos: x=" .. tostring(actualX) .. ", y=" .. tostring(actualY))
end
return
elseif msg == "reset" then
db.profile.x = 0
db.profile.y = 0
db.profile.scale = 1
if FlightsimView and FlightsimView.container then
FlightsimView.container:ClearAllPoints()
FlightsimView.container:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
FlightsimView:SetScale(1)
end
print(L["RESET_DONE"])
return
end
print(L["COMMANDS_HELP"])
print(" /flightsim lock")
print(" /flightsim unlock")
print(" /flightsim scale <number>")
print(" /flightsim width <number>")
print(" /flightsim barmax <number>")
print(" /flightsim sustainable <number|auto> (0 hides marker)")
print(" /flightsim hidenot | showalways")
print(" /flightsim list")
print(" /flightsim toggle <ability>")
print(" /flightsim move <ability> <index>")
print(" /flightsim status")
print(" /flightsim debug")
print(" /flightsim reset")
end