Added seek ability to CutsceneForm player

This commit is contained in:
dexy 2020-03-06 21:24:18 +11:00
parent 56902d4f8b
commit 59301c5b51
2 changed files with 51 additions and 1 deletions

View File

@ -130,11 +130,14 @@
this.TimeTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.TimeTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.TimeTrackBar.AutoSize = false; this.TimeTrackBar.AutoSize = false;
this.TimeTrackBar.LargeChange = 0;
this.TimeTrackBar.Location = new System.Drawing.Point(91, 34); this.TimeTrackBar.Location = new System.Drawing.Point(91, 34);
this.TimeTrackBar.Maximum = 100; this.TimeTrackBar.Maximum = 100;
this.TimeTrackBar.Name = "TimeTrackBar"; this.TimeTrackBar.Name = "TimeTrackBar";
this.TimeTrackBar.Size = new System.Drawing.Size(509, 30); this.TimeTrackBar.Size = new System.Drawing.Size(509, 30);
this.TimeTrackBar.TabIndex = 7; this.TimeTrackBar.TabIndex = 7;
this.TimeTrackBar.Scroll += new System.EventHandler(this.TimeTrackBar_Scroll);
this.TimeTrackBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TimeTrackBar_MouseUp);
// //
// TimeLabel // TimeLabel
// //

View File

@ -23,6 +23,7 @@ namespace CodeWalker.World
private bool AnimateCamera = true; private bool AnimateCamera = true;
private bool Playing = false; private bool Playing = false;
private bool PositionScrolled = false;
class CutsceneDropdownItem class CutsceneDropdownItem
@ -298,8 +299,48 @@ namespace CodeWalker.World
UpdateTimeLabel(); UpdateTimeLabel();
} }
} }
private void TimeTrackBar_Scroll(object sender, EventArgs e)
{
PositionScrolled = true;
var t = TimeTrackBar.Value / 10.0f;
if (Cutscene != null)
{
Cutscene.Update(t);
} }
if (!Playing)
{
UpdateTimeLabel();
}
}
private void TimeTrackBar_MouseUp(object sender, MouseEventArgs e)
{
if (PositionScrolled)
{
PositionScrolled = false;
return;
}
PositionScrolled = false;
var f = Math.Min(Math.Max((e.X - 13.0f) / (TimeTrackBar.Width - 26.0f), 0.0f), 1.0f);
var v = f * (TimeTrackBar.Maximum / 10.0f);
if (Cutscene != null)
{
Cutscene.Update(v);
}
if (!Playing)
{
UpdateTimeTrackBar();
UpdateTimeLabel();
}
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class Cutscene [TypeConverter(typeof(ExpandableObjectConverter))] public class Cutscene
@ -314,6 +355,7 @@ namespace CodeWalker.World
public float Duration { get; set; } = 0.0f; public float Duration { get; set; } = 0.0f;
public float PlaybackTime { get; set; } = 0.0f; public float PlaybackTime { get; set; } = 0.0f;
private bool Seeking = false;
public Dictionary<int, CutObject> Objects { get; set; } = null; public Dictionary<int, CutObject> Objects { get; set; } = null;
@ -409,6 +451,7 @@ namespace CodeWalker.World
else else
{ {
//reset playback to beginning, and seek to newTime //reset playback to beginning, and seek to newTime
Seeking = true;
RaiseEvents(Duration);//raise all events up to the end first RaiseEvents(Duration);//raise all events up to the end first
PlaybackTime = 0.0f; PlaybackTime = 0.0f;
NextLoadEvent = 0; NextLoadEvent = 0;
@ -416,6 +459,7 @@ namespace CodeWalker.World
NextCameraCut = 0; NextCameraCut = 0;
NextConcatData = 0; NextConcatData = 0;
RaiseEvents(newTime); RaiseEvents(newTime);
Seeking = false;
} }
PlaybackTime = newTime; PlaybackTime = newTime;
@ -918,6 +962,8 @@ namespace CodeWalker.World
if (args == null) if (args == null)
{ return; } { return; }
if (Seeking) return; //don't raise subtitle events while seeking backwards...
if (WorldForm != null) if (WorldForm != null)
{ {
var txt = args.cName.ToString(); var txt = args.cName.ToString();
@ -942,6 +988,7 @@ namespace CodeWalker.World
if (oe == null) if (oe == null)
{ return; } { return; }
if (Seeking) return; //this gets a bit messy when seeking backwards
CutsceneObject cso = null; CutsceneObject cso = null;
SceneObjects.TryGetValue(oe.iObjectId, out cso); SceneObjects.TryGetValue(oe.iObjectId, out cso);