diff --git a/Facepunch.Steamworks/Client.cs b/Facepunch.Steamworks/Client.cs index 587bc8e..b5f0a80 100644 --- a/Facepunch.Steamworks/Client.cs +++ b/Facepunch.Steamworks/Client.cs @@ -56,6 +56,8 @@ public Client( uint appId ) // Voice = new Voice( this ); + Workshop.friends = Friends; + // // Cache common, unchanging info diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Item.cs b/Facepunch.Steamworks/Interfaces/Workshop.Item.cs index 6e1deab..39cf4d9 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.Item.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.Item.cs @@ -153,14 +153,27 @@ internal void UpdateState() } + private int YourVote = 0; + + public void VoteUp() { + if ( YourVote == 1 ) return; + if ( YourVote == -1 ) VotesDown--; + + VotesUp++; workshop.ugc.SetUserItemVote( Id, true ); + YourVote = 1; } public void VoteDown() { + if ( YourVote == -1 ) return; + if ( YourVote == 1 ) VotesUp--; + + VotesDown++; workshop.ugc.SetUserItemVote( Id, false ); + YourVote = -1; } public Editor Edit() @@ -188,6 +201,29 @@ public Editor Edit() public int WebsiteViews { get; internal set; } public int ReportScore { get; internal set; } public string PreviewImageUrl { get; internal set; } + + string _ownerName = null; + + public string OwnerName + { + get + { + if ( _ownerName == null && workshop.friends != null ) + { + _ownerName = workshop.friends.GetName( OwnerId ); + if ( _ownerName == "[unknown]" ) + { + _ownerName = null; + return string.Empty; + } + } + + if ( _ownerName == null ) + return string.Empty; + + return _ownerName; + } + } } } } diff --git a/Facepunch.Steamworks/Interfaces/Workshop.Query.cs b/Facepunch.Steamworks/Interfaces/Workshop.Query.cs index c193b43..8819ef8 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.Query.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.Query.cs @@ -52,6 +52,7 @@ public class Query : IDisposable public int PerPage { get; set; } = SteamResponseSize; internal Workshop workshop; + internal Friends friends; private int _resultPage = 0; private int _resultsRemain = 0; diff --git a/Facepunch.Steamworks/Interfaces/Workshop.cs b/Facepunch.Steamworks/Interfaces/Workshop.cs index ccb1321..7ec4b0c 100644 --- a/Facepunch.Steamworks/Interfaces/Workshop.cs +++ b/Facepunch.Steamworks/Interfaces/Workshop.cs @@ -10,6 +10,7 @@ public partial class Workshop : IDisposable internal const ulong InvalidHandle = 0xffffffffffffffff; internal ISteamUGC ugc; + internal Friends friends; internal BaseSteamworks steamworks; internal ISteamRemoteStorage remoteStorage; @@ -31,6 +32,7 @@ public void Dispose() ugc = null; steamworks = null; remoteStorage = null; + friends = null; OnFileDownloaded = null; OnItemInstalled = null; @@ -53,7 +55,8 @@ public Query CreateQuery() return new Query() { AppId = steamworks.AppId, - workshop = this + workshop = this, + friends = friends }; }