From d55a1c8a7d5a72b2476cc3ef246cafcea8cee078 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Thu, 4 Mar 2021 01:20:24 +0800 Subject: [PATCH] Pass CelOutputBuffer to game text printing (#1095) * Pass CelOutputBuffer to game text printing * DrawHalfTransparentRectTo: minor cleanup --- Source/automap.cpp | 8 +- Source/control.cpp | 200 +++++++++----------- Source/control.h | 62 ++++-- Source/engine.cpp | 3 - Source/engine.h | 5 +- Source/error.cpp | 22 +-- Source/error.h | 4 +- Source/help.cpp | 12 +- Source/inv.cpp | 18 +- Source/inv.h | 2 +- Source/items.cpp | 20 +- Source/items.h | 2 +- Source/plrmsg.cpp | 9 +- Source/plrmsg.h | 6 +- Source/quests.cpp | 18 +- Source/quests.h | 4 +- Source/scrollrt.cpp | 42 ++-- Source/stores.cpp | 24 +-- Source/stores.h | 4 +- SourceS/thread.h | 6 + SourceX/controls/modifier_hints.cpp | 284 ++++++++++++++-------------- SourceX/controls/modifier_hints.h | 16 +- 22 files changed, 400 insertions(+), 371 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index 330581551..90fd4ca2e 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -595,16 +595,16 @@ static void DrawAutomapText(CelOutputBuffer out) if (gbIsMultiplayer) { strcat(strcpy(desc, "game: "), szPlayerName); - PrintGameStr(8, 20, desc, COL_GOLD); + PrintGameStr(out, 8, 20, desc, COL_GOLD); nextline = 35; if (szPlayerDescript[0]) { strcat(strcpy(desc, "password: "), szPlayerDescript); - PrintGameStr(8, 35, desc, COL_GOLD); + PrintGameStr(out, 8, 35, desc, COL_GOLD); nextline = 50; } } if (setlevel) { - PrintGameStr(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD); + PrintGameStr(out, 8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD); } else if (currlevel != 0) { if (currlevel < 17 || currlevel > 20) { if (currlevel < 21 || currlevel > 24) @@ -614,7 +614,7 @@ static void DrawAutomapText(CelOutputBuffer out) } else { sprintf(desc, "Level: Nest %i", currlevel - 16); } - PrintGameStr(8, nextline, desc, COL_GOLD); + PrintGameStr(out, 8, nextline, desc, COL_GOLD); } } diff --git a/Source/control.cpp b/Source/control.cpp index f61e9c22c..ec60b96b7 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -512,16 +512,9 @@ void ToggleSpell(int slot) } } -/** - * @brief Print letter to the back buffer - * @param sx Backbuffer offset - * @param sy Backbuffer offset - * @param nCel Number of letter in Windows-1252 - * @param col text_color color value - */ -void PrintChar(int sx, int sy, int nCel, char col) +void PrintChar(CelOutputBuffer out, int sx, int sy, int nCel, char col) { - assert(gpBuffer); + assert(out.begin); int i; BYTE pix; @@ -529,7 +522,7 @@ void PrintChar(int sx, int sy, int nCel, char col) switch (col) { case COL_WHITE: - CelDraw(sx, sy, pPanelText, nCel, 13); + CelDrawTo(out, sx, sy, pPanelText, nCel, 13); return; case COL_BLUE: for (i = 0; i < 256; i++) { @@ -562,7 +555,7 @@ void PrintChar(int sx, int sy, int nCel, char col) } break; } - CelDrawLight(sx, sy, pPanelText, nCel, 13, tbl); + CelDrawLightTo(out, sx, sy, pPanelText, nCel, 13, tbl); } void AddPanelString(const char *str, BOOL just) @@ -580,22 +573,22 @@ void ClearPanel() pinfoflag = FALSE; } -void DrawPanelBox(int x, int y, int w, int h, int sx, int sy) +void DrawPanelBox(CelOutputBuffer out, int x, int y, int w, int h, int sx, int sy) { int nSrcOff, nDstOff; - assert(gpBuffer); + assert(out.begin); nSrcOff = x + PANEL_WIDTH * y; - nDstOff = sx + BUFFER_WIDTH * sy; + nDstOff = sx + out.line_width * sy; int hgt; BYTE *src, *dst; src = &pBtmBuff[nSrcOff]; - dst = &gpBuffer[nDstOff]; + dst = out.begin + nDstOff; - for (hgt = h; hgt; hgt--, src += PANEL_WIDTH, dst += BUFFER_WIDTH) { + for (hgt = h; hgt; hgt--, src += PANEL_WIDTH, dst += out.line_width) { memcpy(dst, src, w); } } @@ -687,12 +680,7 @@ void DrawLifeFlask() DrawFlask(pBtmBuff, PANEL_WIDTH, PANEL_WIDTH * (filled + 3) + 109, gpBuffer, SCREENXY(PANEL_LEFT + 109, PANEL_TOP - 13 + filled), 13 - filled); } -/** - * Controls the drawing of the area of the life flask within the control panel. - * First sets the fill amount then draws the empty flask cel portion then the filled - * flask portion. - */ -void UpdateLifeFlask() +void UpdateLifeFlask(CelOutputBuffer out) { double p; int filled; @@ -711,7 +699,7 @@ void UpdateLifeFlask() if (filled != 69) SetFlaskHeight(pLifeBuff, 16, 85 - filled, 96 + PANEL_X, PANEL_Y); if (filled != 0) - DrawPanelBox(96, 85 - filled, 88, filled, 96 + PANEL_X, PANEL_Y + 69 - filled); + DrawPanelBox(out, 96, 85 - filled, 88, filled, 96 + PANEL_X, PANEL_Y + 69 - filled); } void DrawManaFlask() @@ -746,11 +734,7 @@ void control_update_life_mana() plr[myplr]._pHPPer = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0; } -/** - * Controls the drawing of the area of the life flask within the control panel. - * Also for some reason draws the current right mouse button spell. - */ -void UpdateManaFlask() +void UpdateManaFlask(CelOutputBuffer out) { int filled; int maxMana = plr[myplr]._pMaxMana; @@ -772,7 +756,7 @@ void UpdateManaFlask() if (filled != 69) SetFlaskHeight(pManaBuff, 16, 85 - filled, PANEL_X + 464, PANEL_Y); if (filled != 0) - DrawPanelBox(464, 85 - filled, 88, filled, PANEL_X + 464, PANEL_Y + 69 - filled); + DrawPanelBox(out, 464, 85 - filled, 88, filled, PANEL_X + 464, PANEL_Y + 69 - filled); DrawSpell(); } @@ -866,32 +850,28 @@ void InitControlPan() initialDropGoldIndex = 0; } -void DrawCtrlPan() +void DrawCtrlPan(CelOutputBuffer out) { - DrawPanelBox(0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y); - DrawInfoBox(); + DrawPanelBox(out, 0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y); + DrawInfoBox(out); } -/** - * Draws the control panel buttons in their current state. If the button is in the default - * state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel. - */ -void DrawCtrlBtns() +void DrawCtrlBtns(CelOutputBuffer out) { int i; for (i = 0; i < 6; i++) { if (!panbtn[i]) - DrawPanelBox(PanBtnPos[i][0], PanBtnPos[i][1] + 16, 71, 20, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y); + DrawPanelBox(out, PanBtnPos[i][0], PanBtnPos[i][1] + 16, 71, 20, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y); else - CelDraw(PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y + 18, pPanelButtons, i + 1, 71); + CelDrawTo(out, PanBtnPos[i][0] + PANEL_X, PanBtnPos[i][1] + PANEL_Y + 18, pPanelButtons, i + 1, 71); } if (numpanbtns == 8) { - CelDraw(87 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[6] + 1, 33); + CelDrawTo(out, 87 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[6] + 1, 33); if (FriendlyMode) - CelDraw(527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 3, 33); + CelDrawTo(out, 527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 3, 33); else - CelDraw(527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 5, 33); + CelDrawTo(out, 527 + PANEL_X, 122 + PANEL_Y, pMultiBtns, panbtn[7] + 5, 33); } } @@ -1231,7 +1211,7 @@ BOOL control_WriteStringToBuffer(BYTE *str) return TRUE; } -static void CPrintString(int y, const char *str, BOOL center, int lines) +static void CPrintString(CelOutputBuffer out, int y, const char *str, BOOL center, int lines) { BYTE c; const char *tmp; @@ -1257,14 +1237,14 @@ static void CPrintString(int y, const char *str, BOOL center, int lines) lineOffset += fontkern[c] + 2; if (c) { if (lineOffset < 288) { - PrintChar(sx, sy, c, infoclr); + PrintChar(out, sx, sy, c, infoclr); } } sx += fontkern[c] + 2; } } -static void PrintInfo() +static void PrintInfo(CelOutputBuffer out) { int yo, lo, i; @@ -1272,25 +1252,22 @@ static void PrintInfo() yo = 0; lo = 1; if (infostr[0] != '\0') { - CPrintString(0, infostr, TRUE, pnumlines); + CPrintString(out, 0, infostr, TRUE, pnumlines); yo = 1; lo = 0; } for (i = 0; i < pnumlines; i++) { - CPrintString(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); + CPrintString(out, i + yo, panelstr[i], pstrjust[i], pnumlines - lo); } } } -/** - * Sets a string to be drawn in the info box and then draws it. - */ -void DrawInfoBox() +void DrawInfoBox(CelOutputBuffer out) { int nGold; - DrawPanelBox(177, 62, 288, 60, PANEL_X + 177, PANEL_Y + 46); + DrawPanelBox(out, 177, 62, 288, 60, PANEL_X + 177, PANEL_Y + 46); if (!panelflag && !trigflag && pcursinvitem == -1 && !spselflag) { infostr[0] = '\0'; infoclr = COL_WHITE; @@ -1347,12 +1324,12 @@ void DrawInfoBox() } } if (infostr[0] != '\0' || pnumlines != 0) - PrintInfo(); + PrintInfo(out); } -#define ADD_PlrStringXY(x, y, width, pszStr, col) MY_PlrStringXY(x, y, width, pszStr, col, 1) +#define ADD_PlrStringXY(out, x, y, width, pszStr, col) MY_PlrStringXY(out, x, y, width, pszStr, col, 1) -void PrintGameStr(int x, int y, const char *str, int color) +void PrintGameStr(CelOutputBuffer out, int x, int y, const char *str, int color) { BYTE c; int sx, sy; @@ -1362,13 +1339,14 @@ void PrintGameStr(int x, int y, const char *str, int color) c = gbFontTransTbl[(BYTE)*str++]; c = fontframe[c]; if (c) - PrintChar(sx, sy, c, color); + PrintChar(out, sx, sy, c, color); sx += fontkern[c] + 1; } } /** - * @brief Render text string to back buffer + * @brief Render text string to the given buffer + * @param out Buffer to render to * @param x Screen coordinate * @param y Screen coordinate * @param endX End of line in screen coordinate @@ -1376,7 +1354,7 @@ void PrintGameStr(int x, int y, const char *str, int color) * @param col text_color color value * @param base Letter spacing */ -static void MY_PlrStringXY(int x, int y, int endX, const char *pszStr, char col, int base) +static void MY_PlrStringXY(CelOutputBuffer out, int x, int y, int endX, const char *pszStr, char col, int base) { BYTE c; const char *tmp; @@ -1401,28 +1379,28 @@ static void MY_PlrStringXY(int x, int y, int endX, const char *pszStr, char col, line += fontkern[c] + base; if (c) { if (line < widthOffset) - PrintChar(sx, sy, c, col); + PrintChar(out, sx, sy, c, col); } sx += fontkern[c] + base; } } -void DrawChr() +void DrawChr(CelOutputBuffer out) { char col; char chrstr[64]; int pc, mindam, maxdam; CelDraw(SCREEN_X, 351 + SCREEN_Y, pChrPanel, 1, SPANEL_WIDTH); - ADD_PlrStringXY(20, 32, 151, plr[myplr]._pName, COL_WHITE); + ADD_PlrStringXY(out, 20, 32, 151, plr[myplr]._pName, COL_WHITE); - ADD_PlrStringXY(168, 32, 299, ClassStrTblOld[plr[myplr]._pClass], COL_WHITE); + ADD_PlrStringXY(out, 168, 32, 299, ClassStrTblOld[plr[myplr]._pClass], COL_WHITE); sprintf(chrstr, "%i", plr[myplr]._pLevel); - ADD_PlrStringXY(66, 69, 109, chrstr, COL_WHITE); + ADD_PlrStringXY(out, 66, 69, 109, chrstr, COL_WHITE); sprintf(chrstr, "%i", plr[myplr]._pExperience); - ADD_PlrStringXY(216, 69, 300, chrstr, COL_WHITE); + ADD_PlrStringXY(out, 216, 69, 300, chrstr, COL_WHITE); if (plr[myplr]._pLevel == MAXCHARLEVEL - 1) { strcpy(chrstr, "None"); @@ -1431,10 +1409,10 @@ void DrawChr() sprintf(chrstr, "%i", plr[myplr]._pNextExper); col = COL_WHITE; } - ADD_PlrStringXY(216, 97, 300, chrstr, col); + ADD_PlrStringXY(out, 216, 97, 300, chrstr, col); sprintf(chrstr, "%i", plr[myplr]._pGold); - ADD_PlrStringXY(216, 146, 300, chrstr, COL_WHITE); + ADD_PlrStringXY(out, 216, 146, 300, chrstr, COL_WHITE); col = COL_WHITE; if (plr[myplr]._pIBonusAC > 0) @@ -1442,7 +1420,7 @@ void DrawChr() if (plr[myplr]._pIBonusAC < 0) col = COL_RED; sprintf(chrstr, "%i", plr[myplr]._pIBonusAC + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5); - ADD_PlrStringXY(258, 183, 301, chrstr, col); + ADD_PlrStringXY(out, 258, 183, 301, chrstr, col); col = COL_WHITE; if (plr[myplr]._pIBonusToHit > 0) @@ -1450,7 +1428,7 @@ void DrawChr() if (plr[myplr]._pIBonusToHit < 0) col = COL_RED; sprintf(chrstr, "%i%%", (plr[myplr]._pDexterity >> 1) + plr[myplr]._pIBonusToHit + 50); - ADD_PlrStringXY(258, 211, 301, chrstr, col); + ADD_PlrStringXY(out, 258, 211, 301, chrstr, col); col = COL_WHITE; if (plr[myplr]._pIBonusDam > 0) @@ -1481,9 +1459,9 @@ void DrawChr() } sprintf(chrstr, "%i-%i", mindam, maxdam); if (mindam >= 100 || maxdam >= 100) - MY_PlrStringXY(254, 239, 305, chrstr, col, -1); + MY_PlrStringXY(out, 254, 239, 305, chrstr, col, -1); else - MY_PlrStringXY(258, 239, 301, chrstr, col, 0); + MY_PlrStringXY(out, 258, 239, 301, chrstr, col, 0); if (plr[myplr]._pMagResist == 0) col = COL_WHITE; @@ -1495,7 +1473,7 @@ void DrawChr() col = COL_GOLD; sprintf(chrstr, "MAX"); } - ADD_PlrStringXY(257, 276, 300, chrstr, col); + ADD_PlrStringXY(out, 257, 276, 300, chrstr, col); if (plr[myplr]._pFireResist == 0) col = COL_WHITE; @@ -1507,7 +1485,7 @@ void DrawChr() col = COL_GOLD; sprintf(chrstr, "MAX"); } - ADD_PlrStringXY(257, 304, 300, chrstr, col); + ADD_PlrStringXY(out, 257, 304, 300, chrstr, col); if (plr[myplr]._pLghtResist == 0) col = COL_WHITE; @@ -1519,31 +1497,31 @@ void DrawChr() col = COL_GOLD; sprintf(chrstr, "MAX"); } - ADD_PlrStringXY(257, 332, 300, chrstr, col); + ADD_PlrStringXY(out, 257, 332, 300, chrstr, col); col = COL_WHITE; sprintf(chrstr, "%i", plr[myplr]._pBaseStr); if (MaxStats[plr[myplr]._pClass][ATTRIB_STR] == plr[myplr]._pBaseStr) col = COL_GOLD; - ADD_PlrStringXY(95, 155, 126, chrstr, col); + ADD_PlrStringXY(out, 95, 155, 126, chrstr, col); col = COL_WHITE; sprintf(chrstr, "%i", plr[myplr]._pBaseMag); if (MaxStats[plr[myplr]._pClass][ATTRIB_MAG] == plr[myplr]._pBaseMag) col = COL_GOLD; - ADD_PlrStringXY(95, 183, 126, chrstr, col); + ADD_PlrStringXY(out, 95, 183, 126, chrstr, col); col = COL_WHITE; sprintf(chrstr, "%i", plr[myplr]._pBaseDex); if (MaxStats[plr[myplr]._pClass][ATTRIB_DEX] == plr[myplr]._pBaseDex) col = COL_GOLD; - ADD_PlrStringXY(95, 211, 126, chrstr, col); + ADD_PlrStringXY(out, 95, 211, 126, chrstr, col); col = COL_WHITE; sprintf(chrstr, "%i", plr[myplr]._pBaseVit); if (MaxStats[plr[myplr]._pClass][ATTRIB_VIT] == plr[myplr]._pBaseVit) col = COL_GOLD; - ADD_PlrStringXY(95, 239, 126, chrstr, col); + ADD_PlrStringXY(out, 95, 239, 126, chrstr, col); col = COL_WHITE; if (plr[myplr]._pStrength > plr[myplr]._pBaseStr) @@ -1551,7 +1529,7 @@ void DrawChr() if (plr[myplr]._pStrength < plr[myplr]._pBaseStr) col = COL_RED; sprintf(chrstr, "%i", plr[myplr]._pStrength); - ADD_PlrStringXY(143, 155, 173, chrstr, col); + ADD_PlrStringXY(out, 143, 155, 173, chrstr, col); col = COL_WHITE; if (plr[myplr]._pMagic > plr[myplr]._pBaseMag) @@ -1559,7 +1537,7 @@ void DrawChr() if (plr[myplr]._pMagic < plr[myplr]._pBaseMag) col = COL_RED; sprintf(chrstr, "%i", plr[myplr]._pMagic); - ADD_PlrStringXY(143, 183, 173, chrstr, col); + ADD_PlrStringXY(out, 143, 183, 173, chrstr, col); col = COL_WHITE; if (plr[myplr]._pDexterity > plr[myplr]._pBaseDex) @@ -1567,7 +1545,7 @@ void DrawChr() if (plr[myplr]._pDexterity < plr[myplr]._pBaseDex) col = COL_RED; sprintf(chrstr, "%i", plr[myplr]._pDexterity); - ADD_PlrStringXY(143, 211, 173, chrstr, col); + ADD_PlrStringXY(out, 143, 211, 173, chrstr, col); col = COL_WHITE; if (plr[myplr]._pVitality > plr[myplr]._pBaseVit) @@ -1575,7 +1553,7 @@ void DrawChr() if (plr[myplr]._pVitality < plr[myplr]._pBaseVit) col = COL_RED; sprintf(chrstr, "%i", plr[myplr]._pVitality); - ADD_PlrStringXY(143, 239, 173, chrstr, col); + ADD_PlrStringXY(out, 143, 239, 173, chrstr, col); if (plr[myplr]._pStatPts > 0) { if (CalcStatDiff(myplr) < plr[myplr]._pStatPts) { @@ -1584,7 +1562,7 @@ void DrawChr() } if (plr[myplr]._pStatPts > 0) { sprintf(chrstr, "%i", plr[myplr]._pStatPts); - ADD_PlrStringXY(95, 266, 126, chrstr, COL_RED); + ADD_PlrStringXY(out, 95, 266, 126, chrstr, COL_RED); pc = plr[myplr]._pClass; if (plr[myplr]._pBaseStr < MaxStats[pc][ATTRIB_STR]) CelDraw(137 + SCREEN_X, 159 + SCREEN_Y, pChrButtons, chrbtn[ATTRIB_STR] + 2, 41); @@ -1601,22 +1579,22 @@ void DrawChr() else col = COL_WHITE; sprintf(chrstr, "%i", plr[myplr]._pMaxHP >> 6); - ADD_PlrStringXY(95, 304, 126, chrstr, col); + ADD_PlrStringXY(out, 95, 304, 126, chrstr, col); if (plr[myplr]._pHitPoints != plr[myplr]._pMaxHP) col = COL_RED; sprintf(chrstr, "%i", plr[myplr]._pHitPoints >> 6); - ADD_PlrStringXY(143, 304, 174, chrstr, col); + ADD_PlrStringXY(out, 143, 304, 174, chrstr, col); if (plr[myplr]._pMaxMana > plr[myplr]._pMaxManaBase) col = COL_BLUE; else col = COL_WHITE; sprintf(chrstr, "%i", plr[myplr]._pMaxMana >> 6); - ADD_PlrStringXY(95, 332, 126, chrstr, col); + ADD_PlrStringXY(out, 95, 332, 126, chrstr, col); if (plr[myplr]._pMana != plr[myplr]._pMaxMana) col = COL_RED; sprintf(chrstr, "%i", plr[myplr]._pMana >> 6); - ADD_PlrStringXY(143, 332, 174, chrstr, col); + ADD_PlrStringXY(out, 143, 332, 174, chrstr, col); } void CheckLvlBtn() @@ -1632,13 +1610,13 @@ void ReleaseLvlBtn() lvlbtndown = FALSE; } -void DrawLevelUpIcon() +void DrawLevelUpIcon(CelOutputBuffer out) { int nCel; if (stextflag == STORE_NONE) { nCel = lvlbtndown ? 3 : 2; - ADD_PlrStringXY(PANEL_LEFT + 0, PANEL_TOP - 49, PANEL_LEFT + 120, "Level Up", COL_WHITE); + ADD_PlrStringXY(out, PANEL_LEFT + 0, PANEL_TOP - 49, PANEL_LEFT + 120, "Level Up", COL_WHITE); CelDraw(40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41); } } @@ -1813,7 +1791,7 @@ void RedBack() } } -static void PrintSBookStr(int x, int y, BOOL cjustflag, const char *pszStr, char col) +static void PrintSBookStr(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *pszStr, char col) { BYTE c; const char *tmp; @@ -1838,7 +1816,7 @@ static void PrintSBookStr(int x, int y, BOOL cjustflag, const char *pszStr, char line += fontkern[c] + 1; if (c) { if (line <= 222) - PrintChar(sx, y, c, col); + PrintChar(out, sx, y, c, col); } sx += fontkern[c] + 1; } @@ -1872,7 +1850,7 @@ char GetSBookTrans(int ii, BOOL townok) return st; } -void DrawSpellBook() +void DrawSpellBook(CelOutputBuffer out) { int i, sn, mana, lvl, yp, min, max; char st; @@ -1902,7 +1880,7 @@ void DrawSpellBook() SetSpellTrans(RSPLTYPE_SKILL); DrawSpellCel(RIGHT_PANEL_X + 11, yp, pSBkIconCels, SPLICONLAST, 37); } - PrintSBookStr(10, yp - 23, FALSE, spelldata[sn].sNameText, COL_WHITE); + PrintSBookStr(out, 10, yp - 23, FALSE, spelldata[sn].sNameText, COL_WHITE); switch (GetSBookTrans(sn, FALSE)) { case RSPLTYPE_SKILL: strcpy(tempstr, "Skill"); @@ -1921,7 +1899,7 @@ void DrawSpellBook() if (sn == SPL_BONESPIRIT) { sprintf(tempstr, "Mana: %i Dam: 1/3 tgt hp", mana); } - PrintSBookStr(10, yp - 1, FALSE, tempstr, COL_WHITE); + PrintSBookStr(out, 10, yp - 1, FALSE, tempstr, COL_WHITE); lvl = plr[myplr]._pSplLvl[sn] + plr[myplr]._pISplLvlAdd; if (lvl < 0) { lvl = 0; @@ -1933,7 +1911,7 @@ void DrawSpellBook() } break; } - PrintSBookStr(10, yp - 12, FALSE, tempstr, COL_WHITE); + PrintSBookStr(out, 10, yp - 12, FALSE, tempstr, COL_WHITE); } yp += 43; } @@ -1976,20 +1954,20 @@ const char *get_pieces_str(int nGold) return result; } -void DrawGoldSplit(int amount) +void DrawGoldSplit(CelOutputBuffer out, int amount) { int screen_x, i; screen_x = 0; CelDraw(351 + SCREEN_X, 178 + SCREEN_Y, pGBoxBuff, 1, 261); sprintf(tempstr, "You have %u gold", initialDropGoldValue); - ADD_PlrStringXY(366, 87, 600, tempstr, COL_GOLD); + ADD_PlrStringXY(out, 366, 87, 600, tempstr, COL_GOLD); sprintf(tempstr, "%s. How many do", get_pieces_str(initialDropGoldValue)); - ADD_PlrStringXY(366, 103, 600, tempstr, COL_GOLD); - ADD_PlrStringXY(366, 121, 600, "you want to remove?", COL_GOLD); + ADD_PlrStringXY(out, 366, 103, 600, tempstr, COL_GOLD); + ADD_PlrStringXY(out, 366, 121, 600, "you want to remove?", COL_GOLD); if (amount > 0) { sprintf(tempstr, "%u", amount); - PrintGameStr(388, 140, tempstr, COL_WHITE); + PrintGameStr(out, 388, 140, tempstr, COL_WHITE); } if (amount > 0) { for (i = 0; i < tempstr[i]; i++) { @@ -2000,7 +1978,7 @@ void DrawGoldSplit(int amount) } else { screen_x = 450; } - CelDraw(screen_x, 140 + SCREEN_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, screen_x, 140 + SCREEN_Y, pSPentSpn2Cels, PentSpn2Spin(), 12); } void control_drop_gold(char vkey) @@ -2073,7 +2051,7 @@ void control_set_gold_curs(int pnum) NewCursor(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); } -static char *control_print_talk_msg(char *msg, int *x, int y, int color) +static char *control_print_talk_msg(CelOutputBuffer out, char *msg, int *x, int y, int color) { BYTE c; int width; @@ -2090,14 +2068,14 @@ static char *control_print_talk_msg(char *msg, int *x, int y, int color) return msg; msg++; if (c != 0) { - PrintChar(*x, y, c, color); + PrintChar(out, *x, y, c, color); } *x += fontkern[c] + 1; } return NULL; } -void DrawTalkPan() +void DrawTalkPan(CelOutputBuffer out) { int i, off, talk_btn, color, nCel, x; char *msg; @@ -2105,21 +2083,21 @@ void DrawTalkPan() if (!talkflag) return; - DrawPanelBox(175, sgbPlrTalkTbl + 20, 294, 5, PANEL_X + 175, PANEL_Y + 4); + DrawPanelBox(out, 175, sgbPlrTalkTbl + 20, 294, 5, PANEL_X + 175, PANEL_Y + 4); off = 0; for (i = 293; i > 283; off++, i--) { - DrawPanelBox((off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + PANEL_X + 175, off + PANEL_Y + 9); + DrawPanelBox(out, (off >> 1) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off >> 1) + PANEL_X + 175, off + PANEL_Y + 9); } - DrawPanelBox(185, sgbPlrTalkTbl + 35, 274, 30, PANEL_X + 185, PANEL_Y + 19); - DrawPanelBox(180, sgbPlrTalkTbl + 65, 284, 5, PANEL_X + 180, PANEL_Y + 49); + DrawPanelBox(out, 185, sgbPlrTalkTbl + 35, 274, 30, PANEL_X + 185, PANEL_Y + 19); + DrawPanelBox(out, 180, sgbPlrTalkTbl + 65, 284, 5, PANEL_X + 180, PANEL_Y + 49); for (i = 0; i < 10; i++) { - DrawPanelBox(180, sgbPlrTalkTbl + i + 70, i + 284, 1, PANEL_X + 180, i + PANEL_Y + 54); + DrawPanelBox(out, 180, sgbPlrTalkTbl + i + 70, i + 284, 1, PANEL_X + 180, i + PANEL_Y + 54); } - DrawPanelBox(170, sgbPlrTalkTbl + 80, 310, 55, PANEL_X + 170, PANEL_Y + 64); + DrawPanelBox(out, 170, sgbPlrTalkTbl + 80, 310, 55, PANEL_X + 170, PANEL_Y + 64); msg = sgszTalkMsg; for (i = 0; i < 39; i += 13) { x = 0 + PANEL_LEFT; - msg = control_print_talk_msg(msg, &x, i, 0); + msg = control_print_talk_msg(out, msg, &x, i, 0); if (!msg) break; } @@ -2151,7 +2129,7 @@ void DrawTalkPan() } if (plr[i].plractive) { x = 46 + PANEL_LEFT; - control_print_talk_msg(plr[i]._pName, &x, 60 + talk_btn * 18, color); + control_print_talk_msg(out, plr[i]._pName, &x, 60 + talk_btn * 18, color); } talk_btn++; diff --git a/Source/control.h b/Source/control.h index 61970401f..a34d8838c 100644 --- a/Source/control.h +++ b/Source/control.h @@ -6,6 +6,8 @@ #ifndef __CONTROL_H__ #define __CONTROL_H__ +#include "engine.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus @@ -49,18 +51,47 @@ void DrawSpellList(); void SetSpell(); void SetSpeedSpell(int slot); void ToggleSpell(int slot); -void PrintChar(int sx, int sy, int nCel, char col); + +/** + * @brief Print letter to the given buffer + * @param out The buffer to print to + * @param sx Backbuffer offset + * @param sy Backbuffer offset + * @param nCel Number of letter in Windows-1252 + * @param col text_color color value + */ +void PrintChar(CelOutputBuffer out, int sx, int sy, int nCel, char col); + void AddPanelString(const char *str, BOOL just); void ClearPanel(); -void DrawPanelBox(int x, int y, int w, int h, int sx, int sy); +void DrawPanelBox(CelOutputBuffer out, int x, int y, int w, int h, int sx, int sy); void DrawLifeFlask(); -void UpdateLifeFlask(); + +/** + * Controls the drawing of the area of the life flask within the control panel. + * First sets the fill amount then draws the empty flask cel portion then the filled + * flask portion. + */ +void UpdateLifeFlask(CelOutputBuffer out); + void DrawManaFlask(); void control_update_life_mana(); -void UpdateManaFlask(); + +/** + * Controls the drawing of the area of the life flask within the control panel. + * Also for some reason draws the current right mouse button spell. + */ +void UpdateManaFlask(CelOutputBuffer out); + void InitControlPan(); -void DrawCtrlPan(); -void DrawCtrlBtns(); +void DrawCtrlPan(CelOutputBuffer out); + +/** + * Draws the control panel buttons in their current state. If the button is in the default + * state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel. + */ +void DrawCtrlBtns(CelOutputBuffer out); + void DoSpeedBook(); void DoPanBtn(); void control_check_btn_press(); @@ -69,24 +100,29 @@ void CheckPanelInfo(); void CheckBtnUp(); void FreeControlPan(); BOOL control_WriteStringToBuffer(BYTE *str); -void DrawInfoBox(); -void PrintGameStr(int x, int y, const char *str, int color); -void DrawChr(); + +/** + * Sets a string to be drawn in the info box and then draws it. + */ +void DrawInfoBox(CelOutputBuffer out); + +void PrintGameStr(CelOutputBuffer out, int x, int y, const char *str, int color); +void DrawChr(CelOutputBuffer out); void CheckLvlBtn(); void ReleaseLvlBtn(); -void DrawLevelUpIcon(); +void DrawLevelUpIcon(CelOutputBuffer out); void CheckChrBtns(); void ReleaseChrBtns(bool addAllStatPoints); void DrawDurIcon(); void RedBack(); -void DrawSpellBook(); +void DrawSpellBook(CelOutputBuffer out); void CheckSBook(); const char *get_pieces_str(int nGold); -void DrawGoldSplit(int amount); +void DrawGoldSplit(CelOutputBuffer out, int amount); void control_drop_gold(char vkey); void control_remove_gold(int pnum, int gold_index); void control_set_gold_curs(int pnum); -void DrawTalkPan(); +void DrawTalkPan(CelOutputBuffer out); BOOL control_check_talk_btn(); void control_release_talk_btn(); void control_type_message(); diff --git a/Source/engine.cpp b/Source/engine.cpp index 554ccfa4f..97cae0922 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -582,9 +582,6 @@ static void DrawHalfTransparentStippledRectTo(CelOutputBuffer out, int sx, int s void DrawHalfTransparentRectTo(CelOutputBuffer out, int sx, int sy, int width, int height) { - int row, col; - BYTE *pix = out.at(sx, sy); - if (sgOptions.bBlendedTransparancy) { DrawHalfTransparentBlendedRectTo(out, sx, sy, width, height); } else { diff --git a/Source/engine.h b/Source/engine.h index e4630dcb0..546dc828b 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -13,6 +13,8 @@ #ifndef __ENGINE_H__ #define __ENGINE_H__ +#include "../types.h" + #ifdef __cplusplus #include #endif @@ -346,9 +348,6 @@ void DrawLineTo(CelOutputBuffer out, int x0, int y0, int x1, int y1, BYTE color_ * Draws a half-transparent rectangle by blacking out odd pixels on odd lines, * even pixels on even lines. * - * If blended transparency is enabled, uses `paletteTransparencyLookup` table instead - * of blacking pixels out. - * * @brief Render a transparent black rectangle * @param out Target buffer * @param sx Screen coordinate diff --git a/Source/error.cpp b/Source/error.cpp index 2df9374a2..79e88455d 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -101,32 +101,32 @@ void ClrDiabloMsg() msgcnt = 0; } -void DrawDiabloMsg() +void DrawDiabloMsg(CelOutputBuffer out) { int i, len, width, sx, sy; BYTE c; - CelDraw(PANEL_X + 101, DIALOG_Y, pSTextSlidCels, 1, 12); - CelDraw(PANEL_X + 527, DIALOG_Y, pSTextSlidCels, 4, 12); - CelDraw(PANEL_X + 101, DIALOG_Y + 48, pSTextSlidCels, 2, 12); - CelDraw(PANEL_X + 527, DIALOG_Y + 48, pSTextSlidCels, 3, 12); + CelDrawTo(out, PANEL_X + 101, DIALOG_Y, pSTextSlidCels, 1, 12); + CelDrawTo(out, PANEL_X + 527, DIALOG_Y, pSTextSlidCels, 4, 12); + CelDrawTo(out, PANEL_X + 101, DIALOG_Y + 48, pSTextSlidCels, 2, 12); + CelDrawTo(out, PANEL_X + 527, DIALOG_Y + 48, pSTextSlidCels, 3, 12); sx = PANEL_X + 109; for (i = 0; i < 35; i++) { - CelDraw(sx, DIALOG_Y, pSTextSlidCels, 5, 12); - CelDraw(sx, DIALOG_Y + 48, pSTextSlidCels, 7, 12); + CelDrawTo(out, sx, DIALOG_Y, pSTextSlidCels, 5, 12); + CelDrawTo(out, sx, DIALOG_Y + 48, pSTextSlidCels, 7, 12); sx += 12; } sy = DIALOG_Y + 12; for (i = 0; i < 3; i++) { - CelDraw(PANEL_X + 101, sy, pSTextSlidCels, 6, 12); - CelDraw(PANEL_X + 527, sy, pSTextSlidCels, 8, 12); + CelDrawTo(out, PANEL_X + 101, sy, pSTextSlidCels, 6, 12); + CelDrawTo(out, PANEL_X + 527, sy, pSTextSlidCels, 8, 12); sy += 12; } assert(gpBuffer); - DrawHalfTransparentRectTo(GlobalBackBuffer(), PANEL_LEFT + 104, DIALOG_TOP - 8, 432, 54); + DrawHalfTransparentRectTo(out, PANEL_LEFT + 104, DIALOG_TOP - 8, 432, 54); strcpy(tempstr, MsgStrings[msgflag]); sx = PANEL_X + 101; @@ -145,7 +145,7 @@ void DrawDiabloMsg() for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]; if (c != '\0') { - PrintChar(sx, sy, c, COL_GOLD); + PrintChar(out, sx, sy, c, COL_GOLD); } sx += fontkern[c] + 1; } diff --git a/Source/error.h b/Source/error.h index 8c55b2463..b2a82831a 100644 --- a/Source/error.h +++ b/Source/error.h @@ -6,6 +6,8 @@ #ifndef __ERROR_H__ #define __ERROR_H__ +#include "engine.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus @@ -17,7 +19,7 @@ extern char msgflag; void InitDiabloMsg(char e); void ClrDiabloMsg(); -void DrawDiabloMsg(); +void DrawDiabloMsg(CelOutputBuffer out); #ifdef __cplusplus } diff --git a/Source/help.cpp b/Source/help.cpp index 7c4d86409..6e59e92c8 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -447,7 +447,7 @@ void InitHelp() helpflag = FALSE; } -static void DrawHelpLine(int x, int y, char *text, char color) +static void DrawHelpLine(CelOutputBuffer out, int x, int y, char *text, char color) { int sx, sy, width; BYTE c; @@ -462,7 +462,7 @@ static void DrawHelpLine(int x, int y, char *text, char color) width += fontkern[c] + 1; if (c) { if (width <= 577) - PrintChar(sx, sy, c, color); + PrintChar(out, sx, sy, c, color); } sx += fontkern[c] + 1; } @@ -477,9 +477,9 @@ void DrawHelp(CelOutputBuffer out) DrawSTextHelp(); DrawQTextBack(out); if (gbIsHellfire) - PrintSString(0, 2, TRUE, "Hellfire Help", COL_GOLD, 0); + PrintSString(out, 0, 2, TRUE, "Hellfire Help", COL_GOLD, 0); else - PrintSString(0, 2, TRUE, "Diablo Help", COL_GOLD, 0); + PrintSString(out, 0, 2, TRUE, "Diablo Help", COL_GOLD, 0); DrawSLine(5); s = &gszHelpText[0]; @@ -553,14 +553,14 @@ void DrawHelp(CelOutputBuffer out) } if (c != 0) { tempstr[c] = '\0'; - DrawHelpLine(0, i, tempstr, col); + DrawHelpLine(out, 0, i, tempstr, col); } if (*s == '|') { s++; } } - PrintSString(0, 23, TRUE, "Press ESC to end or the arrow keys to scroll.", COL_GOLD, 0); + PrintSString(out, 0, 23, TRUE, "Press ESC to end or the arrow keys to scroll.", COL_GOLD, 0); } void DisplayHelp() diff --git a/Source/inv.cpp b/Source/inv.cpp index 1c45e10a8..f53fe3b13 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -524,7 +524,7 @@ void DrawInv() } } -void DrawInvBelt() +void DrawInvBelt(CelOutputBuffer out) { int i, frame, frame_width, color; BYTE fi, ff; @@ -533,7 +533,7 @@ void DrawInvBelt() return; } - DrawPanelBox(205, 21, 232, 28, PANEL_X + 205, PANEL_Y + 5); + DrawPanelBox(out, 205, 21, 232, 28, PANEL_X + 205, PANEL_Y + 5); for (i = 0; i < MAXBELTITEMS; i++) { if (plr[myplr].SpdList[i]._itype == ITYPE_NONE) { @@ -552,22 +552,22 @@ void DrawInvBelt() color = ICOL_RED; if (!sgbControllerActive || invflag) { if (frame <= 179) - CelBlitOutline(color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width); + CelBlitOutlineTo(out, color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width); else - CelBlitOutline(color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width); + CelBlitOutlineTo(out, color, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width); } } if (plr[myplr].SpdList[i]._iStatFlag) { if (frame <= 179) - CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width); + CelClippedDrawTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width); else - CelClippedDraw(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width); + CelClippedDrawTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width); } else { if (frame <= 179) - CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width, 1); + CelDrawLightRedTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels, frame, frame_width, 1); else - CelDrawLightRed(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width, 1); + CelDrawLightRedTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, pCursCels2, frame - 179, frame_width, 1); } if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable @@ -575,7 +575,7 @@ void DrawInvBelt() && plr[myplr].SpdList[i]._itype != ITYPE_GOLD) { fi = i + 49; ff = fontframe[gbFontTransTbl[fi]]; - PrintChar(InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X + INV_SLOT_SIZE_PX - fontkern[ff], InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, ff, 0); + PrintChar(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X + INV_SLOT_SIZE_PX - fontkern[ff], InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, ff, 0); } } } diff --git a/Source/inv.h b/Source/inv.h index 3b5a25cb6..b7f95e14d 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -19,7 +19,7 @@ extern const InvXY InvRect[73]; void FreeInvGFX(); void InitInv(); void DrawInv(); -void DrawInvBelt(); +void DrawInvBelt(CelOutputBuffer out); BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag); BOOL SpecialAutoPlace(int pnum, int ii, const ItemStruct &item); BOOL GoldAutoPlace(int pnum); diff --git a/Source/items.cpp b/Source/items.cpp index 7c7de63f2..4d63bfd01 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3960,7 +3960,7 @@ static void DrawUTextBack(CelOutputBuffer out) DrawHalfTransparentRectTo(out, RIGHT_PANEL - SPANEL_WIDTH + 27, 28, 265, 297); } -void PrintUString(int x, int y, BOOL cjustflag, const char *str, int col) +void PrintUString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, int col) { int len, width, sx, sy, i, k; BYTE c; @@ -3982,7 +3982,7 @@ void PrintUString(int x, int y, BOOL cjustflag, const char *str, int col) c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= 257) { - PrintChar(sx, sy, c, col); + PrintChar(out, sx, sy, c, col); } sx += fontkern[c] + 1; } @@ -4002,37 +4002,37 @@ void DrawULine(int y) memcpy(dst, src, 266); // BUGFIX: should be 267 } -void DrawUniqueInfo() +void DrawUniqueInfo(CelOutputBuffer out) { int uid, y; if ((!chrflag && !questlog) || SCREEN_WIDTH >= SPANEL_WIDTH * 3) { uid = curruitem._iUid; DrawUTextBack(GlobalBackBuffer()); - PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, 2, TRUE, UniqueItemList[uid].UIName, 3); + PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, 2, TRUE, UniqueItemList[uid].UIName, 3); DrawULine(5); PrintItemPower(UniqueItemList[uid].UIPower1, &curruitem); y = 6 - UniqueItemList[uid].UINumPL + 8; - PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y, TRUE, tempstr, 0); + PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y, TRUE, tempstr, 0); if (UniqueItemList[uid].UINumPL > 1) { PrintItemPower(UniqueItemList[uid].UIPower2, &curruitem); - PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 2, TRUE, tempstr, 0); + PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 2, TRUE, tempstr, 0); } if (UniqueItemList[uid].UINumPL > 2) { PrintItemPower(UniqueItemList[uid].UIPower3, &curruitem); - PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 4, TRUE, tempstr, 0); + PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 4, TRUE, tempstr, 0); } if (UniqueItemList[uid].UINumPL > 3) { PrintItemPower(UniqueItemList[uid].UIPower4, &curruitem); - PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 6, TRUE, tempstr, 0); + PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 6, TRUE, tempstr, 0); } if (UniqueItemList[uid].UINumPL > 4) { PrintItemPower(UniqueItemList[uid].UIPower5, &curruitem); - PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 8, TRUE, tempstr, 0); + PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 8, TRUE, tempstr, 0); } if (UniqueItemList[uid].UINumPL > 5) { PrintItemPower(UniqueItemList[uid].UIPower6, &curruitem); - PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 10, TRUE, tempstr, 0); + PrintUString(out, 0 + RIGHT_PANEL - SPANEL_WIDTH, y + 10, TRUE, tempstr, 0); } } } diff --git a/Source/items.h b/Source/items.h index f64d37e67..5f27665a5 100644 --- a/Source/items.h +++ b/Source/items.h @@ -75,7 +75,7 @@ void DoRepair(int pnum, int cii); void DoRecharge(int pnum, int cii); void DoOil(int pnum, int cii); void PrintItemPower(char plidx, ItemStruct *x); -void DrawUniqueInfo(); +void DrawUniqueInfo(CelOutputBuffer out); void PrintItemDetails(ItemStruct *x); void PrintItemDur(ItemStruct *x); void UseItem(int p, int Mid, int spl); diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 0537c4ed8..e5645d889 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -84,7 +84,7 @@ void InitPlrMsg() plr_msg_slot = 0; } -void DrawPlrMsg() +void DrawPlrMsg(CelOutputBuffer out) { int i; DWORD x = 10 + SCREEN_X; @@ -105,13 +105,14 @@ void DrawPlrMsg() pMsg = plr_msgs; for (i = 0; i < PMSG_COUNT; i++) { if (pMsg->str[0]) - PrintPlrMsg(x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); + PrintPlrMsg(out, x, y, width, pMsg->str, text_color_from_player_num[pMsg->player]); pMsg++; y += 35; } } -void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col) +// TODO: Can be made static +void PrintPlrMsg(CelOutputBuffer out, DWORD x, DWORD y, DWORD width, const char *str, BYTE col) { int line = 0; @@ -141,7 +142,7 @@ void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col) c = gbFontTransTbl[(BYTE)*str++]; c = fontframe[c]; if (c) - PrintChar(sx, y, c, col); + PrintChar(out, sx, y, c, col); sx += fontkern[c] + 1; } diff --git a/Source/plrmsg.h b/Source/plrmsg.h index 2b51334e1..c9bb91a1a 100644 --- a/Source/plrmsg.h +++ b/Source/plrmsg.h @@ -6,6 +6,8 @@ #ifndef __PLRMSG_H__ #define __PLRMSG_H__ +#include "engine.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus @@ -24,8 +26,8 @@ size_t EventPlrMsg(const char *pszFmt, ...); void SendPlrMsg(int pnum, const char *pszStr); void ClearPlrMsg(); void InitPlrMsg(); -void DrawPlrMsg(); -void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col); +void DrawPlrMsg(CelOutputBuffer out); +void PrintPlrMsg(CelOutputBuffer out, DWORD x, DWORD y, DWORD width, const char *str, BYTE col); #ifdef __cplusplus } diff --git a/Source/quests.cpp b/Source/quests.cpp index 9fce2ef2a..651ccf811 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -802,7 +802,7 @@ void ResyncQuests() } } -void PrintQLString(int x, int y, BOOL cjustflag, const char *str, int col) +static void PrintQLString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, int col) { int len, width, i, k, sx, sy; BYTE c; @@ -820,33 +820,33 @@ void PrintQLString(int x, int y, BOOL cjustflag, const char *str, int col) sx += k; } if (qline == y) { - CelDraw(cjustflag ? x + k + 12 + SCREEN_X : x + 12 + SCREEN_X, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, cjustflag ? x + k + 12 + SCREEN_X : x + 12 + SCREEN_X, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); } for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= 257) { - PrintChar(sx, sy, c, col); + PrintChar(out, sx, sy, c, col); } sx += fontkern[c] + 1; } if (qline == y) { - CelDraw(cjustflag ? x + k + 36 + SCREEN_X : 276 + SCREEN_X - x, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); + CelDrawTo(out, cjustflag ? x + k + 36 + SCREEN_X : 276 + SCREEN_X - x, sy + 1, pSPentSpn2Cels, PentSpn2Spin(), 12); } } -void DrawQuestLog() +void DrawQuestLog(CelOutputBuffer out) { int y, i; - PrintQLString(0, 2, TRUE, "Quest Log", 3); - CelDraw(SCREEN_X, SCREEN_Y + 351, pQLogCel, 1, SPANEL_WIDTH); + PrintQLString(out, 0, 2, TRUE, "Quest Log", 3); + CelDrawTo(out, SCREEN_X, SCREEN_Y + 351, pQLogCel, 1, SPANEL_WIDTH); y = qtopline; for (i = 0; i < numqlines; i++) { - PrintQLString(0, y, TRUE, questlist[qlist[i]]._qlstr, 0); + PrintQLString(out, 0, y, TRUE, questlist[qlist[i]]._qlstr, 0); y += 2; } - PrintQLString(0, 22, TRUE, "Close Quest Log", 0); + PrintQLString(out, 0, 22, TRUE, "Close Quest Log", 0); } void StartQuestlog() diff --git a/Source/quests.h b/Source/quests.h index 2fbca2db9..07e38d74a 100644 --- a/Source/quests.h +++ b/Source/quests.h @@ -6,6 +6,8 @@ #ifndef __QUESTS_H__ #define __QUESTS_H__ +#include "engine.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus @@ -59,7 +61,7 @@ void GetReturnLvlPos(); void LoadPWaterPalette(); void ResyncMPQuests(); void ResyncQuests(); -void DrawQuestLog(); +void DrawQuestLog(CelOutputBuffer out); void StartQuestlog(); void QuestlogUp(); void QuestlogDown(); diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index a614360a7..6c11245ec 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1217,7 +1217,7 @@ static void DrawGame(int x, int y) } // DevilutionX extension. -extern void DrawControllerModifierHints(); +extern void DrawControllerModifierHints(CelOutputBuffer out); /** * @brief Start rendering of screen, town variation @@ -1237,22 +1237,22 @@ void DrawView(int StartX, int StartY) if (invflag) { DrawInv(); } else if (sbookflag) { - DrawSpellBook(); + DrawSpellBook(out); } DrawDurIcon(); if (chrflag) { - DrawChr(); + DrawChr(out); } else if (questlog) { - DrawQuestLog(); + DrawQuestLog(out); } if (!chrflag && plr[myplr]._pStatPts != 0 && !spselflag && (!questlog || SCREEN_HEIGHT >= SPANEL_HEIGHT + PANEL_HEIGHT + 74 || SCREEN_WIDTH >= 4 * SPANEL_WIDTH)) { - DrawLevelUpIcon(); + DrawLevelUpIcon(out); } if (uitemflag) { - DrawUniqueInfo(); + DrawUniqueInfo(out); } if (qtextflag) { DrawQText(out); @@ -1261,13 +1261,13 @@ void DrawView(int StartX, int StartY) DrawSpellList(); } if (dropGoldFlag) { - DrawGoldSplit(dropGoldValue); + DrawGoldSplit(out, dropGoldValue); } if (helpflag) { DrawHelp(out); } if (msgflag) { - DrawDiabloMsg(); + DrawDiabloMsg(out); } if (deathflag) { RedBack(); @@ -1275,11 +1275,11 @@ void DrawView(int StartX, int StartY) gmenu_draw_pause(); } - DrawControllerModifierHints(); - DrawPlrMsg(); + DrawControllerModifierHints(out); + DrawPlrMsg(out); gmenu_draw(); doom_draw(); - DrawInfoBox(); + DrawInfoBox(out); DrawLifeFlask(); DrawManaFlask(); } @@ -1401,7 +1401,7 @@ void EnableFrameCount() /** * @brief Display the current average FPS over 1 sec */ -static void DrawFPS() +static void DrawFPS(CelOutputBuffer out) { DWORD tc, frames; char String[12]; @@ -1416,7 +1416,7 @@ static void DrawFPS() frameend = 0; } snprintf(String, 12, "%d FPS", framerate); - PrintGameStr(8, 65, String, COL_RED); + PrintGameStr(out, 8, 65, String, COL_RED); } } @@ -1560,29 +1560,31 @@ void DrawAndBlit() force_redraw = 0; lock_buf(0); + CelOutputBuffer out = GlobalBackBuffer(); + DrawView(ViewX, ViewY); if (ctrlPan) { - DrawCtrlPan(); + DrawCtrlPan(out); } if (drawhpflag) { - UpdateLifeFlask(); + UpdateLifeFlask(out); } if (drawmanaflag) { - UpdateManaFlask(); + UpdateManaFlask(out); } if (drawbtnflag) { - DrawCtrlBtns(); + DrawCtrlBtns(out); } if (drawsbarflag) { - DrawInvBelt(); + DrawInvBelt(out); } if (talkflag) { - DrawTalkPan(); + DrawTalkPan(out); hgt = SCREEN_HEIGHT; } scrollrt_draw_cursor_item(); - DrawFPS(); + DrawFPS(out); unlock_buf(0); diff --git a/Source/stores.cpp b/Source/stores.cpp index 54d426d58..d923e1a3e 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -124,7 +124,7 @@ static void DrawSTextBack(CelOutputBuffer out) DrawHalfTransparentRectTo(out, PANEL_LEFT + 347, UI_OFFSET_Y + 28, 265, 297); } -void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int val) +void PrintSString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, char col, int val) { int len, width, sx, sy, i, k, s; int xx, yy; @@ -159,7 +159,7 @@ void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int v c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c != 0 && k <= yy) { - PrintChar(sx, sy, c, col); + PrintChar(out, sx, sy, c, col); } sx += fontkern[c] + 1; } @@ -171,7 +171,7 @@ void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int v c = fontframe[gbFontTransTbl[(BYTE)valstr[i]]]; sx -= fontkern[c] + 1; if (c != 0) { - PrintChar(sx, sy, c, col); + PrintChar(out, sx, sy, c, col); } } } @@ -209,23 +209,23 @@ void DrawSLine(int y) memcpy(dst, src, BUFFER_WIDTH - line); } -void DrawSSlider(int y1, int y2) +static void DrawSSlider(CelOutputBuffer out, int y1, int y2) { int yd1, yd2, yd3; yd1 = y1 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y; yd2 = y2 * 12 + 44 + SCREEN_Y + UI_OFFSET_Y; if (stextscrlubtn != -1) - CelDraw(PANEL_X + 601, yd1, pSTextSlidCels, 12, 12); + CelDrawTo(out, PANEL_X + 601, yd1, pSTextSlidCels, 12, 12); else - CelDraw(PANEL_X + 601, yd1, pSTextSlidCels, 10, 12); + CelDrawTo(out, PANEL_X + 601, yd1, pSTextSlidCels, 10, 12); if (stextscrldbtn != -1) - CelDraw(PANEL_X + 601, yd2, pSTextSlidCels, 11, 12); + CelDrawTo(out, PANEL_X + 601, yd2, pSTextSlidCels, 11, 12); else - CelDraw(PANEL_X + 601, yd2, pSTextSlidCels, 9, 12); + CelDrawTo(out, PANEL_X + 601, yd2, pSTextSlidCels, 9, 12); yd1 += 12; for (yd3 = yd1; yd3 < yd2; yd3 += 12) { - CelDraw(PANEL_X + 601, yd3, pSTextSlidCels, 14, 12); + CelDrawTo(out, PANEL_X + 601, yd3, pSTextSlidCels, 14, 12); } if (stextsel == 22) yd3 = stextlhold; @@ -235,7 +235,7 @@ void DrawSSlider(int y1, int y2) yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000; else yd3 = 0; - CelDraw(PANEL_X + 601, (y1 + 1) * 12 + 44 + SCREEN_Y + UI_OFFSET_Y + yd3, pSTextSlidCels, 13, 12); + CelDrawTo(out, PANEL_X + 601, (y1 + 1) * 12 + 44 + SCREEN_Y + UI_OFFSET_Y + yd3, pSTextSlidCels, 13, 12); } void DrawSTextHelp() @@ -1612,11 +1612,11 @@ void DrawSText(CelOutputBuffer out) if (stext[i]._sline) DrawSLine(i); if (stext[i]._sstr[0]) - PrintSString(stext[i]._sx, i, stext[i]._sjust, stext[i]._sstr, stext[i]._sclr, stext[i]._sval); + PrintSString(out, stext[i]._sx, i, stext[i]._sjust, stext[i]._sstr, stext[i]._sclr, stext[i]._sval); } if (stextscrl) - DrawSSlider(4, 20); + DrawSSlider(out, 4, 20); } void STextESC() diff --git a/Source/stores.h b/Source/stores.h index 088e2e8cd..24205c60a 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -6,6 +6,8 @@ #ifndef __STORES_H__ #define __STORES_H__ +#include "engine.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus @@ -41,7 +43,7 @@ void InitStores(); int PentSpn2Spin(); void SetupTownStores(); void FreeStoreMem(); -void PrintSString(int x, int y, BOOL cjustflag, const char *str, char col, int val); +void PrintSString(CelOutputBuffer out, int x, int y, BOOL cjustflag, const char *str, char col, int val); void DrawSLine(int y); void DrawSTextHelp(); void ClearSText(int s, int e); diff --git a/SourceS/thread.h b/SourceS/thread.h index 413d6831a..13a619077 100644 --- a/SourceS/thread.h +++ b/SourceS/thread.h @@ -1,5 +1,11 @@ #pragma once +#include + +#ifdef USE_SDL1 +#include "sdl2_to_1_2_backports.h" +#endif + namespace dvl { typedef struct event_emul { diff --git a/SourceX/controls/modifier_hints.cpp b/SourceX/controls/modifier_hints.cpp index 8b658c8d7..c5290d6d1 100644 --- a/SourceX/controls/modifier_hints.cpp +++ b/SourceX/controls/modifier_hints.cpp @@ -1,142 +1,142 @@ -#include "controls/modifier_hints.h" - -#include - -#include "all.h" -#include "controls/controller.h" -#include "controls/game_controls.h" - -namespace dvl { - -namespace { - -int CalculateTextWidth(const char *s) -{ - int l = 0; - while (*s) { - l += fontkern[fontframe[gbFontTransTbl[static_cast(*s++)]]] + 1; - } - return l; -} - -int SpaceWidth() -{ - static const int kSpaceWidth = CalculateTextWidth(" "); - return kSpaceWidth; -} - -struct CircleMenuHint { - CircleMenuHint(bool is_dpad, const char *top, const char *right, const char *bottom, const char *left) - : is_dpad(is_dpad) - , top(top) - , top_w(CalculateTextWidth(top)) - , right(right) - , right_w(CalculateTextWidth(right)) - , bottom(bottom) - , bottom_w(CalculateTextWidth(bottom)) - , left(left) - , left_w(CalculateTextWidth(left)) - , x_mid(left_w + SpaceWidth() * 2.5) - { - } - - int width() const - { - return 2 * x_mid; - } - - bool is_dpad; - - const char *top; - int top_w; - const char *right; - int right_w; - const char *bottom; - int bottom_w; - const char *left; - int left_w; - - int x_mid; -}; - -bool IsTopActive(const CircleMenuHint &hint) -{ - if (hint.is_dpad) - return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_UP); - return IsControllerButtonPressed(ControllerButton_BUTTON_Y); -} - -bool IsRightActive(const CircleMenuHint &hint) -{ - if (hint.is_dpad) - return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_RIGHT); - return IsControllerButtonPressed(ControllerButton_BUTTON_B); -} - -bool IsBottomActive(const CircleMenuHint &hint) -{ - if (hint.is_dpad) - return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_DOWN); - return IsControllerButtonPressed(ControllerButton_BUTTON_A); -} - -bool IsLeftActive(const CircleMenuHint &hint) -{ - if (hint.is_dpad) - return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_LEFT); - return IsControllerButtonPressed(ControllerButton_BUTTON_X); -} - -text_color CircleMenuHintTextColor(bool active) -{ - return active ? COL_BLUE : COL_GOLD; -} - -void DrawCircleMenuHint(const CircleMenuHint &hint, int x, int y) -{ - const int kLineHeight = 25; - PrintGameStr(x + hint.x_mid - hint.top_w / 2, y, hint.top, CircleMenuHintTextColor(IsTopActive(hint))); - y += kLineHeight; - - PrintGameStr(x, y, hint.left, CircleMenuHintTextColor(IsLeftActive(hint))); - PrintGameStr(x + hint.left_w + 5 * SpaceWidth(), y, hint.right, CircleMenuHintTextColor(IsRightActive(hint))); - y += kLineHeight; - - PrintGameStr(x + hint.x_mid - hint.bottom_w / 2, y, hint.bottom, CircleMenuHintTextColor(IsBottomActive(hint))); -} - -const int kCircleMarginX = 16; -const int kCirclesTop = 76; - -void DrawStartModifierMenu() -{ - if (!start_modifier_active) - return; - static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"Menu", /*right=*/"Inv", /*bottom=*/"Map", /*left=*/"Char"); - static const CircleMenuHint kButtons(/*is_dpad=*/false, /*top=*/"", /*right=*/"", /*bottom=*/"Spells", /*left=*/"Quests"); - DrawCircleMenuHint(kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop); - DrawCircleMenuHint(kButtons, PANEL_LEFT + PANEL_WIDTH - kButtons.width() - kCircleMarginX, PANEL_TOP - kCirclesTop); -} - -void DrawSelectModifierMenu() -{ - if (!select_modifier_active) - return; - if (dpad_hotkeys) - { - static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"F6", /*right=*/"F8", /*bottom=*/"F7", /*left=*/"F5"); - DrawCircleMenuHint(kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop); - } - static const CircleMenuHint kSpells(/*is_dpad=*/false, "F6", "F8", "F7", "F5"); - DrawCircleMenuHint(kSpells, PANEL_LEFT + PANEL_WIDTH - kSpells.width() - kCircleMarginX, PANEL_TOP - kCirclesTop); -} - -} // namespace - -void DrawControllerModifierHints() -{ - DrawStartModifierMenu(); - DrawSelectModifierMenu(); -} - -} // namespace dvl +#include "controls/modifier_hints.h" + +#include + +#include "all.h" +#include "controls/controller.h" +#include "controls/game_controls.h" + +namespace dvl { + +namespace { + +int CalculateTextWidth(const char *s) +{ + int l = 0; + while (*s) { + l += fontkern[fontframe[gbFontTransTbl[static_cast(*s++)]]] + 1; + } + return l; +} + +int SpaceWidth() +{ + static const int kSpaceWidth = CalculateTextWidth(" "); + return kSpaceWidth; +} + +struct CircleMenuHint { + CircleMenuHint(bool is_dpad, const char *top, const char *right, const char *bottom, const char *left) + : is_dpad(is_dpad) + , top(top) + , top_w(CalculateTextWidth(top)) + , right(right) + , right_w(CalculateTextWidth(right)) + , bottom(bottom) + , bottom_w(CalculateTextWidth(bottom)) + , left(left) + , left_w(CalculateTextWidth(left)) + , x_mid(left_w + SpaceWidth() * 2.5) + { + } + + int width() const + { + return 2 * x_mid; + } + + bool is_dpad; + + const char *top; + int top_w; + const char *right; + int right_w; + const char *bottom; + int bottom_w; + const char *left; + int left_w; + + int x_mid; +}; + +bool IsTopActive(const CircleMenuHint &hint) +{ + if (hint.is_dpad) + return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_UP); + return IsControllerButtonPressed(ControllerButton_BUTTON_Y); +} + +bool IsRightActive(const CircleMenuHint &hint) +{ + if (hint.is_dpad) + return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_RIGHT); + return IsControllerButtonPressed(ControllerButton_BUTTON_B); +} + +bool IsBottomActive(const CircleMenuHint &hint) +{ + if (hint.is_dpad) + return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_DOWN); + return IsControllerButtonPressed(ControllerButton_BUTTON_A); +} + +bool IsLeftActive(const CircleMenuHint &hint) +{ + if (hint.is_dpad) + return IsControllerButtonPressed(ControllerButton_BUTTON_DPAD_LEFT); + return IsControllerButtonPressed(ControllerButton_BUTTON_X); +} + +text_color CircleMenuHintTextColor(bool active) +{ + return active ? COL_BLUE : COL_GOLD; +} + +void DrawCircleMenuHint(CelOutputBuffer out, const CircleMenuHint &hint, int x, int y) +{ + const int kLineHeight = 25; + PrintGameStr(out, x + hint.x_mid - hint.top_w / 2, y, hint.top, CircleMenuHintTextColor(IsTopActive(hint))); + y += kLineHeight; + + PrintGameStr(out, x, y, hint.left, CircleMenuHintTextColor(IsLeftActive(hint))); + PrintGameStr(out, x + hint.left_w + 5 * SpaceWidth(), y, hint.right, CircleMenuHintTextColor(IsRightActive(hint))); + y += kLineHeight; + + PrintGameStr(out, x + hint.x_mid - hint.bottom_w / 2, y, hint.bottom, CircleMenuHintTextColor(IsBottomActive(hint))); +} + +const int kCircleMarginX = 16; +const int kCirclesTop = 76; + +void DrawStartModifierMenu(CelOutputBuffer out) +{ + if (!start_modifier_active) + return; + static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"Menu", /*right=*/"Inv", /*bottom=*/"Map", /*left=*/"Char"); + static const CircleMenuHint kButtons(/*is_dpad=*/false, /*top=*/"", /*right=*/"", /*bottom=*/"Spells", /*left=*/"Quests"); + DrawCircleMenuHint(out, kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop); + DrawCircleMenuHint(out, kButtons, PANEL_LEFT + PANEL_WIDTH - kButtons.width() - kCircleMarginX, PANEL_TOP - kCirclesTop); +} + +void DrawSelectModifierMenu(CelOutputBuffer out) +{ + if (!select_modifier_active) + return; + if (dpad_hotkeys) + { + static const CircleMenuHint kDpad(/*is_dpad=*/true, /*top=*/"F6", /*right=*/"F8", /*bottom=*/"F7", /*left=*/"F5"); + DrawCircleMenuHint(out, kDpad, PANEL_LEFT + kCircleMarginX, PANEL_TOP - kCirclesTop); + } + static const CircleMenuHint kSpells(/*is_dpad=*/false, "F6", "F8", "F7", "F5"); + DrawCircleMenuHint(out, kSpells, PANEL_LEFT + PANEL_WIDTH - kSpells.width() - kCircleMarginX, PANEL_TOP - kCirclesTop); +} + +} // namespace + +void DrawControllerModifierHints(CelOutputBuffer out) +{ + DrawStartModifierMenu(out); + DrawSelectModifierMenu(out); +} + +} // namespace dvl diff --git a/SourceX/controls/modifier_hints.h b/SourceX/controls/modifier_hints.h index 0095d8ada..eab367e0a 100644 --- a/SourceX/controls/modifier_hints.h +++ b/SourceX/controls/modifier_hints.h @@ -1,7 +1,9 @@ -#pragma once - -namespace dvl { - -void DrawControllerModifierHints(); - -} // namespace dvl +#pragma once + +#include "engine.h" + +namespace dvl { + +void DrawControllerModifierHints(CelOutputBuffer out); + +} // namespace dvl