internal static void DrawTimeRemaining(Rect rectStart, ARPResource Res)
        {
            Rect rectTemp = new Rect(rectStart)
            {
                y = rectStart.y - 1, height = 18
            };

            if (Res.Rate < 0)
            {
                GUI.Label(rectTemp, Resources.texRateUp, Styles.styleBarRateText);

                Double TimeRemaining = Math.Abs((Res.MaxAmount - Res.Amount) / Res.Rate);
                String strTime       = FormatTime(TimeRemaining);
                GUI.Label(rectTemp, strTime, Styles.styleBarText);
            }
            else if (Res.Rate > 0)
            {
                GUI.Label(rectTemp, Resources.texRateDown, Styles.styleBarRateText);

                Double TimeRemaining = Math.Abs(Res.Amount / Res.Rate);
                String strTime       = FormatTime(TimeRemaining);
                GUI.Label(rectTemp, strTime, Styles.styleBarText);
            }
            else
            {
                GUI.Label(rectTemp, "---", Styles.styleBarText);
            }

            //GUI.Label(rectTemp, string.Format("{0} / {1}", Res.AmountFormatted, Res.MaxAmountFormatted), Styles.styleBarText);
        }
        internal static void DrawUsage(Rect rectStart, ARPResource Res, Boolean ShowRates, Boolean IgnoreInstants = false)
        {
            Rect rectTemp = new Rect(rectStart)
            {
                y = rectStart.y - 1, height = 18
            };

            if (ShowRates && !IgnoreInstants && (rectStart.width < 180))
            {
                rectTemp.width = (rectTemp.width * 2 / 3);
            }

            String strUsageString = String.Format("{0} / {1}", Res.AmountFormatted, Res.MaxAmountFormatted);;

            switch (Res.ResourceConfig.DisplayValueAs)
            {
            case ResourceSettings.DisplayUnitsEnum.Units:                                       break;

            case ResourceSettings.DisplayUnitsEnum.Tonnes:      strUsageString += " T";         break;

            case ResourceSettings.DisplayUnitsEnum.Kilograms:   strUsageString += " Kg";        break;

            case ResourceSettings.DisplayUnitsEnum.Liters:      strUsageString += " L";         break;

            default:                                                                            break;
            }
            GUI.Label(rectTemp, strUsageString, Styles.styleBarText);
        }
Example #3
0
 public AlarmStateChangedEventArgs(ARPResource sender, ARPResource.AlarmStateEnum oldValue, ARPResource.AlarmStateEnum newValue, ARPResource.MonitorStateEnum MonitorState)
 {
     this.sender       = sender;
     this.oldValue     = oldValue;
     this.newValue     = newValue;
     this.MonitorState = MonitorState;
 }
