Esempio n. 1
0
        public override void Render(GameObjectElementBuilder builder, PropCollection props)
        {
            base.Render(builder, props);

            var image         = builder.AddComponent <Image>();
            var imageResource = props.GetString("image", null);

            if (imageResource != null)
            {
                image.SetProperty(Sprite, ComponentResources.Get(imageResource) as Sprite);
            }

            image.SetProperty(Type, Image.Type.Sliced);
        }
Esempio n. 2
0
        static void UpdatePropCollection(string name, Array keptPrefabs, string[] replacedNames)
        {
            PropCollection c = GameObject.Find(name)?.GetComponent <PropCollection>();

            if (c != null)
            {
                c.m_prefabs = keptPrefabs as PropInfo[];

                if (replacedNames != null)
                {
                    c.m_replacedNames = replacedNames;
                }
            }
        }
Esempio n. 3
0
        public override void Render(GameObjectElementBuilder builder, PropCollection props)
        {
            base.Render(builder, props);

            var image   = builder.AddComponent <Image>();
            var button  = builder.AddComponent <Button>();
            var onClick = props.GetCallbackAction("onClick");

            var buttonClickedEvent = new Button.ButtonClickedEvent();

            buttonClickedEvent.AddListener(new UnityAction(onClick));

            button.SetProperty(e => e.onClick, buttonClickedEvent);
            image.SetProperty(e => e.color, Color.blue);
        }
Esempio n. 4
0
        public override void Render(GameObjectElementBuilder builder, PropCollection props)
        {
            base.Render(builder, props);

            var text = builder.AddComponent <Text>();

            var textValue       = props.GetString("text", string.Empty);
            var alignment       = props.GetEnum("textAnchor", TextAnchor.UpperLeft);
            var alignByGeometry = props.GetString("alignByGeometry", "false");

            text.SetProperty(Font, ComponentResources.Get("ArialFont") as Font);
            text.SetProperty(ColorProp, Color.black);
            text.SetProperty(Text, textValue);
            text.SetProperty(Alignment, alignment);
            text.SetProperty(AlignByGeometry, alignByGeometry == "true");
        }
Esempio n. 5
0
        public override void Render(GameObjectElementBuilder builder, PropCollection props)
        {
            var rectTransform  = builder.AddComponent <RectTransform>();
            var canvasRenderer = builder.AddComponent <CanvasRenderer>();

            var width  = props.GetInt("width", 100);
            var height = props.GetInt("height", 100);
            var x      = props.GetInt("x", 0);
            var y      = props.GetInt("y", 0);

            rectTransform.SetProperty(e => e.anchorMin, Vector2.zero);
            rectTransform.SetProperty(e => e.anchorMax, Vector2.zero);
            rectTransform.SetProperty(e => e.pivot, new Vector2(0, 1));

            rectTransform.SetProperty(e => e.offsetMax, new Vector2(x + width, y + height));
            rectTransform.SetProperty(e => e.offsetMin, new Vector2(x, y));
        }
        public IRootElementBuilder Render(Element container)
        {
            var props = MergeProps(container.Props, system?.Props);

            if (previousProps != null)
            {
                if (!HavePropsChanged(previousProps, props))
                {
                    return(null);
                }
            }

            var elementId = state.Call(state.Globals["render"], props).CastToString();
            var element   = Element.GetById(elementId);

            previousProps = props;

            return(new PassThroughElementBuilder(element.Render()));
        }
Esempio n. 7
0
        // Initialize our class variables with values from LatestOverlaps.exe.config. Returns true if all values
        // successfully read and class variables initialized, false otherwise. ConfigurationErrorsException caught
        // and logged in %LOCALAPPDATA%\AcTools\Logs\LatestOverlaps-YYYY-MM-DD.log on initialization failure.
        private static bool initAppConfigData()
        {
            bool ret = true; // assume success

            try
            {
                _fromHoursAgo = AcQuery.getAppConfigSetting <int>("FromHoursAgo");
                _outputFile   = AcQuery.getAppConfigSetting <string>("OutputFile").Trim();

                ADSection adSection = ConfigurationManager.GetSection("activeDir") as ADSection;
                if (adSection == null)
                {
                    AcDebug.Log("Error in Program.initAppConfigData creating ADSection");
                    ret = false;
                }
                else
                {
                    _domains    = adSection.Domains;
                    _properties = adSection.Props;
                }

                DepotsSection depotsConfigSection = ConfigurationManager.GetSection("Depots") as DepotsSection;
                if (depotsConfigSection == null)
                {
                    AcDebug.Log("Error in Program.initAppConfigData creating DepotsSection");
                    ret = false;
                }
                else
                {
                    _selDepots = depotsConfigSection.Depots;
                }
            }

            catch (ConfigurationErrorsException exc)
            {
                Process       currentProcess = Process.GetCurrentProcess();
                ProcessModule pm             = currentProcess.MainModule;
                AcDebug.Log($"Invalid data in {pm.ModuleName}.config{Environment.NewLine}{exc.Message}");
                ret = false;
            }

            return(ret);
        }
