Dat151 progress

This commit is contained in:
dexy 2018-12-27 00:20:39 +11:00
parent 05d302a4e1
commit 77d9c4e4c8
16 changed files with 2177 additions and 247 deletions

View File

@ -239,6 +239,8 @@ namespace CodeWalker.GameFiles
//BuildWavesMaps();
Loaded = true;
}
@ -637,6 +639,29 @@ namespace CodeWalker.GameFiles
{
//TODO!
//need to do this before building the data block since nametable offsets are in there!
if (NameTable != null)
{
NameTableCount = (uint)NameTable.Length;
uint ntlength = 4 + (4 * NameTableCount);
foreach (var name in NameTable)
{
ntlength += (uint)name.Length + 1;
}
NameTableLength = ntlength;
}
else
{
NameTableCount = 0;
NameTableLength = 4;
}
}
private void BuildDataBlock()
{
@ -671,13 +696,13 @@ namespace CodeWalker.GameFiles
var rd = RelDatasSorted[i];
switch ((Dat151RelType)rd.TypeID)
switch ((Dat151RelType)rd.TypeID)//must be a better way of doing this!
{
case Dat151RelType.AmbientEmitter:
case Dat151RelType.AmbientZone:
case Dat151RelType.Unk101:
case Dat151RelType.Unk35:
while ((ms.Position & 0xF) != 0) bw.Write((byte)0); //pad up to nearest 16 bytes
while ((ms.Position & 0xF) != 0) bw.Write((byte)0); //align to nearest 16 bytes
break;
case Dat151RelType.Mood:
case Dat151RelType.Unk70:
@ -717,6 +742,7 @@ namespace CodeWalker.GameFiles
DataBlock = buf;
DataLength = (uint)(DataBlock?.Length ?? 0);
}
private void BuildIndex()
{
@ -750,7 +776,16 @@ namespace CodeWalker.GameFiles
//{ }
IndexHashes = hashes;
//IndexCount = (uint)hashes.Length;
if ((RelType == RelDatFileType.Dat4) && (NameTableLength == 4))
{
IndexCount = (uint)(IndexStrings?.Length ?? 0);
}
else
{
IndexCount = (uint)(IndexHashes?.Length ?? 0);
}
}
private void BuildHashTable()
{
@ -787,13 +822,18 @@ namespace CodeWalker.GameFiles
{
HashTableOffsets = null;
}
HashTableCount = (uint)(HashTableOffsets?.Length ?? 0);
}
private void BuildPackTable()
{
//TODO
PackTableCount = (uint)(PackTableOffsets?.Length ?? 0);
}
private void BuildHashMaps()
{
//for discovering "HashTable" offsets
@ -881,7 +921,6 @@ namespace CodeWalker.GameFiles
}
public struct HashesMapKey
{
public RelDatFileType FileType { get; set; }
@ -947,50 +986,13 @@ namespace CodeWalker.GameFiles
public byte[] Save()
{
//build DataBlock
//update DataLength
//update NameTableCount
//update NameTableLength
//update IndexStrings/IndexHashes
//update IndexCount
//update HashTableOffsets (and hashes?)
//update HashTableCount
//update PackTableOffsets
//update PackTableCount
BuildNameTable();
BuildDataBlock();
BuildIndex();
BuildHashTable();
BuildPackTable();
DataLength = (uint)(DataBlock?.Length ?? 0);
if (NameTable != null)
{
NameTableCount = (uint)NameTable.Length;
uint ntlength = 4 + (4 * NameTableCount);
foreach (var name in NameTable)
{
ntlength += (uint)name.Length + 1;
}
NameTableLength = ntlength;
}
else
{
NameTableCount = 0;
NameTableLength = 4;
}
if ((RelType == RelDatFileType.Dat4) && (NameTableLength == 4))
{
IndexCount = (uint)(IndexStrings?.Length ?? 0);
}
else
{
IndexCount = (uint)(IndexHashes?.Length ?? 0);
}
HashTableCount = (uint)(HashTableOffsets?.Length ?? 0);
PackTableCount = (uint)(PackTableOffsets?.Length ?? 0);
@ -1089,11 +1091,49 @@ namespace CodeWalker.GameFiles
public void AddRelData(RelData d) //TODO!!!
public void AddRelData(RelData d)
{
var newRelDatas = new List<RelData>();
var newRelDatasSorted = new List<RelData>();
newRelDatas.AddRange(RelDatas);
newRelDatasSorted.AddRange(RelDatasSorted);
newRelDatas.Add(d);
newRelDatasSorted.Add(d);
RelDatas = newRelDatas.ToArray();
RelDatasSorted = newRelDatasSorted.ToArray();
//RelDataDict[d.NameHash] = d;
}
public bool RemoveRelData(RelData d) //TODO!!!
public bool RemoveRelData(RelData d)
{
var newRelDatas = new List<RelData>();
var newRelDatasSorted = new List<RelData>();
foreach (var relData in RelDatas)
{
if (relData != d)
{
newRelDatas.Add(relData);
}
}
foreach (var relData in RelDatasSorted)
{
if (relData != d)
{
newRelDatasSorted.Add(relData);
}
}
if (newRelDatas.Count < RelDatas.Length)
{
RelDatas = newRelDatas.ToArray();
RelDatasSorted = newRelDatasSorted.ToArray();
RelDataDict.Remove(d.NameHash);
return true;
}
return false;
}
@ -2594,9 +2634,9 @@ namespace CodeWalker.GameFiles
}
[TC(typeof(EXP))] public class Dat151AmbientZone : Dat151RelData
{
public FlagsUint Flags00 { get; set; }
public FlagsUint Flags0 { get; set; }
public Dat151ZoneShape Shape { get; set; }
public FlagsUint Flags02 { get; set; }
public FlagsUint Flags1 { get; set; }
public Vector3 OuterPos { get; set; }
public float Unused01 { get; set; }
public Vector3 OuterSize { get; set; }
@ -2613,11 +2653,10 @@ namespace CodeWalker.GameFiles
public Vector4 InnerVec2 { get; set; }
public uint InnerAngle { get; set; }
public Vector3 InnerVec3 { get; set; }
public Vector4 Vec11 { get; set; }
public Vector4 Vec12 { get; set; }
public Vector4 Vec13 { get; set; }
public FlagsUint Flags05 { get; set; }
public Vector4 UnkVec1 { get; set; }
public Vector4 UnkVec2 { get; set; }
public Vector4 UnkVec3 { get; set; }
public FlagsUint Flags2 { get; set; }
public byte Unk14 { get; set; }
public byte Unk15 { get; set; }
public byte HashesCount { get; set; }
@ -2648,11 +2687,16 @@ namespace CodeWalker.GameFiles
public Dat151AmbientZone(RelFile rel) : base(rel)
{
Type = Dat151RelType.AmbientZone;
TypeID = (byte)Type;
}
public Dat151AmbientZone(RelData d, BinaryReader br) : base(d, br)
{
Flags00 = br.ReadUInt32();
Flags0 = br.ReadUInt32();
Shape = (Dat151ZoneShape)br.ReadUInt32();
Flags02 = br.ReadUInt32();
Flags1 = br.ReadUInt32();
OuterPos = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
Unused01 = br.ReadSingle();
OuterSize = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
@ -2669,11 +2713,11 @@ namespace CodeWalker.GameFiles
InnerVec2 = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
InnerAngle = br.ReadUInt32();//###
InnerVec3 = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
Vec11 = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
Vec12 = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
Vec13 = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
UnkVec1 = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
UnkVec2 = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
UnkVec3 = new Vector4(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
Flags05 = br.ReadUInt32();
Flags2 = br.ReadUInt32();
Unk14 = br.ReadByte();
Unk15 = br.ReadByte();
HashesCount = br.ReadByte();
@ -2725,13 +2769,13 @@ namespace CodeWalker.GameFiles
{ }//no hit
if (Shape != 0)
{ }//eg 1, 2
if (Flags02.Value != 0)
if (Flags1.Value != 0)
{ }//no hit
if (OuterAngle > 360)
{ }//no hit
if (InnerAngle > 360)
{ }//no hit
if (Flags05.Value != 0)
if (Flags2.Value != 0)
{ }//eg 0xAE64583B, 0x61083310, 0xCAE96294, 0x1C376176
#endregion
@ -2742,9 +2786,9 @@ namespace CodeWalker.GameFiles
//base.Write(bw);
WriteTypeAndOffset(bw);
bw.Write(Flags00.Value);
bw.Write(Flags0.Value);
bw.Write((uint)Shape);
bw.Write(Flags02.Value);
bw.Write(Flags1.Value);
bw.Write(OuterPos.X);
bw.Write(OuterPos.Y);
bw.Write(OuterPos.Z);
@ -2785,20 +2829,20 @@ namespace CodeWalker.GameFiles
bw.Write(InnerVec3.X);
bw.Write(InnerVec3.Y);
bw.Write(InnerVec3.Z);
bw.Write(Vec11.X);
bw.Write(Vec11.Y);
bw.Write(Vec11.Z);
bw.Write(Vec11.W);
bw.Write(Vec12.X);
bw.Write(Vec12.Y);
bw.Write(Vec12.Z);
bw.Write(Vec12.W);
bw.Write(Vec13.X);
bw.Write(Vec13.Y);
bw.Write(Vec13.Z);
bw.Write(Vec13.W);
bw.Write(UnkVec1.X);
bw.Write(UnkVec1.Y);
bw.Write(UnkVec1.Z);
bw.Write(UnkVec1.W);
bw.Write(UnkVec2.X);
bw.Write(UnkVec2.Y);
bw.Write(UnkVec2.Z);
bw.Write(UnkVec2.W);
bw.Write(UnkVec3.X);
bw.Write(UnkVec3.Y);
bw.Write(UnkVec3.Z);
bw.Write(UnkVec3.W);
bw.Write(Flags05.Value);
bw.Write(Flags2.Value);
bw.Write(Unk14);
bw.Write(Unk15);
bw.Write(HashesCount);

View File

@ -31,6 +31,8 @@ namespace CodeWalker.World
public List<AudioPlacement> Emitters = new List<AudioPlacement>();
public List<AudioPlacement> AllItems = new List<AudioPlacement>();
public List<RelFile> AllFiles = new List<RelFile>();
public Dictionary<RelFile, AudioPlacement[]> PlacementsDict = new Dictionary<RelFile, AudioPlacement[]>();
public void Init(GameFileCache gameFileCache, Action<string> updateStatus)
@ -67,23 +69,20 @@ namespace CodeWalker.World
}
}
List<AudioPlacement> placements = new List<AudioPlacement>();
foreach (var dat151entry in datrelentries.Values)
{
var relfile = rpfman.GetFile<RelFile>(dat151entry);
if (relfile != null)
{
foreach (var reldata in relfile.RelDatas)
{
if (reldata is Dat151AmbientZone)
{
Zones.Add(new AudioPlacement(relfile, reldata as Dat151AmbientZone));
}
else if (reldata is Dat151AmbientEmitter)
{
Emitters.Add(new AudioPlacement(relfile, reldata as Dat151AmbientEmitter));
}
}
AllFiles.Add(relfile);
placements.Clear();
CreatePlacements(relfile, placements, true);
PlacementsDict[relfile] = placements.ToArray();
}
}
@ -119,6 +118,49 @@ namespace CodeWalker.World
}
}
private void CreatePlacements(RelFile relfile, List<AudioPlacement> placements, bool addtoLists = false)
{
foreach (var reldata in relfile.RelDatas)
{
AudioPlacement placement = null;
if (reldata is Dat151AmbientZone)
{
placement = new AudioPlacement(relfile, reldata as Dat151AmbientZone);
if (addtoLists) Zones.Add(placement);
}
else if (reldata is Dat151AmbientEmitter)
{
placement = new AudioPlacement(relfile, reldata as Dat151AmbientEmitter);
if (addtoLists) Emitters.Add(placement);
}
if (placement != null)
{
placements.Add(placement);
}
}
}
public void GetPlacements(List<RelFile> relfiles, List<AudioPlacement> placements)
{
foreach (var relfile in relfiles)
{
AudioPlacement[] fileplacements = null;
if (!PlacementsDict.TryGetValue(relfile, out fileplacements))
{
List<AudioPlacement> newplacements = new List<AudioPlacement>();
CreatePlacements(relfile, newplacements);
fileplacements = newplacements.ToArray();
PlacementsDict[relfile] = fileplacements;
}
if (fileplacements != null)
{
placements.AddRange(fileplacements);
}
}
}
}
@ -157,11 +199,30 @@ namespace CodeWalker.World
{
RelFile = rel;
AudioZone = zone;
Shape = zone.Shape;
ShortTypeName = "AudioZone";
FullTypeName = "Audio Zone";
UpdateFromZone();
}
public AudioPlacement(RelFile rel, Dat151AmbientEmitter emitter)
{
RelFile = rel;
AudioEmitter = emitter;
ShortTypeName = "AudioEmitter";
FullTypeName = "Audio Emitter";
UpdateFromEmitter();
}
public void UpdateFromZone()
{
if (AudioZone == null) return;
var zone = AudioZone;
Name = zone.Name;
NameHash = zone.NameHash;
Shape = zone.Shape;
float deg2rad = (float)(Math.PI / 180.0);
@ -205,16 +266,17 @@ namespace CodeWalker.World
{
Position = InnerPos;
}
}
public AudioPlacement(RelFile rel, Dat151AmbientEmitter emitter)
public void UpdateFromEmitter()
{
RelFile = rel;
AudioEmitter = emitter;
Shape = Dat151ZoneShape.Sphere;
ShortTypeName = "AudioEmitter";
FullTypeName = "Audio Emitter";
if (AudioEmitter == null) return;
var emitter = AudioEmitter;
Name = emitter.Name;
NameHash = emitter.NameHash;
Shape = Dat151ZoneShape.Sphere;
Orientation = Quaternion.Identity;
OrientationInv = Quaternion.Identity;
@ -230,6 +292,7 @@ namespace CodeWalker.World
}
Position = InnerPos;
HitSphereRad = InnerRad;// useouter ? OuterRad : InnerRad;
}
@ -240,16 +303,39 @@ namespace CodeWalker.World
InnerPos = pos;
OuterPos += delta;
Position = useouter ? OuterPos : InnerPos;
if (AudioZone != null)
{
AudioZone.InnerPos = InnerPos;
AudioZone.OuterPos = OuterPos;
}
if (AudioEmitter != null)
{
AudioEmitter.Position = InnerPos;
}
}
public void SetOrientation(Quaternion ori)
{
Orientation = ori;
OrientationInv = Quaternion.Invert(ori);
Vector3 t = ori.Multiply(Vector3.UnitX);
float angl = (float)Math.Atan2(t.Y, t.X);
while (angl < 0) angl += ((float)Math.PI * 2.0f);
float rad2deg = (float)(180.0 / Math.PI);
float dangl = angl * rad2deg;
uint uangl = (uint)dangl;
if (InnerOri == OuterOri)
{
InnerOri = Orientation;
OuterOri = Orientation;
if (AudioZone != null)
{
AudioZone.InnerAngle = uangl;
AudioZone.OuterAngle = uangl;
}
}
else
{
@ -259,10 +345,18 @@ namespace CodeWalker.World
if (useouter)
{
OuterOri = Orientation;
if (AudioZone != null)
{
AudioZone.OuterAngle = uangl;
}
}
else
{
InnerOri = Orientation;
if (AudioZone != null)
{
AudioZone.InnerAngle = uangl;
}
}
}
}

View File

@ -31,13 +31,21 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RelForm));
this.RelPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
this.MainTabControl = new System.Windows.Forms.TabControl();
this.DetailsTabPage = new System.Windows.Forms.TabPage();
this.NameTableTabPage = new System.Windows.Forms.TabPage();
this.MainTextBox = new CodeWalker.WinForms.TextBoxFix();
this.DetailsTabPage = new System.Windows.Forms.TabPage();
this.CloseButton = new System.Windows.Forms.Button();
this.SearchTabPage = new System.Windows.Forms.TabPage();
this.SearchResultsGrid = new CodeWalker.WinForms.PropertyGridFix();
this.label12 = new System.Windows.Forms.Label();
this.SearchTextBox = new System.Windows.Forms.TextBox();
this.SearchButton = new System.Windows.Forms.Button();
this.SearchHashRadio = new System.Windows.Forms.RadioButton();
this.SearchTextRadio = new System.Windows.Forms.RadioButton();
this.MainTabControl.SuspendLayout();
this.NameTableTabPage.SuspendLayout();
this.DetailsTabPage.SuspendLayout();
this.NameTableTabPage.SuspendLayout();
this.SearchTabPage.SuspendLayout();
this.SuspendLayout();
//
// RelPropertyGrid
@ -58,6 +66,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.MainTabControl.Controls.Add(this.DetailsTabPage);
this.MainTabControl.Controls.Add(this.NameTableTabPage);
this.MainTabControl.Controls.Add(this.SearchTabPage);
this.MainTabControl.Location = new System.Drawing.Point(5, 5);
this.MainTabControl.Margin = new System.Windows.Forms.Padding(0);
this.MainTabControl.Name = "MainTabControl";
@ -65,6 +74,17 @@
this.MainTabControl.Size = new System.Drawing.Size(664, 394);
this.MainTabControl.TabIndex = 1;
//
// DetailsTabPage
//
this.DetailsTabPage.Controls.Add(this.RelPropertyGrid);
this.DetailsTabPage.Location = new System.Drawing.Point(4, 22);
this.DetailsTabPage.Name = "DetailsTabPage";
this.DetailsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.DetailsTabPage.Size = new System.Drawing.Size(656, 368);
this.DetailsTabPage.TabIndex = 1;
this.DetailsTabPage.Text = "Details";
this.DetailsTabPage.UseVisualStyleBackColor = true;
//
// NameTableTabPage
//
this.NameTableTabPage.Controls.Add(this.MainTextBox);
@ -91,17 +111,6 @@
this.MainTextBox.TabIndex = 1;
this.MainTextBox.WordWrap = false;
//
// DetailsTabPage
//
this.DetailsTabPage.Controls.Add(this.RelPropertyGrid);
this.DetailsTabPage.Location = new System.Drawing.Point(4, 22);
this.DetailsTabPage.Name = "DetailsTabPage";
this.DetailsTabPage.Padding = new System.Windows.Forms.Padding(3);
this.DetailsTabPage.Size = new System.Drawing.Size(656, 368);
this.DetailsTabPage.TabIndex = 1;
this.DetailsTabPage.Text = "Details";
this.DetailsTabPage.UseVisualStyleBackColor = true;
//
// CloseButton
//
this.CloseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@ -113,6 +122,86 @@
this.CloseButton.UseVisualStyleBackColor = true;
this.CloseButton.Click += new System.EventHandler(this.CloseButton_Click);
//
// SearchTabPage
//
this.SearchTabPage.Controls.Add(this.SearchTextRadio);
this.SearchTabPage.Controls.Add(this.SearchHashRadio);
this.SearchTabPage.Controls.Add(this.label12);
this.SearchTabPage.Controls.Add(this.SearchTextBox);
this.SearchTabPage.Controls.Add(this.SearchButton);
this.SearchTabPage.Controls.Add(this.SearchResultsGrid);
this.SearchTabPage.Location = new System.Drawing.Point(4, 22);
this.SearchTabPage.Name = "SearchTabPage";
this.SearchTabPage.Size = new System.Drawing.Size(656, 368);
this.SearchTabPage.TabIndex = 2;
this.SearchTabPage.Text = "Search";
this.SearchTabPage.UseVisualStyleBackColor = true;
//
// SearchResultsGrid
//
this.SearchResultsGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.SearchResultsGrid.HelpVisible = false;
this.SearchResultsGrid.Location = new System.Drawing.Point(3, 31);
this.SearchResultsGrid.Name = "SearchResultsGrid";
this.SearchResultsGrid.Size = new System.Drawing.Size(647, 331);
this.SearchResultsGrid.TabIndex = 1;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(8, 6);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(30, 13);
this.label12.TabIndex = 32;
this.label12.Text = "Find:";
//
// SearchTextBox
//
this.SearchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.SearchTextBox.Location = new System.Drawing.Point(44, 3);
this.SearchTextBox.Name = "SearchTextBox";
this.SearchTextBox.Size = new System.Drawing.Size(237, 20);
this.SearchTextBox.TabIndex = 33;
this.SearchTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SearchTextBox_KeyDown);
//
// SearchButton
//
this.SearchButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SearchButton.Location = new System.Drawing.Point(395, 2);
this.SearchButton.Name = "SearchButton";
this.SearchButton.Size = new System.Drawing.Size(68, 23);
this.SearchButton.TabIndex = 34;
this.SearchButton.Text = "Search";
this.SearchButton.UseVisualStyleBackColor = true;
this.SearchButton.Click += new System.EventHandler(this.SearchButton_Click);
//
// SearchHashRadio
//
this.SearchHashRadio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SearchHashRadio.AutoSize = true;
this.SearchHashRadio.Checked = true;
this.SearchHashRadio.Location = new System.Drawing.Point(287, 4);
this.SearchHashRadio.Name = "SearchHashRadio";
this.SearchHashRadio.Size = new System.Drawing.Size(50, 17);
this.SearchHashRadio.TabIndex = 35;
this.SearchHashRadio.TabStop = true;
this.SearchHashRadio.Text = "Hash";
this.SearchHashRadio.UseVisualStyleBackColor = true;
//
// SearchTextRadio
//
this.SearchTextRadio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.SearchTextRadio.AutoSize = true;
this.SearchTextRadio.Location = new System.Drawing.Point(343, 4);
this.SearchTextRadio.Name = "SearchTextRadio";
this.SearchTextRadio.Size = new System.Drawing.Size(46, 17);
this.SearchTextRadio.TabIndex = 36;
this.SearchTextRadio.Text = "Text";
this.SearchTextRadio.UseVisualStyleBackColor = true;
//
// RelForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -124,9 +213,11 @@
this.Name = "RelForm";
this.Text = "REL Viewer - CodeWalker by dexyfex";
this.MainTabControl.ResumeLayout(false);
this.DetailsTabPage.ResumeLayout(false);
this.NameTableTabPage.ResumeLayout(false);
this.NameTableTabPage.PerformLayout();
this.DetailsTabPage.ResumeLayout(false);
this.SearchTabPage.ResumeLayout(false);
this.SearchTabPage.PerformLayout();
this.ResumeLayout(false);
}
@ -139,5 +230,12 @@
private System.Windows.Forms.TabPage DetailsTabPage;
private WinForms.TextBoxFix MainTextBox;
private System.Windows.Forms.Button CloseButton;
private System.Windows.Forms.TabPage SearchTabPage;
private WinForms.PropertyGridFix SearchResultsGrid;
private System.Windows.Forms.RadioButton SearchTextRadio;
private System.Windows.Forms.RadioButton SearchHashRadio;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox SearchTextBox;
private System.Windows.Forms.Button SearchButton;
}
}

View File

@ -27,6 +27,8 @@ namespace CodeWalker.Forms
}
public string FilePath { get; set; }
private RelFile CurrentFile { get; set; }
public RelForm()
@ -55,6 +57,8 @@ namespace CodeWalker.Forms
RelPropertyGrid.SelectedObject = rel;
CurrentFile = rel;
StringBuilder sb = new StringBuilder();
if (rel != null)
@ -100,9 +104,85 @@ namespace CodeWalker.Forms
}
private void Search()
{
SearchResultsGrid.SelectedObject = null;
if (CurrentFile?.RelDatasSorted == null) return;
bool textsearch = SearchTextRadio.Checked;
var text = SearchTextBox.Text;
var textl = text.ToLowerInvariant();
uint hash = 0;
uint hashl = 0;
if (!uint.TryParse(text, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(text);
JenkIndex.Ensure(text);
hashl = JenkHash.GenHash(textl);
JenkIndex.Ensure(textl);
}
else
{
hashl = hash;
}
var results = new List<RelData>();
foreach (var rd in CurrentFile.RelDatasSorted)
{
if (textsearch)
{
if (((rd.Name?.ToLowerInvariant().Contains(textl))??false) || (rd.NameHash == hash) || (rd.NameHash == hashl) ||
(rd.NameHash.ToString().ToLowerInvariant().Contains(textl)))
{
results.Add(rd);
}
}
else
{
if ((rd.NameHash == hash)||(rd.NameHash == hashl))
{
SearchResultsGrid.SelectedObject = rd;
return;
}
}
}
if (textsearch && (results.Count > 0))
{
SearchResultsGrid.SelectedObject = results.ToArray();
}
else
{
SearchResultsGrid.SelectedObject = null;
}
}
private void CloseButton_Click(object sender, EventArgs e)
{
Close();
}
private void SearchButton_Click(object sender, EventArgs e)
{
Search();
}
private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Search();
}
}
}
}

View File

@ -25,6 +25,7 @@ namespace CodeWalker.Project.Panels
public void SetEmitterList(Dat151AmbientEmitterList list)
{
CurrentEmitterList = list;
Tag = list;
UpdateFormTitle();
}

View File

@ -25,6 +25,7 @@ namespace CodeWalker.Project.Panels
public void SetEmitter(AudioPlacement emitter)
{
CurrentEmitter = emitter;
Tag = emitter;
UpdateFormTitle();
}

View File

@ -25,6 +25,7 @@ namespace CodeWalker.Project.Panels
public void SetFile(RelFile file)
{
CurrentFile = file;
Tag = file;
UpdateFormTitle();
}

View File

@ -29,20 +29,83 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditAudioZoneListPanel));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.label19 = new System.Windows.Forms.Label();
this.HashesTextBox = new CodeWalker.WinForms.TextBoxFix();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Location = new System.Drawing.Point(2, 3);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(559, 446);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.label19);
this.tabPage1.Controls.Add(this.HashesTextBox);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(551, 420);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Ambient Zone List";
this.tabPage1.UseVisualStyleBackColor = true;
//
// label19
//
this.label19.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(11, 11);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(72, 13);
this.label19.TabIndex = 72;
this.label19.Text = "Zone hashes:";
//
// HashesTextBox
//
this.HashesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.HashesTextBox.Location = new System.Drawing.Point(6, 28);
this.HashesTextBox.Multiline = true;
this.HashesTextBox.Name = "HashesTextBox";
this.HashesTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.HashesTextBox.Size = new System.Drawing.Size(428, 330);
this.HashesTextBox.TabIndex = 73;
this.HashesTextBox.WordWrap = false;
this.HashesTextBox.TextChanged += new System.EventHandler(this.HashesTextBox_TextChanged);
//
// EditAudioZoneListPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(562, 450);
this.Controls.Add(this.tabControl1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "EditAudioZoneListPanel";
this.Text = "Edit Audio Zone List";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.Label label19;
private WinForms.TextBoxFix HashesTextBox;
}
}

View File

@ -16,6 +16,9 @@ namespace CodeWalker.Project.Panels
public ProjectForm ProjectForm;
public Dat151AmbientZoneList CurrentZoneList { get; set; }
private bool populatingui = false;
public EditAudioZoneListPanel(ProjectForm owner)
{
ProjectForm = owner;
@ -25,7 +28,9 @@ namespace CodeWalker.Project.Panels
public void SetZoneList(Dat151AmbientZoneList list)
{
CurrentZoneList = list;
Tag = list;
UpdateFormTitle();
UpdateUI();
}
private void UpdateFormTitle()
@ -33,5 +38,80 @@ namespace CodeWalker.Project.Panels
Text = CurrentZoneList?.NameHash.ToString() ?? "";
}
private void UpdateUI()
{
if (CurrentZoneList == null)
{
//AddToProjectButton.Enabled = false;
//DeleteButton.Enabled = false;
populatingui = true;
HashesTextBox.Text = string.Empty;
populatingui = false;
}
else
{
//AddToProjectButton.Enabled = CurrentZoneList?.Rel != null ? !ProjectForm.AudioFileExistsInProject(CurrentZoneList.Rel) : false;
//DeleteButton.Enabled = !AddToProjectButton.Enabled;
populatingui = true;
var zl = CurrentZoneList;
StringBuilder sb = new StringBuilder();
if (zl.ZoneHashes != null)
{
foreach (var hash in zl.ZoneHashes)
{
sb.AppendLine(hash.ToString());
}
}
HashesTextBox.Text = sb.ToString();
populatingui = false;
}
}
private void ProjectItemChanged()
{
if (CurrentZoneList?.Rel != null)
{
ProjectForm.SetAudioFileHasChanged(true);
}
}
private void HashesTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZoneList == null) return;
var hashstrs = HashesTextBox.Text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
if (hashstrs?.Length > 0)
{
var hashlist = new List<MetaHash>();
foreach (var hashstr in hashstrs)
{
uint hash = 0;
if (!uint.TryParse(hashstr, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(hashstr);
JenkIndex.Ensure(hashstr);
}
hashlist.Add(hash);
}
CurrentZoneList.ZoneHashes = hashlist.ToArray();
CurrentZoneList.ZoneCount = (byte)hashlist.Count;
ProjectItemChanged();
}
}
}
}

View File

@ -31,7 +31,57 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EditAudioZonePanel));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.DeleteButton = new System.Windows.Forms.Button();
this.AddToProjectButton = new System.Windows.Forms.Button();
this.label21 = new System.Windows.Forms.Label();
this.Flags2TextBox = new System.Windows.Forms.TextBox();
this.label20 = new System.Windows.Forms.Label();
this.ExtParamsTextBox = new CodeWalker.WinForms.TextBoxFix();
this.label19 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.UnkVec3TextBox = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label();
this.UnkVec2TextBox = new System.Windows.Forms.TextBox();
this.label18 = new System.Windows.Forms.Label();
this.UnkVec1TextBox = new System.Windows.Forms.TextBox();
this.HashesTextBox = new CodeWalker.WinForms.TextBoxFix();
this.label14 = new System.Windows.Forms.Label();
this.Flags1TextBox = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label();
this.Flags0TextBox = new System.Windows.Forms.TextBox();
this.ShapeComboBox = new System.Windows.Forms.ComboBox();
this.label23 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.NameTextBox = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.OuterVec3TextBox = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.OuterVec2TextBox = new System.Windows.Forms.TextBox();
this.label8 = new System.Windows.Forms.Label();
this.OuterVec1TextBox = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.OuterAngleTextBox = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.OuterSizeTextBox = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.OuterPosTextBox = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.InnerVec3TextBox = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.InnerVec2TextBox = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.InnerVec1TextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.InnerAngleTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.InnerSizeTextBox = new System.Windows.Forms.TextBox();
this.label16 = new System.Windows.Forms.Label();
this.InnerPosTextBox = new System.Windows.Forms.TextBox();
this.GoToButton = new System.Windows.Forms.Button();
this.label22 = new System.Windows.Forms.Label();
this.UnkBytesTextBox = new System.Windows.Forms.TextBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
@ -48,24 +98,555 @@
//
// tabPage1
//
this.tabPage1.Controls.Add(this.label22);
this.tabPage1.Controls.Add(this.UnkBytesTextBox);
this.tabPage1.Controls.Add(this.DeleteButton);
this.tabPage1.Controls.Add(this.AddToProjectButton);
this.tabPage1.Controls.Add(this.label21);
this.tabPage1.Controls.Add(this.Flags2TextBox);
this.tabPage1.Controls.Add(this.label20);
this.tabPage1.Controls.Add(this.ExtParamsTextBox);
this.tabPage1.Controls.Add(this.label19);
this.tabPage1.Controls.Add(this.label15);
this.tabPage1.Controls.Add(this.UnkVec3TextBox);
this.tabPage1.Controls.Add(this.label17);
this.tabPage1.Controls.Add(this.UnkVec2TextBox);
this.tabPage1.Controls.Add(this.label18);
this.tabPage1.Controls.Add(this.UnkVec1TextBox);
this.tabPage1.Controls.Add(this.HashesTextBox);
this.tabPage1.Controls.Add(this.label14);
this.tabPage1.Controls.Add(this.Flags1TextBox);
this.tabPage1.Controls.Add(this.label13);
this.tabPage1.Controls.Add(this.Flags0TextBox);
this.tabPage1.Controls.Add(this.ShapeComboBox);
this.tabPage1.Controls.Add(this.label23);
this.tabPage1.Controls.Add(this.label12);
this.tabPage1.Controls.Add(this.NameTextBox);
this.tabPage1.Controls.Add(this.label6);
this.tabPage1.Controls.Add(this.OuterVec3TextBox);
this.tabPage1.Controls.Add(this.label7);
this.tabPage1.Controls.Add(this.OuterVec2TextBox);
this.tabPage1.Controls.Add(this.label8);
this.tabPage1.Controls.Add(this.OuterVec1TextBox);
this.tabPage1.Controls.Add(this.label9);
this.tabPage1.Controls.Add(this.OuterAngleTextBox);
this.tabPage1.Controls.Add(this.label10);
this.tabPage1.Controls.Add(this.OuterSizeTextBox);
this.tabPage1.Controls.Add(this.label11);
this.tabPage1.Controls.Add(this.OuterPosTextBox);
this.tabPage1.Controls.Add(this.label5);
this.tabPage1.Controls.Add(this.InnerVec3TextBox);
this.tabPage1.Controls.Add(this.label4);
this.tabPage1.Controls.Add(this.InnerVec2TextBox);
this.tabPage1.Controls.Add(this.label3);
this.tabPage1.Controls.Add(this.InnerVec1TextBox);
this.tabPage1.Controls.Add(this.label2);
this.tabPage1.Controls.Add(this.InnerAngleTextBox);
this.tabPage1.Controls.Add(this.label1);
this.tabPage1.Controls.Add(this.InnerSizeTextBox);
this.tabPage1.Controls.Add(this.label16);
this.tabPage1.Controls.Add(this.InnerPosTextBox);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(551, 421);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Ambient Emitter";
this.tabPage1.Text = "Ambient Zone";
this.tabPage1.UseVisualStyleBackColor = true;
//
// DeleteButton
//
this.DeleteButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.DeleteButton.Location = new System.Drawing.Point(343, 3);
this.DeleteButton.Name = "DeleteButton";
this.DeleteButton.Size = new System.Drawing.Size(93, 23);
this.DeleteButton.TabIndex = 75;
this.DeleteButton.Text = "Delete zone";
this.DeleteButton.UseVisualStyleBackColor = true;
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
//
// AddToProjectButton
//
this.AddToProjectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.AddToProjectButton.Location = new System.Drawing.Point(452, 3);
this.AddToProjectButton.Name = "AddToProjectButton";
this.AddToProjectButton.Size = new System.Drawing.Size(93, 23);
this.AddToProjectButton.TabIndex = 74;
this.AddToProjectButton.Text = "Add to project";
this.AddToProjectButton.UseVisualStyleBackColor = true;
this.AddToProjectButton.Click += new System.EventHandler(this.AddToProjectButton_Click);
//
// label21
//
this.label21.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label21.AutoSize = true;
this.label21.Location = new System.Drawing.Point(340, 106);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(44, 13);
this.label21.TabIndex = 68;
this.label21.Text = "Flags 2:";
//
// Flags2TextBox
//
this.Flags2TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Flags2TextBox.Location = new System.Drawing.Point(390, 103);
this.Flags2TextBox.Name = "Flags2TextBox";
this.Flags2TextBox.Size = new System.Drawing.Size(155, 20);
this.Flags2TextBox.TabIndex = 69;
this.Flags2TextBox.TextChanged += new System.EventHandler(this.Flags2TextBox_TextChanged);
//
// label20
//
this.label20.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(340, 278);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(193, 13);
this.label20.TabIndex = 72;
this.label20.Text = "Ext params: Name (hash), Value (float)";
//
// ExtParamsTextBox
//
this.ExtParamsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.ExtParamsTextBox.Location = new System.Drawing.Point(335, 295);
this.ExtParamsTextBox.Multiline = true;
this.ExtParamsTextBox.Name = "ExtParamsTextBox";
this.ExtParamsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.ExtParamsTextBox.Size = new System.Drawing.Size(209, 116);
this.ExtParamsTextBox.TabIndex = 73;
this.ExtParamsTextBox.WordWrap = false;
this.ExtParamsTextBox.TextChanged += new System.EventHandler(this.ExtParamsTextBox_TextChanged);
//
// label19
//
this.label19.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(340, 134);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(46, 13);
this.label19.TabIndex = 70;
this.label19.Text = "Hashes:";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(7, 394);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(60, 13);
this.label15.TabIndex = 62;
this.label15.Text = "Unk vec 3:";
//
// UnkVec3TextBox
//
this.UnkVec3TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.UnkVec3TextBox.Location = new System.Drawing.Point(84, 391);
this.UnkVec3TextBox.Name = "UnkVec3TextBox";
this.UnkVec3TextBox.Size = new System.Drawing.Size(237, 20);
this.UnkVec3TextBox.TabIndex = 63;
this.UnkVec3TextBox.TextChanged += new System.EventHandler(this.UnkVec3TextBox_TextChanged);
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(7, 370);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(60, 13);
this.label17.TabIndex = 60;
this.label17.Text = "Unk vec 2:";
//
// UnkVec2TextBox
//
this.UnkVec2TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.UnkVec2TextBox.Location = new System.Drawing.Point(84, 367);
this.UnkVec2TextBox.Name = "UnkVec2TextBox";
this.UnkVec2TextBox.Size = new System.Drawing.Size(237, 20);
this.UnkVec2TextBox.TabIndex = 61;
this.UnkVec2TextBox.TextChanged += new System.EventHandler(this.UnkVec2TextBox_TextChanged);
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(7, 346);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(60, 13);
this.label18.TabIndex = 58;
this.label18.Text = "Unk vec 1:";
//
// UnkVec1TextBox
//
this.UnkVec1TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.UnkVec1TextBox.Location = new System.Drawing.Point(84, 343);
this.UnkVec1TextBox.Name = "UnkVec1TextBox";
this.UnkVec1TextBox.Size = new System.Drawing.Size(237, 20);
this.UnkVec1TextBox.TabIndex = 59;
this.UnkVec1TextBox.TextChanged += new System.EventHandler(this.UnkVec1TextBox_TextChanged);
//
// HashesTextBox
//
this.HashesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.HashesTextBox.Location = new System.Drawing.Point(335, 151);
this.HashesTextBox.Multiline = true;
this.HashesTextBox.Name = "HashesTextBox";
this.HashesTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.HashesTextBox.Size = new System.Drawing.Size(209, 116);
this.HashesTextBox.TabIndex = 71;
this.HashesTextBox.WordWrap = false;
this.HashesTextBox.TextChanged += new System.EventHandler(this.HashesTextBox_TextChanged);
//
// label14
//
this.label14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(340, 82);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(44, 13);
this.label14.TabIndex = 66;
this.label14.Text = "Flags 1:";
//
// Flags1TextBox
//
this.Flags1TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Flags1TextBox.Location = new System.Drawing.Point(390, 79);
this.Flags1TextBox.Name = "Flags1TextBox";
this.Flags1TextBox.Size = new System.Drawing.Size(155, 20);
this.Flags1TextBox.TabIndex = 67;
this.Flags1TextBox.TextChanged += new System.EventHandler(this.Flags1TextBox_TextChanged);
//
// label13
//
this.label13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(340, 58);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(44, 13);
this.label13.TabIndex = 64;
this.label13.Text = "Flags 0:";
//
// Flags0TextBox
//
this.Flags0TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.Flags0TextBox.Location = new System.Drawing.Point(390, 55);
this.Flags0TextBox.Name = "Flags0TextBox";
this.Flags0TextBox.Size = new System.Drawing.Size(155, 20);
this.Flags0TextBox.TabIndex = 65;
this.Flags0TextBox.TextChanged += new System.EventHandler(this.Flags0TextBox_TextChanged);
//
// ShapeComboBox
//
this.ShapeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ShapeComboBox.FormattingEnabled = true;
this.ShapeComboBox.Items.AddRange(new object[] {
"Box",
"Line",
"Sphere"});
this.ShapeComboBox.Location = new System.Drawing.Point(84, 30);
this.ShapeComboBox.Name = "ShapeComboBox";
this.ShapeComboBox.Size = new System.Drawing.Size(151, 21);
this.ShapeComboBox.TabIndex = 33;
this.ShapeComboBox.SelectedIndexChanged += new System.EventHandler(this.ShapeComboBox_SelectedIndexChanged);
//
// label23
//
this.label23.AutoSize = true;
this.label23.Location = new System.Drawing.Point(7, 33);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(41, 13);
this.label23.TabIndex = 32;
this.label23.Text = "Shape:";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(7, 9);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(64, 13);
this.label12.TabIndex = 29;
this.label12.Text = "Name hash:";
//
// NameTextBox
//
this.NameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.NameTextBox.Location = new System.Drawing.Point(84, 6);
this.NameTextBox.Name = "NameTextBox";
this.NameTextBox.Size = new System.Drawing.Size(237, 20);
this.NameTextBox.TabIndex = 30;
this.NameTextBox.TextChanged += new System.EventHandler(this.NameTextBox_TextChanged);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(7, 322);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(66, 13);
this.label6.TabIndex = 56;
this.label6.Text = "Outer vec 3:";
//
// OuterVec3TextBox
//
this.OuterVec3TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.OuterVec3TextBox.Location = new System.Drawing.Point(84, 319);
this.OuterVec3TextBox.Name = "OuterVec3TextBox";
this.OuterVec3TextBox.Size = new System.Drawing.Size(237, 20);
this.OuterVec3TextBox.TabIndex = 57;
this.OuterVec3TextBox.TextChanged += new System.EventHandler(this.OuterVec3TextBox_TextChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(7, 298);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(66, 13);
this.label7.TabIndex = 54;
this.label7.Text = "Outer vec 2:";
//
// OuterVec2TextBox
//
this.OuterVec2TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.OuterVec2TextBox.Location = new System.Drawing.Point(84, 295);
this.OuterVec2TextBox.Name = "OuterVec2TextBox";
this.OuterVec2TextBox.Size = new System.Drawing.Size(237, 20);
this.OuterVec2TextBox.TabIndex = 55;
this.OuterVec2TextBox.TextChanged += new System.EventHandler(this.OuterVec2TextBox_TextChanged);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(7, 274);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(66, 13);
this.label8.TabIndex = 52;
this.label8.Text = "Outer vec 1:";
//
// OuterVec1TextBox
//
this.OuterVec1TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.OuterVec1TextBox.Location = new System.Drawing.Point(84, 271);
this.OuterVec1TextBox.Name = "OuterVec1TextBox";
this.OuterVec1TextBox.Size = new System.Drawing.Size(237, 20);
this.OuterVec1TextBox.TabIndex = 53;
this.OuterVec1TextBox.TextChanged += new System.EventHandler(this.OuterVec1TextBox_TextChanged);
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(7, 250);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(65, 13);
this.label9.TabIndex = 50;
this.label9.Text = "Outer angle:";
//
// OuterAngleTextBox
//
this.OuterAngleTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.OuterAngleTextBox.Location = new System.Drawing.Point(84, 247);
this.OuterAngleTextBox.Name = "OuterAngleTextBox";
this.OuterAngleTextBox.Size = new System.Drawing.Size(237, 20);
this.OuterAngleTextBox.TabIndex = 51;
this.OuterAngleTextBox.TextChanged += new System.EventHandler(this.OuterAngleTextBox_TextChanged);
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(7, 226);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(57, 13);
this.label10.TabIndex = 48;
this.label10.Text = "Outer size:";
//
// OuterSizeTextBox
//
this.OuterSizeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.OuterSizeTextBox.Location = new System.Drawing.Point(84, 223);
this.OuterSizeTextBox.Name = "OuterSizeTextBox";
this.OuterSizeTextBox.Size = new System.Drawing.Size(237, 20);
this.OuterSizeTextBox.TabIndex = 49;
this.OuterSizeTextBox.TextChanged += new System.EventHandler(this.OuterSizeTextBox_TextChanged);
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(7, 202);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(75, 13);
this.label11.TabIndex = 46;
this.label11.Text = "Outer position:";
//
// OuterPosTextBox
//
this.OuterPosTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.OuterPosTextBox.Location = new System.Drawing.Point(84, 199);
this.OuterPosTextBox.Name = "OuterPosTextBox";
this.OuterPosTextBox.Size = new System.Drawing.Size(237, 20);
this.OuterPosTextBox.TabIndex = 47;
this.OuterPosTextBox.TextChanged += new System.EventHandler(this.OuterPosTextBox_TextChanged);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(7, 178);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(64, 13);
this.label5.TabIndex = 44;
this.label5.Text = "Inner vec 3:";
//
// InnerVec3TextBox
//
this.InnerVec3TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.InnerVec3TextBox.Location = new System.Drawing.Point(84, 175);
this.InnerVec3TextBox.Name = "InnerVec3TextBox";
this.InnerVec3TextBox.Size = new System.Drawing.Size(237, 20);
this.InnerVec3TextBox.TabIndex = 45;
this.InnerVec3TextBox.TextChanged += new System.EventHandler(this.InnerVec3TextBox_TextChanged);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(7, 154);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 13);
this.label4.TabIndex = 42;
this.label4.Text = "Inner vec 2:";
//
// InnerVec2TextBox
//
this.InnerVec2TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.InnerVec2TextBox.Location = new System.Drawing.Point(84, 151);
this.InnerVec2TextBox.Name = "InnerVec2TextBox";
this.InnerVec2TextBox.Size = new System.Drawing.Size(237, 20);
this.InnerVec2TextBox.TabIndex = 43;
this.InnerVec2TextBox.TextChanged += new System.EventHandler(this.InnerVec2TextBox_TextChanged);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(7, 130);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 13);
this.label3.TabIndex = 40;
this.label3.Text = "Inner vec 1:";
//
// InnerVec1TextBox
//
this.InnerVec1TextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.InnerVec1TextBox.Location = new System.Drawing.Point(84, 127);
this.InnerVec1TextBox.Name = "InnerVec1TextBox";
this.InnerVec1TextBox.Size = new System.Drawing.Size(237, 20);
this.InnerVec1TextBox.TabIndex = 41;
this.InnerVec1TextBox.TextChanged += new System.EventHandler(this.InnerVec1TextBox_TextChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(7, 106);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(63, 13);
this.label2.TabIndex = 38;
this.label2.Text = "Inner angle:";
//
// InnerAngleTextBox
//
this.InnerAngleTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.InnerAngleTextBox.Location = new System.Drawing.Point(84, 103);
this.InnerAngleTextBox.Name = "InnerAngleTextBox";
this.InnerAngleTextBox.Size = new System.Drawing.Size(237, 20);
this.InnerAngleTextBox.TabIndex = 39;
this.InnerAngleTextBox.TextChanged += new System.EventHandler(this.InnerAngleTextBox_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(7, 82);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 13);
this.label1.TabIndex = 36;
this.label1.Text = "Inner size:";
//
// InnerSizeTextBox
//
this.InnerSizeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.InnerSizeTextBox.Location = new System.Drawing.Point(84, 79);
this.InnerSizeTextBox.Name = "InnerSizeTextBox";
this.InnerSizeTextBox.Size = new System.Drawing.Size(237, 20);
this.InnerSizeTextBox.TabIndex = 37;
this.InnerSizeTextBox.TextChanged += new System.EventHandler(this.InnerSizeTextBox_TextChanged);
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(7, 58);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(73, 13);
this.label16.TabIndex = 34;
this.label16.Text = "Inner position:";
//
// InnerPosTextBox
//
this.InnerPosTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.InnerPosTextBox.Location = new System.Drawing.Point(84, 55);
this.InnerPosTextBox.Name = "InnerPosTextBox";
this.InnerPosTextBox.Size = new System.Drawing.Size(237, 20);
this.InnerPosTextBox.TabIndex = 35;
this.InnerPosTextBox.TextChanged += new System.EventHandler(this.InnerPosTextBox_TextChanged);
//
// GoToButton
//
this.GoToButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.GoToButton.Location = new System.Drawing.Point(483, 0);
this.GoToButton.Name = "GoToButton";
this.GoToButton.Size = new System.Drawing.Size(68, 23);
this.GoToButton.TabIndex = 31;
this.GoToButton.Text = "Go to";
this.GoToButton.UseVisualStyleBackColor = true;
this.GoToButton.Click += new System.EventHandler(this.GoToButton_Click);
//
// label22
//
this.label22.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label22.AutoSize = true;
this.label22.Location = new System.Drawing.Point(327, 34);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(58, 13);
this.label22.TabIndex = 76;
this.label22.Text = "Unk bytes:";
//
// UnkBytesTextBox
//
this.UnkBytesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.UnkBytesTextBox.Location = new System.Drawing.Point(390, 31);
this.UnkBytesTextBox.Name = "UnkBytesTextBox";
this.UnkBytesTextBox.Size = new System.Drawing.Size(155, 20);
this.UnkBytesTextBox.TabIndex = 77;
this.UnkBytesTextBox.TextChanged += new System.EventHandler(this.UnkBytesTextBox_TextChanged);
//
// EditAudioZonePanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(562, 450);
this.Controls.Add(this.GoToButton);
this.Controls.Add(this.tabControl1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "EditAudioZonePanel";
this.Text = "Edit Audio Zone";
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.ResumeLayout(false);
}
@ -73,5 +654,54 @@
#endregion
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.TextBox InnerPosTextBox;
private System.Windows.Forms.Button GoToButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox InnerSizeTextBox;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox InnerVec2TextBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox InnerVec1TextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox InnerAngleTextBox;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox InnerVec3TextBox;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox NameTextBox;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox OuterVec3TextBox;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox OuterVec2TextBox;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox OuterVec1TextBox;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox OuterAngleTextBox;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox OuterSizeTextBox;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox OuterPosTextBox;
private System.Windows.Forms.ComboBox ShapeComboBox;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.TextBox Flags1TextBox;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox Flags0TextBox;
private WinForms.TextBoxFix HashesTextBox;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TextBox UnkVec3TextBox;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.TextBox UnkVec2TextBox;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.TextBox UnkVec1TextBox;
private System.Windows.Forms.Label label20;
private WinForms.TextBoxFix ExtParamsTextBox;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.TextBox Flags2TextBox;
private System.Windows.Forms.Button AddToProjectButton;
private System.Windows.Forms.Button DeleteButton;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.TextBox UnkBytesTextBox;
}
}

