Browse Source

Reduced the size of `OwnedCelSprite*` by 8 bytes

`OwnedCelSpriteWithFrameHeight`: 40 -> 32
pull/4759/head
Gleb Mazovetskiy 4 years ago committed by Anders Jenbo
parent
commit
8e9c9e0238
  1. 4
      Source/DiabloUI/diabloui.cpp
  2. 33
      Source/control.cpp
  3. 2
      Source/controls/touch/renderers.cpp
  4. 2
      Source/cursor.cpp
  5. 2
      Source/doom.cpp
  6. 21
      Source/engine/cel_sprite.hpp
  7. 4
      Source/engine/render/text_render.cpp
  8. 17
      Source/error.cpp
  9. 12
      Source/gmenu.cpp
  10. 2
      Source/interfac.cpp
  11. 8
      Source/inv.cpp
  12. 2
      Source/items.cpp
  13. 2
      Source/minitext.cpp
  14. 9
      Source/panels/charpanel.cpp
  15. 6
      Source/panels/spell_book.cpp
  16. 2
      Source/panels/spell_icons.cpp
  17. 4
      Source/qol/stash.cpp
  18. 6
      Source/quests.cpp
  19. 6
      Source/scrollrt.cpp
  20. 19
      Source/stores.cpp

4
Source/DiabloUI/diabloui.cpp

@ -713,7 +713,7 @@ void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog, int size, in
{
SDL_Rect rect = MakeSdlRect(0, GetUIRectangle().position.y + y, 0, 0);
vecDialog->push_back(std::make_unique<UiImageCel>(
CelSpriteWithFrameHeight { ArtLogos[size]->sprite, ArtLogos[size]->frameHeight }, rect, UiFlags::AlignCenter, /*bAnimated=*/true));
CelSpriteWithFrameHeight { CelSprite { ArtLogos[size]->sprite }, ArtLogos[size]->frameHeight }, rect, UiFlags::AlignCenter, /*bAnimated=*/true));
}
void UiFadeIn()
@ -756,7 +756,7 @@ void DrawSelector(const SDL_Rect &rect)
size = FOCUS_BIG;
else if (rect.h >= 30)
size = FOCUS_MED;
CelSpriteWithFrameHeight sprite { ArtFocus[size]->sprite, ArtFocus[size]->frameHeight };
CelSpriteWithFrameHeight sprite { CelSprite { ArtFocus[size]->sprite }, ArtFocus[size]->frameHeight };
// TODO FOCUS_MED appares higher than the box
const int y = rect.y + (rect.h - static_cast<int>(sprite.frameHeight)) / 2;

33
Source/control.cpp

@ -314,7 +314,7 @@ int DrawDurIcon4Item(const Surface &out, Item &pItem, int x, int c)
}
if (pItem._iDurability > 2)
c += 8;
CelDrawTo(out, { x, -17 + GetMainPanel().position.y }, *pDurIcons, c);
CelDrawTo(out, { x, -17 + GetMainPanel().position.y }, CelSprite { *pDurIcons }, c);
return x - 32 - 8;
}
@ -548,16 +548,22 @@ void InitControlPan()
LoadCharPanel();
LoadSpellIcons();
CelDrawUnsafeTo(*pBtmBuff, { 0, (GetMainPanel().size.height + 16) - 1 }, LoadCel("CtrlPan\\Panel8.CEL", GetMainPanel().size.width), 0);
{
const OwnedCelSprite sprite = LoadCel("CtrlPan\\Panel8.CEL", GetMainPanel().size.width);
CelDrawUnsafeTo(*pBtmBuff, { 0, (GetMainPanel().size.height + 16) - 1 }, CelSprite { sprite }, 0);
}
{
const Point bulbsPosition { 0, 87 };
const OwnedCelSprite statusPanel = LoadCel("CtrlPan\\P8Bulbs.CEL", 88);
CelDrawUnsafeTo(*pLifeBuff, bulbsPosition, statusPanel, 0);
CelDrawUnsafeTo(*pManaBuff, bulbsPosition, statusPanel, 1);
CelDrawUnsafeTo(*pLifeBuff, bulbsPosition, CelSprite { statusPanel }, 0);
CelDrawUnsafeTo(*pManaBuff, bulbsPosition, CelSprite { statusPanel }, 1);
}
talkflag = false;
if (IsChatAvailable()) {
CelDrawUnsafeTo(*pBtmBuff, { 0, (GetMainPanel().size.height + 16) * 2 - 1 }, LoadCel("CtrlPan\\TalkPanl.CEL", GetMainPanel().size.width), 0);
{
const OwnedCelSprite sprite = LoadCel("CtrlPan\\TalkPanl.CEL", GetMainPanel().size.width);
CelDrawUnsafeTo(*pBtmBuff, { 0, (GetMainPanel().size.height + 16) * 2 - 1 }, CelSprite { sprite }, 0);
}
multiButtons = LoadCel("CtrlPan\\P8But2.CEL", 33);
talkButtons = LoadCel("CtrlPan\\TalkButt.CEL", 61);
sgbPlrTalkTbl = 0;
@ -617,16 +623,17 @@ void DrawCtrlBtns(const Surface &out)
DrawPanelBox(out, MakeSdlRect(PanBtnPos[i].x, PanBtnPos[i].y + 16, 71, 20), mainPanelPosition + Displacement { PanBtnPos[i].x, PanBtnPos[i].y });
} else {
Point position = mainPanelPosition + Displacement { PanBtnPos[i].x, PanBtnPos[i].y + 18 };
CelDrawTo(out, position, *pPanelButtons, i);
CelDrawTo(out, position, CelSprite { *pPanelButtons }, i);
DrawArt(out, position + Displacement { 4, -18 }, &PanelButtonDown, i);
}
}
if (PanelButtonIndex == 8) {
CelDrawTo(out, mainPanelPosition + Displacement { 87, 122 }, *multiButtons, PanelButtons[6] ? 1 : 0);
CelSprite sprite { *multiButtons };
CelDrawTo(out, mainPanelPosition + Displacement { 87, 122 }, sprite, PanelButtons[6] ? 1 : 0);
if (MyPlayer->friendlyMode)
CelDrawTo(out, mainPanelPosition + Displacement { 527, 122 }, *multiButtons, PanelButtons[7] ? 3 : 2);
CelDrawTo(out, mainPanelPosition + Displacement { 527, 122 }, sprite, PanelButtons[7] ? 3 : 2);
else
CelDrawTo(out, mainPanelPosition + Displacement { 527, 122 }, *multiButtons, PanelButtons[7] ? 5 : 4);
CelDrawTo(out, mainPanelPosition + Displacement { 527, 122 }, sprite, PanelButtons[7] ? 5 : 4);
}
}
@ -951,7 +958,7 @@ void DrawLevelUpIcon(const Surface &out)
if (IsLevelUpButtonVisible()) {
int nCel = lvlbtndown ? 2 : 1;
DrawString(out, _("Level Up"), { GetMainPanel().position + Displacement { 0, -62 }, { 120, 0 } }, UiFlags::ColorWhite | UiFlags::AlignCenter);
CelDrawTo(out, GetMainPanel().position + Displacement { 40, -17 }, *pChrButtons, nCel);
CelDrawTo(out, GetMainPanel().position + Displacement { 40, -17 }, CelSprite { *pChrButtons }, nCel);
}
}
@ -1053,7 +1060,7 @@ void DrawGoldSplit(const Surface &out, int amount)
{
const int dialogX = 30;
CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { dialogX, 178 }), *pGBoxBuff, 0);
CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { dialogX, 178 }), CelSprite { *pGBoxBuff }, 0);
const std::string description = fmt::format(
fmt::runtime(ngettext(
@ -1142,14 +1149,14 @@ void DrawTalkPan(const Surface &out)
if (WhisperList[i]) {
if (TalkButtonsDown[talkBtn]) {
int nCel = talkBtn != 0 ? 3 : 2;
CelDrawTo(out, talkPanPosition, *talkButtons, nCel);
CelDrawTo(out, talkPanPosition, CelSprite { *talkButtons }, nCel);
DrawArt(out, talkPanPosition + Displacement { 4, -15 }, &TalkButton, 2);
}
} else {
int nCel = talkBtn != 0 ? 1 : 0;
if (TalkButtonsDown[talkBtn])
nCel += 4;
CelDrawTo(out, talkPanPosition, *talkButtons, nCel);
CelDrawTo(out, talkPanPosition, CelSprite { *talkButtons }, nCel);
DrawArt(out, talkPanPosition + Displacement { 4, -15 }, &TalkButton, TalkButtonsDown[talkBtn] ? 1 : 0);
}
if (player.plractive) {

2
Source/controls/touch/renderers.cpp

@ -141,7 +141,7 @@ void LoadPotionArt(Art *potionArt, SDL_Renderer *renderer)
for (item_cursor_graphic graphic : potionGraphics) {
const int cursorID = static_cast<int>(CURSOR_FIRSTITEM) + graphic;
const int frame = GetInvItemFrame(cursorID);
const OwnedCelSprite &potionSprite = GetInvItemSprite(cursorID);
const CelSprite potionSprite { GetInvItemSprite(cursorID) };
position.y += potionSize.height;
CelClippedDrawTo(Surface(surface.get()), position, potionSprite, frame);
}

2
Source/cursor.cpp

@ -195,7 +195,7 @@ void NewCursor(int cursId)
void CelDrawCursor(const Surface &out, Point position, int cursId)
{
const auto &sprite = GetInvItemSprite(cursId);
const CelSprite sprite { GetInvItemSprite(cursId) };
const int frame = GetInvItemFrame(cursId);
if (!MyPlayer->HoldItem.isEmpty()) {
const auto &heldItem = MyPlayer->HoldItem;

2
Source/doom.cpp

@ -37,7 +37,7 @@ void doom_draw(const Surface &out)
return;
}
CelDrawTo(out, GetUIRectangle().position + Displacement { 0, 352 }, *DoomCel, 0);
CelDrawTo(out, GetUIRectangle().position + Displacement { 0, 352 }, CelSprite { *DoomCel }, 0);
}
} // namespace devilution

21
Source/engine/cel_sprite.hpp

@ -28,6 +28,12 @@ public:
{
}
CelSprite(const byte *data, PointerOrValue<uint16_t> widths)
: data_ptr_(data)
, width_(widths)
{
}
explicit CelSprite(const OwnedCelSprite &owned);
CelSprite(const CelSprite &) = default;
@ -63,17 +69,17 @@ private:
* Stores a CEL or CL2 sprite and its width(s).
* Owns the data.
*/
class OwnedCelSprite : public CelSprite {
class OwnedCelSprite {
public:
OwnedCelSprite(std::unique_ptr<byte[]> data, uint16_t width)
: CelSprite(data.get(), width)
, data_(std::move(data))
: data_(std::move(data))
, width_(width)
{
}
OwnedCelSprite(std::unique_ptr<byte[]> data, const uint16_t *widths)
: CelSprite(data.get(), widths)
, data_(std::move(data))
: data_(std::move(data))
, width_(widths)
{
}
@ -87,10 +93,13 @@ public:
private:
std::unique_ptr<byte[]> data_;
PointerOrValue<uint16_t> width_;
friend class CelSprite;
};
inline CelSprite::CelSprite(const OwnedCelSprite &owned)
: CelSprite(static_cast<const CelSprite &>(owned))
: CelSprite(owned.data_.get(), owned.width_)
{
}

4
Source/engine/render/text_render.cpp

@ -650,7 +650,7 @@ uint32_t DrawString(const Surface &out, string_view text, const Rectangle &rect,
const int bytesDrawn = DoDrawString(out, text, rect, characterPosition, spacing, lineHeight, lineWidth, rightMargin, bottomMargin, flags, size, color);
if (HasAnyOf(flags, UiFlags::PentaCursor)) {
CelDrawTo(out, characterPosition + Displacement { 0, lineHeight - BaseLineOffset[size] }, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, characterPosition + Displacement { 0, lineHeight - BaseLineOffset[size] }, CelSprite { *pSPentSpn2Cels }, PentSpn2Spin());
} else if (HasAnyOf(flags, UiFlags::TextCursor) && GetAnimationFrame(2, 500) != 0) {
DrawFont(out, characterPosition, LoadFont(size, color, 0), color, '|');
}
@ -758,7 +758,7 @@ void DrawStringWithColors(const Surface &out, string_view fmt, DrawStringFormatA
}
if (HasAnyOf(flags, UiFlags::PentaCursor)) {
CelDrawTo(out, characterPosition + Displacement { 0, lineHeight - BaseLineOffset[size] }, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, characterPosition + Displacement { 0, lineHeight - BaseLineOffset[size] }, CelSprite { *pSPentSpn2Cels }, PentSpn2Spin());
} else if (HasAnyOf(flags, UiFlags::TextCursor) && GetAnimationFrame(2, 500) != 0) {
DrawFont(out, characterPosition, LoadFont(size, color, 0), color, '|');
}

17
Source/error.cpp

@ -144,21 +144,22 @@ void DrawDiabloMsg(const Surface &out)
auto &uiRectanglePosition = GetUIRectangle().position;
int dialogStartY = ((gnScreenHeight - GetMainPanel().size.height) / 2) - (ErrorWindowHeight / 2) + 9;
CelDrawTo(out, { uiRectanglePosition.x + 101, dialogStartY }, *pSTextSlidCels, 0);
CelDrawTo(out, { uiRectanglePosition.x + 101, dialogStartY + ErrorWindowHeight - 6 }, *pSTextSlidCels, 1);
CelDrawTo(out, { uiRectanglePosition.x + 527, dialogStartY + ErrorWindowHeight - 6 }, *pSTextSlidCels, 2);
CelDrawTo(out, { uiRectanglePosition.x + 527, dialogStartY }, *pSTextSlidCels, 3);
CelSprite sprite { *pSTextSlidCels };
CelDrawTo(out, { uiRectanglePosition.x + 101, dialogStartY }, sprite, 0);
CelDrawTo(out, { uiRectanglePosition.x + 101, dialogStartY + ErrorWindowHeight - 6 }, sprite, 1);
CelDrawTo(out, { uiRectanglePosition.x + 527, dialogStartY + ErrorWindowHeight - 6 }, sprite, 2);
CelDrawTo(out, { uiRectanglePosition.x + 527, dialogStartY }, sprite, 3);
int sx = uiRectanglePosition.x + 109;
for (int i = 0; i < 35; i++) {
CelDrawTo(out, { sx, dialogStartY }, *pSTextSlidCels, 4);
CelDrawTo(out, { sx, dialogStartY + ErrorWindowHeight - 6 }, *pSTextSlidCels, 6);
CelDrawTo(out, { sx, dialogStartY }, sprite, 4);
CelDrawTo(out, { sx, dialogStartY + ErrorWindowHeight - 6 }, sprite, 6);
sx += 12;
}
int drawnYborder = 12;
while ((drawnYborder + 12) < ErrorWindowHeight) {
CelDrawTo(out, { uiRectanglePosition.x + 101, dialogStartY + drawnYborder }, *pSTextSlidCels, 5);
CelDrawTo(out, { uiRectanglePosition.x + 527, dialogStartY + drawnYborder }, *pSTextSlidCels, 7);
CelDrawTo(out, { uiRectanglePosition.x + 101, dialogStartY + drawnYborder }, sprite, 5);
CelDrawTo(out, { uiRectanglePosition.x + 527, dialogStartY + drawnYborder }, sprite, 7);
drawnYborder += 12;
}

12
Source/gmenu.cpp

@ -107,20 +107,21 @@ void GmenuDrawMenuItem(const Surface &out, TMenuItem *pItem, int y)
if ((pItem->dwFlags & GMENU_SLIDER) != 0) {
int uiPositionX = GetUIRectangle().position.x;
int x = 16 + w / 2;
CelDrawTo(out, { x + uiPositionX, y + 40 }, *optbar_cel, 0);
CelDrawTo(out, { x + uiPositionX, y + 40 }, CelSprite { *optbar_cel }, 0);
uint16_t step = pItem->dwFlags & 0xFFF;
uint16_t steps = std::max<uint16_t>((pItem->dwFlags & 0xFFF000) >> 12, 2);
uint16_t pos = step * 256 / steps;
GmenuClearBuffer(out, x + 2 + uiPositionX, y + 38, pos + 13, 28);
CelDrawTo(out, { x + 2 + pos + uiPositionX, y + 38 }, *option_cel, 0);
CelDrawTo(out, { x + 2 + pos + uiPositionX, y + 38 }, CelSprite { *option_cel }, 0);
}
int x = (gnScreenWidth - w) / 2;
UiFlags style = (pItem->dwFlags & GMENU_ENABLED) != 0 ? UiFlags::ColorGold : UiFlags::ColorBlack;
DrawString(out, _(pItem->pszStr), Point { x, y }, style | UiFlags::FontSize46, 2);
if (pItem == sgpCurrItem) {
CelDrawTo(out, { x - 54, y + 51 }, *PentSpin_cel, PentSpn2Spin());
CelDrawTo(out, { x + 4 + w, y + 51 }, *PentSpin_cel, PentSpn2Spin());
CelSprite sprite { *PentSpin_cel };
CelDrawTo(out, { x - 54, y + 51 }, sprite, PentSpn2Spin());
CelDrawTo(out, { x + 4 + w, y + 51 }, sprite, PentSpn2Spin());
}
}
@ -240,7 +241,8 @@ void gmenu_draw(const Surface &out)
}
}
int uiPositionY = GetUIRectangle().position.y;
CelDrawTo(out, { (gnScreenWidth - sgpLogo->Width()) / 2, 102 + uiPositionY }, *sgpLogo, LogoAnim_frame);
CelSprite sprite { *sgpLogo };
CelDrawTo(out, { (gnScreenWidth - sprite.Width()) / 2, 102 + uiPositionY }, sprite, LogoAnim_frame);
int y = 110 + uiPositionY;
TMenuItem *i = sgpCurrentMenu;
if (sgpCurrentMenu->fnMenu != nullptr) {

2
Source/interfac.cpp

@ -180,7 +180,7 @@ void DrawCutsceneBackground()
const PcxSprite sprite { *ArtCutsceneWidescreen };
RenderPcxSprite(out, sprite, { uiRectangle.position.x - (sprite.width() - uiRectangle.size.width) / 2, uiRectangle.position.y });
}
CelDrawTo(out, { uiRectangle.position.x, 480 - 1 + uiRectangle.position.y }, *sgpBackCel, 0);
CelDrawTo(out, { uiRectangle.position.x, 480 - 1 + uiRectangle.position.y }, CelSprite { *sgpBackCel }, 0);
}
void DrawCutsceneForeground()

8
Source/inv.cpp

@ -1130,7 +1130,7 @@ void InitInv()
void DrawInv(const Surface &out)
{
CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { 0, 351 }), *pInvCels, 0);
CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { 0, 351 }), CelSprite { *pInvCels }, 0);
Size slotSize[] = {
{ 2, 2 }, // head
@ -1173,7 +1173,7 @@ void DrawInv(const Surface &out)
screenY += frameSize.height == (3 * InventorySlotSizeInPixels.height) ? 0 : -INV_SLOT_HALF_SIZE_PX;
}
const auto &cel = GetInvItemSprite(cursId);
const CelSprite cel { GetInvItemSprite(cursId) };
const int celFrame = GetInvItemFrame(cursId);
const Point position = GetPanelPosition(UiPanels::Inventory, { screenX, screenY });
@ -1213,7 +1213,7 @@ void DrawInv(const Surface &out)
int ii = myPlayer.InvGrid[j] - 1;
int cursId = myPlayer.InvList[ii]._iCurs + CURSOR_FIRSTITEM;
const auto &cel = GetInvItemSprite(cursId);
const CelSprite cel { GetInvItemSprite(cursId) };
const int celFrame = GetInvItemFrame(cursId);
const Point position = GetPanelPosition(UiPanels::Inventory, InvRect[j + SLOTXY_INV_FIRST]) + Displacement { 0, -1 };
if (pcursinvitem == ii + INVITEM_INV_FIRST) {
@ -1254,7 +1254,7 @@ void DrawInvBelt(const Surface &out)
InvDrawSlotBack(out, position, InventorySlotSizeInPixels);
const int cursId = myPlayer.SpdList[i]._iCurs + CURSOR_FIRSTITEM;
const auto &cel = GetInvItemSprite(cursId);
const CelSprite cel { GetInvItemSprite(cursId) };
const int celFrame = GetInvItemFrame(cursId);
if (pcursinvitem == i + INVITEM_BELT_FIRST) {

2
Source/items.cpp

@ -1775,7 +1775,7 @@ void PrintItemOil(char iDidx)
void DrawUniqueInfoWindow(const Surface &out)
{
CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { 24 - SidePanelSize.width, 327 }), *pSTextBoxCels, 0);
CelDrawTo(out, GetPanelPosition(UiPanels::Inventory, { 24 - SidePanelSize.width, 327 }), CelSprite { *pSTextBoxCels }, 0);
DrawHalfTransparentRectTo(out, GetRightPanel().position.x - SidePanelSize.width + 27, GetRightPanel().position.y + 28, 265, 297);
}