Example #4
0
 //Raise the API event with the aggregated eventargs object
 void API_lstResourcesVessel_OnAlarmStateChanged(ARPResource sender, ARPResource.AlarmStateEnum oldValue, ARPResource.AlarmStateEnum newValue, ARPResource.MonitorStateEnum MonitorState)
 {
     if (onAlarmStateChanged != null)
     {
         onAlarmStateChanged(new AlarmStateChangedEventArgs(sender, oldValue, newValue, MonitorState));
     }
 }
        //internal static Boolean DrawBar(GUIStyle Style, out Rect BarRect, int Width = 0, int Height = 0)
        //{
        //    Boolean blnReturn = false;
        //    List<GUILayoutOption> Options = new List<GUILayoutOption>();
        //    if (Width == 0) Options.Add(GUILayout.ExpandWidth(true));
        //    else Options.Add(GUILayout.Width(Width));
        //    if (Height != 0) Options.Add(GUILayout.Height(Height));

        //    //GUILayout.Label("", Style, Options.ToArray());
        //    if (GUILayout.Button("", Style, Options.ToArray()))
        //        blnReturn = true;
        //    BarRect = GUILayoutUtility.GetLastRect();

        //    return blnReturn;
        //}

        //private void DrawBar(Rect rectStart, int Row, GUIStyle Style)
        //{
        //    GUI.Label(rectStart, "", Style);
        //}

        internal static void DrawBarScaled(Rect rectStart, ARPResource Res, GUIStyle Style, GUIStyle StyleNarrow, float Scale)
        {
            Rect rectTemp = new Rect(rectStart);

            rectTemp.width = (float)Math.Ceiling(rectTemp.width = rectTemp.width * Scale);
            if (rectTemp.width <= 2)
            {
                Style = StyleNarrow;
            }
            GUI.Label(rectTemp, "", Style);
        }
        internal static Boolean DrawResourceBar(Rect rectBar, ARPResource Res, GUIStyle styleBack, GUIStyle styleFront, GUIStyle styleFrontThin, Boolean ShowRates, Boolean Highlight, GUIStyle HighlightStyle)
        {
            Boolean blnReturn         = false;
            Single  fltBarRemainRatio = (float)Res.Amount / (float)Res.MaxAmount;

            //drawhighlight border
            if (Highlight)
            {
                Rect rectHighlight = new Rect(rectBar);
                rectHighlight.x     -= 2; rectHighlight.y -= 2;
                rectHighlight.width += 4; rectHighlight.height += 4;
                GUI.Box(rectHighlight, "", HighlightStyle);
            }


            //blnReturn = Drawing.DrawBar(styleBack, out rectBar, Width);
            blnReturn = GUI.Button(rectBar, "", styleBack);

            if ((rectBar.width * fltBarRemainRatio) > 1)
            {
                Drawing.DrawBarScaled(rectBar, Res, styleFront, styleFrontThin, fltBarRemainRatio);
            }

            if (!KSPAlternateResourcePanel.settings.ShowTimeRem)
            {
                ////add amounts
                Drawing.DrawUsage(rectBar, Res, ShowRates);
                ////add rate
                if (ShowRates)
                {
                    Drawing.DrawRate(rectBar, Res);
                }
            }
            else
            {
                Drawing.DrawTimeRemaining(rectBar, Res);
            }

            return(blnReturn);
        }
        //internal static Double RatePercent;
        internal static void DrawRate(Rect rectStart, ARPResource Res)
        {
            Rect rectTemp = new Rect(rectStart)
            {
                width = rectStart.width - 2, height = 18, y = rectStart.y - 1
            };
            String strLabel = "";

            switch (KSPAlternateResourcePanel.settings.RateDisplayType)
            {
            case Settings.RateDisplayEnum.Default:
                GUI.Label(rectTemp, string.Format("({0})", Res.RateFormatted), Styles.styleBarRateText);
                break;

            case Settings.RateDisplayEnum.LeftRight:
                //Int32 Arrows=1;
                //RatePercent = Math.Abs(Res.Rate) / Res.MaxAmount * 100;
                //if (RatePercent < KSPAlternateResourcePanel.APIInstance.windowDebug.intTest1)
                //    Arrows = 1;
                //else if (RatePercent < KSPAlternateResourcePanel.APIInstance.windowDebug.intTest2)
                //    Arrows = 2;
                //else if (RatePercent < KSPAlternateResourcePanel.APIInstance.windowDebug.intTest2)
                //    Arrows = 3;
                //else
                //    Arrows = 4;

                //if (Res.Rate < 0)
                //    strLabel = new String('>', Arrows);
                //else if (Res.Rate == 0)
                //    strLabel = "---";
                //else
                //    strLabel = new String('<', Arrows);

                if (Res.Rate < 0)
                {
                    strLabel = ">>>";
                }
                else if (Res.Rate == 0)
                {
                    strLabel = "---";
                }
                else
                {
                    strLabel = "<<<";
                }
                GUI.Label(rectTemp, string.Format("{0}", strLabel), Styles.styleBarRateText);
                break;

            case Settings.RateDisplayEnum.LeftRightPlus:
                strLabel = Res.RateFormattedAbs;
                if (Res.Rate < 0)
                {
                    strLabel += " >";
                }
                else if (Res.Rate == 0)
                {
                    strLabel = "---";
                }
                else
                {
                    strLabel = "< " + strLabel;
                }
                GUI.Label(rectTemp, string.Format("{0}", strLabel), Styles.styleBarRateText);
                break;

            case Settings.RateDisplayEnum.UpDown:
            case Settings.RateDisplayEnum.UpDownPlus:
                if (Res.Rate < 0)
                {
                    GUI.Label(rectTemp, Resources.texRateUp, Styles.styleBarRateText);
                }
                else if (Res.Rate > 0)
                {
                    GUI.Label(rectTemp, Resources.texRateDown, Styles.styleBarRateText);
                }

                if (KSPAlternateResourcePanel.settings.RateDisplayType == Settings.RateDisplayEnum.UpDownPlus)
                {
                    rectTemp = new Rect(rectTemp)
                    {
                        width = rectTemp.width - 10
                    };
                    GUI.Label(rectTemp, string.Format("{0}", Res.RateFormattedAbs), Styles.styleBarRateText);
                }
                break;

            default:
                GUI.Label(rectTemp, string.Format("({0})", Res.RateFormatted), Styles.styleBarRateText);
                break;
            }
        }