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 final int ROOT = 0;
static final int TITLE = 1;
static final int OWNER = 2;
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),
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_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
{
private static final int MAX_CHATS = 10;
private static final String RECENT_TITLE = "Recent FCs";
private static final int MESSAGE_DELAY = 10;
@Inject
@@ -157,7 +158,7 @@ public class FriendsChatPlugin extends Plugin
clientThread.invoke(() -> colorIgnoredPlayers(Color.WHITE));
members.clear();
resetCounter();
resetChats();
rebuildFriendsChat();
}
@Subscribe
@@ -167,7 +168,7 @@ public class FriendsChatPlugin extends Plugin
{
if (!config.recentChats())
{
resetChats();
rebuildFriendsChat();
}
if (config.showCounter())
@@ -556,9 +557,19 @@ public class FriendsChatPlugin extends Plugin
@Subscribe
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);
if (chatList == null)
Widget chat = client.getWidget(WidgetInfo.FRIENDS_CHAT_ROOT);
if (chat == null)
{
return;
}
FriendsChatManager friendsChatManager = client.getFriendsChatManager();
if (friendsChatManager == null || friendsChatManager.getCount() == 0)
{
chatList.setChildren(null);
}
Object[] args = chat.getOnVarTransmitListener();
clientThread.invokeLater(() -> client.runScript(args));
}
private void loadFriendsChats()
{
Widget chatOwner = client.getWidget(WidgetInfo.FRIENDS_CHAT_OWNER);
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
if (chatList == null)
if (chatList == null || chatOwner == null)
{
return;
}
chatOwner.setText(RECENT_TITLE);
int y = 2;
chatList.setChildren(null);
for (String chat : Lists.reverse(chats))