Пример #1
0
 public void openEditor(EntryEditor editor, int index)
 {
     editor.Entry = GetEntry(index);
 }
Пример #2
0
        public void EditEntry(int index, bool forceHex = false)
        {
            BundleEntry entry = GetEntry(index);

            if (EntryTypeRegistry.IsRegistered(entry.Type) && !forceHex)
            {
                IEntryData data = EntryTypeRegistry.GetHandler(entry.Type);

                TextureCache.ResetCache();
                LoadingDialog loader = new LoadingDialog();
                loader.Status = "Loading: " + entry.ID.ToString("X8");

                Thread loadInstanceThread = null;
                bool   failure            = false;

                loader.Done += (cancelled, value) =>
                {
                    if (cancelled)
                    {
                        loadInstanceThread?.Abort();
                    }
                    else
                    {
                        if (failure)
                        {
                            MessageBox.Show(this, "Failed to load Entry", "Error", MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                        else
                        {
                            loader.Hide();

                            IEntryEditor editor = data.GetEditor(entry);
                            if (editor != null)
                            {
                                editor.ShowDialog(this);
                            }
                            else
                            {
                                DebugUtil.ShowDebug(this, data);
                            }
                            if (ForceOnlySpecificEntry)
                            {
                                Environment.Exit(0);
                            }
                        }
                    }
                    TextureCache.ResetCache();
                };

                loadInstanceThread = new Thread(() =>
                {
                    try
                    {
                        try
                        {
                            failure = !data.Read(entry, loader);
                        }
                        catch (ReadFailedError ex)
                        {
                            MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            failure = true;

                            throw;
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Failed to load Entry", "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                        failure = true;
                    }
                    loader.IsDone = true;
                });
                loadInstanceThread.Start();
                loader.ShowDialog(this);
            }
            else
            {
                EntryEditor editor = new EntryEditor();
                editor.ForceHex = forceHex;
                Task.Run(() => openEditor(editor, index));
                editor.ShowDialog(this);
            }
        }