HD Cursor
This commit is contained in:
parent
32411daa67
commit
4b9b02783f
5
assets/opensb/cursors/cursors.frames.patch
Normal file
5
assets/opensb/cursors/cursors.frames.patch
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"frameGrid" : {
|
||||
"size" : [32, 32]
|
||||
}
|
||||
}
|
BIN
assets/opensb/cursors/cursors.png
Normal file
BIN
assets/opensb/cursors/cursors.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
3
assets/opensb/cursors/inspect.cursor.patch
Normal file
3
assets/opensb/cursors/inspect.cursor.patch
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"scale" : 1
|
||||
}
|
3
assets/opensb/cursors/link.cursor.patch
Normal file
3
assets/opensb/cursors/link.cursor.patch
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"scale" : 1
|
||||
}
|
3
assets/opensb/cursors/pointer.cursor.patch
Normal file
3
assets/opensb/cursors/pointer.cursor.patch
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"scale" : 1
|
||||
}
|
@ -76,11 +76,13 @@ void ErrorScreen::renderCursor() {
|
||||
Vec2I cursorPos = m_cursorScreenPos;
|
||||
Vec2I cursorSize = m_cursor.size();
|
||||
Vec2I cursorOffset = m_cursor.offset();
|
||||
unsigned int cursorScale = m_cursor.scale(interfaceScale());
|
||||
Drawable cursorDrawable = m_cursor.drawable();
|
||||
|
||||
cursorPos[0] -= cursorOffset[0] * interfaceScale();
|
||||
cursorPos[1] -= (cursorSize[1] - cursorOffset[1]) * interfaceScale();
|
||||
if (!m_guiContext->trySetCursor(m_cursor.drawable(), cursorOffset, interfaceScale()))
|
||||
m_guiContext->drawDrawable(m_cursor.drawable(), Vec2F(cursorPos), interfaceScale());
|
||||
cursorPos[0] -= cursorOffset[0] * cursorScale;
|
||||
cursorPos[1] -= (cursorSize[1] - cursorOffset[1]) * cursorScale;
|
||||
if (!m_guiContext->trySetCursor(cursorDrawable, cursorOffset, cursorScale))
|
||||
m_guiContext->drawDrawable(cursorDrawable, Vec2F(cursorPos), cursorScale);
|
||||
}
|
||||
|
||||
float ErrorScreen::interfaceScale() const {
|
||||
|
@ -36,6 +36,8 @@ void InterfaceCursor::setCursor(String const& configFile) {
|
||||
m_drawable = Animation(config.get("animation"), "/interface");
|
||||
m_size = Vec2I(m_drawable.get<Animation>().drawable(1.0f).boundBox(false).size());
|
||||
}
|
||||
|
||||
m_scale = config.getUInt("scale", 0);
|
||||
}
|
||||
|
||||
Drawable InterfaceCursor::drawable() const {
|
||||
@ -53,6 +55,10 @@ Vec2I InterfaceCursor::offset() const {
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
unsigned int InterfaceCursor::scale(unsigned int interfaceScale) const {
|
||||
return m_scale ? m_scale : interfaceScale;
|
||||
}
|
||||
|
||||
void InterfaceCursor::update(float dt) {
|
||||
if (m_drawable.is<Animation>()) {
|
||||
m_drawable.get<Animation>().update(dt);
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
Drawable drawable() const;
|
||||
Vec2I size() const;
|
||||
Vec2I offset() const;
|
||||
unsigned int scale(unsigned int interfaceScale = 0) const;
|
||||
|
||||
void update(float dt);
|
||||
|
||||
@ -27,6 +28,7 @@ private:
|
||||
String m_configFile;
|
||||
Vec2I m_offset;
|
||||
Vec2I m_size;
|
||||
unsigned int m_scale;
|
||||
MVariant<String, Animation> m_drawable;
|
||||
};
|
||||
|
||||
|
@ -1375,10 +1375,13 @@ void MainInterface::renderCursor() {
|
||||
Vec2I cursorPos = m_cursorScreenPos;
|
||||
Vec2I cursorSize = m_cursor.size();
|
||||
Vec2I cursorOffset = m_cursor.offset();
|
||||
cursorPos[0] -= cursorOffset[0] * interfaceScale();
|
||||
cursorPos[1] -= (cursorSize[1] - cursorOffset[1]) * interfaceScale();
|
||||
if (!m_guiContext->trySetCursor(m_cursor.drawable(), cursorOffset, interfaceScale()))
|
||||
m_guiContext->drawDrawable(m_cursor.drawable(), Vec2F(cursorPos), interfaceScale());
|
||||
unsigned int cursorScale = m_cursor.scale(interfaceScale());
|
||||
Drawable cursorDrawable = m_cursor.drawable();
|
||||
|
||||
cursorPos[0] -= cursorOffset[0] * cursorScale;
|
||||
cursorPos[1] -= (cursorSize[1] - cursorOffset[1]) * cursorScale;
|
||||
if (!m_guiContext->trySetCursor(cursorDrawable, cursorOffset, cursorScale))
|
||||
m_guiContext->drawDrawable(cursorDrawable, Vec2F(cursorPos), cursorScale);
|
||||
|
||||
if (m_cursorTooltip) {
|
||||
auto assets = Root::singleton().assets();
|
||||
@ -1388,7 +1391,7 @@ void MainInterface::renderCursor() {
|
||||
auto rawCursorOffset = jsonToVec2I(assets->json("/interface.config:cursorTooltip.offset"));
|
||||
|
||||
Vec2I tooltipSize = Vec2I(imgDb->imageSize(backgroundImage)) * interfaceScale();
|
||||
Vec2I cursorOffset = (Vec2I{0, -m_cursor.size().y()} + rawCursorOffset) * interfaceScale();
|
||||
Vec2I cursorOffset = (Vec2I{0, -m_cursor.size().y()} + rawCursorOffset) * cursorScale;
|
||||
Vec2I tooltipOffset = m_cursorScreenPos + cursorOffset;
|
||||
size_t fontSize = assets->json("/interface.config:cursorTooltip.fontSize").toUInt();
|
||||
String font = assets->json("/interface.config:cursorTooltip.font").toString();
|
||||
@ -1404,7 +1407,7 @@ void MainInterface::renderCursor() {
|
||||
VerticalAnchor::VMidAnchor));
|
||||
}
|
||||
|
||||
m_cursorItem->setPosition(m_cursorScreenPos / interfaceScale() + m_config->inventoryItemMouseOffset);
|
||||
m_cursorItem->setPosition(m_cursorScreenPos / cursorScale + m_config->inventoryItemMouseOffset);
|
||||
|
||||
if (auto swapItem = m_client->mainPlayer()->inventory()->swapSlotItem())
|
||||
m_cursorItem->setItem(swapItem);
|
||||
|
@ -414,11 +414,14 @@ void TitleScreen::renderCursor() {
|
||||
Vec2I cursorPos = m_cursorScreenPos;
|
||||
Vec2I cursorSize = m_cursor.size();
|
||||
Vec2I cursorOffset = m_cursor.offset();
|
||||
unsigned int cursorScale = m_cursor.scale(interfaceScale());
|
||||
Drawable cursorDrawable = m_cursor.drawable();
|
||||
|
||||
cursorPos[0] -= cursorOffset[0] * interfaceScale();
|
||||
cursorPos[1] -= (cursorSize[1] - cursorOffset[1]) * interfaceScale();
|
||||
if (!m_guiContext->trySetCursor(m_cursor.drawable(), cursorOffset, interfaceScale()))
|
||||
m_guiContext->drawDrawable(m_cursor.drawable(), Vec2F(cursorPos), interfaceScale());
|
||||
cursorPos[0] -= cursorOffset[0] * cursorScale;
|
||||
cursorPos[1] -= (cursorSize[1] - cursorOffset[1]) * cursorScale;
|
||||
|
||||
if (!m_guiContext->trySetCursor(cursorDrawable, cursorOffset, cursorScale))
|
||||
m_guiContext->drawDrawable(cursorDrawable, Vec2F(cursorPos), cursorScale);
|
||||
}
|
||||
|
||||
float TitleScreen::interfaceScale() const {
|
||||
|
Loading…
Reference in New Issue
Block a user