//----- (0044C51E) -------------------------------------------------------- int GUIFont::GetLineWidth(const char *pString) { int str_len; // ebp@3 int string_line_width; // esi@3 unsigned char c; if (!pString) return 0; str_len = strlen(pString); string_line_width = 0; for ( int i = 0; i < str_len; ++i ) { c = pString[i]; if (IsCharValid(c)) { switch (c) { case '\t': case '\n': case '\r': return string_line_width; case '\f': i += 5; break; default: if (i > 0) string_line_width += pMetrics[c].uLeftSpacing; string_line_width += pMetrics[c].uWidth; if (i < str_len) string_line_width +=pMetrics[c].uRightSpacing; } } } return string_line_width; }
//----- (0044C59D) -------------------------------------------------------- int GUIFont::CalcTextHeight( const char *pString, struct GUIWindow *pWindow, int uXOffset, int a5 ) { int uAllHeght; int uStringLen; unsigned char c; char *test_string; if (!pString) return 0; uAllHeght = uFontHeight - 6; test_string = FitTextInAWindow(pString, this, pWindow, uXOffset, 0); uStringLen = strlen(pString); for (int i = 0; i < uStringLen; ++i) { c = test_string[i]; if (IsCharValid(c)) { switch (c) { case '\n': //Line Feed 0A 10: uAllHeght += uFontHeight - 3; break; case '\f': //Form Feed, page eject 0C 12 i += 5; break; case '\t': // Horizontal tab 09 case '\r': //Carriage Return 0D 13 if (a5 != 1) i += 3; break; } } } return uAllHeght; }
//----- (0044D1E7) -------------------------------------------------------- void GUIFont::DrawTextLine( unsigned int uDefaultColor, signed int uX, signed int uY, const char *text, int max_len_pix ) { signed int uX_pos; // edi@3 unsigned char c; // cl@4 unsigned __int16 draw_color; // cx@12 unsigned __int8 *pCharPixels; // eax@12 char color_code[20]; // [sp+Ch] [bp-1Ch]@16 int text_length; // [sp+20h] [bp-8h]@2 int text_color; // [sp+24h] [bp-4h]@1 int uCharWidth; // [sp+30h] [bp+8h]@9 if ( !text ) return; text_color = ui_current_text_color; text_length = strlen(text); uX_pos=uX; for (int i=0; i<text_length; ++i ) { c = text[i]; if ( IsCharValid(c) ) { switch (c) { case '\n': //Line Feed 0A 10: return; break; case '\f': //Form Feed, page eject 0C 12 strncpy(color_code, &text[i + 1], 5); color_code[5] = 0; text_color = atoi(color_code); ui_current_text_color = text_color; i += 5; break; case '\t': // Horizontal tab 09 case '\r': //Carriage Return 0D 13 break; default: uCharWidth = pMetrics[c].uWidth; if ( uCharWidth ) { if ( i > 0 ) uX_pos += pMetrics[c].uLeftSpacing; draw_color = text_color; pCharPixels = &pFontData[font_pixels_offset[c]]; if ( !text_color ) draw_color = -1; pRenderer->DrawText(uX_pos, uY, pCharPixels, uCharWidth, uFontHeight, pFontPalettes[0], draw_color, 0); uX_pos += uCharWidth; if ( i < text_length ) uX_pos += pMetrics[c].uRightSpacing; } } } } }
bool AStarDungeon::LoadMap(const std::string mapFile) { std::ifstream file(mapFile); if (!file) return false; std::string line; bool foundStart = false; bool foundGoal = false; while (file >> line) { std::vector<char> mapRow; // each line represents a map row for (char c : line) { if (!IsCharValid(c)) return false; if (c == TileType::typeStart) { if (foundStart) // allow only one start { return false; } else { startNode.x = mapRow.size(); startNode.y = map.size(); foundStart = true; } } else if (c == TileType::typeGoal) { if (foundGoal) // allow only one goal { return false; } else { goalNode.x = mapRow.size(); goalNode.y = map.size(); foundGoal = true; } } mapRow.push_back(c); } map.push_back(mapRow); } mapLoaded = foundStart && foundGoal; return mapLoaded; }
bool CTeleport::RealizeTeleport() { ADDTOCALLSTACK("CTeleport::RealizeTeleport"); if ( ! IsCharValid() || ! m_ptDst.IsCharValid()) { DEBUG_ERR(( "CTeleport bad coords %s\n", WriteUsed() )); return false; } CSector *pSector = GetSector(); if ( pSector ) return pSector->AddTeleport(this); else return false; }
//----- (0044C6C2) -------------------------------------------------------- char* GUIFont::GetPageTop( const char *pInString, GUIWindow *pWindow, unsigned int uX, int a5 ) { int text_height; // edi@1 char *text_str; // ebx@3 unsigned char c; // cl@4 int text_length; text_height = 0; if ( !pInString ) return 0; text_str = FitTextInAWindow(pInString, this, pWindow, uX, 0); text_length = strlen(text_str); for ( int i = 0; i < text_length; ++i ) { c = text_str[i]; if ( IsCharValid(c) ) { switch (c) { case '\n': //Line Feed 0A 10: text_height = text_height + (uFontHeight - 3); if ( text_height >= (signed int)(a5 * (pWindow->uFrameHeight - (uFontHeight - 3))) ) return &text_str[i]; break; case '\f': //Form Feed, page eject 0C 12 i += 5; break; case '\t': // Horizontal tab 09 case '\r': //Carriage Return 0D 13 i += 3; break; } if ( text_height >= (signed int)(a5 * pWindow->uFrameHeight) ) break; } } return &text_str[0]; }
//----- (0044C62E) -------------------------------------------------------- int GUIFont::GetStringHeight2( GUIFont *secondFont, const char *text_str, GUIWindow* pWindow, int startX, int a6 ) { int uAllHeght; int uStringLen; unsigned char c; char *test_string; if ( !text_str ) return 0; uAllHeght = uFontHeight - 3; test_string = FitTwoFontStringINWindow(text_str, this, secondFont, pWindow, startX, 0); uStringLen = strlen(test_string); for (int i = 0; i < uStringLen; ++i) { c = test_string[i]; if (IsCharValid(c)) { switch (c) { case '\n': //Line Feed 0A 10: uAllHeght+= uFontHeight - 3; break; case '\f': //Form Feed, page eject 0C 12 i += 5; break; case '\t': // Horizontal tab 09 case '\r': //Carriage Return 0D 13 if (a6 != 1) i += 3; break; } } } return uAllHeght; }