Exemplo n.º 1
0
        private void configsLoaded()
        {
            string          skillstr      = @"Configs\skillstr.txt";
            string          buff_str      = @"Configs\buff_str.txt";
            string          item_ext_desc = @"Configs\item_ext_desc.txt";
            string          item_color    = @"Configs\item_color.txt";
            List <PckEntry> dd1           = configspckManager.getDirectory(Path.GetDirectoryName(skillstr), true, Path.GetFileName(skillstr));
            List <PckEntry> dd2           = configspckManager.getDirectory(Path.GetDirectoryName(buff_str), true, Path.GetFileName(buff_str));
            List <PckEntry> dd3           = configspckManager.getDirectory(Path.GetDirectoryName(item_ext_desc), true, Path.GetFileName(item_ext_desc));
            List <PckEntry> dd4           = configspckManager.getDirectory(Path.GetDirectoryName(item_color), true, Path.GetFileName(item_color));

            Task <bool>[] taskList =
            {
                Task.Factory.StartNew(() => LoadSkillList(_NAME,       new MemoryStream(dd1[0].bytes)), ct), //Configs//skillstr.txt
                Task.Factory.StartNew(() => LoadBuffList(_NAME,        new MemoryStream(dd2[0].bytes)), ct), //buff_str.txt
                Task.Factory.StartNew(() => LoadItemDescription(_NAME, new MemoryStream(dd3[0].bytes)), ct), //item_ext_desc.txt
                Task.Factory.StartNew(() => loadItem_color(_NAME,      new MemoryStream(dd4[0].bytes)), ct), //item_color.txt
            };
            Task.WaitAll(taskList);
            CURRENT_SESSION.isredyC2           = true;
            CURRENT_SESSION.hasJustBecomeReady = CURRENT_SESSION.isredyC2;
            if (CURRENT_SESSION.hasJustBecomeReady)
            {
                PackDatabase.Instance.Clear();
            }
        }
Exemplo n.º 2
0
        public bool ExtractSfx()
        {
            try
            {
                string     sfx        = Directory.GetParent(Path.GetDirectoryName(ElementEditorPath)).FullName + Path.DirectorySeparatorChar + "sfx.pck";
                PackHelper gfxManager = getManager("sfx.pck", sfx, null, false, false);
                if (gfxManager == null)
                {
                    return(true);
                }
                foreach (string str in this.sfx)
                {
                    List <PckEntry> dd = gfxManager.getDirectory(Path.GetDirectoryName(str), true, Path.GetFileName(str));
                    for (int i = 0; i < dd.Count; i++)
                    {
                        PckEntry curGfx  = dd[i];
                        string   dirpath = Path.GetDirectoryName(Path.Combine(saveDirectory, curGfx.fullP));
                        string   subpath = Path.Combine(saveDirectory, curGfx.fullP);
                        string   fileEx  = Path.GetExtension(subpath).Replace(".", "").ToLower();
                        if (!Directory.Exists(dirpath))
                        {
                            Directory.CreateDirectory(dirpath);
                        }

                        File.WriteAllBytes(subpath, curGfx.bytes);
                    }
                }
            }
            catch { }
            return(true);
        }
Exemplo n.º 3
0
        private void SurfacesLoaded()
        {
            string          iconlist_ivtrmdds = @"surfaces\iconset\iconlist_ivtrm.dds".Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar).ToLower();
            string          iconlist_ivtrmtxt = @"surfaces\iconset\iconlist_ivtrm.txt".Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar).ToLower();
            List <PckEntry> dd  = surfacespckManager.getDirectory(Path.GetDirectoryName(iconlist_ivtrmdds), true, Path.GetFileName(iconlist_ivtrmdds));
            List <PckEntry> dd2 = surfacespckManager.getDirectory(Path.GetDirectoryName(iconlist_ivtrmtxt), true, Path.GetFileName(iconlist_ivtrmtxt));

            Task <bool>[] taskList =
            {
                Task.Factory.StartNew(() => loadSurfaces(_NAME, new MemoryStream(dd[0].bytes), new MemoryStream(dd2[0].bytes)), ct)    // iconlist_ivtrm.dds // txt
            };
            Task.WaitAll(taskList);
            CURRENT_SESSION.isredyC1           = true;
            CURRENT_SESSION.hasJustBecomeReady = CURRENT_SESSION.isredyC2;
            if (CURRENT_SESSION.hasJustBecomeReady)
            {
                PackDatabase.Instance.Clear();
            }
        }
