Skip to content
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 issue with scrolling in item description #35766 #35929

Merged
merged 5 commits into from
Dec 9, 2019
Merged

Fix issue with scrolling in item description #35766 #35929

merged 5 commits into from
Dec 9, 2019

Conversation

8street
Copy link
Contributor

@8street 8street commented Dec 7, 2019

Summary

SUMMARY: Bugfixes "Issue with scrolling in item description #35766"

Purpose of change

It fully resolves an issue: Fixes #35766
When scrolling the item description of an item with PgUp and PgDown, the scrolling now not get stuck.

Describe the solution

Scroll position now passed to "draw_item_info()" function by reference.

Testing

Tested in crafting menu, picking menu, compare menu and shift+V menu.

FIX Issue scrolling in item description #35766
FIX Issue scrolling in item description #35766
Update from astyle output
Update from astyle output
@Qrox
Copy link
Contributor

Qrox commented Dec 7, 2019

Perhaps it's better to pass selected as a reference to draw_item_info instead.

@8street
Copy link
Contributor Author

8street commented Dec 7, 2019

This is the reference. But I understood what you mean. I tried. This does not work. The function "draw_item_info" is also called without the parameter "selected" and it should equal zero. If the reference is zero, an exception will be thrown. Thus, the structure must store both parameters - the value "selected" and a link to it "ptr_selected".

@Qrox
Copy link
Contributor

Qrox commented Dec 7, 2019

You can add a new signature of draw_item_info without the parameter selected, and initialize a local variable with 0 and pass it to the actual draw_item_info function.

void draw_item_info( ... )
{
   int selected = 0;
   draw_item_info( ..., selected );
}

void draw_item_info( ..., int &selected )
{
  // the actual implementation of draw_item_info
}

And use it like this

item_info_data data( ... );
draw_item_info( win, data );
// or draw_item_info( win, data, selected );

@8street
Copy link
Contributor Author

8street commented Dec 7, 2019

Then you need to change a lot of code in the files where the function "draw_item_info" is called.
Instead, I'd changed one function "draw_item_info". In my case, the function interface is fully compatible with existing calls.

@Qrox
Copy link
Contributor

Qrox commented Dec 7, 2019

Well, having a struct contain a pointer to a value that is not managed by the struct itself could be dangerous. What if someone constructs item_info_data with a local selected variable and then uses
the item_info_data ouside the scope of selected? Then he gets a dangling pointer. If you pass selected as a reference directly to draw_item_info, there wouldn't be such problems.

@8street
Copy link
Contributor Author

8street commented Dec 7, 2019

You're right. But I can not figure out how to make it easier without lot code to be modified. Can you change the files yourself?

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. labels Dec 8, 2019
@kevingranade kevingranade merged commit b1c187d into CleverRaven:master Dec 9, 2019
@8street 8street deleted the fix-issue-with-scrolling-in-item-description-#35766 branch January 18, 2020 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with scrolling in item description
4 participants