MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / GUI_DrawScreen

Function GUI_DrawScreen

src/gui/gui.c:4554–4648  ·  view source on GitHub ↗

* Draw the screen. * This also handles animation tick and other viewport related activity. * @param screenID The screen to draw on. */

Source from the content-addressed store, hash-verified

4552 * @param screenID The screen to draw on.
4553 */
4554void GUI_DrawScreen(Screen screenID)
4555{
4556 static uint32 s_timerViewportMessage = 0;
4557 bool hasScrolled = false;
4558 Screen oldScreenID;
4559 uint16 xpos;
4560
4561 if (g_selectionType == SELECTIONTYPE_MENTAT) return;
4562 if (g_selectionType == SELECTIONTYPE_DEBUG) return;
4563 if (g_selectionType == SELECTIONTYPE_UNKNOWN6) return;
4564 if (g_selectionType == SELECTIONTYPE_INTRO) return;
4565
4566 oldScreenID = GFX_Screen_SetActive(screenID);
4567
4568 if (!GFX_Screen_IsActive(SCREEN_0)) g_viewport_forceRedraw = true;
4569
4570 Explosion_Tick();
4571 Animation_Tick();
4572 Unit_Sort();
4573
4574 if (!g_viewport_forceRedraw && g_viewportPosition != g_minimapPosition) {
4575 uint16 viewportX = Tile_GetPackedX(g_viewportPosition);
4576 uint16 viewportY = Tile_GetPackedY(g_viewportPosition);
4577 int16 xOffset = Tile_GetPackedX(g_minimapPosition) - viewportX; /* Horizontal offset between viewport and minimap. */
4578 int16 yOffset = Tile_GetPackedY(g_minimapPosition) - viewportY; /* Vertical offset between viewport and minmap. */
4579
4580 /* Overlap remaining in tiles. */
4581 int16 xOverlap = 15 - abs(xOffset);
4582 int16 yOverlap = 10 - abs(yOffset);
4583
4584 int16 x, y;
4585
4586 if (xOverlap < 1 || yOverlap < 1) {
4587 g_viewport_forceRedraw = true;
4588 } else if (!g_viewport_forceRedraw && (xOverlap != 15 || yOverlap != 10)) {
4589 Map_SetSelectionObjectPosition(0xFFFF);
4590 hasScrolled = true;
4591
4592 GUI_Mouse_Hide_InWidget(2);
4593
4594 GUI_Screen_Copy(max(-xOffset << 1, 0), 40 + max(-yOffset << 4, 0), max(0, xOffset << 1), 40 + max(0, yOffset << 4), xOverlap << 1, yOverlap << 4, SCREEN_0, SCREEN_1);
4595 } else {
4596 g_viewport_forceRedraw = true;
4597 }
4598
4599 xOffset = max(0, xOffset);
4600 yOffset = max(0, yOffset);
4601
4602 for (y = 0; y < 10; y++) {
4603 uint16 mapYBase = (y + viewportY) << 6;
4604
4605 for (x = 0; x < 15; x++) {
4606 if (x >= xOffset && (xOffset + xOverlap) > x && y >= yOffset && (yOffset + yOverlap) > y && !g_viewport_forceRedraw) continue;
4607
4608 Map_Update(x + viewportX + mapYBase, 0, true);
4609 }
4610 }
4611 }

Callers 2

GameLoop_MainFunction · 0.85

Calls 13

GFX_Screen_SetActiveFunction · 0.85
GFX_Screen_IsActiveFunction · 0.85
Explosion_TickFunction · 0.85
Animation_TickFunction · 0.85
Unit_SortFunction · 0.85
GUI_Mouse_Hide_InWidgetFunction · 0.85
GUI_Screen_CopyFunction · 0.85
Map_UpdateFunction · 0.85
BitArray_SetFunction · 0.85
GUI_Widget_Viewport_DrawFunction · 0.85

Tested by

no test coverage detected