public void ClearSelection() { reset_highlight(lhs); reset_highlight(rhs); lhs = rhs = null; lhs_selected = null; if(storages != null) storages.ForEach(reset_highlight); }
static void vessels_list(HangarStorage storage, ref Vector2 scroll, ref PackedVessel selected, bool is_lhs = true) { if (storage == null) { return; } scroll = GUILayout.BeginScrollView(scroll, GUILayout.Height(scroll_height), GUILayout.Width(scroll_width)); GUILayout.BeginVertical(); List <PackedVessel> vessels = storage.GetVessels(); vessels.Sort((a, b) => a.name.CompareTo(b.name)); foreach (var v in vessels) { GUILayout.BeginHorizontal(); if (is_lhs) { HangarGUI.PackedVesselLabel(v); } if (GUILayout.Button(is_lhs? ">>" : "<<", Styles.normal_button, GUILayout.ExpandWidth(true))) { selected = v; } if (!is_lhs) { HangarGUI.PackedVesselLabel(v); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); }
protected override void on_storage_remove(HangarStorage old_storage) { base.on_storage_remove(old_storage); old_storage.OnVesselStored -= on_ship_stored; old_storage.OnVesselRemoved -= on_ship_removed; old_storage.OnVesselUnfittedAdded -= on_ship_stored; old_storage.OnVesselUnfittedRemoved -= on_ship_removed; old_storage.OnStorageEmpty -= on_storage_empty; }
protected override void on_storage_add(HangarStorage new_storage) { base.on_storage_add(new_storage); new_storage.OnVesselStored += on_ship_stored; new_storage.OnVesselRemoved += on_ship_removed; new_storage.OnVesselUnfittedAdded += on_ship_stored; new_storage.OnVesselUnfittedRemoved += on_ship_removed; new_storage.OnStorageEmpty += on_storage_empty; }
public void ClearSelection() { reset_highlight(lhs); reset_highlight(rhs); lhs = rhs = null; lhs_selected = null; if (storages != null) { storages.ForEach(reset_highlight); } }
public bool TryTransferTo(PackedVessel vsl, HangarStorage other) { if (!CanTransferTo(vsl, other)) { Utils.Message("Unable to move \"{0}\" from \"{1}\" to \"{2}\"", vsl.name, this.Title(), other.Title()); return(false); } if (!RemoveVessel(vsl)) { this.Log("TryTransferTo: trying to remove a PackedVessel that is not present."); return(false); } vsl.SpawnRotation = other.SpawnManager.GetOptimalRotation(vsl.size).eulerAngles; other.StoreVessel(vsl); return(true); }
static void vessels_list(HangarStorage storage, ref Vector2 scroll, ref PackedVessel selected, bool is_lhs=true) { if(storage == null) return; scroll = GUILayout.BeginScrollView(scroll, GUILayout.Height(scroll_height), GUILayout.Width(scroll_width)); GUILayout.BeginVertical(); List<PackedVessel> vessels = storage.GetAllVesselsBase(); vessels.Sort((a, b) => a.name.CompareTo(b.name)); foreach(var v in vessels) { GUILayout.BeginHorizontal(); if(is_lhs) HangarGUI.PackedVesselLabel(v); if(GUILayout.Button(is_lhs? ">>" : "<<", Styles.normal_button, GUILayout.ExpandWidth(true))) selected = v; if(!is_lhs) HangarGUI.PackedVesselLabel(v); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); }
void parts_list(ref Vector2 scroll, ref HangarStorage selected, bool is_lhs = true) { if (storages == null || storages.Count == 0) { return; } scroll = GUILayout.BeginScrollView(scroll, GUILayout.Height(scroll_height), GUILayout.Width(scroll_width)); Color selected_color = is_lhs? XKCDColors.Cyan : XKCDColors.Magenta; GUIStyle selected_style = is_lhs? Styles.sel1_button : Styles.sel2_button; GUILayout.BeginVertical(); foreach (var s in storages) { GUIStyle style = (s == selected)? selected_style : Styles.normal_button; if (!is_lhs && s == lhs || is_lhs && s == rhs) { GUILayout.Label(s.Title(), Styles.inactive, GUILayout.ExpandWidth(true)); } else if (GUILayout.Button(s.Title(), style, GUILayout.ExpandWidth(true))) { if (selected != null) { reset_highlight(selected); } selected = s == selected ? null : s; } } if (selected != null) { selected.part.highlightType = Part.HighlightType.AlwaysOn; selected.part.SetHighlight(true, false); selected.part.SetHighlightColor(selected_color); } GUILayout.EndVertical(); GUILayout.EndScrollView(); }
public bool TryTransferTo(PackedVessel vsl, HangarStorage other) { if(!CanTransferTo(vsl, other)) { ScreenMessager.showMessage("Unable to move \"{0}\" from \"{1}\" to \"{2}\"", vsl.name, this.Title(), other.Title()); return false; } if(!RemoveVessel(vsl)) { this.Log("TryTransferTo: trying to remove a PackedVessel that is not present."); return false; } other.StoreVessel(vsl); return true; }
void parts_list(ref Vector2 scroll, ref HangarStorage selected, bool is_lhs=true) { if(storages == null || storages.Count == 0) return; scroll = GUILayout.BeginScrollView(scroll, GUILayout.Height(scroll_height), GUILayout.Width(scroll_width)); Color selected_color = is_lhs? XKCDColors.Cyan : XKCDColors.Magenta; GUIStyle selected_style = is_lhs? Styles.cyan_button : Styles.magenta_button; GUILayout.BeginVertical(); foreach(var s in storages) { GUIStyle style = (s == selected)? selected_style : Styles.normal_button; if(!is_lhs && s == lhs || is_lhs && s == rhs) GUILayout.Label(s.Title(), Styles.grey, GUILayout.ExpandWidth(true)); else if(GUILayout.Button(s.Title(), style, GUILayout.ExpandWidth(true))) { if(selected != null) reset_highlight(selected); selected = s == selected ? null : s; } } if(selected != null) { selected.part.highlightType = Part.HighlightType.AlwaysOn; selected.part.SetHighlight(true, false); selected.part.SetHighlightColor(selected_color); } GUILayout.EndVertical(); GUILayout.EndScrollView(); }
public static Color UsedVolumeColor(HangarStorage s) { var frac = s.UsedVolumeFrac; return(new Color(frac, 1f - frac, 0)); }