Esempio n. 1
0
        private void SetBitflagParam()
        {
            XActors actors;

            short[] bitDictionary = new short[16];
            actors = XActors.LoadFromFile(XActors.OcaXmlPath);

            for (int i = 0; i < 16; i++)
            {
                bitDictionary[i] = (short)(1 << i);
            }

            foreach (XActor actor in actors.Actor)
            {
                var value = from v in actor.Variables
                            where bitDictionary.Contains(GetCaptureMask(v.Capture))
                            select v;

                foreach (var v in value)
                {
                    if (v.UI.Item is UIDefault)
                    {
                        v.UI.Item = new UIBitFlag();
                    }
                }
            }
            outRichTextBox.Text = actors.Serialize();
        }
Esempio n. 2
0
        private void SetBitflagParam()
        {
            XActors actors;

            Int16[] bitDictionary = new Int16[16];
            actors = XActors.LoadFromFile(OcaXmlFileLocation);

            for (int i = 0; i < 16; i++)
            {
                bitDictionary[i] = (Int16)(1 << i);
            }

            foreach (XActor actor in actors.Actor)
            {
                var value = from v in actor.Variables
                            where bitDictionary.Contains(GetCaptureMask(v.Capture))
                            select v;

                foreach (var v in value)
                {
                    if (v.UI.name == UITypes.@default)
                    {
                        v.UI.name = UITypes.bitflag;
                    }
                }
            }
            outRichTextBox.Text = actors.Serialize();
        }
Esempio n. 3
0
        static XActorFactory()
        {
            OcarinaDoc          = XActors.LoadFromFile(XActors.OcaXmlPath);
            OcarinaActorParsers = GetXActorParsers(OcarinaDoc, Game.OcarinaOfTime);

            MaskDoc          = XActors.LoadFromFile(XActors.MaskXmlPath);
            MaskActorParsers = GetXActorParsers(MaskDoc, Game.MajorasMask);
        }
Esempio n. 4
0
        static XActorFactory()
        {
            var Document = XActors.LoadFromFile(XActors.OcaXmlPath);

            OcarinaActorParsers = GetXActorParsers(Document, Game.OcarinaOfTime);

            Document         = XActors.LoadFromFile(XActors.MaskXmlPath);
            MaskActorParsers = GetXActorParsers(Document, Game.MajorasMask);
        }
Esempio n. 5
0
        static Dictionary <short, XActorParser> GetXActorParsers(XActors root, Game game)
        {
            Dictionary <short, XActorParser> result = new();

            foreach (var item in root.Actor)
            {
                short id = short.Parse(item.id, NumberStyles.HexNumber);
                result.Add(id, new XActorParser(item, game));
            }
            return(result);
        }
Esempio n. 6
0
        private void loadOcaButton_Click(object sender, EventArgs e)
        {
            Document = XActors.LoadFromFile(OcaXmlFileLocation);
            actorControl.Document = Document;
            Game = Game.Oca;

            //foreach (var item in Document.Actor)
            //{
            //    item.name = ActorNameConstants.OcaActorNames[Convert.ToUInt16(item.id, 16)];
            //}
        }
Esempio n. 7
0
        private void loadMMButton_Click(object sender, EventArgs e)
        {
            Document = XActors.LoadFromFile(MaskXmlFileLoaction);
            actorControl.Document = Document;
            Game = Game.Mask;

            //foreach(var item in Document.Actor)
            //{
            //    item.name = ActorNameConstants.MaskActorNames[Convert.ToUInt16(item.id, 16)];
            //}
            //ParseMMGbFormat();
        }
Esempio n. 8
0
        public static StringBuilder Output(XActors root)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("== Actors ==");
            sb.AppendLine("<pre>");
            foreach (XActor actor in root.Actor)
            {
                PrintActor(sb, actor);
                sb.AppendLine();
            }
            sb.AppendLine("</pre>");
            return(sb);
        }
Esempio n. 9
0
        public static StringBuilder Output(XActors root, Game game)
        {
            StringBuilder sb = new();

            SetGame = game;
            sb.AppendLine("== Actors ==");
            sb.AppendLine("<div style=\"font-family: monospace, Consolas, DejaVu Sans Mono, Droid Sans Mono, Lucida Console, Courier New;\">");
            foreach (XActor actor in root.Actor)
            {
                PrintActor(sb, actor, game);
                sb.AppendLine();
            }
            sb.AppendLine("</div>");
            return(sb);
        }
Esempio n. 10
0
        private void ActorObjectRelationshipsFromXml()
        {
            XActors       actorList;
            StringBuilder sb = new StringBuilder();
            List <Tuple <string, string> > ActorToObjects = new List <Tuple <string, string> >();

            actorList = XActors.LoadFromFile(OcaXmlFileLocation);

            sb.AppendLine("{|class=\"wikitable sortable\"");
            sb.AppendLine("! data-sort-type=\"text\" | Actor");
            sb.AppendLine("! data-sort-type=\"text\" | Object");
            foreach (XActor actor in actorList.Actor)
            {
                foreach (string obj in actor.Objects.Object)
                {
                    if (obj != "????")
                    {
                        ActorToObjects.Add(new Tuple <string, string>(actor.id, obj));
                    }
                    else
                    {
                        //var objList = actor.Variables.SelectMany(v => v.Value)
                        //     .Select(x => x.Data.objectid)
                        //     .Where(y => !String.IsNullOrEmpty(y))
                        //     .Distinct();

                        //foreach (string obj_sub in objList)
                        //{
                        //    ActorToObjects.Add(new Tuple<string, string>(actor.id, obj_sub));
                        //}
                    }
                }
            }
            foreach (Tuple <string, string> a2o in ActorToObjects)
            {
                sb.AppendLine("|-");
                sb.AppendFormat("|{0}||{1}", a2o.Item1, a2o.Item2);
                sb.AppendLine();
            }
            sb.AppendLine("|}");
            dataInRichTextBox.Text = sb.ToString();
        }
