|
|
|
|
@ -16,45 +16,14 @@
|
|
|
|
|
#include "utils/language.h" |
|
|
|
|
|
|
|
|
|
namespace devilution { |
|
|
|
|
|
|
|
|
|
/** Pixel width of the current cursor image */ |
|
|
|
|
int cursW; |
|
|
|
|
/** Pixel height of the current cursor image */ |
|
|
|
|
int cursH; |
|
|
|
|
/** Current highlighted monster */ |
|
|
|
|
int pcursmonst = -1; |
|
|
|
|
/** Width of current cursor in inventory cells */ |
|
|
|
|
int icursW28; |
|
|
|
|
/** Height of current cursor in inventory cells */ |
|
|
|
|
int icursH28; |
|
|
|
|
namespace { |
|
|
|
|
/** Cursor images CEL */ |
|
|
|
|
std::optional<CelSprite> pCursCels; |
|
|
|
|
std::optional<CelSprite> pCursCels2; |
|
|
|
|
constexpr int InvItems1Size = 180; |
|
|
|
|
|
|
|
|
|
/** inv_item value */ |
|
|
|
|
int8_t pcursinvitem; |
|
|
|
|
/** Pixel width of the current cursor image */ |
|
|
|
|
int icursW; |
|
|
|
|
/** Pixel height of the current cursor image */ |
|
|
|
|
int icursH; |
|
|
|
|
/** Current highlighted item */ |
|
|
|
|
int8_t pcursitem; |
|
|
|
|
/** Current highlighted object */ |
|
|
|
|
int8_t pcursobj; |
|
|
|
|
/** Current highlighted player */ |
|
|
|
|
int8_t pcursplr; |
|
|
|
|
/** Current highlighted tile row */ |
|
|
|
|
int cursmx; |
|
|
|
|
/** Current highlighted tile column */ |
|
|
|
|
int cursmy; |
|
|
|
|
/** Previously highlighted monster */ |
|
|
|
|
int pcurstemp; |
|
|
|
|
/** Index of current cursor image */ |
|
|
|
|
int pcurs; |
|
|
|
|
|
|
|
|
|
/* rdata */ |
|
|
|
|
/** Maps from objcurs.cel frame number to frame width. */ |
|
|
|
|
const int InvItemWidth[] = { |
|
|
|
|
const int InvItemWidth1[] = { |
|
|
|
|
// clang-format off
|
|
|
|
|
// Cursors
|
|
|
|
|
0, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 23, |
|
|
|
|
@ -76,6 +45,9 @@ const int InvItemWidth[] = {
|
|
|
|
|
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, |
|
|
|
|
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, |
|
|
|
|
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, |
|
|
|
|
}; |
|
|
|
|
const int InvItemWidth2[] = { |
|
|
|
|
0, |
|
|
|
|
1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, |
|
|
|
|
1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, |
|
|
|
|
1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, |
|
|
|
|
@ -86,7 +58,7 @@ const int InvItemWidth[] = {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** Maps from objcurs.cel frame number to frame height. */ |
|
|
|
|
const int InvItemHeight[] = { |
|
|
|
|
const int InvItemHeight1[] = { |
|
|
|
|
// clang-format off
|
|
|
|
|
// Cursors
|
|
|
|
|
0, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35, |
|
|
|
|
@ -108,6 +80,9 @@ const int InvItemHeight[] = {
|
|
|
|
|
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, |
|
|
|
|
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, |
|
|
|
|
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, |
|
|
|
|
}; |
|
|
|
|
const int InvItemHeight2[] = { |
|
|
|
|
0, |
|
|
|
|
1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, |
|
|
|
|
1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, |
|
|
|
|
1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, 1 * 28, |
|
|
|
|
@ -117,12 +92,46 @@ const int InvItemHeight[] = {
|
|
|
|
|
// clang-format on
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
/** Pixel width of the current cursor image */ |
|
|
|
|
int cursW; |
|
|
|
|
/** Pixel height of the current cursor image */ |
|
|
|
|
int cursH; |
|
|
|
|
/** Current highlighted monster */ |
|
|
|
|
int pcursmonst = -1; |
|
|
|
|
/** Width of current cursor in inventory cells */ |
|
|
|
|
int icursW28; |
|
|
|
|
/** Height of current cursor in inventory cells */ |
|
|
|
|
int icursH28; |
|
|
|
|
|
|
|
|
|
/** inv_item value */ |
|
|
|
|
int8_t pcursinvitem; |
|
|
|
|
/** Pixel width of the current cursor image */ |
|
|
|
|
int icursW; |
|
|
|
|
/** Pixel height of the current cursor image */ |
|
|
|
|
int icursH; |
|
|
|
|
/** Current highlighted item */ |
|
|
|
|
int8_t pcursitem; |
|
|
|
|
/** Current highlighted object */ |
|
|
|
|
int8_t pcursobj; |
|
|
|
|
/** Current highlighted player */ |
|
|
|
|
int8_t pcursplr; |
|
|
|
|
/** Current highlighted tile row */ |
|
|
|
|
int cursmx; |
|
|
|
|
/** Current highlighted tile column */ |
|
|
|
|
int cursmy; |
|
|
|
|
/** Previously highlighted monster */ |
|
|
|
|
int pcurstemp; |
|
|
|
|
/** Index of current cursor image */ |
|
|
|
|
int pcurs; |
|
|
|
|
|
|
|
|
|
void InitCursor() |
|
|
|
|
{ |
|
|
|
|
assert(!pCursCels); |
|
|
|
|
pCursCels = LoadCel("Data\\Inv\\Objcurs.CEL", InvItemWidth); |
|
|
|
|
pCursCels = LoadCel("Data\\Inv\\Objcurs.CEL", InvItemWidth1); |
|
|
|
|
if (gbIsHellfire) |
|
|
|
|
pCursCels2 = LoadCel("Data\\Inv\\Objcurs2.CEL", InvItemWidth); |
|
|
|
|
pCursCels2 = LoadCel("Data\\Inv\\Objcurs2.CEL", InvItemWidth2); |
|
|
|
|
ClearCursor(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -133,10 +142,26 @@ void FreeCursor()
|
|
|
|
|
ClearCursor(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const CelSprite &GetInvItemSprite(int i) |
|
|
|
|
{ |
|
|
|
|
return i < InvItems1Size ? *pCursCels : *pCursCels2; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int GetInvItemFrame(int i) |
|
|
|
|
{ |
|
|
|
|
return i < InvItems1Size ? i : i - (InvItems1Size - 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::pair<int, int> GetInvItemSize(int i) |
|
|
|
|
{ |
|
|
|
|
if (i >= InvItems1Size) |
|
|
|
|
return { InvItemWidth2[i - (InvItems1Size - 1)], InvItemHeight2[i - (InvItems1Size - 1)] }; |
|
|
|
|
return { InvItemWidth1[i], InvItemHeight1[i] }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SetICursor(int i) |
|
|
|
|
{ |
|
|
|
|
icursW = InvItemWidth[i]; |
|
|
|
|
icursH = InvItemHeight[i]; |
|
|
|
|
std::tie(icursW, icursH) = GetInvItemSize(i); |
|
|
|
|
icursW28 = icursW / 28; |
|
|
|
|
icursH28 = icursH / 28; |
|
|
|
|
} |
|
|
|
|
@ -144,8 +169,7 @@ void SetICursor(int i)
|
|
|
|
|
void NewCursor(int i) |
|
|
|
|
{ |
|
|
|
|
pcurs = i; |
|
|
|
|
cursW = InvItemWidth[i]; |
|
|
|
|
cursH = InvItemHeight[i]; |
|
|
|
|
std::tie(cursW, cursH) = GetInvItemSize(i); |
|
|
|
|
SetICursor(i); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|