Browse Source

♻️Use DrawString in error.cpp

pull/1899/head
Anders Jenbo 5 years ago
parent
commit
8361e70087
  1. 32
      Source/error.cpp
  2. 28
      Source/help.cpp
  3. 13
      Source/inv.cpp

32
Source/error.cpp

@ -109,22 +109,19 @@ void ClrDiabloMsg()
void DrawDiabloMsg(const CelOutputBuffer &out)
{
int i, len, width, sx, sy;
BYTE c;
CelDrawTo(out, PANEL_X + 101, DIALOG_Y, *pSTextSlidCels, 1);
CelDrawTo(out, PANEL_X + 527, DIALOG_Y, *pSTextSlidCels, 4);
CelDrawTo(out, PANEL_X + 101, DIALOG_Y + 48, *pSTextSlidCels, 2);
CelDrawTo(out, PANEL_X + 527, DIALOG_Y + 48, *pSTextSlidCels, 3);
sx = PANEL_X + 109;
for (i = 0; i < 35; i++) {
int sx = PANEL_X + 109;
for (int i = 0; i < 35; i++) {
CelDrawTo(out, sx, DIALOG_Y, *pSTextSlidCels, 5);
CelDrawTo(out, sx, DIALOG_Y + 48, *pSTextSlidCels, 7);
sx += 12;
}
sy = DIALOG_Y + 12;
for (i = 0; i < 3; i++) {
int sy = DIALOG_Y + 12;
for (int i = 0; i < 3; i++) {
CelDrawTo(out, PANEL_X + 101, sy, *pSTextSlidCels, 6);
CelDrawTo(out, PANEL_X + 527, sy, *pSTextSlidCels, 8);
sy += 12;
@ -133,26 +130,7 @@ void DrawDiabloMsg(const CelOutputBuffer &out)
DrawHalfTransparentRectTo(out, PANEL_X + 104, DIALOG_Y - 8, 432, 54);
strcpy(tempstr, _(MsgStrings[msgflag]));
sx = PANEL_X + 101;
sy = DIALOG_Y + 24;
len = strlen(tempstr);
width = 0;
for (i = 0; i < len; i++) {
width += fontkern[GameFontSmall][fontframe[GameFontSmall][gbFontTransTbl[(BYTE)tempstr[i]]]] + 1;
}
if (width < 442) {
sx += (442 - width) / 2;
}
for (i = 0; i < len; i++) {
c = fontframe[GameFontSmall][gbFontTransTbl[(BYTE)tempstr[i]]];
if (c != '\0') {
PrintChar(out, sx, sy, c, COL_GOLD);
}
sx += fontkern[GameFontSmall][c] + 1;
}
DrawString(out, tempstr, { PANEL_X + 101, DIALOG_Y + 24, 442, 0 }, UIS_CENTER);
if (msgdelay > 0 && msgdelay <= SDL_GetTicks() - 3500) {
msgdelay = 0;

28
Source/help.cpp

@ -459,25 +459,11 @@ void InitHelp()
helpflag = false;
}
static void DrawHelpLine(const CelOutputBuffer &out, int x, int y, char *text, text_color color)
static void DrawHelpLine(const CelOutputBuffer &out, int x, int y, char *text, uint16_t style)
{
int sx, sy, width;
BYTE c;
width = 0;
sx = x + 32 + PANEL_X;
sy = y * 12 + 44 + UI_OFFSET_Y;
while (*text) {
c = gbFontTransTbl[(BYTE)*text];
text++;
c = fontframe[GameFontSmall][c];
width += fontkern[GameFontSmall][c] + 1;
if (c) {
if (width <= 577)
PrintChar(out, sx, sy, c, color);
}
sx += fontkern[GameFontSmall][c] + 1;
}
const int sx = x + 32 + PANEL_X;
const int sy = y * 12 + 44 + UI_OFFSET_Y;
DrawString(out, text, { sx, sy, 577, 0 }, style);
}
void DrawHelp(const CelOutputBuffer &out)
@ -535,10 +521,10 @@ void DrawHelp(const CelOutputBuffer &out)
while (*s == '\0') {
s++;
}
text_color col = COL_WHITE;
uint16_t style = UIS_SILVER;
if (*s == '$') {
s++;
col = COL_RED;
style = UIS_RED;
}
if (*s == '&') {
HelpTop = help_select_line;
@ -563,7 +549,7 @@ void DrawHelp(const CelOutputBuffer &out)
}
if (c != 0) {
tempstr[c] = '\0';
DrawHelpLine(out, 0, i, tempstr, col);
DrawHelpLine(out, 0, i, tempstr, style);
}
if (*s == '|') {
s++;

13
Source/inv.cpp

@ -301,8 +301,6 @@ void DrawInv(const CelOutputBuffer &out)
void DrawInvBelt(const CelOutputBuffer &out)
{
BYTE fi, ff;
if (talkflag) {
return;
}
@ -335,9 +333,14 @@ void DrawInvBelt(const CelOutputBuffer &out)
if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable
&& plr[myplr].SpdList[i]._iStatFlag
&& plr[myplr].SpdList[i]._itype != ITYPE_GOLD) {
fi = i + 49;
ff = fontframe[GameFontSmall][gbFontTransTbl[fi]];
PrintChar(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X + INV_SLOT_SIZE_PX - fontkern[GameFontSmall][ff], InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, ff, COL_WHITE);
sprintf(tempstr, "%d", i + 1);
SDL_Rect rect {
InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X + INV_SLOT_SIZE_PX - GetLineWidth(tempstr),
InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1,
0,
0
};
DrawString(out, tempstr, rect, UIS_SILVER);
}
}
}

Loading…
Cancel
Save