Skip to content

Add playtime tracking to player info with pause-on-blur#546

Open
dasafe wants to merge 3 commits into
Detanup01:devfrom
dasafe:playtime-tracking
Open

Add playtime tracking to player info with pause-on-blur#546
dasafe wants to merge 3 commits into
Detanup01:devfrom
dasafe:playtime-tracking

Conversation

@dasafe

@dasafe dasafe commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

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]

@ndiruhniu

Copy link
Copy Markdown

I had never used this feature before and decided to try it now. I immediately found several bugs:

  1. In some games the file playtime.txt is created even when record_playtime=0.
  2. In some games the file playtime.txt is NOT created even when record_playtime=1.

In short, the feature is very inconsistent, but it behaved like this before your pull request. Could you fix it?

@dasafe

dasafe commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

I had never used this feature before and decided to try it now. I immediately found several bugs:

  1. In some games the file playtime.txt is created even when record_playtime=0.
  2. In some games the file playtime.txt is NOT created even when record_playtime=1.

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.

@ndiruhniu

Copy link
Copy Markdown

Fixed

Comment thread dll/steam_client.cpp Outdated
Comment on lines +23 to +25
#if defined(_WIN32)
#include <windows.h>
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is already included here.

Comment thread dll/steam_client.cpp Outdated
#include "dll/steam_client.h"
#include "dll/settings_parser.h"
#include "dll/dll.h"
#include <optional>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is already included here.

Comment thread dll/steam_client.cpp Outdated
// On non-Windows platforms, always returns true (no focus-based pausing).
static bool is_game_focused()
{
#if defined(_WIN32)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it would be better to use __WINDOWS__ macro defined here.

Comment thread overlay_experimental/steam_overlay.cpp Outdated
unsigned total_m = static_cast<unsigned>((total_sec % 3600) / 60);

char total_buf[32]{};
char session_buf[32];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to forget initialization({}).

@NicknineTheEagle

Copy link
Copy Markdown
Collaborator

I remember playtime tracker also having a problem where playtime doesn't get saved properly when using steamclient.dll since Steam_Client destructor never gets called.

- 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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants