Browse Source

Use Point/SDL_Rect for control functions coordinate system

LineClear
Kalebe Alves 5 years ago committed by GitHub
parent
commit
118efe8e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 151
      Source/control.cpp
  2. 2
      Source/control.h
  3. 2
      Source/doom.cpp
  4. 86
      Source/engine/render/cel_render.cpp
  5. 55
      Source/engine/render/cel_render.hpp
  6. 14
      Source/engine/render/text_render.cpp
  7. 16
      Source/error.cpp
  8. 10
      Source/gmenu.cpp
  9. 2
      Source/interfac.cpp
  10. 26
      Source/inv.cpp
  11. 2
      Source/items.cpp
  12. 2
      Source/minitext.cpp
  13. 6
      Source/quests.cpp
  14. 28
      Source/scrollrt.cpp
  15. 18
      Source/stores.cpp

151
Source/control.cpp

@ -226,14 +226,13 @@ spell_id SpellPages[6][7] = {
/**
* Draw spell cell onto the given buffer.
* @param out Output buffer
* @param xp Buffer coordinate
* @param yp Buffer coordinate
* @param position Buffer coordinates
* @param cel The CEL sprite
* @param nCel Index of the cel frame to draw. 0 based.
*/
static void DrawSpellCel(const CelOutputBuffer &out, int xp, int yp, const CelSprite &cel, int nCel)
static void DrawSpellCel(const CelOutputBuffer &out, Point position, const CelSprite &cel, int nCel)
{
CelDrawLightTo(out, xp, yp, cel, nCel, SplTransTbl);
CelDrawLightTo(out, position, cel, nCel, SplTransTbl);
}
void SetSpellTrans(spell_type t)
@ -313,14 +312,17 @@ static void DrawSpell(const CelOutputBuffer &out)
if (currlevel == 0 && st != RSPLTYPE_INVALID && !spelldata[spl].sTownSpell)
st = RSPLTYPE_INVALID;
SetSpellTrans(st);
const Point position { PANEL_X + 565, PANEL_Y + 119 };
if (spl != SPL_INVALID)
DrawSpellCel(out, PANEL_X + 565, PANEL_Y + 119, *pSpellCels, SpellITbl[spl]);
DrawSpellCel(out, position, *pSpellCels, SpellITbl[spl]);
else
DrawSpellCel(out, PANEL_X + 565, PANEL_Y + 119, *pSpellCels, 27);
DrawSpellCel(out, position, *pSpellCels, 27);
}
static void PrintSBookHotkey(const CelOutputBuffer &out, int x, int y, const std::string &text)
static void PrintSBookHotkey(const CelOutputBuffer &out, Point position, const std::string &text)
{
int &x = position.x;
int &y = position.y;
x -= GetLineWidth(text.c_str()) + 5;
x += SPLICONLENGTH;
y += 17;
@ -338,8 +340,11 @@ void DrawSpellList(const CelOutputBuffer &out)
pSpell = SPL_INVALID;
infostr[0] = '\0';
int x = PANEL_X + 12 + SPLICONLENGTH * SPLROWICONLS;
int y = PANEL_Y - 17;
Point location;
int &x = location.x;
int &y = location.y;
x = PANEL_X + 12 + SPLICONLENGTH * SPLROWICONLS;
y = PANEL_Y - 17;
ClearPanel();
for (int i = RSPLTYPE_SKILL; i < RSPLTYPE_INVALID; i++) {
@ -382,7 +387,7 @@ void DrawSpellList(const CelOutputBuffer &out)
}
if (currlevel == 0 && !spelldata[j].sTownSpell)
SetSpellTrans(RSPLTYPE_INVALID);
DrawSpellCel(out, x, y, *pSpellCels, SpellITbl[j]);
DrawSpellCel(out, location, *pSpellCels, SpellITbl[j]);
int lx = x;
int ly = y - SPLICONLENGTH;
if (MouseX >= lx && MouseX < lx + SPLICONLENGTH && MouseY >= ly && MouseY < ly + SPLICONLENGTH) {
@ -390,7 +395,7 @@ void DrawSpellList(const CelOutputBuffer &out)
pSplType = (spell_type)i;
if (myPlayer._pClass == HeroClass::Monk && j == SPL_SEARCH)
pSplType = RSPLTYPE_SKILL;
DrawSpellCel(out, x, y, *pSpellCels, c);
DrawSpellCel(out, location, *pSpellCels, c);
switch (pSplType) {
case RSPLTYPE_SKILL:
strcpy(infostr, fmt::format(_("{:s} Skill"), _(spelldata[pSpell].sSkillText)).c_str());
@ -439,7 +444,7 @@ void DrawSpellList(const CelOutputBuffer &out)
for (int t = 0; t < 4; t++) {
if (myPlayer._pSplHotKey[t] == pSpell && myPlayer._pSplTHotKey[t] == pSplType) {
auto hotkeyName = keymapper.keyNameForAction(quickSpellActionIndexes[t]);
PrintSBookHotkey(out, x, y, hotkeyName);
PrintSBookHotkey(out, location, hotkeyName);
strcpy(tempstr, fmt::format(_("Spell Hotkey {:s}"), hotkeyName.c_str()).c_str());
AddPanelString(tempstr);
}
@ -538,13 +543,13 @@ void ClearPanel()
pinfoflag = false;
}
void DrawPanelBox(const CelOutputBuffer &out, int x, int y, int w, int h, int sx, int sy)
void DrawPanelBox(const CelOutputBuffer &out, SDL_Rect srcRect, Point targetPosition)
{
const BYTE *src = pBtmBuff.at(x, y);
BYTE *dst = out.at(sx, sy);
const BYTE *src = pBtmBuff.at(srcRect.x, srcRect.y);
BYTE *dst = &out[targetPosition];
for (int hgt = h; hgt != 0; hgt--, src += pBtmBuff.pitch(), dst += out.pitch()) {
memcpy(dst, src, w);
for (int hgt = srcRect.h; hgt != 0; hgt--, src += pBtmBuff.pitch(), dst += out.pitch()) {
memcpy(dst, src, srcRect.w);
}
}
@ -553,16 +558,15 @@ void DrawPanelBox(const CelOutputBuffer &out, int x, int y, int w, int h, int sx
* of the flask getting empty. This function takes a cel and draws a
* horizontal stripe of height (max-min) onto the given buffer.
* @param out Target buffer.
* @param sx Buffer coordinate
* @param sy Buffer coordinate
* @param position Buffer coordinate.
* @param celBuf Buffer of the empty flask cel.
* @param y0 Top of the flask cel section to draw.
* @param y1 Bottom of the flask cel section to draw.
*/
static void DrawFlaskTop(const CelOutputBuffer &out, int sx, int sy, const CelOutputBuffer &celBuf, int y0, int y1)
static void DrawFlaskTop(const CelOutputBuffer &out, Point position, const CelOutputBuffer &celBuf, int y0, int y1)
{
const BYTE *src = celBuf.at(0, y0);
BYTE *dst = out.at(sx, sy);
BYTE *dst = &out[position];
for (int h = y1 - y0; h != 0; --h, src += celBuf.pitch(), dst += out.pitch())
memcpy(dst, src, celBuf.w());
@ -574,16 +578,14 @@ static void DrawFlaskTop(const CelOutputBuffer &out, int sx, int sy, const CelOu
* into the target buffer.
* @param out The target buffer.
* @param celBuf Buffer of the empty flask cel.
* @param celX Source buffer start coordinate.
* @param celY Source buffer start coordinate.
* @param sx Target buffer coordinate.
* @param sy Target buffer coordinate.
* @param sourcePosition Source buffer start coordinate.
* @param targetPosition Target buffer coordinate.
* @param h How many lines of the source buffer that will be copied.
*/
static void DrawFlask(const CelOutputBuffer &out, const CelOutputBuffer &celBuf, int celX, int celY, int x, int y, int h)
static void DrawFlask(const CelOutputBuffer &out, const CelOutputBuffer &celBuf, Point sourcePosition, Point targetPosition, int h)
{
const BYTE *src = celBuf.at(celX, celY);
BYTE *dst = out.at(x, y);
const BYTE *src = &celBuf[sourcePosition];
BYTE *dst = &out[targetPosition];
for (int hgt = h; hgt != 0; hgt--, src += celBuf.pitch() - 59, dst += out.pitch() - 59) {
for (int wdt = 59; wdt != 0; wdt--) {
@ -614,9 +616,9 @@ void DrawLifeFlask(const CelOutputBuffer &out)
filled = 11;
filled += 2;
DrawFlask(out, pLifeBuff, 13, 3, PANEL_LEFT + 109, PANEL_TOP - 13, filled);
DrawFlask(out, pLifeBuff, { 13, 3 }, { PANEL_LEFT + 109, PANEL_TOP - 13 }, filled);
if (filled != 13)
DrawFlask(out, pBtmBuff, 109, filled + 3, PANEL_LEFT + 109, PANEL_TOP - 13 + filled, 13 - filled);
DrawFlask(out, pBtmBuff, { 109, filled + 3 }, { PANEL_LEFT + 109, PANEL_TOP - 13 + filled }, 13 - filled);
}
void UpdateLifeFlask(const CelOutputBuffer &out)
@ -635,9 +637,9 @@ void UpdateLifeFlask(const CelOutputBuffer &out)
else if (filled < 0)
filled = 0;
if (filled != 69)
DrawFlaskTop(out, 96 + PANEL_X, PANEL_Y, pLifeBuff, 16, 85 - filled);
DrawFlaskTop(out, { 96 + PANEL_X, PANEL_Y }, pLifeBuff, 16, 85 - filled);
if (filled != 0)
DrawPanelBox(out, 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(const CelOutputBuffer &out)
@ -650,9 +652,9 @@ void DrawManaFlask(const CelOutputBuffer &out)
filled = 11;
filled += 2;
DrawFlask(out, pManaBuff, 13, 3, PANEL_LEFT + 475, PANEL_TOP - 13, filled);
DrawFlask(out, pManaBuff, { 13, 3 }, { PANEL_LEFT + 475, PANEL_TOP - 13 }, filled);
if (filled != 13)
DrawFlask(out, pBtmBuff, 475, filled + 3, PANEL_LEFT + 475, PANEL_TOP - 13 + filled, 13 - filled);
DrawFlask(out, pBtmBuff, { 475, filled + 3 }, { PANEL_LEFT + 475, PANEL_TOP - 13 + filled }, 13 - filled);
}
void control_update_life_mana()
@ -677,9 +679,9 @@ void UpdateManaFlask(const CelOutputBuffer &out)
filled = std::min(filled, 69);
if (filled != 69)
DrawFlaskTop(out, PANEL_X + 464, PANEL_Y, pManaBuff, 16, 85 - filled);
DrawFlaskTop(out, { PANEL_X + 464, PANEL_Y }, pManaBuff, 16, 85 - filled);
if (filled != 0)
DrawPanelBox(out, 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(out);
}
@ -696,15 +698,16 @@ void InitControlPan()
else
pSpellCels = LoadCel("Data\\SpelIcon.CEL", SPLICONLENGTH);
SetSpellTrans(RSPLTYPE_SKILL);
CelDrawUnsafeTo(pBtmBuff, 0, (PANEL_HEIGHT + 16) - 1, LoadCel("CtrlPan\\Panel8.CEL", PANEL_WIDTH), 1);
CelDrawUnsafeTo(pBtmBuff, { 0, (PANEL_HEIGHT + 16) - 1 }, LoadCel("CtrlPan\\Panel8.CEL", PANEL_WIDTH), 1);
{
const Point bulbsPosition { 0, 87 };
const CelSprite statusPanel = LoadCel("CtrlPan\\P8Bulbs.CEL", 88);
CelDrawUnsafeTo(pLifeBuff, 0, 87, statusPanel, 1);
CelDrawUnsafeTo(pManaBuff, 0, 87, statusPanel, 2);
CelDrawUnsafeTo(pLifeBuff, bulbsPosition, statusPanel, 1);
CelDrawUnsafeTo(pManaBuff, bulbsPosition, statusPanel, 2);
}
talkflag = false;
if (gbIsMultiplayer) {
CelDrawUnsafeTo(pBtmBuff, 0, (PANEL_HEIGHT + 16) * 2 - 1, LoadCel("CtrlPan\\TalkPanl.CEL", PANEL_WIDTH), 1);
CelDrawUnsafeTo(pBtmBuff, { 0, (PANEL_HEIGHT + 16) * 2 - 1 }, LoadCel("CtrlPan\\TalkPanl.CEL", PANEL_WIDTH), 1);
pMultiBtns = LoadCel("CtrlPan\\P8But2.CEL", 33);
pTalkBtns = LoadCel("CtrlPan\\TalkButt.CEL", 61);
sgbPlrTalkTbl = 0;
@ -772,7 +775,7 @@ void InitControlPan()
void DrawCtrlPan(const CelOutputBuffer &out)
{
DrawPanelBox(out, 0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y);
DrawPanelBox(out, { 0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT }, { PANEL_X, PANEL_Y });
DrawInfoBox(out);
}
@ -780,16 +783,16 @@ void DrawCtrlBtns(const CelOutputBuffer &out)
{
for (int i = 0; i < 6; i++) {
if (!panbtns[i])
DrawPanelBox(out, PanBtnPos[i].x, PanBtnPos[i].y + 16, 71, 20, PanBtnPos[i].x + PANEL_X, PanBtnPos[i].y + PANEL_Y);
DrawPanelBox(out, { PanBtnPos[i].x, PanBtnPos[i].y + 16, 71, 20 }, { PanBtnPos[i].x + PANEL_X, PanBtnPos[i].y + PANEL_Y });
else
CelDrawTo(out, PanBtnPos[i].x + PANEL_X, PanBtnPos[i].y + PANEL_Y + 18, *pPanelButtons, i + 1);
CelDrawTo(out, { PanBtnPos[i].x + PANEL_X, PanBtnPos[i].y + PANEL_Y + 18 }, *pPanelButtons, i + 1);
}
if (numpanbtns == 8) {
CelDrawTo(out, 87 + PANEL_X, 122 + PANEL_Y, *pMultiBtns, panbtns[6] ? 2 : 1);
CelDrawTo(out, { 87 + PANEL_X, 122 + PANEL_Y }, *pMultiBtns, panbtns[6] ? 2 : 1);
if (gbFriendlyMode)
CelDrawTo(out, 527 + PANEL_X, 122 + PANEL_Y, *pMultiBtns, panbtns[7] ? 4 : 3);
CelDrawTo(out, { 527 + PANEL_X, 122 + PANEL_Y }, *pMultiBtns, panbtns[7] ? 4 : 3);
else
CelDrawTo(out, 527 + PANEL_X, 122 + PANEL_Y, *pMultiBtns, panbtns[7] ? 6 : 5);
CelDrawTo(out, { 527 + PANEL_X, 122 + PANEL_Y }, *pMultiBtns, panbtns[7] ? 6 : 5);
}
}
@ -1134,7 +1137,7 @@ static void PrintInfo(const CelOutputBuffer &out)
void DrawInfoBox(const CelOutputBuffer &out)
{
DrawPanelBox(out, 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 = UIS_SILVER;
@ -1202,7 +1205,7 @@ void DrawChr(const CelOutputBuffer &out)
auto &myPlayer = plr[myplr];
CelDrawTo(out, 0, 351, *pChrPanel, 1);
CelDrawTo(out, { 0, 351 }, *pChrPanel, 1);
DrawString(out, myPlayer._pName, { 20, 32, 131, 0 }, UIS_SILVER | UIS_CENTER);
DrawString(out, _(ClassStrTbl[static_cast<std::size_t>(myPlayer._pClass)]), { 168, 32, 131, 0 }, UIS_SILVER | UIS_CENTER);
@ -1372,13 +1375,13 @@ void DrawChr(const CelOutputBuffer &out)
sprintf(chrstr, "%i", myPlayer._pStatPts);
DrawString(out, chrstr, { 95, 266, 31, 0 }, UIS_RED | UIS_CENTER);
if (myPlayer._pBaseStr < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Strength))
CelDrawTo(out, 137, 159, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Strength)] ? 3 : 2);
CelDrawTo(out, { 137, 159 }, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Strength)] ? 3 : 2);
if (myPlayer._pBaseMag < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Magic))
CelDrawTo(out, 137, 187, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Magic)] ? 5 : 4);
CelDrawTo(out, { 137, 187 }, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Magic)] ? 5 : 4);
if (myPlayer._pBaseDex < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Dexterity))
CelDrawTo(out, 137, 216, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Dexterity)] ? 7 : 6);
CelDrawTo(out, { 137, 216 }, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Dexterity)] ? 7 : 6);
if (myPlayer._pBaseVit < myPlayer.GetMaximumAttributeValue(CharacterAttribute::Vitality))
CelDrawTo(out, 137, 244, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Vitality)] ? 9 : 8);
CelDrawTo(out, { 137, 244 }, *pChrButtons, chrbtn[static_cast<size_t>(CharacterAttribute::Vitality)] ? 9 : 8);
}
style = UIS_SILVER;
@ -1420,7 +1423,7 @@ void DrawLevelUpIcon(const CelOutputBuffer &out)
if (stextflag == STORE_NONE) {
int nCel = lvlbtndown ? 3 : 2;
DrawString(out, _("Level Up"), { PANEL_LEFT + 0, PANEL_TOP - 49, 120, 0 }, UIS_SILVER | UIS_CENTER);
CelDrawTo(out, 40 + PANEL_X, -17 + PANEL_Y, *pChrButtons, nCel);
CelDrawTo(out, { 40 + PANEL_X, -17 + PANEL_Y }, *pChrButtons, nCel);
}
}
@ -1542,7 +1545,7 @@ static int DrawDurIcon4Item(const CelOutputBuffer &out, ItemStruct *pItem, int x
}
if (pItem->_iDurability > 2)
c += 8;
CelDrawTo(out, x, -17 + PANEL_Y, *pDurIcons, c);
CelDrawTo(out, { x, -17 + PANEL_Y }, *pDurIcons, c);
return x - 32 - 8;
}
@ -1582,9 +1585,9 @@ void RedBack(const CelOutputBuffer &out)
}
}
static void PrintSBookStr(const CelOutputBuffer &out, int x, int y, const char *text)
static void PrintSBookStr(const CelOutputBuffer &out, Point position, const char *text)
{
DrawString(out, text, { RIGHT_PANEL_X + SPLICONLENGTH + x, y, 222, 0 }, UIS_SILVER);
DrawString(out, text, { RIGHT_PANEL_X + SPLICONLENGTH + position.x, position.y, 222, 0 }, UIS_SILVER);
}
spell_type GetSBookTrans(spell_id ii, bool townok)
@ -1616,16 +1619,16 @@ spell_type GetSBookTrans(spell_id ii, bool townok)
void DrawSpellBook(const CelOutputBuffer &out)
{
CelDrawTo(out, RIGHT_PANEL_X, 351, *pSpellBkCel, 1);
CelDrawTo(out, { RIGHT_PANEL_X, 351 }, *pSpellBkCel, 1);
if (gbIsHellfire && sbooktab < 5) {
CelDrawTo(out, RIGHT_PANEL_X + 61 * sbooktab + 7, 348, *pSBkBtnCel, sbooktab + 1);
CelDrawTo(out, { RIGHT_PANEL_X + 61 * sbooktab + 7, 348 }, *pSBkBtnCel, sbooktab + 1);
} else {
// BUGFIX: rendering of page 3 and page 4 buttons are both off-by-one pixel (fixed).
int sx = RIGHT_PANEL_X + 76 * sbooktab + 7;
if (sbooktab == 2 || sbooktab == 3) {
sx++;
}
CelDrawTo(out, sx, 348, *pSBkBtnCel, sbooktab + 1);
CelDrawTo(out, { sx, 348 }, *pSBkBtnCel, sbooktab + 1);
}
auto &myPlayer = plr[myplr];
uint64_t spl = myPlayer._pMemSpells | myPlayer._pISpells | myPlayer._pAblSpells;
@ -1636,12 +1639,13 @@ void DrawSpellBook(const CelOutputBuffer &out)
if (sn != SPL_INVALID && (spl & GetSpellBitmask(sn)) != 0) {
spell_type st = GetSBookTrans(sn, true);
SetSpellTrans(st);
DrawSpellCel(out, RIGHT_PANEL_X + 11, yp, *pSBkIconCels, SpellITbl[sn]);
const Point spellCellPosition { RIGHT_PANEL_X + 11, yp };
DrawSpellCel(out, spellCellPosition, *pSBkIconCels, SpellITbl[sn]);
if (sn == myPlayer._pRSpell && st == myPlayer._pRSplType) {
SetSpellTrans(RSPLTYPE_SKILL);
DrawSpellCel(out, RIGHT_PANEL_X + 11, yp, *pSBkIconCels, SPLICONLAST);
DrawSpellCel(out, spellCellPosition, *pSBkIconCels, SPLICONLAST);
}
PrintSBookStr(out, 10, yp - 23, _(spelldata[sn].sNameText));
PrintSBookStr(out, { 10, yp - 23 }, _(spelldata[sn].sNameText));
switch (GetSBookTrans(sn, false)) {
case RSPLTYPE_SKILL:
strcpy(tempstr, _("Skill"));
@ -1663,7 +1667,7 @@ void DrawSpellBook(const CelOutputBuffer &out)
if (sn == SPL_BONESPIRIT) {
strcpy(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: {:d} Dam: 1/3 tgt hp"), mana).c_str());
}
PrintSBookStr(out, 10, yp - 1, tempstr);
PrintSBookStr(out, { 10, yp - 1 }, tempstr);
int lvl = myPlayer._pSplLvl[sn] + myPlayer._pISplLvlAdd;
if (lvl < 0) {
lvl = 0;
@ -1675,7 +1679,7 @@ void DrawSpellBook(const CelOutputBuffer &out)
}
} break;
}
PrintSBookStr(out, 10, yp - 12, tempstr);
PrintSBookStr(out, { 10, yp - 12 }, tempstr);
}
yp += 43;
}
@ -1709,7 +1713,7 @@ void DrawGoldSplit(const CelOutputBuffer &out, int amount)
{
const int dialogX = RIGHT_PANEL_X + 30;
CelDrawTo(out, dialogX, 178, *pGBoxBuff, 1);
CelDrawTo(out, { dialogX, 178 }, *pGBoxBuff, 1);
strcpy(
tempstr,
@ -1795,17 +1799,17 @@ void DrawTalkPan(const CelOutputBuffer &out)
if (!talkflag)
return;
DrawPanelBox(out, 175, sgbPlrTalkTbl + 20, 294, 5, PANEL_X + 175, PANEL_Y + 4);
DrawPanelBox(out, { 175, sgbPlrTalkTbl + 20, 294, 5 }, { PANEL_X + 175, PANEL_Y + 4 });
int off = 0;
for (int i = 293; i > 283; off++, i--) {
DrawPanelBox(out, (off / 2) + 175, sgbPlrTalkTbl + off + 25, i, 1, (off / 2) + PANEL_X + 175, off + PANEL_Y + 9);
DrawPanelBox(out, { (off / 2) + 175, sgbPlrTalkTbl + off + 25, i, 1 }, { (off / 2) + PANEL_X + 175, off + PANEL_Y + 9 });
}
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);
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 (int i = 0; i < 10; i++) {
DrawPanelBox(out, 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(out, 170, sgbPlrTalkTbl + 80, 310, 55, PANEL_X + 170, PANEL_Y + 64);
DrawPanelBox(out, { 170, sgbPlrTalkTbl + 80, 310, 55 }, { PANEL_X + 170, PANEL_Y + 64 });
char *msg = sgszTalkMsg;
int i = 0;
int x = PANEL_LEFT + 200;
@ -1821,17 +1825,18 @@ void DrawTalkPan(const CelOutputBuffer &out)
continue;
uint16_t color = UIS_RED;
const Point talkPanPosition { 172 + PANEL_X, 84 + 18 * talkBtn + PANEL_Y };
if (whisperList[i]) {
color = UIS_GOLD;
if (talkButtonsDown[talkBtn]) {
int nCel = talkBtn != 0 ? 4 : 3;
CelDrawTo(out, 172 + PANEL_X, 84 + 18 * talkBtn + PANEL_Y, *pTalkBtns, nCel);
CelDrawTo(out, talkPanPosition, *pTalkBtns, nCel);
}
} else {
int nCel = talkBtn != 0 ? 2 : 1;
if (talkButtonsDown[talkBtn])
nCel += 4;
CelDrawTo(out, 172 + PANEL_X, 84 + 18 * talkBtn + PANEL_Y, *pTalkBtns, nCel);
CelDrawTo(out, talkPanPosition, *pTalkBtns, nCel);
}
auto &player = plr[i];
if (player.plractive) {

2
Source/control.h

@ -75,7 +75,7 @@ void ToggleSpell(int slot);
void AddPanelString(const char *str);
void ClearPanel();
void DrawPanelBox(const CelOutputBuffer &out, int x, int y, int w, int h, int sx, int sy);
void DrawPanelBox(const CelOutputBuffer &out, SDL_Rect srcRect, Point targetPosition);
/**
* Draws the top dome of the life flask (that part that protrudes out of the control panel).

2
Source/doom.cpp

@ -74,7 +74,7 @@ void doom_draw(const CelOutputBuffer &out)
return;
}
CelDrawTo(out, PANEL_X, PANEL_Y - 1, *DoomCel, 1);
CelDrawTo(out, { PANEL_X, PANEL_Y - 1 }, *DoomCel, 1);
}
} // namespace devilution

86
Source/engine/render/cel_render.cpp

@ -527,34 +527,31 @@ void RenderCelOutline(const CelOutputBuffer &out, Point position, const byte *sr
/**
* @brief Blit CEL sprite to the given buffer, checks for drawing outside the buffer.
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param pRLEBytes CEL pixel stream (run-length encoded)
* @param nDataSize Size of CEL in bytes
*/
void CelBlitSafeTo(const CelOutputBuffer &out, int sx, int sy, const byte *pRLEBytes, int nDataSize, int nWidth)
void CelBlitSafeTo(const CelOutputBuffer &out, Point position, const byte *pRLEBytes, int nDataSize, int nWidth)
{
assert(pRLEBytes != nullptr);
RenderCel(out, { sx, sy }, pRLEBytes, nDataSize, nWidth, RenderLineMemcpy, NullLineEndFn);
RenderCel(out, position, pRLEBytes, nDataSize, nWidth, RenderLineMemcpy, NullLineEndFn);
}
/**
* @brief Same as CelBlitLightSafeTo but with stippled transparency applied
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param pRLEBytes CEL pixel stream (run-length encoded)
* @param nDataSize Size of CEL in bytes
*/
void CelBlitLightTransSafeTo(const CelOutputBuffer &out, int sx, int sy, const byte *pRLEBytes, int nDataSize, int nWidth)
void CelBlitLightTransSafeTo(const CelOutputBuffer &out, Point position, const byte *pRLEBytes, int nDataSize, int nWidth)
{
assert(pRLEBytes != nullptr);
const std::uint8_t *tbl = &pLightTbl[light_table_index * 256];
const Point from { sx, sy };
bool shift = (reinterpret_cast<uintptr_t>(&out[from]) % 2 == 1);
bool shift = (reinterpret_cast<uintptr_t>(&out[position]) % 2 == 1);
const bool pitchIsEven = (out.pitch() % 2 == 0);
RenderCel(
out, from, pRLEBytes, nDataSize, nWidth,
out, position, pRLEBytes, nDataSize, nWidth,
[tbl, &shift](std::uint8_t *dst, const std::uint8_t *src, std::size_t width) {
if (reinterpret_cast<uintptr_t>(dst) % 2 == (shift ? 1 : 0)) {
++dst, ++src, --width;
@ -574,14 +571,14 @@ void CelBlitLightTransSafeTo(const CelOutputBuffer &out, int sx, int sy, const b
* @param nWidth Width of sprite
* @param tbl Palette translation table
*/
void CelBlitLightBlendedSafeTo(const CelOutputBuffer &out, int sx, int sy, const byte *pRLEBytes, int nDataSize, int nWidth, uint8_t *tbl)
void CelBlitLightBlendedSafeTo(const CelOutputBuffer &out, Point position, const byte *pRLEBytes, int nDataSize, int nWidth, uint8_t *tbl)
{
assert(pRLEBytes != nullptr);
if (tbl == nullptr)
tbl = &pLightTbl[light_table_index * 256];
RenderCel(
out, { sx, sy }, pRLEBytes, nDataSize, nWidth, [tbl](std::uint8_t *dst, const uint8_t *src, std::size_t w) {
out, position, pRLEBytes, nDataSize, nWidth, [tbl](std::uint8_t *dst, const uint8_t *src, std::size_t w) {
while (w-- > 0) {
*dst = paletteTransparencyLookup[*dst][tbl[*src++]];
++dst;
@ -593,120 +590,119 @@ void CelBlitLightBlendedSafeTo(const CelOutputBuffer &out, int sx, int sy, const
/**
* @brief Blit CEL sprite, and apply lighting, to the given buffer, checks for drawing outside the buffer
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param pRLEBytes CEL pixel stream (run-length encoded)
* @param nDataSize Size of CEL in bytes
* @param tbl Palette translation table
*/
void CelBlitLightSafeTo(const CelOutputBuffer &out, int sx, int sy, const byte *pRLEBytes, int nDataSize, int nWidth, uint8_t *tbl)
void CelBlitLightSafeTo(const CelOutputBuffer &out, Point position, const byte *pRLEBytes, int nDataSize, int nWidth, uint8_t *tbl)
{
assert(pRLEBytes != nullptr);
if (tbl == nullptr)
tbl = &pLightTbl[light_table_index * 256];
RenderCelWithLightTable(out, { sx, sy }, pRLEBytes, nDataSize, nWidth, tbl);
RenderCelWithLightTable(out, position, pRLEBytes, nDataSize, nWidth, tbl);
}
} // namespace
void CelDrawTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
void CelDrawTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrame(cel.Data(), frame, &nDataSize);
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
}
void CelClippedDrawTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
void CelClippedDrawTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
}
void CelDrawLightTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame, uint8_t *tbl)
void CelDrawLightTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame, uint8_t *tbl)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrame(cel.Data(), frame, &nDataSize);
if (light_table_index != 0 || tbl != nullptr)
CelBlitLightSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame), tbl);
CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), tbl);
else
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
}
void CelClippedDrawLightTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
void CelClippedDrawLightTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
if (light_table_index != 0)
CelBlitLightSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
else
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
}
void CelDrawLightRedTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
void CelDrawLightRedTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
RenderCelWithLightTable(out, { sx, sy }, pRLEBytes, nDataSize, cel.Width(frame), GetLightTable(1));
RenderCelWithLightTable(out, position, pRLEBytes, nDataSize, cel.Width(frame), GetLightTable(1));
}
void CelDrawItem(bool usable, const CelOutputBuffer &out, int x, int y, const CelSprite &cel, int frame)
void CelDrawItem(bool usable, const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
if (!usable) {
CelDrawLightRedTo(out, x, y, cel, frame);
CelDrawLightRedTo(out, position, cel, frame);
} else {
CelClippedDrawTo(out, x, y, cel, frame);
CelClippedDrawTo(out, position, cel, frame);
}
}
void CelClippedDrawSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
void CelClippedDrawSafeTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
}
void CelClippedBlitLightTransTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
void CelClippedBlitLightTransTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const byte *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
if (cel_transparency_active) {
if (sgOptions.Graphics.bBlendedTransparancy)
CelBlitLightBlendedSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
CelBlitLightBlendedSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
else
CelBlitLightTransSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
CelBlitLightTransSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
} else if (light_table_index != 0)
CelBlitLightSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
CelBlitLightSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame), nullptr);
else
CelBlitSafeTo(out, sx, sy, pRLEBytes, nDataSize, cel.Width(frame));
CelBlitSafeTo(out, position, pRLEBytes, nDataSize, cel.Width(frame));
}
void CelDrawLightRedSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame)
void CelDrawLightRedSafeTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
RenderCelWithLightTable(out, { sx, sy }, pRLEBytes, nDataSize, cel.Width(frame), GetLightTable(1));
RenderCelWithLightTable(out, position, 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, Point position, const CelSprite &cel, int frame)
{
int nDataSize;
const auto *pRLEBytes = CelGetFrame(cel.Data(), frame, &nDataSize);
RenderCelClipY(out, { x, y }, pRLEBytes, nDataSize, cel.Width(frame), RenderLineMemcpy, NullLineEndFn);
RenderCelClipY(out, position, pRLEBytes, nDataSize, cel.Width(frame), RenderLineMemcpy, NullLineEndFn);
}
void CelBlitOutlineTo(const CelOutputBuffer &out, uint8_t col, int sx, int sy, const CelSprite &cel, int frame, bool skipColorIndexZero)
void CelBlitOutlineTo(const CelOutputBuffer &out, uint8_t col, Point position, const CelSprite &cel, int frame, bool skipColorIndexZero)
{
int nDataSize;
const byte *src = CelGetFrameClipped(cel.Data(), frame, &nDataSize);
if (skipColorIndexZero)
RenderCelOutline<true>(out, { sx, sy }, src, nDataSize, cel.Width(frame), col);
RenderCelOutline<true>(out, position, src, nDataSize, cel.Width(frame), col);
else
RenderCelOutline<false>(out, { sx, sy }, src, nDataSize, cel.Width(frame), col);
RenderCelOutline<false>(out, position, src, nDataSize, cel.Width(frame), col);
}
std::pair<int, int> MeasureSolidHorizontalBounds(const CelSprite &cel, int frame)

