Struct steamworks::UserStats
source · pub struct UserStats<Manager> { /* private fields */ }
Expand description
Access to the steam user interface
Implementations§
source§impl<Manager> UserStats<Manager>
impl<Manager> UserStats<Manager>
pub fn find_leaderboard<F>(&self, name: &str, cb: F)
pub fn find_or_create_leaderboard<F>( &self, name: &str, sort_method: LeaderboardSortMethod, display_type: LeaderboardDisplayType, cb: F )
pub fn upload_leaderboard_score<F>( &self, leaderboard: &Leaderboard, method: UploadScoreMethod, score: i32, details: &[i32], cb: F )
pub fn download_leaderboard_entries<F>( &self, leaderboard: &Leaderboard, request: LeaderboardDataRequest, start: usize, end: usize, max_details_len: usize, cb: F )
sourcepub fn get_leaderboard_display_type(
&self,
leaderboard: &Leaderboard
) -> Option<LeaderboardDisplayType>
pub fn get_leaderboard_display_type( &self, leaderboard: &Leaderboard ) -> Option<LeaderboardDisplayType>
Returns the display type of a leaderboard handle. Returns None
if the leaderboard handle is invalid.
sourcepub fn get_leaderboard_sort_method(
&self,
leaderboard: &Leaderboard
) -> Option<LeaderboardSortMethod>
pub fn get_leaderboard_sort_method( &self, leaderboard: &Leaderboard ) -> Option<LeaderboardSortMethod>
Returns the sort method of a leaderboard handle. Returns None
if the leaderboard handle is invalid.
sourcepub fn get_leaderboard_name(&self, leaderboard: &Leaderboard) -> String
pub fn get_leaderboard_name(&self, leaderboard: &Leaderboard) -> String
Returns the name of a leaderboard handle. Returns an empty string if the leaderboard handle is invalid.
sourcepub fn get_leaderboard_entry_count(&self, leaderboard: &Leaderboard) -> i32
pub fn get_leaderboard_entry_count(&self, leaderboard: &Leaderboard) -> i32
Returns the total number of entries in a leaderboard. Returns 0 if the leaderboard handle is invalid.
sourcepub fn request_current_stats(&self)
pub fn request_current_stats(&self)
Triggers a UserStatsReceived
callback.
sourcepub fn request_global_achievement_percentages<F>(&self, cb: F)
pub fn request_global_achievement_percentages<F>(&self, cb: F)
Asynchronously fetch the data for the percentage of players who have received each achievement for the current game globally.
You must have called request_current_stats()
and it needs to return successfully via its
callback prior to calling this!*
*Note: Not sure if this is applicable, as the other achievement functions requiring
request_current_stats()
don’t specifically need it to be called in order for them to complete
successfully. Maybe it autoruns via Client::init()/init_app()
somehow?
sourcepub fn store_stats(&self) -> Result<(), ()>
pub fn store_stats(&self) -> Result<(), ()>
Send the changed stats and achievements data to the server for permanent storage.
- Triggers a
UserStatsStored
callback if successful. - Triggers a
UserAchievementStored
callback if achievements have been unlocked.
Requires request_current_stats()
to have been called
and a successful UserStatsReceived
callback processed.
sourcepub fn reset_all_stats(&self, achievements_too: bool) -> Result<(), ()>
pub fn reset_all_stats(&self, achievements_too: bool) -> Result<(), ()>
Resets the current users stats and, optionally achievements.
sourcepub fn get_stat_i32(&self, name: &str) -> Result<i32, ()>
pub fn get_stat_i32(&self, name: &str) -> Result<i32, ()>
Gets the value of a given stat for the current user
The specified stat must exist and match the type set on the Steamworks App Admin website.
Requires request_current_stats()
to have been called
and a successful UserStatsReceived
callback processed.
sourcepub fn set_stat_i32(&self, name: &str, stat: i32) -> Result<(), ()>
pub fn set_stat_i32(&self, name: &str, stat: i32) -> Result<(), ()>
Sets / updates the value of a given stat for the current user
This call only changes the value in-memory and is very cheap. To commit the stats you
must call store_stats()
The specified stat must exist and match the type set on the Steamworks App Admin website.
Requires request_current_stats()
to have been called
and a successful UserStatsReceived
callback processed.
sourcepub fn get_stat_f32(&self, name: &str) -> Result<f32, ()>
pub fn get_stat_f32(&self, name: &str) -> Result<f32, ()>
Gets the value of a given stat for the current user
The specified stat must exist and match the type set on the Steamworks App Admin website.
Requires request_current_stats()
to have been called
and a successful UserStatsReceived
callback processed.
sourcepub fn set_stat_f32(&self, name: &str, stat: f32) -> Result<(), ()>
pub fn set_stat_f32(&self, name: &str, stat: f32) -> Result<(), ()>
Sets / updates the value of a given stat for the current user
This call only changes the value in-memory and is very cheap. To commit the stats you
must call store_stats()
The specified stat must exist and match the type set on the Steamworks App Admin website.
Requires request_current_stats()
to have been called
and a successful UserStatsReceived
callback processed.
sourcepub fn achievement(&self, name: &str) -> AchievementHelper<'_, Manager>
pub fn achievement(&self, name: &str) -> AchievementHelper<'_, Manager>
Access achievement API for a given achievement ‘API Name’.
Requires request_current_stats()
to have been called
and a successful UserStatsReceived
callback processed.
sourcepub fn get_num_achievements(&self) -> Result<u32, ()>
pub fn get_num_achievements(&self) -> Result<u32, ()>
Get the number of achievements defined in the App Admin panel of the Steamworks website.
This is used for iterating through all of the achievements with GetAchievementName.
Returns 0 if the current App ID has no achievements.
Note: Returns an error for AppId 480
(Spacewar)!
sourcepub fn get_achievement_names(&self) -> Option<Vec<String>>
pub fn get_achievement_names(&self) -> Option<Vec<String>>
Returns an array of all achievement names for the current AppId.
Returns an empty string for an achievement name if iAchievement
is not a valid index,
and the current AppId must have achievements.