ExLP.ExLaunchPad.ResourceLine C# (CSharp) Method

ResourceLine() private method

private ResourceLine ( string label, string resourceName, float fraction, double minAmount, double maxAmount, double available ) : float
label string
resourceName string
fraction float
minAmount double
maxAmount double
available double
return float
        private float ResourceLine(string label, string resourceName, float fraction, double minAmount, double maxAmount, double available)
        {
            GUILayout.BeginHorizontal();

            // Resource name
            GUILayout.Box(label, Styles.white, GUILayout.Width(120), GUILayout.Height(40));

            // Fill amount
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            // limit slider to 0.5% increments
            if (minAmount == maxAmount) {
            GUILayout.Box("Must be 100%", GUILayout.Width(300), GUILayout.Height(20));
            fraction = 1.0F;
            } else {
            fraction = (float)Math.Round(GUILayout.HorizontalSlider(fraction, 0.0F, 1.0F, Styles.slider, GUI.skin.horizontalSliderThumb, GUILayout.Width(300), GUILayout.Height(20)), 3);
            fraction = (Mathf.Floor(fraction * 200)) / 200;
            GUILayout.Box((fraction * 100).ToString() + "%", Styles.sliderText, GUILayout.Width(300), GUILayout.Height(20));
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();

            double required = minAmount * (1 - fraction)  + maxAmount * fraction;

            // Calculate if we have enough resources to build
            GUIStyle requiredStyle = Styles.green;
            if (available < required) {
            requiredStyle = Styles.red;
            // prevent building unless debug mode is on, or kethane is not
            // installed (kethane is required for resource production)
            uis.canbuildcraft = (!kethane_present || DebugPad);
            }
            // Required and Available
            GUILayout.Box((Math.Round(required, 2)).ToString(), requiredStyle, GUILayout.Width(75), GUILayout.Height(40));
            GUILayout.Box((Math.Round(available, 2)).ToString(), Styles.white, GUILayout.Width(75), GUILayout.Height(40));

            // Flexi space to make sure any unused space is at the right-hand edge
            GUILayout.FlexibleSpace();

            GUILayout.EndHorizontal();

            return fraction;
        }