예제 #1
0
        public void UpdatePanels()
        {
            for (int i = panels.Count - 1; i >= 0; i--)
            {
                StageGroup group = panels.KeyAt(i);

                if (group == null)
                {
                    continue;
                }

                BasicDeltaV_StagePanel panel = panels.At(i);

                if (panel == null)
                {
                    continue;
                }

                panel.Index = group.inverseStageIndex;

                panel.Stage = BasicDeltaV.Instance.GetStage(panel.Index);

                if (panel.Stage == null)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (!BasicDeltaV.Instance.DisplayActive)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (group.Icons.Count <= 0)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (HighLogic.LoadedSceneIsFlight && BasicDeltaV_Settings.Instance.ShowCurrentStageOnly)
                {
                    if (group.inverseStageIndex == StageManager.LastStage)
                    {
                        if (panel.Stage.deltaV <= 0)
                        {
                            panel.ToggleNoDVModules(true);
                        }
                        else
                        {
                            panel.ToggleNoDVModules(false);
                        }
                    }
                    //if (group.inverseStageIndex != StageManager.LastStage)
                    //{
                    //    panel.SetVisible(false);
                    //    continue;
                    //}
                    //else if (panel.Stage.deltaV <= 0)
                    //{
                    //    panel.ToggleNoDVModules(true);
                    //}
                    //else
                    //{
                    //    panel.ToggleNoDVModules(false);
                    //}
                }
                else if (panel.Stage.deltaV <= 0)
                {
                    panel.SetVisible(false);
                    continue;
                }

                if (HighLogic.LoadedSceneIsFlight)
                {
                    bool info = false;

                    int checks = 0;

                    for (int j = group.Icons.Count - 1; j >= 0; j--)
                    {
                        if (checks >= 2)
                        {
                            break;
                        }

                        StageIcon icon = group.Icons[j];

                        if (icon.grouped)
                        {
                            if (icon.expanded)
                            {
                                if (checks >= 1)
                                {
                                    if (icon.groupedIcons[icon.groupedIcons.Count - 1].isDisplayingInfo)
                                    {
                                        info = true;
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    checks += 2;
                                }
                            }
                            else
                            {
                                checks++;
                            }

                            if (!icon.isDisplayingInfoInGroup)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            checks++;

                            if (!icon.isDisplayingInfo)
                            {
                                continue;
                            }
                        }

                        info = true;
                        break;
                    }

                    if (info)
                    {
                        if (!panel.PanelRight)
                        {
                            panel.MovePanel(true);
                        }
                    }
                    else if (panel.PanelRight)
                    {
                        panel.MovePanel(false);
                    }
                }

                panel.SetVisible(true);
            }
        }