Add playtime tracking to player info with pause-on-blur#546
Conversation
|
I had never used this feature before and decided to try it now. I immediately found several bugs:
In short, the feature is very inconsistent, but it behaved like this before your pull request. Could you fix it? |
As you said, this behavior was already there, but I decided to 'fix' it anyway. |
|
Fixed |
| #if defined(_WIN32) | ||
| #include <windows.h> | ||
| #endif |
| #include "dll/steam_client.h" | ||
| #include "dll/settings_parser.h" | ||
| #include "dll/dll.h" | ||
| #include <optional> |
| // On non-Windows platforms, always returns true (no focus-based pausing). | ||
| static bool is_game_focused() | ||
| { | ||
| #if defined(_WIN32) |
There was a problem hiding this comment.
I suppose it would be better to use __WINDOWS__ macro defined here.
| unsigned total_m = static_cast<unsigned>((total_sec % 3600) / 60); | ||
|
|
||
| char total_buf[32]{}; | ||
| char session_buf[32]; |
There was a problem hiding this comment.
Seems to forget initialization({}).
|
I remember playtime tracker also having a problem where playtime doesn't get saved properly when using steamclient.dll since |
- Remove redundant #include <optional> and #include <windows.h> (already in common_includes.h)
- Use project's __WINDOWS__ macro instead of _WIN32
- Add {} initializer to session_buf[32]
Adds per-game playtime tracking displayed in the overlay's user info section, with automatic pause when the game loses focus.
Features:
1. Playtime tracking — records total and session playtime per game
2. Pause-on-blur — total and session playtime independently configurable to pause when game not focused
3. Overlay display — shows playtime in the user info panel
4. Settings: record_playtime (default=0), pause_total_when_unfocused (default=0), pause_session_when_unfocused (default=0) under [main::stats], and Show_Playtime_In_User_Info (default=0) under [overlay::general]