//info labels void HangarInfo() { GUILayout.BeginVertical(); GUILayout.Label("Vessel Volume: " + Utils.formatVolume(vessel_metric.volume), GUILayout.ExpandWidth(true)); GUILayout.Label("Vessel Dimensions: " + Utils.formatDimensions(vessel_metric.size), GUILayout.ExpandWidth(true)); GUILayout.Label("Hangar Dimensions: " + Utils.formatDimensions(selected_hangar.hangar_metric.size), GUILayout.ExpandWidth(true)); GUILayout.Label("Hangar volume: " + Utils.formatVolume(selected_hangar.hangar_metric.volume), GUILayout.ExpandWidth(true)); GUILayout.Label(string.Format("Used volume: {0}, {1:F1}%", Utils.formatVolume(selected_hangar.used_volume), selected_hangar.used_volume_frac * 100), Styles.fracStyle(1 - selected_hangar.used_volume_frac), GUILayout.ExpandWidth(true)); GUILayout.Label(string.Format("Mass: {0} stored, {1} total", Utils.formatMass(selected_hangar.vessels_mass), Utils.formatMass(selected_hangar.vessel.GetTotalMass())), GUILayout.ExpandWidth(true)); GUILayout.Label("Vessels docked: " + selected_hangar.numVessels(), GUILayout.ExpandWidth(true)); GUILayout.Label(string.Format("Vessel crew: {0}/{1}", selected_hangar.vessel.GetCrewCount(), selected_hangar.vessel.GetCrewCapacity()), GUILayout.ExpandWidth(true)); GUILayout.EndVertical(); }
static float ResourceLine(string label, float fraction, double pool, double minAmount, double maxAmount, double capacity) { GUILayout.BeginHorizontal(); // Resource name GUILayout.Box(label, Styles.white, GUILayout.Width(120), GUILayout.Height(40)); // Fill amount // limit slider to 0.5% increments GUILayout.BeginVertical(); fraction = GUILayout.HorizontalSlider(fraction, 0.0F, 1.0F, Styles.slider, GUI.skin.horizontalSliderThumb, GUILayout.Width(300), GUILayout.Height(20)); fraction = (float)Math.Round(fraction, 3); fraction = (Mathf.Floor(fraction * 200)) / 200; if (fraction * maxAmount < minAmount) { fraction = (float)(minAmount / maxAmount); } GUILayout.Box((fraction * 100) + "%", Styles.slider_text, GUILayout.Width(300), GUILayout.Height(20)); GUILayout.EndVertical(); // amount and capacity GUILayout.Box((Math.Round(pool - fraction * maxAmount, 2)).ToString(), Styles.white, GUILayout.Width(75), GUILayout.Height(40)); GUILayout.Box((Math.Round(fraction * maxAmount, 2)).ToString(), Styles.fracStyle(fraction), GUILayout.Width(75), GUILayout.Height(40)); GUILayout.Box((Math.Round(capacity, 2)).ToString(), Styles.yellow, GUILayout.Width(75), GUILayout.Height(40)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return(fraction); }
void hangar_content_editor(int windowID) { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); //VAB / SPH / SubAss selection GUILayout.FlexibleSpace(); for (var T = VesselType.VAB; T <= VesselType.SubAssembly; T++) { if (GUILayout.Toggle(vessel_type == T, T.ToString(), GUILayout.Width(100))) { vessel_type = T; } } GUILayout.FlexibleSpace(); //Vessel selector if (GUILayout.Button("Select Vessel", Styles.normal_button, GUILayout.ExpandWidth(true))) { Rect sWindowPos = new Rect(eWindowPos) { height = 500 }; var diff = HighLogic.CurrentGame.Parameters.Difficulty; bool stock = diff.AllowStockVessels; if (vessel_type == VesselType.SubAssembly) { diff.AllowStockVessels = false; } vessel_selector = new CraftBrowser(sWindowPos, vessel_dirs[(int)vessel_type], HighLogic.SaveFolder, "Select a ship to store", vessel_selected, selection_canceled, HighLogic.Skin, EditorLogic.ShipFileImage, true); diff.AllowStockVessels = stock; } GUILayout.EndHorizontal(); //hangar info float used_frac = used_volume / hangar_metric.volume; GUILayout.Label(string.Format("Used Volume: {0} {1:F1}%", Utils.formatVolume(used_volume), used_frac * 100f), Styles.fracStyle(1 - used_frac), GUILayout.ExpandWidth(true)); //hangar contents List <PackedConstruct> constructs = packed_constructs.Values; constructs.Sort((a, b) => a.name.CompareTo(b.name)); scroll_view = GUILayout.BeginScrollView(scroll_view, GUILayout.Height(200), GUILayout.Width(400)); GUILayout.BeginVertical(); foreach (PackedConstruct pc in constructs) { GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("{0}: {1} Cost: {2:F1}", pc.name, Utils.formatMass(pc.metric.mass), pc.metric.cost), Styles.label, GUILayout.ExpandWidth(true)); if (GUILayout.Button("X", Styles.red_button, GUILayout.Width(25))) { remove_construct(pc); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); if (GUILayout.Button("Clear", Styles.red_button, GUILayout.ExpandWidth(true))) { clear_constructs(); } if (GUILayout.Button("Close", Styles.normal_button, GUILayout.ExpandWidth(true))) { Utils.LockIfMouseOver(eLock, eWindowPos, false); editing_hangar = false; } GUILayout.EndVertical(); GUI.DragWindow(new Rect(0, 0, 500, 20)); }
public static void UsedVolumeLabel(float UsedVolume, float UsedVolumeFrac, string label = "Used Volume") { GUILayout.Label(string.Format("{0}: {1} {2:P1}", label, Utils.formatVolume(UsedVolume), UsedVolumeFrac), Styles.fracStyle(1 - UsedVolumeFrac), GUILayout.ExpandWidth(true)); }