View File

@ -1,9 +1,12 @@
using CodeWalker.World;
using CodeWalker.GameFiles;
using CodeWalker.World;
using SharpDX;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -16,6 +19,9 @@ namespace CodeWalker.Project.Panels
public ProjectForm ProjectForm;
public AudioPlacement CurrentZone { get; set; }
private bool populatingui = false;
public EditAudioZonePanel(ProjectForm owner)
{
ProjectForm = owner;
@ -25,7 +31,9 @@ namespace CodeWalker.Project.Panels
public void SetZone(AudioPlacement zone)
{
CurrentZone = zone;
Tag = zone;
UpdateFormTitle();
UpdateUI();
}
private void UpdateFormTitle()
@ -34,5 +42,533 @@ namespace CodeWalker.Project.Panels
}
private void UpdateUI()
{
if (CurrentZone?.AudioZone == null)
{
AddToProjectButton.Enabled = false;
DeleteButton.Enabled = false;
populatingui = true;
NameTextBox.Text = string.Empty;
ShapeComboBox.Text = string.Empty;
InnerPosTextBox.Text = string.Empty;
InnerSizeTextBox.Text = string.Empty;
InnerAngleTextBox.Text = string.Empty;
InnerVec1TextBox.Text = string.Empty;
InnerVec2TextBox.Text = string.Empty;
InnerVec3TextBox.Text = string.Empty;
OuterPosTextBox.Text = string.Empty;
OuterSizeTextBox.Text = string.Empty;
OuterAngleTextBox.Text = string.Empty;
OuterVec1TextBox.Text = string.Empty;
OuterVec2TextBox.Text = string.Empty;
OuterVec3TextBox.Text = string.Empty;
UnkVec1TextBox.Text = string.Empty;
UnkVec2TextBox.Text = string.Empty;
UnkVec3TextBox.Text = string.Empty;
UnkBytesTextBox.Text = string.Empty;
Flags0TextBox.Text = string.Empty;
Flags1TextBox.Text = string.Empty;
Flags2TextBox.Text = string.Empty;
HashesTextBox.Text = string.Empty;
ExtParamsTextBox.Text = string.Empty;
populatingui = false;
}
else
{
AddToProjectButton.Enabled = CurrentZone?.RelFile != null ? !ProjectForm.AudioFileExistsInProject(CurrentZone.RelFile) : false;
DeleteButton.Enabled = !AddToProjectButton.Enabled;
populatingui = true;
var z = CurrentZone.AudioZone;
NameTextBox.Text = z.NameHash.ToString();
ShapeComboBox.Text = z.Shape.ToString();
InnerPosTextBox.Text = FloatUtil.GetVector3String(z.InnerPos);
InnerSizeTextBox.Text = FloatUtil.GetVector3String(z.InnerSize);
InnerAngleTextBox.Text = z.InnerAngle.ToString();
InnerVec1TextBox.Text = FloatUtil.GetVector4String(z.InnerVec1);
InnerVec2TextBox.Text = FloatUtil.GetVector4String(z.InnerVec2);
InnerVec3TextBox.Text = FloatUtil.GetVector3String(z.InnerVec3);
OuterPosTextBox.Text = FloatUtil.GetVector3String(z.OuterPos);
OuterSizeTextBox.Text = FloatUtil.GetVector3String(z.OuterSize);
OuterAngleTextBox.Text = z.OuterAngle.ToString();
OuterVec1TextBox.Text = FloatUtil.GetVector4String(z.OuterVec1);
OuterVec2TextBox.Text = FloatUtil.GetVector4String(z.OuterVec2);
OuterVec3TextBox.Text = FloatUtil.GetVector3String(z.OuterVec3);
UnkVec1TextBox.Text = FloatUtil.GetVector4String(z.UnkVec1);
UnkVec2TextBox.Text = FloatUtil.GetVector4String(z.UnkVec2);
UnkVec3TextBox.Text = FloatUtil.GetVector4String(z.UnkVec3);
UnkBytesTextBox.Text = string.Format("{0}, {1}, {2}", z.Unk14, z.Unk15, z.Unk16);
Flags0TextBox.Text = z.Flags0.Hex;
Flags1TextBox.Text = z.Flags1.Hex;
Flags2TextBox.Text = z.Flags2.Hex;
StringBuilder sb = new StringBuilder();
if (z.Hashes != null)
{
foreach (var hash in z.Hashes)
{
sb.AppendLine(hash.ToString());
}
}
HashesTextBox.Text = sb.ToString();
sb.Clear();
if (z.ExtParams != null)
{
foreach (var extparam in z.ExtParams)
{
sb.Append(extparam.Hash.ToString());
sb.Append(", ");
sb.Append(FloatUtil.ToString(extparam.Value));
sb.AppendLine();
}
}
ExtParamsTextBox.Text = sb.ToString();
populatingui = false;
if (ProjectForm.WorldForm != null)
{
ProjectForm.WorldForm.SelectAudio(CurrentZone);
}
}
}
private void ProjectItemChanged()
{
CurrentZone?.UpdateFromZone();//also update the placement wrapper
if (CurrentZone?.RelFile != null)
{
ProjectForm.SetAudioFileHasChanged(true);
}
}
private void NameTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
uint hash = 0;
string name = NameTextBox.Text;
if (!uint.TryParse(name, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(name);
JenkIndex.Ensure(name);
}
//NameHashLabel.Text = "Hash: " + hash.ToString();
if (CurrentZone.AudioZone.NameHash != hash)
{
CurrentZone.AudioZone.Name = NameTextBox.Text;
CurrentZone.AudioZone.NameHash = hash;
ProjectItemChanged();
}
}
private void ShapeComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
Dat151ZoneShape shape = Dat151ZoneShape.Box;
if (Enum.TryParse<Dat151ZoneShape>(ShapeComboBox.Text, out shape))
{
if (CurrentZone.AudioZone.Shape != shape)
{
CurrentZone.AudioZone.Shape = shape;
ProjectItemChanged();
}
}
}
private void InnerPosTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector3String(InnerPosTextBox.Text);
if (CurrentZone.AudioZone.InnerPos != vec)
{
CurrentZone.AudioZone.InnerPos = vec;
ProjectItemChanged();
//var wf = ProjectForm.WorldForm;
//if (wf != null)
//{
// wf.BeginInvoke(new Action(() =>
// {
// wf.SetWidgetPosition(CurrentZone.Position, true);
// }));
//}
}
}
private void InnerSizeTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector3String(InnerSizeTextBox.Text);
if (CurrentZone.AudioZone.InnerSize != vec)
{
CurrentZone.AudioZone.InnerSize = vec;
ProjectItemChanged();
}
}
private void InnerAngleTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
uint ang = 0;
if (uint.TryParse(InnerAngleTextBox.Text, out ang))
{
if (CurrentZone.AudioZone.InnerAngle != ang)
{
CurrentZone.AudioZone.InnerAngle = ang;
ProjectItemChanged();
}
}
}
private void InnerVec1TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector4String(InnerVec1TextBox.Text);
if (CurrentZone.AudioZone.InnerVec1 != vec)
{
CurrentZone.AudioZone.InnerVec1 = vec;
ProjectItemChanged();
}
}
private void InnerVec2TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector4String(InnerVec2TextBox.Text);
if (CurrentZone.AudioZone.InnerVec2 != vec)
{
CurrentZone.AudioZone.InnerVec2 = vec;
ProjectItemChanged();
}
}
private void InnerVec3TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector3String(InnerVec3TextBox.Text);
if (CurrentZone.AudioZone.InnerVec3 != vec)
{
CurrentZone.AudioZone.InnerVec3 = vec;
ProjectItemChanged();
}
}
private void OuterPosTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector3String(OuterPosTextBox.Text);
if (CurrentZone.AudioZone.OuterPos != vec)
{
CurrentZone.AudioZone.OuterPos = vec;
ProjectItemChanged();
}
}
private void OuterSizeTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector3String(OuterSizeTextBox.Text);
if (CurrentZone.AudioZone.OuterSize != vec)
{
CurrentZone.AudioZone.OuterSize = vec;
ProjectItemChanged();
}
}
private void OuterAngleTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
uint ang = 0;
if (uint.TryParse(OuterAngleTextBox.Text, out ang))
{
if (CurrentZone.AudioZone.OuterAngle != ang)
{
CurrentZone.AudioZone.OuterAngle = ang;
ProjectItemChanged();
}
}
}
private void OuterVec1TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector4String(OuterVec1TextBox.Text);
if (CurrentZone.AudioZone.OuterVec1 != vec)
{
CurrentZone.AudioZone.OuterVec1 = vec;
ProjectItemChanged();
}
}
private void OuterVec2TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector4String(OuterVec2TextBox.Text);
if (CurrentZone.AudioZone.OuterVec2 != vec)
{
CurrentZone.AudioZone.OuterVec2 = vec;
ProjectItemChanged();
}
}
private void OuterVec3TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector3String(OuterVec3TextBox.Text);
if (CurrentZone.AudioZone.OuterVec3 != vec)
{
CurrentZone.AudioZone.OuterVec3 = vec;
ProjectItemChanged();
}
}
private void UnkVec1TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector4String(UnkVec1TextBox.Text);
if (CurrentZone.AudioZone.UnkVec1 != vec)
{
CurrentZone.AudioZone.UnkVec1 = vec;
ProjectItemChanged();
}
}
private void UnkVec2TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector4String(UnkVec2TextBox.Text);
if (CurrentZone.AudioZone.UnkVec2 != vec)
{
CurrentZone.AudioZone.UnkVec2 = vec;
ProjectItemChanged();
}
}
private void UnkVec3TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var vec = FloatUtil.ParseVector4String(UnkVec3TextBox.Text);
if (CurrentZone.AudioZone.UnkVec3 != vec)
{
CurrentZone.AudioZone.UnkVec3 = vec;
ProjectItemChanged();
}
}
private void UnkBytesTextBox_TextChanged(object sender, EventArgs e)
{
var vals = UnkBytesTextBox.Text.Split(',');
if (vals?.Length == 3)
{
byte val0 = 0, val1 = 0, val2 = 0;
byte.TryParse(vals[0].Trim(), out val0);
byte.TryParse(vals[1].Trim(), out val1);
byte.TryParse(vals[2].Trim(), out val2);
CurrentZone.AudioZone.Unk14 = val0;
CurrentZone.AudioZone.Unk15 = val1;
CurrentZone.AudioZone.Unk16 = val2;
ProjectItemChanged();
}
}
private void Flags0TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
uint flags = 0;
if (uint.TryParse(Flags0TextBox.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out flags))
{
if (CurrentZone.AudioZone.Flags0.Value != flags)
{
CurrentZone.AudioZone.Flags0 = flags;
ProjectItemChanged();
}
}
}
private void Flags1TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
uint flags = 0;
if (uint.TryParse(Flags1TextBox.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out flags))
{
if (CurrentZone.AudioZone.Flags1.Value != flags)
{
CurrentZone.AudioZone.Flags1 = flags;
ProjectItemChanged();
}
}
}
private void Flags2TextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
uint flags = 0;
if (uint.TryParse(Flags2TextBox.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out flags))
{
if (CurrentZone.AudioZone.Flags2.Value != flags)
{
CurrentZone.AudioZone.Flags2 = flags;
ProjectItemChanged();
}
}
}
private void HashesTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var hashstrs = HashesTextBox.Text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
if (hashstrs?.Length > 0)
{
var hashlist = new List<MetaHash>();
foreach (var hashstr in hashstrs)
{
uint hash = 0;
if (!uint.TryParse(hashstr, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(hashstr);
JenkIndex.Ensure(hashstr);
}
hashlist.Add(hash);
}
CurrentZone.AudioZone.Hashes = hashlist.ToArray();
CurrentZone.AudioZone.HashesCount = (byte)hashlist.Count;
ProjectItemChanged();
}
}
private void ExtParamsTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (CurrentZone?.AudioZone == null) return;
var paramstrs = ExtParamsTextBox.Text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
if (paramstrs?.Length > 0)
{
var paramlist = new List<Dat151AmbientZone.ExtParam>();
foreach (var paramstr in paramstrs)
{
var paramvals = paramstr.Split(',');
if (paramvals?.Length == 2)
{
var param = new Dat151AmbientZone.ExtParam();
var hashstr = paramvals[0].Trim();
var valstr = paramvals[1].Trim();
uint hash = 0;
if (!uint.TryParse(hashstr, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(hashstr);
JenkIndex.Ensure(hashstr);
}
param.Hash = hash;
param.Value = FloatUtil.Parse(valstr);
paramlist.Add(param);
}
}
CurrentZone.AudioZone.ExtParams = paramlist.ToArray();
CurrentZone.AudioZone.ExtParamsCount = (uint)paramlist.Count;
ProjectItemChanged();
}
}
private void GoToButton_Click(object sender, EventArgs e)
{
if (CurrentZone == null) return;
if (ProjectForm.WorldForm == null) return;
ProjectForm.WorldForm.GoToPosition(CurrentZone.Position, CurrentZone.AudioZone.InnerSize);
}
private void AddToProjectButton_Click(object sender, EventArgs e)
{
ProjectForm.SetProjectItem(CurrentZone);
ProjectForm.AddAudioFileToProject(CurrentZone.RelFile);
}
private void DeleteButton_Click(object sender, EventArgs e)
{
ProjectForm.SetProjectItem(CurrentZone);
ProjectForm.DeleteAudioZone();
}
}
}

