| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- diff --git a/src/ugc.rs b/src/ugc.rs
- index 653ab11..bb93239 100644
- --- a/src/ugc.rs
- +++ b/src/ugc.rs
- @@ -517,6 +517,14 @@ pub struct InstallInfo {
- pub timestamp: u32,
- }
-
- +#[derive(Clone, Copy, Debug)]
- +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
- +pub struct UserItemVote {
- + pub voted_up: bool,
- + pub voted_down: bool,
- + pub vote_skipped: bool,
- +}
- +
- impl<Manager> UGC<Manager> {
- /// Suspends or resumes all workshop downloads
- pub fn suspend_downloads(&self, suspend: bool) {
- @@ -617,6 +625,114 @@ impl<Manager> UGC<Manager> {
- }
- }
-
- + /// Sets the current user's vote (up or down) on a workshop item.
- + ///
- + /// {@link https://partner.steamgames.com/doc/api/ISteamUGC#SetUserItemVote}
- + pub fn vote_up_item<F>(&self, published_file_id: PublishedFileId, vote_up: bool, cb: F)
- + where
- + F: FnOnce(Result<(), SteamError>) + 'static + Send,
- + {
- + unsafe {
- + let api_call =
- + sys::SteamAPI_ISteamUGC_SetUserItemVote(self.ugc, published_file_id.0, vote_up);
- + register_call_result::<sys::SetUserItemVoteResult_t, _, _>(
- + &self.inner,
- + api_call,
- + CALLBACK_BASE_ID + 8,
- + move |v, io_error| {
- + cb(if io_error {
- + Err(SteamError::IOFailure)
- + } else if v.m_eResult != sys::EResult::k_EResultOK {
- + Err(v.m_eResult.into())
- + } else {
- + Ok(())
- + })
- + },
- + );
- + }
- + }
- +
- + /// Adds a workshop item to the current user's favorites list.
- + ///
- + /// {@link https://partner.steamgames.com/doc/api/ISteamUGC#AddItemToFavorites}
- + pub fn add_item_to_favorites<F>(&self, app_id: AppId, published_file_id: PublishedFileId, cb: F)
- + where
- + F: FnOnce(Result<(), SteamError>) + 'static + Send,
- + {
- + unsafe {
- + let api_call =
- + sys::SteamAPI_ISteamUGC_AddItemToFavorites(self.ugc, app_id.0, published_file_id.0);
- + self.register_favorites_result(api_call, cb);
- + }
- + }
- +
- + /// Removes a workshop item from the current user's favorites list.
- + ///
- + /// {@link https://partner.steamgames.com/doc/api/ISteamUGC#RemoveItemFromFavorites}
- + pub fn remove_item_from_favorites<F>(&self, app_id: AppId, published_file_id: PublishedFileId, cb: F)
- + where
- + F: FnOnce(Result<(), SteamError>) + 'static + Send,
- + {
- + unsafe {
- + let api_call = sys::SteamAPI_ISteamUGC_RemoveItemFromFavorites(
- + self.ugc,
- + app_id.0,
- + published_file_id.0,
- + );
- + self.register_favorites_result(api_call, cb);
- + }
- + }
- +
- + unsafe fn register_favorites_result<F>(&self, api_call: sys::SteamAPICall_t, cb: F)
- + where
- + F: FnOnce(Result<(), SteamError>) + 'static + Send,
- + {
- + register_call_result::<sys::UserFavoriteItemsListChanged_t, _, _>(
- + &self.inner,
- + api_call,
- + CALLBACK_BASE_ID + 7,
- + move |v, io_error| {
- + cb(if io_error {
- + Err(SteamError::IOFailure)
- + } else if v.m_eResult != sys::EResult::k_EResultOK {
- + Err(v.m_eResult.into())
- + } else {
- + Ok(())
- + })
- + },
- + );
- + }
- +
- + /// Gets the current user's existing vote (if any) on a workshop item.
- + ///
- + /// {@link https://partner.steamgames.com/doc/api/ISteamUGC#GetUserItemVote}
- + pub fn user_item_vote<F>(&self, published_file_id: PublishedFileId, cb: F)
- + where
- + F: FnOnce(Result<UserItemVote, SteamError>) + 'static + Send,
- + {
- + unsafe {
- + let api_call = sys::SteamAPI_ISteamUGC_GetUserItemVote(self.ugc, published_file_id.0);
- + register_call_result::<sys::GetUserItemVoteResult_t, _, _>(
- + &self.inner,
- + api_call,
- + CALLBACK_BASE_ID + 9,
- + move |v, io_error| {
- + cb(if io_error {
- + Err(SteamError::IOFailure)
- + } else if v.m_eResult != sys::EResult::k_EResultOK {
- + Err(v.m_eResult.into())
- + } else {
- + Ok(UserItemVote {
- + voted_up: v.m_bVotedUp,
- + voted_down: v.m_bVotedDown,
- + vote_skipped: v.m_bVoteSkipped,
- + })
- + })
- + },
- + );
- + }
- + }
- +
- /// Gets the publisher file IDs of all currently subscribed items.
- pub fn subscribed_items(&self) -> Vec<PublishedFileId> {
- unsafe {
|