Skip to content

Commit

Permalink
Update 1
Browse files Browse the repository at this point in the history
  • Loading branch information
amrshaheen61 committed Oct 31, 2023
1 parent 1eee5fd commit 43b1c42
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 56 deletions.
10 changes: 5 additions & 5 deletions Controls/SearchBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private bool IsMatch(string value)
private void FindNext_Click(object sender, EventArgs e)
{
bool found = false;

for (int rowIndex = CurrentRowIndex; rowIndex < DataGridView.Rows.Count; rowIndex++)
{
for (int colIndex = CurrentColumnIndex + 1; colIndex < DataGridView.Columns.Count; colIndex++)
Expand All @@ -61,13 +61,13 @@ private void FindNext_Click(object sender, EventArgs e)
if (found)
break;


CurrentColumnIndex = -1;
}

if (!found)
{

for (int rowIndex = 0; rowIndex < DataGridView.Rows.Count; rowIndex++)
{
for (int colIndex = 0; colIndex < DataGridView.Columns.Count; colIndex++)
Expand Down Expand Up @@ -118,7 +118,7 @@ private void FindPrevious_Click(object sender, EventArgs e)
if (found)
break;


CurrentColumnIndex = DataGridView.Columns.Count;
}

Expand Down Expand Up @@ -187,7 +187,7 @@ private void InputSearch_KeyDown(object sender, KeyEventArgs e)

public new void Show()
{
if (DataGridView.CurrentCell!=null)
if (DataGridView.CurrentCell != null)
{
InputSearch.Text = DataGridView.CurrentCell.Value.ToString();
}
Expand Down
28 changes: 12 additions & 16 deletions Core/rmdtoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void Read(IStream stream)
NameLength = stream.Get<int>();
Hash = stream.Get<ulong>();
}

public void Write(IStream stream)
{
stream.SetIntValue(NameOffset);
Expand Down Expand Up @@ -268,12 +268,12 @@ public string GetRMDBLOBPath(CompressInfo info)

public string GetRMDBLOBPath()
{
if(CompressInfos.Count==0)
if (CompressInfos.Count == 0)
{
return "";
}

return Path.GetFullPath( Path.Combine(Path.GetDirectoryName(Rmdtoc.rmdtocStream.Name), Rmdtoc.RMDBLOBPaths[CompressInfos[0].FileIndex].Path));
return Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Rmdtoc.rmdtocStream.Name), Rmdtoc.RMDBLOBPaths[CompressInfos[0].FileIndex].Path));
}
public byte[] GetRow()
{
Expand Down Expand Up @@ -302,15 +302,15 @@ public byte[] GetRow()
}
DecompressBuffer.SetStringValue("End of File");

stream.Close();
stream.Close();
}


return DecompressBuffer.ToArray();



}
}
public string GetId()
{
if (CompressInfos.Count == 0)
Expand Down Expand Up @@ -418,7 +418,7 @@ void Load()
NameTable = new MStream(BufferStream.GetBytes(header.Names_Size, SeekToOffset: header.Names_Offset));


RMDBLOBPaths=new List<RMDBLOBPath>();
RMDBLOBPaths = new List<RMDBLOBPath>();
for (int i = 0; i < header.RMDBLOB_Path_Count; i++)
{
var path = new RMDBLOBPath();
Expand Down Expand Up @@ -467,23 +467,19 @@ void Load()

Root = new TreeNode(Path.GetFileNameWithoutExtension(Folders[0].Name));
Root.Tag = Folders[0];
var Temp = Root;
MakeNode(Folders, Root, Folders[0]);
Root = Temp;


}

private void MakeNode(List<FolderInfo> folders, TreeNode node, FolderInfo Folder)
{
for (int i = Folder.FolderIndex; i < Folder.FolderIndex + Folder.FolderCount; i++)
{
Root = new TreeNode(folders[i].Name);
Root.Tag = folders[i];

node.Nodes.Add(Root);
MakeNode(folders, Root, folders[i]);


var treenode = new TreeNode(folders[i].Name);
treenode.Tag = folders[i];
node.Nodes.Add(treenode);
MakeNode(folders, treenode, folders[i]);
}
}

Expand Down Expand Up @@ -558,7 +554,7 @@ public void Save()
header.RMDBLOB_Path_Offset = (int)BufferStream.Position;
BufferStream.SetBytes(RMDBLOBPathBlock.ToArray());

header.Table_1_Offset=(int)BufferStream.Position;
header.Table_1_Offset = (int)BufferStream.Position;
BufferStream.SetBytes(Table1.ToArray());

header.Table_2_Offset = (int)BufferStream.Position;
Expand Down
11 changes: 2 additions & 9 deletions Forms/FrmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Forms/FrmStringTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void saveToolStripMenuItem_Click(object sender, EventArgs e)

private void exportAllToolStripMenuItem_Click(object sender, EventArgs e)
{

}

private void importAllToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -197,9 +197,9 @@ private void valuesToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (i >= dataGridView1.Rows.Count) break;

var Table = dataGridView1.Rows[i++];
Table.Cells["TableValue"].Value = line;
var Table = dataGridView1.Rows[i++];
Table.Cells["TableValue"].Value = line;

}

MessageBox.Show("Done!");
Expand Down Expand Up @@ -246,7 +246,7 @@ private void bothToolStripMenuItem1_Click(object sender, EventArgs e)
var sb = new System.Text.StringBuilder();
foreach (var Table in stringtable as List<SrtingTableEntry>)
{
sb.AppendLine(Table.Name+"="+ Table.Value);
sb.AppendLine(Table.Name + "=" + Table.Value);
}
File.WriteAllText(sdf.FileName, sb.ToString());
}
Expand Down
39 changes: 19 additions & 20 deletions Helper/DDSToBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using static Helper.DDSCooker;

namespace Helper
Expand All @@ -19,13 +18,13 @@ static private Bitmap UncompressDXT1(IStream stream, int w, int h)
{
Bitmap res = new Bitmap((w < 4) ? 4 : w, (h < 4) ? 4 : h);

for (int j = 0; j < h; j += 4)
{
for (int i = 0; i < w; i += 4)
{
DecompressBlockDXT1(i, j, stream.GetBytes(8), res);
}
}
for (int j = 0; j < h; j += 4)
{
for (int i = 0; i < w; i += 4)
{
DecompressBlockDXT1(i, j, stream.GetBytes(8), res);
}
}
return res;
}

Expand Down Expand Up @@ -107,13 +106,13 @@ static private Bitmap UncompressDXT5(IStream stream, int w, int h)
{
Bitmap res = new Bitmap((w < 4) ? 4 : w, (h < 4) ? 4 : h);

for (int j = 0; j < h; j += 4)
{
for (int i = 0; i < w; i += 4)
{
DecompressBlockDXT5(i, j, stream.GetBytes(16), res);
}
}
for (int j = 0; j < h; j += 4)
{
for (int i = 0; i < w; i += 4)
{
DecompressBlockDXT5(i, j, stream.GetBytes(16), res);
}
}
return res;
}

Expand Down Expand Up @@ -231,7 +230,7 @@ private static Bitmap UncompressDXT3(IStream stream, int w, int h)
{
for (int t = 0; t < w; t += 4)
{
blockStorage=stream.GetBytes(bufferSize, false, ptr);
blockStorage = stream.GetBytes(bufferSize, false, ptr);
ptr += bufferSize;
{
int color0 = blockStorage[8] | blockStorage[9] << 8;
Expand Down Expand Up @@ -328,7 +327,7 @@ static private Bitmap Uncompress8_8_8_8(IStream stream, int w, int h)
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width; x++)
{
{
uint RGBABits = stream.GetUIntValue();
int b = GetMaskValue(BBitMask, RGBABits);
int g = GetMaskValue(GBitMask, RGBABits);
Expand Down Expand Up @@ -515,14 +514,14 @@ public static Bitmap Convert(byte[] DDSBytes)
info = DDSCooker.DdsToTex(DDSBytes);

var stream = new MStream(info.Data);
return GetBitMapFromDDS(info.Format, stream);

return GetBitMapFromDDS(info.Format, stream);
}


public static Bitmap Convert(IStream stream)
{
info= DDSCooker.DdsToTex(stream);
info = DDSCooker.DdsToTex(stream);
return GetBitMapFromDDS(info.Format, stream);
}

Expand Down
4 changes: 3 additions & 1 deletion Helper/MStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public MStream(byte[] FileData) : base(0)
Position = 0;
}

public MStream(string FileName, byte[] FileData) : base(FileData)
public MStream(string FileName, byte[] FileData) : base(0)
{
Write(FileData, 0, FileData.Length);
Position = 0;
Name = FileName;
}

Expand Down

0 comments on commit 43b1c42

Please sign in to comment.