MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ChatDraw

Function ChatDraw

src/openrct2/interface/Chat.cpp:92–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void ChatDraw(RenderTarget& rt, ColourWithFlags chatBackgroundColor)
93{
94 thread_local std::string lineBuffer;
95
96 if (!ChatAvailable())
97 {
98 gChatOpen = false;
99 return;
100 }
101
102 _chatLeft = 10;
103 _chatRight = std::min<int16_t>((ContextGetWidth() - 10), kChatMaxWindowWidth);
104 _chatWidth = _chatRight - _chatLeft;
105 _chatBottom = ContextGetHeight() - 45;
106 _chatTop = _chatBottom - 10;
107
108 const char* inputLine = _chatCurrentLine.c_str();
109 int32_t inputLineHeight = 10;
110
111 // Draw chat window
112 if (gChatOpen)
113 {
114 inputLineHeight = ChatStringWrappedGetHeight(inputLine, _chatWidth - 10);
115 _chatTop -= inputLineHeight;
116
117 for (const auto& entry : _chatHistory)
118 {
119 if (entry.empty())
120 {
121 continue;
122 }
123 lineBuffer = entry;
124 int32_t lineHeight = ChatStringWrappedGetHeight(lineBuffer, _chatWidth - 10);
125 _chatTop -= (lineHeight + 5);
126 }
127
128 _chatHeight = _chatBottom - _chatTop;
129
130 if (_chatTop < 50)
131 {
132 _chatTop = 50;
133 }
134 else if (_chatHeight < 150)
135 { // Min height
136 _chatTop = _chatBottom - 150;
137 _chatHeight = 150;
138 }
139
140 ScreenCoordsXY topLeft{ _chatLeft, _chatTop };
141 ScreenCoordsXY bottomRight{ _chatRight, _chatBottom };
142 ScreenCoordsXY bottomLeft{ _chatLeft, _chatBottom };
143 GfxSetDirtyBlocks(
144 { topLeft - ScreenCoordsXY{ 0, 5 }, bottomRight + ScreenCoordsXY{ 0, 5 } }); // Background area + Textbox
145 Rectangle::filter(
146 rt, { topLeft - ScreenCoordsXY{ 0, 5 }, bottomRight + ScreenCoordsXY{ 0, 5 } },
147 FilterPaletteID::palette51); // Opaque grey background
148 Rectangle::fillInset(
149 rt, { topLeft - ScreenCoordsXY{ 0, 5 }, bottomRight + ScreenCoordsXY{ 0, 5 } }, chatBackgroundColor,

Callers 1

DrawFunction · 0.85

Calls 15

ChatAvailableFunction · 0.85
ContextGetWidthFunction · 0.85
ContextGetHeightFunction · 0.85
GfxSetDirtyBlocksFunction · 0.85
filterFunction · 0.85
fillInsetFunction · 0.85
ChatHistoryGetTimeFunction · 0.85
GetTicksFunction · 0.85
ChatHistoryDrawStringFunction · 0.85
drawTextWrappedFunction · 0.85
getStringWidthFunction · 0.85

Tested by

no test coverage detected