コード例 #1
0
ファイル: Form1.cs プロジェクト: furrychemistry/UOX3-Tools
        private void cmdUOX3IniFind_Click(object sender, System.EventArgs e)
        {
            opnFileDialog.Filter = "INI files (*.ini)|*.ini|All files (*.*)|*.*";
            if (opnFileDialog.ShowDialog() == DialogResult.OK)
            {
                txtUOX3Ini.Text = opnFileDialog.FileName;
                iniScript       = new UOXData.Script.Script(txtUOX3Ini.Text);

                UOXData.Script.ScriptSection dirSect = iniScript.FindSection("directories");
                if (dirSect != null)
                {
                    dfnPath = dirSect.FindTag("DEFSDIRECTORY");
                }
                else
                {
                    dfnPath = "";
                }
            }
            else
            {
                txtUOX3Ini.Text = "";
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: furrychemistry/UOX3-Tools
        public SetupInfo(UOXData.Script.Script iniScript)
        {
            iniFile = iniScript;
            dfnPath = "";
            jsPath  = "";
            UOXData.Script.ScriptSection dirSect = iniScript.FindSection("directories");
            if (dirSect != null)
            {
                dfnPath = dirSect.FindTag("DEFSDIRECTORY").Replace("\\", "/");
                jsPath  = dirSect.FindTag("SCRIPTSDIRECTORY").Replace("\\", "/");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("No definitions directory found!");
                return;
            }

            configScripts    = new UOXData.Script.Script[3];
            configScripts[0] = new UOXData.Script.Script(jsPath + "/jse_fileassociations.scp");
            configScripts[1] = new UOXData.Script.Script(jsPath + "/jse_objectassociations.scp");
            configScripts[2] = new UOXData.Script.Script(jsPath + "/jse_typeassociations.scp");
            jsFiles          = new System.Collections.Hashtable();
            generalSetup     = new System.Collections.ArrayList[6];
            for (int i = 0; i < 6; ++i)
            {
                generalSetup[i] = new System.Collections.ArrayList();
            }

            dfnFiles = new System.Collections.ArrayList[(int)UOXData.Script.DFN_Categories.NUM_DEFS];
            for (int i = (int)UOXData.Script.DFN_Categories.FIRST_DEF; i < (int)UOXData.Script.DFN_Categories.NUM_DEFS; ++i)
            {
                dfnFiles[i] = new System.Collections.ArrayList();
            }

            inUse = new UOXData.Script.ScriptSection();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: furrychemistry/UOX3-Tools
        public void Parse(UOXData.Script.Script stpInfo)
        {
            UOXData.Script.ScriptSection mSection = null;

            mSection = stpInfo.FindSection("DESCRIPTION");
            if (mSection != null)
            {
                UOXData.Script.TagDataPair t = mSection.GetDataPair("DIRECTORY");
                if (t != null)
                {
                    dirPath = t.Data.Value.Replace("\\", "/");
                    if (dirPath[dirPath.Length - 1] != '/')
                    {
                        dirPath += "/";
                    }
                }
                else
                {
                    dirPath = "custom/";
                }
            }
            else
            {
                dirPath = "custom/";
            }
            // parse the individual DFN sections now and store what goes where
            for (int i = (int)UOXData.Script.DFN_Categories.FIRST_DEF; i < (int)UOXData.Script.DFN_Categories.NUM_DEFS; ++i)
            {
                mSection = stpInfo.FindSection(((UOXData.Script.DFN_Categories)i).ToString());
                if (mSection != null)
                {
                    foreach (UOXData.Script.TagDataPair t in mSection.TagDataPairs)
                    {
                        dfnFiles[i].Add(t.Data);
                    }
                }
            }
            // Now let's grab the JS file request stuff, and find some free mappings
            // so that we can update the config files
            mSection = stpInfo.FindSection("JS_FILES");
            if (mSection != null)
            {
                foreach (UOXData.Script.TagDataPair t in mSection.TagDataPairs)
                {
                    int freeNumber = FindFreeNumber(inUse);
                    if (freeNumber != -1)
                    {
                        jsFiles.Add(t.Tag, freeNumber);
                        inUse.Add(freeNumber.ToString(), t.Data.Value);
                    }
                }
            }

            // OK, we've built up our list of free numbers
            // Now let's update the relevant config files
            // with the newly acquired data
            UOXData.Script.ScriptSection tSection = null;
            string [] sectTypes = new string[6];
            sectTypes[0] = "COMMAND";
            sectTypes[1] = "MAGIC";
            sectTypes[2] = "CONSOLE";
            sectTypes[3] = "PACKET";
            sectTypes[4] = "SKILLUSE";
            sectTypes[5] = "GENERIC";
            mSection     = stpInfo.FindSection("CONFIGURE");
            if (mSection != null)
            {
                for (int i = 0; i < 6; ++i)
                {
                    UOXData.Script.TagDataPair t = mSection.GetDataPair(sectTypes[i]);
                    if (t != null)
                    {
                        if (i != 5)
                        {
                            tSection = configScripts[0].FindSection(sectTypes + "_SCRIPTS");
                        }
                        else
                        {
                            tSection = configScripts[0].FindSection("SCRIPT_LIST");
                        }

                        string[] values = t.Data.Value.Split(',');
                        for (int j = 0; j < values.Length; ++j)
                        {
                            bool containsKey = jsFiles.ContainsKey(values[j].Trim());
                            if (containsKey)
                            {
                                string tag  = ((int)jsFiles[values[j].Trim()]).ToString();
                                string data = dirPath + inUse.GetDataPair(tag).Data.Value;
                                tSection.Add(tag, data);
                            }
                        }
                    }
                }
            }
            // OK, the file associations config file has been updated
            // Let's do envoke now



            // Let's do type now
        }