devilutionX/Source/cursor.h
Gleb Mazovetskiy f9d20b44d6 🎉 Hardware cursor (SDL2-only)
Disabled by default because of these known issues:

1. When clicking on inventory item, it briefly appears a bit shifted (in the wrong coordinates).

   This issue can happen with software cursor as well, but is a lot more
   obvious with the hardware cursor.

2. Cursor is scaled with nearest-neighbour scaling, which may look a bit different from
   how the rest of the graphics are scaled.

See also previous attempt: https://github.com/diasurgical/devilutionX/pull/955 by @viciious

Co-authored-by: Victor Luchits <vluchits@gmail.com>
2021-06-19 01:03:40 +02:00

73 lines
1.5 KiB
C++

/**
* @file cursor.h
*
* Interface of cursor tracking functionality.
*/
#pragma once
#include <cstdint>
#include <utility>
#include "engine.h"
#include "miniwin/miniwin.h"
#include "utils/stdcompat/optional.hpp"
namespace devilution {
enum cursor_id : uint8_t {
CURSOR_NONE,
CURSOR_HAND,
CURSOR_IDENTIFY,
CURSOR_REPAIR,
CURSOR_RECHARGE,
CURSOR_DISARM,
CURSOR_OIL,
CURSOR_TELEKINESIS,
CURSOR_RESURRECT,
CURSOR_TELEPORT,
CURSOR_HEALOTHER,
CURSOR_HOURGLASS,
CURSOR_FIRSTITEM,
};
extern int cursW;
extern int cursH;
extern int pcursmonst;
extern int icursW28;
extern int icursH28;
extern int icursH;
extern int8_t pcursinvitem;
extern int icursW;
extern int8_t pcursitem;
extern int8_t pcursobj;
extern int8_t pcursplr;
extern int cursmx;
extern int cursmy;
extern int pcurs;
void InitCursor();
void FreeCursor();
void SetICursor(int i);
void NewCursor(int i);
void InitLevelCursor();
void CheckRportal();
void CheckTown();
void CheckCursMove();
inline bool IsItemSprite(int pcurs)
{
return pcurs >= CURSOR_FIRSTITEM;
}
void CelDrawCursor(const CelOutputBuffer &out, Point position, int pcurs);
/** Returns the sprite for the given inventory index. */
const CelSprite &GetInvItemSprite(int i);
/** Returns the CEL frame index for the given inventory index. */
int GetInvItemFrame(int i);
/** Returns the width and height for an inventory index. */
std::pair<int, int> GetInvItemSize(int i);
} // namespace devilution