Skip to content

Commit 784eb1e

Browse files
committed
* Add guild folder name support
1 parent be3a360 commit 784eb1e

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

src/discord/DiscordInstance.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,37 @@ class DiscordInstance
261261
sf.push_back(g.m_snowflake);
262262
}
263263

264+
std::string GetGuildFolderName(Snowflake sf)
265+
{
266+
auto items = m_guildItemList.GetItems();
267+
for (auto& item : *items)
268+
{
269+
if (item->GetID() != sf)
270+
continue;
271+
272+
auto name = item->GetName();
273+
if (!name.empty())
274+
return name;
275+
276+
if (!item->IsFolder() || item->GetItems()->empty())
277+
return "Empty Folder";
278+
279+
name = "";
280+
auto subitems = item->GetItems();
281+
for (auto& subitem : *subitems) {
282+
if (!name.empty())
283+
name += ", ";
284+
name += subitem->GetName();
285+
}
286+
287+
if (name.size() > 100)
288+
name = name.substr(0, 97) + "...";
289+
return name;
290+
}
291+
292+
return "Unknown";
293+
}
294+
264295
void GetGuildIDsOrdered(std::vector<Snowflake>& sf, bool bUI = false)
265296
{
266297
if (bUI) {

src/windows/GuildLister.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void GuildLister::UpdateTooltips()
128128
std::string name = "";
129129
if (sf & BIT_FOLDER)
130130
{
131-
name = "Server Folder";
131+
name = GetDiscordInstance()->GetGuildFolderName(sf & ~BIT_FOLDER);
132132
currentFolder = sf & ~BIT_FOLDER;
133133

134134
if (sf == BIT_FOLDER) {
@@ -518,13 +518,13 @@ void GuildLister::DrawServerIcon(HDC hdc, HBITMAP hicon, int& y, RECT& rect, Sno
518518
oldPen = SelectObject(hdc, GetStockObject(BLACK_PEN));
519519

520520
if (currentFolder == (id & ~BIT_FOLDER)) {
521-
RoundRect(hdc, rcProfile.left, rcProfile.top, rcProfile.right, rcProfile.top + pfpBorderSize + amount, 10, 10);
521+
RoundRect(hdc, rcProfile.left + 1, rcProfile.top + 1, rcProfile.right - 1, rcProfile.top - 1 + pfpBorderSize + amount, 10, 10);
522522
}
523523
else if (isLastItem) {
524-
RoundRect(hdc, rcProfile.left, rcProfile.top - 15, rcProfile.right, rcProfile.top + pfpBorderSize, 10, 10);
524+
RoundRect(hdc, rcProfile.left + 1, rcProfile.top - 14, rcProfile.right - 1, rcProfile.top - 1 + pfpBorderSize, 10, 10);
525525
}
526526
else {
527-
RoundRect(hdc, rcProfile.left, rcProfile.top - 15, rcProfile.right, rcProfile.bottom + 15, 10, 10);
527+
RoundRect(hdc, rcProfile.left + 1, rcProfile.top - 14, rcProfile.right - 1, rcProfile.bottom - 1 + 15, 10, 10);
528528
}
529529

530530
SelectObject(hdc, oldPen);
@@ -1076,7 +1076,7 @@ LRESULT CALLBACK GuildLister::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
10761076

10771077
if (sf & BIT_FOLDER)
10781078
{
1079-
name = "Server Folder";
1079+
name = "";
10801080
avatarlnk = "";
10811081

10821082
currentFolder = sf & ~BIT_FOLDER;

0 commit comments

Comments
 (0)