private void btnLoad_Click(object sender, EventArgs e) { OpenFileDialog od = new OpenFileDialog(); od.Filter = "Cutscene save (*.xml.save)|*.xml.save|All files (*.*)|*.*"; if (od.ShowDialog() == System.Windows.Forms.DialogResult.OK) { XDocument d = XDocument.Load(od.FileName); Cutscene cs = Cutscene.Deserialize(d.Element("root")); if (cs == null) { MessageBox.Show("Error reading file!"); return; } myCutscene = cs; cbFlights.Items.Clear(); foreach (Flight f in cs.Flights) { cbFlights.Items.Add(f); } selectedFlight = null; selectedFlightPoint = null; lvCut.Items.Clear(); cbFlights.SelectedItem = cbFlights.Items[0]; } }
public void ShowInState(LuaState luaState, Control parent) { this.Location = new Point(parent.Location.X + parent.Width / 2 - Width / 2, parent.Location.Y + parent.Height / 2 - Height / 2); this.Show(); if (this.LS != luaState) { this.LS = luaState; luaState.OnStateRemoved += luaState_OnStateRemoved; LS.EvaluateLua(@" Cutscene_Preview_Finished = function() Camera.SetControlMode(1); end Cutscene_Preview_Cancel = function() Camera.SetControlMode(1); end"); myCutscene = new Cutscene(); lvCut.Items.Clear(); cbFlights.Items.Clear(); cbFlights_SelectedIndexChanged(gbPreviewCutscene, new EventArgs()); selectedFlight = null; selectedFlightPoint = null; freeFlightActive = false; } }
private void lvCut_MouseDoubleClick(object sender, MouseEventArgs e) { if (selectedFlightPoint == null) { return; } if (e.Location.X < chJumpTo.Width) { if (!freeFlightActive) { MessageBox.Show("Please activate free flight mode!"); return; } Camera.Point3D = selectedFlightPoint.CamPos.Position; Camera.PitchAngle = selectedFlightPoint.CamPitch; Camera.YawAngle = selectedFlightPoint.CamYaw; Camera.WriteToMemory(); } else if (e.Location.X < (chJumpTo.Width + chProperties.Width)) { int ind = selectedFlight.FlightPoints.IndexOf(selectedFlightPoint) - 1; FlightPoint prev = null; if (ind >= 0 && ind < selectedFlight.FlightPoints.Count) { prev = selectedFlight.FlightPoints[ind]; } propertyWindow.ShowProperties(selectedFlightPoint, prev); } else if (e.Location.X < (chLuaCall.Width + chJumpTo.Width + chProperties.Width)) { selectedFlightPoint.LuaCallback = Interaction.InputBox("Lua Callback Function Name", "S5Cutscene Editor", selectedFlightPoint.LuaCallback); lvCut.SelectedItems[0].SubItems[2].Text = selectedFlightPoint.LuaCallback; } }
public void ShowProperties(FlightPoint fp, FlightPoint prev) { curFlightPoint = fp; this.prev = prev; nudSpeed.Value = (decimal)curFlightPoint.Speed; cbLookAtActive.Checked = curFlightPoint.LookAtPos.Active; cbCamPosActive.Checked = curFlightPoint.CamPos.Active; cbUseOnlyXY.Checked = curFlightPoint.SpeedUseOnlyXY; updateLDist(); this.ShowDialog(); }
public static Flight Deserialize(XElement el) { el = el.Element("Flight"); Flight r = new Flight(el.Element("name").Value); foreach (XElement e in el.Element("FlightPoints").Elements("FlightPoint")) { r.FlightPoints.Add(FlightPoint.Deserialize(e, r.GetNextPointID())); } return(r); }
private void btnReplace_Click(object sender, EventArgs e) { FlightPoint newPoint = new FlightPoint(Camera, selectedFlight.GetNextPointID()); newPoint.LuaCallback = selectedFlightPoint.LuaCallback; newPoint.Speed = selectedFlightPoint.Speed; newPoint.SpeedUseOnlyXY = selectedFlightPoint.SpeedUseOnlyXY; int oldIndex = selectedFlight.FlightPoints.IndexOf(selectedFlightPoint); selectedFlight.FlightPoints[oldIndex] = newPoint; lvCut.SelectedItems[0].Tag = newPoint; lvCut.SelectedItems[0].SubItems[0].Text = newPoint.ID.ToString(); selectedFlightPoint = newPoint; }
public float getDistanceRelativeTo(FlightPoint p) { float dx = p.CamPos.Position.X - this.CamPos.Position.X; float dy = p.CamPos.Position.Y - this.CamPos.Position.Y; float dz = p.CamPos.Position.Z - this.CamPos.Position.Z; float fullDistance = 0; if (this.SpeedUseOnlyXY) { fullDistance = (float)Math.Sqrt(dx * dx + dy * dy); } else { fullDistance = (float)Math.Sqrt(dx * dx + dy * dy + dz * dz); } return(fullDistance); }
public static FlightPoint Deserialize(XElement el, int id) { el = el.Element("FlightPoint"); FlightPoint r = new FlightPoint(); r.CamPos = Waypoint.Deserialize(el.Element("CamPos")); r.LookAtPos = Waypoint.Deserialize(el.Element("LookAt")); r.LuaCallback = el.Element("callback").Value; r.CamPitch = float.Parse(el.Element("pitch").Value, CultureInfo.InvariantCulture); r.CamYaw = float.Parse(el.Element("yaw").Value, CultureInfo.InvariantCulture); r.Speed = float.Parse(el.Element("speed").Value, CultureInfo.InvariantCulture); if (el.Element("speedOnlyXY") != null) { r.SpeedUseOnlyXY = el.Element("speedOnlyXY").Value == "True"; } r.ID = id; return(r); }
private void InsertPointAt(int index) { if (!freeFlightActive) { MessageBox.Show("Please activate free flight mode!"); return; } FlightPoint newFlightPoint = new FlightPoint(Camera, selectedFlight.GetNextPointID()); ListViewItem point = new ListViewItem(new string[] { newFlightPoint.ID.ToString(), "Edit", newFlightPoint.LuaCallback }); point.Tag = newFlightPoint; lvCut.Items.Insert(index, point); selectedFlight.FlightPoints.Insert(index, newFlightPoint); }
private void lvCut_SelectedIndexChanged(object sender, EventArgs e) { selectedFlightPoint = lvCut.SelectedItems.Count > 0 ? lvCut.SelectedItems[0].Tag as FlightPoint : null; btnPlaySelected.Enabled = (selectedFlightPoint != null && lvCut.SelectedIndices[0] != lvCut.Items.Count - 1); btnReplace.Enabled = selectedFlightPoint != null; }