public void ControlGUI() { GUILayout.BeginHorizontal(); tank_resource_gui(); GUILayout.FlexibleSpace(); GUILayout.Label(Utils.formatVolume(tank.Volume), Styles.boxed_label, GUILayout.ExpandWidth(true)); var usage = tank.Usage; GUILayout.Label("Filled: " + usage.ToString("P1"), Styles.fracStyle(usage), GUILayout.Width(95)); GUILayout.EndHorizontal(); }
static float ResourceLine(string label, float fraction, ResourceManifest res) { GUILayout.BeginHorizontal(); // Resource name GUILayout.Box(label, Styles.white, GUILayout.Width(120), GUILayout.Height(res_line_height)); var rhs = fraction * res.maxAmount; var lhs = res.pool - rhs; // lhs amount/capacity GUILayout.Box(Utils.formatBigValue((float)res.host_capacity, "u"), Styles.yellow, GUILayout.Width(60), GUILayout.Height(res_line_height)); GUILayout.Box(Utils.formatBigValue((float)lhs, "u"), Styles.fracStyle((float)(lhs / res.host_capacity)), GUILayout.Width(60), GUILayout.Height(res_line_height)); // Fill amount GUILayout.BeginVertical(); GUILayout.Box(fraction.ToString("P1"), Styles.slider_text, GUILayout.Width(200), GUILayout.Height(20)); var frac = GUILayout.HorizontalSlider(fraction, 0.0F, 1.0F, Styles.slider, GUI.skin.horizontalSliderThumb, GUILayout.Width(200), GUILayout.Height(20)); if (fraction * res.maxAmount < res.minAmount) { frac = (float)(res.minAmount / res.maxAmount); } GUILayout.EndVertical(); // rhs amount and capacity GUILayout.Box(Utils.formatBigValue((float)(rhs), "u"), Styles.fracStyle((float)(rhs / res.capacity)), GUILayout.Width(60), GUILayout.Height(res_line_height)); GUILayout.Box(Utils.formatBigValue((float)res.capacity, "u"), Styles.yellow, GUILayout.Width(60), GUILayout.Height(res_line_height)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return(frac); }
public void ManageGUI() { GUILayout.BeginHorizontal(); tank_type_gui(); tank_resource_gui(); GUILayout.FlexibleSpace(); if (HighLogic.LoadedSceneIsEditor && manager.Volume > 0) { if (edit) { if (VolumeField.Draw("m3", true, manager.Volume / 20, "F2")) { var max_volume = tank.Volume + manager.Volume - manager.TotalVolume; if (VolumeField.Value > max_volume) { VolumeField.Value = max_volume; } if (VolumeField.IsSet) { tank.Volume = VolumeField.Value; tank.UpdateMaxAmount(true); manager.total_volume = -1; edit = false; } } } else { edit |= GUILayout.Button(new GUIContent(Utils.formatVolume(tank.Volume), "Edit tank volume"), Styles.add_button, GUILayout.ExpandWidth(true)); } } else { GUILayout.Label(Utils.formatVolume(tank.Volume), Styles.boxed_label, GUILayout.ExpandWidth(true)); } if (!edit) { var usage = tank.Usage; GUILayout.Label("Filled: " + usage.ToString("P1"), Styles.fracStyle(usage), GUILayout.Width(95)); if (HighLogic.LoadedSceneIsEditor) { if (GUILayout.Button(new GUIContent("F", "Fill the tank with the resource"), Styles.add_button, GUILayout.Width(20))) { tank.Amount = tank.MaxAmount; } if (GUILayout.Button(new GUIContent("E", "Empty the tank"), Styles.active_button, GUILayout.Width(20))) { tank.Amount = 0; } } if (manager.AddRemoveEnabled) { if (GUILayout.Button(new GUIContent("X", "Delete the tank"), Styles.danger_button, GUILayout.Width(20))) { if (HighLogic.LoadedSceneIsEditor) { tank.Amount = 0; } manager.remove_tank(tank); manager.part.UpdatePartMenu(); } } } GUILayout.EndHorizontal(); }