2
Source/minitext.cpp

@ -146,7 +146,7 @@ void InitQTextMsg(_speech_id m)
void DrawQTextBack(const Surface &out)
{
const Point uiPosition = GetUIRectangle().position;
CelDrawTo(out, uiPosition + Displacement { 24, 327 }, *pTextBoxCels, 0);
CelDrawTo(out, uiPosition + Displacement { 24, 327 }, CelSprite { *pTextBoxCels }, 0);
DrawHalfTransparentRectTo(out, uiPosition.x + 27, uiPosition.y + 28, 585, 297);
}

9
Source/panels/charpanel.cpp

@ -252,14 +252,15 @@ void DrawShadowString(const Surface &out, const PanelEntry &entry)
void DrawStatButtons(const Surface &out)
{
if (MyPlayer->_pStatPts > 0) {
CelSprite sprite { *pChrButtons };
if (MyPlayer->_pBaseStr < MyPlayer->GetMaximumAttributeValue(CharacterAttribute::Strength))
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 157 }), *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Strength)] ? 2 : 1);
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 157 }), sprite, chrbtn[static_cast<size_t>(CharacterAttribute::Strength)] ? 2 : 1);
if (MyPlayer->_pBaseMag < MyPlayer->GetMaximumAttributeValue(CharacterAttribute::Magic))
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 185 }), *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Magic)] ? 4 : 3);
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 185 }), sprite, chrbtn[static_cast<size_t>(CharacterAttribute::Magic)] ? 4 : 3);
if (MyPlayer->_pBaseDex < MyPlayer->GetMaximumAttributeValue(CharacterAttribute::Dexterity))
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 214 }), *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Dexterity)] ? 6 : 5);
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 214 }), sprite, chrbtn[static_cast<size_t>(CharacterAttribute::Dexterity)] ? 6 : 5);
if (MyPlayer->_pBaseVit < MyPlayer->GetMaximumAttributeValue(CharacterAttribute::Vitality))
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 242 }), *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Vitality)] ? 8 : 7);
CelDrawTo(out, GetPanelPosition(UiPanels::Character, { 137, 242 }), sprite, chrbtn[static_cast<size_t>(CharacterAttribute::Vitality)] ? 8 : 7);
}
}

