I started looking at how to filter the follow order to be only if the selected item in SystemLocationsListBox was a task group or contact, but I'm not fully following how it's getting the type (looking at AddMoveButton_Clicked in Handlers/TaskGroup.cs) it appears to be looping through *everything* in the listbox here when the add button is clicked, and doing a switch case inside this loop.
doesn't it just need to check the selected item index? what am I missing?
regardless, this chunk should probably be put in a function of it's own, since it'll be wanting to get called from the BuildActionList() as well.
Index is just a number, it doesn't tell you anything about it, the Build SystemLocationListBox function can put planets, asteroids, contacts, friendly taskgroups,etc based on filtering, and the addMoveButton_clicked function needs a way of determining what exactly the system location is.The function then is looping through the SystemLocationListIndicies, which is going to be a list of 4 or 5(right now) "System Location Types". when it gets to the one it is, then it goes to the switch to determine what type of action should be undertaken.
This is BuildSystemLocationList, and as you can see not everything is put in there, so an index being selected in this list tells you nothing about what type of location is at any particular index without context.
/// <summary>
/// Build the Total System Location List here.
/// </summary>
private void BuildSystemLocationList()
{
m_oTaskGroupPanel.SystemLocationsListBox.Items.Clear();
SystemLocationListIndices.Clear();
SystemLocationListTypes.Clear();
AddPlanetsToList();
if (m_oTaskGroupPanel.DisplayContactsCheckBox.Checked == true)
AddContactsToList();
if (m_oTaskGroupPanel.DisplayTaskGroupsCheckBox.Checked == true)
AddTaskGroupsToList();
if (m_oTaskGroupPanel.DisplayWaypointsCheckBox.Checked == true)
AddWaypointsToList();
SystemLocationListIndices.Add(m_oTaskGroupPanel.SystemLocationsListBox.Items.Count);
SystemLocationListTypes.Add(SystemLocationListType.Count);
}
you don't have to worry about that right now though, just print the order in BuildActionList() and don't worry about filtering(it can be done later), and just don't click follow Planet/waypoint/etc, and AddMoveButton_Clicked will "automatically" take care of issuing the right order(again as long as you don't try to follow a planet).
If you do want to do orders filtering, then you have to update BuildActionList() to duplicate the for loop, and the switch present in AddMoveButton_Clicked() if an index is selected.
You basically have to duplicate the logic involved in putting entries into these lists if you want to get useful information out of them in other words, so look at how taskgroups are added to the list for example to see how taskgroups should be extracted from it based on index.