Skip to content

Commit

Permalink
Add optional duration param to IGuiApi.AddMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Feb 7, 2022
1 parent f4b4c60 commit 267f48e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/BizHawk.Client.Common/Api/Classes/GuiApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 2 additions & 1 deletion src/BizHawk.Client.Common/Api/Interfaces/IGuiApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/BizHawk.Client.Common/DisplayManager/OSDManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ private string MakeFrameCounter()
private readonly List<UIDisplay> _guiTextList = new List<UIDisplay>();
private readonly List<UIDisplay> _ramWatchList = new List<UIDisplay>();

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()
{
Expand Down

0 comments on commit 267f48e

Please sign in to comment.