diff --git a/Heimdall.lua b/Heimdall.lua index fdf12b7..9452c3a 100644 --- a/Heimdall.lua +++ b/Heimdall.lua @@ -429,6 +429,7 @@ local function init() enabled = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "enabled" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "debug" }, false), masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "masterChannel" }, "Agent"), + lastNotes = shared.GetOrDefault(Heimdall_Data, { "config", "noter", "lastNotes" }, 5), }, } diff --git a/Modules/Config.lua b/Modules/Config.lua index 38d601a..fd34dc4 100644 --- a/Modules/Config.lua +++ b/Modules/Config.lua @@ -1863,7 +1863,7 @@ function shared.Config.Init() return Heimdall_Data.config.noter.enabled end) enableButton:UpdateColor(Heimdall_Data.config.noter.enabled) - noterConfigFrame:Add(enableButton, 2, 6) + noterConfigFrame:Add(enableButton, 1, 12) local masterChannel = CreateBasicSmallEditBox("HeimdallNoterConfigMasterChannel", noterConfigFrame.frame, shared.L[Heimdall_Data.config.locale].config.masterChannel, @@ -1879,6 +1879,22 @@ function shared.Config.Init() end end) 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 -- Whisper Notify diff --git a/Modules/Noter.lua b/Modules/Noter.lua index fd01ca0..0f79c92 100644 --- a/Modules/Noter.lua +++ b/Modules/Noter.lua @@ -103,6 +103,22 @@ function shared.Noter.Init() print(string.format("[%s] Print note command received for: %s", ModuleName, name)) end 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 Heimdall_Data.config.noter.debug then print(string.format("[%s] Range received for print note: %s", ModuleName, range)) @@ -213,15 +229,17 @@ function shared.Noter.Init() end local command = args[1] 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 print(string.format("[%s] Note command received for: %s", ModuleName, name)) 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 DeleteNotes(name, args) - -- Incorrect... We do not NEED a range for print, we also print last N if we say "note ", fix this - elseif string.find(note, "%d") then + elseif string.find(note, "[%d%.]*") then PrintNotes(name, args) else AddNote(name, sender, args) diff --git a/_L.lua b/_L.lua index 25a9c42..e103a5d 100644 --- a/_L.lua +++ b/_L.lua @@ -80,6 +80,7 @@ shared.L = { agentsAssist = "Agents Assist", assist = "Assist", kickOffline = "Kick Offline", + lastNotes = "Last Notes", }, }, ru = { @@ -159,6 +160,7 @@ shared.L = { assist = "Ассист", kickOffline = "Кик Оффлайн", bonkDetector = "Детектор Ударов", + lastNotes = "Последние Заметки", }, zones = { ["Orgrimmar"] = "Оргриммар",