Cutscene viewer showing subtitles on WorldForm

This commit is contained in:
dexy 2019-11-25 21:35:15 +11:00
parent 5a869fa836
commit 866cc9ab57
4 changed files with 104 additions and 24 deletions

View File

@ -16,7 +16,6 @@ namespace CodeWalker.World
public partial class CutsceneForm : Form
{
private WorldForm WorldForm;
private GameFileCache GameFileCache;
private Cutscene Cutscene = null;
@ -100,7 +99,7 @@ namespace CodeWalker.World
GameFileCache.RpfMan.LoadFile(cutFile, entry);
cutscene = new Cutscene();
cutscene.Init(cutFile, GameFileCache);
cutscene.Init(cutFile, GameFileCache, WorldForm);
}
}
@ -288,6 +287,7 @@ namespace CodeWalker.World
{
public CutFile CutFile { get; set; } = null;
private GameFileCache GameFileCache = null;
private WorldForm WorldForm = null;
public float[] CameraCutList { get; set; } = null;
public YcdFile[] Ycds { get; set; } = null;
@ -317,10 +317,11 @@ namespace CodeWalker.World
public void Init(CutFile cutFile, GameFileCache gfc)
public void Init(CutFile cutFile, GameFileCache gfc, WorldForm wf)
{
CutFile = cutFile;
GameFileCache = gfc;
WorldForm = wf;
var csf = cutFile?.CutsceneFile2;
if (csf == null) return;
@ -734,6 +735,17 @@ namespace CodeWalker.World
if (args == null)
{ return; }
if (WorldForm != null)
{
var txt = args.cName.ToString();
var dur = args.fSubtitleDuration;
txt = txt.Replace("~z~", "");
txt = txt.Replace("~n~", "\n");
txt = txt.Replace("~c~", " - ");
WorldForm.ShowSubtitle(txt, dur);
}
}
private void PedVariation(CutEvent e)
{

67
WorldForm.Designer.cs generated
View File

@ -219,6 +219,7 @@ namespace CodeWalker
this.ToolsMenuRPFExplorer = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenuSelectionInfo = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenuProjectWindow = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenuCutsceneViewer = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenuWorldSearch = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenuBinarySearch = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenuJenkGen = new System.Windows.Forms.ToolStripMenuItem();
@ -292,7 +293,8 @@ namespace CodeWalker
this.ToolbarCameraMapViewButton = new System.Windows.Forms.ToolStripMenuItem();
this.ToolbarCameraOrthographicButton = new System.Windows.Forms.ToolStripMenuItem();
this.ToolbarPanel = new System.Windows.Forms.Panel();
this.ToolsMenuCutsceneViewer = new System.Windows.Forms.ToolStripMenuItem();
this.SubtitleLabel = new System.Windows.Forms.Label();
this.SubtitleTimer = new System.Windows.Forms.Timer(this.components);
this.StatusStrip.SuspendLayout();
this.ToolsPanel.SuspendLayout();
this.ToolsTabControl.SuspendLayout();
@ -2681,12 +2683,12 @@ namespace CodeWalker
this.ToolsMenuExtractShaders,
this.ToolsMenuOptions});
this.ToolsMenu.Name = "ToolsMenu";
this.ToolsMenu.Size = new System.Drawing.Size(181, 334);
this.ToolsMenu.Size = new System.Drawing.Size(170, 312);
//
// ToolsMenuRPFBrowser
//
this.ToolsMenuRPFBrowser.Name = "ToolsMenuRPFBrowser";
this.ToolsMenuRPFBrowser.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuRPFBrowser.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuRPFBrowser.Text = "RPF Browser...";
this.ToolsMenuRPFBrowser.Visible = false;
this.ToolsMenuRPFBrowser.Click += new System.EventHandler(this.ToolsMenuRPFBrowser_Click);
@ -2694,14 +2696,14 @@ namespace CodeWalker
// ToolsMenuRPFExplorer
//
this.ToolsMenuRPFExplorer.Name = "ToolsMenuRPFExplorer";
this.ToolsMenuRPFExplorer.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuRPFExplorer.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuRPFExplorer.Text = "RPF Explorer...";
this.ToolsMenuRPFExplorer.Click += new System.EventHandler(this.ToolsMenuRPFExplorer_Click);
//
// ToolsMenuSelectionInfo
//
this.ToolsMenuSelectionInfo.Name = "ToolsMenuSelectionInfo";
this.ToolsMenuSelectionInfo.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuSelectionInfo.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuSelectionInfo.Text = "Selection info...";
this.ToolsMenuSelectionInfo.Click += new System.EventHandler(this.ToolsMenuSelectionInfo_Click);
//
@ -2709,14 +2711,22 @@ namespace CodeWalker
//
this.ToolsMenuProjectWindow.Enabled = false;
this.ToolsMenuProjectWindow.Name = "ToolsMenuProjectWindow";
this.ToolsMenuProjectWindow.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuProjectWindow.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuProjectWindow.Text = "Project window...";
this.ToolsMenuProjectWindow.Click += new System.EventHandler(this.ToolsMenuProjectWindow_Click);
//
// ToolsMenuCutsceneViewer
//
this.ToolsMenuCutsceneViewer.Enabled = false;
this.ToolsMenuCutsceneViewer.Name = "ToolsMenuCutsceneViewer";
this.ToolsMenuCutsceneViewer.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuCutsceneViewer.Text = "Cutscene viewer...";
this.ToolsMenuCutsceneViewer.Click += new System.EventHandler(this.ToolsMenuCutsceneViewer_Click);
//
// ToolsMenuWorldSearch
//
this.ToolsMenuWorldSearch.Name = "ToolsMenuWorldSearch";
this.ToolsMenuWorldSearch.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuWorldSearch.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuWorldSearch.Text = "World search...";
this.ToolsMenuWorldSearch.Click += new System.EventHandler(this.ToolsMenuWorldSearch_Click);
//
@ -2724,14 +2734,14 @@ namespace CodeWalker
//
this.ToolsMenuBinarySearch.Enabled = false;
this.ToolsMenuBinarySearch.Name = "ToolsMenuBinarySearch";
this.ToolsMenuBinarySearch.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuBinarySearch.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuBinarySearch.Text = "Binary search...";
this.ToolsMenuBinarySearch.Click += new System.EventHandler(this.ToolsMenuBinarySearch_Click);
//
// ToolsMenuJenkGen
//
this.ToolsMenuJenkGen.Name = "ToolsMenuJenkGen";
this.ToolsMenuJenkGen.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuJenkGen.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuJenkGen.Text = "JenkGen...";
this.ToolsMenuJenkGen.Click += new System.EventHandler(this.ToolsMenuJenkGen_Click);
//
@ -2739,42 +2749,42 @@ namespace CodeWalker
//
this.ToolsMenuJenkInd.Enabled = false;
this.ToolsMenuJenkInd.Name = "ToolsMenuJenkInd";
this.ToolsMenuJenkInd.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuJenkInd.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuJenkInd.Text = "JenkInd...";
this.ToolsMenuJenkInd.Click += new System.EventHandler(this.ToolsMenuJenkInd_Click);
//
// ToolsMenuExtractScripts
//
this.ToolsMenuExtractScripts.Name = "ToolsMenuExtractScripts";
this.ToolsMenuExtractScripts.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuExtractScripts.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuExtractScripts.Text = "Extract scripts...";
this.ToolsMenuExtractScripts.Click += new System.EventHandler(this.ToolsMenuExtractScripts_Click);
//
// ToolsMenuExtractTextures
//
this.ToolsMenuExtractTextures.Name = "ToolsMenuExtractTextures";
this.ToolsMenuExtractTextures.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuExtractTextures.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuExtractTextures.Text = "Extract textures...";
this.ToolsMenuExtractTextures.Click += new System.EventHandler(this.ToolsMenuExtractTextures_Click);
//
// ToolsMenuExtractRawFiles
//
this.ToolsMenuExtractRawFiles.Name = "ToolsMenuExtractRawFiles";
this.ToolsMenuExtractRawFiles.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuExtractRawFiles.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuExtractRawFiles.Text = "Extract raw files...";
this.ToolsMenuExtractRawFiles.Click += new System.EventHandler(this.ToolsMenuExtractRawFiles_Click);
//
// ToolsMenuExtractShaders
//
this.ToolsMenuExtractShaders.Name = "ToolsMenuExtractShaders";
this.ToolsMenuExtractShaders.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuExtractShaders.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuExtractShaders.Text = "Extract shaders...";
this.ToolsMenuExtractShaders.Click += new System.EventHandler(this.ToolsMenuExtractShaders_Click);
//
// ToolsMenuOptions
//
this.ToolsMenuOptions.Name = "ToolsMenuOptions";
this.ToolsMenuOptions.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuOptions.Size = new System.Drawing.Size(169, 22);
this.ToolsMenuOptions.Text = "Options...";
this.ToolsMenuOptions.Click += new System.EventHandler(this.ToolsMenuOptions_Click);
//
@ -3383,13 +3393,25 @@ namespace CodeWalker
this.ToolbarPanel.TabIndex = 7;
this.ToolbarPanel.Visible = false;
//
// ToolsMenuCutsceneViewer
// SubtitleLabel
//
this.ToolsMenuCutsceneViewer.Enabled = false;
this.ToolsMenuCutsceneViewer.Name = "ToolsMenuCutsceneViewer";
this.ToolsMenuCutsceneViewer.Size = new System.Drawing.Size(180, 22);
this.ToolsMenuCutsceneViewer.Text = "Cutscene viewer...";
this.ToolsMenuCutsceneViewer.Click += new System.EventHandler(this.ToolsMenuCutsceneViewer_Click);
this.SubtitleLabel.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.SubtitleLabel.AutoSize = true;
this.SubtitleLabel.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.SubtitleLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.SubtitleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.SubtitleLabel.Location = new System.Drawing.Point(455, 555);
this.SubtitleLabel.Name = "SubtitleLabel";
this.SubtitleLabel.Size = new System.Drawing.Size(84, 18);
this.SubtitleLabel.TabIndex = 8;
this.SubtitleLabel.Text = "Test Subtitle";
this.SubtitleLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.SubtitleLabel.Visible = false;
this.SubtitleLabel.SizeChanged += new System.EventHandler(this.SubtitleLabel_SizeChanged);
//
// SubtitleTimer
//
this.SubtitleTimer.Tick += new System.EventHandler(this.SubtitleTimer_Tick);
//
// WorldForm
//
@ -3403,6 +3425,7 @@ namespace CodeWalker
this.Controls.Add(this.ToolsPanel);
this.Controls.Add(this.StatusStrip);
this.Controls.Add(this.ToolsPanelShowButton);
this.Controls.Add(this.SubtitleLabel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
this.Name = "WorldForm";
@ -3742,5 +3765,7 @@ namespace CodeWalker
private System.Windows.Forms.NumericUpDown NearClipUpDown;
private System.Windows.Forms.Label label31;
private System.Windows.Forms.ToolStripMenuItem ToolsMenuCutsceneViewer;
private System.Windows.Forms.Label SubtitleLabel;
private System.Windows.Forms.Timer SubtitleTimer;
}
}

View File

@ -6111,6 +6111,35 @@ namespace CodeWalker
}
public void ShowSubtitle(string text, float duration)
{
if (InvokeRequired)
{
try
{
BeginInvoke(new Action(() => { ShowSubtitle(text, duration); }));
}
catch { }
return;
}
SubtitleLabel.Text = text;
SubtitleLabel.Visible = true;
SubtitleTimer.Interval = (int)(duration * 1000.0f);
SubtitleTimer.Enabled = true;
}
private void StatsUpdateTimer_Tick(object sender, EventArgs e)
{
@ -7890,6 +7919,17 @@ namespace CodeWalker
var statsForm = new StatisticsForm(this);
statsForm.Show(this);
}
private void SubtitleLabel_SizeChanged(object sender, EventArgs e)
{
SubtitleLabel.Left = (ClientSize.Width - SubtitleLabel.Size.Width) / 2; //keep subtitle label centered
}
private void SubtitleTimer_Tick(object sender, EventArgs e)
{
SubtitleTimer.Enabled = false;
SubtitleLabel.Visible = false;
}
}
public enum WorldControlMode

View File

@ -437,6 +437,9 @@ ufo
5ZF+uwdZKEYtmuBGFSIXhtejBe5PHX7dxL+qKPoEppRHcXOtiDsAAAAASUVORK5CYII=
</value>
</data>
<metadata name="SubtitleTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>652, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAMAICAAAAAAGACoDAAANgAAABAQAAAAABgAaAMAAN4MAABAQAAAAAAYACgyAABGEAAAKAAAACAA