Exemplo n.º 4
0
        public void SaveTextures(PckEntry entry)
        {
            try
            {
                string      gfx        = Directory.GetParent(Path.GetDirectoryName(ElementEditorPath)).FullName + Path.DirectorySeparatorChar + "gfx.pck";
                const Int32 BufferSize = 128;
                using (var streamReader = new StreamReader(new MemoryStream(entry.bytes), Encoding.GetEncoding("GB2312"), true, BufferSize))
                {
                    String line;
                    while ((line = streamReader.ReadLine()) != null)
                    {
                        if (line.ToLower().StartsWith("texfile"))
                        {
                            string fileName = line.Split(':')[1].TrimStart();
                            if (fileName.Length > 3)
                            {
                                PackHelper aa = getManager("gfx.pck", gfx, null);
                                if (aa != null)
                                {
                                    List <PckEntry> dd = aa.getDirectory("gfx" + Path.DirectorySeparatorChar + "textures" + Path.DirectorySeparatorChar + Path.GetDirectoryName(fileName), true, Path.GetFileName(fileName));
                                    for (int i = 0; i < dd.Count; i++)
                                    {
                                        PckEntry curGfx  = dd[i];
                                        string   dirpath = Path.GetDirectoryName(Path.Combine(saveDirectory, curGfx.fullP));
                                        string   subpath = Path.Combine(saveDirectory, curGfx.fullP);
                                        string   fileEx  = Path.GetExtension(subpath).Replace(".", "").ToLower();
                                        if (!Directory.Exists(dirpath))
                                        {
                                            Directory.CreateDirectory(dirpath);
                                        }

                                        File.WriteAllBytes(subpath, curGfx.bytes);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch { }
        }
Exemplo n.º 5
0
        private void UnpackDirectoryOrFiles(object sender, EventArgs e)
        {
            if (lockedItemDrop || selectedPck == null || selectedtree == null)
            {
                return;
            }
            using (var fbd = new FolderBrowserDialog())
            {
                progress_bar("Extracting...", 0, 0);
                DialogResult result = fbd.ShowDialog();
                if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
                {
                    string pckName  = selectedPck.fiullFilePath;
                    string savePath = fbd.SelectedPath;
                    if (openedPckFies != null)
                    {
                        List <PckEntry> filesToSave = new List <PckEntry>();
                        // this.Cursor = Cursors.WaitCursor;
                        foreach (ListViewItem item in FileList.SelectedItems)
                        {
                            int index = item.Index;
                            if (FileList.Items[index].Tag is PckEntry)
                            {
                                PckEntry file = (PckEntry)FileList.Items[index].Tag;
                                if (Path.HasExtension(file.filePath))
                                {
                                    filesToSave.AddRange(openedPckFies.getDirectory(file.filePath, true, Path.GetFileName(file.filePath)));
                                }
                                else
                                {
                                    filesToSave.AddRange(openedPckFies.getDirectory(file.filePath));
                                }
                            }
                            else
                            {
                                if (FileList.Items[index].Tag is FolderTreeModel)
                                {
                                    FolderTreeModel file = (FolderTreeModel)FileList.Items[index].Tag;

                                    filesToSave.AddRange(openedPckFies.getDirectory(textBox1.Text + Path.DirectorySeparatorChar + file.Title));
                                }
                            }
                        }
                        if (filesToSave.Count > 0)
                        {
                            foreach (PckEntry item in filesToSave)
                            {
                                string dirpath = Path.GetDirectoryName(Path.Combine(savePath, item.fullP));
                                string subpath = Path.Combine(savePath, item.fullP);
                                string fileEx  = Path.GetExtension(subpath).Replace(".", "").ToLower();
                                if (!Directory.Exists(dirpath))
                                {
                                    Directory.CreateDirectory(dirpath);
                                }

                                File.WriteAllBytes(subpath, item.bytes);
                            }
                        }
                        // this.Cursor = Cursors.Default;
                    }
                }
            }
            progress_bar("Ready", 0, 0);
        }
Exemplo n.º 6
0
        private void viewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lockedCheck)
            {
                return;
            }
            if (dynObjcts == null)
            {
                return;
            }
            if (ElementsEditor.eLC == null)
            {
                JMessageBox.Show(this, "Element Editor must be loaded to use this function!");
                return;
            }
            try
            {
                if (listBox_items.CurrentCell != null && listBox_items.CurrentCell != null)
                {
                    int    element  = listBox_items.CurrentCell.RowIndex;
                    string path     = dynObjcts.objects[element].Path.Value;
                    string savePath = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "ModelView" + Path.DirectorySeparatorChar + "dataexe";
                    string exe      = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "ModelView" + Path.DirectorySeparatorChar + "model.exe";

                    string modelPath    = path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar).ToLower();
                    string mainPackName = modelPath.Split(Path.DirectorySeparatorChar)[0] + ".pck";
                    string packPath     = Directory.GetParent(Path.GetDirectoryName(ElementsEditor.eLC.loadedFile)).FullName + Path.DirectorySeparatorChar + mainPackName;
                    bool   found        = false;

                    tpackManager = PackDatabase.Instance.getManager(mainPackName, packPath, () => {
                        if (tpackManager != null)
                        {
                            List <PckEntry> files = tpackManager.getDirectory(Path.GetDirectoryName(modelPath));
                            string titles         = modelPath;
                            ModelClass model      = new ModelClass();

                            foreach (PckEntry file in files)
                            {
                                string extenstion = Path.GetExtension(file.fullP);
                                if (extenstion.ToLower().Equals(".ski"))
                                {
                                    model.skyfile = file.bytes;
                                    found         = true;
                                }
                                if (extenstion.ToLower().Equals(".dds"))
                                {
                                    model.DDSIMAGE.Add(Path.GetFileName(file.fullP), file.bytes);
                                }
                            }
                            if (found)
                            {
                                using (BinaryWriter br = new BinaryWriter(new FileStream(savePath, FileMode.Create, FileAccess.Write)))
                                {
                                    byte[] title = Encoding.GetEncoding(936).GetBytes(titles);
                                    br.Write(title.Length);
                                    br.Write(title);
                                    br.Write(model.skyfile.Length);
                                    br.Write(model.skyfile);
                                    br.Write(model.DDSIMAGE.Count);
                                    foreach (KeyValuePair <string, byte[]> xxa in model.DDSIMAGE)
                                    {
                                        byte[] titlex = Encoding.GetEncoding(936).GetBytes(xxa.Key);
                                        br.Write(titlex.Length);
                                        br.Write(titlex);
                                        br.Write(xxa.Value.Length);
                                        br.Write(xxa.Value);
                                    }
                                }
                                Process.Start(exe);
                            }
                        }
                    }
                                                                    , true);
                }
            }
            catch { }
        }