void ChatLogMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) { // this function sets up the string into several single line structures //ScrollStringStPtr pStringSt; UINT32 uiFont = CHAT_MESSAGE_FONT; //STR16pString; va_list argptr; CHAR16 DestString[512]; WRAPPED_STRING *pStringWrapper=NULL; WRAPPED_STRING *pStringWrapperHead=NULL; BOOLEAN fNewString = FALSE; UINT16 usLineWidthIfWordIsWiderThenWidth; /*pStringSt=pStringS; while(GetNextString(pStringSt)) pStringSt=GetNextString(pStringSt);*/ va_start(argptr, pStringA); // Set up variable argument pointer vswprintf(DestString, pStringA, argptr); // process gprintf string (get output str) va_end(argptr); // send message to tactical screen and map screen ScreenMsg( usColor, ubPriority, DestString ); pStringWrapperHead=LineWrap(uiFont, CHAT_LINE_WIDTH, &usLineWidthIfWordIsWiderThenWidth, DestString); pStringWrapper=pStringWrapperHead; if(!pStringWrapper) return; fNewString = TRUE; while(pStringWrapper->pNextWrappedString!=NULL) { AddStringToChatLogMessageList(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority ); fNewString = FALSE; pStringWrapper=pStringWrapper->pNextWrappedString; } AddStringToChatLogMessageList(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority ); // clear up list of wrapped strings ClearWrappedStringsCHAT( pStringWrapperHead ); // play new message beep //PlayNewMessageSound( ); MoveToEndOfChatScreenMessageList( ); //LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__); }
void MultiLineTextView::typesetGlyphs(const std::string& str, const zeus::CColor& defaultColor, unsigned wrap) { if (wrap) { typesetGlyphs(LineWrap(str, wrap), defaultColor); return; } m_width = 0; m_lines.clear(); size_t rem = str.size() + 1; const utf8proc_uint8_t* it = reinterpret_cast<const utf8proc_uint8_t*>(str.data()); size_t lineCount = 0; while (rem) { utf8proc_int32_t ch; utf8proc_ssize_t sz = utf8proc_iterate(it, -1, &ch); if (sz < 0) Log.report(logvisor::Fatal, "invalid UTF-8 char"); if (ch == '\n' || ch == '\0') ++lineCount; rem -= sz; it += sz; } m_lines.reserve(lineCount); rem = str.size() + 1; it = reinterpret_cast<const utf8proc_uint8_t*>(str.data()); const utf8proc_uint8_t* beginIt = it; while (rem) { utf8proc_int32_t ch; utf8proc_ssize_t sz = utf8proc_iterate(it, -1, &ch); if (ch == '\n' || ch == '\0') { m_lines.emplace_back(new TextView(m_viewSystem, *this, m_fontAtlas, m_align, m_lineCapacity)); m_lines.back()->typesetGlyphs(std::string((char*)beginIt, it - beginIt), defaultColor); m_width = std::max(m_width, m_lines.back()->nominalWidth()); beginIt = it + 1; } rem -= sz; it += sz; } updateSize(); }
void MultiLineTextView::typesetGlyphs(const std::wstring& str, const zeus::CColor& defaultColor, unsigned wrap) { if (wrap) { typesetGlyphs(LineWrap(str, wrap), defaultColor); return; } m_width = 0; m_lines.clear(); size_t rem = str.size() + 1; auto it = str.cbegin(); size_t lineCount = 0; while (rem) { if (*it == L'\n' || *it == L'\0') ++lineCount; --rem; ++it; } m_lines.reserve(lineCount); rem = str.size() + 1; it = str.cbegin(); auto beginIt = it; while (rem) { if (*it == L'\n' || *it == L'\0') { m_lines.emplace_back(new TextView(m_viewSystem, *this, m_fontAtlas, m_align, m_lineCapacity)); m_lines.back()->typesetGlyphs(std::wstring(beginIt, it), defaultColor); m_width = std::max(m_width, m_lines.back()->nominalWidth()); beginIt = it + 1; } --rem; ++it; } updateSize(); }
void MapScreenMessage( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) { // this function sets up the string into several single line structures ScrollStringStPtr pStringSt; UINT32 uiFont = MAP_SCREEN_MESSAGE_FONT; UINT16 usPosition=0; UINT16 usCount=0; UINT16 usStringLength=0; UINT16 usCurrentSPosition=0; UINT16 usCurrentLookup=0; //wchar_t *pString; BOOLEAN fLastLine=FALSE; va_list argptr; wchar_t DestString[512], DestStringA[ 512 ]; //wchar_t *pStringBuffer; BOOLEAN fMultiLine=FALSE; WRAPPED_STRING *pStringWrapper=NULL; WRAPPED_STRING *pStringWrapperHead=NULL; BOOLEAN fNewString = FALSE; UINT16 usLineWidthIfWordIsWiderThenWidth; if( fDisableJustForIan == TRUE ) { if( ubPriority == MSG_BETAVERSION ) { return; } else if( ubPriority == MSG_TESTVERSION ) { return; } else if ( ubPriority == MSG_DEBUG ) { return; } } if( ubPriority == MSG_BETAVERSION ) { usColor = BETAVERSION_COLOR; #ifndef JA2BETAVERSION #ifndef JA2TESTVERSION return; #endif #endif WriteMessageToFile( DestString ); } if( ubPriority == MSG_TESTVERSION ) { usColor = TESTVERSION_COLOR; #ifndef JA2TESTVERSION return; #endif WriteMessageToFile( DestString ); } // OK, check if we are ani imeediate feedback message, if so, do something else! if ( ubPriority == MSG_UI_FEEDBACK ) { va_start(argptr, pStringA); // Set up variable argument pointer vswprintf(DestString, pStringA, argptr); // process gprintf string (get output str) va_end(argptr); BeginUIMessage( DestString ); return; } if ( ubPriority == MSG_SKULL_UI_FEEDBACK ) { va_start(argptr, pStringA); // Set up variable argument pointer vswprintf(DestString, pStringA, argptr); // process gprintf string (get output str) va_end(argptr); InternalBeginUIMessage( TRUE, DestString ); return; } // check if error if ( ubPriority == MSG_ERROR ) { va_start(argptr, pStringA); // Set up variable argument pointer vswprintf(DestString, pStringA, argptr); // process gprintf string (get output str) va_end(argptr); swprintf( DestStringA, L"DEBUG: %s", DestString ); BeginUIMessage( DestStringA ); WriteMessageToFile( DestStringA ); return; } // OK, check if we are an immediate MAP feedback message, if so, do something else! if ( ( ubPriority == MSG_MAP_UI_POSITION_UPPER ) || ( ubPriority == MSG_MAP_UI_POSITION_MIDDLE ) || ( ubPriority == MSG_MAP_UI_POSITION_LOWER ) ) { va_start(argptr, pStringA); // Set up variable argument pointer vswprintf(DestString, pStringA, argptr); // process gprintf string (get output str) va_end(argptr); BeginMapUIMessage( ubPriority, DestString ); return; } if ( fFirstTimeInMessageSystem ) { // Init display array! memset( gpDisplayList, 0, sizeof( gpDisplayList ) ); fFirstTimeInMessageSystem = FALSE; //if(!(InitializeMutex(SCROLL_MESSAGE_MUTEX,"ScrollMessageMutex" ))) // return; } pStringSt=pStringS; while(GetNextString(pStringSt)) pStringSt=GetNextString(pStringSt); va_start(argptr, pStringA); // Set up variable argument pointer vswprintf(DestString, pStringA, argptr); // process gprintf string (get output str) va_end(argptr); if ( ubPriority == MSG_DEBUG ) { #ifndef _DEBUG return; #endif #ifdef JA2DEMO return; #endif usColor = DEBUG_COLOR; wcscpy( DestStringA, DestString ); swprintf( DestString, L"Debug: %s", DestStringA ); } if ( ubPriority == MSG_DIALOG ) { usColor = DIALOGUE_COLOR; } if ( ubPriority == MSG_INTERFACE ) { usColor = INTERFACE_COLOR; } pStringWrapperHead=LineWrap(uiFont, MAP_LINE_WIDTH, &usLineWidthIfWordIsWiderThenWidth, DestString); pStringWrapper=pStringWrapperHead; if(!pStringWrapper) return; fNewString = TRUE; while(pStringWrapper->pNextWrappedString!=NULL) { AddStringToMapScreenMessageList(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority ); fNewString = FALSE; pStringWrapper=pStringWrapper->pNextWrappedString; } AddStringToMapScreenMessageList(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority ); // clear up list of wrapped strings ClearWrappedStrings( pStringWrapperHead ); // play new message beep //PlayNewMessageSound( ); MoveToEndOfMapScreenMessageList( ); //LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__); }
// new tactical and mapscreen message system void TacticalScreenMsg( UINT16 usColor, UINT8 ubPriority, STR16 pStringA, ... ) { // this function sets up the string into several single line structures ScrollStringStPtr pStringSt; UINT32 uiFont = TINYFONT1; UINT16 usPosition=0; UINT16 usCount=0; UINT16 usStringLength=0; UINT16 usCurrentSPosition=0; UINT16 usCurrentLookup=0; //wchar_t *pString; BOOLEAN fLastLine=FALSE; va_list argptr; wchar_t DestString[512], DestStringA[ 512 ]; //wchar_t *pStringBuffer; BOOLEAN fMultiLine=FALSE; ScrollStringStPtr pTempStringSt=NULL; WRAPPED_STRING *pStringWrapper=NULL; WRAPPED_STRING *pStringWrapperHead=NULL; BOOLEAN fNewString = FALSE; UINT16 usLineWidthIfWordIsWiderThenWidth=0; if( giTimeCompressMode > TIME_COMPRESS_X1 ) { return; } if( fDisableJustForIan == TRUE && ubPriority != MSG_ERROR && ubPriority != MSG_INTERFACE ) { return; } if( ubPriority == MSG_BETAVERSION ) { usColor = BETAVERSION_COLOR; #ifndef JA2BETAVERSION #ifndef JA2TESTVERSION return; #endif #endif WriteMessageToFile( DestString ); } if( ubPriority == MSG_TESTVERSION ) { usColor = TESTVERSION_COLOR; #ifndef JA2TESTVERSION return; #endif WriteMessageToFile( DestString ); } if ( fFirstTimeInMessageSystem ) { // Init display array! memset( gpDisplayList, 0, sizeof( gpDisplayList ) ); fFirstTimeInMessageSystem = FALSE; //if(!(InitializeMutex(SCROLL_MESSAGE_MUTEX,"ScrollMessageMutex" ))) // return; } pStringSt=pStringS; while(GetNextString(pStringSt)) pStringSt=GetNextString(pStringSt); va_start(argptr, pStringA); // Set up variable argument pointer vswprintf(DestString, pStringA, argptr); // process gprintf string (get output str) va_end(argptr); if ( ubPriority == MSG_DEBUG ) { #ifndef _DEBUG return; #endif #ifdef JA2DEMO return; #endif usColor = DEBUG_COLOR; wcscpy( DestStringA, DestString ); swprintf( DestString, L"Debug: %s", DestStringA ); WriteMessageToFile( DestStringA ); } if ( ubPriority == MSG_DIALOG ) { usColor = DIALOGUE_COLOR; } if ( ubPriority == MSG_INTERFACE ) { usColor = INTERFACE_COLOR; } pStringWrapperHead=LineWrap(uiFont, LINE_WIDTH, &usLineWidthIfWordIsWiderThenWidth, DestString); pStringWrapper=pStringWrapperHead; if(!pStringWrapper) return; fNewString = TRUE; while(pStringWrapper->pNextWrappedString!=NULL) { if(!pStringSt) { pStringSt=AddString(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority ); fNewString = FALSE; pStringSt->pNext=NULL; pStringSt->pPrev=NULL; pStringS=pStringSt; } else { pTempStringSt=AddString(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority); fNewString = FALSE; pTempStringSt->pPrev=pStringSt; pStringSt->pNext=pTempStringSt; pStringSt=pTempStringSt; pTempStringSt->pNext=NULL; } pStringWrapper=pStringWrapper->pNextWrappedString; } pTempStringSt=AddString(pStringWrapper->sString, usColor, uiFont, fNewString, ubPriority ); if(pStringSt) { pStringSt->pNext=pTempStringSt; pTempStringSt->pPrev=pStringSt; pStringSt=pTempStringSt; pStringSt->pNext=NULL; } else { pStringSt=pTempStringSt; pStringSt->pNext=NULL; pStringSt->pPrev=NULL; pStringS=pStringSt; } // clear up list of wrapped strings ClearWrappedStrings( pStringWrapperHead ); //LeaveMutex(SCROLL_MESSAGE_MUTEX, __LINE__, __FILE__); return; }