MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / DrawDiabloMsg

Function DrawDiabloMsg

Source/error.cpp:158–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158void DrawDiabloMsg(const Surface &out)
159{
160 auto &uiRectanglePosition = GetUIRectangle().position;
161 int dialogStartY = ((gnScreenHeight - GetMainPanel().size.height) / 2) - (ErrorWindowHeight / 2) + 9;
162
163 ClxDraw(out, { uiRectanglePosition.x + 101, dialogStartY }, (*pSTextSlidCels)[0]);
164 ClxDraw(out, { uiRectanglePosition.x + 101, dialogStartY + ErrorWindowHeight - 6 }, (*pSTextSlidCels)[1]);
165 ClxDraw(out, { uiRectanglePosition.x + 527, dialogStartY + ErrorWindowHeight - 6 }, (*pSTextSlidCels)[2]);
166 ClxDraw(out, { uiRectanglePosition.x + 527, dialogStartY }, (*pSTextSlidCels)[3]);
167
168 int sx = uiRectanglePosition.x + 109;
169 for (int i = 0; i < 35; i++) {
170 ClxDraw(out, { sx, dialogStartY }, (*pSTextSlidCels)[4]);
171 ClxDraw(out, { sx, dialogStartY + ErrorWindowHeight - 6 }, (*pSTextSlidCels)[6]);
172 sx += 12;
173 }
174 int drawnYborder = 12;
175 while ((drawnYborder + 12) < ErrorWindowHeight) {
176 ClxDraw(out, { uiRectanglePosition.x + 101, dialogStartY + drawnYborder }, (*pSTextSlidCels)[5]);
177 ClxDraw(out, { uiRectanglePosition.x + 527, dialogStartY + drawnYborder }, (*pSTextSlidCels)[7]);
178 drawnYborder += 12;
179 }
180
181 DrawHalfTransparentRectTo(out, uiRectanglePosition.x + 104, dialogStartY - 8, 432, ErrorWindowHeight);
182
183 int lineNumber = 0;
184 for (auto &line : TextLines) {
185 DrawString(out, line, { { uiRectanglePosition.x + 109, dialogStartY + 12 + lineNumber * LineHeight }, { LineWidth, LineHeight } }, { UiFlags::AlignCenter, 1, LineHeight });
186 lineNumber += 1;
187 }
188
189 // Calculate the time the current message has been displayed
190 uint32_t currentTime = SDL_GetTicks();
191 uint32_t messageElapsedTime = currentTime - msgStartTime;
192
193 // Check if the current message's duration has passed
194 if (!DiabloMessages.empty() && messageElapsedTime >= DiabloMessages.front().duration) {
195 DiabloMessages.pop_front();
196 if (!DiabloMessages.empty()) {
197 InitNextLines();
198 msgStartTime = currentTime;
199 }
200 }
201}
202
203} // namespace devilution

Callers 1

DrawViewFunction · 0.85

Calls 5

ClxDrawFunction · 0.85
InitNextLinesFunction · 0.85
DrawStringFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected