AWC research progress

This commit is contained in:
dexy 2020-02-09 05:23:18 +11:00
parent 5d1321e291
commit cdda4b943e
5 changed files with 1164 additions and 562 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2661,7 +2661,7 @@ namespace CodeWalker
case MetaFormat.Awc: case MetaFormat.Awc:
{ {
var awc = XmlAwc.GetAwc(doc, fpathin); var awc = XmlAwc.GetAwc(doc, fpathin);
if (awc.Audios == null) if (awc.Streams == null)
{ {
MessageBox.Show(fname + ": Schema not supported.", "Cannot import AWC XML"); MessageBox.Show(fname + ": Schema not supported.", "Cannot import AWC XML");
continue; continue;

View File

@ -53,24 +53,30 @@
this.DetailsPropertyGrid = new CodeWalker.WinForms.PropertyGridFix(); this.DetailsPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
this.Timer = new System.Windows.Forms.Timer(this.components); this.Timer = new System.Windows.Forms.Timer(this.components);
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.XmlTabPage = new System.Windows.Forms.TabPage();
this.XmlTextBox = new FastColoredTextBoxNS.FastColoredTextBox();
this.MainTabControl.SuspendLayout(); this.MainTabControl.SuspendLayout();
this.PlayerTabPage.SuspendLayout(); this.PlayerTabPage.SuspendLayout();
this.contextMenuStrip.SuspendLayout(); this.contextMenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.VolumeTrackBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.VolumeTrackBar)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).BeginInit();
this.DetailsTabPage.SuspendLayout(); this.DetailsTabPage.SuspendLayout();
this.XmlTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// MainTabControl // MainTabControl
// //
this.MainTabControl.Controls.Add(this.PlayerTabPage); this.MainTabControl.Controls.Add(this.PlayerTabPage);
this.MainTabControl.Controls.Add(this.DetailsTabPage); this.MainTabControl.Controls.Add(this.DetailsTabPage);
this.MainTabControl.Controls.Add(this.XmlTabPage);
this.MainTabControl.Dock = System.Windows.Forms.DockStyle.Fill; this.MainTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.MainTabControl.Location = new System.Drawing.Point(0, 0); this.MainTabControl.Location = new System.Drawing.Point(0, 0);
this.MainTabControl.Name = "MainTabControl"; this.MainTabControl.Name = "MainTabControl";
this.MainTabControl.SelectedIndex = 0; this.MainTabControl.SelectedIndex = 0;
this.MainTabControl.Size = new System.Drawing.Size(576, 361); this.MainTabControl.Size = new System.Drawing.Size(709, 448);
this.MainTabControl.TabIndex = 0; this.MainTabControl.TabIndex = 0;
this.MainTabControl.SelectedIndexChanged += new System.EventHandler(this.MainTabControl_SelectedIndexChanged);
// //
// PlayerTabPage // PlayerTabPage
// //
@ -88,7 +94,7 @@
this.PlayerTabPage.Location = new System.Drawing.Point(4, 22); this.PlayerTabPage.Location = new System.Drawing.Point(4, 22);
this.PlayerTabPage.Name = "PlayerTabPage"; this.PlayerTabPage.Name = "PlayerTabPage";
this.PlayerTabPage.Padding = new System.Windows.Forms.Padding(3); this.PlayerTabPage.Padding = new System.Windows.Forms.Padding(3);
this.PlayerTabPage.Size = new System.Drawing.Size(568, 335); this.PlayerTabPage.Size = new System.Drawing.Size(701, 422);
this.PlayerTabPage.TabIndex = 0; this.PlayerTabPage.TabIndex = 0;
this.PlayerTabPage.Text = "Player"; this.PlayerTabPage.Text = "Player";
this.PlayerTabPage.UseVisualStyleBackColor = true; this.PlayerTabPage.UseVisualStyleBackColor = true;
@ -97,7 +103,7 @@
// //
this.LabelInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.LabelInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.LabelInfo.AutoSize = true; this.LabelInfo.AutoSize = true;
this.LabelInfo.Location = new System.Drawing.Point(8, 247); this.LabelInfo.Location = new System.Drawing.Point(8, 334);
this.LabelInfo.Name = "LabelInfo"; this.LabelInfo.Name = "LabelInfo";
this.LabelInfo.Size = new System.Drawing.Size(0, 13); this.LabelInfo.Size = new System.Drawing.Size(0, 13);
this.LabelInfo.TabIndex = 12; this.LabelInfo.TabIndex = 12;
@ -105,7 +111,7 @@
// LabelTime // LabelTime
// //
this.LabelTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.LabelTime.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.LabelTime.Location = new System.Drawing.Point(285, 308); this.LabelTime.Location = new System.Drawing.Point(418, 395);
this.LabelTime.Name = "LabelTime"; this.LabelTime.Name = "LabelTime";
this.LabelTime.Size = new System.Drawing.Size(114, 17); this.LabelTime.Size = new System.Drawing.Size(114, 17);
this.LabelTime.TabIndex = 11; this.LabelTime.TabIndex = 11;
@ -115,7 +121,7 @@
// //
this.StopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.StopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.StopButton.Enabled = false; this.StopButton.Enabled = false;
this.StopButton.Location = new System.Drawing.Point(211, 304); this.StopButton.Location = new System.Drawing.Point(211, 391);
this.StopButton.Name = "StopButton"; this.StopButton.Name = "StopButton";
this.StopButton.Size = new System.Drawing.Size(31, 23); this.StopButton.Size = new System.Drawing.Size(31, 23);
this.StopButton.TabIndex = 10; this.StopButton.TabIndex = 10;
@ -127,9 +133,9 @@
// //
this.VolumeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.VolumeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.VolumeLabel.AutoSize = true; this.VolumeLabel.AutoSize = true;
this.VolumeLabel.Location = new System.Drawing.Point(405, 308); this.VolumeLabel.Location = new System.Drawing.Point(538, 395);
this.VolumeLabel.Name = "VolumeLabel"; this.VolumeLabel.Name = "VolumeLabel";
this.VolumeLabel.Size = new System.Drawing.Size(56, 13); this.VolumeLabel.Size = new System.Drawing.Size(60, 13);
this.VolumeLabel.TabIndex = 9; this.VolumeLabel.TabIndex = 9;
this.VolumeLabel.Text = "🕩 Volume"; this.VolumeLabel.Text = "🕩 Volume";
// //
@ -137,7 +143,7 @@
// //
this.chbAutoJump.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.chbAutoJump.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chbAutoJump.AutoSize = true; this.chbAutoJump.AutoSize = true;
this.chbAutoJump.Location = new System.Drawing.Point(17, 308); this.chbAutoJump.Location = new System.Drawing.Point(17, 395);
this.chbAutoJump.Name = "chbAutoJump"; this.chbAutoJump.Name = "chbAutoJump";
this.chbAutoJump.Size = new System.Drawing.Size(108, 17); this.chbAutoJump.Size = new System.Drawing.Size(108, 17);
this.chbAutoJump.TabIndex = 8; this.chbAutoJump.TabIndex = 8;
@ -147,7 +153,7 @@
// PrevButton // PrevButton
// //
this.PrevButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.PrevButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.PrevButton.Location = new System.Drawing.Point(137, 304); this.PrevButton.Location = new System.Drawing.Point(137, 391);
this.PrevButton.Name = "PrevButton"; this.PrevButton.Name = "PrevButton";
this.PrevButton.Size = new System.Drawing.Size(31, 23); this.PrevButton.Size = new System.Drawing.Size(31, 23);
this.PrevButton.TabIndex = 2; this.PrevButton.TabIndex = 2;
@ -158,7 +164,7 @@
// NextButton // NextButton
// //
this.NextButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.NextButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.NextButton.Location = new System.Drawing.Point(248, 304); this.NextButton.Location = new System.Drawing.Point(248, 391);
this.NextButton.Name = "NextButton"; this.NextButton.Name = "NextButton";
this.NextButton.Size = new System.Drawing.Size(31, 23); this.NextButton.Size = new System.Drawing.Size(31, 23);
this.NextButton.TabIndex = 4; this.NextButton.TabIndex = 4;
@ -169,7 +175,7 @@
// PlayButton // PlayButton
// //
this.PlayButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.PlayButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.PlayButton.Location = new System.Drawing.Point(174, 304); this.PlayButton.Location = new System.Drawing.Point(174, 391);
this.PlayButton.Name = "PlayButton"; this.PlayButton.Name = "PlayButton";
this.PlayButton.Size = new System.Drawing.Size(31, 23); this.PlayButton.Size = new System.Drawing.Size(31, 23);
this.PlayButton.TabIndex = 3; this.PlayButton.TabIndex = 3;
@ -193,7 +199,7 @@
this.PlayListView.Location = new System.Drawing.Point(6, 6); this.PlayListView.Location = new System.Drawing.Point(6, 6);
this.PlayListView.MultiSelect = false; this.PlayListView.MultiSelect = false;
this.PlayListView.Name = "PlayListView"; this.PlayListView.Name = "PlayListView";
this.PlayListView.Size = new System.Drawing.Size(556, 238); this.PlayListView.Size = new System.Drawing.Size(689, 325);
this.PlayListView.TabIndex = 0; this.PlayListView.TabIndex = 0;
this.PlayListView.UseCompatibleStateImageBehavior = false; this.PlayListView.UseCompatibleStateImageBehavior = false;
this.PlayListView.View = System.Windows.Forms.View.Details; this.PlayListView.View = System.Windows.Forms.View.Details;
@ -203,7 +209,7 @@
// PlaylistNameHeader // PlaylistNameHeader
// //
this.PlaylistNameHeader.Text = "Name"; this.PlaylistNameHeader.Text = "Name";
this.PlaylistNameHeader.Width = 260; this.PlaylistNameHeader.Width = 337;
// //
// PlaylistTypeHeader // PlaylistTypeHeader
// //
@ -241,7 +247,7 @@
this.VolumeTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.VolumeTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.VolumeTrackBar.BackColor = System.Drawing.SystemColors.ControlLightLight; this.VolumeTrackBar.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.VolumeTrackBar.LargeChange = 10; this.VolumeTrackBar.LargeChange = 10;
this.VolumeTrackBar.Location = new System.Drawing.Point(455, 304); this.VolumeTrackBar.Location = new System.Drawing.Point(588, 391);
this.VolumeTrackBar.Maximum = 100; this.VolumeTrackBar.Maximum = 100;
this.VolumeTrackBar.Name = "VolumeTrackBar"; this.VolumeTrackBar.Name = "VolumeTrackBar";
this.VolumeTrackBar.Size = new System.Drawing.Size(105, 45); this.VolumeTrackBar.Size = new System.Drawing.Size(105, 45);
@ -256,10 +262,10 @@
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.PositionTrackBar.BackColor = System.Drawing.SystemColors.ControlLightLight; this.PositionTrackBar.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.PositionTrackBar.LargeChange = 1000; this.PositionTrackBar.LargeChange = 1000;
this.PositionTrackBar.Location = new System.Drawing.Point(6, 266); this.PositionTrackBar.Location = new System.Drawing.Point(6, 353);
this.PositionTrackBar.Maximum = 1000; this.PositionTrackBar.Maximum = 1000;
this.PositionTrackBar.Name = "PositionTrackBar"; this.PositionTrackBar.Name = "PositionTrackBar";
this.PositionTrackBar.Size = new System.Drawing.Size(554, 45); this.PositionTrackBar.Size = new System.Drawing.Size(687, 45);
this.PositionTrackBar.TabIndex = 1; this.PositionTrackBar.TabIndex = 1;
this.PositionTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; this.PositionTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
this.PositionTrackBar.Scroll += new System.EventHandler(this.PositionTrackBar_Scroll); this.PositionTrackBar.Scroll += new System.EventHandler(this.PositionTrackBar_Scroll);
@ -270,7 +276,7 @@
this.DetailsTabPage.Location = new System.Drawing.Point(4, 22); this.DetailsTabPage.Location = new System.Drawing.Point(4, 22);
this.DetailsTabPage.Name = "DetailsTabPage"; this.DetailsTabPage.Name = "DetailsTabPage";
this.DetailsTabPage.Padding = new System.Windows.Forms.Padding(3); this.DetailsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.DetailsTabPage.Size = new System.Drawing.Size(568, 335); this.DetailsTabPage.Size = new System.Drawing.Size(701, 422);
this.DetailsTabPage.TabIndex = 1; this.DetailsTabPage.TabIndex = 1;
this.DetailsTabPage.Text = "Details"; this.DetailsTabPage.Text = "Details";
this.DetailsTabPage.UseVisualStyleBackColor = true; this.DetailsTabPage.UseVisualStyleBackColor = true;
@ -281,7 +287,7 @@
this.DetailsPropertyGrid.HelpVisible = false; this.DetailsPropertyGrid.HelpVisible = false;
this.DetailsPropertyGrid.Location = new System.Drawing.Point(3, 3); this.DetailsPropertyGrid.Location = new System.Drawing.Point(3, 3);
this.DetailsPropertyGrid.Name = "DetailsPropertyGrid"; this.DetailsPropertyGrid.Name = "DetailsPropertyGrid";
this.DetailsPropertyGrid.Size = new System.Drawing.Size(562, 329); this.DetailsPropertyGrid.Size = new System.Drawing.Size(695, 416);
this.DetailsPropertyGrid.TabIndex = 0; this.DetailsPropertyGrid.TabIndex = 0;
// //
// Timer // Timer
@ -295,11 +301,63 @@
this.saveFileDialog.DefaultExt = "wav"; this.saveFileDialog.DefaultExt = "wav";
this.saveFileDialog.Filter = "Wave files (*.wav)|*.wav"; this.saveFileDialog.Filter = "Wave files (*.wav)|*.wav";
// //
// XmlTabPage
//
this.XmlTabPage.Controls.Add(this.XmlTextBox);
this.XmlTabPage.Location = new System.Drawing.Point(4, 22);
this.XmlTabPage.Name = "XmlTabPage";
this.XmlTabPage.Size = new System.Drawing.Size(701, 422);
this.XmlTabPage.TabIndex = 2;
this.XmlTabPage.Text = "XML";
this.XmlTabPage.UseVisualStyleBackColor = true;
//
// XmlTextBox
//
this.XmlTextBox.AutoCompleteBracketsList = new char[] {
'(',
')',
'{',
'}',
'[',
']',
'\"',
'\"',
'\'',
'\''};
this.XmlTextBox.AutoIndentChars = false;
this.XmlTextBox.AutoIndentCharsPatterns = "";
this.XmlTextBox.AutoIndentExistingLines = false;
this.XmlTextBox.AutoScrollMinSize = new System.Drawing.Size(27, 14);
this.XmlTextBox.BackBrush = null;
this.XmlTextBox.CharHeight = 14;
this.XmlTextBox.CharWidth = 8;
this.XmlTextBox.CommentPrefix = null;
this.XmlTextBox.Cursor = System.Windows.Forms.Cursors.IBeam;
this.XmlTextBox.DelayedEventsInterval = 1;
this.XmlTextBox.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
this.XmlTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.XmlTextBox.IsReplaceMode = false;
this.XmlTextBox.Language = FastColoredTextBoxNS.Language.XML;
this.XmlTextBox.LeftBracket = '<';
this.XmlTextBox.LeftBracket2 = '(';
this.XmlTextBox.Location = new System.Drawing.Point(0, 0);
this.XmlTextBox.Name = "XmlTextBox";
this.XmlTextBox.Paddings = new System.Windows.Forms.Padding(0);
this.XmlTextBox.RightBracket = '>';
this.XmlTextBox.RightBracket2 = ')';
this.XmlTextBox.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
this.XmlTextBox.ServiceColors = ((FastColoredTextBoxNS.ServiceColors)(resources.GetObject("XmlTextBox.ServiceColors")));
this.XmlTextBox.Size = new System.Drawing.Size(701, 422);
this.XmlTextBox.TabIndex = 2;
this.XmlTextBox.Zoom = 100;
this.XmlTextBox.TextChanged += new System.EventHandler<FastColoredTextBoxNS.TextChangedEventArgs>(this.XmlTextBox_TextChanged);
this.XmlTextBox.VisibleRangeChangedDelayed += new System.EventHandler(this.XmlTextBox_VisibleRangeChangedDelayed);
//
// AwcForm // AwcForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(576, 361); this.ClientSize = new System.Drawing.Size(709, 448);
this.Controls.Add(this.MainTabControl); this.Controls.Add(this.MainTabControl);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(592, 300); this.MinimumSize = new System.Drawing.Size(592, 300);
@ -313,6 +371,8 @@
((System.ComponentModel.ISupportInitialize)(this.VolumeTrackBar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.VolumeTrackBar)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).EndInit();
this.DetailsTabPage.ResumeLayout(false); this.DetailsTabPage.ResumeLayout(false);
this.XmlTabPage.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -342,5 +402,7 @@
private System.Windows.Forms.ToolStripMenuItem ExportAsWav; private System.Windows.Forms.ToolStripMenuItem ExportAsWav;
private System.Windows.Forms.SaveFileDialog saveFileDialog; private System.Windows.Forms.SaveFileDialog saveFileDialog;
private System.Windows.Forms.ColumnHeader PlaylistSizeHeader; private System.Windows.Forms.ColumnHeader PlaylistSizeHeader;
private System.Windows.Forms.TabPage XmlTabPage;
private FastColoredTextBoxNS.FastColoredTextBox XmlTextBox;
} }
} }

View File

@ -1,10 +1,12 @@
using CodeWalker.GameFiles; using CodeWalker.GameFiles;
using FastColoredTextBoxNS;
using SharpDX.Multimedia; using SharpDX.Multimedia;
using SharpDX.XAudio2; using SharpDX.XAudio2;
using System; using System;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing;
namespace CodeWalker.Forms namespace CodeWalker.Forms
{ {
@ -12,7 +14,7 @@ namespace CodeWalker.Forms
{ {
public AwcFile Awc { get; set; } public AwcFile Awc { get; set; }
private AwcAudio currentAudio; private AwcStream currentAudio;
private XAudio2 xAudio2; private XAudio2 xAudio2;
private MasteringVoice masteringVoice; private MasteringVoice masteringVoice;
private AudioBuffer audioBuffer; private AudioBuffer audioBuffer;
@ -38,6 +40,10 @@ namespace CodeWalker.Forms
private float trackLength; private float trackLength;
private bool trackFinished; private bool trackFinished;
private bool LoadingXml = false;
private bool DelayHighlight = false;
public AwcForm() public AwcForm()
{ {
InitializeComponent(); InitializeComponent();
@ -50,6 +56,48 @@ namespace CodeWalker.Forms
Text = fileName + " - AWC Player - CodeWalker by dexyfex"; Text = fileName + " - AWC Player - CodeWalker by dexyfex";
} }
private void UpdateXmlTextBox(string xml)
{
LoadingXml = true;
XmlTextBox.Text = "";
XmlTextBox.Language = Language.XML;
DelayHighlight = false;
if (string.IsNullOrEmpty(xml))
{
LoadingXml = false;
return;
}
//if (xml.Length > (1048576 * 5))
//{
// XmlTextBox.Language = Language.Custom;
// XmlTextBox.Text = "[XML size > 10MB - Not shown due to performance limitations - Please use an external viewer for this file.]";
// return;
//}
//else
if (xml.Length > (1024 * 512))
{
XmlTextBox.Language = Language.Custom;
DelayHighlight = true;
}
//else
//{
// XmlTextBox.Language = Language.XML;
//}
Cursor = Cursors.WaitCursor;
XmlTextBox.Text = xml;
//XmlTextBox.IsChanged = false;
XmlTextBox.ClearUndo();
Cursor = Cursors.Default;
LoadingXml = false;
}
public void LoadAwc(AwcFile awc) public void LoadAwc(AwcFile awc)
{ {
Awc = awc; Awc = awc;
@ -64,11 +112,11 @@ namespace CodeWalker.Forms
PlayListView.Items.Clear(); PlayListView.Items.Clear();
float totalLength = 0; float totalLength = 0;
if (awc.Audios != null) if (awc.Streams != null)
{ {
foreach (var audio in awc.Audios) foreach (var audio in awc.Streams)
{ {
if (audio.MultiChannelBlocks != null) continue;//don't display multichannel source audios if (audio.StreamBlocks != null) continue;//don't display multichannel source audios
var item = PlayListView.Items.Add(audio.Name); var item = PlayListView.Items.Add(audio.Name);
item.SubItems.Add(audio.Type); item.SubItems.Add(audio.Type);
item.SubItems.Add(audio.LengthStr); item.SubItems.Add(audio.LengthStr);
@ -78,10 +126,44 @@ namespace CodeWalker.Forms
} }
} }
LabelInfo.Text = awc.Audios.Length.ToString() + " track(s), Length: " + TimeSpan.FromSeconds((float)totalLength).ToString("h\\:mm\\:ss"); LabelInfo.Text = awc.Streams.Length.ToString() + " track(s), Length: " + TimeSpan.FromSeconds((float)totalLength).ToString("h\\:mm\\:ss");
UpdateFormTitle(); UpdateFormTitle();
} }
public void LoadXml()
{
if (Awc != null)
{
var xml = AwcXml.GetXml(Awc);
UpdateXmlTextBox(xml);
}
}
private void HTMLSyntaxHighlight(Range range)
{
try
{
Style BlueStyle = new TextStyle(Brushes.Blue, null, FontStyle.Regular);
Style RedStyle = new TextStyle(Brushes.Red, null, FontStyle.Regular);
Style MaroonStyle = new TextStyle(Brushes.Maroon, null, FontStyle.Regular);
//clear style of changed range
range.ClearStyle(BlueStyle, MaroonStyle, RedStyle);
//tag brackets highlighting
range.SetStyle(BlueStyle, @"<|/>|</|>");
//tag name
range.SetStyle(MaroonStyle, @"<(?<range>[!\w]+)");
//end of tag
range.SetStyle(MaroonStyle, @"</(?<range>\w+)>");
//attributes
range.SetStyle(RedStyle, @"(?<range>\S+?)='[^']*'|(?<range>\S+)=""[^""]*""|(?<range>\S+)=\S+");
//attribute values
range.SetStyle(BlueStyle, @"\S+?=(?<range>'[^']*')|\S+=(?<range>""[^""]*"")|\S+=(?<range>\S+)");
}
catch
{ }
}
private void Stop() private void Stop()
{ {
if (playerState != PlayerState.Stopped) if (playerState != PlayerState.Stopped)
@ -127,7 +209,7 @@ namespace CodeWalker.Forms
} }
} }
private void InitializeAudio(AwcAudio audio, float playBegin = 0) private void InitializeAudio(AwcStream audio, float playBegin = 0)
{ {
currentAudio = audio; currentAudio = audio;
trackLength = audio.Length; trackLength = audio.Length;
@ -174,15 +256,15 @@ namespace CodeWalker.Forms
if (PlayListView.SelectedItems.Count == 1) if (PlayListView.SelectedItems.Count == 1)
{ {
var item = PlayListView.SelectedItems[0]; var item = PlayListView.SelectedItems[0];
var audio = item.Tag as AwcAudio; var audio = item.Tag as AwcStream;
if ((audio?.Format != null) || (audio?.MultiChannelFormat != null)) if ((audio?.FormatChunk != null) || (audio?.StreamFormat != null))
{ {
InitializeAudio(audio); InitializeAudio(audio);
sourceVoice.Start(); sourceVoice.Start();
SetPlayerState(PlayerState.Playing); SetPlayerState(PlayerState.Playing);
} }
else if (audio.MIDIData != null) else if (audio.MidiChunk != null)
{ {
//todo: play MIDI? //todo: play MIDI?
} }
@ -335,10 +417,10 @@ namespace CodeWalker.Forms
if (PlayListView.SelectedItems.Count == 1) if (PlayListView.SelectedItems.Count == 1)
{ {
var item = PlayListView.SelectedItems[0]; var item = PlayListView.SelectedItems[0];
var audio = item.Tag as AwcAudio; var audio = item.Tag as AwcStream;
var ext = ".wav"; var ext = ".wav";
if (audio?.MIDIData != null) if (audio?.MidiChunk != null)
{ {
ext = ".midi"; ext = ".midi";
} }
@ -346,11 +428,11 @@ namespace CodeWalker.Forms
saveFileDialog.FileName = audio.Name + ext; saveFileDialog.FileName = audio.Name + ext;
if (saveFileDialog.ShowDialog() == DialogResult.OK) if (saveFileDialog.ShowDialog() == DialogResult.OK)
{ {
if (audio?.MIDIData != null) if (audio?.MidiChunk != null)
{ {
File.WriteAllBytes(saveFileDialog.FileName, audio.MIDIData.Data); File.WriteAllBytes(saveFileDialog.FileName, audio.MidiChunk.Data);
} }
else if ((audio?.Format != null) || (audio?.MultiChannelFormat != null)) else if ((audio?.FormatChunk != null) || (audio?.StreamFormat != null))
{ {
Stream wavStream = audio.GetWavStream(); Stream wavStream = audio.GetWavStream();
FileStream stream = File.Create(saveFileDialog.FileName); FileStream stream = File.Create(saveFileDialog.FileName);
@ -369,13 +451,42 @@ namespace CodeWalker.Forms
if (PlayListView.SelectedItems.Count == 1) if (PlayListView.SelectedItems.Count == 1)
{ {
var item = PlayListView.SelectedItems[0]; var item = PlayListView.SelectedItems[0];
var audio = item.Tag as AwcAudio; var audio = item.Tag as AwcStream;
if (audio?.MIDIData != null) if (audio?.MidiChunk != null)
{ {
ExportAsWav.Text = "Export as .midi"; ExportAsWav.Text = "Export as .midi";
} }
} }
} }
private void MainTabControl_SelectedIndexChanged(object sender, EventArgs e)
{
if (MainTabControl.SelectedTab == XmlTabPage)
{
if (string.IsNullOrEmpty(XmlTextBox.Text))
{
LoadXml();
}
}
}
private void XmlTextBox_VisibleRangeChangedDelayed(object sender, EventArgs e)
{
//this approach is much faster to load, but no outlining is available
//highlight only visible area of text
if (DelayHighlight)
{
HTMLSyntaxHighlight(XmlTextBox.VisibleRange);
}
}
private void XmlTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (!LoadingXml)
{
}
}
} }
} }

View File

@ -120,6 +120,24 @@
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>99, 17</value> <value>99, 17</value>
</metadata> </metadata>
<data name="XmlTextBox.ServiceColors" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdGYXN0Q29sb3JlZFRleHRCb3gsIFZlcnNpb249Mi4xNi4yNC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWZiOGFhMTJiOTk0ZWY2MWIMAwAAAFFTeXN0
ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2Vu
PWIwM2Y1ZjdmMTFkNTBhM2EFAQAAACJGYXN0Q29sb3JlZFRleHRCb3hOUy5TZXJ2aWNlQ29sb3JzBgAA
ACg8Q29sbGFwc2VNYXJrZXJGb3JlQ29sb3I+a19fQmFja2luZ0ZpZWxkKDxDb2xsYXBzZU1hcmtlckJh
Y2tDb2xvcj5rX19CYWNraW5nRmllbGQqPENvbGxhcHNlTWFya2VyQm9yZGVyQ29sb3I+a19fQmFja2lu
Z0ZpZWxkJjxFeHBhbmRNYXJrZXJGb3JlQ29sb3I+a19fQmFja2luZ0ZpZWxkJjxFeHBhbmRNYXJrZXJC
YWNrQ29sb3I+a19fQmFja2luZ0ZpZWxkKDxFeHBhbmRNYXJrZXJCb3JkZXJDb2xvcj5rX19CYWNraW5n
RmllbGQEBAQEBAQUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAA
ABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAAUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5E
cmF3aW5nLkNvbG9yAwAAABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAACAAAABfz///8UU3lzdGVtLkRy
YXdpbmcuQ29sb3IEAAAABG5hbWUFdmFsdWUKa25vd25Db2xvcgVzdGF0ZQEAAAAJBwcDAAAACgAAAAAA
AAAAlgABAAH7/////P///woAAAAAAAAAAKQAAQAB+v////z///8KAAAAAAAAAACWAAEAAfn////8////
CgAAAAAAAAAATgABAAH4/////P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAACWAAEACw==
</value>
</data>
<metadata name="Timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="Timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>