Skip to content

Commit 0701eb4

Browse files
committed
Merge branch 'dev' into main
2 parents 6a08025 + ff65157 commit 0701eb4

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

VRCOSC.Desktop/VRCOSC.Desktop.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<ApplicationIcon>game.ico</ApplicationIcon>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<Version>0.0.0</Version>
9-
<FileVersion>2023.727.0</FileVersion>
9+
<FileVersion>2023.727.1</FileVersion>
1010
<Title>VRCOSC</Title>
1111
<Authors>VolcanicArts</Authors>
1212
<Company>VolcanicArts</Company>
1313
<Nullable>enable</Nullable>
14-
<AssemblyVersion>2023.727.0</AssemblyVersion>
14+
<AssemblyVersion>2023.727.1</AssemblyVersion>
1515
</PropertyGroup>
1616
<ItemGroup Label="Project References">
1717
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />

VRCOSC.Game/Processes/ProcessExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Diagnostics;
77
using System.Linq;
8+
using System.Text;
89
using System.Threading.Tasks;
910
using NAudio.CoreAudioApi;
1011
using osu.Framework.Extensions.IEnumerableExtensions;
@@ -24,9 +25,9 @@ public static async Task PressKeys(IEnumerable<User32.VirtualKey> keys, int pres
2425

2526
public static string? GetActiveWindowTitle()
2627
{
27-
var buff = new char[256];
28+
var buffer = new char[256];
2829
var handle = User32.GetForegroundWindow();
29-
return User32.GetWindowText(handle, buff, 256) > 0 ? buff.ToString() : null;
30+
return User32.GetWindowText(handle, buffer, 256) > 0 ? Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(buffer)).TrimEnd('\u0000') : null;
3031
}
3132

3233
public static void ShowMainWindow(this Process process, User32.WindowShowStyle style) => User32.ShowWindow(process.MainWindowHandle, style);

VRCOSC.Modules/AFK/AFKModule.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// See the LICENSE file in the repository root for full license text.
33

44
using VRCOSC.Game.Modules.ChatBox;
5-
using VRCOSC.Game.OSC.VRChat;
65
using VRCOSC.Game.Processes;
76

87
namespace VRCOSC.Modules.AFK;
@@ -13,7 +12,7 @@ public class AFKModule : ChatBoxModule
1312
public override string Description => "Display text and time since going AFK";
1413
public override string Author => "VolcanicArts";
1514
public override ModuleType Type => ModuleType.General;
16-
protected override TimeSpan DeltaUpdate => VRChatOscConstants.UPDATE_TIME_SPAN;
15+
protected override TimeSpan DeltaUpdate => TimeSpan.FromSeconds(1);
1716

1817
private DateTime? afkBegan;
1918

@@ -38,6 +37,14 @@ protected override void OnModuleStart()
3837
}
3938

4039
protected override void OnModuleUpdate()
40+
{
41+
SetVariableValue(AFKVariable.FocusedWindow, ProcessExtensions.GetActiveWindowTitle() ?? "None");
42+
SetVariableValue(AFKVariable.Duration, afkBegan is null ? null : (DateTime.Now - afkBegan.Value).ToString(@"hh\:mm\:ss"));
43+
SetVariableValue(AFKVariable.Since, afkBegan?.ToString(@"hh\:mm"));
44+
ChangeStateTo(afkBegan is null ? AFKState.NotAFK : AFKState.AFK);
45+
}
46+
47+
protected override void OnPlayerUpdate()
4148
{
4249
if (Player.AFK is null)
4350
{
@@ -48,7 +55,6 @@ protected override void OnModuleUpdate()
4855
if (Player.AFK.Value && afkBegan is null)
4956
{
5057
afkBegan = DateTime.Now;
51-
SetVariableValue(AFKVariable.FocusedWindow, ProcessExtensions.GetActiveWindowTitle() ?? "None");
5258
TriggerEvent(AFKEvent.AFKStarted);
5359
}
5460

@@ -57,10 +63,6 @@ protected override void OnModuleUpdate()
5763
afkBegan = null;
5864
TriggerEvent(AFKEvent.AFKStopped);
5965
}
60-
61-
SetVariableValue(AFKVariable.Duration, afkBegan is null ? null : (DateTime.Now - afkBegan.Value).ToString(@"hh\:mm\:ss"));
62-
SetVariableValue(AFKVariable.Since, afkBegan?.ToString(@"hh\:mm"));
63-
ChangeStateTo(afkBegan is null ? AFKState.NotAFK : AFKState.AFK);
6466
}
6567

6668
private enum AFKVariable

0 commit comments

Comments
 (0)