Пример #1
0
        public override void Save(StreamWriter ioStream)
        {
            // first part, the SUBMENU
            Script.ScriptSection weWrite = new Script.ScriptSection();
            weWrite.SectionName = "ITEM " + MenuID;

            weWrite.Add("NAME", name);
            weWrite.Add("ID", Conversion.ToHexString(targID));
            weWrite.Add("COLOUR", Conversion.ToHexString(colour));
            weWrite.Add("MINRANK", minRank.ToString());
            weWrite.Add("MAXRANK", maxRank.ToString());
            weWrite.Add("SOUND", Conversion.ToHexString(soundPlayed));
            weWrite.Add("ADDITEM", addItem);
            weWrite.Add("DELAY", delay.ToString());
            weWrite.Add("SPELL", spell.ToString());

            foreach (ResSkillReq rsr in SkillReqs)
            {
                weWrite.Add("SKILL", ((int)rsr.SkillNumber).ToString() + " " + rsr.MinSkill + " " + rsr.MaxSkill);
            }

            foreach (ResAmountPair rap in ResourceNeeded)
            {
                weWrite.Add("RESOURCE", Conversion.ToHexString(rap.ItemID) + " " + rap.AmountNeeded.ToString() + " " + rap.Colour.ToString());
            }

            weWrite.Save(ioStream);
        }
Пример #2
0
        public override void Retrieve(System.IO.Stream toRead)
        {
            StreamReader ioStream = new StreamReader(toRead);
            string       curLine  = "";

            while (curLine != null)
            {
                curLine = ioStream.ReadLine();
                if (curLine != null && curLine != "")
                {
                    if (curLine[0] == '[')
                    {
                        int brackPos = curLine.IndexOf(']');
                        if (brackPos != -1)
                        {
                            string        sectionName = curLine.Remove(brackPos, curLine.Length - brackPos).Substring(1);
                            ScriptSection toAdd       = new ScriptSection(sectionName, ioStream, category);
                            sectionCollection.Add(toAdd);
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Error!  Invalid section format (missing closing bracket), in " + ((System.IO.FileStream)toRead).Name + " line: " + curLine);
                        }
                    }
                }
            }
        }
Пример #3
0
 public ScriptSection FindEntry(string toFind)
 {
     foreach (Script s in files.Values)
     {
         ScriptSection checkVal = s.FindSection(toFind);
         if (checkVal != null)
         {
             return(checkVal);
         }
     }
     return(null);
 }
Пример #4
0
        public string Directory(DirectoryPaths toCheck)
        {
            if (toCheck == DirectoryPaths.COUNT)
            {
                return("");
            }
            ScriptSection dirSection = FindSection("directories");

            if (dirSection != null)
            {
                string sRoot       = dirSection.FindTag("DIRECTORY");
                string partialPath = "";
                if (toCheck == DirectoryPaths.Root)
                {
                    return(sRoot);
                }
                switch (toCheck)
                {
                case DirectoryPaths.Dictionaries:       partialPath = dirSection.FindTag("DICTIONARYDIRECTORY");                                              break;

                case DirectoryPaths.Definitions:        partialPath = dirSection.FindTag("DEFSDIRECTORY");                                                    break;

                case DirectoryPaths.Accounts:           partialPath = dirSection.FindTag("ACTSDIRECTORY");                                                    break;

                default:                                                        partialPath = dirSection.FindTag(toCheck.ToString().ToUpper() + "DIRECTORY");     break;
                }
                if (partialPath == "")
                {
                    return("");
                }
                if (partialPath.StartsWith("./"))
                {
                    string builtPath = sRoot;
                    builtPath = builtPath.Replace("\\", "/");
                    if (!builtPath.EndsWith("/"))
                    {
                        builtPath += "/";
                    }
                    builtPath += partialPath.Substring(2);
                    return(builtPath);
                }
                else
                {
                    return(partialPath);
                }
            }
            else
            {
                return("");
            }
        }
Пример #5
0
        public override void Save(StreamWriter ioStream)
        {
            // first part, the SUBMENU
            Script.ScriptSection weWrite = new Script.ScriptSection();
            weWrite.SectionName = "SUBMENU " + MenuID;

            foreach (CreateItemEntry cie in SubItems)
            {
                weWrite.Add("ITEM", cie.MenuID.ToString());
            }

            foreach (CreateMenuEntry cme in SubMenus)
            {
                weWrite.Add("MENU", cme.MenuID.ToString());
            }

            weWrite.Save(ioStream);

            // second part, the MENUENTRY
            if (!isRoot)
            {
                Script.ScriptSection menuEntry = new Script.ScriptSection();
                menuEntry.SectionName = "MENUENTRY " + MenuID;

                menuEntry.Add("NAME", name);
                menuEntry.Add("ID", Conversion.ToHexString(targID));
                menuEntry.Add("COLOUR", Conversion.ToHexString(colour));
                menuEntry.Add("SUBMENU", MenuID.ToString());

                menuEntry.Save(ioStream);
            }

            foreach (CreateItemEntry cie2 in SubItems)
            {
                cie2.Save(ioStream);
            }

            foreach (CreateMenuEntry cme2 in SubMenus)
            {
                cme2.Save(ioStream);
            }
        }
Пример #6
0
 public static Validation.Schemas.BaseSchema ValidationSchema(ScriptSection toValidate)
 {
     return(ValidationSchema(toValidate.Category, toValidate.SectionName));
 }