Exemplo n.º 1
0
        void Construct()
        {
            if (database == null)
            {
                database = RTS.Subsys.DataProvider.Get().componentDatabase;
            }

            if (root == null)
            {
                //Build ui

                if (tabs == null)
                {
                    tabs = new ESwitchTab().RelativeSize(true)
                           + new ComponentEditor.Tabs.DBEditTab(this)
                           + new ComponentEditor.Tabs.NewCompTab(this)
                           + new ComponentEditor.Tabs.CompEditTab(this)
                    ;
                    tabs.FixInheritance(null);
                }

                root = new EVerticalLayout()
                       + tabs;

                PrefabStage.prefabStageClosing += Closing;
            }


            root.OnConstruct(this);
        }
Exemplo n.º 2
0
            void UpdateCompList()
            {
                EditorUIBase GenCompEntry(int index)
                {
                    var disp = new EHorizontalLayout()
                               + new EText().Content(index.ToString()).Width(20)
                               + new EText().BindContent(() =>
                    {
                        AssetTypes.ComponentDBPage p = window.GetSelectedPage();
                        if (p != null)
                        {
                            if (p.componentList.Count > index)
                            {
                                return(p.componentList[index].name);
                            }
                        }
                        return("OUT OF SCOPE!");
                    }).RelativeSize(true);

                    var tabs    = new ESwitchTab().Height(100);
                    var element = tabs
                                  //Unselected
                                  + (new EButton().OnClicked((EButton b) => { window.selectedComp = index; window.OpenCompEditTab(); })
                                     + disp
                                     )
                    ;

                    element.OnConstruct(window);
                    return(element);
                }

                AssetTypes.ComponentDBPage page = window.GetSelectedPage();

                if (page == null)
                {
                    compList.children.Clear();
                    return;
                }

                if (compList.children.Count < page.componentList.Count)
                {
                    for (int i = compList.children.Count; i < page.componentList.Count; i++)
                    {
                        compList.children.Add(GenCompEntry(i));
                    }
                }
                else if (page.componentList.Count < compList.children.Count)
                {
                    compList.children.RemoveRange(page.componentList.Count, compList.children.Count - page.componentList.Count);
                }
            }
Exemplo n.º 3
0
            public PageContentPanel(ComponentEditorWindow window)
            {
                RelativeSize(true);
                UCellRelativeSize(false);
                UCellWidth(200);
                HandleSize(4);
                this.window    = window;
                delPageButton  = new EButton().Width(100).OnClicked((EButton b) => DelPage()) + new EText().Content("Del");
                editPageButton = new EButton().Width(100).OnClicked((EButton b) => EditPage()) + new EText().Content("Rename");

                namingBar = (new ESwitchTab().Height(16)
                             + (new EHorizontalLayout().Height(16)
                                + new EText().BindContent(() =>
                {
                    return(this.window.selectedPage == -1 ? "" : window.database.pages[this.window.selectedPage].pageName);
                })
                                .RelativeSize(true)
                                + editPageButton
                                + delPageButton
                                )
                             + (new EHorizontalLayout().Height(16)
                                + new ETextInputField().RelativeSize(true)
                                + editPageButton
                                + delPageButton
                                )
                             );

                compList = new EVerticalLayout().RelativeSize(true).EnableScroll(true);
                uchild   = (new EVerticalLayout().RelativeSize(true)
                            + namingBar
                            + (new EButton().Height(20) + new EText("Flags"))
                            + (new EVerticalLayout().RelativeSize(true).EnableScroll(true)
                               + new EBox().Content(new GUIContent("Placeholder")).Height(50)
                               + new EBox().Content(new GUIContent("Placeholder")).Height(50)
                               + new EBox().Content(new GUIContent("Placeholder")).Height(50)
                               )
                            );
                //page contents
                lchild = (
                    new EVerticalLayout().RelativeSize(true)
                    + (new EButton().OnClicked((EButton b) => window.OpenCompCreateTab()) + new EText("New component"))
                    + compList
                    );
            }
