Skip to content

Inconsistent ordering of CPUs on menu. #2598

@Dunbaratu

Description

@Dunbaratu

(This is true for both for kOSToolbarWindow and the TelnetWelcomeMenu.)

Right now, if you use either the TelnetWelcomeMenu or the kOSToolbarWindow, they display a list of CPUs you can connect to. That list is only semi-sorted and isn't consistent. It comes out all different every time. This means when a user clicks a terminal in the list (or picks a number from the telnet welcome menu), even if they click the same position in the list, they keep getting a different terminal every time. (i.e. "I will revert to launch, then click the first terminal. Oh dang it, the first terminal isn't the same one this time. Where did the one I wanted end up in the list this time? Let's go through and try them one at a time.")

This is a bit annoying for the twitch-plays-ksp people, where "first terminal in the list" it connects to isn't the same every time.

The fix would be to sort that list so a CPU appears on it in a consistent position. Right now it is finding the objects in whatever random order Unity happens to return the jumble of GameObjects of type KOSProcessor in, and putting them on the menu in that order.

I am considering this ordering:

  • FIRST SORT CRITERIA: By Vessel, ordered by XYZ distance of vessel from active vessel, so vessels near the active vessel come first, with the active vessel always at the top.

  • SECOND SORT CRITERIA: Within each Vessel, order CPUs by how many parts between it and the root, counted by iterating the "parent" links. The CPU that is "closest to root" comes first in the list - as measured by integer number of parts rather than by XYZ distance. This should have the effect that the "most central" CPU will be first in the list, with detachable things like rovers coming further down the list. Alternatively, the count could JUST count decouplers between itself and the root, to order by stages, but that could generate "ties" more often.

As this is a list that doesn't get regenerated frequently, the expense of the sort shouldn't matter too much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething new (not a bug fix) is being requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions