friendschat: readd user count

Also readd the Recent FCs title
This commit is contained in:
Adam
2021-05-23 13:34:54 -04:00
parent ed5d359320
commit 5de8eee04d
3 changed files with 28 additions and 14 deletions

View File

@@ -251,6 +251,8 @@ public class WidgetID
static class FriendsChat static class FriendsChat
{ {
static final int ROOT = 0;
static final int TITLE = 1;
static final int OWNER = 2; static final int OWNER = 2;
static final int LIST = 12; static final int LIST = 12;
} }

View File

@@ -126,6 +126,8 @@ public enum WidgetInfo
EXPLORERS_RING_ALCH_INVENTORY(WidgetID.EXPLORERS_RING_ALCH_GROUP_ID, WidgetID.ExplorersRing.INVENTORY), EXPLORERS_RING_ALCH_INVENTORY(WidgetID.EXPLORERS_RING_ALCH_GROUP_ID, WidgetID.ExplorersRing.INVENTORY),
FRIENDS_CHAT_ROOT(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.ROOT),
FRIENDS_CHAT_TITLE(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.TITLE),
FRIENDS_CHAT_OWNER(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.OWNER), FRIENDS_CHAT_OWNER(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.OWNER),
FRIENDS_CHAT_LIST(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.LIST), FRIENDS_CHAT_LIST(WidgetID.FRIENDS_CHAT_GROUP_ID, WidgetID.FriendsChat.LIST),

View File

@@ -96,6 +96,7 @@ import net.runelite.client.util.Text;
public class FriendsChatPlugin extends Plugin public class FriendsChatPlugin extends Plugin
{ {
private static final int MAX_CHATS = 10; private static final int MAX_CHATS = 10;
private static final String RECENT_TITLE = "Recent FCs";
private static final int MESSAGE_DELAY = 10; private static final int MESSAGE_DELAY = 10;
@Inject @Inject
@@ -157,7 +158,7 @@ public class FriendsChatPlugin extends Plugin
clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE)); clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE));
members.clear(); members.clear();
resetCounter(); resetCounter();
resetChats(); rebuildFriendsChat();
} }
@Subscribe @Subscribe
@@ -167,7 +168,7 @@ public class FriendsChatPlugin extends Plugin
{ {
if (!config.recentChats()) if (!config.recentChats())
{ {
resetChats(); rebuildFriendsChat();
} }
if (config.showCounter()) if (config.showCounter())
@@ -556,9 +557,19 @@ public class FriendsChatPlugin extends Plugin
@Subscribe @Subscribe
public void onScriptPostFired(ScriptPostFired event) public void onScriptPostFired(ScriptPostFired event)
{ {
if (event.getScriptId() == ScriptID.FRIENDS_CHAT_CHANNEL_REBUILD && config.showIgnores()) if (event.getScriptId() == ScriptID.FRIENDS_CHAT_CHANNEL_REBUILD)
{ {
colorIgnoredPlayers(config.showIgnoresColor()); if (config.showIgnores())
{
colorIgnoredPlayers(config.showIgnoresColor());
}
FriendsChatManager friendsChatManager = client.getFriendsChatManager();
Widget chatTitle = client.getWidget(WidgetInfo.FRIENDS_CHAT_TITLE);
if (friendsChatManager != null && friendsChatManager.getCount() > 0 && chatTitle != null)
{
chatTitle.setText(chatTitle.getText() + " (" + friendsChatManager.getCount() + "/100)");
}
} }
} }
@@ -589,30 +600,29 @@ public class FriendsChatPlugin extends Plugin
} }
} }
private void resetChats() private void rebuildFriendsChat()
{ {
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); Widget chat = client.getWidget(WidgetInfo.FRIENDS_CHAT_ROOT);
if (chat == null)
if (chatList == null)
{ {
return; return;
} }
FriendsChatManager friendsChatManager = client.getFriendsChatManager(); Object[] args = chat.getOnVarTransmitListener();
if (friendsChatManager == null || friendsChatManager.getCount() == 0) clientThread.invokeLater(() -> client.runScript(args));
{
chatList.setChildren(null);
}
} }
private void loadFriendsChats() private void loadFriendsChats()
{ {
Widget chatOwner = client.getWidget(WidgetInfo.FRIENDS_CHAT_OWNER);
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
if (chatList == null) if (chatList == null || chatOwner == null)
{ {
return; return;
} }
chatOwner.setText(RECENT_TITLE);
int y = 2; int y = 2;
chatList.setChildren(null); chatList.setChildren(null);
for (String chat : Lists.reverse(chats)) for (String chat : Lists.reverse(chats))