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

Feature: Option to group vehicle list by shared orders #7028

Open
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@btzy
Copy link
Contributor

commented Jan 8, 2019

I added a "group by" dropdown to all vehicle lists to display one row per shared order, instead of one row per vehicle. I've tested it with all vehicle types, as well as with the "vehicle groups" window. When grouped by shared orders, clicking on a row will open the "shared orders of X vehicles" window.

Rationale: Quite often, we are concerned only with "routes" instead of individual vehicles. This feature highlights the important information (i.e. the routes) while reducing the importance of non-important information (i.e. the individual vehicles).

Extension: It is possible to have a third option - to group by vehicle group. As vehicle groups are mutually exclusive, it should be relatively simple to implement this extension. However, I'm not sure of its usefulness and I didn't want to make this PR too big.

Note: The new dropdown is available in the "shared orders of X vehicles" window too. Though it is of not much use, I left it in for consistency. The dropdown will be useful for the extension described above.

This is as per my post on TT Forums: https://www.tt-forums.net/viewtopic.php?f=32&t=84587&sid=fa68e80118896fca8f275a70d5cf6045

Some screenshots:
image
image
image
image

@btzy btzy force-pushed the btzy:station-vehicle-grouping branch from a02f906 to 7d4722c Jan 8, 2019

@LordAro
Copy link
Member

left a comment

General idea is great, thanks for contributing! It's quite a large diff with lots of changes all together, do you think it would be feasible to split it into multiple logical commits?
I wonder about the fairly significant use of C++11 stuff as well. Technically we should be all fine for it, but...

Show resolved Hide resolved src/vehicle_gui.cpp Outdated
Show resolved Hide resolved src/vehicle_gui.cpp Outdated
Show resolved Hide resolved src/vehicle_gui.cpp Outdated
Show resolved Hide resolved src/widgets/group_widget.h Outdated
Show resolved Hide resolved src/widgets/vehicle_widget.h Outdated
Show resolved Hide resolved src/vehicle_gui.cpp Outdated
@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Jan 11, 2019

@LordAro Maybe I can split it into two commits: The first commit would split the original this->vehicles into this->vehicles and this->vehgroups. And the second commit would introduce GB_NONE and GB_SHARED_ORDERS. Would this be okay?

@btzy btzy force-pushed the btzy:station-vehicle-grouping branch 7 times, most recently from a31262a to 70ab77f Jan 11, 2019

fixed

@LordAro LordAro requested a review from PeterN Feb 10, 2019

Show resolved Hide resolved src/vehicle_gui.cpp
Show resolved Hide resolved src/vehicle_gui.cpp Outdated
Show resolved Hide resolved src/vehicle_gui.cpp

@btzy btzy force-pushed the btzy:station-vehicle-grouping branch 3 times, most recently from 34cef8f to dbcac10 Feb 21, 2019

@PeterN

This comment has been minimized.

Copy link
Member

commented Feb 28, 2019

Seems confusing to have both explicit groups and this. Not sure where they should fit together.

@PeterN

This comment has been minimized.

Copy link
Member

commented Feb 28, 2019

This doesn't compile currently:

