MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / drawStringYOffsets

Function drawStringYOffsets

src/OpenLoco/src/Graphics/TextRenderer.cpp:780–1020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778 }
779
780 static void drawStringYOffsets(
781 TextDrawingState& drawState,
782 DrawingContext& ctx,
783 const RenderTarget& rt,
784 const Ui::Point& loc,
785 AdvancedColour colour,
786 const char* str,
787 const int8_t* yOffsets)
788 {
789 // This function has been somewhat simplified removing unreachable parts
790 if (colour.isFE())
791 {
792 assert(false);
793 return;
794 }
795 if (loc.x >= rt.x + rt.width)
796 {
797 return;
798 }
799
800 if (loc.x < rt.x - 1280)
801 {
802 return;
803 }
804
805 if (loc.y >= rt.y + rt.height)
806 {
807 return;
808 }
809
810 // Note: 60 not 90 like drawString
811 if (loc.y < rt.y - 60)
812 {
813 return;
814 }
815
816 drawState.fontFlags = TextDrawFlags::none;
817
818 setTextColours(drawState, Colours::getShade(colour.c(), 9), PaletteIndex::black0, PaletteIndex::black0);
819
820 Ui::Point pos = loc;
821 while (true)
822 {
823 // When off-screen in y dimension don't draw text
824 // In original this check only performed if pos.y updated instead of every loop
825 bool offscreen = true;
826 // Note: 39 unlike drawString
827 if (pos.y + 39 > rt.y)
828 {
829 if (rt.y + rt.height > pos.y - 20)
830 {
831 offscreen = false;
832 }
833 }
834
835 const auto chr = static_cast<uint8_t>(*str);
836 str++;
837

Callers 1

drawStringYOffsetsMethod · 0.85

Calls 12

setTextColoursFunction · 0.85
getShadeFunction · 0.85
getSmallerLineHeightFunction · 0.85
getLineHeightFunction · 0.85
getWindowColourFunction · 0.85
setTextColourFunction · 0.85
getCharacterWidthFunction · 0.85
getImageForCharacterFunction · 0.85
isFEMethod · 0.80
cMethod · 0.80
drawImagePaletteSetMethod · 0.80
withPrimaryMethod · 0.80

Tested by

no test coverage detected