diff --git a/components/chatwnd.c b/components/chatwnd.c index e6e3423..631c85e 100755 --- a/components/chatwnd.c +++ b/components/chatwnd.c @@ -234,11 +234,16 @@ LRESULT CALLBACK ChatWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, for (int i = 0; i < cwnd->uimsgcnt; i++) { RECT contr = {0, 0, clientRect.right - clientRect.left - 6 - 6 - 40, 0}; + if (strlen(cwnd->uimsgs[i].msg.content) == 0) { + msgdet[i].TextContentHeight = 0; + } + else{ DrawTextA(hdc, cwnd->uimsgs[i].msg.content, strlen(cwnd->uimsgs[i].msg.content), &contr, DT_CALCRECT | DT_WORDBREAK); - // printf("%i | %i\n", i, contr.bottom - contr.top); msgdet[i].TextContentHeight = contr.bottom - contr.top; + } + // printf("%i | %i\n", i, contr.bottom - contr.top); msgdet[i].StartMsg = IsStartMsg(cwnd, i); if (msgdet[i].StartMsg) { diff --git a/discordapi.h b/discordapi.h index a1e576b..4c60478 100755 --- a/discordapi.h +++ b/discordapi.h @@ -3,11 +3,12 @@ int DiscordSendMessage(const char *channelID, const char* content); int DiscordListGuildChannels(char* guildID, DiscordChannel** out); #define GUILD_TEXT 0 -#define DM_CHANNEL 1 +#define CHANNEL_DM 1 #define GUILD_VOICE 2 -#define GROUPCHAT_CHANNEL 3 +#define CHANNEL_GC 3 #define GUILD_CATEGORY 4 #define GUILD_ANNOUNCEMENT 5 +#define GUILD_FORUM 15 int DiscordGetChannelHistory(const char* channelID, unsigned int amount, DiscordMessage** msgs); char *DiscordFetchTmpPfp(char *userID, char *hash); char *DiscordFetchTmpGuildIcon(char *guildID, char *hash); diff --git a/main.c b/main.c index 10b79d9..16f1d43 100755 --- a/main.c +++ b/main.c @@ -72,9 +72,11 @@ int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, PSTR pCmdLine, InitSnowsControls(); hSidePfps = ImageList_Create(32, 32, ILC_COLOR32 | ILC_MASK, 12, 1); hChannelImgList = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 8, 1); + ImageList_AddMasked(hChannelImgList,LoadBitmap(hinstance,MAKEINTRESOURCE(IDI_CHANNEL_CATEGORY)),RGB(255,0,255)); ImageList_AddMasked(hChannelImgList,LoadBitmap(hinstance,MAKEINTRESOURCE(IDI_CHANNEL_TC)),RGB(255,0,255)); ImageList_AddMasked(hChannelImgList,LoadBitmap(hinstance,MAKEINTRESOURCE(IDI_CHANNEL_VC)),RGB(255,0,255)); ImageList_AddMasked(hChannelImgList,LoadBitmap(hinstance,MAKEINTRESOURCE(IDI_CHANNEL_ANC)),RGB(255,0,255)); + ImageList_AddMasked(hChannelImgList,LoadBitmap(hinstance,MAKEINTRESOURCE(IDI_CHANNEL_FORUM)),RGB(255,0,255)); hInstance = hinstance; // register the window claws const char CLASS_NAME[] = "BackcordMain"; @@ -391,7 +393,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, HTREEITEM hParent = TVI_ROOT; int pfpidx = 0; for (int i = 0; i < cnt; i++) { - if (dms[i].type == DM_CHANNEL) { + if (dms[i].type == CHANNEL_DM) { printf("%s\n", dms[i].receipents[0].Username); if (dms[i].receipents[0].avatar) { @@ -451,6 +453,7 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, DiscordChannel *Channels; int ChannelCount = DiscordListGuildChannels(guild->id, &Channels); + TreeView_SelectItem(hChTree, NULL); TreeView_DeleteAllItems(hChTree); //TreeView_SetImageList(hChTree, hChannelImgList, TVSIL_NORMAL); struct hashmap *ChannelUITable = @@ -480,13 +483,18 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, tvInsert.item.lParam = (LPARAM) & (Channels[i]); tvInsert.item.state = TVIS_EXPANDED; tvInsert.item.stateMask = TVIS_EXPANDED; - if(Channels[i].type==GUILD_VOICE){ - tvInsert.item.iImage=1; - }else if(Channels[i].type==GUILD_ANNOUNCEMENT){ - tvInsert.item.iImage=2; - }else{ + if(Channels[i].type==GUILD_CATEGORY){ tvInsert.item.iImage=0; } + else if(Channels[i].type==GUILD_VOICE){ + tvInsert.item.iImage=2; + }else if(Channels[i].type==GUILD_ANNOUNCEMENT){ + tvInsert.item.iImage=3; + }else if(Channels[i].type==GUILD_FORUM){ + tvInsert.item.iImage=4; + }else{ + tvInsert.item.iImage=1; + } HTREEITEM lres = (HTREEITEM)SendMessage( hChTree, TVM_INSERTITEM, 0, (LPARAM)&tvInsert); if (Channels[i].type == GUILD_CATEGORY) { @@ -503,9 +511,16 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, pnmv->itemNew.state & TVIS_SELECTED) { DiscordChannel *chnl = ((DiscordChannel *)pnmv->itemNew.lParam); if (chnl->type != GUILD_CATEGORY) { - char *title = malloc(13 + strlen(chnl->name)); + char *title = NULL; + if(chnl->type==CHANNEL_DM){ + title = malloc(12 + strlen(chnl->receipents[0].DisplayName)); + wsprintf(title, "Backcord - %s", chnl->receipents[0].DisplayName); + SetWindowTextA(hwnd, title); + }else{ + title = malloc(13 + strlen(chnl->name)); wsprintf(title, "Backcord - #%s", chnl->name); SetWindowTextA(hwnd, title); + } DiscordMessage *msgs; int msgcnt = DiscordGetChannelHistory(chnl->id, 50, &msgs); ClearChatControl(hMsgList); diff --git a/rc/category.bmp b/rc/category.bmp new file mode 100644 index 0000000..aeb6ff9 Binary files /dev/null and b/rc/category.bmp differ diff --git a/rc/forum.bmp b/rc/forum.bmp new file mode 100644 index 0000000..3a1bd34 Binary files /dev/null and b/rc/forum.bmp differ diff --git a/rc/res.h b/rc/res.h index e5da783..d63d211 100644 --- a/rc/res.h +++ b/rc/res.h @@ -2,4 +2,6 @@ #define IDI_BACKCORDBANNERIC 102 #define IDI_CHANNEL_TC 110 #define IDI_CHANNEL_VC 111 -#define IDI_CHANNEL_ANC 112 \ No newline at end of file +#define IDI_CHANNEL_ANC 112 +#define IDI_CHANNEL_FORUM 113 +#define IDI_CHANNEL_CATEGORY 114 \ No newline at end of file diff --git a/rc/res.o b/rc/res.o index 29e82c5..f11aee1 100644 Binary files a/rc/res.o and b/rc/res.o differ diff --git a/rc/res.rc b/rc/res.rc index 653de46..93f9f2c 100644 --- a/rc/res.rc +++ b/rc/res.rc @@ -2,6 +2,8 @@ IDI_BACKCORDIC RCDATA "backcord_icon.png" IDI_BACKCORDBANNERIC BITMAP "backcordbanner.bmp" +IDI_CHANNEL_CATEGORY BITMAP "category.bmp" IDI_CHANNEL_TC BITMAP "tc.bmp" IDI_CHANNEL_VC BITMAP "vc.bmp" -IDI_CHANNEL_ANC BITMAP "anc.bmp" \ No newline at end of file +IDI_CHANNEL_ANC BITMAP "anc.bmp" +IDI_CHANNEL_FORUM BITMAP "forum.bmp" \ No newline at end of file