View File

@ -731,6 +731,7 @@ namespace CodeWalker.Project
RelFile relfile = new RelFile();
relfile.RpfFileEntry = new RpfResourceFileEntry();
relfile.RpfFileEntry.Name = Path.GetFileName(filename);
relfile.RpfFileEntry.NameHash = JenkHash.GenHash(relfile.RpfFileEntry.Name);
relfile.FilePath = GetFullFilePath(filename);
relfile.Name = relfile.RpfFileEntry.Name;
if (!AddAudioRelFile(relfile)) return null;

View File

@ -124,6 +124,16 @@
this.toolStripSeparator22 = new System.Windows.Forms.ToolStripSeparator();
this.ScenarioAddToProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ScenarioRemoveFromProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNameMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator();
this.AudioNewAmbientEmitterMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNewAmbientEmitterListMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNewAmbientZoneMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNewAmbientZoneListMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator24 = new System.Windows.Forms.ToolStripSeparator();
this.AudioAddToProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioRemoveFromProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsManifestGeneratorMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ToolsNavMeshGeneratorMenu = new System.Windows.Forms.ToolStripMenuItem();
@ -158,16 +168,8 @@
this.ToolbarSaveButton = new System.Windows.Forms.ToolStripButton();
this.ToolbarSaveAllButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.AudioMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNameMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator();
this.AudioNewAmbientEmitterMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNewAmbientZoneMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNewAmbientEmitterListMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioNewAmbientZoneListMenu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator24 = new System.Windows.Forms.ToolStripSeparator();
this.AudioAddToProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.AudioRemoveFromProjectMenu = new System.Windows.Forms.ToolStripMenuItem();
this.FileNewAudioDatMenu = new System.Windows.Forms.ToolStripMenuItem();
this.FileOpenAudioDatMenu = new System.Windows.Forms.ToolStripMenuItem();
this.MainMenu.SuspendLayout();
this.MainToolbar.SuspendLayout();
this.SuspendLayout();
@ -219,62 +221,63 @@
this.FileNewYndMenu,
this.FileNewYnvMenu,
this.FileNewTrainsMenu,
this.FileNewScenarioMenu});
this.FileNewScenarioMenu,
this.FileNewAudioDatMenu});
this.FileNewMenu.Name = "FileNewMenu";
this.FileNewMenu.Size = new System.Drawing.Size(163, 22);
this.FileNewMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewMenu.Text = "New";
//
// FileNewProjectMenu
//
this.FileNewProjectMenu.Name = "FileNewProjectMenu";
this.FileNewProjectMenu.Size = new System.Drawing.Size(140, 22);
this.FileNewProjectMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewProjectMenu.Text = "Project";
this.FileNewProjectMenu.Click += new System.EventHandler(this.FileNewProjectMenu_Click);
//
// toolStripSeparator8
//
this.toolStripSeparator8.Name = "toolStripSeparator8";
this.toolStripSeparator8.Size = new System.Drawing.Size(137, 6);
this.toolStripSeparator8.Size = new System.Drawing.Size(177, 6);
//
// FileNewYmapMenu
//
this.FileNewYmapMenu.Name = "FileNewYmapMenu";
this.FileNewYmapMenu.Size = new System.Drawing.Size(140, 22);
this.FileNewYmapMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewYmapMenu.Text = "Ymap File";
this.FileNewYmapMenu.Click += new System.EventHandler(this.FileNewYmapMenu_Click);
//
// FileNewYtypMenu
//
this.FileNewYtypMenu.Name = "FileNewYtypMenu";
this.FileNewYtypMenu.Size = new System.Drawing.Size(140, 22);
this.FileNewYtypMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewYtypMenu.Text = "Ytyp File";
this.FileNewYtypMenu.Click += new System.EventHandler(this.FileNewYtypMenu_Click);
//
// FileNewYndMenu
//
this.FileNewYndMenu.Name = "FileNewYndMenu";
this.FileNewYndMenu.Size = new System.Drawing.Size(140, 22);
this.FileNewYndMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewYndMenu.Text = "Ynd File";
this.FileNewYndMenu.Click += new System.EventHandler(this.FileNewYndMenu_Click);
//
// FileNewYnvMenu
//
this.FileNewYnvMenu.Name = "FileNewYnvMenu";
this.FileNewYnvMenu.Size = new System.Drawing.Size(140, 22);
this.FileNewYnvMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewYnvMenu.Text = "Ynv File";
this.FileNewYnvMenu.Click += new System.EventHandler(this.FileNewYnvMenu_Click);
//
// FileNewTrainsMenu
//
this.FileNewTrainsMenu.Name = "FileNewTrainsMenu";
this.FileNewTrainsMenu.Size = new System.Drawing.Size(140, 22);
this.FileNewTrainsMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewTrainsMenu.Text = "Trains File";
this.FileNewTrainsMenu.Click += new System.EventHandler(this.FileNewTrainsMenu_Click);
//
// FileNewScenarioMenu
//
this.FileNewScenarioMenu.Name = "FileNewScenarioMenu";
this.FileNewScenarioMenu.Size = new System.Drawing.Size(140, 22);
this.FileNewScenarioMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewScenarioMenu.Text = "Scenario File";
this.FileNewScenarioMenu.Click += new System.EventHandler(this.FileNewScenarioMenu_Click);
//
@ -288,88 +291,89 @@
this.FileOpenYndMenu,
this.FileOpenYnvMenu,
this.FileOpenTrainsMenu,
this.FileOpenScenarioMenu});
this.FileOpenScenarioMenu,
this.FileOpenAudioDatMenu});
this.FileOpenMenu.Name = "FileOpenMenu";
this.FileOpenMenu.Size = new System.Drawing.Size(163, 22);
this.FileOpenMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenMenu.Text = "Open";
//
// FileOpenProjectMenu
//
this.FileOpenProjectMenu.Name = "FileOpenProjectMenu";
this.FileOpenProjectMenu.Size = new System.Drawing.Size(149, 22);
this.FileOpenProjectMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenProjectMenu.Text = "Project...";
this.FileOpenProjectMenu.Click += new System.EventHandler(this.FileOpenProjectMenu_Click);
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(146, 6);
this.toolStripSeparator9.Size = new System.Drawing.Size(177, 6);
//
// FileOpenYmapMenu
//
this.FileOpenYmapMenu.Name = "FileOpenYmapMenu";
this.FileOpenYmapMenu.Size = new System.Drawing.Size(149, 22);
this.FileOpenYmapMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenYmapMenu.Text = "Ymap File...";
this.FileOpenYmapMenu.Click += new System.EventHandler(this.FileOpenYmapMenu_Click);
//
// FileOpenYtypMenu
//
this.FileOpenYtypMenu.Name = "FileOpenYtypMenu";
this.FileOpenYtypMenu.Size = new System.Drawing.Size(149, 22);
this.FileOpenYtypMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenYtypMenu.Text = "Ytyp File...";
this.FileOpenYtypMenu.Click += new System.EventHandler(this.FileOpenYtypMenu_Click);
//
// FileOpenYndMenu
//
this.FileOpenYndMenu.Name = "FileOpenYndMenu";
this.FileOpenYndMenu.Size = new System.Drawing.Size(149, 22);
this.FileOpenYndMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenYndMenu.Text = "Ynd File...";
this.FileOpenYndMenu.Click += new System.EventHandler(this.FileOpenYndMenu_Click);
//
// FileOpenYnvMenu
//
this.FileOpenYnvMenu.Name = "FileOpenYnvMenu";
this.FileOpenYnvMenu.Size = new System.Drawing.Size(149, 22);
this.FileOpenYnvMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenYnvMenu.Text = "Ynv File...";
this.FileOpenYnvMenu.Click += new System.EventHandler(this.FileOpenYnvMenu_Click);
//
// FileOpenTrainsMenu
//
this.FileOpenTrainsMenu.Name = "FileOpenTrainsMenu";
this.FileOpenTrainsMenu.Size = new System.Drawing.Size(149, 22);
this.FileOpenTrainsMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenTrainsMenu.Text = "Trains File...";
this.FileOpenTrainsMenu.Click += new System.EventHandler(this.FileOpenTrainsMenu_Click);
//
// FileOpenScenarioMenu
//
this.FileOpenScenarioMenu.Name = "FileOpenScenarioMenu";
this.FileOpenScenarioMenu.Size = new System.Drawing.Size(149, 22);
this.FileOpenScenarioMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenScenarioMenu.Text = "Scenario File...";
this.FileOpenScenarioMenu.Click += new System.EventHandler(this.FileOpenScenarioMenu_Click);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(160, 6);
this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6);
//
// FileCloseProjectMenu
//
this.FileCloseProjectMenu.Enabled = false;
this.FileCloseProjectMenu.Name = "FileCloseProjectMenu";
this.FileCloseProjectMenu.Size = new System.Drawing.Size(163, 22);
this.FileCloseProjectMenu.Size = new System.Drawing.Size(180, 22);
this.FileCloseProjectMenu.Text = "Close Project";
this.FileCloseProjectMenu.Click += new System.EventHandler(this.FileCloseProjectMenu_Click);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(160, 6);
this.toolStripSeparator4.Size = new System.Drawing.Size(177, 6);
//
// FileSaveProjectMenu
//
this.FileSaveProjectMenu.Enabled = false;
this.FileSaveProjectMenu.Name = "FileSaveProjectMenu";
this.FileSaveProjectMenu.Size = new System.Drawing.Size(163, 22);
this.FileSaveProjectMenu.Size = new System.Drawing.Size(180, 22);
this.FileSaveProjectMenu.Text = "Save Project";
this.FileSaveProjectMenu.Click += new System.EventHandler(this.FileSaveProjectMenu_Click);
//
@ -377,7 +381,7 @@
//
this.FileSaveProjectAsMenu.Enabled = false;
this.FileSaveProjectAsMenu.Name = "FileSaveProjectAsMenu";
this.FileSaveProjectAsMenu.Size = new System.Drawing.Size(163, 22);
this.FileSaveProjectAsMenu.Size = new System.Drawing.Size(180, 22);
this.FileSaveProjectAsMenu.Text = "Save Project As...";
this.FileSaveProjectAsMenu.Click += new System.EventHandler(this.FileSaveProjectAsMenu_Click);
//
@ -385,7 +389,7 @@
//
this.FileSaveItemMenu.Enabled = false;
this.FileSaveItemMenu.Name = "FileSaveItemMenu";
this.FileSaveItemMenu.Size = new System.Drawing.Size(163, 22);
this.FileSaveItemMenu.Size = new System.Drawing.Size(180, 22);
this.FileSaveItemMenu.Text = "Save Item";
this.FileSaveItemMenu.Visible = false;
this.FileSaveItemMenu.Click += new System.EventHandler(this.FileSaveItemMenu_Click);
@ -394,7 +398,7 @@
//
this.FileSaveItemAsMenu.Enabled = false;
this.FileSaveItemAsMenu.Name = "FileSaveItemAsMenu";
this.FileSaveItemAsMenu.Size = new System.Drawing.Size(163, 22);
this.FileSaveItemAsMenu.Size = new System.Drawing.Size(180, 22);
this.FileSaveItemAsMenu.Text = "Save Item As...";
this.FileSaveItemAsMenu.Visible = false;
this.FileSaveItemAsMenu.Click += new System.EventHandler(this.FileSaveItemAsMenu_Click);
@ -939,6 +943,88 @@
this.ScenarioRemoveFromProjectMenu.Text = "Remove from Project";
this.ScenarioRemoveFromProjectMenu.Click += new System.EventHandler(this.ScenarioRemoveFromProjectMenu_Click);
//
// AudioMenu
//
this.AudioMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.AudioNameMenu,
this.toolStripSeparator23,
this.AudioNewAmbientEmitterMenu,
this.AudioNewAmbientEmitterListMenu,
this.AudioNewAmbientZoneMenu,
this.AudioNewAmbientZoneListMenu,
this.toolStripSeparator24,
this.AudioAddToProjectMenu,
this.AudioRemoveFromProjectMenu});
this.AudioMenu.Name = "AudioMenu";
this.AudioMenu.Size = new System.Drawing.Size(51, 20);
this.AudioMenu.Text = "Audio";
this.AudioMenu.Visible = false;
//
// AudioNameMenu
//
this.AudioNameMenu.Enabled = false;
this.AudioNameMenu.Name = "AudioNameMenu";
this.AudioNameMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNameMenu.Text = "(No audio dat file selected)";
//
// toolStripSeparator23
//
this.toolStripSeparator23.Name = "toolStripSeparator23";
this.toolStripSeparator23.Size = new System.Drawing.Size(213, 6);
//
// AudioNewAmbientEmitterMenu
//
this.AudioNewAmbientEmitterMenu.Enabled = false;
this.AudioNewAmbientEmitterMenu.Name = "AudioNewAmbientEmitterMenu";
this.AudioNewAmbientEmitterMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientEmitterMenu.Text = "New Ambient Emitter";
this.AudioNewAmbientEmitterMenu.Click += new System.EventHandler(this.AudioNewAmbientEmitterMenu_Click);
//
// AudioNewAmbientEmitterListMenu
//
this.AudioNewAmbientEmitterListMenu.Enabled = false;
this.AudioNewAmbientEmitterListMenu.Name = "AudioNewAmbientEmitterListMenu";
this.AudioNewAmbientEmitterListMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientEmitterListMenu.Text = "New Ambient Emitter List";
this.AudioNewAmbientEmitterListMenu.Click += new System.EventHandler(this.AudioNewAmbientEmitterListMenu_Click);
//
// AudioNewAmbientZoneMenu
//
this.AudioNewAmbientZoneMenu.Enabled = false;
this.AudioNewAmbientZoneMenu.Name = "AudioNewAmbientZoneMenu";
this.AudioNewAmbientZoneMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientZoneMenu.Text = "New Ambient Zone";
this.AudioNewAmbientZoneMenu.Click += new System.EventHandler(this.AudioNewAmbientZoneMenu_Click);
//
// AudioNewAmbientZoneListMenu
//
this.AudioNewAmbientZoneListMenu.Enabled = false;
this.AudioNewAmbientZoneListMenu.Name = "AudioNewAmbientZoneListMenu";
this.AudioNewAmbientZoneListMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientZoneListMenu.Text = "New Ambient Zone List";
this.AudioNewAmbientZoneListMenu.Click += new System.EventHandler(this.AudioNewAmbientZoneListMenu_Click);
//
// toolStripSeparator24
//
this.toolStripSeparator24.Name = "toolStripSeparator24";
this.toolStripSeparator24.Size = new System.Drawing.Size(213, 6);
//
// AudioAddToProjectMenu
//
this.AudioAddToProjectMenu.Enabled = false;
this.AudioAddToProjectMenu.Name = "AudioAddToProjectMenu";
this.AudioAddToProjectMenu.Size = new System.Drawing.Size(216, 22);
this.AudioAddToProjectMenu.Text = "Add to Project";
this.AudioAddToProjectMenu.Click += new System.EventHandler(this.AudioAddToProjectMenu_Click);
//
// AudioRemoveFromProjectMenu
//
this.AudioRemoveFromProjectMenu.Enabled = false;
this.AudioRemoveFromProjectMenu.Name = "AudioRemoveFromProjectMenu";
this.AudioRemoveFromProjectMenu.Size = new System.Drawing.Size(216, 22);
this.AudioRemoveFromProjectMenu.Text = "Remove from Project";
this.AudioRemoveFromProjectMenu.Click += new System.EventHandler(this.AudioRemoveFromProjectMenu_Click);
//
// ToolsMenu
//
this.ToolsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -1214,87 +1300,19 @@
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
//
// AudioMenu
// FileNewAudioDatMenu
//
this.AudioMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.AudioNameMenu,
this.toolStripSeparator23,
this.AudioNewAmbientEmitterMenu,
this.AudioNewAmbientEmitterListMenu,
this.AudioNewAmbientZoneMenu,
this.AudioNewAmbientZoneListMenu,
this.toolStripSeparator24,
this.AudioAddToProjectMenu,
this.AudioRemoveFromProjectMenu});
this.AudioMenu.Name = "AudioMenu";
this.AudioMenu.Size = new System.Drawing.Size(51, 20);
this.AudioMenu.Text = "Audio";
this.AudioMenu.Visible = false;
this.FileNewAudioDatMenu.Name = "FileNewAudioDatMenu";
this.FileNewAudioDatMenu.Size = new System.Drawing.Size(180, 22);
this.FileNewAudioDatMenu.Text = "Audio Dat File";
this.FileNewAudioDatMenu.Click += new System.EventHandler(this.FileNewAudioDatMenu_Click);
//
// AudioNameMenu
// FileOpenAudioDatMenu
//
this.AudioNameMenu.Enabled = false;
this.AudioNameMenu.Name = "AudioNameMenu";
this.AudioNameMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNameMenu.Text = "(No audio dat file selected)";
//
// toolStripSeparator23
//
this.toolStripSeparator23.Name = "toolStripSeparator23";
this.toolStripSeparator23.Size = new System.Drawing.Size(213, 6);
//
// AudioNewAmbientEmitterMenu
//
this.AudioNewAmbientEmitterMenu.Enabled = false;
this.AudioNewAmbientEmitterMenu.Name = "AudioNewAmbientEmitterMenu";
this.AudioNewAmbientEmitterMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientEmitterMenu.Text = "New Ambient Emitter";
this.AudioNewAmbientEmitterMenu.Click += new System.EventHandler(this.AudioNewAmbientEmitterMenu_Click);
//
// AudioNewAmbientZoneMenu
//
this.AudioNewAmbientZoneMenu.Enabled = false;
this.AudioNewAmbientZoneMenu.Name = "AudioNewAmbientZoneMenu";
this.AudioNewAmbientZoneMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientZoneMenu.Text = "New Ambient Zone";
this.AudioNewAmbientZoneMenu.Click += new System.EventHandler(this.AudioNewAmbientZoneMenu_Click);
//
// AudioNewAmbientEmitterListMenu
//
this.AudioNewAmbientEmitterListMenu.Enabled = false;
this.AudioNewAmbientEmitterListMenu.Name = "AudioNewAmbientEmitterListMenu";
this.AudioNewAmbientEmitterListMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientEmitterListMenu.Text = "New Ambient Emitter List";
this.AudioNewAmbientEmitterListMenu.Click += new System.EventHandler(this.AudioNewAmbientEmitterListMenu_Click);
//
// AudioNewAmbientZoneListMenu
//
this.AudioNewAmbientZoneListMenu.Enabled = false;
this.AudioNewAmbientZoneListMenu.Name = "AudioNewAmbientZoneListMenu";
this.AudioNewAmbientZoneListMenu.Size = new System.Drawing.Size(216, 22);
this.AudioNewAmbientZoneListMenu.Text = "New Ambient Zone List";
this.AudioNewAmbientZoneListMenu.Click += new System.EventHandler(this.AudioNewAmbientZoneListMenu_Click);
//
// toolStripSeparator24
//
this.toolStripSeparator24.Name = "toolStripSeparator24";
this.toolStripSeparator24.Size = new System.Drawing.Size(213, 6);
//
// AudioAddToProjectMenu
//
this.AudioAddToProjectMenu.Enabled = false;
this.AudioAddToProjectMenu.Name = "AudioAddToProjectMenu";
this.AudioAddToProjectMenu.Size = new System.Drawing.Size(216, 22);
this.AudioAddToProjectMenu.Text = "Add to Project";
this.AudioAddToProjectMenu.Click += new System.EventHandler(this.AudioAddToProjectMenu_Click);
//
// AudioRemoveFromProjectMenu
//
this.AudioRemoveFromProjectMenu.Enabled = false;
this.AudioRemoveFromProjectMenu.Name = "AudioRemoveFromProjectMenu";
this.AudioRemoveFromProjectMenu.Size = new System.Drawing.Size(216, 22);
this.AudioRemoveFromProjectMenu.Text = "Remove from Project";
this.AudioRemoveFromProjectMenu.Click += new System.EventHandler(this.AudioRemoveFromProjectMenu_Click);
this.FileOpenAudioDatMenu.Name = "FileOpenAudioDatMenu";
this.FileOpenAudioDatMenu.Size = new System.Drawing.Size(180, 22);
this.FileOpenAudioDatMenu.Text = "Audio Dat File...";
this.FileOpenAudioDatMenu.Click += new System.EventHandler(this.FileOpenAudioDatMenu_Click);
//
// ProjectForm
//
@ -1460,5 +1478,7 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator24;
private System.Windows.Forms.ToolStripMenuItem AudioAddToProjectMenu;
private System.Windows.Forms.ToolStripMenuItem AudioRemoveFromProjectMenu;
private System.Windows.Forms.ToolStripMenuItem FileNewAudioDatMenu;
private System.Windows.Forms.ToolStripMenuItem FileOpenAudioDatMenu;
}
}

