From 784eb1e4ec7f4dcff5d6c07b291328393616f535 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Thu, 6 Feb 2025 18:30:33 +0200 Subject: [PATCH] * Add guild folder name support --- src/discord/DiscordInstance.hpp | 31 +++++++++++++++++++++++++++++++ src/windows/GuildLister.cpp | 10 +++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/discord/DiscordInstance.hpp b/src/discord/DiscordInstance.hpp index 8dc8308..56f2552 100644 --- a/src/discord/DiscordInstance.hpp +++ b/src/discord/DiscordInstance.hpp @@ -261,6 +261,37 @@ class DiscordInstance sf.push_back(g.m_snowflake); } + std::string GetGuildFolderName(Snowflake sf) + { + auto items = m_guildItemList.GetItems(); + for (auto& item : *items) + { + if (item->GetID() != sf) + continue; + + auto name = item->GetName(); + if (!name.empty()) + return name; + + if (!item->IsFolder() || item->GetItems()->empty()) + return "Empty Folder"; + + name = ""; + auto subitems = item->GetItems(); + for (auto& subitem : *subitems) { + if (!name.empty()) + name += ", "; + name += subitem->GetName(); + } + + if (name.size() > 100) + name = name.substr(0, 97) + "..."; + return name; + } + + return "Unknown"; + } + void GetGuildIDsOrdered(std::vector& sf, bool bUI = false) { if (bUI) { diff --git a/src/windows/GuildLister.cpp b/src/windows/GuildLister.cpp index 4069e60..a7babbf 100644 --- a/src/windows/GuildLister.cpp +++ b/src/windows/GuildLister.cpp @@ -128,7 +128,7 @@ void GuildLister::UpdateTooltips() std::string name = ""; if (sf & BIT_FOLDER) { - name = "Server Folder"; + name = GetDiscordInstance()->GetGuildFolderName(sf & ~BIT_FOLDER); currentFolder = sf & ~BIT_FOLDER; if (sf == BIT_FOLDER) { @@ -518,13 +518,13 @@ void GuildLister::DrawServerIcon(HDC hdc, HBITMAP hicon, int& y, RECT& rect, Sno oldPen = SelectObject(hdc, GetStockObject(BLACK_PEN)); if (currentFolder == (id & ~BIT_FOLDER)) { - RoundRect(hdc, rcProfile.left, rcProfile.top, rcProfile.right, rcProfile.top + pfpBorderSize + amount, 10, 10); + RoundRect(hdc, rcProfile.left + 1, rcProfile.top + 1, rcProfile.right - 1, rcProfile.top - 1 + pfpBorderSize + amount, 10, 10); } else if (isLastItem) { - RoundRect(hdc, rcProfile.left, rcProfile.top - 15, rcProfile.right, rcProfile.top + pfpBorderSize, 10, 10); + RoundRect(hdc, rcProfile.left + 1, rcProfile.top - 14, rcProfile.right - 1, rcProfile.top - 1 + pfpBorderSize, 10, 10); } else { - RoundRect(hdc, rcProfile.left, rcProfile.top - 15, rcProfile.right, rcProfile.bottom + 15, 10, 10); + RoundRect(hdc, rcProfile.left + 1, rcProfile.top - 14, rcProfile.right - 1, rcProfile.bottom - 1 + 15, 10, 10); } SelectObject(hdc, oldPen); @@ -1076,7 +1076,7 @@ LRESULT CALLBACK GuildLister::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA if (sf & BIT_FOLDER) { - name = "Server Folder"; + name = ""; avatarlnk = ""; currentFolder = sf & ~BIT_FOLDER;