private static void PrintVariableValue(StringBuilder sb, XVariableValue value, CaptureExpression capture) { int shiftback = ShiftBack(int.Parse(value.Data, System.Globalization.NumberStyles.HexNumber), capture.Mask); string obj = null; if (SetGame != Game.OcarinaOfTime && capture.VarType != CaptureVar.v) { shiftback = ShiftBack(shiftback, 0xFF80); } if (value.Meta != null) { obj = string.Join(", ", value.Meta.Object); } obj = (!string.IsNullOrEmpty(obj)) ? $" ({obj})" : ""; sb.AppendFormat(":{0} [{2:X4}]{1} {3} {4}", value.Data, (!string.IsNullOrEmpty(value.repeat)) ? "+" : "", shiftback, obj, value.Description); PrintComments(sb, value.Comment, true); sb.AppendLine(); }
private void NewVariableValue(GroupCollection groupCollection, XVariableValue val) { throw new NotImplementedException(); //Regex ValueLine = new Regex(@"^\s*(?:-|=)\s*([0-9a-fA-F]{1,4})(\+)?\s*(?:\(([0-9a-fA-F?]{4})\))?\s*(?:-|=)\s*(.*?)$"); //Groups: //Hex Value, repeater?, Hex Object?, description //val.Data = groupCollection[1].Value; //if (!String.IsNullOrEmpty(groupCollection[2].Value)) // val.repeat = groupCollection[2].Value; //if (!String.IsNullOrEmpty(groupCollection[3].Value)) // val.Data.objectid = groupCollection[3].Value; //val.Description = groupCollection[4].Value.Trim(); }
private static void PrintVariableValue(StringBuilder sb, XVariableValue value, int mask) { string obj = null; if (value.Meta != null) { obj = string.Join(", ", value.Meta.Object); } sb.AppendFormat(" - {0}{1} [{2:X4}]{3} {4}", value.Data, (!string.IsNullOrEmpty(value.repeat)) ? "+" : " ", Shift(int.Parse(value.Data, System.Globalization.NumberStyles.HexNumber), mask), (!string.IsNullOrEmpty(obj)) ? string.Format(" ({0})", obj) : "", value.Description); PrintComments(sb, value.Comment, true); sb.AppendLine(); }
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); }
public XVariableValueDisplay(XVariableValue data) { Source = data; }
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); }