public JSONTable getJSON(string name, JSONTable defaultValue) { if (dictionary.ContainsKey(name)) { return(new JSONTable((Dictionary <string, System.Object>)dictionary[name])); } else { return(defaultValue); } }
public RichImage(JSONTable template, ContentManager content) { layers = new List <RichImageLayer>(); JSONArray layerTemplate = template.getArray("layers", null); if (layerTemplate != null) { for (int Idx = 0; Idx < layerTemplate.Length; ++Idx) { layers.Add(new RichImageLayer_Texture(layerTemplate.getJSON(Idx), content)); } } else { layers.Add(new RichImageLayer_Texture(template, content)); } }
public RichImageLayer_Texture(JSONTable template, ContentManager content) { texture = content.Load <Texture2D>(template.getString("texture", "white")); color = template.getString("color", "FFFFFF").toColor(); drawMode = drawModesByName[template.getString("draw", "default")]; padding = template.getInt("padding", 0); JSONArray offsetArray = template.getArray("offset", null); if (offsetArray == null) { offset = new Vector2(0, 0); } else { offset = offsetArray.toVector2(); } rotation = template.getRotation("rotation", Rotation90.None); modifiesRect = (padding != 0 || offset.X != 0 || offset.Y != 0); }
public static Rotation90 getRotation(this JSONTable table, string name, Rotation90 defaultValue) { int angle = table.getInt(name, defaultValue.toInt()); return((Rotation90)(angle / 90)); }