0x00451582
| 1021 | |
| 1022 | // 0x00451582 |
| 1023 | static int16_t drawStringMaxChars( |
| 1024 | TextDrawingState& drawState, |
| 1025 | DrawingContext& ctx, |
| 1026 | const RenderTarget& rt, |
| 1027 | Ui::Point origin, |
| 1028 | const AdvancedColour colour, |
| 1029 | uint8_t* str, |
| 1030 | const int16_t numCharsRemaining) |
| 1031 | { |
| 1032 | // This function has been somewhat simplified removing unreachable parts |
| 1033 | if (!colour.isFE()) |
| 1034 | { |
| 1035 | assert(false); |
| 1036 | return numCharsRemaining; |
| 1037 | } |
| 1038 | int16_t numChars = numCharsRemaining; |
| 1039 | Ui::Point pos = origin; |
| 1040 | while (true) |
| 1041 | { |
| 1042 | if (numChars == 0) |
| 1043 | { |
| 1044 | break; |
| 1045 | } |
| 1046 | // When off-screen in y dimension don't draw text |
| 1047 | // In original this check only performed if pos.y updated instead of every loop |
| 1048 | bool offscreen = true; |
| 1049 | if (pos.y + 19 > rt.y) |
| 1050 | { |
| 1051 | if (rt.y + rt.height > pos.y) |
| 1052 | { |
| 1053 | offscreen = false; |
| 1054 | } |
| 1055 | } |
| 1056 | const auto chr = static_cast<uint8_t>(*str); |
| 1057 | str++; |
| 1058 | |
| 1059 | switch (chr) |
| 1060 | { |
| 1061 | case 0U: |
| 1062 | return numChars; |
| 1063 | |
| 1064 | case ControlCodes::adjustPalette: |
| 1065 | // This control character does not appear in the localisation files |
| 1066 | assert(false); |
| 1067 | str++; |
| 1068 | break; |
| 1069 | |
| 1070 | case ControlCodes::newlineSmaller: |
| 1071 | pos.x = origin.x; |
| 1072 | pos.y += getSmallerLineHeight(drawState.font); |
| 1073 | break; |
| 1074 | |
| 1075 | case ControlCodes::newline: |
| 1076 | pos.x = origin.x; |
| 1077 | pos.y += getLineHeight(drawState.font); |
| 1078 | break; |
| 1079 | |
| 1080 | case ControlCodes::moveX: |
no test coverage detected