55
Source/engine/render/cel_render.hpp

@ -20,114 +20,103 @@ std::pair<int, int> MeasureSolidHorizontalBounds(const CelSprite &cel, int frame
/**
* @brief Blit CEL sprite to the back buffer at the given coordinates
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelDrawTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
void CelDrawTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @briefBlit CEL sprite to the given buffer, does not perform bounds-checking.
* @param out Target buffer
* @param x Cordinate in the target buffer
* @param y Cordinate in the target buffer
* @param position Coordinate in the target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelDrawUnsafeTo(const CelOutputBuffer &out, int x, int y, const CelSprite &cel, int frame);
void CelDrawUnsafeTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @brief Same as CelDrawTo but with the option to skip parts of the top and bottom of the sprite
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelClippedDrawTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
void CelClippedDrawTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @brief Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelDrawLightTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame, uint8_t *tbl);
void CelDrawLightTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame, uint8_t *tbl);
/**
* @brief Same as CelDrawLightTo but with the option to skip parts of the top and bottom of the sprite
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelClippedDrawLightTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
void CelClippedDrawLightTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @brief Same as CelBlitLightTransSafeTo
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelClippedBlitLightTransTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
void CelClippedBlitLightTransTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @brief Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates, translated to a red hue
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelDrawLightRedTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
void CelDrawLightRedTo(const CelOutputBuffer &out, Point position, 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 position 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);
void CelDrawItem(bool usable, const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @brief Same as CelClippedDrawTo but checks for drawing outside the buffer
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelClippedDrawSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
void CelClippedDrawSafeTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @brief Same as CelDrawLightRedTo but checks for drawing outside the buffer
* @param out Target buffer
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param cel CEL sprite
* @param frame CEL frame number
*/
void CelDrawLightRedSafeTo(const CelOutputBuffer &out, int sx, int sy, const CelSprite &cel, int frame);
void CelDrawLightRedSafeTo(const CelOutputBuffer &out, Point position, const CelSprite &cel, int frame);
/**
* @brief Blit a solid colder shape one pixel larger than the given sprite shape, to the target buffer at the given coordianates
* @param out Target buffer
* @param col Color index from current palette
* @param sx Target buffer coordinate
* @param sy Target buffer coordinate
* @param position Target buffer coordinate
* @param pCelBuff CEL buffer
* @param frame CEL frame number
* @param skipColorIndexZero If true, color in index 0 will be treated as transparent (these are typically used for shadows in sprites)
*/
void CelBlitOutlineTo(const CelOutputBuffer &out, uint8_t col, int sx, int sy, const CelSprite &cel, int frame, bool skipColorIndexZero = true);
void CelBlitOutlineTo(const CelOutputBuffer &out, uint8_t col, Point position, const CelSprite &cel, int frame, bool skipColorIndexZero = true);
} // namespace devilution