6
Source/panels/spell_book.cpp

@ -116,16 +116,16 @@ void FreeSpellBook()
void DrawSpellBook(const Surface &out)
{
CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { 0, 351 }), *pSpellBkCel, 0);
CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { 0, 351 }), CelSprite { *pSpellBkCel }, 0);
if (gbIsHellfire && sbooktab < 5) {
CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { 61 * sbooktab + 7, 348 }), *pSBkBtnCel, sbooktab);
CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { 61 * sbooktab + 7, 348 }), CelSprite { *pSBkBtnCel }, sbooktab);
} else {
// BUGFIX: rendering of page 3 and page 4 buttons are both off-by-one pixel (fixed).
int sx = 76 * sbooktab + 7;
if (sbooktab == 2 || sbooktab == 3) {
sx++;
}
CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { sx, 348 }), *pSBkBtnCel, sbooktab);
CelDrawTo(out, GetPanelPosition(UiPanels::Spell, { sx, 348 }), CelSprite { *pSBkBtnCel }, sbooktab);
}
Player &player = *MyPlayer;
uint64_t spl = player._pMemSpells | player._pISpells | player._pAblSpells;

2
Source/panels/spell_icons.cpp

@ -89,7 +89,7 @@ void DrawSpellCel(const Surface &out, Point position, int nCel)
void DrawSpellCel(const Surface &out, Point position, const OwnedCelSprite &sprite, int nCel)
{
CelDrawLightTo(out, position, sprite, nCel, SplTransTbl);
CelDrawLightTo(out, position, CelSprite { sprite }, nCel, SplTransTbl);
}
void SetSpellTrans(spell_type t)

