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

Depress 'sell chain' button as well as sell button #6391

Closed
DorpsGek opened this issue Nov 15, 2015 · 3 comments
Closed

Depress 'sell chain' button as well as sell button #6391

DorpsGek opened this issue Nov 15, 2015 · 3 comments
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

Eearslya opened the ticket and wrote:

Something I neglected with my last patch, this will now depress the 'sell chain' button in train depots in the same fashion as the sell button in all other depots.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6391
@DorpsGek
Copy link
Member Author

Alberth wrote:

Some comments:

- bool sell_hovered; ///< A vehicle is being dragged/hovered over the sell button.
+ int current_hovered_widget;

Would be nice to have documentation here as well, in particular for the magic value -1.
Maybe add a constant to denote the special value?

Just "lowered_widget" or "hovered_widget" ? "current" is a bit implied already, and the name gets a bit long.

------------

+ if (widget != this->current_hovered_widget) {
+ if (this->current_hovered_widget == WID_D_SELL || this->current_hovered_widget == WID_D_SELL_CHAIN) {

Any particular reason not to use "!= -1" here?
As you wrote it now, the reader has to deduce that "!= -1" used in the previous hunk is equivalent to these equality tests. When the code gets changed in the future, somewhen this deduction will go wrong. Better be safe, and use the same condition when you mean the same thing.

------------

+ if (widget == WID_D_SELL || widget == WID_D_SELL_CHAIN) {
+ this->SetWidgetLoweredState(widget, true);
+ this->SetWidgetDirty(widget);
+ }
+ this->current_hovered_widget = widget;

I would swap this, first update 'current_hovered_widget', and then use the same condition and code as above with the same variable, making it plain and obviously it's doing the exact same thing with the new value.
You can go one step further, and fold the statements in a new function. Not sure this is useful though.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6391#comment14094

@DorpsGek
Copy link
Member Author

Eearslya wrote:

I fixed your first and third comments, but as for the second comment, that's not what it's doing. -1 was defined as 'no drag-and-drop is in progress', and that's not what that if is checking for. It's checking to see if the currently hovered widget has changed from its last recorded value. If it hasn't changed, there's no reason to proceed into that block.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6391#comment14095

@DorpsGek
Copy link
Member Author

Alberth closed the ticket.

Reason for closing: Implemented

in r27450


This comment was imported from FlySpray: https://bugs.openttd.org/task/6391

@DorpsGek DorpsGek added component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: interface This is an interface issue flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant