-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartyPresets.lua
More file actions
876 lines (785 loc) · 26.9 KB
/
PartyPresets.lua
File metadata and controls
876 lines (785 loc) · 26.9 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
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
-- ============================================================
-- PartyPresets v1.0.0
-- Standalone addon for SoloCraft WoW 1.12.1
-- Auto-opens alongside PCP (original or Remake)
-- Faction-aware: Horde=no paladin, Alliance=no shaman
-- ============================================================
local CMD_ADD = ".partybot add "
local playerFaction = nil
-- Kick all party bots by uninviting party members (not yourself)
local function KickAllBots()
local myName = UnitName("player")
local kicked = 0
for i = 1, 4 do
local unit = "party" .. i
local name = UnitName(unit)
if name and name ~= myName then
UninviteByName(name)
kicked = kicked + 1
end
end
if kicked > 0 then
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff[PartyPresets]|r Kicked " .. kicked .. " bot(s).")
else
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff[PartyPresets]|r No bots to kick.")
end
return kicked
end
local function GetFaction()
if playerFaction then return playerFaction end
local _, eng = UnitFactionGroup("player")
if eng then playerFaction = eng end
return playerFaction
end
local allClasses = { "warrior", "paladin", "hunter", "rogue", "priest", "shaman", "mage", "warlock", "druid" }
local classRoles = {
warrior = { "tank", "meleedps" },
paladin = { "tank", "healer", "meleedps" },
hunter = { "rangedps" },
rogue = { "meleedps" },
priest = { "healer", "rangedps" },
shaman = { "tank", "healer", "meleedps", "rangedps" },
mage = { "rangedps" },
warlock = { "rangedps" },
druid = { "tank", "healer", "meleedps", "rangedps" },
}
local classColors = {
warrior = "|cffC79C6E",
paladin = "|cffF58CBA",
hunter = "|cffABD473",
rogue = "|cffFFF569",
priest = "|cffFFFFFF",
shaman = "|cff0070DE",
mage = "|cff69CCF0",
warlock = "|cff9482C9",
druid = "|cffFF7D0A",
}
local function GetValidClasses()
local faction = GetFaction()
local result = {}
for i = 1, table.getn(allClasses) do
local c = allClasses[i]
if faction == "Horde" and c == "paladin" then
-- skip
elseif faction == "Alliance" and c == "shaman" then
-- skip
else
table.insert(result, c)
end
end
return result
end
local function Capitalize(str)
if not str or str == "" then return str end
return string.upper(string.sub(str, 1, 1)) .. string.sub(str, 2)
end
local function ClassColorText(className)
local cc = classColors[className]
local name = Capitalize(className)
if cc then return cc .. name .. "|r" end
return name
end
local function RoleText(roleName)
if roleName == "meleedps" then return "MeleeDPS" end
if roleName == "rangedps" then return "RangeDPS" end
return Capitalize(roleName)
end
local function RandomGender()
if math.random(2) == 1 then return "male" else return "female" end
end
-- ============================================================
-- Spawn System
-- ============================================================
local spawnQueue = {}
local spawnIndex = 0
local spawnTimer = CreateFrame("Frame")
spawnTimer:Hide()
local spawnElapsed = 0
spawnTimer:SetScript("OnUpdate", function()
spawnElapsed = spawnElapsed + arg1
if spawnElapsed >= 1.0 then
spawnElapsed = 0
if spawnIndex > table.getn(spawnQueue) then
spawnTimer:Hide()
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff[PartyPresets]|r Done! " .. table.getn(spawnQueue) .. " bots added.")
spawnQueue = {}
spawnIndex = 0
return
end
local bot = spawnQueue[spawnIndex]
local gender = RandomGender()
-- Skip invalid classes for faction
local faction = GetFaction()
if (faction == "Horde" and bot.class == "paladin") or (faction == "Alliance" and bot.class == "shaman") then
DEFAULT_CHAT_FRAME:AddMessage("|cffff3333[PartyPresets]|r Skipped " .. Capitalize(bot.class) .. " (not available for " .. faction .. ")")
spawnIndex = spawnIndex + 1
return
end
SendChatMessage(CMD_ADD .. bot.class .. " " .. bot.role .. " " .. gender)
local cc = classColors[bot.class] or "|cffffffff"
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff[PartyPresets]|r " .. cc .. Capitalize(bot.class) .. "|r " .. RoleText(bot.role) .. " (" .. spawnIndex .. "/" .. table.getn(spawnQueue) .. ")")
spawnIndex = spawnIndex + 1
end
end)
local function FillParty(presetName)
if not PartyPresetsDB or not PartyPresetsDB.presets then return end
local preset = PartyPresetsDB.presets[presetName]
if not preset then
DEFAULT_CHAT_FRAME:AddMessage("|cffff3333[PartyPresets]|r Preset not found: " .. (presetName or "nil"))
return
end
local cur = GetNumPartyMembers()
local maxAdd = 4 - cur
if maxAdd <= 0 then
DEFAULT_CHAT_FRAME:AddMessage("|cffff3333[PartyPresets]|r Party is full!")
return
end
spawnQueue = {}
local count = table.getn(preset)
if count > maxAdd then count = maxAdd end
for i = 1, count do
table.insert(spawnQueue, preset[i])
end
spawnIndex = 1
spawnElapsed = 99
spawnTimer:Show()
end
-- Kick all then fill after delay
local kickThenFillName = nil
local kickTimer = CreateFrame("Frame")
kickTimer:Hide()
local kickElapsed = 0
local kickPhase = 0
kickTimer:SetScript("OnUpdate", function()
kickElapsed = kickElapsed + arg1
if kickPhase == 1 then
KickAllBots()
kickPhase = 2
kickElapsed = 0
elseif kickPhase == 2 and kickElapsed >= 2.0 then
if kickThenFillName then
FillParty(kickThenFillName)
end
kickPhase = 0
kickTimer:Hide()
end
end)
local function KickAndFill(presetName)
local cur = GetNumPartyMembers()
if cur > 0 then
kickThenFillName = presetName
kickPhase = 1
kickElapsed = 0
kickTimer:Show()
else
FillParty(presetName)
end
end
-- ============================================================
-- Database
-- ============================================================
-- Default presets are faction-aware
-- Based on FillRaidBots/SoloCraft community proven compositions
local function BuildDefaultPresets()
local faction = GetFaction()
local isHorde = (faction == "Horde")
local healer1 = isHorde and "priest" or "paladin"
local healer2 = isHorde and "shaman" or "priest"
return {
["Dungeon Balanced"] = {
{ class = "warrior", role = "tank" },
{ class = healer1, role = "healer" },
{ class = "mage", role = "rangedps" },
{ class = "rogue", role = "meleedps" },
},
["Dungeon Cleave"] = {
{ class = "warrior", role = "tank" },
{ class = healer1, role = "healer" },
{ class = "warrior", role = "meleedps" },
{ class = "rogue", role = "meleedps" },
},
["Dungeon AoE"] = {
{ class = "warrior", role = "tank" },
{ class = healer1, role = "healer" },
{ class = "mage", role = "rangedps" },
{ class = "mage", role = "rangedps" },
},
["Heal Heavy"] = {
{ class = "warrior", role = "tank" },
{ class = healer1, role = "healer" },
{ class = healer2, role = "healer" },
{ class = "mage", role = "rangedps" },
},
["All Melee"] = {
{ class = "warrior", role = "tank" },
{ class = healer1, role = "healer" },
{ class = "rogue", role = "meleedps" },
{ class = "rogue", role = "meleedps" },
},
["All Ranged"] = {
{ class = "warrior", role = "tank" },
{ class = healer1, role = "healer" },
{ class = "mage", role = "rangedps" },
{ class = "warlock", role = "rangedps" },
},
}
end
local function InitDB()
if not PartyPresetsDB then PartyPresetsDB = { presets = {} } end
if not PartyPresetsDB.presets then PartyPresetsDB.presets = {} end
-- Add default presets if they don't exist (keeps user-created ones)
if not PartyPresetsDB.defaultsAdded then
local defaults = BuildDefaultPresets()
for k, v in pairs(defaults) do
if not PartyPresetsDB.presets[k] then
PartyPresetsDB.presets[k] = v
end
end
PartyPresetsDB.defaultsAdded = true
end
end
local function GetSortedNames()
InitDB()
local names = {}
for name in pairs(PartyPresetsDB.presets) do
table.insert(names, name)
end
table.sort(names)
return names
end
local selectedPreset = nil
-- ============================================================
-- Dropdown Factory (Lua 5.0 closure-safe)
-- ============================================================
local activeSlotDD = nil
local function MakeItemClick(dd, value, displayText)
return function()
dd.text:SetText(displayText or value)
dd.selectedValue = value
dd.list:Hide()
dd.isOpen = false
activeSlotDD = nil
if dd.onSelect then dd.onSelect(value) end
end
end
local function CreateDropdown(parent, width)
local dd = {}
dd.selectedValue = nil
dd.frame = CreateFrame("Frame", nil, parent)
dd.frame:SetWidth(width)
dd.frame:SetHeight(22)
dd.frame:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 8,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
dd.frame:SetBackdropColor(0.08, 0.08, 0.1, 0.95)
dd.btn = CreateFrame("Button", nil, dd.frame)
dd.btn:SetAllPoints(dd.frame)
dd.text = dd.btn:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
dd.text:SetPoint("LEFT", dd.btn, "LEFT", 6, 0)
dd.text:SetJustifyH("LEFT")
dd.text:SetText("...")
dd.arrow = dd.btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
dd.arrow:SetPoint("RIGHT", dd.btn, "RIGHT", -3, 0)
dd.arrow:SetText("|cff666666v|r")
dd.list = CreateFrame("Frame", nil, parent)
dd.list:SetWidth(width)
dd.list:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 8,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
dd.list:SetBackdropColor(0.04, 0.04, 0.06, 0.98)
dd.list:SetFrameStrata("TOOLTIP")
dd.list:SetPoint("TOP", dd.frame, "BOTTOM", 0, -1)
dd.list:Hide()
dd.items = {}
dd.isOpen = false
dd.onSelect = nil
dd.btn:SetScript("OnClick", function()
if dd.isOpen then
dd.list:Hide()
dd.isOpen = false
activeSlotDD = nil
else
if activeSlotDD and activeSlotDD ~= dd then
activeSlotDD.list:Hide()
activeSlotDD.isOpen = false
end
dd.list:Show()
dd.isOpen = true
activeSlotDD = dd
end
end)
dd.list:SetScript("OnHide", function()
dd.isOpen = false
if activeSlotDD == dd then activeSlotDD = nil end
end)
return dd
end
local function PopulateDropdown(dd, values, displayFn)
for _, item in ipairs(dd.items) do item:Hide() end
dd.items = {}
local h = 18
local total = table.getn(values) * h + 4
if total < 20 then total = 20 end
dd.list:SetHeight(total)
for i = 1, table.getn(values) do
local v = values[i]
local disp = v
if displayFn then disp = displayFn(v) end
local item = CreateFrame("Button", nil, dd.list)
item:SetWidth(dd.frame:GetWidth() - 4)
item:SetHeight(h)
item:SetPoint("TOP", dd.list, "TOP", 0, -((i - 1) * h) - 2)
local txt = item:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
txt:SetPoint("LEFT", item, "LEFT", 8, 0)
txt:SetText(disp)
item:SetHighlightTexture("Interface/QuestFrame/UI-QuestTitleHighlight", "ADD")
item:SetScript("OnClick", MakeItemClick(dd, v, disp))
table.insert(dd.items, item)
end
end
-- ============================================================
-- Layout constants (all Y positions computed from here)
-- ============================================================
local PADDING = 12 -- outer padding
local INNER_PAD = 8 -- between sections
local ROW_H = 28 -- slot row height
local BTN_H = 24 -- button height
local DD_H = 22 -- dropdown height
-- Y positions from top of frame
local Y_TITLE = -10
local Y_ACCENT = -28
local Y_PRESET_DD = -36
local Y_SECTION = -68 -- "Bot Slots" header
local Y_COLUMNS = -84 -- Class / Role column labels
local Y_COL_SEP = -95 -- thin line under column labels
local Y_SLOT1 = -102 -- first slot
local Y_SLOT2 = Y_SLOT1 - ROW_H
local Y_SLOT3 = Y_SLOT2 - ROW_H
local Y_SLOT4 = Y_SLOT3 - ROW_H
local Y_BOT_SEP = Y_SLOT4 - ROW_H - 2 -- separator after slots
local Y_SAVE_ROW = Y_BOT_SEP - 14 -- "Save as:" + input
local Y_BTN_ROW1 = Y_SAVE_ROW - 28 -- Fill Party / Kick All
local Y_BTN_ROW2 = Y_BTN_ROW1 - BTN_H - 4 -- Save / Delete
local FRAME_W = 280
local FRAME_H = -(Y_BTN_ROW2) + BTN_H + PADDING + 4 -- auto-fit
-- ============================================================
-- Main Frame
-- ============================================================
local f = CreateFrame("Frame", "PartyPresetsFrame", UIParent)
f:SetWidth(FRAME_W)
f:SetHeight(FRAME_H)
f:SetPoint("CENTER", UIParent, "CENTER", 250, 0)
f:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/DialogFrame/UI-DialogBox-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 },
})
f:SetBackdropColor(0.02, 0.02, 0.06, 0.92)
f:SetBackdropBorderColor(0.3, 0.7, 1, 0.8)
f:SetMovable(true)
f:SetUserPlaced(true)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", function() f:StartMoving() end)
f:SetScript("OnDragStop", function() f:StopMovingOrSizing() end)
f:SetFrameStrata("HIGH")
f:Hide()
-- Title
local title = f:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING + 2, Y_TITLE)
title:SetText("|cff00ccffParty Presets|r")
local ver = f:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
ver:SetPoint("LEFT", title, "RIGHT", 6, 0)
ver:SetText("|cff444444v1.0|r")
-- Close button
local closeBtn = CreateFrame("Button", nil, f, "UIPanelCloseButton")
closeBtn:SetPoint("TOPRIGHT", f, "TOPRIGHT", -2, -2)
closeBtn:SetScript("OnClick", function() f:Hide() end)
-- Accent line under title
local accent = f:CreateTexture(nil, "ARTWORK")
accent:SetHeight(1)
accent:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING, Y_ACCENT)
accent:SetPoint("TOPRIGHT", f, "TOPRIGHT", -PADDING, Y_ACCENT)
accent:SetTexture(0, 0.6, 1, 0.5)
-- ============================================================
-- Preset Dropdown + Kick Button
-- ============================================================
local ddOpen = false
local ddItems = {}
-- Kick button (small, right side)
local kickBtn = CreateFrame("Button", "PPKickBtn", f, "UIPanelButtonTemplate")
kickBtn:SetWidth(50)
kickBtn:SetHeight(24)
kickBtn:SetPoint("TOPRIGHT", f, "TOPRIGHT", -PADDING, Y_PRESET_DD)
kickBtn:SetText("|cffff6666Kick|r")
kickBtn:SetScript("OnClick", function()
KickAllBots()
end)
kickBtn:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:SetText("Kick all bots from party", 1, 1, 1, 1, true)
GameTooltip:Show()
end)
kickBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
-- Preset dropdown (fills remaining space)
local ddFrame = CreateFrame("Frame", "PPDropdown", f)
ddFrame:SetHeight(24)
ddFrame:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING, Y_PRESET_DD)
ddFrame:SetPoint("RIGHT", kickBtn, "LEFT", -4, 0)
ddFrame:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 8,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
ddFrame:SetBackdropColor(0.08, 0.08, 0.1, 0.95)
local ddBtn = CreateFrame("Button", nil, ddFrame)
ddBtn:SetAllPoints(ddFrame)
local ddBtnText = ddBtn:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
ddBtnText:SetPoint("LEFT", ddBtn, "LEFT", 10, 0)
ddBtnText:SetText("|cff777777Select Preset...|r")
local ddArrow = ddBtn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
ddArrow:SetPoint("RIGHT", ddBtn, "RIGHT", -8, 0)
ddArrow:SetText("|cff666666v|r")
local ddList = CreateFrame("Frame", "PPDropdownList", f)
ddList:SetWidth(FRAME_W - PADDING * 2 - 54)
ddList:SetPoint("TOP", ddFrame, "BOTTOM", 0, -1)
ddList:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 8,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
ddList:SetBackdropColor(0.04, 0.04, 0.06, 0.98)
ddList:SetFrameStrata("TOOLTIP")
ddList:Hide()
local editSlots = {}
local RefreshDropdown
local function LoadPresetIntoSlots(presetName)
InitDB()
local preset = PartyPresetsDB.presets[presetName]
if not preset then return end
for si = 1, 4 do
local s = editSlots[si]
if s and preset[si] then
s.class = preset[si].class or "warrior"
s.role = preset[si].role or "tank"
s.classDD.text:SetText(ClassColorText(s.class))
s.classDD.selectedValue = s.class
s.roleDD.text:SetText(RoleText(s.role))
s.roleDD.selectedValue = s.role
PopulateDropdown(s.roleDD, classRoles[s.class], RoleText)
end
end
end
local function MakePresetClick(itemName)
return function()
selectedPreset = itemName
ddBtnText:SetText("|cff00ff00" .. itemName .. "|r")
ddList:Hide()
ddOpen = false
LoadPresetIntoSlots(itemName)
end
end
RefreshDropdown = function()
for _, item in ipairs(ddItems) do item:Hide() end
ddItems = {}
local names = GetSortedNames()
local h = 20
local total = table.getn(names) * h + 4
if total < 24 then total = 24 end
ddList:SetHeight(total)
for i = 1, table.getn(names) do
local n = names[i]
local item = CreateFrame("Button", "PPDDItem" .. i, ddList)
item:SetWidth(ddList:GetWidth() - 4)
item:SetHeight(h)
item:SetPoint("TOP", ddList, "TOP", 0, -((i - 1) * h) - 2)
local txt = item:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
txt:SetPoint("LEFT", item, "LEFT", 10, 0)
txt:SetText(n)
item:SetHighlightTexture("Interface/QuestFrame/UI-QuestTitleHighlight", "ADD")
item:SetScript("OnClick", MakePresetClick(n))
table.insert(ddItems, item)
end
end
ddBtn:SetScript("OnClick", function()
if activeSlotDD then
activeSlotDD.list:Hide()
activeSlotDD.isOpen = false
activeSlotDD = nil
end
if ddOpen then
ddList:Hide()
ddOpen = false
else
RefreshDropdown()
ddList:Show()
ddOpen = true
end
end)
ddList:SetScript("OnHide", function() ddOpen = false end)
-- ============================================================
-- Bot Slots Section
-- ============================================================
local sectionLabel = f:CreateFontString(nil, "OVERLAY", "GameFontNormal")
sectionLabel:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING + 2, Y_SECTION)
sectionLabel:SetText("|cff00ccffBot Slots|r")
local colClass = f:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
colClass:SetPoint("TOPLEFT", f, "TOPLEFT", 30, Y_COLUMNS)
colClass:SetText("|cff666666Class|r")
local colRole = f:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
colRole:SetPoint("TOPLEFT", f, "TOPLEFT", 155, Y_COLUMNS)
colRole:SetText("|cff666666Role|r")
-- Thin line under column headers
local colSep = f:CreateTexture(nil, "ARTWORK")
colSep:SetHeight(1)
colSep:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING, Y_COL_SEP)
colSep:SetPoint("TOPRIGHT", f, "TOPRIGHT", -PADDING, Y_COL_SEP)
colSep:SetTexture(0.2, 0.4, 0.7, 0.25)
-- Slot factory
local function MakeClassSelect(slot)
return function(value)
slot.class = value
slot.role = classRoles[value][1]
slot.roleDD.text:SetText(RoleText(slot.role))
slot.roleDD.selectedValue = slot.role
PopulateDropdown(slot.roleDD, classRoles[value], RoleText)
end
end
local function MakeRoleSelect(slot)
return function(value)
slot.role = value
end
end
local slotYPositions = { Y_SLOT1, Y_SLOT2, Y_SLOT3, Y_SLOT4 }
for i = 1, 4 do
local slot = {}
slot.class = "warrior"
slot.role = "tank"
local yOff = slotYPositions[i]
local num = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
num:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING + 2, yOff)
num:SetText("|cffffff00" .. i .. ".|r")
local classDD = CreateDropdown(f, 115)
classDD.frame:SetPoint("LEFT", num, "RIGHT", 4, 0)
classDD.text:SetText(ClassColorText(slot.class))
classDD.selectedValue = slot.class
PopulateDropdown(classDD, GetValidClasses(), ClassColorText)
slot.classDD = classDD
local roleDD = CreateDropdown(f, 110)
roleDD.frame:SetPoint("LEFT", classDD.frame, "RIGHT", 6, 0)
roleDD.text:SetText(RoleText(slot.role))
roleDD.selectedValue = slot.role
PopulateDropdown(roleDD, classRoles[slot.class], RoleText)
slot.roleDD = roleDD
classDD.onSelect = MakeClassSelect(slot)
roleDD.onSelect = MakeRoleSelect(slot)
editSlots[i] = slot
end
-- Separator after slots
local botSep = f:CreateTexture(nil, "ARTWORK")
botSep:SetHeight(1)
botSep:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING, Y_BOT_SEP)
botSep:SetPoint("TOPRIGHT", f, "TOPRIGHT", -PADDING, Y_BOT_SEP)
botSep:SetTexture(0.2, 0.4, 0.7, 0.25)
-- ============================================================
-- Save Section
-- ============================================================
local saveLabel = f:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
saveLabel:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING + 2, Y_SAVE_ROW)
saveLabel:SetText("|cffaaaaaaSave as:|r")
local nameInput = CreateFrame("EditBox", "PPNameInput", f, "InputBoxTemplate")
nameInput:SetWidth(175)
nameInput:SetHeight(20)
nameInput:SetPoint("LEFT", saveLabel, "RIGHT", 6, 0)
nameInput:SetAutoFocus(false)
nameInput:SetMaxLetters(30)
nameInput:SetScript("OnEscapePressed", function() this:ClearFocus() end)
nameInput:SetScript("OnEnterPressed", function() this:ClearFocus() end)
-- ============================================================
-- Action Buttons (2 rows of 2)
-- ============================================================
local halfW = (FRAME_W - PADDING * 2 - 4) / 2 -- half width minus gap
local fillBtn = CreateFrame("Button", "PPFillBtn", f, "UIPanelButtonTemplate")
fillBtn:SetWidth(halfW)
fillBtn:SetHeight(BTN_H)
fillBtn:SetPoint("TOPLEFT", f, "TOPLEFT", PADDING, Y_BTN_ROW1)
fillBtn:SetText("|cff44ff44Apply|r")
fillBtn:SetScript("OnClick", function()
if not selectedPreset then
DEFAULT_CHAT_FRAME:AddMessage("|cffff3333[PartyPresets]|r Select a preset first!")
return
end
KickAndFill(selectedPreset)
end)
fillBtn:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:SetText("Apply selected preset\nKicks current bots and spawns new ones\nMax 4 bots, gender randomized", 1, 1, 1, 1, true)
GameTooltip:Show()
end)
fillBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
local saveBtn = CreateFrame("Button", "PPSaveBtn", f, "UIPanelButtonTemplate")
saveBtn:SetWidth(halfW)
saveBtn:SetHeight(BTN_H)
saveBtn:SetPoint("LEFT", fillBtn, "RIGHT", 4, 0)
saveBtn:SetText("Save Preset")
saveBtn:SetScript("OnClick", function()
local name = nameInput:GetText()
if not name or name == "" then
if selectedPreset then
name = selectedPreset
else
DEFAULT_CHAT_FRAME:AddMessage("|cffff3333[PartyPresets]|r Type a name in 'Save as'!")
return
end
end
InitDB()
local newPreset = {}
for i = 1, 4 do
local s = editSlots[i]
table.insert(newPreset, { class = s.class, role = s.role })
end
PartyPresetsDB.presets[name] = newPreset
selectedPreset = name
ddBtnText:SetText("|cff00ff00" .. name .. "|r")
nameInput:SetText("")
nameInput:ClearFocus()
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff[PartyPresets]|r Saved: " .. name)
RefreshDropdown()
end)
saveBtn:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:SetText("Save bot slots as a preset\nType a name or leave empty\nto overwrite selected", 1, 1, 1, 1, true)
GameTooltip:Show()
end)
saveBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
local kickAllBtn = CreateFrame("Button", "PPKickAllBtn", f, "UIPanelButtonTemplate")
kickAllBtn:SetWidth(halfW)
kickAllBtn:SetHeight(BTN_H)
kickAllBtn:SetPoint("TOPLEFT", fillBtn, "BOTTOMLEFT", 0, -4)
kickAllBtn:SetText("|cffff4444Kick All|r")
kickAllBtn:SetScript("OnClick", function()
KickAllBots()
end)
kickAllBtn:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:SetText("Remove all bots from party", 1, 1, 1, 1, true)
GameTooltip:Show()
end)
kickAllBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
local delBtn = CreateFrame("Button", "PPDelBtn", f, "UIPanelButtonTemplate")
delBtn:SetWidth(halfW)
delBtn:SetHeight(BTN_H)
delBtn:SetPoint("LEFT", kickAllBtn, "RIGHT", 4, 0)
delBtn:SetText("Delete Preset")
delBtn:SetScript("OnClick", function()
if not selectedPreset then
DEFAULT_CHAT_FRAME:AddMessage("|cffff3333[PartyPresets]|r Select a preset first!")
return
end
InitDB()
PartyPresetsDB.presets[selectedPreset] = nil
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff[PartyPresets]|r Deleted: " .. selectedPreset)
selectedPreset = nil
ddBtnText:SetText("|cff777777Select Preset...|r")
RefreshDropdown()
end)
delBtn:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:SetText("Delete the selected preset", 1, 1, 1, 1, true)
GameTooltip:Show()
end)
delBtn:SetScript("OnLeave", function() GameTooltip:Hide() end)
-- ============================================================
-- Auto-open alongside PCP (original or Remake)
-- ============================================================
local pcpWatcher = CreateFrame("Frame")
local wasVisible = false
pcpWatcher:SetScript("OnUpdate", function()
local pcpVisible = false
if PCPFrame and PCPFrame:IsVisible() then pcpVisible = true end
if PCPFrameRemake and PCPFrameRemake:IsVisible() then pcpVisible = true end
if pcpVisible and not wasVisible then
f:ClearAllPoints()
if PCPFrameRemake and PCPFrameRemake:IsVisible() then
f:SetPoint("LEFT", PCPFrameRemake, "RIGHT", 5, 0)
elseif PCPFrame and PCPFrame:IsVisible() then
f:SetPoint("LEFT", PCPFrame, "RIGHT", 5, 0)
end
InitDB()
f:Show()
RefreshDropdown()
elseif not pcpVisible and wasVisible then
f:Hide()
end
wasVisible = pcpVisible
end)
pcpWatcher:Show()
-- ============================================================
-- Slash Commands
-- ============================================================
SLASH_PARTYPRESETS1 = "/partypresets"
SLASH_PARTYPRESETS2 = "/pp"
SlashCmdList["PARTYPRESETS"] = function(msg)
if msg and msg ~= "" then
InitDB()
FillParty(msg)
else
if f:IsShown() then
f:Hide()
else
InitDB()
f:Show()
RefreshDropdown()
end
end
end
-- ============================================================
-- Init & Faction Detection
-- ============================================================
local initFrame = CreateFrame("Frame")
initFrame:RegisterEvent("ADDON_LOADED")
initFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
initFrame:SetScript("OnEvent", function()
if event == "ADDON_LOADED" and arg1 == "PartyPresets" then
InitDB()
DEFAULT_CHAT_FRAME:AddMessage("|cff00ccff[PartyPresets]|r v1.0 loaded. Opens with PCP or use /pp")
end
if event == "PLAYER_ENTERING_WORLD" then
local classes = GetValidClasses()
local faction = GetFaction()
if faction then
for si = 1, 4 do
local s = editSlots[si]
if s then
PopulateDropdown(s.classDD, classes, ClassColorText)
if faction == "Horde" and s.class == "paladin" then
s.class = "warrior"
s.role = "tank"
s.classDD.text:SetText(ClassColorText("warrior"))
s.classDD.selectedValue = "warrior"
s.roleDD.text:SetText(RoleText("tank"))
s.roleDD.selectedValue = "tank"
PopulateDropdown(s.roleDD, classRoles["warrior"], RoleText)
elseif faction == "Alliance" and s.class == "shaman" then
s.class = "warrior"
s.role = "tank"
s.classDD.text:SetText(ClassColorText("warrior"))
s.classDD.selectedValue = "warrior"
s.roleDD.text:SetText(RoleText("tank"))
s.roleDD.selectedValue = "tank"
PopulateDropdown(s.roleDD, classRoles["warrior"], RoleText)
end
end
end
end
end
end)