Exemplo n.º 4
0
            void UpdatePageList()
            {
                EditorUIBase GenPageEntry(int index)
                {
                    var disp = new EHorizontalLayout()
                               + new EText().Content(index.ToString()).Width(20)
                               + new EText().BindContent(() =>
                    {
                        if (window.database.pages.Count > index)
                        {
                            return(window.database.pages[index].pageName);
                        }
                        else
                        {
                            return("OUT OF SCOPE!");
                        }
                    }).RelativeSize(true);

                    var tabs    = new ESwitchTab();
                    var element = tabs
                                  //Unselected
                                  + (new EButton().OnClicked((EButton b) => { SelectPageEntry(index); })
                                     + disp
                                     )
                                  //Selected
                                  + (new ECascade()
                                     + disp
                                     + new EBox()
                                     )

                    ;

                    element.OnConstruct(window);
                    return(element);
                }

                if (dbPageList.children.Count < window.database.pages.Count)
                {
                    for (int i = dbPageList.children.Count; i < window.database.pages.Count; i++)
                    {
                        dbPageList.children.Add(GenPageEntry(i));
                    }
                }
                else if (window.database.pages.Count < dbPageList.children.Count)
                {
                    dbPageList.children.RemoveRange(window.database.pages.Count, dbPageList.children.Count - window.database.pages.Count);
                }

                for (int i = 0; i < dbPageList.children.Count; i++)
                {
                    ESwitchTab entry = (dbPageList.children[i] as ESwitchTab);
                    if (window.selectedPage == i)
                    {
                        if (entry.ActivatedTab() == 0)
                        {
                            entry.ActivateTab(1);
                        }
                    }
                    else
                    {
                        entry.ActivateTab(0);
                    }
                }
            }
Exemplo n.º 5
0
        public NewCompTab(ComponentEditorWindow window)
        {
            RelativeSize(true);
            this.window = window;

            aimingAngleField = new ETextInputField().OnInputUpdate((ETextInputField f, string val) =>
            {
                compAim.aimingAngle = Convert.ToSingle(val);
            }).RelativeSize(true);
            horizontalRotationSpeedField = new ETextInputField().OnInputUpdate((ETextInputField f, string val) =>
            {
                compAim.horizontalRotationSpeed = Convert.ToSingle(val);
            }).RelativeSize(true);
            verticalRotationSpeedField = new ETextInputField().OnInputUpdate((ETextInputField f, string val) =>
            {
                compAim.verticalRotationSpeed = Convert.ToSingle(val);
            }).RelativeSize(true);

            List <string> aimingTypes = new List <string>(Enum.GetNames(typeof(ComponentAimingType)));

            aimingTypes.Insert(0, "Disable aiming");

            var aimConfig = new ESwitchTab().RelativeSize(true).OnActivateTab((ESwitchTab tab, int i) => { })
                            + new EBox().Content(new GUIContent("Aiming disabled"))
                            + (new EVerticalLayout()
                               + (new EHorizontalLayout()
                                  + (new EText("Aiming angle resolution").RelativeSize(true))
                                  + aimingAngleField
                                  )
                               + (new EHorizontalLayout()
                                  + (new EText("Horizontal rotation speed").RelativeSize(true))
                                  + horizontalRotationSpeedField
                                  )
                               + (new EHorizontalLayout()
                                  + (new EText("Vertical rotation speed").RelativeSize(true))
                                  + verticalRotationSpeedField
                                  )
                               );

            children.Add(new EVerticalLayout().RelativeSize(true)
                         //Name input field

                         //Name viability status


                         + (new EHorizontalLayout()
                            //Component type
                            + (new ETextInputField().OnInputUpdate((ETextInputField f, string val) => SetName(val))).RelativeSize(true).Width(3)
                            + new EPopup().RelativeSize(true).Width(1)
                            .Content(Enum.GetNames(typeof(ComponentType)))
                            .OnSelectionChange((EPopup p, int i) => { SetType(i); })
                            )
                         + (new EText().BindContent(() => { return(CheckNameViability() ? "All good" : "!! Naming conflict !!"); }))
                         //Component aiming mechanism
                         + new EPopup()
                         .Content(aimingTypes.ToArray())
                         .OnSelectionChange((EPopup p, int i) => {
                if (i == 0)
                {
                    aimConfig.ActivateTab(0);
                }
                else
                {
                    aimConfig.ActivateTab(1);
                }
                SetAimType(i);
            })
                         + aimConfig
                         );

            children.Add(
                new EHorizontalLayout()
                + (new EButton().RelativeSize(true).OnClicked((EButton b) => CreateComponent()) + new EText("Create"))
                + (new EButton().RelativeSize(true).OnClicked((EButton b) => window.OpenDBEditTab()) + new EText("Cancel"))
                );
        }