Exemple #1
0
        private void InitUI()
        {
            #region Content
            List <UI.Toolbar.CustomView> ContentViews = new List <UI.Toolbar.CustomView>();
            if (ContentFilter != null)
            {
                for (int i = 0; i < ScopedObjects.Length; i++)
                {
                    if (ContentFilter(ScopedObjects[i]))
                    {
                        ContentViews.Add(new UI.Toolbar.CustomView(ScopedObjects[i]));
                    }
                }
            }
            if (CustomContentFilter != null)
            {
                for (int i = 0; i < ScopedObjects.Length; i++)
                {
                    ContentViews.AddRange(CustomContentFilter(ScopedObjects[i]));                     // add custom content to content views
                }
            }
            #endregion

            // init toolbar
            UI.Toolbar.ToolbarSettings BarSettings = new UI.Toolbar.ToolbarSettings {
                HeaderSections  = InitializeHeaderSections(),
                ToolbarIconSize = 28f,
                Title           = (ScopedObjects.Length == 1) ? ScopedObjects [0].gameObject.name : ScopedObjects.Length + " Objects Selected",
            };

            // Add content
            if (ContentViews.Count > 0)
            {
                BarSettings.Content = ContentViews.ToArray();
            }

            SettingsBar = GameManager.I.UI.InitToolbar(BarSettings, ScopedObjects);
        }
