OpenTTD

Tasklist

FS#6491 - New group as subgroup of selected group

Attached to Project: OpenTTD
Opened by 3298 (3298) - Monday, 18 July 2016, 19:31 GMT
Type Patch
Category Interface
Status New
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

When creating a group, it is sometimes meant to be a subgroup of an existing group. Currently this has to be done in two steps: creating the group, then dragging it onto the parent group. With a lot of groups, dragging can become unpleasant. This patch aims to eliminate the second step by using the selected group as parent of the new group. Parent-less groups can be created by selecting the special groups (all, ungrouped).
This patch was originally done as a response to a thread in the OpenTTD Suggestions forum (https://www.tt-forums.net/viewtopic.php?f=32&t=72169), but it seems I never actually posted it. I recently rediscovered it in my local git repository and rebased it.
The implementation is pretty straightforward, using the (previously unused) parameter p2 of CmdCreateGroup to transfer the parent group. If it is a valid group, the same sanity checks as in CmdAlterGroup are performed (excluding the infinite loop check because the newly created group cannot be the parent of anything yet).
Creating a group by pushing the button sends the currently selected group as parent, of course.
Creating a group by dragging a vehicle sends INVALID_GROUP as parent because it needs to be dragged into the empty space below the list of groups. In that case, it feels more logical to create a parent-less group, but I am open to suggestions here.
Scripts also get to create parent-less groups only because I value compatibility over the slight performance and convenience advantages of changing the API to expose the added parent parameter. If a script wizard (Zuu?) knows how to expose the new parameter while preserving compatibility, feel free to amend the patch.
The attached patch applies to r27618.
This task depends upon

Loading...