* 0x004955BC * * @param buffer @ * @return width @ */
| 1816 | * @return width @<cx> |
| 1817 | */ |
| 1818 | static uint16_t getMaxStringWidth(Font font, const char* str) |
| 1819 | { |
| 1820 | uint16_t width = 0; |
| 1821 | uint16_t maxWidth = 0; |
| 1822 | |
| 1823 | while (*str != '\0') |
| 1824 | { |
| 1825 | const auto chr = static_cast<uint8_t>(*str); |
| 1826 | str++; |
| 1827 | |
| 1828 | if (chr >= 32) |
| 1829 | { |
| 1830 | width += Gfx::getCharacterWidth(font, chr); |
| 1831 | continue; |
| 1832 | } |
| 1833 | |
| 1834 | switch (chr) |
| 1835 | { |
| 1836 | case ControlCodes::moveX: |
| 1837 | maxWidth = std::max(width, maxWidth); |
| 1838 | width = *str; |
| 1839 | str++; |
| 1840 | break; |
| 1841 | |
| 1842 | case ControlCodes::adjustPalette: |
| 1843 | case 3: |
| 1844 | case 4: |
| 1845 | str++; |
| 1846 | break; |
| 1847 | |
| 1848 | case ControlCodes::newline: |
| 1849 | case ControlCodes::newlineSmaller: |
| 1850 | continue; |
| 1851 | |
| 1852 | case ControlCodes::Font::small: |
| 1853 | font = Font::small; |
| 1854 | break; |
| 1855 | |
| 1856 | case ControlCodes::Font::large: |
| 1857 | font = Font::large; |
| 1858 | break; |
| 1859 | |
| 1860 | case ControlCodes::Font::bold: |
| 1861 | font = Font::medium_bold; |
| 1862 | break; |
| 1863 | |
| 1864 | case ControlCodes::Font::regular: |
| 1865 | font = Font::medium_normal; |
| 1866 | break; |
| 1867 | |
| 1868 | case ControlCodes::Font::outline: |
| 1869 | case ControlCodes::Font::outlineOff: |
| 1870 | case ControlCodes::windowColour1: |
| 1871 | case ControlCodes::windowColour2: |
| 1872 | case ControlCodes::windowColour3: |
| 1873 | case ControlCodes::windowColour4: |
| 1874 | break; |
| 1875 |
no test coverage detected