14
Source/engine/render/text_render.cpp

@ -135,24 +135,24 @@ uint8_t fontColorTableGold[256];
uint8_t fontColorTableBlue[256];
uint8_t fontColorTableRed[256];
void DrawChar(const CelOutputBuffer &out, Point point, GameFontTables size, int nCel, text_color color)
void DrawChar(const CelOutputBuffer &out, Point position, GameFontTables size, int nCel, text_color color)
{
switch (color) {
case ColorWhite:
CelDrawTo(out, point.x, point.y, *fonts[size], nCel);
CelDrawTo(out, position, *fonts[size], nCel);
return;
case ColorBlue:
CelDrawLightTo(out, point.x, point.y, *fonts[size], nCel, fontColorTableBlue);
CelDrawLightTo(out, position, *fonts[size], nCel, fontColorTableBlue);
break;
case ColorRed:
CelDrawLightTo(out, point.x, point.y, *fonts[size], nCel, fontColorTableRed);
CelDrawLightTo(out, position, *fonts[size], nCel, fontColorTableRed);
break;
case ColorGold:
CelDrawLightTo(out, point.x, point.y, *fonts[size], nCel, fontColorTableGold);
CelDrawLightTo(out, position, *fonts[size], nCel, fontColorTableGold);
break;
case ColorBlack:
light_table_index = 15;
CelDrawLightTo(out, point.x, point.y, *fonts[size], nCel, nullptr);
CelDrawLightTo(out, position, *fonts[size], nCel, nullptr);
return;
}
}
@ -351,7 +351,7 @@ int DrawString(const CelOutputBuffer &out, const char *text, const SDL_Rect &rec
sx += symbolWidth + spacing;
}
if (drawTextCursor) {
CelDrawTo(out, sx, sy, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, { sx, sy }, *pSPentSpn2Cels, PentSpn2Spin());
}
return i;

