public void Init()
        {
            if (GlobalStuff.FindSetting("isNew") == "1")
            {
                MessageBox.Show("Please initialize the database in Misc > Database with Scan");
                this.BeginInvoke(new MethodInvoker(Close));
                return;
            }
            string path = GlobalStuff.FindSetting("gamepath");

            path += "Data\\cas.cat";
            cat   = new CATFile(path);
            SQLiteConnection con = Database.GetConnection();

            con.Open();
            SQLiteDataReader reader = new SQLiteCommand("SELECT path FROM langsbfiles WHERE path LIKE '%\\loctext\\%' ORDER BY path ", con).ExecuteReader();

            toolStripComboBox1.Items.Clear();
            languages = new List <string>();
            while (reader.Read())
            {
                languages.Add(reader.GetString(0));
            }
            con.Close();
            foreach (string l in languages)
            {
                toolStripComboBox1.Items.Add(Path.GetFileNameWithoutExtension(l));
            }
            toolStripComboBox1.SelectedIndex = 0;
            language = new SBFile(languages[0]);
            MakeTree();
            init = true;
        }
Exemplo n.º 2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.sb|*.sb";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                sb = new SBFile(d.FileName);
            }
            else
            {
                return;
            }
            if (cat == null)
            {
                d.Filter = "*.cat|*.cat";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    cat = new CATFile(d.FileName);
                }
            }
            if (langTOC == null)
            {
                d.Filter = "*.toc|*.toc";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    langTOC = new TOCFile(d.FileName);
                }
                LoadTOC();
            }
            RefreshMe();
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            int n = toolStripComboBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            language = new SBFile(languages[n]);
            MakeTree();
        }
        private void opensbToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.sb|*.sb";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                sb = new SBFile(d.FileName);
                RefreshMe();
            }
        }
Exemplo n.º 5
0
        private void openRawBundleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "*.bundle|*.bundle";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                toolStrip1.Visible = true;
                splitContainer2.BringToFront();
                sb = new SBFile(d.FileName);
                RefreshTree();
                return;
            }
        }
Exemplo n.º 6
0
 public void LoadFile(string path)
 {
     this.Text = "SB Tool - " + path;
     toc       = new TOCFile(Helpers.GetFileNameWithOutExtension(path) + ".toc");
     if (toc.iscas)
     {
         toolStrip1.Visible = true;
         splitContainer2.BringToFront();
         sb = new SBFile(path);
         RefreshTree();
     }
     else
     {
         toolStrip1.Visible = false;
         tabControl1.BringToFront();
         RefreshBinary();
     }
 }
Exemplo n.º 7
0
        private void ScanBundles(CATFile cat)
        {
            Log("Saving bundles into db...");
            SQLiteConnection con = Database.GetConnection();

            con.Open();
            SQLiteDataReader reader = Database.getAll("sbfiles", con);
            StringBuilder    sb     = new StringBuilder();
            List <string>    files  = new List <string>();

            while (reader.Read())
            {
                files.Add(reader.GetString(0));
            }
            int       counter = 1;
            Stopwatch sp      = new Stopwatch();

            sp.Start();
            foreach (string file in files)
            {
                Log("Opening " + file + " ...");
                SBFile sbfile = new SBFile(file);
                Log(" found " + sbfile.bundles.Count + " bundles, saving to db...");
                var transaction = con.BeginTransaction();
                int counter2    = 1;
                foreach (Bundle b in sbfile.bundles)
                {
                    if (b.ebx == null)
                    {
                        b.ebx = new List <Bundle.ebxtype>();
                    }
                    Log("  processing bundle: " + (counter2++) + "/" + sbfile.bundles.Count + " \"" + b.path + "\" (ebxcount = " + b.ebx.Count + ") ...");
                    Database.AddBundle(file, b, con, cat);
                }
                transaction.Commit();
                long     elapsed = sp.ElapsedMilliseconds;
                long     ETA     = ((elapsed / counter) * files.Count);
                TimeSpan ETAt    = TimeSpan.FromMilliseconds(ETA);
                Log((counter++) + "/" + files.Count + " files done." + " - Elapsed: " + sp.Elapsed.ToString() + " ETA: " + ETAt.ToString());
            }
            con.Clone();
        }
