chatchannels: display online member count

Co-authored-by: Dasgust <dasgust@gmail.com>
This commit is contained in:
Adam
2021-12-13 17:38:30 -05:00
committed by Adam
parent 36e670112e
commit 62bb21a516
5 changed files with 87 additions and 0 deletions

View File

@@ -199,6 +199,12 @@ public final class ScriptID
@ScriptArguments(integer = 15)
public static final int FRIENDS_CHAT_CHANNEL_REBUILD = 1658;
/**
* Builds the widget that holds all of the players inside a clan chat
*/
@ScriptArguments(integer = 7)
public static final int CLAN_SIDEPANEL_DRAW = 4396;
/**
* Builds the widget for making an offer in Grand Exchange
*/

View File

@@ -921,11 +921,15 @@ public final class WidgetID
static class Clan
{
static final int LAYER = 0;
static final int HEADER = 1;
static final int MEMBERS = 6;
}
static class ClanGuest
{
static final int LAYER = 0;
static final int HEADER = 1;
static final int MEMBERS = 6;
}
}

View File

@@ -552,7 +552,12 @@ public enum WidgetInfo
TEMPOROSS_STATUS_INDICATOR(WidgetID.TEMPOROSS_GROUP_ID, WidgetID.TemporossStatus.STATUS_INDICATOR),
CLAN_LAYER(WidgetID.CLAN_GROUP_ID, WidgetID.Clan.LAYER),
CLAN_HEADER(WidgetID.CLAN_GROUP_ID, WidgetID.Clan.HEADER),
CLAN_MEMBER_LIST(WidgetID.CLAN_GROUP_ID, WidgetID.Clan.MEMBERS),
CLAN_GUEST_LAYER(WidgetID.CLAN_GUEST_GROUP_ID, WidgetID.ClanGuest.LAYER),
CLAN_GUEST_HEADER(WidgetID.CLAN_GUEST_GROUP_ID, WidgetID.ClanGuest.HEADER),
CLAN_GUEST_MEMBER_LIST(WidgetID.CLAN_GUEST_GROUP_ID, WidgetID.ClanGuest.MEMBERS),
POH_TREASURE_CHEST_INVENTORY_CONTAINER(WidgetID.POH_TREASURE_CHEST_INVENTORY_GROUP_ID, 0),

View File

@@ -206,6 +206,18 @@ public interface ChatChannelConfig extends Config
return false;
}
@ConfigItem(
keyName = "clanChatShowOnlineMemberCount",
name = "Show Online Member Count",
description = "Shows the number of online clan members at the end of the clan's name.",
position = 1,
section = clanChatSection
)
default boolean clanChatShowOnlineMemberCount()
{
return false;
}
@ConfigItem(
keyName = "guestClanChatShowJoinLeave",
name = "Show Join/Leave",
@@ -217,4 +229,16 @@ public interface ChatChannelConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "guestClanChatShowOnlineMemberCount",
name = "Show Online Member Count",
description = "Shows the number of online guest clan members at the end of the clan's name.",
position = 1,
section = guestClanChatSection
)
default boolean guestClanChatShowOnlineMemberCount()
{
return false;
}
}

View File

@@ -145,6 +145,8 @@ public class ChatChannelPlugin extends Plugin
{
clientThread.invoke(() -> colorIgnoredPlayers(config.showIgnoresColor()));
}
rebuildClanTitle();
}
@Override
@@ -153,6 +155,7 @@ public class ChatChannelPlugin extends Plugin
chats = null;
clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE));
rebuildFriendsChat();
rebuildClanTitle();
}
@Subscribe
@@ -167,6 +170,8 @@ public class ChatChannelPlugin extends Plugin
Color ignoreColor = config.showIgnores() ? config.showIgnoresColor() : Color.WHITE;
clientThread.invoke(() -> colorIgnoredPlayers(ignoreColor));
rebuildClanTitle();
}
}
@@ -606,6 +611,18 @@ public class ChatChannelPlugin extends Plugin
chatTitle.setText(chatTitle.getText() + " (" + friendsChatManager.getCount() + "/100)");
}
}
else if (event.getScriptId() == ScriptID.CLAN_SIDEPANEL_DRAW)
{
if (config.clanChatShowOnlineMemberCount())
{
updateClanTitle(WidgetInfo.CLAN_HEADER, client.getClanChannel());
}
if (config.guestClanChatShowOnlineMemberCount())
{
updateClanTitle(WidgetInfo.CLAN_GUEST_HEADER, client.getGuestClanChannel());
}
}
}
private void insertRankIcon(final ChatMessage message)
@@ -740,4 +757,35 @@ public class ChatChannelPlugin extends Plugin
listWidget.setTextColor(ignoreColor.getRGB());
}
}
private void rebuildClanTitle()
{
clientThread.invokeLater(() ->
{
Widget w = client.getWidget(WidgetInfo.CLAN_LAYER);
if (w != null)
{
client.runScript(w.getOnVarTransmitListener());
}
});
clientThread.invokeLater(() ->
{
Widget w = client.getWidget(WidgetInfo.CLAN_GUEST_LAYER);
if (w != null)
{
client.runScript(w.getOnVarTransmitListener());
}
});
}
private void updateClanTitle(WidgetInfo widget, ClanChannel channel)
{
Widget header = client.getWidget(widget);
if (header != null && channel != null)
{
Widget title = header.getChild(0);
title.setText(title.getText() + " (" + channel.getMembers().size() + ")");
}
}
}