Exemplo n.º 1
0
        internal static void Init()
        {
            RobloxInstance GuiObject = RobloxParser.RobloxHierachy["GuiObject"]; //This better be hear.


            //Add custom properties
            //GuiObject is superclass to all flat plane objects.
            GuiObject.AddProperty(new RobloxProperty("padding-left", null, "Proportion"));
            GuiObject.AddProperty(new RobloxProperty("padding-right", null, "Proportion"));
            GuiObject.AddProperty(new RobloxProperty("padding-top", null, "Proportion"));
            GuiObject.AddProperty(new RobloxProperty("padding-bottom", null, "Proportion"));


            GuiObject.AddProperty(new RobloxProperty("Alignment", null, "Alignment"));

            GuiObject.AddProperty(new RobloxProperty("CustomStyle", null, "Style"));

            AddRobloxEnum("Alignment", "Top-Left", "Top-Centre", "Top-Right", "Centre-Left", "Centre", "Centre-Right", "Bottom-Left", "Bottom-Right");

            //Adding colors and stuff.

            AddColors();

            //Class specific custom properties.

            RobloxInstance TextLabel = RobloxParser.RobloxHierachy["TextLabel"];

            TextLabel.AddProperty(new RobloxProperty("text-shadow-transparency", null, "float"));
            TextLabel.AddProperty(new RobloxProperty("text-shadow-offset", null, "Proportion"));
            TextLabel.AddProperty(new RobloxProperty("text-shadow-color", null, "Color3"));
        }
Exemplo n.º 2
0
        private RobloxInstance CreateInstance(string name, string className)
        {
            var instance = new RobloxInstance();

            instance.ClassName  = className;
            instance.Name       = name;
            instance.Properties = new Dictionary <string, object>();
            instance.Children   = new List <RobloxInstance>();

            return(instance);
        }
Exemplo n.º 3
0
        internal static void Parse(Scope Sc, string varVal, string propName, string[] classes = null)
        {
            if (PropertyCallbacks == null)
            {
                AddCallbacks();
            }

            //Properties can be defined within a WidgetScope.

            if (Sc.ID == "Widget")
            {
                var WScope = Sc as WidgetScope;

                if (WScope != null)
                {
                    RSSInstance Instance = WScope.Instance;

                    RobloxProperty Prop;

                    if (!Instance.HasProperty(propName, out Prop))
                    {
                        throw new ParserException($"The Instance {Instance.Name} does not have the property {propName}");
                    }

                    //Check to make sure the value passed isn't a variable.

                    varVal = FetchVarVal(Sc, varVal);

                    //Check for a callback.

                    PropertyProcessCallback Callback;

                    bool isValidFunc = PropertyCallbacks.TryGetValue(Prop.ValueType, out Callback);

                    if (!isValidFunc)
                    {
                        /////ENUM CALLBACK
                        RobloxEnum Enum;
                        if (!RobloxEnum.Enums.TryGetValue(Prop.ValueType, out Enum))
                        {
                            throw new ParserException($"Failed to find the correct datatype for {Prop.Name} for Instance {Instance.Name}");
                        }

                        if (!Enum.HasEnumItem(varVal))
                        {
                            throw new ParserException($"The Enunm {Enum.Name} does not have the item {varVal}");
                        }

                        Instance.AddProperty(new RSSProperty(Prop.Name, Prop.ValueType, new string[] { RSS.RobloxJSONParser.Writer.JSONWriter.Quotify(varVal) }));
                    }
                    else
                    {
                        Instance.AddProperty(new RSSProperty(Prop.Name, Prop.ValueType, Callback(varVal, WScope)));
                    }
                }
            }
            else if (Sc.ID == "StyleId")
            {
                RobloxProperty Prop = null;
                foreach (var Name in classes)
                {
                    RobloxInstance Inst = RobloxParser.RobloxHierachy[Name];

                    if (!Inst.GetProperty(propName, out Prop))
                    {
                        throw new ParserException($"The ClassName {Name} in the style {((StyleScope)Sc.Parent).StyleName} does not have the property you are trying to set: {propName}");
                    }
                }

                PropertyProcessCallback Callback;

                bool isValidFunc = PropertyCallbacks.TryGetValue(Prop.ValueType, out Callback);

                if (isValidFunc)
                {
                    ((StyleIdScope)Sc).AddProperty(new RSSProperty(Prop.Name, Prop.ValueType, Callback(varVal, Sc)));
                }
            }
        }