예제 #1
0
 //build dropdown list of all hangars in the vessel
 void BuildHangarList(Vessel vsl)
 {
     //reset state
     if (selected_hangar != null)
     {
         selected_hangar.part.SetHighlightDefault();
     }
     hangars.Clear();
     hangar_list.Items = new List <string>();
     selected_hangar   = null;
     //check the vessel
     if (vsl == null)
     {
         return;
     }
     //build new list
     foreach (var p in vsl.Parts)
     {
         hangars.AddRange(p.Modules.OfType <Hangar>().Where(h => h.enabled));
     }
     if (hangars.Count > 0)
     {
         selected_hangar = hangars.Find(h => h.part.flightID == hangar_id);
         if (selected_hangar == null)
         {
             selected_hangar = hangars[0];
         }
         var hangar_names = new List <string>();
         for (int i = 0; i < hangars.Count; i++)
         {
             string h_name = hangars[i].HangarName == default(string) ? "Unnamed Hangar" : hangars[i].HangarName;
             hangar_names.Add(string.Format("{0} {1}", i + 1, h_name));
         }
         hangar_list.Items = hangar_names;
         hangar_list.SelectItem(hangars.IndexOf(selected_hangar));
     }
 }
예제 #2
0
 public static void SelectHangar(Hangar hangar)
 {
     instance.Select_Hangar(hangar);
 }