/// <summary> /// Remove references to local game objects. /// </summary> public void Cleanup() { ((TreeModel)tvwEquip.Model).Nodes.Clear(); this.game = null; this.selectedVehicle = null; this.selectedToe = null; }
public override Toe.Vector2 GetTextureCoordinate(Face face, Toe.Vector3 point) { Vector2 ret = new Vector2(); float XScale = face.Scale.X == 0.0f ? 1.0f : face.Scale.X; float YScale = face.Scale.Y == 0.0f ? 1.0f : face.Scale.Y; Vector3 scaledAxisX = Vector3.Divide(face.XTexVector.Value, XScale); Vector3 scaledAxisY = Vector3.Divide(face.YTexVector.Value, YScale); ret.X = (Vector3.Dot(point, scaledAxisX) + face.Offset.X) / 32.0f; ret.Y = (Vector3.Dot(point, scaledAxisY) + face.Offset.Y) / 32.0f; return ret; }
/// <summary> /// Gets the tree node that is associated with the given Toe. /// </summary> /// <param name="toe">The Toe to look for.</param> /// <returns>The node if found, otherwise null.</returns> private TreeNodeAdv FindEquipNode(Toe toe) { foreach (TreeNodeAdv countryNode in tvwEquip.Root.Nodes) { foreach (TreeNodeAdv toeNode in countryNode.Nodes) { if (((EquipNode)toeNode.Tag).Toe == toe) { return(toeNode); } } } return(null); }
// update new vehicle info private void tvwEquip_SelectionChanged(object sender, EventArgs e) { // get selected node if (tvwEquip.SelectedNode != null) { EquipNode node = (EquipNode)tvwEquip.SelectedNode.Tag; this.selectedVehicle = node.Vehicle; this.selectedToe = this.selectedVehicle == null ? null : ((EquipNode)node.Parent.Parent).Toe; } else { this.selectedVehicle = null; this.selectedToe = null; } // update controls UpdateVehicleInfo(); }
/// <summary> /// Makes the Equipment widget visible by making sure it's expanded, scrolling it into /// view, and expanding the relevant tree nodes to select the given toe. /// </summary> /// <seealso cref="tmrReveal_Tick"/> /// <param name="arg">The Toe to select.</param> public void Reveal(object arg) { Toe toe = arg as Toe; if (toe == null) { return; } if (tmrReveal.Enabled) { return; // another Reveal() in progress } TreeNodeAdv node = FindEquipNode(toe); if (node == null) { return; // not found; } RestoreTree(); node.IsExpanded = true; tvwEquip.ScrollToTop(node); /// test tvwEquip.SelectedNode = node; Expando expEquipment = (Expando)this.Parent; if (expEquipment.Collapsed) { expEquipment.Collapsed = false; // animate tmrReveal.Start(); // scroll into view after animation } else { if (expEquipment.TaskPane != null) { expEquipment.TaskPane.ScrollControlIntoView(expEquipment); } } }
/// <summary> /// Create a new Toe node. /// </summary> public EquipNode(Toe toe) : base(toe.Name) { this.toe = toe; }
/// <summary> /// Create a new Vehicle node. /// </summary> public EquipNode(Toe toe, Vehicle vehicle) : base(vehicle.Name) { this.vehicle = vehicle; this.cycles = toe[vehicle].Cycle; }