diff --git a/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua b/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua index b7b932cb04..4193ed54eb 100644 --- a/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua +++ b/Themes/_fallback/BGAnimations/ScreenSystemLayer error.lua @@ -48,6 +48,7 @@ end local log_args= { Name= "ScriptError", ReplaceLinesWhenHidden= true, + IgnoreIdentical= true, Times= message_time, Font= "Common Error", } diff --git a/Themes/_fallback/Scripts/04 LogDisplay.lua b/Themes/_fallback/Scripts/04 LogDisplay.lua index 4bfb50564b..482a73eaa7 100644 --- a/Themes/_fallback/Scripts/04 LogDisplay.lua +++ b/Themes/_fallback/Scripts/04 LogDisplay.lua @@ -58,6 +58,9 @@ -- If this is false, messages recieved while the LogDisplay is hidden -- will push other messages back. Messages pushed past MaxLines will be -- removed. +-- IgnoreIdentical= bool +-- If true, then a message that is identical to one already in the log +-- will be ignored. -- Font= font name -- The name of the font to use. This will be passed to THEME:GetPathF, -- so it should not be a path. @@ -146,6 +149,19 @@ local log_display_mt= { -- Long ago, someone decided that "::" should be an alias for "\n" -- and hardcoded it into BitmapText. local message= tostring(mess.message):gsub("::", ":") + if params.IgnoreIdentical then + -- Use only the first line for comparison because the rest is + -- probably stack trace, with args that might vary uselessly. + self.width_tester:settext(message) + local lines= convert_text_to_indented_lines( + self.width_tester, self.indent, self.line_width, self.text_zoom) + for i, prevmess in ipairs(self.message_log) do + self.width_tester:settext(prevmess) + local prevlines= convert_text_to_indented_lines( + self.width_tester, self.indent, self.line_width, self.text_zoom) + if lines[1][2] == prevmess[1][2] then return end + end + end if params.ReplaceLinesWhenHidden and self.hidden then self:clear() self.message_log[1]= message