Implement printing last N notes

This commit is contained in:
2025-01-15 11:50:35 +01:00
parent 75a84baa42
commit ec2f146095
4 changed files with 42 additions and 5 deletions

View File

@@ -429,6 +429,7 @@ local function init()
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "enabled" }, false),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "debug" }, false),
masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "masterChannel" }, "Agent"), masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "masterChannel" }, "Agent"),
lastNotes = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "lastNotes" }, 5),
}, },
} }

View File

@@ -1863,7 +1863,7 @@ function shared.Config.Init()
return Heimdall_Data.config.noter.enabled return Heimdall_Data.config.noter.enabled
end) end)
enableButton:UpdateColor(Heimdall_Data.config.noter.enabled) enableButton:UpdateColor(Heimdall_Data.config.noter.enabled)
noterConfigFrame:Add(enableButton, 2, 6) noterConfigFrame:Add(enableButton, 1, 12)
local masterChannel = CreateBasicSmallEditBox("HeimdallNoterConfigMasterChannel", local masterChannel = CreateBasicSmallEditBox("HeimdallNoterConfigMasterChannel",
noterConfigFrame.frame, shared.L[Heimdall_Data.config.locale].config.masterChannel, noterConfigFrame.frame, shared.L[Heimdall_Data.config.locale].config.masterChannel,
@@ -1879,6 +1879,22 @@ function shared.Config.Init()
end end
end) end)
noterConfigFrame:Add(masterChannel, 2, 6) noterConfigFrame:Add(masterChannel, 2, 6)
local lastNotes = CreateBasicSmallEditBox("HeimdallNoterConfigLastNotes",
noterConfigFrame.frame, shared.L[Heimdall_Data.config.locale].config.lastNotes,
tostring(Heimdall_Data.config.noter.lastNotes),
function(self)
local text = self:GetText()
local value = tonumber(text)
if value and value > 0 then
Heimdall_Data.config.noter.lastNotes = value
print("Last notes set to", value)
else
print("Invalid number of last notes", text)
self:SetText(tostring(Heimdall_Data.config.noter.lastNotes))
end
end)
noterConfigFrame:Add(lastNotes, 2, 6)
end end
-- Whisper Notify -- Whisper Notify

View File

@@ -103,6 +103,22 @@ function shared.Noter.Init()
print(string.format("[%s] Print note command received for: %s", ModuleName, name)) print(string.format("[%s] Print note command received for: %s", ModuleName, name))
end end
local range = args[3] local range = args[3]
if not range then
if Heimdall_Data.config.noter.debug then
print(string.format("[%s] No range specified for print note, defaulting to last %d notes", ModuleName,
Heimdall_Data.config.noter.lastNotes))
end
local notes = Heimdall_Data.config.notes[name] or {}
local start = math.max(1, #notes - Heimdall_Data.config.noter.lastNotes + 1)
local finish = #notes
if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Printing notes from %d to %d for: %s", ModuleName, start, finish, name))
end
for i = start, finish do
PrintNote(notes[i])
end
return
end
if range then if range then
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Range received for print note: %s", ModuleName, range)) print(string.format("[%s] Range received for print note: %s", ModuleName, range))
@@ -213,15 +229,17 @@ function shared.Noter.Init()
end end
local command = args[1] local command = args[1]
if command == "note" then if command == "note" then
local name = strtrim(string.lower(args[2])) local name = strtrim(string.lower(args[2] or ""))
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Note command received for: %s", ModuleName, name)) print(string.format("[%s] Note command received for: %s", ModuleName, name))
end end
local note = strtrim(args[3]) local note = strtrim(args[3] or "")
if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Note: %s", ModuleName, note))
end
if note == "delete" then if note == "delete" then
DeleteNotes(name, args) DeleteNotes(name, args)
-- Incorrect... We do not NEED a range for print, we also print last N if we say "note <name>", fix this elseif string.find(note, "[%d%.]*") then
elseif string.find(note, "%d") then
PrintNotes(name, args) PrintNotes(name, args)
else else
AddNote(name, sender, args) AddNote(name, sender, args)

2
_L.lua
View File

@@ -80,6 +80,7 @@ shared.L = {
agentsAssist = "Agents Assist", agentsAssist = "Agents Assist",
assist = "Assist", assist = "Assist",
kickOffline = "Kick Offline", kickOffline = "Kick Offline",
lastNotes = "Last Notes",
}, },
}, },
ru = { ru = {
@@ -159,6 +160,7 @@ shared.L = {
assist = "Ассист", assist = "Ассист",
kickOffline = "Кик Оффлайн", kickOffline = "Кик Оффлайн",
bonkDetector = "Детектор Ударов", bonkDetector = "Детектор Ударов",
lastNotes = "Последние Заметки",
}, },
zones = { zones = {
["Orgrimmar"] = "Оргриммар", ["Orgrimmar"] = "Оргриммар",