From 8ed1a9382f88102f1a77a392a4ec43e60647e7e9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 13 Nov 2017 21:46:58 +0300 Subject: fixes (#1010) tabsrmm group chat colors regression (#1010) --- plugins/TabSRMM/src/chat_log.cpp | 5 +++++ plugins/TabSRMM/src/chat_window.cpp | 1 - plugins/TabSRMM/src/msgdlgutils.cpp | 27 ++++++++++++++++++++------- plugins/TabSRMM/src/utils.cpp | 17 +++++++++++++---- 4 files changed, 38 insertions(+), 12 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp index 2211f60496..17d70dbe04 100644 --- a/plugins/TabSRMM/src/chat_log.cpp +++ b/plugins/TabSRMM/src/chat_log.cpp @@ -654,6 +654,11 @@ char* Log_CreateRtfHeader(void) for (int i = 0; i < OPTIONS_FONTCOUNT; i++) str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color)); + for (int i = 0; i < Utils::rtf_clrs.getCount(); i++) { + COLORREF clr = Utils::rtf_clrs[i].clr; + str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(clr), GetGValue(clr), GetBValue(clr)); + } + for (int i = 0; i < STATUSICONCOUNT; i++) str.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(g_Settings.nickColors[i]), GetGValue(g_Settings.nickColors[i]), GetBValue(g_Settings.nickColors[i])); diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp index 9ac5627bac..9db44118f1 100644 --- a/plugins/TabSRMM/src/chat_window.cpp +++ b/plugins/TabSRMM/src/chat_window.cpp @@ -641,7 +641,6 @@ void CChatRoomDlg::onClick_OK(CCtrlButton*) DoRtfToTags(ptszText); ptszText.Trim(); - ptszText.Replace(L"%", L"%%"); if (mi->bAckMsg) { m_message.Enable(false); diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index 21924f7c9a..267374f850 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -885,17 +885,23 @@ BOOL CTabBaseDlg::DoRtfToTags(CMStringW &pszText) const if (iCol > 0) { if (!isChat()) res.AppendFormat((iInd >= 0) ? (bInsideColor ? L"[/color][color=%s]" : L"[color=%s]") : (bInsideColor ? L"[/color]" : L""), Utils::rtf_clrs[iInd].szName); - // else - // res.AppendFormat((iInd >= 0) ? L"%%c%02u" : L"%%C", iInd); + else { + MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + if (mi && mi->bColor) + res.AppendFormat((iInd >= 0) ? L"%%c%u" : L"%%C", iInd); + } } bInsideColor = iInd >= 0; } - else if (!wcsncmp(p, L"\\highlight", 10)) { //background color - /* if (isChat()) { - int iInd = RtfColorToIndex(iNumColors, pIndex, _wtoi(p + 10)); - res.AppendFormat((iInd >= 0) ? L"%%f%02u" : L"%%F", iInd); - } */ + else if (!wcsncmp(p, L"\\highlight", 10)) { // background color + if (isChat()) { + MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + if (mi && mi->bBkgColor) { + int iInd = RtfColorToIndex(iNumColors, pIndex, _wtoi(p + 10)); + res.AppendFormat((iInd >= 0) ? L"%%f%u" : L"%%F", iInd); + } + } } else if (!wcsncmp(p, L"\\line", 5)) { // soft line break; res.AppendChar('\n'); @@ -980,6 +986,13 @@ BOOL CTabBaseDlg::DoRtfToTags(CMStringW &pszText) const p++; break; + case '%': // double % for stupid chat engine + if (isChat()) + res.Append(L"%%"); + else + res.AppendChar(*p++); + break; + default: // other text that should not be touched res.AppendChar(*p++); break; diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index aa4110c804..6c6c3e2bab 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -416,13 +416,22 @@ int CTabBaseDlg::FindRTLLocale() static TRTFColorTable _rtf_ctable[] = { - { L"red", RGB(255, 0, 0), ID_FONT_RED }, + { L"black", 0, ID_FONT_BLACK }, + { L"", RGB(0,0,128), -1 }, + { L"", RGB(0,128,128), -1 }, + { L"", RGB(128,0,128), -1 }, + { L"", RGB(0,128,0), -1 }, + { L"", RGB(128,128,0), -1 }, + { L"", RGB(128,0,0), -1 }, + { L"", RGB(128,128,128), -1 }, + + { L"", RGB(192,192,192), -1 }, { L"blue", RGB(0, 0, 255), ID_FONT_BLUE }, - { L"green", RGB(0, 255, 0), ID_FONT_GREEN }, + { L"cyan", RGB(0, 255, 255), ID_FONT_CYAN }, { L"magenta", RGB(255, 0, 255), ID_FONT_MAGENTA }, + { L"green", RGB(0, 255, 0), ID_FONT_GREEN }, { L"yellow", RGB(255, 255, 0), ID_FONT_YELLOW }, - { L"cyan", RGB(0, 255, 255), ID_FONT_CYAN }, - { L"black", 0, ID_FONT_BLACK }, + { L"red", RGB(255, 0, 0), ID_FONT_RED }, { L"white", RGB(255, 255, 255), ID_FONT_WHITE } }; -- cgit v1.2.3