New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix offset being ignored by inventory bar HUD #2094
Conversation
rubenwardy
commented
Jan 9, 2015
4e1fba1
to
027e404
Compare
Just look at the code, the offset is never used. |
{ | ||
#ifdef HAVE_TOUCHSCREENGUI | ||
if ( (g_touchscreengui) && (offset == 0)) | ||
if ( (g_touchscreengui) && (inv_offset == 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the superfluous parenthesis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just changed the existing code, but I'll fix that.
@sapier, please may you check that the scaling works on this? |
What's the status on this? Just tried it in the latest version and offset still does absolutely nothing. |
I was waiting for @sapier to test the scaling, as I'm unsure whether it works correctly. |
} | ||
|
||
offset.X *= g_settings->getFloat("hud_scaling") * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting the setting? Twice? Best, it should be cached somewhere, retrieving settings with the hashmap isn't fast at all.
ee4bc83
to
9b5faa7
Compare
Fixed, rebased and ready for review. |
Bump, is it worth rebasing this? |
9b5faa7
to
5eb8eee
Compare
Rebased and ready for review |
Yes it's worth rebasing, thanks, sorry it was neglected. |
Rebased and code style fixed |
I assume the bug is fixed by this PR? |
That rendering bug is present both before and after my PR. Currently working out the cause. |
Read the code change, and this is almost trivial. The actual effective change is maybe 3 lines, the rest are all cleanups or passing the parameter around the function calls. |
Graphics bug moved to here: #3970 |
👍 |
Code reviewed @rubenwardy is this tested? if so +1. |
I've tested this, and it makes the attached code example work. |
👍 |
void Hud::drawItems(v2s32 upperleftpos, s32 itemcount, s32 offset, | ||
InventoryList *mainlist, u16 selectitem, u16 direction) | ||
void Hud::drawItems(v2s32 upperleftpos, s32 itemcount, s32 inv_offset, | ||
InventoryList *mainlist, u16 selectitem, u16 direction, const v2s32 &offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is offset a const ref while upperleftpos isn't? Please make both a const ref, or pass offset by value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this makes that much sense any way... sizeof(v2s32) == 8
so on 64 bit architectures the pointer isn't smaller than the actual data. This means an extra level of indirection, which is bad, and for (almost) no use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I'm just going to change this while merging...
👍 |