Exemple #2
0
        private void InitUI()
        {
            List <UI.Toolbar.HeaderAction> Settings     = new List <UI.Toolbar.HeaderAction> ();
            List <UI.Toolbar.HeaderAction> ColorActions = new List <UI.Toolbar.HeaderAction> ();

            // add actions
            #region Movement actions

            if (ScopedObject.PositionRestriction == PositionRestrictions.None)               // only add settings if doesnt have restrictions
            {
                #region Snap Type Settings
                int SnapTypeIndex = 0;
                if (SnapType == SnapTypes.Cross)
                {
                    SnapTypeIndex = 0;
                }
                else if (SnapType == SnapTypes.Edge)
                {
                    SnapTypeIndex = 1;
                }
                else if (SnapType == SnapTypes.Center)
                {
                    SnapTypeIndex = 2;
                }
                else if (SnapType == SnapTypes.FreeForm)
                {
                    SnapTypeIndex = 3;
                }


                Settings.Add(new UI.Toolbar.HeaderAction(
                                 UI.Toolbar.HeaderActionType.Toggle,
                                 new IconPack.IconType[] {
                    IconPack.IconType.GridCross,
                    IconPack.IconType.GridEdge,
                    IconPack.IconType.GridCenter,
                    IconPack.IconType.NoGrid
                }, new string[] {
                    "Grid cross",
                    "Grid edge",
                    "Grid center",
                    "No grid"
                }, new System.Action <object[]>[] {
                    (objects) => {
                        SnapType = SnapTypes.Cross;
                    },
                    (objects) => {
                        SnapType = SnapTypes.Edge;
                    },
                    (objects) => {
                        SnapType = SnapTypes.Center;
                    },
                    (objects) => {
                        SnapType = SnapTypes.FreeForm;
                    }
                }, SnapTypeIndex, UI.ToolTipComponent.AlignSide.Top
                                 ));

                #endregion
                #region Align To Surface
                Settings.Add(new UI.Toolbar.HeaderAction(
                                 UI.Toolbar.HeaderActionType.Toggle,
                                 new IconPack.IconType[] {
                    IconPack.IconType.AlignStraight,
                    IconPack.IconType.AlignSurface,
                    IconPack.IconType.AlignSet,
                    IconPack.IconType.NoAlign
                }, new string[] {
                    "Align to surface position",
                    "Align to surface",
                    "Align to anything",
                    "Don't align"
                }, new System.Action <object[]>[] {
                    (objects) => {
                        AlignToSurface = 0;
                    },
                    (objects) => {
                        AlignToSurface = 1;
                    },
                    (objects) => {
                        AlignToSurface = 2;
                    },
                    (objects) => {
                        AlignToSurface = 3;
                    }
                }, AlignToSurface, UI.ToolTipComponent.AlignSide.Top
                                 ));
                #endregion
                #region Stack Types
                int StackIndex = 0;
                if (StackType == StackTypes.Center)
                {
                    StackIndex = 1;
                }
                else if (StackType == StackTypes.Disabled)
                {
                    StackIndex = 2;
                }
                Settings.Add(new UI.Toolbar.HeaderAction(
                                 UI.Toolbar.HeaderActionType.Toggle,
                                 new IconPack.IconType[] {
                    IconPack.IconType.BoundaryStacking,
                    IconPack.IconType.CenterStacking,
                    IconPack.IconType.NoStacking
                }, new string[] {
                    "Boundary stacking",
                    "Center stacking",
                    "No stacking"
                }, new System.Action <object[]>[] {
                    (objects) => {
                        StackType = StackTypes.Boundary;
                    },
                    (objects) => {
                        StackType = StackTypes.Center;
                    },
                    (objects) => {
                        StackType = StackTypes.Disabled;
                    }
                }, StackIndex, UI.ToolTipComponent.AlignSide.Top
                                 ));
                #endregion
                #region Local/world Space
                int LocalSetting = (LocalSpace)?0:1;
                Settings.Add(new UI.Toolbar.HeaderAction(
                                 UI.Toolbar.HeaderActionType.Boolean,
                                 new IconPack.IconType[] {
                    IconPack.IconType.LocalSpace,
                    IconPack.IconType.WorldSpace
                }, new string[] {
                    "Local space",
                    "World space"
                }, new System.Action <object[]>[] {
                    (objects) => {
                        LocalSpace = true;
                    },
                    (objects) => {
                        LocalSpace = false;
                    }
                }, LocalSetting, UI.ToolTipComponent.AlignSide.Top
                                 ));
                #endregion
            }

            #region Colors
            ModularPlacableObject.ColorGroup[] ColorGroups = new Modular.ModularPlacableObject[] { ScopedObject }.ColorGroups();
            if (ColorGroups.Length < 8)               // limit colors to 8
            {
                for (int i = 0; i < ColorGroups.Length; i++)
                {
                    ColorActions.Add(InitColorSwatch(ColorGroups, i));
                }
            }
            #endregion


            #endregion

            // create toolbar settings
            UI.Toolbar.ToolbarSettings TempSettings = new UI.Toolbar.ToolbarSettings {
                HeaderSections = new UI.Toolbar.HeaderSection[] {                 // movement actions section
                    new UI.Toolbar.HeaderSection(Settings.ToArray()),
                    new UI.Toolbar.HeaderSection(ColorActions.ToArray())
                },
                ToolbarIconSize    = 28f,
                Title              = "Advanced",
                ScreenPadding      = 52,
                MaxLength          = 40,
                SettingsToolTip    = "Extra",
                TransparentOnHover = true,
                Content            = (ScopedObject.PositionRestriction == PositionRestrictions.None)?new object[] {
                    DetailSettings
                }:new object[0]
            };

            // init toolbar
            if (SettingsBar == null)
            {
                SettingsBar = GameManager.I.UI.InitToolbar(TempSettings, false);
            }
            else
            {
                for (int i = 0; i < SettingsBar.ToolbarSettings.HeaderSections.Length; i++)
                {
                    if (TempSettings.HeaderSections.Length > i)
                    {
                        for (int x = 0; x < SettingsBar.ToolbarSettings.HeaderSections [i].Actions.Length; x++)
                        {
                            if (TempSettings.HeaderSections [i].Actions.Length > x)
                            {
                                SettingsBar.ToolbarSettings.HeaderSections [i].Actions [x].ClickCallbacks = TempSettings.HeaderSections [i].Actions [x].ClickCallbacks;
                            }
                        }
                    }
                }
            }
        }