Esempio n. 8
0
        public override PropCollection GetProps(int pageNumber, int pageSize, bool all, ref int?totalCount)
        {
            using (SqlQuery db = new SqlQuery())
            {
                db.Pager.TableName  = "bx_Props";
                db.Pager.PageNumber = pageNumber;
                db.Pager.PageSize   = pageSize;
                db.Pager.SortField  = "SortOrder";
                db.Pager.PrimaryKey = "PropID";
                db.Pager.IsDesc     = false;

                if (all == false)
                {
                    db.Pager.Condition = "Enable = 1";
                }

                if (totalCount != null)
                {
                    db.Pager.TotalRecords = totalCount;
                    db.Pager.SelectCount  = false;
                }
                else
                {
                    db.Pager.SelectCount = true;
                }

                using (XSqlDataReader reader = db.ExecuteReader())
                {
                    PropCollection result = new PropCollection(reader);

                    if (reader.NextResult() && reader.Read())
                    {
                        totalCount = reader.Get <int>(0);
                    }

                    result.TotalRecords = totalCount.Value;

                    return(result);
                }
            }
        }
        private PropCollection MergeProps(PropCollection containerProps, PropCollection systemProps)
        {
            var props = new PropCollection(new Dictionary <string, object>());

            if (systemProps != null)
            {
                foreach (var key in systemProps.Keys)
                {
                    props[key] = systemProps[key];
                }
            }

            if (containerProps != null)
            {
                foreach (var key in containerProps.Keys)
                {
                    props[key] = containerProps[key];
                }
            }

            return(props);
        }
Esempio n. 10
0
        private bool HavePropsChanged(PropCollection previous, PropCollection current)
        {
            if (previous.Count != current.Count)
            {
                return(true);
            }

            foreach (var key in previous.Keys)
            {
                if (!current.ContainsKey(key))
                {
                    return(true);
                }

                if (!current[key].Equals(previous[key]))
                {
                    return(true);
                }
            }

            return(false);
        }
        public override void OnReleased()
        {
            base.OnReleased();

            if (_menuInstaller != null)
            {
                Object.Destroy(_menuInstaller);
                _menuInstaller = null;
            }

            if (_roadsInstaller != null)
            {
                Object.Destroy(_roadsInstaller);
                _roadsInstaller = null;
            }

            if (_roads != null)
            {
                Object.Destroy(_roads);
                _roads = null;
            }

            if (_props != null)
            {
                Object.Destroy(_props);
                _props = null;
            }

            if (_container != null)
            {
                Object.Destroy(_container);
                _container = null;
            }
        }
Esempio n. 12
0
        public override PropCollection GetProps(int pageNumber, int pageSize, bool all, ref int? totalCount)
        {
            using (SqlQuery db = new SqlQuery())
            {
                db.Pager.TableName = "bx_Props";
                db.Pager.PageNumber = pageNumber;
                db.Pager.PageSize = pageSize;
                db.Pager.SortField = "SortOrder";
                db.Pager.PrimaryKey = "PropID";
                db.Pager.IsDesc = false;
                
                if(all == false)
                    db.Pager.Condition = "Enable = 1";

                if (totalCount != null)
                {
                    db.Pager.TotalRecords = totalCount;
                    db.Pager.SelectCount = false;
                }
                else
                {
                    db.Pager.SelectCount = true;
                }

                using (XSqlDataReader reader = db.ExecuteReader())
                {
                    PropCollection result = new PropCollection(reader);

                    if (reader.NextResult() && reader.Read())
                    {
                        totalCount = reader.Get<int>(0);
                    }

                    result.TotalRecords = totalCount.Value;

                    return result;
                }
            }
        }
        public (List <Element> children, GameObjectElementBuilder builder) Render(Element container, PropCollection props, List <Element> children)
        {
            var builder = new GameObjectElementBuilder(
                container.Component.Name);

            this.Render(builder, props);

            return(children, builder);
        }
 public abstract void Render(GameObjectElementBuilder builder, PropCollection props);
Esempio n. 15
0
 public static Element Create(IBaseUIComponent component, PropCollection props = null)
 {
     return(new Element(component, props));
 }
Esempio n. 16
0
 private Element(IBaseUIComponent component, PropCollection props = null)
 {
     this.Component = component;
     this.Props     = props;
 }
Esempio n. 17
0
        public static Element Create(IBaseUIComponent component, PropCollection props = null)
        {
            var id = "root";

            return(new Element(id, component, props));
        }
Esempio n. 18
0
        public (List <Element> children, GameObjectElementBuilder builder) Render(Element container, PropCollection props, List <Element> children)
        {
            HookComponentRegistration.CurrentComponent = this;
            HookComponentRegistration.CurrentContainer = container;
            HookComponentRegistration.ResetHookCounter();

            var elementId = state.Call(state.Globals[$"{Name}_render"], props).CastToString();

            HookComponentRegistration.CurrentComponent = null;
            HookComponentRegistration.CurrentContainer = null;

            var element = Element.GetById(elementId);

            if (element == null)
            {
                return(new List <Element>(), null);
            }

            element.Parent = container;

            return(new List <Element>()
            {
                element
            }, null);
        }
Esempio n. 19
0
 private Element(string id, IBaseUIComponent component, PropCollection props = null)
 {
     this.Component = component;
     this.Props     = props;
     this.Id        = id;
 }