-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv3Assign.lua
More file actions
419 lines (388 loc) · 18.2 KB
/
Copy pathv3Assign.lua
File metadata and controls
419 lines (388 loc) · 18.2 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
-- ============================================================
-- RT v3 — modules/Assign.lua
-- Surface le moteur d'attribution intelligent v2 (RT_AA).
-- C'est le joyau de l'addon : analyse le roster et attribue
-- tanks/markers, soins, groupes, buffs, bénédictions automatiquement.
--
-- Le module v3 NE réimplémente RIEN : il appelle RT_AA_Run / PackGuild
-- / PackPUG / AnnounceAll et affiche RT_AA_LAST proprement.
-- ============================================================
local function fmtAssignment(out)
if not out then
return "|cff888888No assignment computed.\n\nClick |cffFFD700Compute|r to analyze the roster,\nor |cff88CCFFPUG Pack|r to compute + announce + whisper each player.|r"
end
local L = {}
local function add(s) table.insert(L, s) end
-- Tanks
add("|cffFF4D4D» TANKS|r")
local tanks = out.tanks or {}
if table.getn(tanks) == 0 then
add(" |cff888888no tank in the roster|r")
else
for i = 1, table.getn(tanks) do
local mk = out.tankMarkers and out.tankMarkers[i] or ""
local tag = mk ~= "" and ("|cffFFD700[" .. mk .. "]|r ") or ""
add(" " .. tag .. "|cffFFFFFFMT" .. i .. "|r : " .. tanks[i])
end
end
-- Soins tank
add(" ")
add("|cff33FF33» TANK HEALS|r")
local anyHT = false
for ti = 1, table.getn(out.healTank or {}) do
if out.healTank[ti] and out.healTank[ti] ~= "" then
anyHT = true
add(" MT" .. ti .. " (" .. (tanks[ti] or "?") .. ") <- |cff88FF88" .. out.healTank[ti] .. "|r")
end
end
if not anyHT then add(" |cff888888no tank healer assigned|r") end
-- Soins raid
if table.getn(out.healRaid or {}) > 0 then
add(" |cffAAAAAARaid:|r " .. table.concat(out.healRaid, ", "))
end
if out.druidNote and out.druidNote ~= "" then
add(" |cff66CC66" .. out.druidNote .. "|r")
end
-- Buffs
if table.getn(out.buffs or {}) > 0 then
add(" ")
add("|cff69CCF0» BUFFS|r")
for i = 1, table.getn(out.buffs) do
local b = out.buffs[i]
local scope = b.scope and ("|cff888888 [" .. b.scope .. "]|r") or ""
add(" " .. b.name .. " : |cffAACCFF" .. b.buff .. "|r" .. scope)
end
end
-- Malédictions (démonistes)
if table.getn(out.curses or {}) > 0 then
add(" ")
add("|cffAA44FF» CURSES|r |cff666666(1 per warlock, never at the same time)|r")
for i = 1, table.getn(out.curses) do
local c = out.curses[i]
local why = c.why and ("|cff666666 " .. c.why .. "|r") or ""
add(" |cffCC88FF" .. c.name .. "|r : " .. c.curse .. why)
end
end
-- (Groupes : affichés dans l'onglet Groupes, pas ici)
-- (Bénédictions : désactivées pour l'instant)
return table.concat(L, "\n")
end
RT.Modules.Register({
id = "assign",
title = "Assign *",
tip = "The brain: computes tanks/heals/buffs/curses. 'Setup Raid' does it all, 'Announce' sends to /raid.",
color = { 1.00, 0.82, 0.20 },
tabWidth = 80,
build = function(panel)
-- Copie l'attribution RT_AA_LAST dans le preset actif de l'onglet Groupes
local function applyAssignToGroups()
local out = RT_AA_LAST
if not out or not out.groups then return end
local db = RT.Store.DB()
db.v3grppresets = db.v3grppresets or { active=1, presets={} }
local pd = db.v3grppresets
local ap = pd.active or 1
pd.presets = pd.presets or {}
if not pd.presets[ap] then pd.presets[ap] = { name="Assign", groups={} } end
local preset = pd.presets[ap]
preset.groups = preset.groups or {}
for g = 1, 8 do
local old_role = preset.groups[g] and preset.groups[g].role or 1
preset.groups[g] = { names={}, role=old_role }
local grp = out.groups[g] or {}
for s = 1, table.getn(grp) do
preset.groups[g].names[s] = grp[s]
end
end
RT.Store.Notify("groups")
end
-- Écrit un "défaut Boss" global (noms tanks ordre MT + soins) que
-- l'onglet Boss recopie dans chaque boss à l'ouverture.
local function applyAssignToBossDefault()
local out = RT_AA_LAST
if not out then return end
local d = { tanks = {}, htank = {}, hraid = {} }
for i = 1, table.getn(out.tanks or {}) do d.tanks[i] = out.tanks[i] or "" end
for ti = 1, table.getn(out.healTank or {}) do d.htank[ti] = out.healTank[ti] or "" end
for i = 1, table.getn(out.healRaid or {}) do d.hraid[i] = out.healRaid[i] or "" end
RT.Store.DB().v3boss_default = d
-- Force le refresh immédiat si l'onglet Boss est déjà ouvert
if RT3_BossReload then RT3_BossReload() end
end
RT.UI.Label(panel, {
text = "|cffFFD700Smart assignment|r — analyzes the roster and assigns everything",
font = "GameFontNormal",
anchor = { "TOPLEFT", panel, "TOPLEFT", 12, -10 },
})
local preview -- forward ref
local refreshMT -- forward ref (zone tanks MT)
-- Les groupes ne sont recopiés dans l'onglet Groupes QUE si le toggle
-- "Groups: UPDATE" est actif (défaut KEEP : préserve un import Comp
-- Tool / un placement manuel).
local function wantCopyGroups()
local db = RT.Store.DB()
return db.v3assign_copygroups and true or false
end
local function recompute(fn)
local n = 0
for _ in pairs(RT.Store.Roster()) do n = n + 1 end
if n == 0 then
RT.Print("|cffFFAA00Empty roster — scan the raid (Roster tab) or import.|r")
return
end
if fn then fn() end
if wantCopyGroups() then applyAssignToGroups()
else RT.Print("|cff888888[Assign] Groups kept as-is (toggle 'Groups: KEEP' to change).|r") end
applyAssignToBossDefault()
if refreshMT then refreshMT() end
if preview then preview:SetText(fmtAssignment(RT_AA_LAST)) end
end
-- Ligne 1 : bouton Setup Raid (1-clic pour tout faire)
RT.UI.Button(panel, {
text = "▶ Setup Raid", width = 126, height = 24,
color = { 0.60, 0.30, 0.00 },
anchor = { "TOPLEFT", panel, "TOPLEFT", 12, -32 },
onClick = function()
-- 1. Scan si en raid
if RT.ScanRaid then
local n = (GetNumRaidMembers and GetNumRaidMembers()) or 0
if n > 0 then RT.ScanRaid() end
end
-- 2. Calcule + applique (sans annoncer)
recompute(RT_AA_PackGuild)
RT.Print("|cff88FF88[RT] Setup done — review and click Announce when ready.|r")
end,
tooltip = "Scan raid → compute assignment. Does NOT announce. Copies groups only if 'Groups: UPDATE'.",
})
-- Ligne 1 suite : boutons individuels
RT.UI.Button(panel, {
text = "Compute", width = 82, height = 24,
color = { 0.20, 0.60, 0.30 },
anchor = { "TOPLEFT", panel, "TOPLEFT", 142, -32 },
onClick = function() recompute(RT_AA_PackGuild) end,
tooltip = "Recomputes tanks/heals/buffs and applies to Boss. Copies groups only if 'Groups: UPDATE'.",
})
RT.UI.Button(panel, {
text = "Announce", width = 82, height = 24,
color = { 1.00, 0.75, 0.20 },
anchor = { "TOPLEFT", panel, "TOPLEFT", 228, -32 },
onClick = function()
if RT_AA_LAST then RT_AA_AnnounceAll(RT_AA_LAST)
else RT.Print("|cffFFAA00Calcule d'abord une attribution.|r") end
end,
tooltip = "Announces the last computed assignment to /raid.",
})
RT.UI.Button(panel, {
text = "PUG Pack", width = 82, height = 24,
color = { 0.40, 0.70, 1.00 },
anchor = { "TOPLEFT", panel, "TOPLEFT", 314, -32 },
onClick = function() recompute(RT_AA_PackPUG) end,
tooltip = "Compute + announce + whisper each player (PUG mode). Copies groups only if 'Groups: UPDATE'.",
})
RT.UI.Button(panel, {
text = "Whisper all", width = 82, height = 24,
anchor = { "TOPLEFT", panel, "TOPLEFT", 400, -32 },
onClick = function()
if RT_AA_LAST then RT_AA_WhisperPersonal(RT_AA_LAST)
else RT.Print("|cffFFAA00Compute an assignment first.|r") end
end,
tooltip = "Whispers each player their role/group/healing.",
})
-- Toggle : recopier (ou non) les groupes calculés dans l'onglet Groupes
local grpTgl = RT.UI.Button(panel, {
text = "Groups: KEEP", width = 108, height = 24,
color = { 0.30, 0.40, 0.55 },
anchor = { "TOPLEFT", panel, "TOPLEFT", 486, -32 },
tooltip = "KEEP (default): Compute/Setup never touch the Groups tab — your Comp Tool import or manual placement is preserved. UPDATE: computed groups overwrite the active preset.",
})
local function grpTglPaint()
local db = RT.Store.DB()
local tex = grpTgl:GetNormalTexture()
if db.v3assign_copygroups then
grpTgl:SetText("Groups: UPDATE")
if tex then tex:SetVertexColor(0.60, 0.35, 0.10) end
else
grpTgl:SetText("Groups: KEEP")
if tex then tex:SetVertexColor(0.30, 0.40, 0.55) end
end
end
grpTgl:SetScript("OnClick", function()
local db = RT.Store.DB()
db.v3assign_copygroups = not db.v3assign_copygroups
grpTglPaint()
end)
grpTglPaint()
-- ── Toggles de buffs (inclus/exclus des annonces et whispers) ──
local BUFF_TOGGLES = {
{ key="fort", label="Fortitude" },
{ key="spirit", label="Spirit" },
{ key="motw", label="MotW" },
{ key="arcane", label="Arc.Int" },
{ key="soulstone", label="Soulstone" },
{ key="curses", label="Curses" },
}
local bl = panel:CreateFontString(nil,"OVERLAY","GameFontHighlightSmall")
bl:SetPoint("TOPLEFT", panel, "TOPLEFT", 12, -64)
bl:SetText("|cff69CCF0Buffs:|r")
for i = 1, table.getn(BUFF_TOGGLES) do
local t = BUFF_TOGGLES[i]
local b = RT.UI.Button(panel, {
text = t.label, width = 74, height = 18,
anchor = { "TOPLEFT", panel, "TOPLEFT", 54 + (i-1)*78, -61 },
tooltip = "Green = included in assignments, announces and whispers. Red = disabled. Recompute after changing.",
})
local key = t.key
local function paintTgl()
local o = RT_AA_BuffOpts and RT_AA_BuffOpts() or {}
local tex = b:GetNormalTexture()
if tex then
if o[key] then tex:SetVertexColor(0.15, 0.55, 0.20)
else tex:SetVertexColor(0.50, 0.15, 0.10) end
end
end
b:SetScript("OnClick", function()
if not RT_AA_BuffOpts then return end
local o = RT_AA_BuffOpts()
o[key] = not o[key]
paintTgl()
end)
paintTgl()
end
-- ── Zone éditable : TANKS + SOINS (attribution manuelle) ──
local MT_MARK = { "Skull", "Cross", "Square", "Moon" }
local helpFS = panel:CreateFontString(nil,"OVERLAY","GameFontHighlightSmall")
helpFS:SetPoint("TOPLEFT", panel, "TOPLEFT", 12, -84)
helpFS:SetText("|cff888888Click a filled slot = |cffFFD700select|r (green). Click another = |cffFFD700swap|r. Empty slot = type a name. Tanks → MT1 Skull · MT2 Cross · MT3 Square · MT4 Moon|r")
local tankBoxes, htBoxes, hrBoxes = {}, {}, {}
-- Slot sélectionné pour swap (clic-sélection, comme l'onglet Groupes)
-- { btn, store, idx }
local selSlot = nil
local function slotDeselect()
if selSlot then
local tex = selSlot.btn:GetNormalTexture()
if tex then tex:SetVertexColor(1, 1, 1) end
selSlot = nil
end
end
-- Crée label + 4 boutons cliquables (clic pour sélectionner/swap).
-- Un clic sur un slot vide ouvre une popup pour saisir un nom.
local function mkBoxes(y, labelText, color, store, isTank)
local lb = panel:CreateFontString(nil,"OVERLAY","GameFontHighlightSmall")
lb:SetPoint("TOPLEFT", panel, "TOPLEFT", 12, y-2)
lb:SetWidth(54) lb:SetJustifyH("LEFT")
lb:SetText(color..labelText.."|r")
local boxes = {}
for i = 1, 4 do
local btn = CreateFrame("Button", nil, panel, "UIPanelButtonTemplate")
btn:SetPoint("TOPLEFT", panel, "TOPLEFT", 68 + (i-1)*134, y)
btn:SetWidth(128) btn:SetHeight(18)
btn:SetText("")
local ii, ss = i, store
btn:SetScript("OnClick", function()
if selSlot then
if selSlot.btn == btn then
-- Désélectionne
slotDeselect()
else
-- Swap les deux slots (quelle que soit la ligne)
local nameA = btn:GetText() or ""
local nameB = selSlot.btn:GetText() or ""
btn:SetText(nameB)
selSlot.btn:SetText(nameA)
RT_AA_LAST = RT_AA_LAST or {}
RT_AA_LAST[ss] = RT_AA_LAST[ss] or {}
RT_AA_LAST[selSlot.store] = RT_AA_LAST[selSlot.store] or {}
RT_AA_LAST[ss][ii] = nameB
RT_AA_LAST[selSlot.store][selSlot.idx] = nameA
slotDeselect()
applyAssignToBossDefault()
if refreshMT then refreshMT() end
if preview then preview:SetText(fmtAssignment(RT_AA_LAST)) end
end
else
local cur = btn:GetText() or ""
if cur == "" then
-- Slot vide : saisie manuelle via popup
RT3_ASSIGN_SLOT = { store=ss, idx=ii, btn=btn }
StaticPopup_Show("RT3_ASSIGN_ENTER")
else
-- Sélectionne ce slot (vert)
selSlot = { btn=btn, store=ss, idx=ii }
local tex = btn:GetNormalTexture()
if tex then tex:SetVertexColor(0.3, 0.85, 0.3) end
end
end
end)
boxes[i] = btn
end
return boxes
end
StaticPopupDialogs["RT3_ASSIGN_ENTER"] = {
text = "Enter a player name:",
button1 = "OK",
button2 = "Cancel",
hasEditBox = 1,
OnAccept = function()
local name = getglobal(this:GetParent():GetName().."EditBox"):GetText()
if RT3_ASSIGN_SLOT and name and name ~= "" then
local sl = RT3_ASSIGN_SLOT
sl.btn:SetText(name)
RT_AA_LAST = RT_AA_LAST or {}
RT_AA_LAST[sl.store] = RT_AA_LAST[sl.store] or {}
RT_AA_LAST[sl.store][sl.idx] = name
applyAssignToBossDefault()
if refreshMT then refreshMT() end
if preview then preview:SetText(fmtAssignment(RT_AA_LAST)) end
end
RT3_ASSIGN_SLOT = nil
end,
OnCancel = function() RT3_ASSIGN_SLOT = nil end,
timeout = 0, whileDead = 1, hideOnEscape = 1,
}
tankBoxes = mkBoxes(-102, "Tanks", "|cffFF7777", "tanks", true)
htBoxes = mkBoxes(-126, "T.Heal", "|cff66DD66", "healTank", false)
hrBoxes = mkBoxes(-150, "H.Raid", "|cff66DD66", "healRaid", false)
local function applySlotColor(btn, name)
local fs = btn:GetFontString()
if not fs then return end
if name and name ~= "" then
local db = RT.Store.Roster()
local r, g, b = RT.ClassColor((db[name] or {}).class)
fs:SetTextColor(r, g, b)
else
fs:SetTextColor(0.8, 0.8, 0.8)
end
end
refreshMT = function()
local L = RT_AA_LAST or {}
local t, ht, hr = L.tanks or {}, L.healTank or {}, L.healRaid or {}
for i = 1, 4 do
tankBoxes[i]:SetText(t[i] or "")
htBoxes[i]:SetText(ht[i] or "")
hrBoxes[i]:SetText(hr[i] or "")
applySlotColor(tankBoxes[i], t[i])
applySlotColor(htBoxes[i], ht[i])
applySlotColor(hrBoxes[i], hr[i])
end
end
preview = RT.UI.TextScroll(panel, {
name = "RT3_AssignPreview",
anchor = { "TOPLEFT", panel, "TOPLEFT", 8, -176 },
width = 690, height = 248, font = "GameFontHighlightSmall",
})
preview.scroll:SetPoint("BOTTOMRIGHT", panel, "BOTTOMRIGHT", -28, 8)
panel._preview = preview
panel._refreshMT = refreshMT
RT.Store.Subscribe("roster", function()
-- Le roster a changé : on n'efface pas l'attrib existante,
-- mais on rafraîchit l'affichage si une attrib est présente.
if panel:IsShown() and RT_AA_LAST then
preview:SetText(fmtAssignment(RT_AA_LAST))
end
end)
end,
show = function(panel)
if panel._preview then panel._preview:SetText(fmtAssignment(RT_AA_LAST)) end
if panel._refreshMT then panel._refreshMT() end
end,
})