Browse Source

inventory items rendering cleanup (#1938)

pull/1968/head
qndel 5 years ago committed by GitHub
parent
commit
89c40eaa7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      Source/engine/render/cel_render.cpp
  2. 17
      Source/engine/render/cel_render.hpp
  3. 31
      Source/inv.cpp
  4. 10
      Source/scrollrt.cpp

18
Source/engine/render/cel_render.cpp

@ -647,12 +647,20 @@ void CelClippedDrawLightTo(const CelOutputBuffer &out, int sx, int sy, const Cel
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame)); CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
} }
void CelDrawLightRedTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame, char light) void CelDrawLightRedTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
{ {
int nDataSize; int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize); const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
const std::uint8_t *tbl = GetLightTable(light); RenderCelWithLightTable(out, { sx, sy }, pRLEBytes, nDataSize, cel.Width(frame), GetLightTable(1));
RenderCelWithLightTable(out, { sx, sy }, pRLEBytes, nDataSize, cel.Width(frame), tbl); }
void CelDrawItem(bool usable, const CelOutputBuffer &out, int x, int y, const CelSprite &cel, int frame)
{
if (usable) {
CelDrawLightRedTo(out, x, y, cel, frame);
} else {
CelClippedDrawTo(out, x, y, cel, frame);
}
} }
void CelClippedDrawSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame) void CelClippedDrawSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
@ -678,11 +686,11 @@ void CelClippedBlitLightTransTo(const CelOutputBuffer &out, int sx, int sy, cons
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame)); CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
} }
void CelDrawLightRedSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame, char light) void CelDrawLightRedSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
{ {
int nDataSize; int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize); const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
RenderCelWithLightTable(out, { sx, sy }, pRLEBytes, nDataSize, cel.Width(frame), GetLightTable(light)); RenderCelWithLightTable(out, { sx, sy }, pRLEBytes, nDataSize, cel.Width(frame), GetLightTable(1));
} }
void CelDrawUnsafeTo(const CelOutputBuffer &out, int x, int y, const CelSprite &cel, int frame) void CelDrawUnsafeTo(const CelOutputBuffer &out, int x, int y, const CelSprite &cel, int frame)

17
Source/engine/render/cel_render.hpp

@ -84,9 +84,19 @@ void CelClippedBlitLightTransTo(const CelOutputBuffer &out, int sx, int sy, cons
* @param sy Target buffer coordinate * @param sy Target buffer coordinate
* @param cel CEL sprite * @param cel CEL sprite
* @param frame CEL frame number * @param frame CEL frame number
* @param light Light shade to use
*/ */
void CelDrawLightRedTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame, char light); void CelDrawLightRedTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
/**
* @brief Blit item's CEL sprite recolored red if not usable, normal if usable
* @param usable indicates if the item should be recolored red or not
* @param out Target buffer
* @param x Target buffer coordinate
* @param y Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelDrawItem(bool usable, const CelOutputBuffer &out, int x, int y, const CelSprite &cel, int frame);
/** /**
* @brief Same as CelClippedDrawTo but checks for drawing outside the buffer * @brief Same as CelClippedDrawTo but checks for drawing outside the buffer
@ -105,9 +115,8 @@ void CelClippedDrawSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelS
* @param sy Target buffer coordinate * @param sy Target buffer coordinate
* @param cel CEL sprite * @param cel CEL sprite
* @param frame CEL frame number * @param frame CEL frame number
* @param light Light shade to use
*/ */
void CelDrawLightRedSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame, char light); void CelDrawLightRedSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
/** /**
* @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the target buffer at the given coordianates * @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the target buffer at the given coordianates

31
Source/inv.cpp

@ -230,11 +230,7 @@ void DrawInv(const CelOutputBuffer &out)
CelBlitOutlineTo(out, GetOutlineColor(plr[myplr].InvBody[slot], true), RIGHT_PANEL_X + screen_x, screen_y, cel, celFrame, false); CelBlitOutlineTo(out, GetOutlineColor(plr[myplr].InvBody[slot], true), RIGHT_PANEL_X + screen_x, screen_y, cel, celFrame, false);
} }
if (plr[myplr].InvBody[slot]._iStatFlag) { CelDrawItem(plr[myplr].InvBody[slot]._iStatFlag, out, RIGHT_PANEL_X + screen_x, screen_y, cel, celFrame);
CelClippedDrawTo(out, RIGHT_PANEL_X + screen_x, screen_y, cel, celFrame);
} else {
CelDrawLightRedTo(out, RIGHT_PANEL_X + screen_x, screen_y, cel, celFrame, 1);
}
if (slot == INVLOC_HAND_LEFT) { if (slot == INVLOC_HAND_LEFT) {
if (plr[myplr].InvBody[slot]._iLoc == ILOC_TWOHAND) { if (plr[myplr].InvBody[slot]._iLoc == ILOC_TWOHAND) {
@ -284,19 +280,12 @@ void DrawInv(const CelOutputBuffer &out)
cel, celFrame, false); cel, celFrame, false);
} }
if (plr[myplr].InvList[ii]._iStatFlag) { CelDrawItem(
CelClippedDrawTo( plr[myplr].InvList[ii]._iStatFlag,
out, out,
InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X,
InvRect[j + SLOTXY_INV_FIRST].Y - 1, InvRect[j + SLOTXY_INV_FIRST].Y - 1,
cel, celFrame); cel, celFrame);
} else {
CelDrawLightRedTo(
out,
InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X,
InvRect[j + SLOTXY_INV_FIRST].Y - 1,
cel, celFrame, 1);
}
} }
} }
} }
@ -326,11 +315,7 @@ void DrawInvBelt(const CelOutputBuffer &out)
} }
} }
if (plr[myplr].SpdList[i]._iStatFlag) { CelDrawItem(plr[myplr].SpdList[i]._iStatFlag, out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, cel, celFrame);
CelClippedDrawTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, cel, celFrame);
} else {
CelDrawLightRedTo(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, cel, celFrame, 1);
}
if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable
&& plr[myplr].SpdList[i]._iStatFlag && plr[myplr].SpdList[i]._iStatFlag

10
Source/scrollrt.cpp

@ -186,17 +186,13 @@ static void DrawCursor(const CelOutputBuffer &out)
const auto &sprite = GetInvItemSprite(pcurs); const auto &sprite = GetInvItemSprite(pcurs);
const int frame = GetInvItemFrame(pcurs); const int frame = GetInvItemFrame(pcurs);
bool usable = true;
if (pcurs >= CURSOR_FIRSTITEM) { if (pcurs >= CURSOR_FIRSTITEM) {
const auto &heldItem = plr[myplr].HoldItem; const auto &heldItem = plr[myplr].HoldItem;
CelBlitOutlineTo(out, GetOutlineColor(heldItem, true), MouseX, MouseY + cursH - 1, sprite, frame, false); CelBlitOutlineTo(out, GetOutlineColor(heldItem, true), MouseX, MouseY + cursH - 1, sprite, frame, false);
if (heldItem._iStatFlag) { usable = heldItem._iStatFlag;
CelClippedDrawSafeTo(out, MouseX, MouseY + cursH - 1, sprite, frame);
} else {
CelDrawLightRedSafeTo(out, MouseX, MouseY + cursH - 1, sprite, frame, 1);
}
} else {
CelClippedDrawSafeTo(out, MouseX, MouseY + cursH - 1, sprite, frame);
} }
CelDrawItem(usable, out, MouseX, MouseY + cursH - 1, sprite, frame);
} }
/** /**

Loading…
Cancel
Save