-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.lua
More file actions
executable file
·714 lines (604 loc) · 23.6 KB
/
Copy pathUI.lua
File metadata and controls
executable file
·714 lines (604 loc) · 23.6 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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
-- UI.lua
local addonName, Ironman = ...
function Ironman:OpenUI()
if Ironman.UI then
Ironman.UI:Show()
if Ironman.ShowTab then
Ironman:ShowTab("status")
end
return
end
-------------------------------------------------
-- Check if ineligible
-------------------------------------------------
if IronmanModeDB and IronmanModeDB.disabledDueToEligibility then
print("|cffff0000[Ironman]|r You are ineligible to use Ironman Mode on this character.")
print("|cffff0000[Ironman]|r Ironman Mode has been disabled for this character.")
print("|cffff0000[Ironman]|r You may create a new character to use Ironman Mode.")
return
end
-------------------------------------------------
-- Main Frame
-------------------------------------------------
local frame = CreateFrame("Frame", "IronmanUIFrame", UIParent, "BasicFrameTemplateWithInset")
frame:SetSize(650, 520)
frame:SetPoint("CENTER")
frame:SetFrameStrata("FULLSCREEN_DIALOG") -- Highest non-tooltip layer
frame:SetFrameLevel(1000) -- Very high within that strata
frame:SetMovable(true)
frame:EnableMouse(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
-- Make ESC key close the frame
frame:SetScript("OnHide", function(self)
if self.isClosing then return end
end)
-- Register for ESC key
table.insert(UISpecialFrames, "IronmanUIFrame")
frame.title = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
frame.title:SetPoint("TOP", 0, -8)
frame.title:SetText("Ironman Mode")
-- Logo
local logo = frame:CreateTexture(nil, "ARTWORK")
logo:SetSize(64, 64)
logo:SetPoint("TOP", 0, -35)
logo:SetTexture("Interface\\AddOns\\IronmanMode\\Ironman_Mode_logo.png")
-------------------------------------------------
-- Tabs
-------------------------------------------------
local tabs = {}
local selectedTab = nil
local function CreateTab(id, text, tabKey)
local tab = CreateFrame("Button", "IronmanTab"..id, frame, "PanelTabButtonTemplate")
tab:SetID(id)
tab.tabKey = tabKey
-- Get font string before setting text
local fontString = tab:GetFontString()
-- Set text
tab:SetText(text)
-- Measure text width and set tab width accordingly
if fontString then
local textWidth = fontString:GetStringWidth()
local padding = 54 -- Standard padding for PanelTabButtonTemplate
tab:SetWidth(textWidth + padding)
-- Make sure text region is wide enough
fontString:SetWidth(textWidth + 40)
end
tab:SetScript("OnClick", function(self)
Ironman:ShowTab(self.tabKey)
end)
return tab
end
-- Helper to update tab selection visuals
local function SelectTab(tab)
for i, t in ipairs(tabs) do
if t == tab then
PanelTemplates_SelectTab(t)
selectedTab = t
else
PanelTemplates_DeselectTab(t)
end
end
end
tabs[1] = CreateTab(1, "Status", "status")
tabs[2] = CreateTab(2, "Rules", "rules")
tabs[3] = CreateTab(3, "Achievements", "achievements")
tabs[4] = CreateTab(4, "Violations", "violations")
tabs[5] = CreateTab(5, "Settings", "settings")
-- Position tabs along the bottom
tabs[1]:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 5, 2)
for i = 2, #tabs do
tabs[i]:SetPoint("LEFT", tabs[i-1], "RIGHT", 4, 0)
end
-------------------------------------------------
-- Status Tab
-------------------------------------------------
local statusPanel = CreateFrame("Frame", nil, frame)
statusPanel:SetSize(610, 440)
statusPanel:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -30)
statusPanel:SetFrameLevel(frame:GetFrameLevel() + 1)
-- Status display elements
local statusY = -110
local statusSpacing = -30
local turnedOffLabel = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
turnedOffLabel:SetPoint("TOPLEFT", 20, statusY)
turnedOffLabel:SetText("Has Been Turned Off:")
local turnedOffValue = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
turnedOffValue:SetPoint("LEFT", turnedOffLabel, "RIGHT", 10, 0)
statusY = statusY + statusSpacing
local clearedLabel = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
clearedLabel:SetPoint("TOPLEFT", 20, statusY)
clearedLabel:SetText("Has Been Cleared:")
local clearedValue = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
clearedValue:SetPoint("LEFT", clearedLabel, "RIGHT", 10, 0)
statusY = statusY + statusSpacing
local violationCountLabel = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
violationCountLabel:SetPoint("TOPLEFT", 20, statusY)
violationCountLabel:SetText("Total Violations:")
local violationCountValue = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
violationCountValue:SetPoint("LEFT", violationCountLabel, "RIGHT", 10, 0)
statusY = statusY + statusSpacing
local validityLabel = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
validityLabel:SetPoint("TOPLEFT", 20, statusY)
validityLabel:SetText("Iron Man Validity:")
local validityValue = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
validityValue:SetPoint("LEFT", validityLabel, "RIGHT", 10, 0)
statusY = statusY + statusSpacing
local ironmanScoreLabel = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
ironmanScoreLabel:SetPoint("TOPLEFT", 20, statusY)
ironmanScoreLabel:SetText("Iron Man Score:")
local ironmanScoreValue = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
ironmanScoreValue:SetPoint("LEFT", ironmanScoreLabel, "RIGHT", 10, 0)
statusY = statusY + statusSpacing
local hardcoreScoreLabel = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontNormal")
hardcoreScoreLabel:SetPoint("TOPLEFT", 20, statusY)
hardcoreScoreLabel:SetText("Hardcore Score:")
local hardcoreScoreValue = statusPanel:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
hardcoreScoreValue:SetPoint("LEFT", hardcoreScoreLabel, "RIGHT", 10, 0)
-------------------------------------------------
local function RefreshStatus()
-- Get data from DB
local hasBeenTurnedOff = IronmanModeDB.hasBeenTurnedOff or false
local hasBeenCleared = IronmanModeDB.hasBeenCleared or false
local violations = IronmanModeDB.violations or {}
local violationCount = #violations
-- Calculate validity using the centralized method
local validity = Ironman:CalculateValidity()
-- Determine validity text and color
local validityColor = {1, 0, 0}
local validityText = "Invalid"
if hasBeenCleared or hasBeenTurnedOff then
validityText = "Invalid (Flagged)"
validityColor = {1, 0, 0}
elseif validity >= 90 then
validityText = string.format("Excellent (%.2f)", validity)
validityColor = {0, 1, 0}
elseif validity >= 70 then
validityText = string.format("Good (%.2f)", validity)
validityColor = {0.5, 1, 0}
elseif validity >= 50 then
validityText = string.format("Fair (%.2f)", validity)
validityColor = {1, 1, 0}
elseif validity >= 25 then
validityText = string.format("Poor (%.2f)", validity)
validityColor = {1, 0.5, 0}
elseif validity > 0 then
validityText = string.format("Very Poor (%.2f)", validity)
validityColor = {1, 0, 0}
else
validityText = "Invalid (0.00)"
validityColor = {1, 0, 0}
end
-- Save validity to database
IronmanModeDB.validity = validity
turnedOffValue:SetText(hasBeenTurnedOff and "Yes" or "No")
turnedOffValue:SetTextColor(hasBeenTurnedOff and 1 or 0, hasBeenTurnedOff and 0 or 1, 0)
clearedValue:SetText(hasBeenCleared and "Yes" or "No")
clearedValue:SetTextColor(hasBeenCleared and 1 or 0, hasBeenCleared and 0 or 1, 0)
violationCountValue:SetText(tostring(violationCount))
violationCountValue:SetTextColor(violationCount > 0 and 1 or 0, violationCount == 0 and 1 or 0, 0)
validityValue:SetText(validityText)
validityValue:SetTextColor(validityColor[1], validityColor[2], validityColor[3])
-- Iron Man Score
local ironmanScore = IronmanModeDB.normalScore or 0
local hardcoreScore = IronmanModeDB.hardcoreScore or 0
if IronmanModeDB.doHardcoreTurnedOffOnStart == true then
ironmanScoreValue:SetText(string.format("%d", ironmanScore))
ironmanScoreValue:SetTextColor(1, 1, 1)
elseif IronmanModeDB.doHardcoreTurnedOff == true then
-- Show both scores if hardcore was turned off, but hardcore score is frozen
ironmanScoreValue:SetText(string.format("%d", ironmanScore))
ironmanScoreValue:SetTextColor(1, 1, 1) -- Orange tint
hardcoreScoreValue:SetText(string.format("%d (Frozen)", hardcoreScore))
hardcoreScoreValue:SetTextColor(1, 1, 0.5)
else
-- Show only hardcore score if in hardcore mode
ironmanScoreValue:SetText(tostring(ironmanScore))
ironmanScoreValue:SetTextColor(1, 1, 1)
hardcoreScoreValue:SetText(string.format("%d", hardcoreScore))
hardcoreScoreValue:SetTextColor(1, 1, 1)
end
end
-------------------------------------------------
-- Rules Tab
-------------------------------------------------
local rulesPanel = CreateFrame("Frame", nil, frame)
rulesPanel:SetSize(610, 440)
rulesPanel:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -30)
rulesPanel:SetFrameLevel(frame:GetFrameLevel() + 1)
-- Temporary storage for rule changes
local tempRules = {}
-- Forward declare RefreshRules so it can be used by both OK button and ShowTab
local RefreshRules
local function CreateCheckbox(parent, label, ruleKey, offsetY)
local rule = IronmanModeDB.rules[ruleKey]
if not rule then
return nil
end
local cb = CreateFrame("CheckButton", nil, parent, "UICheckButtonTemplate")
cb:SetPoint("TOPLEFT", 20, offsetY)
cb.text = cb:CreateFontString(nil, "OVERLAY", "GameFontNormal")
cb.text:SetPoint("LEFT", cb, "RIGHT", 5, 0)
cb.text:SetText(label)
cb.ruleKey = ruleKey
-- Handle both old boolean format and new object format
local isEnabled = false
if type(rule) == "table" then
isEnabled = rule.enabled
else
isEnabled = rule
end
cb:SetChecked(isEnabled)
tempRules[ruleKey] = isEnabled
cb:SetScript("OnClick", function(self)
tempRules[ruleKey] = self:GetChecked()
end)
return cb
end
local y = -110
local spacing = -35
rulesPanel.checks = {}
rulesPanel.checks.noTrade = CreateCheckbox(rulesPanel, "No Trading", "noTrade", y)
if IronmanModeDB.rules["noTrade"] then
y = y + spacing
end
rulesPanel.checks.noGuild = CreateCheckbox(rulesPanel, "No Guilds", "noGuild", y)
if IronmanModeDB.rules["noGuild"] then
y = y + spacing
end
rulesPanel.checks.noParty = CreateCheckbox(rulesPanel, "No Parties", "noParty", y)
if IronmanModeDB.rules["noParty"] then
y = y + spacing
end
rulesPanel.checks.noMail = CreateCheckbox(rulesPanel, "No Mail", "noMail", y)
if IronmanModeDB.rules["noMail"] then
y = y + spacing
end
rulesPanel.checks.noAH = CreateCheckbox(rulesPanel, "No Auction House", "noAH", y)
-- Define RefreshRules function before OK button uses it
RefreshRules = function()
for _, cb in pairs(rulesPanel.checks) do
if cb and IronmanModeDB and IronmanModeDB.rules and cb.ruleKey then
local rule = IronmanModeDB.rules[cb.ruleKey]
local isEnabled = false
if type(rule) == "table" then
isEnabled = rule.enabled
else
isEnabled = rule
end
cb:SetChecked(isEnabled)
tempRules[cb.ruleKey] = isEnabled
-- Disable checkbox and mark with red text if rule is disabled
if not isEnabled then
cb:Disable()
-- Get the original label text and add DISABLED tag in red
local ruleName = ""
if type(rule) == "table" and rule.name then
ruleName = rule.name
else
ruleName = cb.text:GetText():gsub(" %[DISABLED%]", "") -- Remove existing tag
end
cb.text:SetText(ruleName .. " |cffff0000[DISABLED]|r")
else
-- Make sure text is normal color if enabled
local ruleName = ""
if type(rule) == "table" and rule.name then
ruleName = rule.name
else
ruleName = cb.text:GetText():gsub(" %[DISABLED%]", "")
end
cb.text:SetText(ruleName)
end
end
end
end
-- OK Button
local okBtn = CreateFrame("Button", nil, rulesPanel, "UIPanelButtonTemplate")
okBtn:SetSize(100, 24)
okBtn:SetPoint("BOTTOM", 0, 15)
okBtn:SetText("OK")
okBtn:SetScript("OnClick", function()
for ruleKey, value in pairs(tempRules) do
local rule = IronmanModeDB.rules[ruleKey]
if type(rule) == "table" then
IronmanModeDB.rules[ruleKey].enabled = value
else
IronmanModeDB.rules[ruleKey] = value
end
end
-- Recalculate validity after rule changes
IronmanModeDB.validity = Ironman:CalculateValidity()
print("|cffff0000[Ironman]|r Rules saved. Validity: " .. string.format("%.2f%%", IronmanModeDB.validity))
-- Refresh rules to update checkbox states and disable unchecked ones
RefreshRules()
-- Refresh both status and rules displays
if Ironman.RefreshStatus then
Ironman:RefreshStatus()
end
end)
-------------------------------------------------
-- Achievements Tab
-------------------------------------------------
local achievementsPanel = CreateFrame("Frame", nil, frame)
achievementsPanel:SetSize(610, 440)
achievementsPanel:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -30)
achievementsPanel:SetFrameLevel(frame:GetFrameLevel() + 1)
local achieveScrollFrame = CreateFrame("ScrollFrame", "IronmanAchievementsScroll", achievementsPanel, "UIPanelScrollFrameTemplate")
achieveScrollFrame:SetSize(590, 330)
achieveScrollFrame:SetPoint("TOPLEFT", 20, -110)
local achieveContent = CreateFrame("Frame", nil, achieveScrollFrame)
achieveContent:SetSize(570, 1)
achieveScrollFrame:SetScrollChild(achieveContent)
local achieveFontStrings = {}
local function RefreshAchievements()
for _, fs in ipairs(achieveFontStrings) do
fs:Hide()
end
local data = IronmanModeDB.achievements or {}
local yOff = -5
if #data == 0 then
if not achieveFontStrings[1] then
achieveFontStrings[1] = achieveContent:CreateFontString(nil, "ARTWORK", "GameFontNormal")
end
achieveFontStrings[1]:SetPoint("TOPLEFT", 0, yOff)
achieveFontStrings[1]:SetText("No achievements earned yet. Get out there!")
achieveFontStrings[1]:Show()
achieveContent:SetHeight(20)
return
end
-- Sort by time (most recent first)
local sortedData = {}
for i, entry in ipairs(data) do
sortedData[i] = entry
end
table.sort(sortedData, function(a, b)
return (a.time or 0) > (b.time or 0)
end)
for i, entry in ipairs(sortedData) do
if not achieveFontStrings[i] then
achieveFontStrings[i] = achieveContent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
end
local fs = achieveFontStrings[i]
fs:ClearAllPoints()
fs:SetPoint("TOPLEFT", 0, yOff)
-- Format: [Category] Description (+Points) - Level X @ Zone
local text = string.format("|cff00ff00[%s]|r %s |cffffd700(+%d)|r",
entry.category or "Unknown",
entry.description or "Achievement",
entry.points or 0)
if entry.level then
text = text .. string.format(" - Lvl %d", entry.level)
end
if entry.zone and entry.zone ~= "" then
text = text .. string.format(" @ %s", entry.zone)
end
fs:SetText(text)
fs:SetJustifyH("LEFT")
fs:SetWidth(570)
fs:Show()
yOff = yOff - 20
end
achieveContent:SetHeight(math.max(1, math.abs(yOff)))
end
-------------------------------------------------
-- Violations Tab
-------------------------------------------------
local violationsPanel = CreateFrame("Frame", nil, frame)
violationsPanel:SetSize(610, 440)
violationsPanel:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -30)
violationsPanel:SetFrameLevel(frame:GetFrameLevel() + 1)
local scrollFrame = CreateFrame("ScrollFrame", "IronmanViolationsScroll", violationsPanel, "UIPanelScrollFrameTemplate")
scrollFrame:SetSize(590, 330)
scrollFrame:SetPoint("TOPLEFT", 20, -110)
local content = CreateFrame("Frame", nil, scrollFrame)
content:SetSize(570, 1)
scrollFrame:SetScrollChild(content)
local fontStrings = {}
local function RefreshViolations()
for _, fs in ipairs(fontStrings) do
fs:Hide()
end
local data = IronmanModeDB.violations or {}
local yOff = -5
if #data == 0 then
if not fontStrings[1] then
fontStrings[1] = content:CreateFontString(nil, "ARTWORK", "GameFontNormal")
end
fontStrings[1]:SetPoint("TOPLEFT", 0, yOff)
fontStrings[1]:SetText("No violations recorded for this character.")
fontStrings[1]:Show()
content:SetHeight(20)
return
end
for i, entry in ipairs(data) do
if not fontStrings[i] then
fontStrings[i] = content:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
end
local fs = fontStrings[i]
fs:ClearAllPoints()
fs:SetPoint("TOPLEFT", 0, yOff)
fs:SetText(string.format("[%s] %s - %s", entry.time, entry.rule, entry.detail))
fs:SetJustifyH("LEFT")
fs:SetWidth(570)
fs:Show()
yOff = yOff - 20
end
content:SetHeight(math.max(1, math.abs(yOff)))
end
local clearBtn = CreateFrame("Button", nil, violationsPanel, "UIPanelButtonTemplate")
clearBtn:SetSize(100, 22)
clearBtn:SetPoint("BOTTOM", 0, 15)
clearBtn:SetText("Clear Log")
clearBtn:SetScript("OnClick", function()
IronmanModeDB.violations = {}
IronmanModeDB.hasBeenCleared = true
RefreshViolations()
if Ironman.RefreshStatus then
Ironman:RefreshStatus()
end
end)
-------------------------------------------------
-- Settings Tab
-------------------------------------------------
local settingsPanel = CreateFrame("Frame", nil, frame)
settingsPanel:SetSize(610, 440)
settingsPanel:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -30)
settingsPanel:SetFrameLevel(frame:GetFrameLevel() + 1)
-- -- Version display (bottom left, opposite of close button)
-- local versionText = settingsPanel:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
-- versionText:SetPoint("BOTTOMLEFT", 20, 15)
-- local addonVersion = GetAddOnMetadata("IronmanMode", "Version") or "Unknown"
-- local addonAuthor = GetAddOnMetadata("IronmanMode", "Author") or "Unknown"
-- versionText:SetText(string.format("v%s by %s", addonVersion, addonAuthor))
-- versionText:SetTextColor(0.7, 0.7, 0.7, 1) -- Gray color
local settingsY = -110
local settingsSpacing = -35
-- Minimap Icon checkbox
local minimapCheckbox = CreateFrame("CheckButton", nil, settingsPanel, "UICheckButtonTemplate")
minimapCheckbox:SetPoint("TOPLEFT", 20, settingsY)
minimapCheckbox.text = minimapCheckbox:CreateFontString(nil, "OVERLAY", "GameFontNormal")
minimapCheckbox.text:SetPoint("LEFT", minimapCheckbox, "RIGHT", 5, 0)
minimapCheckbox.text:SetText("Show Minimap Icon")
settingsY = settingsY + settingsSpacing
-- Hardcore Mode checkbox
local hardcoreCheckbox = CreateFrame("CheckButton", nil, settingsPanel, "UICheckButtonTemplate")
hardcoreCheckbox:SetPoint("TOPLEFT", 20, settingsY)
hardcoreCheckbox.text = hardcoreCheckbox:CreateFontString(nil, "OVERLAY", "GameFontNormal")
hardcoreCheckbox.text:SetPoint("LEFT", hardcoreCheckbox, "RIGHT", 5, 0)
hardcoreCheckbox.text:SetText("Hardcore Mode (Death = Disabled)")
local function RefreshSettings()
if IronmanModeDB and IronmanModeDB.minimap then
minimapCheckbox:SetChecked(not IronmanModeDB.minimap.hide)
end
-- Initialize doHardcore if it doesn't exist
if IronmanModeDB.doHardcore == nil then
IronmanModeDB.doHardcore = false
end
if IronmanModeDB.doHardcoreTurnedOff == nil then
IronmanModeDB.doHardcoreTurnedOff = false
end
-- Hide hardcore checkbox if it was previously turned off
if IronmanModeDB.doHardcoreTurnedOff or IronmanModeDB.doHardcoreTurnedOffOnStart then
hardcoreCheckbox:Hide()
hardcoreCheckbox.text:Hide()
else
hardcoreCheckbox:Show()
hardcoreCheckbox.text:Show()
hardcoreCheckbox:SetChecked(IronmanModeDB.doHardcore)
end
end
minimapCheckbox:SetScript("OnClick", function(self)
if IronmanModeDB and IronmanModeDB.minimap then
IronmanModeDB.minimap.hide = not self:GetChecked()
local icon = LibStub("LibDBIcon-1.0")
if IronmanModeDB.minimap.hide then
icon:Hide("IronmanMode")
print("|cffff0000[Ironman]|r Minimap icon hidden.")
else
icon:Show("IronmanMode")
print("|cffff0000[Ironman]|r Minimap icon shown.")
end
end
end)
hardcoreCheckbox:SetScript("OnClick", function(self)
local isChecked = self:GetChecked()
if isChecked then
-- Turning hardcore ON
IronmanModeDB.doHardcore = true
else
-- Turning hardcore OFF - show confirmation
if IronmanModeDB.doHardcore then
-- Revert the checkbox state temporarily
self:SetChecked(true)
-- Show confirmation dialog
StaticPopupDialogs["IRONMAN_HARDCORE_DISABLE"] = {
text = "If you opt out of hardcore mode, your Hardcore Score will be frozen and you will not be able to opt in again. Are you sure?",
button1 = "OK",
button2 = "Cancel",
OnAccept = function()
-- User confirmed - disable hardcore
IronmanModeDB.doHardcore = false
IronmanModeDB.doHardcoreTurnedOff = true
hardcoreCheckbox:SetChecked(false)
print("|cffff0000[Ironman]|r Hardcore mode disabled and locked.")
-- Hide the checkbox
hardcoreCheckbox:Hide()
hardcoreCheckbox.text:Hide()
end,
OnCancel = function()
-- User cancelled - keep it checked
hardcoreCheckbox:SetChecked(true)
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
}
StaticPopup_Show("IRONMAN_HARDCORE_DISABLE")
end
end
end)
-------------------------------------------------
-- Tab Switch Logic
-------------------------------------------------
function Ironman:ShowTab(tab)
statusPanel:Hide()
rulesPanel:Hide()
achievementsPanel:Hide()
violationsPanel:Hide()
settingsPanel:Hide()
-- Find and select the matching tab
local matchingTab = nil
for _, t in ipairs(tabs) do
if t.tabKey == tab then
matchingTab = t
break
end
end
if matchingTab then
SelectTab(matchingTab)
end
if tab == "status" then
statusPanel:Show()
RefreshStatus()
elseif tab == "rules" then
rulesPanel:Show()
RefreshRules()
elseif tab == "achievements" then
achievementsPanel:Show()
RefreshAchievements()
elseif tab == "violations" then
violationsPanel:Show()
RefreshViolations()
elseif tab == "settings" then
settingsPanel:Show()
RefreshSettings()
else
statusPanel:Show()
RefreshStatus()
end
end
function Ironman:RefreshStatus()
RefreshStatus()
end
statusPanel:Show()
rulesPanel:Hide()
achievementsPanel:Hide()
violationsPanel:Hide()
settingsPanel:Hide()
RefreshStatus()
SelectTab(tabs[1]) -- Select the Status tab initially
-------------------------------------------------
-- Close Button
-------------------------------------------------
local close = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
close:SetSize(80, 24)
close:SetPoint("BOTTOMRIGHT", -10, 15)
close:SetText("Close")
close:SetScript("OnClick", function() frame:Hide() end)
Ironman.UI = frame
end
SLASH_IRONMANUI1 = "/ironman"
SlashCmdList["IRONMANUI"] = function()
Ironman:OpenUI()
end