Esempio n. 11
0
 private void TestForm_Load(object sender, EventArgs e)
 {
     Document = null;
 }
Esempio n. 12
0
        public XActors ParseLines(String[] lines)
        {
            XActors   root            = new XActors();
            String    currentComment  = string.Empty;
            XActor    currentActor    = null;
            XVariable currentVariable = null;
            Object    commentParent   = null;

            foreach (string line in lines)
            {
                string line_nocomment;
                String lineComment;//comment within the current line

                //remove comment
                line_nocomment = StripComment(line, out lineComment);

                //if line only contains a comment
                if (line_nocomment.Trim().Length == 0)
                {
                    //continue the current comment
                    currentComment += (String.IsNullOrEmpty(currentComment)) ? lineComment : Environment.NewLine + lineComment;
                    continue;
                }

                //Else match one of three patterns:
                //Actor/Object id line,
                //Mask Line
                //Value line

                //If Actor/Object id line
                if (IdLine.IsMatch(line_nocomment))
                {
                    //attach currentComment to proper node
                    AddCommentToNode(ref commentParent, ref currentComment, lineComment);

                    //Start a new XActor, attach it
                    currentActor = new XActor();
                    root.Actor.Add(currentActor);

                    //set new comment node
                    commentParent = currentActor;

                    //null current variable
                    currentVariable = null;

                    NewActorDefinition(IdLine.Matches(line_nocomment)[0].Groups, currentActor);
                }
                //mask value line
                else if (MaskLine.IsMatch(line_nocomment))
                {
                    //Push currentComment to proper node
                    AddCommentToNode(ref commentParent, ref currentComment, lineComment);

                    currentVariable = new XVariable();
                    currentActor.Variables.Add(currentVariable);

                    commentParent = currentVariable;
                    throw new NotImplementedException();
                    //NewVariableDefinition(MaskLine.Matches(line_nocomment)[0].Groups, currentVariable);
                }
                else if (ValueLine.IsMatch(line_nocomment))
                {
                    //Push currentComment to proper node
                    AddCommentToNode(ref commentParent, ref currentComment, lineComment);

                    if (currentVariable == null)
                    {
                        currentVariable = NoMaskSet(currentActor);
                    }

                    XVariableValue val = new XVariableValue();
                    currentVariable.Value.Add(val);

                    commentParent = val;

                    NewVariableValue(ValueLine.Matches(line_nocomment)[0].Groups, val);
                }
                else //unknown
                {
                    currentComment += String.Format("{1}#NOPARSE: {0}", line_nocomment,
                                                    (String.IsNullOrEmpty(currentComment)) ? string.Empty : Environment.NewLine);
                    continue;
                }
            }
            AddCommentToNode(ref commentParent, ref currentComment, string.Empty);
            return(root);
        }
Esempio n. 13
0
        public static XActors ParseLines(string[] lines)
        {
            XActors   root        = new XActors();
            XActor    curActor    = null;
            XVariable curVariable = null;

            //assume lines are trimmed
            foreach (var line_untrimmed in lines)
            {
                string line = line_untrimmed.Trim();
                if (line.StartsWith("==A") ||
                    line.StartsWith("Variables:"))
                //do nothing
                {
                    continue;
                }
                if (line.StartsWith("===0"))
                //new actor
                {
                    curActor = new XActor()
                    {
                        id = line.Substring(3, 4)
                    };
                    root.Actor.Add(curActor);
                }
                else if (line.StartsWith("Identity:"))
                //name
                {
                    curActor.Description = line.Substring(9).Trim();
                }
                else if (line.StartsWith("Objects:"))
                {
                    curActor.Objects = new XObjects();
                    curActor.Objects.Object.Add(line.Substring(8).Trim());
                }
                else if (line.StartsWith("Notes:"))
                {
                    var comment = line.Substring(6).Trim();
                    if (comment.Length > 0)
                    {
                        curActor.Comment = comment;
                    }
                }
                else if (line.ToLower().StartsWith("x rot:") ||
                         line.ToLower().StartsWith("y rot:") ||
                         line.ToLower().StartsWith("z rot:"))
                //capture
                {
                    string vType = line[0].ToString().ToLower();
                    string desc  = line.Substring(6).Trim();

                    curVariable = new XVariable()
                    {
                        Capture     = $"r{vType} &>> 0x1FF",
                        Description = desc,
                    };

                    curActor.Variables.Add(curVariable);
                }
                else if (line.StartsWith("&"))
                //new variable
                {
                    var extract = MaskLine.Match(line);

                    curVariable = new XVariable()
                    {
                        Capture     = $"v {extract.Groups[1].Value}>> 0x{extract.Groups[2].Value}",
                        Description = extract.Groups[3].ToString()
                    };
                    curActor.Variables.Add(curVariable);
                }
                else
                //variable value
                {
                    var extract = ValueLine.Match(line).Groups;
                    var value   = new XVariableValue()
                    {
                        Description = extract[4].ToString(),
                        Data        = extract[1].ToString()
                    };
                    if (extract[2].ToString() == "+")
                    {
                        value.repeat = "+";
                    }

                    curVariable.Value.Add(value);
                }
            }

            return(root);
        }