Added Workshop.Item.OwnerName

This commit is contained in:
Garry Newman 2016-10-21 14:51:43 +01:00
parent b4c48242cb
commit a92d680443
4 changed files with 43 additions and 1 deletions

View File

@ -56,6 +56,8 @@ namespace Facepunch.Steamworks
// //
Voice = new Voice( this ); Voice = new Voice( this );
Workshop.friends = Friends;
// //
// Cache common, unchanging info // Cache common, unchanging info

View File

@ -153,14 +153,27 @@ namespace Facepunch.Steamworks
} }
private int YourVote = 0;
public void VoteUp() public void VoteUp()
{ {
if ( YourVote == 1 ) return;
if ( YourVote == -1 ) VotesDown--;
VotesUp++;
workshop.ugc.SetUserItemVote( Id, true ); workshop.ugc.SetUserItemVote( Id, true );
YourVote = 1;
} }
public void VoteDown() public void VoteDown()
{ {
if ( YourVote == -1 ) return;
if ( YourVote == 1 ) VotesUp--;
VotesDown++;
workshop.ugc.SetUserItemVote( Id, false ); workshop.ugc.SetUserItemVote( Id, false );
YourVote = -1;
} }
public Editor Edit() public Editor Edit()
@ -188,6 +201,29 @@ namespace Facepunch.Steamworks
public int WebsiteViews { get; internal set; } public int WebsiteViews { get; internal set; }
public int ReportScore { get; internal set; } public int ReportScore { get; internal set; }
public string PreviewImageUrl { 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;
}
}
} }
} }
} }

View File

@ -52,6 +52,7 @@ namespace Facepunch.Steamworks
public int PerPage { get; set; } = SteamResponseSize; public int PerPage { get; set; } = SteamResponseSize;
internal Workshop workshop; internal Workshop workshop;
internal Friends friends;
private int _resultPage = 0; private int _resultPage = 0;
private int _resultsRemain = 0; private int _resultsRemain = 0;

View File

@ -10,6 +10,7 @@ namespace Facepunch.Steamworks
internal const ulong InvalidHandle = 0xffffffffffffffff; internal const ulong InvalidHandle = 0xffffffffffffffff;
internal ISteamUGC ugc; internal ISteamUGC ugc;
internal Friends friends;
internal BaseSteamworks steamworks; internal BaseSteamworks steamworks;
internal ISteamRemoteStorage remoteStorage; internal ISteamRemoteStorage remoteStorage;
@ -31,6 +32,7 @@ namespace Facepunch.Steamworks
ugc = null; ugc = null;
steamworks = null; steamworks = null;
remoteStorage = null; remoteStorage = null;
friends = null;
OnFileDownloaded = null; OnFileDownloaded = null;
OnItemInstalled = null; OnItemInstalled = null;
@ -53,7 +55,8 @@ namespace Facepunch.Steamworks
return new Query() return new Query()
{ {
AppId = steamworks.AppId, AppId = steamworks.AppId,
workshop = this workshop = this,
friends = friends
}; };
} }