示例#1
0
        void DrawKerbalInfo(RadioactivityKerbal kerbal)
        {
            GUILayout.BeginHorizontal(groupStyle);


            GUILayout.Label("<b><color=#ffffff>" + kerbal.Name + "</color></b>", labelStyle);

            float tempAreaWidth = 325f;
            float tempBarWidth  = 180f;
            Rect  tempArea      = GUILayoutUtility.GetRect(tempAreaWidth, 40f);
            Rect  barArea       = new Rect(20f, 20f, tempBarWidth, 40f);

            float sickIconPos   = tempBarWidth * RadioactivitySettings.kerbalSicknessThreshold / RadioactivitySettings.kerbalDeathThreshold;
            float tempBarFGSize = (tempBarWidth - 4f) * Mathf.Clamp01((float)kerbal.TotalExposure / RadioactivitySettings.kerbalDeathThreshold);

            // Bars
            GUI.BeginGroup(tempArea);
            GUI.Box(new Rect(0f, 10f, tempBarWidth, 10f), "", barBGStyle);

            // Colorize bar
            if (kerbal.TotalExposure < RadioactivitySettings.kerbalSicknessThreshold)
            {
                GUI.color = Color.green;
            }
            else if (kerbal.TotalExposure < RadioactivitySettings.kerbalDeathThreshold)
            {
                GUI.color = Color.yellow;
            }
            else
            {
                GUI.color = Color.red;
            }

            GUI.Box(new Rect(2f, 11f, tempBarFGSize, 7f), "", barFGStyle);
            GUI.color = Color.white;


            // icons
            GUI.DrawTextureWithTexCoords(new Rect(sickIconPos - iconDims.x / 2f, iconDims.y / 2f - 1f, iconDims.x, iconDims.y), atlas, new Rect(0.0f, 0.0f, 0.5f, 1f));
            GUI.DrawTextureWithTexCoords(new Rect(tempBarWidth - iconDims.x / 2f, iconDims.y / 2f - 1f, iconDims.x, iconDims.y), atlas, new Rect(0.5f, 0.0f, 0.5f, 1f));

            // icon labels
            GUI.Label(new Rect(sickIconPos - iconDims.x, iconDims.y + 4f, iconDims.x * 2f, 20f), String.Format("{0}Sv", Utils.ToSI(RadioactivitySettings.kerbalSicknessThreshold, "F0")), labelStyle);
            GUI.Label(new Rect(tempBarWidth - iconDims.x, iconDims.y + 4f, iconDims.x * 2f, 20f), String.Format("{0}Sv", Utils.ToSI(RadioactivitySettings.kerbalDeathThreshold, "F0")), labelStyle);

            // End labels
            GUI.Label(new Rect(tempBarWidth + 20f, 2f, 120f, 20f), String.Format("<b><color=#ffffff>Current:</color></b> {0}Sv/s", Utils.ToSI(kerbal.CurrentExposure, "F2")), labelStyle);
            GUI.Label(new Rect(tempBarWidth + 20f, 20f, 120f, 20f), String.Format("<b><color=#ffffff>Total:</color></b> {0}Sv", Utils.ToSI(kerbal.TotalExposure, "F2")), labelStyle);

            // GUI.Label(new Rect(20f+tempBarWidth, 30f, 40f, 20f), String.Format("{0:F0} K", meltdownTemp), gui_text);
            GUI.EndGroup();

            GUILayout.EndHorizontal();
        }
        void DrawKerbalInfo(RadioactivityKerbal kerbal)
        {
            GUILayout.BeginHorizontal(groupStyle);

               GUILayout.Label("<b><color=#ffffff>" + kerbal.Name + "</color></b>", labelStyle);

               float tempAreaWidth = 325f;
               float tempBarWidth = 180f;
               Rect tempArea = GUILayoutUtility.GetRect(tempAreaWidth, 40f);
               Rect barArea = new Rect(20f, 20f, tempBarWidth, 40f);

               float sickIconPos = tempBarWidth * RadioactivitySettings.kerbalSicknessThreshold/RadioactivitySettings.kerbalDeathThreshold;
               float tempBarFGSize = (tempBarWidth-4f) * Mathf.Clamp01((float)kerbal.TotalExposure / RadioactivitySettings.kerbalDeathThreshold);

               // Bars
               GUI.BeginGroup(tempArea);
               GUI.Box(new Rect(0f, 10f, tempBarWidth, 10f), "", barBGStyle);

               // Colorize bar
               if (kerbal.TotalExposure < RadioactivitySettings.kerbalSicknessThreshold)
              GUI.color = Color.green;
               else if (kerbal.TotalExposure < RadioactivitySettings.kerbalDeathThreshold)
              GUI.color = Color.yellow;
               else
              GUI.color = Color.red;

               GUI.Box(new Rect(2f, 11f, tempBarFGSize, 7f), "", barFGStyle);
               GUI.color = Color.white;

               // icons
               GUI.DrawTextureWithTexCoords(new Rect(sickIconPos - iconDims.x / 2f,  iconDims.y / 2f-1f, iconDims.x, iconDims.y), atlas, new Rect(0.0f,0.0f,0.5f,1f));
               GUI.DrawTextureWithTexCoords(new Rect(tempBarWidth - iconDims.x / 2f,  iconDims.y / 2f-1f, iconDims.x, iconDims.y), atlas, new Rect(0.5f,0.0f,0.5f,1f));

               // icon labels
               GUI.Label(new Rect(sickIconPos - iconDims.x, iconDims.y +4f, iconDims.x*2f, 20f), String.Format("{0}Sv", Utils.ToSI(RadioactivitySettings.kerbalSicknessThreshold,"F0")), labelStyle);
               GUI.Label(new Rect(tempBarWidth - iconDims.x, iconDims.y +4f, iconDims.x*2f, 20f), String.Format("{0}Sv", Utils.ToSI(RadioactivitySettings.kerbalDeathThreshold,"F0")), labelStyle);

               // End labels
               GUI.Label(new Rect(tempBarWidth + 20f, 2f, 120f, 20f), String.Format("<b><color=#ffffff>Current:</color></b> {0}Sv/s", Utils.ToSI(kerbal.CurrentExposure, "F2")), labelStyle);
               GUI.Label(new Rect(tempBarWidth + 20f, 20f, 120f, 20f), String.Format("<b><color=#ffffff>Total:</color></b> {0}Sv", Utils.ToSI(kerbal.TotalExposure, "F2")), labelStyle);

               // GUI.Label(new Rect(20f+tempBarWidth, 30f, 40f, 20f), String.Format("{0:F0} K", meltdownTemp), gui_text);
               GUI.EndGroup();

               GUILayout.EndHorizontal();
        }