Beispiel #1
0
        public async void TS_Load_Data_Click(object sender, EventArgs e)
        {
            if (!structLoaded)
            {
                MessageBox.Show("You can not do that until a structure has been loaded!", "Structure Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            dCore                  = new DataCore.Core(Encodings.GetByName(ts_enc_list.Text));
            Paths.Title            = "Select client data.000";
            Paths.DefaultDirectory = OPT.GetString("data.load.directory");
            string dataPath = Paths.FilePath;

            if (Paths.FileResult == DialogResult.OK)
            {
                lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "RDB Tab: {0} attempting load file selection from index at path:\n\t- {1}", tManager.Text, dataPath);

                List <DataCore.Structures.IndexEntry> results = null;

                await Task.Run(() =>
                {
                    dCore.Load(dataPath);
                    results = dCore.GetEntriesByExtensions("rdb", "ref");
                });

                lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "File list retrived successfully!\n\t- Selections available: {0}", results.Count);

                using (Grimoire.GUI.ListSelect selectGUI = new GUI.ListSelect("Select RDB", results))
                {
                    selectGUI.FormClosing += (o, x) =>
                    {
                        if (selectGUI.DialogResult == DialogResult.OK)
                        {
                            string fileName = selectGUI.SelectedText;
                            DataCore.Structures.IndexEntry finalResult = results.Find(i => i.Name == fileName);
                            byte[] fileBytes = dCore.GetFileBytes(finalResult);

                            if (fileBytes.Length > 0)
                            {
                                load_file(fileName, fileBytes);
                            }
                        }
                        else
                        {
                            lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "User cancelled Data load on RDB Tab: {0}", tManager.Text);
                            return;
                        }
                    };
                    selectGUI.ShowDialog(Grimoire.GUI.Main.Instance);
                }
            }
        }
Beispiel #2
0
        public DataCore.Core DataCoreByKey(string key)
        {
            if (pages == null || pages.Count == 0)
            {
                return(null);
            }

            if (!pages.ContainsKey(key))
            {
                return(null);
            }

            DataCore.Core ret = null;
            GUI.Main.Instance.Invoke(new MethodInvoker(delegate { ret = ((Styles.Data)pages[key].Controls[0]).Core; }));

            return(ret);
        }
Beispiel #3
0
        private async void load_data_file(string filePath)
        {
            dCore = new DataCore.Core(Encodings.GetByName(ts_enc_list.Text));

            lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "RDB Tab: {0} attempting load file selection from index at path:\n\t- {1}", tManager.Text, filePath);

            List <DataCore.Structures.IndexEntry> results = null;

            actionSW.Reset();
            actionSW.Start();

            await Task.Run(() =>
            {
                dCore.Load(filePath);
                results = dCore.GetEntriesByExtensions("rdb", "ref");
            });

            lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "File list retrived successfully! ({0}ms)\n\t- Selections available: {1}",
                           actionSW.ElapsedMilliseconds.ToString("D4"),
                           results.Count);

            using (Grimoire.GUI.ListSelect selectGUI = new GUI.ListSelect("Select RDB", results))
            {
                selectGUI.ShowDialog(Grimoire.GUI.Main.Instance);

                if (selectGUI.DialogResult == DialogResult.OK)
                {
                    string fileName = selectGUI.SelectedText;
                    DataCore.Structures.IndexEntry finalResult = results.Find(i => i.Name == fileName);
                    byte[] fileBytes = dCore.GetFileBytes(finalResult);

                    lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "User selected rdb: {0}", fileName);

                    if (fileBytes.Length > 0)
                    {
                        load_file(fileName, fileBytes);
                    }
                }
                else
                {
                    lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "User cancelled Data load on RDB Tab: {0}", tManager.Text);
                    return;
                }
            }
        }
Beispiel #4
0
Datei: GUI.cs Projekt: odasm/rMOD
        private async void saveFileBtn_Click(object sender, EventArgs e)
        {
            DataCore.Core dCore = new DataCore.Core();

            if (RDBControls.GridRows > 0)
            {
                string savePath = OPT.GetString("save.directory");
                if (string.IsNullOrEmpty(savePath))
                {
                    string structFileName = structFileName = string.Format(@"{0}.{1}", StructureManager.FileName(RDBControls.StructureListValue), rCore.Extension);
                    string fileName       = OPT.GetBool("save.hashed") ? dCore.EncodeName(structFileName) : structFileName;

                    using (SaveFileDialog sfDlg = new SaveFileDialog()
                    {
                        Filter = "All files (*.*)|*.*|RDB files (*.rdb)|*.rdb|REF files (*.ref)|*.ref", Title = "Define the name of your rdb", FileName = fileName
                    })
                    {
                        if (sfDlg.ShowDialog(this) == DialogResult.OK)
                        {
                            if (!string.IsNullOrEmpty(sfDlg.FileName))
                            {
                                savePath = sfDlg.FileName;
                            }
                        }
                    }
                }
                else
                {
                    savePath += GuessName.Result(RDBControls.StructureListValue, NameType.File);
                }

                if (!string.IsNullOrEmpty(savePath))
                {
                    await Task.Run(() => { rdbCores[tabIdx].WriteRDB(savePath); });
                }
            }
        }
Beispiel #5
0
 public void LoadAll()
 {
     dCore = tManager.DataCore;
     readSPR("01_equip(ascii).spr");
     readSPR("02_item(ascii).spr");
 }