View File

@ -79,6 +79,7 @@ namespace CodeWalker.Project
private Dictionary<string, TrainTrack> visibletrains = new Dictionary<string, TrainTrack>();
private Dictionary<string, YmtFile> visiblescenarios = new Dictionary<string, YmtFile>();
private Dictionary<uint, YmapEntityDef> visiblemloentities = new Dictionary<uint, YmapEntityDef>();
private Dictionary<uint, RelFile> visibleaudiofiles = new Dictionary<uint, RelFile>();
private bool ShowProjectItemInProcess = false;
@ -1140,6 +1141,10 @@ namespace CodeWalker.Project
{
SaveScenario();
}
else if (CurrentAudioFile != null)
{
SaveAudioFile();
}
else if (CurrentProjectFile != null)
{
SaveProject();
@ -1221,6 +1226,18 @@ namespace CodeWalker.Project
//ShowEditScenarioPanel(false);
}
if (CurrentProjectFile.AudioRelFiles != null)
{
var caudf = CurrentAudioFile;
foreach (var audf in CurrentProjectFile.AudioRelFiles)
{
CurrentAudioFile = audf;
SaveAudioFile();
}
CurrentAudioFile = caudf;
//ShowEditAudioFilePanel(false);
}
SaveProject();
}
@ -1251,6 +1268,10 @@ namespace CodeWalker.Project
{
SaveScenario(saveas);
}
else if (CurrentAudioFile != null)
{
SaveAudioFile(saveas);
}
}
@ -4493,13 +4514,124 @@ namespace CodeWalker.Project
return CurrentProjectFile.ContainsAudioRel(rel);
}
public void NewAudioZone(AudioPlacement copy = null, bool copyPosition = false) //TODO
public void NewAudioZone(AudioPlacement copy = null, bool copyPosition = false)
{
MessageBox.Show("NewAudioZone TODO!");
if (CurrentAudioFile == null) return;
if (copy == null)
{
copy = CurrentAudioZone;
}
var zone = new Dat151AmbientZone(CurrentAudioFile);
var ap = new AudioPlacement(CurrentAudioFile, zone);
bool cp = copyPosition && (copy != null);
Vector3 pos = cp ? copy.Position : GetSpawnPos(20.0f);
Quaternion ori = cp ? copy.Orientation : Quaternion.Identity;
ap.SetPosition(pos);
ap.SetOrientation(ori);
//AA800424 box, line
//AA800420 sphere
zone.Flags0 = cp ? copy.AudioZone.Flags0 : 0xAA800424;
zone.Flags1 = cp ? copy.AudioZone.Flags1 : 0;
zone.Flags2 = cp ? copy.AudioZone.Flags2 : 0;
zone.Shape = cp ? copy.AudioZone.Shape : Dat151ZoneShape.Box;
zone.InnerSize = cp ? copy.AudioZone.InnerSize : Vector3.One * 10.0f;
zone.InnerAngle = cp ? copy.AudioZone.InnerAngle : 0;
zone.InnerVec1 = cp ? copy.AudioZone.InnerVec1 : Vector4.Zero;
zone.InnerVec2 = cp ? copy.AudioZone.InnerVec2 : new Vector4(1, 1, 1, 0);
zone.InnerVec3 = cp ? copy.AudioZone.InnerVec3 : Vector3.Zero;
zone.OuterSize = cp ? copy.AudioZone.OuterSize : Vector3.One * 15.0f;
zone.OuterAngle = cp ? copy.AudioZone.OuterAngle : 0;
zone.OuterVec1 = cp ? copy.AudioZone.OuterVec1 : Vector4.Zero;
zone.OuterVec2 = cp ? copy.AudioZone.OuterVec2 : new Vector4(1, 1, 1, 0);
zone.OuterVec3 = cp ? copy.AudioZone.OuterVec3 : Vector3.Zero;
zone.UnkVec1 = cp ? copy.AudioZone.UnkVec1 : new Vector4(0, 0, 1, 0);
zone.UnkVec2 = cp ? copy.AudioZone.UnkVec2 : new Vector4(1, -1, -1, 0);
zone.UnkVec3 = cp ? copy.AudioZone.UnkVec3 : new Vector4(0, 0, -1, 0);
zone.Unk14 = cp ? copy.AudioZone.Unk14 : (byte)0;
zone.Unk15 = cp ? copy.AudioZone.Unk15 : (byte)0;
zone.Unk16 = cp ? copy.AudioZone.Unk16 : (byte)0;
zone.HashesCount = cp ? copy.AudioZone.HashesCount: (byte)0;
zone.Hashes = cp ? copy.AudioZone.Hashes : null;
zone.ExtParamsCount = cp ? copy.AudioZone.ExtParamsCount : 0;
zone.ExtParams = cp ? copy.AudioZone.ExtParams : null;
zone.Name = "zone1";
zone.NameHash = JenkHash.GenHash(zone.Name);
ap.Name = zone.Name;
ap.NameHash = zone.NameHash;
CurrentAudioFile.AddRelData(zone);
LoadProjectTree();
ProjectExplorer?.TrySelectAudioZoneTreeNode(ap);
CurrentAudioZone = ap;
ShowEditAudioZonePanel(false);
if (WorldForm != null)
{
WorldForm.UpdateAudioPlacementGraphics(CurrentAudioFile);
}
}
public bool DeleteAudioZone() //TODO
public bool DeleteAudioZone()
{
return false;
if (CurrentAudioZone?.RelFile != CurrentAudioFile) return false;
if (CurrentAudioFile?.RelDatas == null) return false; //nothing to delete..
if (CurrentAudioFile?.RelDatasSorted == null) return false; //nothing to delete..
if (CurrentAudioZone?.AudioZone == null) return false;
if (MessageBox.Show("Are you sure you want to delete this audio zone?\n" + CurrentAudioZone.GetNameString() + "\n" + CurrentAudioZone.Position.ToString() + "\n\nThis operation cannot be undone. Continue?", "Confirm delete", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return true;
}
bool res = false;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot) //don't try to do this while rendering...
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioZone.AudioZone);
WorldForm.UpdateAudioPlacementGraphics(CurrentAudioFile);
}
}
else
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioZone.AudioZone);
}
if (!res)
{
MessageBox.Show("Unspecified error occurred when removing the audio zone from the file!");
}
var delzone = CurrentAudioZone;
var delrel = CurrentAudioFile;
//ProjectExplorer?.RemoveAudioZoneTreeNode(delzone);
ProjectExplorer?.SetAudioRelHasChanged(delrel, true);
ClosePanel((EditAudioZonePanel p) => { return p.Tag == delzone; });
CurrentAudioZone = null;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot)
{
WorldForm.SelectItem(null);
}
}
return true;
}
public bool IsCurrentAudioZone(AudioPlacement zone)
{
@ -4510,9 +4642,57 @@ namespace CodeWalker.Project
{
MessageBox.Show("NewAudioEmitter TODO!");
}
public bool DeleteAudioEmitter() //TODO
public bool DeleteAudioEmitter()
{
return false;
if (CurrentAudioEmitter?.RelFile != CurrentAudioFile) return false;
if (CurrentAudioFile?.RelDatas == null) return false; //nothing to delete..
if (CurrentAudioFile?.RelDatasSorted == null) return false; //nothing to delete..
if (CurrentAudioEmitter?.AudioEmitter == null) return false;
if (MessageBox.Show("Are you sure you want to delete this audio emitter?\n" + CurrentAudioEmitter.GetNameString() + "\n" + CurrentAudioEmitter.Position.ToString() + "\n\nThis operation cannot be undone. Continue?", "Confirm delete", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return true;
}
bool res = false;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot) //don't try to do this while rendering...
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioEmitter.AudioEmitter);
WorldForm.UpdateAudioPlacementGraphics(CurrentAudioFile);
}
}
else
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioEmitter.AudioEmitter);
}
if (!res)
{
MessageBox.Show("Unspecified error occurred when removing the audio emitter from the file!");
}
var delem = CurrentAudioEmitter;
var delrel = CurrentAudioFile;
//ProjectExplorer?.RemoveAudioEmitterTreeNode(delem);
ProjectExplorer?.SetAudioRelHasChanged(delrel, true);
ClosePanel((EditAudioEmitterPanel p) => { return p.Tag == delem; });
CurrentAudioEmitter = null;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot)
{
WorldForm.SelectItem(null);
}
}
return true;
}
public bool IsCurrentAudioEmitter(AudioPlacement emitter)
{
@ -4523,9 +4703,47 @@ namespace CodeWalker.Project
{
MessageBox.Show("NewAudioZoneList TODO!");
}
public bool DeleteAudioZoneList() //TODO
public bool DeleteAudioZoneList()
{
return false;
if (CurrentAudioZoneList?.Rel != CurrentAudioFile) return false;
if (CurrentAudioFile?.RelDatas == null) return false; //nothing to delete..
if (CurrentAudioFile?.RelDatasSorted == null) return false; //nothing to delete..
if (MessageBox.Show("Are you sure you want to delete this audio zone list?\n" + CurrentAudioZoneList.GetNameString() + "\n\nThis operation cannot be undone. Continue?", "Confirm delete", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return true;
}
bool res = false;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot) //don't try to do this while rendering...
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioZoneList);
//WorldForm.SelectItem(null, null, null);
}
}
else
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioZoneList);
}
if (!res)
{
MessageBox.Show("Unspecified error occurred when removing the audio zone list from the file!");
}
var delzl = CurrentAudioZoneList;
var delrel = CurrentAudioFile;
ProjectExplorer?.RemoveAudioZoneListTreeNode(delzl);
ProjectExplorer?.SetAudioRelHasChanged(delrel, true);
ClosePanel((EditAudioZoneListPanel p) => { return p.Tag == delzl; });
CurrentAudioZoneList = null;
return true;
}
public bool IsCurrentAudioZoneList(Dat151AmbientZoneList list)
{
@ -4536,9 +4754,47 @@ namespace CodeWalker.Project
{
MessageBox.Show("NewAudioEmitterList TODO!");
}
public bool DeleteAudioEmitterList() //TODO
public bool DeleteAudioEmitterList()
{
return false;
if (CurrentAudioEmitterList?.Rel != CurrentAudioFile) return false;
if (CurrentAudioFile?.RelDatas == null) return false; //nothing to delete..
if (CurrentAudioFile?.RelDatasSorted == null) return false; //nothing to delete..
if (MessageBox.Show("Are you sure you want to delete this audio emitter list?\n" + CurrentAudioEmitterList.GetNameString() + "\n\nThis operation cannot be undone. Continue?", "Confirm delete", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return true;
}
bool res = false;
if (WorldForm != null)
{
lock (WorldForm.RenderSyncRoot) //don't try to do this while rendering...
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioEmitterList);
//WorldForm.SelectItem(null, null, null);
}
}
else
{
res = CurrentAudioFile.RemoveRelData(CurrentAudioEmitterList);
}
if (!res)
{
MessageBox.Show("Unspecified error occurred when removing the audio emitter list from the file!");
}
var delel = CurrentAudioEmitterList;
var delrel = CurrentAudioFile;
ProjectExplorer?.RemoveAudioEmitterListTreeNode(delel);
ProjectExplorer?.SetAudioRelHasChanged(delrel, true);
ClosePanel((EditAudioEmitterListPanel p) => { return p.Tag == delel; });
CurrentAudioEmitterList = null;
return true;
}
public bool IsCurrentAudioEmitterList(Dat151AmbientEmitterList list)
{
@ -4747,27 +5003,38 @@ namespace CodeWalker.Project
}
}
public void GetVisibleAudioPlacements(Camera camera, List<AudioPlacement> placements)
public void GetVisibleAudioFiles(Camera camera, List<RelFile> rels)
{
if (hidegtavmap)
{
placements.Clear();
rels.Clear();
}
if (CurrentProjectFile == null) return;
lock (projectsyncroot)
{
visibleaudiofiles.Clear();
for (int i = 0; i < rels.Count; i++)
{
var rel = rels[i];
visibleaudiofiles[rel.RpfFileEntry.NameHash] = rel;
}
for (int i = 0; i < CurrentProjectFile.AudioRelFiles.Count; i++)
{
var auddat = CurrentProjectFile.AudioRelFiles[i];
if (auddat.Loaded)
var rel = CurrentProjectFile.AudioRelFiles[i];
if (rel.Loaded)
{
//TODO: create AudioPlacement objects for project audio files!
visibleaudiofiles[rel.RpfFileEntry.NameHash] = rel;
}
}
rels.Clear();
foreach (var rel in visibleaudiofiles.Values)
{
rels.Add(rel);
}
}
@ -6075,6 +6342,10 @@ namespace CodeWalker.Project
{
NewScenario();
}
private void FileNewAudioDatMenu_Click(object sender, EventArgs e)
{
NewAudioFile();
}
private void FileOpenProjectMenu_Click(object sender, EventArgs e)
{
OpenProject();
@ -6103,6 +6374,10 @@ namespace CodeWalker.Project
{
OpenScenario();
}
private void FileOpenAudioDatMenu_Click(object sender, EventArgs e)
{
OpenAudioFile();
}
private void FileCloseProjectMenu_Click(object sender, EventArgs e)
{
CloseProject();

View File

@ -688,7 +688,7 @@ namespace CodeWalker
}
else if (Audio != null)
{
return WidgetAxis.XYZ;
return WidgetAxis.Z;
}
return WidgetAxis.None;
}

View File

@ -138,7 +138,8 @@ namespace CodeWalker
bool renderaudiozones = false;
bool renderaudioouterbounds = true;
List<AudioPlacement> renderaudzonelist = new List<AudioPlacement>();
List<RelFile> renderaudfilelist = new List<RelFile>();
List<AudioPlacement> renderaudplacementslist = new List<AudioPlacement>();
bool MapViewEnabled = false;
int MapViewDragX = 0;
@ -850,17 +851,17 @@ namespace CodeWalker
{
if (!audiozones.Inited) return;
renderaudzonelist.Clear();
for (int i = 0; i < audiozones.AllItems.Count; i++)
{
renderaudzonelist.Add(audiozones.AllItems[i]);
}
renderaudfilelist.Clear();
renderaudfilelist.AddRange(audiozones.AllFiles);
if (ProjectForm != null)
{
ProjectForm.GetVisibleAudioPlacements(camera, renderaudzonelist);
ProjectForm.GetVisibleAudioFiles(camera, renderaudfilelist);
}
renderaudplacementslist.Clear();
audiozones.GetPlacements(renderaudfilelist, renderaudplacementslist);
//RenderablePathBatch rnd = renderableCache.GetRenderablePathBatch(audiozones);
//if ((rnd != null) && (rnd.IsLoaded))
@ -881,9 +882,9 @@ namespace CodeWalker
MapBox mb = new MapBox();
MapSphere ms = new MapSphere();
for (int i = 0; i < renderaudzonelist.Count; i++)
for (int i = 0; i < renderaudplacementslist.Count; i++)
{
var placement = renderaudzonelist[i];
var placement = renderaudplacementslist[i];
switch (placement.Shape)
{
case Dat151ZoneShape.Box:
@ -1869,6 +1870,11 @@ namespace CodeWalker
}
}
public void UpdateAudioPlacementGraphics(RelFile rel)
{
audiozones.PlacementsDict.Remove(rel); //should cause a rebuild to add/remove items
}
public Vector3 GetCameraPosition()
{