Skip to content

Commit

Permalink
* Add guild folder name support
Browse files Browse the repository at this point in the history
  • Loading branch information
iProgramMC committed Feb 6, 2025
1 parent be3a360 commit 784eb1e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
31 changes: 31 additions & 0 deletions src/discord/DiscordInstance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Snowflake>& sf, bool bUI = false)
{
if (bUI) {
Expand Down
10 changes: 5 additions & 5 deletions src/windows/GuildLister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 784eb1e

Please sign in to comment.