Skip to content

Enable user_stats module for achievements and leaderboards#4

Merged
Jasper-Bekkers merged 1 commit intofor-traversefrom
Traverse-Research/enable-user-stats-module
Feb 26, 2026
Merged

Enable user_stats module for achievements and leaderboards#4
Jasper-Bekkers merged 1 commit intofor-traversefrom
Traverse-Research/enable-user-stats-module

Conversation

@Jasper-Bekkers
Copy link
Member

Summary

  • Enables the user_stats module which was previously commented out
  • Adapts the module to use the dynamic library loading pattern established in this fork
  • Adds missing callback struct definitions required for Steam API responses

Changes

src/lib.rs

  • Uncommented mod user_stats and pub use crate::user_stats::*
  • Added CString import for string handling
  • Added user_stats() method to Client implementation

src/user_stats.rs & src/user_stats/stats.rs

  • Updated all Steam API calls to use dynamic library pattern (self.inner.lib.SteamAPI_* instead of sys::SteamAPI_*)
  • For closures that need library access, cloned the lib Arc before capturing

steamworks-sys/src/lib.rs

  • Added 8 callback struct definitions missing from auto-generated bindings:
    • UserStatsReceived_t - callback for RequestCurrentStats
    • UserStatsStored_t - callback for StoreStats
    • UserAchievementStored_t - callback for achievement storage
    • UserAchievementIconFetched_t - callback for achievement icon fetch
    • LeaderboardFindResult_t - callback for FindLeaderboard
    • LeaderboardScoreUploaded_t - callback for UploadLeaderboardScore
    • LeaderboardScoresDownloaded_t - callback for DownloadLeaderboardEntries
    • GlobalAchievementPercentagesReady_t - callback for RequestGlobalAchievementPercentages

Features Enabled

  • Achievements: get/set/clear, display attributes, icons, global unlock percentages
  • Leaderboards: find, create, upload scores, download entries, get metadata (name, entry count, sort method, display type)
  • Stats: get/set i32 and f32 stats, store stats, reset all stats

Test plan

  • cargo check passes successfully
  • cargo fmt --all -- --check passes

🤖 Generated with Claude Code

- Uncomment user_stats module declaration and exports in lib.rs
- Add user_stats() method to Client implementation
- Update user_stats.rs to use dynamic library pattern (self.inner.lib.*)
- Update stats.rs achievement helper to use dynamic library pattern
- Add missing callback struct definitions to steamworks-sys:
  - UserStatsReceived_t, UserStatsStored_t, UserAchievementStored_t
  - UserAchievementIconFetched_t, LeaderboardFindResult_t
  - LeaderboardScoreUploaded_t, LeaderboardScoresDownloaded_t
  - GlobalAchievementPercentagesReady_t

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where do these bindings come from? How come they weren't generated to begin with?

@Jasper-Bekkers Jasper-Bekkers merged commit 6137cf7 into for-traverse Feb 26, 2026
9 checks passed
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.

3 participants