Make OSD message duration (time to fade) configurable

This commit is contained in:
YoshiRulz 2022-01-09 16:09:38 +10:00
parent 940dc69ae5
commit 0a3a597c99
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 27 additions and 2 deletions

View File

@ -92,7 +92,7 @@ namespace BizHawk.Client.Common
public void AddMessage(string message)
{
_messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) });
_messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(_config.OSDMessageDuration) });
}
public void ClearRamWatches()

View File

@ -342,5 +342,8 @@ namespace BizHawk.Client.Common
public IReadOnlyList<string> ModifierKeysEffective;
public bool MergeLAndRModifierKeys { get; set; } = true;
/// <remarks>in seconds</remarks>
public int OSDMessageDuration { get; set; } = 2;
}
}

View File

@ -89,7 +89,7 @@
//
// StackMessagesCheckbox
//
this.StackMessagesCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.StackMessagesCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.StackMessagesCheckbox.AutoSize = true;
this.StackMessagesCheckbox.Location = new System.Drawing.Point(195, 388);
this.StackMessagesCheckbox.Name = "StackMessagesCheckbox";

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Common;
using BizHawk.WinForms.Controls;
namespace BizHawk.Client.EmuHawk
{
@ -21,6 +22,8 @@ namespace BizHawk.Client.EmuHawk
private MessagePosition _autohold;
private MessagePosition _ramWatches;
private readonly SzNUDEx _nudDuration;
private Dictionary<string, MessagePosition> Positions => new Dictionary<string, MessagePosition>
{
["Fps"] = _fps,
@ -57,6 +60,23 @@ namespace BizHawk.Client.EmuHawk
_ramWatches = _config.RamWatches.Clone();
InitializeComponent();
// I'm done wasting my time w/ the Designer --yoshi
SuspendLayout();
_nudDuration = new() { Maximum = 10.0M, Minimum = 1.0M, Size = new(48, 20) };
Controls.Add(new LocSzSingleRowFLP
{
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
Controls =
{
new LabelEx { Text = "Messages fade after" },
_nudDuration,
new LabelEx { Text = "seconds" },
},
Location = OSTailoredCode.IsUnixHost ? new(224, 380) : new(192, 360), // ¯\_(ツ)_/¯
Size = new(300, 24),
});
ResumeLayout();
}
private void MessageConfig_Load(object sender, EventArgs e)
@ -64,6 +84,7 @@ namespace BizHawk.Client.EmuHawk
CreateMessageRows();
CreateColorBoxes();
StackMessagesCheckbox.Checked = _config.StackOSDMessages;
_nudDuration.Value = _config.OSDMessageDuration;
}
private void CreateMessageRows()
@ -136,6 +157,7 @@ namespace BizHawk.Client.EmuHawk
_config.LastInputColor = ColorRows.Single(r => r.Name == "Previous Frame Input").SelectedColor;
_config.MovieInput = ColorRows.Single(r => r.Name == "Movie Input").SelectedColor;
_config.OSDMessageDuration = (int) _nudDuration.Value;
_config.StackOSDMessages = StackMessagesCheckbox.Checked;
Close();
}