private object CreateNewObject(GOLD.Reduction r) { object result = r; switch ((ProductionIndex)r.Parent.TableIndex()) { case ProductionIndex.Objects: var newResult = new List<UINode>(); newResult.Add((UINode)r.get_Data(0)); newResult.AddRange((List<UINode>)r.get_Data(1)); result = newResult; program = result; // <Objects> ::= <Object> <Objects> break; case ProductionIndex.Objects2: // <Objects> ::= <Object> var newResult2 = new List<UINode>(); newResult2.Add((UINode)r.get_Data(0)); result = newResult2; program = result; break; case ProductionIndex.Object_Beginliteral_Endliteral: // <Object> ::= BeginLiteral <Content> EndLiteral result = UIGroup.FromReduction(r); break; case ProductionIndex.Object: // <Object> ::= <Start Tag> result = r.get_Data(0); break; case ProductionIndex.Object2: // <Object> ::= <Unary Tag> break; case ProductionIndex.Starttag_Lt_Id_Gt: // <Start Tag> ::= '<' ID <OptionalID> <Attributes> '>' var node = new UINode(); node.Name = (string)r.get_Data(1); node.ID = (string)r.get_Data(2); var atts = (List<KeyValuePair<string, string>>)r.get_Data(3); foreach (var att in atts) { node[att.Key] = att.Value; } result = node; break; case ProductionIndex.Endtag_Ltdiv_Id_Gt: // <End Tag> ::= '</' ID '>' break; case ProductionIndex.Unarytag_Lt_Id_Divgt: // <Unary Tag> ::= '<' ID <OptionalID> <Attributes> '/>' break; case ProductionIndex.Optionalid_Stringliteral: // <OptionalID> ::= StringLiteral result = GetStringLiteral((string)r.get_Data(0)); break; case ProductionIndex.Optionalid: // <OptionalID> ::= result = null; break; case ProductionIndex.Content: // <Content> ::= <Objects> var newResult3 = new List<UINode>(); newResult3.AddRange((List<UINode>)r.get_Data(0)); result = newResult3; break; case ProductionIndex.Content2: // <Content> ::= <Text> var newResult4 = new List<UINode>(); newResult4.Add((UINode)r.get_Data(0)); result = newResult4; break; case ProductionIndex.Attributes: // <Attributes> ::= <Attribute> <Attributes> var attributeList = new List<KeyValuePair<string, string>>(); attributeList.Add((KeyValuePair<string, string>)r.get_Data(0)); if (r.Count() > 1) { attributeList.AddRange((List<KeyValuePair<string, string>>)r.get_Data(1)); } result = attributeList; break; case ProductionIndex.Attributes2: // <Attributes> ::= result = new List<KeyValuePair<string, string>>(); break; case ProductionIndex.Attribute_Id_Eq_Stringliteral: // <Attribute> ::= ID '=' StringLiteral result = new KeyValuePair<string, string>((string)r.get_Data(0), GetStringLiteral((string)r.get_Data(2))); break; case ProductionIndex.Attribute_Id_Eq_Id: // <Attribute> ::= ID '=' ID result = new KeyValuePair<string, string>((string)r.get_Data(0), (string)r.get_Data(2)); break; case ProductionIndex.Text: // <Text> ::= <Text> <Word> break; case ProductionIndex.Text2: // <Text> ::= <Word> break; case ProductionIndex.Word_Id: // <Word> ::= ID break; case ProductionIndex.Word_Eq: // <Word> ::= '=' break; case ProductionIndex.Word_Charname: // <Word> ::= CharName break; case ProductionIndex.Word_Charnumber: // <Word> ::= CharNumber break; } //switch return result; }
void UIAttributeParser.ParseAttribute(UINode node) { /** * font = 10 * textColor = (255,249,157) * textColorSelected = (0,243,247) * textColorHighlighted = (255,255,255) * textColorDisabled = (100,100,100) */ var fontSize = 10; if (node.Attributes.ContainsKey("font")) { fontSize = int.Parse(node.Attributes["font"]); } var fontColor = TextStyle.DefaultButton.Color; if (node.Attributes.ContainsKey("textColor")) { fontColor = UIScript.ParseRGB(node.Attributes["textColor"]); } if (node.Attributes.ContainsKey("color")) { fontColor = UIScript.ParseRGB(node.Attributes["color"]); } if (node.Attributes.ContainsKey("textColorSelected")) { SelectedColor = UIScript.ParseRGB(node.Attributes["textColorSelected"]); } if (node.Attributes.ContainsKey("textColorHighlighted")) { HighlightedColor = UIScript.ParseRGB(node.Attributes["textColorHighlighted"]); } if (node.Attributes.ContainsKey("textColorDisabled")) { DisabledColor = UIScript.ParseRGB(node.Attributes["textColorDisabled"]); } if (node.Attributes.ContainsKey("cursorColor")) { CursorColor = UIScript.ParseRGB(node.Attributes["cursorColor"]); } Font = GameFacade.MainFont; Size = fontSize; Color = fontColor; }
private object CreateNewObject(GOLD.Reduction r) { object result = r; switch ((ProductionIndex)r.Parent.TableIndex()) { case ProductionIndex.Objects: var newResult = new List <UINode>(); newResult.Add((UINode)r.get_Data(0)); newResult.AddRange((List <UINode>)r.get_Data(1)); result = newResult; program = result; // <Objects> ::= <Object> <Objects> break; case ProductionIndex.Objects2: // <Objects> ::= <Object> var newResult2 = new List <UINode>(); newResult2.Add((UINode)r.get_Data(0)); result = newResult2; program = result; break; case ProductionIndex.Object_Beginliteral_Endliteral: // <Object> ::= BeginLiteral <Content> EndLiteral result = UIGroup.FromReduction(r); break; case ProductionIndex.Object: // <Object> ::= <Start Tag> result = r.get_Data(0); break; case ProductionIndex.Object2: // <Object> ::= <Unary Tag> break; case ProductionIndex.Starttag_Lt_Id_Gt: // <Start Tag> ::= '<' ID <OptionalID> <Attributes> '>' var node = new UINode(); node.Name = (string)r.get_Data(1); node.ID = (string)r.get_Data(2); var atts = (List <KeyValuePair <string, string> >)r.get_Data(3); foreach (var att in atts) { node[att.Key] = att.Value; } result = node; break; case ProductionIndex.Endtag_Ltdiv_Id_Gt: // <End Tag> ::= '</' ID '>' break; case ProductionIndex.Unarytag_Lt_Id_Divgt: // <Unary Tag> ::= '<' ID <OptionalID> <Attributes> '/>' break; case ProductionIndex.Optionalid_Stringliteral: // <OptionalID> ::= StringLiteral result = GetStringLiteral((string)r.get_Data(0)); break; case ProductionIndex.Optionalid: // <OptionalID> ::= result = null; break; case ProductionIndex.Content: // <Content> ::= <Objects> var newResult3 = new List <UINode>(); newResult3.AddRange((List <UINode>)r.get_Data(0)); result = newResult3; break; case ProductionIndex.Content2: // <Content> ::= <Text> var newResult4 = new List <UINode>(); newResult4.Add((UINode)r.get_Data(0)); result = newResult4; break; case ProductionIndex.Attributes: // <Attributes> ::= <Attribute> <Attributes> var attributeList = new List <KeyValuePair <string, string> >(); attributeList.Add((KeyValuePair <string, string>)r.get_Data(0)); if (r.Count() > 1) { attributeList.AddRange((List <KeyValuePair <string, string> >)r.get_Data(1)); } result = attributeList; break; case ProductionIndex.Attributes2: // <Attributes> ::= result = new List <KeyValuePair <string, string> >(); break; case ProductionIndex.Attribute_Id_Eq_Stringliteral: // <Attribute> ::= ID '=' StringLiteral result = new KeyValuePair <string, string>((string)r.get_Data(0), GetStringLiteral((string)r.get_Data(2))); break; case ProductionIndex.Attribute_Id_Eq_Id: // <Attribute> ::= ID '=' ID result = new KeyValuePair <string, string>((string)r.get_Data(0), (string)r.get_Data(2)); break; case ProductionIndex.Text: // <Text> ::= <Text> <Word> break; case ProductionIndex.Text2: // <Text> ::= <Word> break; case ProductionIndex.Word_Id: // <Word> ::= ID break; case ProductionIndex.Word_Eq: // <Word> ::= '=' break; case ProductionIndex.Word_Charname: // <Word> ::= CharName break; case ProductionIndex.Word_Charnumber: // <Word> ::= CharNumber break; } //switch return(result); }