Exemplo n.º 1
0
        private void toolBtnDump_Click(object sender, EventArgs e)
        {
            if (DoingSomeJob.Working)
            {
                MessageBox.Show("Please wait... Still working in background!", "UO:KR Uop Dumper", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ThreadArgs.MyThreadDelegate mtdParse = delegate(object args)
                {
                    ThreadArgs      theArgs = (ThreadArgs)args;
                    StupidInterface theForm = (StupidInterface)theArgs.Args[0];
                    string          thePath = (string)theArgs.Args[1];
                    string          theFile = (string)theArgs.Args[2];

                    UopManager upIstance = UopManager.getIstance();

                    try
                    {
                        string pathandfile = thePath + @"\" + theFile;

                        if (!Directory.Exists(thePath))
                        {
                            Directory.CreateDirectory(thePath);
                        }

                        using (StreamWriter swFile = new StreamWriter(pathandfile, false))
                        {
                            swFile.Write(UopManager.getIstance().UopFile.ToString());
                        }

                        theForm.SetTextArea("Completed information dump.");
                    }
                    catch
                    {
                        theForm.SetTextArea("ERROR while writing information dump.");
                    }
                    finally
                    {
                        theForm.DisableOtherIcon(false);
                        theForm.SetLoadIcon(true);
                        DoingSomeJob.Working = false;
                    }
                };

                DoingSomeJob.Working = true;

                string sPath = Application.StartupPath + StaticData.DUMPINFO_DIR;
                string sFile = Utility.GetFileName(UopManager.getIstance().UopPath) + ".txt";

                SetTextArea("Dumping UOP file to \"" + sPath + "\\" + sFile + "\" ...");
                this.SetDisableIcon(true);
                this.SetLoadIcon(false);

                System.Threading.Thread tRun = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(mtdParse));
                tRun.Start(new ThreadArgs(new object[] { this, sPath, sFile }));
            }
        }
Exemplo n.º 2
0
        private void CommonSave(string sFile, bool bFix)
        {
            if (DoingSomeJob.Working)
            {
                MessageBox.Show("Please wait... Still working in background!", "UO:KR Uop Dumper", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ThreadArgs.MyThreadDelegate mtdParse = delegate(object args)
                {
                    ThreadArgs      theArgs = (ThreadArgs)args;
                    StupidInterface theForm = (StupidInterface)theArgs.Args[0];
                    string          theFile = (string)theArgs.Args[1];
                    bool            theFix  = (bool)theArgs.Args[2];

                    UopManager upIstance = UopManager.getIstance();

                    if (theFix)
                    {
                        upIstance.FixOffsets(0, 0);
                    }

                    bool bResult = upIstance.Write(theFile);

                    if (bResult)
                    {
                        theForm.SetTextArea("Done saving UOP file.");

                        if (!upIstance.UopPath.Equals(theFile, StringComparison.OrdinalIgnoreCase))
                        {
                            upIstance.UopPath = theFile;
                        }
                    }
                    else
                    {
                        theForm.SetTextArea("ERROR while saving file \"" + theFile + "\" !!!");
                    }

                    theForm.DisableOtherIcon(false);
                    theForm.SetLoadIcon(true);
                    DoingSomeJob.Working = false;
                };

                DoingSomeJob.Working = true;
                SetTextArea("Saving UOP file to \"" + sFile + "\" ...");
                this.SetDisableIcon(true);
                this.SetLoadIcon(false);

                System.Threading.Thread tRun = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(mtdParse));
                tRun.Start(new ThreadArgs(new object[] { this, sFile, bFix }));
            }
        }
Exemplo n.º 3
0
        private void LoadUOP(string theNewFile)
        {
            ThreadArgs.MyThreadDelegate mtdParse = delegate(object args)
            {
                ThreadArgs      theArgs = (ThreadArgs)args;
                StupidInterface theForm = (StupidInterface)theArgs.Args[0];
                string          theFile = (string)theArgs.Args[1];

                UopManager upIstance = UopManager.getIstance(true);
                upIstance.UopPath = theFile;

                bool bResult = upIstance.Load();

                if (bResult)
                {
                    theForm.SetTextArea("Done parsing.");
                }
                else
                {
                    theForm.SetTextArea("ERROR while parsing file \"" + theFile + "\" !!!");
                }

                if (bResult)
                {
                    theForm.SetNodes();
                    theForm.DisableOtherIcon(false);
                }

                theForm.SetLoadIcon(true);
                DoingSomeJob.Working = false;
            };

            DoingSomeJob.Working = true;
            this.SetTextArea("Parsing file \"" + theNewFile + "\" ...");

            this.SetDisableIcon(true);
            this.SetLoadIcon(false);

            System.Threading.Thread tRun = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(mtdParse));
            tRun.Start(new ThreadArgs(new object[] { this, theNewFile }));
        }
