void strreplaceall (xr_string &str, LPCSTR S, LPCSTR N) { LPCSTR A; int S_len = xr_strlen(S); while ((A = strstr(str.c_str(),S)) != 0) str.replace(A - str.c_str(),S_len,N); }
void CUILines::CutFirstColoredTextEntry(xr_string& entry, u32& color, xr_string& text) const { entry.clear(); StrSize begin = text.find(BEGIN); StrSize end = text.find(END, begin); if (xr_string::npos == end) begin = end; StrSize begin2 = text.find(BEGIN, end); StrSize end2 = text.find(END,begin2); if (xr_string::npos == end2) begin2 = end2; // if we do not have any color entry or it is single with 0 position if (xr_string::npos == begin) { entry = text; color = m_dwTextColor; text.clear(); } else if (0 == begin && xr_string::npos == begin2) { entry = text; color = GetColorFromText(entry); entry.replace(begin, end - begin + 1, ""); text.clear(); } // if we have color entry not at begin else if (0 != begin) { entry = text.substr(0, begin ); color = m_dwTextColor; text.replace(0, begin, ""); } // if we have two color entries. and first has 0 position else if (0 == begin && xr_string::npos != begin2) { entry = text.substr(0, begin2); color = GetColorFromText(entry); entry.replace(begin, end - begin + 1, ""); text.replace(0, begin2, ""); } }