| 834 | } |
| 835 | |
| 836 | u8string shortenPath(const u8string& path, int32_t availableWidth, FontStyle fontStyle) |
| 837 | { |
| 838 | if (getStringWidth(path, fontStyle) <= availableWidth) |
| 839 | { |
| 840 | return path; |
| 841 | } |
| 842 | |
| 843 | u8string shortenedPath = u8"..."; |
| 844 | |
| 845 | size_t begin = 0; |
| 846 | while (begin < path.size()) |
| 847 | { |
| 848 | begin = path.find_first_of(*PATH_SEPARATOR, begin + 1); |
| 849 | if (begin == path.npos) |
| 850 | break; |
| 851 | |
| 852 | shortenedPath = u8"..." + path.substr(begin); |
| 853 | if (getStringWidth(shortenedPath, fontStyle) <= availableWidth) |
| 854 | { |
| 855 | return shortenedPath; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | return shortenedPath; |
| 860 | } |
| 861 | } // namespace OpenRCT2::Drawing |
no test coverage detected