src/vehicle_gui.cpp:204:73: error: initialized lambda captures are a C++14 extension [-Werror,-Wc++14-extensions] const Vehicle **end = std::find_if_not(begin, this->vehicles.End(), [first_shared = (*...

Plus it would be useful to rebase to master.

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Feb 28, 2019

Seems confusing to have both explicit groups and this. Not sure where they should fit together.

My original motivation was that it was difficult to find a correct vehicle (for cloning / Ctrl-clicking) in a long list. I tend to play with lots of vehicles, and without this patch I would have to click vehicles at random and open their order lists to see if I've gotten the correct one.

Grouping by shared orders also allows certain contextual actions (on the vehicle list) that explicit groups can't have, such as opening the "Shared orders of X vehicles" window, opening the order list, or Ctrl-clicking for cloning.

Since both explicit groups and shared orders already exist in OpenTTD and solve orthogonal concerns (explicit groups being arbitrarily user-defined and shared orders being defined by having the same route), maybe it would reduce confusion to have a third option in the "group by" dropdown that groups by the explicit (user-defined) group? This would probably emphasise the distinction between explicit groups and shared orders. (If this is done, maybe "user-defined group" is a better term than "vehicle group".)

@Eddi-z

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2019

I would maybe even go further and include other automatic group-like features like "all vehicles visiting <station>"

@btzy btzy force-pushed the btzy:station-vehicle-grouping branch 2 times, most recently from a578902 to d87bfd3 Feb 28, 2019

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Feb 28, 2019

I would maybe even go further and include other automatic group-like features like "all vehicles visiting "

I'm not sure how this could be a group-like feature. Vehicles can visit multiple stations, so this kind of grouping doesn't seem to be mutually exclusive? Looks more like a filter-like feature to me.

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Feb 28, 2019

This doesn't compile currently:

src/vehicle_gui.cpp:204:73: error: initialized lambda captures are a C++14 extension [-Werror,-Wc++14-extensions] const Vehicle **end = std::find_if_not(begin, this->vehicles.End(), [first_shared = (*...

Plus it would be useful to rebase to master.

Sorry about that, now fixed and rebased to master.

@PeterN

This comment has been minimized.

Copy link
Member

commented Feb 28, 2019

Thanks, now able to test it :-)

Show resolved Hide resolved src/group_gui.cpp Outdated
Show resolved Hide resolved src/vehicle_gui_base.h Outdated
@PeterN

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

Could the group-by stuff be hidden/disabled when in the grouped-by vehicle list?

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Mar 25, 2019

Could the group-by stuff be hidden/disabled when in the grouped-by vehicle list?

I'm not sure which list you are referring to... do you mean the "Shared orders of X vehicles" list?

@PeterN

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

Yes, that particular one. I'm not sure if it makes sense or not to be have to have it grouped by shared orders, as it already is shared orders. On the other hand, if other group-by schemes are added it would again make sense. Hmm!

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Mar 26, 2019

Here's how it looks when disabled:

image

@btzy btzy force-pushed the btzy:station-vehicle-grouping branch from d87bfd3 to aed7b51 Mar 26, 2019

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Mar 26, 2019

Now the grouping is saved (in memory, similar to the way the sort option is saved). Different vehicle types have their grouping option saved independently, which is similar to the sort option. Different vehicle list types also have their grouping option saved independently, because it seems reasonable that users might only want to group by shared orders when in particular lists (e.g. list of vehicles at a station).

Also, the grouping dropdown menu is disabled for the shared-orders vehicle list, because it probably isn't useful to be able to group a shared-orders vehicle list by shared orders.

@btzy btzy force-pushed the btzy:station-vehicle-grouping branch 4 times, most recently from ef2cf9d to 9123cf3 Mar 28, 2019

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented Mar 28, 2019

@PeterN I've made the changes as you suggested, and also changed a few things related to the recent commits that replaced SmallVector with std::vector.

Outdated.

@stale

This comment has been minimized.

Copy link

commented Apr 29, 2019

This pull request has been automatically marked as stale because it has not had any activity in the last month.
Please feel free to give a status update now, ping for review, or re-open when it's ready.
It will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Apr 29, 2019

btzy added some commits Jan 11, 2019

Codechange: Make vehicle lists internally support grouping of vehicles
This is in preparation for the new UI feature that allows grouping by shared orders.
Feature: Option to group vehicle lists by shared orders
This applies to all kinds of vehicle lists, as well as the "vehicle groups" window.

@btzy btzy force-pushed the btzy:station-vehicle-grouping branch from 9123cf3 to 1437488 May 1, 2019

@stale stale bot removed the stale label May 1, 2019

@btzy

This comment has been minimized.

Copy link
Contributor Author

commented May 1, 2019

@PeterN Can you please review this PR? Your stalebot is reminding me about this...

@LordAro LordAro requested a review from PeterN May 2, 2019

resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.