Skip to content

Commit e7d4712

Browse files
CO2-codeMetadoriusSadPencil
authored
Add icon for +v (voice) on players to facilitate medals functionality for RA1 (CnCNet#851)
* Update AllianceHolder.cs * Update AllianceHolder.cs * Clienttype=RA * Update DXMainClient/Domain/Multiplayer/AllianceHolder.cs Co-authored-by: Kerbiter <[email protected]> * Update AllianceHolder.cs * removed space (line 117) * Reword the comment by Copilot * Fix incorrect allyHouseId for other games * Correct the indent * Correct the indent * Adjust for the fourth game type * Add steam init for red alert Co-authored-by: Kerbiter <[email protected]> * Quick Test. Ignore. * Update ChannelUser.cs * Update ChannelUser.cs * Update README.md * Create medal.png.png * Edits. unhardcoded medalIcon size, replaced HasMedal by HasVoice . * Edits . persistence of medal , (+v) has the same logic of (+o). Medalist (HasVoice) is under "Admin" in the Player list . * Update CnCNetManager.cs * Update CnCNetManager.cs * Update CnCNetManager.cs * Replace "medal" and "Medal" with "voice" and "Voice" . * voice.png * Update ChannelUser.cs * Update PlayerListBox.cs if voice.png isn't found skip drawing. * fix the missing texture case * clean up the branch code before merging --------- Co-authored-by: Kerbiter <[email protected]> Co-authored-by: SadPencil <[email protected]>
1 parent 9114d80 commit e7d4712

File tree

5 files changed

+37
-12
lines changed

5 files changed

+37
-12
lines changed

DXMainClient/DXGUI/Multiplayer/PlayerListBox.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public class PlayerListBox : XNAListBox
2525

2626
private Texture2D adminGameIcon;
2727
private Texture2D unknownGameIcon;
28-
private Texture2D badgeGameIcon;
2928
private Texture2D friendIcon;
3029
private Texture2D ignoreIcon;
30+
private Texture2D? voiceIcon;
3131

3232
private GameCollection gameCollection;
3333

@@ -45,7 +45,10 @@ public PlayerListBox(WindowManager windowManager, GameCollection gameCollection)
4545
unknownGameIcon = AssetLoader.TextureFromImage(Image.Load(unknownIconStream));
4646
friendIcon = AssetLoader.LoadTexture("friendicon.png");
4747
ignoreIcon = AssetLoader.LoadTexture("ignoreicon.png");
48-
badgeGameIcon = AssetLoader.LoadTexture("Badges/badge.png");
48+
49+
const string voiceIconName = "voiceicon.png";
50+
if (AssetLoader.AssetExists(voiceIconName))
51+
voiceIcon = AssetLoader.LoadTexture(voiceIconName);
4952
}
5053

5154
public void AddUser(ChannelUser user)
@@ -119,14 +122,14 @@ public override void Draw(GameTime gameTime)
119122
x += ignoreIcon.Width + MARGIN;
120123
}
121124

122-
// Badge Icon - coming soon
123-
/*
124-
Renderer.DrawTexture(badgeGameIcon,
125-
new Rectangle(windowRectangle.X + x, windowRectangle.Y + height,
126-
badgeGameIcon.Width, badgeGameIcon.Height), Color.White);
125+
// Voice Icon
126+
if (user.HasVoice && voiceIcon != null)
127+
{
128+
DrawTexture(voiceIcon,
129+
new Rectangle(x, height, voiceIcon.Width, voiceIcon.Height), Color.White);
127130

128-
x += badgeGameIcon.Width + margin;
129-
*/
131+
x += voiceIcon.Width + MARGIN;
132+
}
130133

131134
// Player Name
132135
string name = user.IsAdmin ? user.IRCUser.Name + " " + "(Admin)".L10N("Client:Main:AdminSuffix") : user.IRCUser.Name;
@@ -166,4 +169,4 @@ private void UpdateItemInfo(ChannelUser user, XNAListBoxItem item)
166169
}
167170
}
168171
}
169-
}
172+
}

DXMainClient/Online/ChannelUser.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,22 @@ public ChannelUser(IRCUser ircUser)
1717
public bool IsAdmin { get; set; }
1818

1919
public bool IsFriend { get; set; }
20+
21+
public bool HasVoice => IRCUser.HasVoice;
2022

2123
public static int ChannelUserComparison(ChannelUser u1, ChannelUser u2)
2224
{
2325
if (u1.IsAdmin != u2.IsAdmin)
2426
return u1.IsAdmin ? -1 : 1;
27+
28+
if (u1.HasVoice != u2.HasVoice)
29+
return u1.HasVoice ? -1 : 1;
2530

2631
if (u1.IsFriend != u2.IsFriend)
2732
return u1.IsFriend ? -1 : 1;
28-
33+
2934
return string.Compare(u1.IRCUser.Name, u2.IRCUser.Name, StringComparison.InvariantCultureIgnoreCase);
3035

3136
}
3237
}
33-
}
38+
}

DXMainClient/Online/CnCNetManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,17 @@ private void ApplyChannelModes(Channel channel, string modeString, List<string>
284284
break;
285285
user.IsAdmin = addMode;
286286
break;
287+
288+
// Add/remove voice status on user.
289+
case 'v':
290+
if (parameterCount >= modeParameters.Count)
291+
break;
292+
string vParam = modeParameters[parameterCount++];
293+
ChannelUser vUser = channel.Users.Find(vParam);
294+
if (vUser == null)
295+
break;
296+
vUser.IRCUser.HasVoice = addMode;
297+
break;
287298
}
288299
}
289300
}
@@ -739,14 +750,18 @@ private void DoUserListReceived(string channelName, string[] userList)
739750
{
740751
string name = userName;
741752
bool isAdmin = false;
753+
bool hasVoice = false;
742754

743755
if (userName.StartsWith("@"))
744756
{
745757
isAdmin = true;
746758
name = userName.Substring(1);
747759
}
748760
else if (userName.StartsWith("+"))
761+
{
762+
hasVoice = true;
749763
name = userName.Substring(1);
764+
}
750765

751766
// Check if we already know the IRC user from another channel
752767
IRCUser ircUser = UserList.Find(u => u.Name == name);
@@ -762,6 +777,7 @@ private void DoUserListReceived(string channelName, string[] userList)
762777
var channelUser = new ChannelUser(ircUser);
763778
channelUser.IsAdmin = isAdmin;
764779
channelUser.IsFriend = cncNetUserData.IsFriend(channelUser.IRCUser.Name);
780+
channelUser.IRCUser.HasVoice = hasVoice;
765781

766782
channelUserList.Add(channelUser);
767783
}

DXMainClient/Online/IRCUser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ public object Clone()
3636

3737
public bool IsFriend { get; set; }
3838
public bool IsIgnored { get; set; }
39+
public bool HasVoice { get; set; }
3940
}
4041
}
925 Bytes
Loading

0 commit comments

Comments
 (0)