using System;
using System.Windows.Forms;
using System.IO;
namespace DBC_Converter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName.ToLower();
}
}
private void button3_Click(object sender, EventArgs e)
{
if (File.Exists(textBox1.Text))
{
switch (Header(textBox1.Text))
{
case "EFFE":
{
var dbc = new CO2_CORE_DLL.IO.DBC.EFFE();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
case "RSDB32":
{
var dbc = new CO2_CORE_DLL.IO.DBC.RSDB_SMALL();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
case "RSDB64":
{
var dbc = new CO2_CORE_DLL.IO.DBC.RSDB_BIG();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
case "SIMO":
{
var dbc = new CO2_CORE_DLL.IO.DBC.SIMO();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
case "MESH":
{
var dbc = new CO2_CORE_DLL.IO.DBC.MESH();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
case "EMOI":
{
var dbc = new CO2_CORE_DLL.IO.DBC.EMOI();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
case "MATR":
{
var dbc = new CO2_CORE_DLL.IO.DBC.MATR();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
case "ROPT":
{
var dbc = new CO2_CORE_DLL.IO.DBC.ROPT();
if (IsDbc(textBox1.Text))
{
dbc.LoadFromDat(textBox1.Text);
dbc.SaveToTxt(ExtDbc(true));
}
else
{
dbc.LoadFromTxt(textBox1.Text);
dbc.SaveToDat(ExtDbc(false));
}
Done();
break;
}
default:
{
MessageBox.Show("The DBC file is not recognized.");
break;
}
}
}
else
{
MessageBox.Show("You either forgot to select a file or somehow selected a non-existing one.");
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("So you probably clicked here because of the program not working.\nYou probably did something weird, try again.");
}
private void button4_Click(object sender, EventArgs e)
{
MessageBox.Show("Credits:\nCptSky for his .dll, program wouldn't have existed without him.\nMe for putting together this for the lazy ones.\nGoogle for random stuff.");
}
public bool IsDbc(string path)
{
if (path.EndsWith(".dbc"))
return true;
return false;
}
public string ExtDbc(bool extension)
{
if(extension)
return textBox1.Text.Replace(".dbc", ".txt");
return textBox1.Text.Replace(".txt", ".dbc");
}
public string Header(string text)
{
if (text.Contains("3deffectobj") || text.Contains("3dobj") || text.Contains("3dtexture") || text.Contains("sound"))
return "RSDB32";
if (text.Contains("3deffect"))
return "EFFE";
if (text.Contains("motion") && !text.Contains("emotionico"))
return "RSDB64";
if (text.Contains("3dsimpleobj"))
return "SIMO";
if (text.Contains("armet") || text.Contains("armor") || text.Contains("head") || text.Contains("misc") || text.Contains("mount") || text.Contains("weapon"))
return "MESH";
if (text.Contains("emotionico"))
return "EMOI";
if (text.Contains("material"))
return "MATR";
if (text.Contains("rolepart"))
return "ROPT";
return "NONE";
}
public void Done()
{
MessageBox.Show("Done converting.");
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
if (text.Contains("3deffect"))
return "EFFE";
else if (text.Contains("3deffectobj") || text.Contains("3dobj") || text.Contains("3dtexture") || text.Contains("sound"))
return "RSDB32";
if (text.Contains("3deffect") && !text.Contains("3deffectobj"))
return "EFFE";
else if (text.Contains("3deffectobj") || text.Contains("3dobj") || text.Contains("3dtexture") || text.Contains("sound"))
return "RSDB32";
if (path.EndsWith(".dbc"))
return true;
else
return false;
if (path.EndsWith(".dbc"))
return true;
return false;