Пример #1
0
        private void HandleNodeClick(object sender, EventArgs ea)
        {
            itemsList.Items.Clear();

            if (filesTree.SelectedNodes.Count > 0)
            {
                var node = filesTree.SelectedNodes[0];

                if (node.Tag != null)
                {
                    var tag = (NodeTag)node.Tag;
                    if (tag.FullPath.EndsWith(".big"))
                    {
                        BigFile bf = new BigFile();
                        if (bf.Read(tag.FullPath))
                        {
                            //label2.Text = $"archive {Path.GetFileName(tag.FullPath)} has {bf.Entries.Count} files.";

                            foreach (var e in bf.Entries)
                            {
                                DarkListItem item = new DarkListItem(e.Name);
                                item.Tag = new ListTag()
                                {
                                    NodeTag = tag, BigFile = bf, Entry = e
                                };

                                itemsList.Items.Add(item);
                            }
                        }
                        else
                        {
                            MessageBox.Show($"Failed reading {Path.GetFileName(tag.FullPath)} :(");
                        }
                    }
                }
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            Logger = new LogConsole(null, new LogOptions()
            {
                LogTimestamp = false
            });

            Logger.ClearPrependers();

            var origVisible = Console.CursorVisible;
            var origWidth   = Console.WindowWidth;
            var origHeight  = Console.WindowHeight;

            Console.CursorVisible   = false;
            Console.CancelKeyPress += (s, e) =>
            {
                ms_isTerminating = true;
                e.Cancel         = true;
                FinishWithError("User terminated execution.", true);
            };

            if (origWidth < 160)
            {
                Console.WindowWidth = 160;
            }

            if (origHeight < 8 + 16)
            {
                Console.WindowHeight = 8 + 16;
            }

            Console.Clear();

            void DrawCentered(string text, Color col)
            {
                Logger.Info(new string(' ', (Console.WindowWidth - text.Length) / 2), col);
                Console.WriteLine(text);
            }

            string filePath = "";

            if (args.Length == 0)
            {
                TitleDraw.Welcome(Logger);
                DrawCentered("DR2 Format Tools - by avail (alpha)", Color.OrangeRed);

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();

                DrawCentered("Drop a .big or .tex onto me to dump contents.", Color.Cyan);
                DrawCentered("(or drop to exe itself next time instead of launching it first)", Color.Green);

                Logger.Info("\t\t Input -> ", Color.Cyan);

                bool CheckExtension(char[] data, int len)
                {
                    int readOffset = 0;

                    if (data[0] == '"')
                    {
                        readOffset += 1;
                    }

                    if (data[len - (readOffset + 2)] == 't' &&
                        data[len - (readOffset + 1)] == 'e' &&
                        data[len - (readOffset + 0)] == 'x')
                    {
                        return(true);
                    }

                    if (data[len - (readOffset + 2)] == 'b' &&
                        data[len - (readOffset + 1)] == 'i' &&
                        data[len - (readOffset + 0)] == 'g')
                    {
                        return(true);
                    }

                    return(false);
                }

                var input = new char[256];
                for (var i = 0; i < input.Length; i++)
                {
                    input[i] = Console.ReadKey().KeyChar;

                    if (i > 6 && CheckExtension(input, i))
                    {
                        Console.WriteLine();
                        break;
                    }
                }

                filePath = new string(input).Split('\0')[0].Replace("\"", "");

                if (!File.Exists(filePath))
                {
                    FinishWithError("The file you specified isn't valid.");
                }
            }
            else
            {
                filePath = args[0];
                var ext = Path.GetExtension(filePath);

                if (!File.Exists(filePath) || (ext != ".tex" && ext != ".big"))
                {
                    FinishWithError("The file you specified isn't valid.");
                }
            }

            var bf = new BigFile();

            var  dumpDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dump", Path.GetFileNameWithoutExtension(filePath));
            bool success = bf.Read(filePath, true, dumpDir);

            Console.CursorVisible = origVisible;
            //Console.WindowWidth = origWidth;
            //Console.WindowHeight = origHeight;

            Console.Clear();
            Console.SetCursorPosition(0, 0);

            if (success)
            {
                FinishWithSuccess(ProcessElapsed, MetadataElapsed, ExportElapsed, EntryCount);
            }
        }