aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Venner <[email protected]>2021-03-01 16:42:28 +0000
committerWilliam Venner <[email protected]>2021-03-01 16:42:28 +0000
commit9e5169c38ce31a610f731bd33e457f5e97eb880e (patch)
tree41e8710a563cbef1855260774ae043771de3949a
parentMerge pull request #31 from WilliamVenner/master (diff)
downloadsteamworks-rs-9e5169c38ce31a610f731bd33e457f5e97eb880e.tar.xz
steamworks-rs-9e5169c38ce31a610f731bd33e457f5e97eb880e.zip
Add steamworks::UGCStatisticType and add QueryResults::statistic (bindings for ISteamUGC::GetQueryUGCStatistic)
-rw-r--r--src/ugc.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/ugc.rs b/src/ugc.rs
index ade8a12..d54d391 100644
--- a/src/ugc.rs
+++ b/src/ugc.rs
@@ -201,6 +201,56 @@ impl Into<sys::EUserUGCList> for UserList {
}
}
+/// Available published item statistic types.
+#[derive(Debug,Clone,Copy,PartialEq,Eq)]
+pub enum UGCStatisticType {
+ /// The number of subscriptions.
+ Subscriptions,
+ /// The number of favorites.
+ Favorites,
+ /// The number of followers.
+ Followers,
+ /// The number of unique subscriptions.
+ UniqueSubscriptions,
+ /// The number of unique favorites.
+ UniqueFavorites,
+ /// The number of unique followers.
+ UniqueFollowers,
+ /// The number of unique views the item has on its Steam Workshop page.
+ UniqueWebsiteViews,
+ /// The number of times the item has been reported.
+ Reports,
+ /// The total number of seconds this item has been used across all players.
+ SecondsPlayed,
+ /// The total number of play sessions this item has been used in.
+ PlaytimeSessions,
+ /// The number of comments on the items steam has on its Steam Workshop page.
+ Comments,
+ /// The number of seconds this item has been used over the given time period.
+ SecondsPlayedDuringTimePeriod,
+ /// The number of sessions this item has been used in over the given time period.
+ PlaytimeSessionsDuringTimePeriod,
+}
+impl Into<sys::EItemStatistic> for UGCStatisticType {
+ fn into(self) -> sys::EItemStatistic {
+ match self {
+ UGCStatisticType::Subscriptions => sys::EItemStatistic::k_EItemStatistic_NumSubscriptions,
+ UGCStatisticType::Favorites => sys::EItemStatistic::k_EItemStatistic_NumFavorites,
+ UGCStatisticType::Followers => sys::EItemStatistic::k_EItemStatistic_NumFollowers,
+ UGCStatisticType::UniqueSubscriptions => sys::EItemStatistic::k_EItemStatistic_NumUniqueSubscriptions,
+ UGCStatisticType::UniqueFavorites => sys::EItemStatistic::k_EItemStatistic_NumUniqueFavorites,
+ UGCStatisticType::UniqueFollowers => sys::EItemStatistic::k_EItemStatistic_NumUniqueFollowers,
+ UGCStatisticType::UniqueWebsiteViews => sys::EItemStatistic::k_EItemStatistic_NumUniqueWebsiteViews,
+ UGCStatisticType::Reports => sys::EItemStatistic::k_EItemStatistic_ReportScore,
+ UGCStatisticType::SecondsPlayed => sys::EItemStatistic::k_EItemStatistic_NumSecondsPlayed,
+ UGCStatisticType::PlaytimeSessions => sys::EItemStatistic::k_EItemStatistic_NumPlaytimeSessions,
+ UGCStatisticType::Comments => sys::EItemStatistic::k_EItemStatistic_NumComments,
+ UGCStatisticType::SecondsPlayedDuringTimePeriod => sys::EItemStatistic::k_EItemStatistic_NumSecondsPlayedDuringTimePeriod,
+ UGCStatisticType::PlaytimeSessionsDuringTimePeriod => sys::EItemStatistic::k_EItemStatistic_NumPlaytimeSessionsDuringTimePeriod,
+ }
+ }
+}
+
bitflags! {
pub struct ItemState: u32 {
const NONE = 0;
@@ -745,6 +795,23 @@ impl<'a> QueryResults<'a> {
self.num_results_returned
}
+ /// Gets a UGC statistic about the published file at the specified index.
+ pub fn statistic(&self, index: u32, stat_type: UGCStatisticType) -> Option<u64> {
+ let mut value = 0u64;
+
+ let ok = unsafe {
+ sys::SteamAPI_ISteamUGC_GetQueryUGCStatistic(self.ugc, self.handle, index, stat_type.into(), &mut value)
+ };
+
+ debug_assert!(ok);
+
+ if ok {
+ Some(value)
+ } else {
+ None
+ }
+ }
+
/// Gets a result.
///
/// Returns None if index was out of bounds.