16
Source/error.cpp

@ -109,21 +109,21 @@ void ClrDiabloMsg()
void DrawDiabloMsg(const CelOutputBuffer &out)
{
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);
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);
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);
CelDrawTo(out, { sx, DIALOG_Y }, *pSTextSlidCels, 5);
CelDrawTo(out, { sx, DIALOG_Y + 48 }, *pSTextSlidCels, 7);
sx += 12;
}
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);
CelDrawTo(out, { PANEL_X + 101, sy }, *pSTextSlidCels, 6);
CelDrawTo(out, { PANEL_X + 527, sy }, *pSTextSlidCels, 8);
sy += 12;
}

10
Source/gmenu.cpp

@ -165,20 +165,20 @@ static void GmenuDrawMenuItem(const CelOutputBuffer &out, TMenuItem *pItem, int
int w = GmenuGetLfont(pItem);
if ((pItem->dwFlags & GMENU_SLIDER) != 0) {
int x = 16 + w / 2;
CelDrawTo(out, x + PANEL_LEFT, y - 10, *optbar_cel, 1);
CelDrawTo(out, { x + PANEL_LEFT, y - 10 }, *optbar_cel, 1);
int step = pItem->dwFlags & 0xFFF;
int nSteps = std::max<int>((pItem->dwFlags & 0xFFF000) >> 12, 2);
int pos = step * 256 / nSteps;
GmenuClearBuffer(out, x + 2 + PANEL_LEFT, y - 12, pos + 13, 28);
CelDrawTo(out, x + 2 + pos + PANEL_LEFT, y - 12, *option_cel, 1);
CelDrawTo(out, { x + 2 + pos + PANEL_LEFT, y - 12 }, *option_cel, 1);
}
int x = (gnScreenWidth - w) / 2;
uint16_t style = (pItem->dwFlags & GMENU_ENABLED) != 0 ? UIS_SILVER : UIS_BLACK;
DrawString(out, _(pItem->pszStr), { x, y, 0, 0 }, style | UIS_HUGE, 2);
if (pItem == sgpCurrItem) {
CelDrawTo(out, x - 54, y + 1, *PentSpin_cel, PentSpn2Spin());
CelDrawTo(out, x + 4 + w, y + 1, *PentSpin_cel, PentSpn2Spin());
CelDrawTo(out, { x - 54, y + 1 }, *PentSpin_cel, PentSpn2Spin());
CelDrawTo(out, { x + 4 + w, y + 1 }, *PentSpin_cel, PentSpn2Spin());
}
}
@ -207,7 +207,7 @@ void gmenu_draw(const CelOutputBuffer &out)
LogoAnim_tick = ticks;
}
}
CelDrawTo(out, (gnScreenWidth - sgpLogo->Width()) / 2, 102 + UI_OFFSET_Y, *sgpLogo, LogoAnim_frame);
CelDrawTo(out, { (gnScreenWidth - sgpLogo->Width()) / 2, 102 + UI_OFFSET_Y }, *sgpLogo, LogoAnim_frame);
int y = 160 + UI_OFFSET_Y;
TMenuItem *i = sgpCurrentMenu;
if (sgpCurrentMenu->fnMenu != nullptr) {

2
Source/interfac.cpp

@ -178,7 +178,7 @@ static void DrawCutscene()
lock_buf(1);
const CelOutputBuffer &out = GlobalBackBuffer();
DrawArt(out, PANEL_X - (ArtCutsceneWidescreen.w() - PANEL_WIDTH) / 2, UI_OFFSET_Y, &ArtCutsceneWidescreen);
CelDrawTo(out, PANEL_X, 480 - 1 + UI_OFFSET_Y, *sgpBackCel, 1);
CelDrawTo(out, { PANEL_X, 480 - 1 + UI_OFFSET_Y }, *sgpBackCel, 1);
for (unsigned i = 0; i < sgdwProgress; i++) {
DrawProgress(

26
Source/inv.cpp

@ -179,7 +179,7 @@ static void InvDrawSlotBack(const CelOutputBuffer &out, int x, int y, int w, int
void DrawInv(const CelOutputBuffer &out)
{
CelDrawTo(out, RIGHT_PANEL_X, 351, *pInvCels, 1);
CelDrawTo(out, { RIGHT_PANEL_X, 351 }, *pInvCels, 1);
InvXY slotSize[] = {
{ 2, 2 }, //head
@ -226,12 +226,13 @@ void DrawInv(const CelOutputBuffer &out)
const auto &cel = GetInvItemSprite(frame);
const int celFrame = GetInvItemFrame(frame);
const Point position { RIGHT_PANEL_X + screenX, screenY };
if (pcursinvitem == slot) {
CelBlitOutlineTo(out, GetOutlineColor(myPlayer.InvBody[slot], true), RIGHT_PANEL_X + screenX, screenY, cel, celFrame, false);
CelBlitOutlineTo(out, GetOutlineColor(myPlayer.InvBody[slot], true), position, cel, celFrame, false);
}
CelDrawItem(myPlayer.InvBody[slot]._iStatFlag, out, RIGHT_PANEL_X + screenX, screenY, cel, celFrame);
CelDrawItem(myPlayer.InvBody[slot]._iStatFlag, out, position, cel, celFrame);
if (slot == INVLOC_HAND_LEFT) {
if (myPlayer.InvBody[slot]._iLoc == ILOC_TWOHAND) {
@ -244,7 +245,7 @@ void DrawInv(const CelOutputBuffer &out)
const int dstX = RIGHT_PANEL_X + slotPos[INVLOC_HAND_RIGHT].X + (frameW == INV_SLOT_SIZE_PX ? 13 : -1);
const int dstY = slotPos[INVLOC_HAND_RIGHT].Y;
CelClippedBlitLightTransTo(out, dstX, dstY, cel, celFrame);
CelClippedBlitLightTransTo(out, { dstX, dstY }, cel, celFrame);
cel_transparency_active = false;
}
@ -271,21 +272,19 @@ void DrawInv(const CelOutputBuffer &out)
const auto &cel = GetInvItemSprite(frame);
const int celFrame = GetInvItemFrame(frame);
const Point position { InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X, InvRect[j + SLOTXY_INV_FIRST].Y - 1 };
if (pcursinvitem == ii + INVITEM_INV_FIRST) {
CelBlitOutlineTo(
out,
GetOutlineColor(myPlayer.InvList[ii], true),
InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X,
InvRect[j + SLOTXY_INV_FIRST].Y - 1,
position,
cel, celFrame, false);
}
CelDrawItem(
myPlayer.InvList[ii]._iStatFlag,
out,
InvRect[j + SLOTXY_INV_FIRST].X + RIGHT_PANEL_X,
InvRect[j + SLOTXY_INV_FIRST].Y - 1,
position,
cel, celFrame);
}
}
@ -297,7 +296,7 @@ void DrawInvBelt(const CelOutputBuffer &out)
return;
}
DrawPanelBox(out, 205, 21, 232, 28, PANEL_X + 205, PANEL_Y + 5);
DrawPanelBox(out, { 205, 21, 232, 28 }, { PANEL_X + 205, PANEL_Y + 5 });
auto &myPlayer = plr[myplr];
@ -306,7 +305,8 @@ void DrawInvBelt(const CelOutputBuffer &out)
continue;
}
InvDrawSlotBack(out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
const Point position { InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1 };
InvDrawSlotBack(out, position.x, position.y, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
int frame = myPlayer.SpdList[i]._iCurs + CURSOR_FIRSTITEM;
const auto &cel = GetInvItemSprite(frame);
@ -314,11 +314,11 @@ void DrawInvBelt(const CelOutputBuffer &out)
if (pcursinvitem == i + INVITEM_BELT_FIRST) {
if (!sgbControllerActive || invflag) {
CelBlitOutlineTo(out, GetOutlineColor(myPlayer.SpdList[i], true), InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, cel, celFrame, false);
CelBlitOutlineTo(out, GetOutlineColor(myPlayer.SpdList[i], true), position, cel, celFrame, false);
}
}
CelDrawItem(myPlayer.SpdList[i]._iStatFlag, out, InvRect[i + SLOTXY_BELT_FIRST].X + PANEL_X, InvRect[i + SLOTXY_BELT_FIRST].Y + PANEL_Y - 1, cel, celFrame);
CelDrawItem(myPlayer.SpdList[i]._iStatFlag, out, position, cel, celFrame);
if (AllItemsList[myPlayer.SpdList[i].IDidx].iUsable
&& myPlayer.SpdList[i]._iStatFlag

2
Source/items.cpp

@ -3696,7 +3696,7 @@ void PrintItemPower(char plidx, ItemStruct *x)
static void DrawUTextBack(const CelOutputBuffer &out)
{
CelDrawTo(out, RIGHT_PANEL_X - SPANEL_WIDTH + 24, 327, *pSTextBoxCels, 1);
CelDrawTo(out, { RIGHT_PANEL_X - SPANEL_WIDTH + 24, 327 }, *pSTextBoxCels, 1);
DrawHalfTransparentRectTo(out, RIGHT_PANEL_X - SPANEL_WIDTH + 27, 28, 265, 297);
}

2
Source/minitext.cpp

@ -155,7 +155,7 @@ void InitQTextMsg(_speech_id m)
void DrawQTextBack(const CelOutputBuffer &out)
{
CelDrawTo(out, PANEL_X + 24, 327 + UI_OFFSET_Y, *pTextBoxCels, 1);
CelDrawTo(out, { PANEL_X + 24, 327 + UI_OFFSET_Y }, *pTextBoxCels, 1);
DrawHalfTransparentRectTo(out, PANEL_X + 27, UI_OFFSET_Y + 28, 585, 297);
}

6
Source/quests.cpp

@ -718,18 +718,18 @@ static void PrintQLString(const CelOutputBuffer &out, int x, int line, const cha
int sx = x + std::max((257 - width) / 2, 0);
int sy = line * 12 + 44;
if (qline == line) {
CelDrawTo(out, sx - 20, sy + 1, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, { sx - 20, sy + 1 }, *pSPentSpn2Cels, PentSpn2Spin());
}
DrawString(out, str, { sx, sy, 257, 0 }, UIS_SILVER);
if (qline == line) {
CelDrawTo(out, sx + width + 7, sy + 1, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, { sx + width + 7, sy + 1 }, *pSPentSpn2Cels, PentSpn2Spin());
}
}
void DrawQuestLog(const CelOutputBuffer &out)
{
DrawString(out, _("Quest Log"), { 32, 44, 257, 0 }, UIS_CENTER);
CelDrawTo(out, 0, 351, *pQLogCel, 1);
CelDrawTo(out, { 0, 351 }, *pQLogCel, 1);
int line = qtopline;
for (int i = 0; i < numqlines; i++) {
PrintQLString(out, 32, line, _(questlist[qlist[i]]._qlstr));

28
Source/scrollrt.cpp

@ -217,12 +217,13 @@ static void DrawCursor(const CelOutputBuffer &out)
const auto &sprite = GetInvItemSprite(pcurs);
const int frame = GetInvItemFrame(pcurs);
bool usable = true;
const Point mousePosition { MouseX, MouseY + cursH - 1 };
if (pcurs >= CURSOR_FIRSTITEM) {
const auto &heldItem = plr[myplr].HoldItem;
CelBlitOutlineTo(out, GetOutlineColor(heldItem, true), MouseX, MouseY + cursH - 1, sprite, frame, false);
CelBlitOutlineTo(out, GetOutlineColor(heldItem, true), mousePosition, sprite, frame, false);
usable = heldItem._iStatFlag;
}
CelDrawItem(usable, out, MouseX, MouseY + cursH - 1, sprite, frame);
CelDrawItem(usable, out, mousePosition, sprite, frame);
}
/**
@ -532,13 +533,14 @@ static void DrawObject(const CelOutputBuffer &out, int x, int y, int ox, int oy,
return;
}
const Point objectPosition { sx, sy };
CelSprite cel { object[bv]._oAnimData, object[bv]._oAnimWidth };
if (bv == pcursobj)
CelBlitOutlineTo(out, 194, sx, sy, cel, object[bv]._oAnimFrame);
CelBlitOutlineTo(out, 194, objectPosition, cel, object[bv]._oAnimFrame);
if (object[bv]._oLight) {
CelClippedDrawLightTo(out, sx, sy, cel, object[bv]._oAnimFrame);
CelClippedDrawLightTo(out, objectPosition, cel, object[bv]._oAnimFrame);
} else {
CelClippedDrawTo(out, sx, sy, cel, object[bv]._oAnimFrame);
CelClippedDrawTo(out, objectPosition, cel, object[bv]._oAnimFrame);
}
}
@ -633,10 +635,11 @@ static void DrawItem(const CelOutputBuffer &out, int x, int y, int sx, int sy, b
}
int px = sx - CalculateWidth2(cel->Width());
const Point position { px, sy };
if (bItem - 1 == pcursitem || AutoMapShowItems) {
CelBlitOutlineTo(out, GetOutlineColor(*pItem, false), px, sy, *cel, nCel);
CelBlitOutlineTo(out, GetOutlineColor(*pItem, false), position, *cel, nCel);
}
CelClippedDrawLightTo(out, px, sy, *cel, nCel);
CelClippedDrawLightTo(out, position, *cel, nCel);
if (pItem->_iAnimFrame == pItem->_iAnimLen)
AddItemToLabelQueue(bItem - 1, px, sy);
}
@ -660,11 +663,12 @@ static void DrawMonsterHelper(const CelOutputBuffer &out, int x, int y, int oy,
if (leveltype == DTYPE_TOWN) {
px = sx - CalculateWidth2(towners[mi]._tAnimWidth);
const Point position { px, sy };
if (mi == pcursmonst) {
CelBlitOutlineTo(out, 166, px, sy, CelSprite(towners[mi]._tAnimData, towners[mi]._tAnimWidth), towners[mi]._tAnimFrame);
CelBlitOutlineTo(out, 166, position, CelSprite(towners[mi]._tAnimData, towners[mi]._tAnimWidth), towners[mi]._tAnimFrame);
}
assert(towners[mi]._tAnimData);
CelClippedDrawTo(out, px, sy, CelSprite(towners[mi]._tAnimData, towners[mi]._tAnimWidth), towners[mi]._tAnimFrame);
CelClippedDrawTo(out, position, CelSprite(towners[mi]._tAnimData, towners[mi]._tAnimWidth), towners[mi]._tAnimFrame);
return;
}
@ -754,7 +758,7 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in
#ifdef _DEBUG
if (visiondebug && bFlag & BFLAG_LIT) {
CelClippedDrawTo(out, dx, dy, *pSquareCel, 1);
CelClippedDrawTo(out, { dx, dy }, *pSquareCel, 1);
}
#endif
@ -814,7 +818,7 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in
cel_transparency_active = false; // Turn transparency off here for debugging
}
#endif
CelClippedBlitLightTransTo(out, dx, dy, *pSpecialCels, bArch);
CelClippedBlitLightTransTo(out, { dx, dy }, *pSpecialCels, bArch);
#ifdef _DEBUG
if ((GetAsyncKeyState(DVL_VK_MENU) & 0x8000) != 0) {
cel_transparency_active = TransList[bMap]; // Turn transparency back to its normal state
@ -828,7 +832,7 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in
if (sx > 0 && sy > 0 && dy > TILE_HEIGHT) {
char bArch = dSpecial[sx - 1][sy - 1];
if (bArch != 0) {
CelDrawTo(out, dx, dy - TILE_HEIGHT, *pSpecialCels, bArch);
CelDrawTo(out, { dx, dy - TILE_HEIGHT }, *pSpecialCels, bArch);
}
}
}

18
Source/stores.cpp

@ -75,7 +75,7 @@ const char *const TownerNames[] = {
void DrawSTextBack(const CelOutputBuffer &out)
{
CelDrawTo(out, PANEL_X + 320 + 24, 327 + UI_OFFSET_Y, *pSTextBoxCels, 1);
CelDrawTo(out, { PANEL_X + 320 + 24, 327 + UI_OFFSET_Y }, *pSTextBoxCels, 1);
DrawHalfTransparentRectTo(out, PANEL_X + 347, UI_OFFSET_Y + 28, 265, 297);
}
@ -84,17 +84,17 @@ void DrawSSlider(const CelOutputBuffer &out, int y1, int y2)
int yd1 = y1 * 12 + 44 + UI_OFFSET_Y;
int yd2 = y2 * 12 + 44 + UI_OFFSET_Y;
if (stextscrlubtn != -1)
CelDrawTo(out, PANEL_X + 601, yd1, *pSTextSlidCels, 12);
CelDrawTo(out, { PANEL_X + 601, yd1 }, *pSTextSlidCels, 12);
else
CelDrawTo(out, PANEL_X + 601, yd1, *pSTextSlidCels, 10);
CelDrawTo(out, { PANEL_X + 601, yd1 }, *pSTextSlidCels, 10);
if (stextscrldbtn != -1)
CelDrawTo(out, PANEL_X + 601, yd2, *pSTextSlidCels, 11);
CelDrawTo(out, { PANEL_X + 601, yd2 }, *pSTextSlidCels, 11);
else
CelDrawTo(out, PANEL_X + 601, yd2, *pSTextSlidCels, 9);
CelDrawTo(out, { PANEL_X + 601, yd2 }, *pSTextSlidCels, 9);
yd1 += 12;
int yd3 = yd1;
for (; yd3 < yd2; yd3 += 12) {
CelDrawTo(out, PANEL_X + 601, yd3, *pSTextSlidCels, 14);
CelDrawTo(out, { PANEL_X + 601, yd3 }, *pSTextSlidCels, 14);
}
if (stextsel == 22)
yd3 = stextlhold;
@ -104,7 +104,7 @@ void DrawSSlider(const CelOutputBuffer &out, int y1, int y2)
yd3 = 1000 * (stextsval + ((yd3 - stextup) / 4)) / (storenumh - 1) * (y2 * 12 - y1 * 12 - 24) / 1000;
else
yd3 = 0;
CelDrawTo(out, PANEL_X + 601, (y1 + 1) * 12 + 44 + UI_OFFSET_Y + yd3, *pSTextSlidCels, 13);
CelDrawTo(out, { PANEL_X + 601, (y1 + 1) * 12 + 44 + UI_OFFSET_Y + yd3 }, *pSTextSlidCels, 13);
}
void AddSLine(int y)
@ -2226,13 +2226,13 @@ static void DrawSelector(const CelOutputBuffer &out, const SDL_Rect &rect, const
if ((flags & UIS_CENTER) != 0)
x1 += (rect.w - lineWidth) / 2;
CelDrawTo(out, x1, rect.y + 1, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, { x1, rect.y + 1 }, *pSPentSpn2Cels, PentSpn2Spin());
int x2 = rect.x + rect.w + 5;
if ((flags & UIS_CENTER) != 0)
x2 = rect.x + (rect.w - lineWidth) / 2 + lineWidth + 5;
CelDrawTo(out, x2, rect.y + 1, *pSPentSpn2Cels, PentSpn2Spin());
CelDrawTo(out, { x2, rect.y + 1 }, *pSPentSpn2Cels, PentSpn2Spin());
}
void PrintSString(const CelOutputBuffer &out, int margin, int line, const char *text, uint16_t flags, int price)

Loading…
Cancel
Save