[Release]DBC Converter

02/23/2012 11:26 Kiyono#16
Quote:
Originally Posted by JobvdH View Post
I hope you'll succeed!
If you succeed this will be a great progress to 5165+ item editing!
Don't expect anything though, the chance of me doing anything half decent at programming is as high as doomsday happening this year.
02/23/2012 11:50 JobvdH#17
Ah alright, perhaps CrpSky might want to help you?
If he won't, you atleast tried it :)
02/23/2012 18:15 CptSky#18
I fixed the errors, plus I added the 3DEffect support.
02/23/2012 18:30 JobvdH#19
Quote:
Originally Posted by CptSky View Post
I fixed the errors, plus I added the 3DEffect support.
Great job!
02/23/2012 18:33 Kiyono#20
Quote:
Originally Posted by CptSky View Post
I fixed the errors, plus I added the 3DEffect support.
Also added 3deffect support, can't test since I'm on my notebook but it should work.
02/23/2012 19:01 2slam#21
we are getting so close
03/13/2012 10:24 Kiyono#22
And it should support all .dbc files now.
//edit Moved to the editing section as it seems more suitable.
04/25/2012 23:22 _DreadNought_#23
What about converting the .txt back to .dbc? Or is that not required, abit of a nub with this shit.
04/25/2012 23:30 CptSky#24
Quote:
Originally Posted by _DreadNought_ View Post
What about converting the .txt back to .dbc? Or is that not required, abit of a nub with this shit.
It should support both conversions as my DLL support them...
04/25/2012 23:44 _DreadNought_#25
Ah yeah it did, it just wasn't very clear...

However when trying to convert 3DEffectObj.dbc I am unable to do it, this exception is as follows(in spoiler)..

04/26/2012 00:11 CptSky#26
Quote:
Originally Posted by _DreadNought_ View Post
Ah yeah it did, it just wasn't very clear...

However when trying to convert 3DEffectObj.dbc I am unable to do it, this exception is as follows(in spoiler)..
The app should use the RSDB [32bits] class and not the EFFE class for this file.
04/26/2012 00:35 _DreadNought_#27
Here is the fixed class:
Code:
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)
          {

          }
     }
}
Tiny code changes, but that now will work with all of the .dbc files.

There was a few useless else's and if's that I have removed. That class works fine and is abit better.
04/26/2012 09:05 2slam#28
well it didnt work for 3deffect.dbc
04/26/2012 10:56 Kiyono#29
Fail on my part.
Code:
if (text.Contains("3deffect"))
                  return "EFFE";
              else if (text.Contains("3deffectobj") || text.Contains("3dobj") || text.Contains("3dtexture") || text.Contains("sound"))
                  return "RSDB32";
Change it to:
Code:
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";
And it should work.

//edit Uploaded it.
04/26/2012 12:11 _DreadNought_#30
Should probably fix your minor unnecessary codes..
for ex
Code:
              if (path.EndsWith(".dbc"))
                    return true;
              else 
                    return false;
why the else?
Code:
              if (path.EndsWith(".dbc"))
                    return true;
              return false;