diff --git a/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs b/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs index 9a4b0d04782..27f098a9515 100644 --- a/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs @@ -181,7 +181,8 @@ public void DrawNew(string name, bool clear) public (int Left, int Top, int Right, int Bottom) GetPadding() => _padding; - public void AddMessage(string message) => _displayManager.OSD.AddMessage(message); + public void AddMessage(string message, int? duration = null) + => _displayManager.OSD.AddMessage(message, duration); public void ClearGraphics(DisplaySurfaceID? surfaceID = null) => GetRelevantSurface(surfaceID).Clear(); diff --git a/src/BizHawk.Client.Common/Api/Interfaces/IGuiApi.cs b/src/BizHawk.Client.Common/Api/Interfaces/IGuiApi.cs index 563eb2de8e7..40984abe031 100644 --- a/src/BizHawk.Client.Common/Api/Interfaces/IGuiApi.cs +++ b/src/BizHawk.Client.Common/Api/Interfaces/IGuiApi.cs @@ -26,7 +26,8 @@ public interface IGuiApi : IDisposable, IExternalApi void SetPadding(int l, int t, int r, int b); (int Left, int Top, int Right, int Bottom) GetPadding(); - void AddMessage(string message); + void AddMessage(string message, int? duration = null); + void ClearGraphics(DisplaySurfaceID? surfaceID = null); void ClearText(); void SetDefaultForegroundColor(Color color); diff --git a/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs b/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs index f5f5bbb5798..04f8645e44e 100644 --- a/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs +++ b/src/BizHawk.Client.Common/DisplayManager/OSDManager.cs @@ -90,10 +90,11 @@ private string MakeFrameCounter() private readonly List _guiTextList = new List(); private readonly List _ramWatchList = new List(); - public void AddMessage(string message) - { - _messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(_config.OSDMessageDuration) }); - } + public void AddMessage(string message, int? duration = null) + => _messages.Add(new() { + Message = message, + ExpireAt = DateTime.Now + TimeSpan.FromSeconds(duration ?? _config.OSDMessageDuration), + }); public void ClearRamWatches() {