void create_fields()
 {
     TCA.InitModuleFields(this);
     AllWindows.ForEach(w => w.Init(TCA));
     foreach (var fi in AllTabFields)
     {
         var tab = TCA.CreateComponent(fi.FieldType) as ControlTab;
         if (tab == null)
         {
             continue;
         }
         tab.Init();
         if (!tab.Valid)
         {
             continue;
         }
         var info = fi.GetCustomAttributes(typeof(TabInfo), false).FirstOrDefault() as TabInfo;
         if (info != null)
         {
             tab.SetupTab(info);
         }
         fi.SetValue(this, tab);
         AllTabs.Add(tab);
     }
     AllTabs.Sort((a, b) => a.Index.CompareTo(b.Index));
     if (CFG != null && CFG.ActiveTab < AllTabs.Count - 1)
     {
         ActiveTab = AllTabs[CFG.ActiveTab];
     }
     else
     {
         ActiveTab = AllTabs[0];
     }
 }
Пример #2
0
 public override void Awake()
 {
     base.Awake();
     AllTabFields = ControlTab.GetTabFields(GetType());
     AllWindows   = subwindows.Where(sw => sw is ControlWindow).Cast <ControlWindow>().ToList();
     GameEvents.onGameStateSave.Add(save_config);
     GameEvents.onVesselChange.Add(onVesselChange);
     NavigationTab.OnAwake();
 }
        #pragma warning restore 169

        #region Initialization
        public override void Awake()
        {
            base.Awake();
            AllTabFields = ControlTab.GetTabFields(GetType());
            AllPanels.Add(VFlight_Panel);
            AllPanels.Add(Attitude_Panel);
            AllPanels.Add(Maneuver_Panel);
            AllPanels.Add(Status_Panel);
            AllPanels.Add(Info_Panel);
            GameEvents.onVesselChange.Add(onVesselChange);
            GameEvents.onVesselDestroy.Add(onVesselDestroy);
            NavigationTab.OnAwake();
        }
 void DrawMainWindow(int windowID)
 {
     //help button
     if (GUI.Button(new Rect(0, 0f, 20f, 18f),
                    Collapsed? uncollapse_button : collapse_button, Styles.label))
     {
         Collapsed = !Collapsed;
         update_collapsed_rect();
     }
     if (GUI.Button(new Rect(WindowPos.width - 20f, 0f, 20f, 18f),
                    new GUIContent("?", "Help"), Styles.label))
     {
         TCAManual.ToggleInstance();
     }
     //vessel switching
     if (HaveRemoteControl)
     {
         if (GUI.Button(new Rect(22, 0f, 20f, 18f), prev_vessel_button, Styles.label))
         {
             switch_vessel(FlightGlobals.Vessels.Next);
         }
         if (RemoteControl &&
             GUI.Button(new Rect(44, 0f, 20f, 18f), active_vessel_button, Styles.label))
         {
             onVesselChange(ActiveVesselTCA.vessel);
         }
         if (RemoteControl &&
             GUI.Button(new Rect(WindowPos.width - 64f, 0f, 20f, 18f), switch_vessel_button, Styles.label))
         {
             FlightGlobals.SetActiveVessel(vessel);
         }
         if (GUI.Button(new Rect(WindowPos.width - 42f, 0f, 20f, 18f), next_vessel_button, Styles.label))
         {
             switch_vessel(FlightGlobals.Vessels.Prev);
         }
     }
     if (TCA.IsControllable)
     {
         GUILayout.BeginVertical();
         GUILayout.BeginHorizontal();
         //tca toggle
         var enabled_style = Styles.inactive_button;
         if (CFG.Enabled)
         {
             enabled_style = Styles.enabled_button;
         }
         else if (!VSL.LandedOrSplashed)
         {
             if (EnabledBlinker.On)
             {
                 enabled_style = Styles.danger_button;
             }
             Status(0.1, "red", "<b>TCA is disabled</b>");
         }
         if (GUILayout.Button("Enabled", enabled_style, GUILayout.Width(70)))
         {
             TCA.ToggleTCA();
         }
                         #if DEBUG
         if (GUILayout.Button("ReGlobals", Styles.active_button, GUILayout.ExpandWidth(false)))
         {
             Globals.Load();
             Styles.ConfigureButtons();
             TCA.OnReloadGlobals();
         }
                         #endif
         //squad mode switch
         if (SQD != null)
         {
             SQD.Draw();
         }
         GUILayout.FlexibleSpace();
         StatusLabel();
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         GUILayout.BeginVertical(Styles.white, GUILayout.MinHeight(ControlsHeight), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true));
         if (ActiveTab != null)
         {
             ActiveTab.Draw();
         }
         GUILayout.EndVertical();
         tabs_scroll = GUILayout.BeginScrollView(tabs_scroll, Styles.white, GUILayout.ExpandHeight(true), GUILayout.Width(55));
         for (int i = 0, AllTabsCount = AllTabs.Count; i < AllTabsCount; i++)
         {
             var t = AllTabs[i];
             if (t.DrawTabButton(t == ActiveTab))
             {
                 ActiveTab     = t;
                 CFG.ActiveTab = i;
             }
         }
         GUILayout.EndScrollView();
         GUILayout.EndHorizontal();
         DrawStatusMessage();
         GUILayout.EndVertical();
     }
     else
     {
         GUILayout.BeginVertical();
         GUILayout.BeginHorizontal();
         VSL.Info.Draw();
         GUILayout.FlexibleSpace();
         StatusLabel();
         GUILayout.EndHorizontal();
         GUILayout.Label("Vessel is Uncontrollable", Styles.label, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
         DrawStatusMessage();
         GUILayout.EndVertical();
     }
     TooltipsAndDragWindow();
 }