Exemplo n.º 4
0
        private void CommonDump(ShowPanels spType, object oCast)
        {
            if (DoingSomeJob.Working)
            {
                MessageBox.Show("Please wait... Still working in background!", "UO:KR Uop Dumper", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ThreadArgs.MyThreadDelegate mtdParse = delegate(object args)
                {
                    ThreadArgs      theArgs   = (ThreadArgs)args;
                    StupidInterface theForm   = (StupidInterface)theArgs.Args[0];
                    string          thePath   = (string)theArgs.Args[1];
                    ShowPanels      theType   = (ShowPanels)theArgs.Args[2];
                    object          theObject = theArgs.Args[3];

                    UopManager upIstance  = UopManager.getIstance();
                    string     baseName   = Path.GetFileNameWithoutExtension(upIstance.UopPath);
                    string     resultName = "";

                    try
                    {
                        if (!Directory.Exists(thePath))
                        {
                            Directory.CreateDirectory(thePath);
                        }

                        int i = 0, j = 0;

                        switch (spType)
                        {
                        case ShowPanels.RootNode:
                        {
                            UOPFile toDump = (UOPFile)theObject;
                            foreach (UOPIndexBlockHeader dumpTemp1 in toDump.m_Content)
                            {
                                foreach (UOPPairData dumpTemp2 in dumpTemp1.m_ListData)
                                {
                                    using (FileStream fsWrite = File.Create(thePath + @"\" + String.Format(StaticData.UNPACK_NAMEPATTERN, baseName, i, j, dumpTemp2.First.IsCompressed ? StaticData.UNPACK_EXT_COMP : StaticData.UNPACK_EXT_UCOMP)))
                                    {
                                        using (BinaryWriter bwWrite = new BinaryWriter(fsWrite))
                                        {
                                            bwWrite.Write(dumpTemp2.Second.Extract(dumpTemp2.First.IsCompressed, dumpTemp2.First.m_LenghtUncompressed));
                                        }
                                    }

                                    j++;
                                }

                                i++;
                                j = 0;
                            }

                            resultName = "the UOP file.";
                        } break;

                        case ShowPanels.DataNode:
                        {
                            UOPIndexBlockHeader toDump = (UOPIndexBlockHeader)theObject;
                            foreach (UOPIndexBlockHeader dumpTemp1 in upIstance.UopFile.m_Content)
                            {
                                if (dumpTemp1.Equals(toDump))
                                {
                                    break;
                                }

                                i++;
                            }

                            foreach (UOPPairData dumpTemp2 in toDump.m_ListData)
                            {
                                using (FileStream fsWrite = File.Create(thePath + @"\" + String.Format(StaticData.UNPACK_NAMEPATTERN, baseName, i, j, dumpTemp2.First.IsCompressed ? StaticData.UNPACK_EXT_COMP : StaticData.UNPACK_EXT_UCOMP)))
                                {
                                    using (BinaryWriter bwWrite = new BinaryWriter(fsWrite))
                                    {
                                        bwWrite.Write(dumpTemp2.Second.Extract(dumpTemp2.First.IsCompressed, dumpTemp2.First.m_LenghtUncompressed));
                                    }
                                }

                                j++;
                            }

                            resultName = "the Header Block " + i.ToString() + ".";
                        } break;

                        case ShowPanels.SingleHeader:
                        {
                            UOPPairData toDump = (UOPPairData)theObject; bool bBreakLoop = false;
                            foreach (UOPIndexBlockHeader dumpTemp1 in upIstance.UopFile.m_Content)
                            {
                                foreach (UOPPairData dumpTemp2 in dumpTemp1.m_ListData)
                                {
                                    bBreakLoop = dumpTemp2.Equals(toDump);
                                    if (bBreakLoop)
                                    {
                                        break;
                                    }

                                    j++;
                                }

                                if (bBreakLoop)
                                {
                                    break;
                                }

                                i++;
                                j = 0;
                            }

                            using (FileStream fsWrite = File.Create(thePath + @"\" + String.Format(StaticData.UNPACK_NAMEPATTERN, baseName, i, j, toDump.First.IsCompressed ? StaticData.UNPACK_EXT_COMP : StaticData.UNPACK_EXT_UCOMP)))
                            {
                                using (BinaryWriter bwWrite = new BinaryWriter(fsWrite))
                                {
                                    bwWrite.Write(toDump.Second.Extract(toDump.First.IsCompressed, toDump.First.m_LenghtUncompressed));
                                }
                            }

                            resultName = "the Index " + j.ToString() + ".";
                        } break;
                        }

                        GC.Collect();
                        theForm.SetTextArea("Completed unpacking for " + resultName);
                    }
                    catch
                    {
                        theForm.SetTextArea("ERROR while unpacking selected data.");
                    }
                    finally
                    {
                        theForm.DisableOtherIcon(false);
                        theForm.SetLoadIcon(true);
                        DoingSomeJob.Working = false;
                    }
                };

                DoingSomeJob.Working = true;
                SetTextArea("Unpacking seleceted data to \"" + Application.StartupPath + StaticData.UNPACK_DIR + "\" ...");
                this.SetDisableIcon(true);
                this.SetLoadIcon(false);

                System.Threading.Thread tRun = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(mtdParse));
                tRun.Start(new ThreadArgs(new object[] { this, Application.StartupPath + StaticData.UNPACK_DIR, spType, oCast }));
            }
        }