4
Source/qol/stash.cpp

@ -366,7 +366,7 @@ void DrawStash(const Surface &out)
int frame = item._iCurs + CURSOR_FIRSTITEM;
const Point position = GetStashSlotCoord(item.position) + offset;
const auto &cel = GetInvItemSprite(frame);
const CelSprite cel { GetInvItemSprite(frame) };
const int celFrame = GetInvItemFrame(frame);
if (pcursstashitem == itemId) {
@ -617,7 +617,7 @@ void DrawGoldWithdraw(const Surface &out, int amount)
const int dialogX = 30;
CelDrawTo(out, GetPanelPosition(UiPanels::Stash, { dialogX, 178 }), *pGBoxBuff, 0);
CelDrawTo(out, GetPanelPosition(UiPanels::Stash, { dialogX, 178 }), CelSprite { *pGBoxBuff }, 0);
// Pre-wrap the string at spaces, otherwise DrawString would hard wrap in the middle of words
const std::string wrapped = WordWrapString(_("How many gold pieces do you want to withdraw?"), 200);

6
Source/quests.cpp

@ -215,11 +215,11 @@ void PrintQLString(const Surface &out, int x, int y, string_view str, bool marke
int width = GetLineWidth(str);
x += std::max((257 - width) / 2, 0);
if (marked) {
CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { x - 20, y + 13 }), *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { x - 20, y + 13 }), CelSprite { *pSPentSpn2Cels }, PentSpn2Spin());
}
DrawString(out, str, { GetPanelPosition(UiPanels::Quest, { x, y }), { 257, 0 } }, disabled ? UiFlags::ColorWhitegold : UiFlags::ColorWhite);
if (marked) {
CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { x + width + 7, y + 13 }), *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { x + width + 7, y + 13 }), CelSprite { *pSPentSpn2Cels }, PentSpn2Spin());
}
}
@ -678,7 +678,7 @@ void DrawQuestLog(const Surface &out)
SelectedQuest = l;
}
const auto x = InnerPanel.position.x;
CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { 0, 351 }), *pQLogCel, 0);
CelDrawTo(out, GetPanelPosition(UiPanels::Quest, { 0, 351 }), CelSprite { *pQLogCel }, 0);
int y = InnerPanel.position.y + ListYOffset;
for (int i = 0; i < EncounteredQuestCount; i++) {
if (i == FirstFinishedQuest) {

6
Source/scrollrt.cpp

@ -843,7 +843,7 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit
#ifdef _DEBUG
if (DebugVision && IsTileLit(tilePosition)) {
CelClippedDrawTo(out, targetBufferPosition, *pSquareCel, 1);
CelClippedDrawTo(out, targetBufferPosition, CelSprite { *pSquareCel }, 1);
}
#endif
@ -896,7 +896,7 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit
cel_transparency_active = false; // Turn transparency off here for debugging
}
#endif
CelClippedBlitLightTransTo(out, targetBufferPosition, *pSpecialCels, bArch - 1);
CelClippedBlitLightTransTo(out, targetBufferPosition, CelSprite { *pSpecialCels }, bArch - 1);
#ifdef _DEBUG
if (GetAsyncKeyState(DVL_VK_MENU)) {
cel_transparency_active = TransList[bMap]; // Turn transparency back to its normal state
@ -910,7 +910,7 @@ void DrawDungeon(const Surface &out, Point tilePosition, Point targetBufferPosit
if (tilePosition.x > 0 && tilePosition.y > 0 && targetBufferPosition.y > TILE_HEIGHT) {
char bArch = dSpecial[tilePosition.x - 1][tilePosition.y - 1];
if (bArch != 0) {
CelDrawTo(out, targetBufferPosition + Displacement { 0, -TILE_HEIGHT }, *pSpecialCels, bArch - 1);
CelDrawTo(out, targetBufferPosition + Displacement { 0, -TILE_HEIGHT }, CelSprite { *pSpecialCels }, bArch - 1);
}
}
}

19
Source/stores.cpp

@ -164,7 +164,7 @@ void CalculateLineHeights()
void DrawSTextBack(const Surface &out)
{
const Point uiPosition = GetUIRectangle().position;
CelDrawTo(out, { uiPosition.x + 320 + 24, 327 + uiPosition.y }, *pSTextBoxCels, 0);
CelDrawTo(out, { uiPosition.x + 320 + 24, 327 + uiPosition.y }, CelSprite { *pSTextBoxCels }, 0);
DrawHalfTransparentRectTo(out, uiPosition.x + 347, uiPosition.y + 28, 265, 297);
}
@ -173,18 +173,19 @@ void DrawSSlider(const Surface &out, int y1, int y2)
const Point uiPosition = GetUIRectangle().position;
int yd1 = y1 * 12 + 44 + uiPosition.y;
int yd2 = y2 * 12 + 44 + uiPosition.y;
CelSprite sprite { *pSTextSlidCels };
if (stextscrlubtn != -1)
CelDrawTo(out, { uiPosition.x + 601, yd1 }, *pSTextSlidCels, 11);
CelDrawTo(out, { uiPosition.x + 601, yd1 }, sprite, 11);
else
CelDrawTo(out, { uiPosition.x + 601, yd1 }, *pSTextSlidCels, 9);
CelDrawTo(out, { uiPosition.x + 601, yd1 }, sprite, 9);
if (stextscrldbtn != -1)
CelDrawTo(out, { uiPosition.x + 601, yd2 }, *pSTextSlidCels, 10);
CelDrawTo(out, { uiPosition.x + 601, yd2 }, sprite, 10);
else
CelDrawTo(out, { uiPosition.x + 601, yd2 }, *pSTextSlidCels, 8);
CelDrawTo(out, { uiPosition.x + 601, yd2 }, sprite, 8);
yd1 += 12;
int yd3 = yd1;
for (; yd3 < yd2; yd3 += 12) {
CelDrawTo(out, { uiPosition.x + 601, yd3 }, *pSTextSlidCels, 13);
CelDrawTo(out, { uiPosition.x + 601, yd3 }, sprite, 13);
}
if (stextsel == BackButtonLine())
yd3 = stextlhold;
@ -194,7 +195,7 @@ void DrawSSlider(const Surface &out, int y1, int y2)
yd3 = 1000 * (stextsval + ((yd3 - stextup) / 4)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000;
else
yd3 = 0;
CelDrawTo(out, { uiPosition.x + 601, (y1 + 1) * 12 + 44 + uiPosition.y + yd3 }, *pSTextSlidCels, 12);
CelDrawTo(out, { uiPosition.x + 601, (y1 + 1) * 12 + 44 + uiPosition.y + yd3 }, sprite, 12);
}
void AddSLine(int y)
@ -2140,13 +2141,13 @@ void DrawSelector(const Surface &out, const Rectangle &rect, const char *text, U
if (HasAnyOf(flags, UiFlags::AlignCenter))
x1 += (rect.size.width - lineWidth) / 2;
CelDrawTo(out, { x1, rect.position.y + 13 }, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, { x1, rect.position.y + 13 }, CelSprite { *pSPentSpn2Cels }, PentSpn2Spin());
int x2 = rect.position.x + rect.size.width + 5;
if (HasAnyOf(flags, UiFlags::AlignCenter))
x2 = rect.position.x + (rect.size.width - lineWidth) / 2 + lineWidth + 5;
CelDrawTo(out, { x2, rect.position.y + 13 }, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, { x2, rect.position.y + 13 }, CelSprite { *pSPentSpn2Cels }, PentSpn2Spin());
}
} // namespace

Loading…
Cancel
Save