Skip to content

Commit 5f0d22a

Browse files
committed
Added a boolean config to optionally play the classic Windows "beep" when a new session starts.
1 parent 184f153 commit 5f0d22a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

SteamP2PInfo/Config/GameConfig.cs

+12
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ public class GameConfig : INotifyPropertyChanged
7171
})]
7272
public bool HotkeysEnabled { get; set; } = true;
7373

74+
/// <summary>
75+
/// If true, a sound will be played when a new multiplayer session is detected.
76+
/// </summary>
77+
[JsonProperty("play_sound_on_new_session")]
78+
[ConfigBindingElement("Play sound on new session", typeof(ToggleSwitch), "IsOnProperty",
79+
Tooltip: "If enabled, a sound will be played when a new multiplayer session is detected.",
80+
UIElementProperties: new object[] {
81+
new object[] { "OnContent", "Yes" },
82+
new object[] { "OffContent", "No" }
83+
})]
84+
public bool PlaySoundOnNewSession { get; set; } = false;
85+
7486
/// <summary>
7587
/// Overlay configuration for this game. Includes things like placement, enabled/disabled, etc.
7688
/// </summary>

SteamP2PInfo/MainWindow.xaml.cs

+10
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public partial class MainWindow
3636
private Timer timer;
3737
private int timerTicks = 0;
3838
private int overlayHotkey = 0;
39+
private int previousPeersAmount = 0;
3940

4041
private WindowSelectDialog.WindowInfo wInfo;
4142

@@ -108,6 +109,15 @@ private void Timer_Tick(object o)
108109
foreach (SteamPeerBase p in SteamPeerManager.GetPeers())
109110
peers.Add(p);
110111

112+
if (GameConfig.Current.PlaySoundOnNewSession)
113+
{
114+
if (peers.Count > 0 && previousPeersAmount == 0)
115+
{
116+
SystemSounds.Beep.Play();
117+
}
118+
previousPeersAmount = peers.Count;
119+
}
120+
111121
// Update session info column sizes
112122
foreach (var col in dataGridSession.Columns)
113123
{

0 commit comments

Comments
 (0)