@@ -11,6 +11,9 @@ namespace DiscordRPC
11
11
[ Serializable ]
12
12
public class Assets
13
13
{
14
+ private const string EXTERNAL_KEY_PREFIX = "mp:external" ;
15
+
16
+ #region Large Image
14
17
/// <summary>
15
18
/// Name of the uploaded image for the large profile artwork.
16
19
/// <para>Max 256 characters.</para>
@@ -25,25 +28,12 @@ public string LargeImageKey
25
28
if ( ! BaseRichPresence . ValidateString ( value , out _largeimagekey , false , 256 ) )
26
29
throw new StringOutOfRangeException ( 256 ) ;
27
30
28
- //Get if this is a external link
29
- _islargeimagekeyexternal = _largeimagekey ? . StartsWith ( "mp:external/" ) ?? false ;
30
-
31
31
//Reset the large image ID
32
- _largeimageID = null ;
32
+ LargeImageID = null ;
33
33
}
34
34
}
35
35
private string _largeimagekey ;
36
36
37
- /// <summary>
38
- /// Gets if the large square image is from an external link
39
- /// </summary>
40
- [ JsonIgnore ]
41
- public bool IsLargeImageKeyExternal
42
- {
43
- get { return _islargeimagekeyexternal ; }
44
- }
45
- private bool _islargeimagekeyexternal ;
46
-
47
37
/// <summary>
48
38
/// The tooltip for the large square image. For example, "Summoners Rift" or "Horizon Lunar Colony".
49
39
/// <para>Max 128 characters.</para>
@@ -79,6 +69,20 @@ public string LargeImageUrl
79
69
}
80
70
private string _largeimageurl ;
81
71
72
+ /// <summary>
73
+ /// The ID of the large image. This is only set after Update Presence and will automatically become null when <see cref="LargeImageKey"/> is changed.
74
+ /// </summary>
75
+ [ JsonIgnore ]
76
+ public string LargeImageID { get ; private set ; }
77
+
78
+ /// <summary>
79
+ /// Gets if the large square image is from an external link
80
+ /// </summary>
81
+ [ JsonIgnore ]
82
+ public bool IsLargeImageKeyExternal { get ; private set ; }
83
+ #endregion
84
+
85
+ #region Small Image
82
86
/// <summary>
83
87
/// Name of the uploaded image for the small profile artwork.
84
88
/// <para>Max 256 characters.</para>
@@ -93,25 +97,12 @@ public string SmallImageKey
93
97
if ( ! BaseRichPresence . ValidateString ( value , out _smallimagekey , false , 256 ) )
94
98
throw new StringOutOfRangeException ( 256 ) ;
95
99
96
- //Get if this is a external link
97
- _issmallimagekeyexternal = _smallimagekey ? . StartsWith ( "mp:external/" ) ?? false ;
98
-
99
100
//Reset the small image id
100
- _smallimageID = null ;
101
+ SmallImageID = null ;
101
102
}
102
103
}
103
104
private string _smallimagekey ;
104
105
105
- /// <summary>
106
- /// Gets if the small profile artwork is from an external link
107
- /// </summary>
108
- [ JsonIgnore ]
109
- public bool IsSmallImageKeyExternal
110
- {
111
- get { return _issmallimagekeyexternal ; }
112
- }
113
- private bool _issmallimagekeyexternal ;
114
-
115
106
/// <summary>
116
107
/// The tooltip for the small circle image. For example, "LvL 6" or "Ultimate 85%".
117
108
/// <para>Max 128 characters.</para>
@@ -148,18 +139,18 @@ public string SmallImageUrl
148
139
private string _smallimageurl ;
149
140
150
141
/// <summary>
151
- /// The ID of the large image. This is only set after Update Presence and will automatically become null when <see cref="LargeImageKey "/> is changed.
142
+ /// The ID of the small image. This is only set after Update Presence and will automatically become null when <see cref="SmallImageKey "/> is changed.
152
143
/// </summary>
153
144
[ JsonIgnore ]
154
- public ulong ? LargeImageID { get { return _largeimageID ; } }
155
- private ulong ? _largeimageID ;
145
+ public string SmallImageID { get ; private set ; }
156
146
157
147
/// <summary>
158
- /// The ID of the small image. This is only set after Update Presence and will automatically become null when <see cref="SmallImageKey"/> is changed.
148
+ /// Gets if the small profile artwork is from an external link
159
149
/// </summary>
160
150
[ JsonIgnore ]
161
- public ulong ? SmallImageID { get { return _smallimageID ; } }
162
- private ulong ? _smallimageID ;
151
+ public bool IsSmallImageKeyExternal { get ; private set ; }
152
+ #endregion
153
+
163
154
164
155
/// <summary>
165
156
/// Merges this asset with the other, taking into account for ID's instead of keys.
@@ -173,30 +164,42 @@ internal void Merge(Assets other)
173
164
_largeimagetext = other . _largeimagetext ;
174
165
_largeimageurl = other . _largeimageurl ;
175
166
176
- //Convert large ID
177
- ulong largeID ;
178
- if ( ulong . TryParse ( other . _largeimagekey , out largeID ) )
167
+ //Convert the Large Key
168
+ if ( other . _largeimagekey . StartsWith ( EXTERNAL_KEY_PREFIX ) )
179
169
{
180
- _largeimageID = largeID ;
170
+ IsLargeImageKeyExternal = true ;
171
+ LargeImageID = other . _largeimagekey ;
172
+ }
173
+ else if ( ulong . TryParse ( other . _largeimagekey , out _ ) )
174
+ {
175
+ IsLargeImageKeyExternal = false ;
176
+ LargeImageID = other . _largeimagekey ;
181
177
}
182
178
else
183
179
{
180
+ IsLargeImageKeyExternal = false ;
181
+ LargeImageID = null ;
184
182
_largeimagekey = other . _largeimagekey ;
185
- _largeimageID = null ;
186
183
}
187
184
188
- //Convert the small ID
189
- ulong smallID ;
190
- if ( ulong . TryParse ( other . _smallimagekey , out smallID ) )
185
+ //Convert the Small Key
186
+ // TODO: Make this a function
187
+ if ( other . _smallimagekey . StartsWith ( EXTERNAL_KEY_PREFIX ) )
188
+ {
189
+ IsSmallImageKeyExternal = true ;
190
+ SmallImageID = other . _smallimagekey ;
191
+ }
192
+ else if ( ulong . TryParse ( other . _smallimagekey , out _ ) )
191
193
{
192
- _smallimageID = smallID ;
194
+ IsSmallImageKeyExternal = false ;
195
+ SmallImageID = other . _smallimagekey ;
193
196
}
194
197
else
195
198
{
199
+ IsSmallImageKeyExternal = false ;
200
+ SmallImageID = null ;
196
201
_smallimagekey = other . _smallimagekey ;
197
- _smallimageID = null ;
198
202
}
199
203
}
200
204
}
201
-
202
205
}
0 commit comments