MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / Open

Method Open

Descent3/hudmessage.cpp:1616–1703  ·  view source on GitHub ↗

registers dimensions of box

Source from the content-addressed store, hash-verified

1614
1615// registers dimensions of box
1616bool MsgListConsole::Open(const char *title, int x, int y, int w, int h) {
1617 m_x = x;
1618 m_y = y;
1619 m_w = w;
1620 m_h = h;
1621
1622 if (!m_list)
1623 return false;
1624
1625 // determine text buffer dimensions
1626 m_buflen = 2048;
1627
1628redo_copy:
1629 m_buffer = (char *)mem_malloc(m_buflen);
1630 if (m_buffer) {
1631 m_buffer[0] = 0;
1632 m_opened = true;
1633 } else {
1634 m_opened = false;
1635 return false;
1636 }
1637
1638 // generate text buffer
1639 int i, len, j;
1640 char *bufptr = m_buffer;
1641
1642 for (i = 0; i < m_list->m_nmsg; i++) {
1643 const char *msg = m_list->m_msg[i];
1644 if ((strlen(m_buffer) + strlen(msg) + 2) >= (unsigned)(m_buflen)) {
1645 // reallocate buffer
1646 mem_free(m_buffer);
1647 m_buflen = m_buflen * 2;
1648 goto redo_copy;
1649 }
1650
1651 textaux_WordWrap(msg, bufptr, m_w - MSGL_BORDER_THICKNESS * 2, HUD_FONT);
1652 bufptr += strlen(bufptr);
1653
1654 // append newline character if there are more messages.
1655 if (i < (m_list->m_nmsg - 1)) {
1656 *bufptr = '\n';
1657 bufptr++;
1658 }
1659 }
1660
1661 // allocate console line pointers
1662 int c = 0;
1663 int y2 = grfont_GetHeight(HUD_FONT) + MSGL_BORDER_THICKNESS + 3;
1664 while (y2 < (m_h - MSGL_BORDER_THICKNESS - grfont_GetHeight(HUD_FONT))) {
1665 y2 += (grfont_GetHeight(HUD_FONT) + 1);
1666 c++;
1667 }
1668
1669 ASSERT(c > 0);
1670 m_conlines = (char **)mem_malloc(sizeof(char *) * c);
1671 n_conlines = c;
1672 memset(m_conlines, 0, sizeof(char *) * c);
1673

Callers 15

DrawMethod · 0.95
PilotSelectFunction · 0.45
PilotChooseFunction · 0.45
DoPilotTauntScreenFunction · 0.45
PltSelectShipFunction · 0.45
ShowPilotPicDialogFunction · 0.45
SaveGameDialogFunction · 0.45
LoadGameDialogFunction · 0.45
taunt_ImportWaveFunction · 0.45
MainMultiplayerMenuFunction · 0.45
DisplayNetDLLHelpFunction · 0.45

Calls 3

textaux_WordWrapFunction · 0.85
grfont_GetHeightFunction · 0.85
SuspendControlsFunction · 0.85

Tested by

no test coverage detected