1
0
mirror of synced 2024-11-12 02:00:50 +01:00

Bfres library fixes, and some form fixes

This commit is contained in:
KillzXGaming 2019-07-26 15:35:15 -04:00
parent 0ed8555b3a
commit df9641faab
17 changed files with 176 additions and 20 deletions

Binary file not shown.

View File

@ -84,9 +84,13 @@ namespace FirstPlugin
public void Load(System.IO.Stream stream)
{
CanSave = true;
CanRenameFiles = true;
CanReplaceFiles = true;
using (var reader = new FileReader(stream))
{
_savedDirectories.Clear();
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
reader.ReadSignature(4, "RARC");
uint FileSize = reader.ReadUInt32();
@ -249,6 +253,7 @@ namespace FirstPlugin
//Write the directories and files
WriteOffset(writer, 12, InfoPos);
int I = 0;
foreach (FileEntry entry in TotalList)
{
entry.SaveFileFormat();

View File

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
namespace FirstPlugin
{
public class CMB : IFileFormat
{
public FileType FileType { get; set; } = FileType.Layout;
public bool CanSave { get; set; }
public string[] Description { get; set; } = new string[] { "CMB" };
public string[] Extension { get; set; } = new string[] { "*.cmb" };
public string FileName { get; set; }
public string FilePath { get; set; }
public IFileInfo IFileInfo { get; set; }
public bool Identify(System.IO.Stream stream)
{
using (var reader = new Toolbox.Library.IO.FileReader(stream, true))
{
return reader.CheckSignature(4, "cmb ");
}
}
public Type[] Types
{
get
{
List<Type> types = new List<Type>();
return types.ToArray();
}
}
public Header header;
public void Load(System.IO.Stream stream)
{
header = new Header();
header.Read(new FileReader(stream));
}
public void Unload()
{
}
public byte[] Save()
{
return null;
}
public enum CMBVersion
{
OOT3DS,
MM3DS,
LM3DS,
}
public class Header
{
public string Name { get; set; }
public CMBVersion Version;
public void Read(FileReader reader)
{
string magic = reader.ReadSignature(4, "cmb ");
uint FileSize = reader.ReadUInt32();
uint ChunkCount = reader.ReadUInt32();
uint Unknown = reader.ReadUInt32();
Name = reader.ReadString(0x10).TrimEnd('\0');
//Check the chunk count used by the game
if (ChunkCount == 0x0F)
Version = CMBVersion.LM3DS;
else if (ChunkCount == 0x0A)
Version = CMBVersion.MM3DS;
else if (ChunkCount == 0x06)
Version = CMBVersion.OOT3DS;
else
throw new Exception("Unexpected chunk count! " + ChunkCount);
int chunkIdx = 0x04;
}
}
}
}

View File

@ -225,8 +225,9 @@
<Compile Include="FileFormats\Archives\Sonic Racing\SP2.cs" />
<Compile Include="FileFormats\Archives\TMPK.cs" />
<Compile Include="FileFormats\Archives\U8.cs" />
<Compile Include="FileFormats\Archives\Grezzo\ZAR.cs" />
<Compile Include="FileFormats\Archives\Grezzo\ZSI.cs" />
<Compile Include="FileFormats\Grezzo\CMB.cs" />
<Compile Include="FileFormats\Grezzo\ZAR.cs" />
<Compile Include="FileFormats\Grezzo\ZSI.cs" />
<Compile Include="FileFormats\Audio\Archives\BARS.cs" />
<Compile Include="FileFormats\Audio\BARSLIST.cs" />
<Compile Include="FileFormats\Audio\BCSTM.cs" />

View File

@ -137,7 +137,7 @@ namespace Toolbox.Library.Forms
memWav.Position = 0;
//Load the player
audioChannel.audioPlayer.Open(new MemoryStream(audioChannel.Data),"test.wav", activeDevice);
audioChannel.audioPlayer.Open(new MemoryStream(audioChannel.Data), "test.wav", activeDevice);
/* OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == DialogResult.OK)
@ -359,6 +359,9 @@ namespace Toolbox.Library.Forms
private void ResetPlayers()
{
if (selectedFile == null || selectedFile.Channels == null)
return;
foreach (var channel in selectedFile.Channels)
{
channel.audioPlayer.Stop();
@ -404,10 +407,27 @@ namespace Toolbox.Library.Forms
private void AudioPlayer_FormClosed(object sender, FormClosedEventArgs e)
{
Console.WriteLine("Closing audio form");
var channel = GetActiveAudio();
if (channel != null)
{
channel.audioPlayer.Stop();
channel.audioPlayer.Position = TimeSpan.Zero;
colorSlider1.Value = 0;
}
channelCB.Items.Clear();
foreach (var obj in audioListView.Objects)
{
foreach (var chan in ((AudioFile)obj).Channels)
{
chan.audioStream.Dispose();
chan.audioPlayer.Dispose();
chan.samplerSource.Dispose();
}
((AudioFile)obj).Dispose();
}
audioListView.ClearObjects();

View File

@ -69,10 +69,7 @@ namespace Toolbox.Library.Forms
public void LoadFile(IWaveSource source, IFileFormat fileFormat, bool ClearPlaylist = true, object AudioStruct = null)
{
if (ClearPlaylist)
{
audioListView.Items.Clear();
AudioFileFormats.Clear();
}
ResetAudioList();
AudioFile file = new AudioFile();
file.Title = fileFormat.FileName;
@ -109,10 +106,7 @@ namespace Toolbox.Library.Forms
public void LoadFile(AudioData audioData, IFileFormat fileFormat, bool ClearPlaylist = true)
{
if (ClearPlaylist)
{
audioListView.Items.Clear();
AudioFileFormats.Clear();
}
ResetAudioList();
AudioFileFormats.Add(fileFormat);
@ -363,11 +357,17 @@ namespace Toolbox.Library.Forms
private void ResetPlayers()
{
if (selectedFile == null || selectedFile.Channels == null)
return;
foreach (var channel in selectedFile.Channels)
{
channel.audioPlayer.Stop();
channel.audioPlayer.Position = TimeSpan.Zero;
}
colorSlider1.Value = 0;
btnPlay.BackgroundImage = Properties.Resources.PlayArrowR;
}
private void colorSlider1_ValueChanged(object sender, EventArgs e)
@ -405,18 +405,43 @@ namespace Toolbox.Library.Forms
channel.audioPlayer.Volume = trackbarVolume.Value;
}
private void AudioPlayer_FormClosed(object sender, FormClosedEventArgs e)
public void ResetAudioList()
{
ResetPlayers();
channelCB.Items.Clear();
if (audioListView.Objects == null)
return;
foreach (var obj in audioListView.Objects)
{
foreach (var chan in ((AudioFile)obj).Channels)
{
chan.audioStream.Dispose();
chan.audioPlayer.Dispose();
chan.samplerSource.Dispose();
}
((AudioFile)obj).Dispose();
}
audioListView.ClearObjects();
}
public override void OnControlClosing()
{
Console.WriteLine("Closing audio panel");
var channel = GetActiveAudio();
if (channel != null)
{
channel.audioPlayer.Stop();
channel.audioPlayer.Position = TimeSpan.Zero;
colorSlider1.Value = 0;
}
ResetAudioList();
}
private void loopingToolStripMenuItem_Click(object sender, EventArgs e)
{
if (selectedFile != null && selectedFile.vgAdudioFile != null )

View File

@ -84,6 +84,7 @@
this.ClientSize = new System.Drawing.Size(549, 398);
this.Name = "GenericEditorForm";
this.Text = "GenericEditorForm";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GenericEditorForm_FormClosing);
this.contentContainer.ResumeLayout(false);
this.ResumeLayout(false);

View File

@ -34,5 +34,14 @@ namespace Toolbox.Library.Forms
stPanel1.Dock = DockStyle.Fill;
}
}
private void GenericEditorForm_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (var control in stPanel1.Controls)
{
if (control is STUserControl)
((STUserControl)control).OnControlClosing();
}
}
}
}

View File

@ -34,6 +34,7 @@ namespace Toolbox.Library
{
case PICASurfaceFormat.RGB565: return TEX_FORMAT.B5G6R5_UNORM;
case PICASurfaceFormat.RGB8: return TEX_FORMAT.R8G8_UNORM;
case PICASurfaceFormat.RGBA8: return TEX_FORMAT.R8G8B8A8_UNORM;
case PICASurfaceFormat.RGBA5551: return TEX_FORMAT.B5G5R5A1_UNORM;
case PICASurfaceFormat.RGBA4: return TEX_FORMAT.B4G4R4A4_UNORM;
case PICASurfaceFormat.LA8: return TEX_FORMAT.LA8;
@ -56,6 +57,7 @@ namespace Toolbox.Library
{
case TEX_FORMAT.B5G6R5_UNORM: return PICASurfaceFormat.RGB565;
case TEX_FORMAT.R8G8_UNORM: return PICASurfaceFormat.RGB8;
case TEX_FORMAT.R8G8B8A8_UNORM: return PICASurfaceFormat.RGBA8;
case TEX_FORMAT.B5G5R5A1_UNORM: return PICASurfaceFormat.RGBA5551;
case TEX_FORMAT.B4G4R4A4_UNORM: return PICASurfaceFormat.RGBA4;
case TEX_FORMAT.LA8: return PICASurfaceFormat.LA8;

Binary file not shown.

Binary file not shown.