Exemplo n.º 8
0
        public void PreviewFile(string path)
        {
            string  ext = Path.GetExtension(path).ToLower();
            TOCFile toc;

            switch (ext)
            {
            case ".toc":
                toc = new TOCFile(path);
                if (toc != null && toc.lines != null)
                {
                    Helpers.FillTreeFast(treeView2, toc.lines);
                }
                break;

            case ".sb":
                string tocpath = Helpers.GetFileNameWithOutExtension(path) + ".toc";
                if (File.Exists(tocpath))
                {
                    toc = new TOCFile(tocpath);
                    if (toc != null && toc.lines != null && toc.lines.Count != 0)
                    {
                        foreach (BJSON.Field f in toc.lines[0].fields)
                        {
                            if (f.fieldname == "cas" && (bool)f.data)
                            {
                                SBFile sb = new SBFile(path);
                                if (sb != null && sb.lines != null)
                                {
                                    Helpers.FillTreeFast(treeView2, sb.lines);
                                }
                                return;
                            }
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 9
0
        public Task <FileMessage> SendImage(GroupChannel channel, string userId, string userName, string memberToken, string fileUrl, string date)
        {
            var tcs = new TaskCompletionSource <FileMessage>();

            if (channel == null)
            {
                tcs.TrySetCanceled();
                return(tcs.Task);
            }

            var file = new SBFile(fileUrl);

            channel.SendFileMessage(file, file.FileName, "image/jpeg", (int)file.Length, date, (FileMessage message, SendBirdException e) => {
                if (e != null)
                {
                    tcs.TrySetCanceled();
                }

                tcs.TrySetResult(message);
                SendPushNotification(userId, userName, memberToken, "", NotificationType.Image);
            });

            return(tcs.Task);
        }
Exemplo n.º 10
0
        private void CompareSB(string file1, string file2)
        {
            if (!File.Exists(file1) || !File.Exists(file2))
            {
                return;
            }
            SBFile sb1 = new SBFile(file1);
            SBFile sb2 = new SBFile(file2);

            foreach (Bundle b in sb1.bundles)
            {
                Bundle b2 = null;
                foreach (Bundle c in sb2.bundles)
                {
                    if (c.path == b.path)
                    {
                        b2 = c;
                        break;
                    }
                }
                if (b2 == null)
                {
                    continue;
                }
                StringBuilder sb = new StringBuilder();
                sb.Append(" D:bundle " + b.path + "\n");
                bool diff = false;
                foreach (Bundle.ebxtype ebx in b.ebx)
                {
                    Bundle.ebxtype ebx2 = new Bundle.ebxtype();
                    ebx2.name = "";
                    foreach (Bundle.ebxtype compare in b2.ebx)
                    {
                        if (ebx.name == compare.name)
                        {
                            ebx2 = compare;
                            break;
                        }
                    }
                    if (ebx2.name == "")
                    {
                        sb.Append("  E:ebx not found - " + ebx.name + "\n");
                        continue;
                    }
                    sb.Append(CompareEBX(ebx, ebx2, diff, out diff));
                }
                foreach (Bundle.restype res in b.res)
                {
                    Bundle.restype res2 = new Bundle.restype();
                    res2.name = "";
                    foreach (Bundle.restype compare in b2.res)
                    {
                        if (res.name == compare.name)
                        {
                            res2 = compare;
                            break;
                        }
                    }
                    if (res2.name == "")
                    {
                        sb.Append("  E:res not found - " + res.name + "\n");
                        continue;
                    }
                    sb.Append(CompareRES(res, res2, diff, out diff));
                }
                foreach (Bundle.chunktype chunk in b.chunk)
                {
                    Bundle.chunktype chunk2 = new Bundle.chunktype();
                    chunk2.id = new byte[0];
                    foreach (Bundle.chunktype compare in b2.chunk)
                    {
                        if (Helpers.ByteArrayCompare(chunk.id, compare.id))
                        {
                            chunk2 = compare;
                            break;
                        }
                    }
                    if (chunk2.id.Length == 0)
                    {
                        sb.Append("  E:chunk not found - " + Helpers.ByteArrayToHexString(chunk.id) + "\n");
                        continue;
                    }
                    sb.Append(CompareCHUNK(chunk, chunk2, diff, out diff));
                }
                if (diff)
                {
                    P(sb.ToString());
                }
            }
        }