Пример #1
0
        public override void _Ready()
        {
            base._Ready();

            editorInterface = GodotSharpEditor.Instance.GetEditorInterface();

            var editorBaseControl = editorInterface.GetBaseControl();

            SizeFlagsVertical = (int)SizeFlags.ExpandFill;
            SetAnchorsAndMarginsPreset(LayoutPreset.Wide);

            panelTabs = new TabContainer
            {
                TabAlign          = TabContainer.TabAlignEnum.Left,
                RectMinSize       = new Vector2(0, 228) * EditorScale,
                SizeFlagsVertical = (int)SizeFlags.ExpandFill
            };
            panelTabs.AddStyleboxOverride("panel", editorBaseControl.GetStylebox("DebuggerPanel", "EditorStyles"));
            panelTabs.AddStyleboxOverride("tab_fg", editorBaseControl.GetStylebox("DebuggerTabFG", "EditorStyles"));
            panelTabs.AddStyleboxOverride("tab_bg", editorBaseControl.GetStylebox("DebuggerTabBG", "EditorStyles"));
            AddChild(panelTabs);

            {
                // Builds tab
                panelBuildsTab = new VBoxContainer
                {
                    Name = "Builds".TTR(),
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill
                };
                panelTabs.AddChild(panelBuildsTab);

                var toolBarHBox = new HBoxContainer {
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill
                };
                panelBuildsTab.AddChild(toolBarHBox);

                var buildProjectBtn = new Button
                {
                    Text      = "Build Project".TTR(),
                    FocusMode = FocusModeEnum.None
                };
                buildProjectBtn.Connect("pressed", this, nameof(BuildProjectPressed));
                toolBarHBox.AddChild(buildProjectBtn);

                toolBarHBox.AddSpacer(begin: false);

                warningsBtn = new ToolButton
                {
                    Text       = "Warnings".TTR(),
                    ToggleMode = true,
                    Pressed    = true,
                    Visible    = false,
                    FocusMode  = FocusModeEnum.None
                };
                warningsBtn.Connect("toggled", this, nameof(_WarningsToggled));
                toolBarHBox.AddChild(warningsBtn);

                errorsBtn = new ToolButton
                {
                    Text       = "Errors".TTR(),
                    ToggleMode = true,
                    Pressed    = true,
                    Visible    = false,
                    FocusMode  = FocusModeEnum.None
                };
                errorsBtn.Connect("toggled", this, nameof(_ErrorsToggled));
                toolBarHBox.AddChild(errorsBtn);

                toolBarHBox.AddSpacer(begin: false);

                viewLogBtn = new Button
                {
                    Text      = "View log".TTR(),
                    FocusMode = FocusModeEnum.None,
                    Visible   = false
                };
                viewLogBtn.Connect("pressed", this, nameof(_ViewLogPressed));
                toolBarHBox.AddChild(viewLogBtn);

                var hsc = new HSplitContainer
                {
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill,
                    SizeFlagsVertical   = (int)SizeFlags.ExpandFill
                };
                panelBuildsTab.AddChild(hsc);

                buildTabsList = new ItemList {
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill
                };
                buildTabsList.Connect("item_selected", this, nameof(_BuildTabsItemSelected));
                buildTabsList.Connect("nothing_selected", this, nameof(_BuildTabsNothingSelected));
                hsc.AddChild(buildTabsList);

                buildTabs = new TabContainer
                {
                    TabAlign            = TabContainer.TabAlignEnum.Left,
                    SizeFlagsHorizontal = (int)SizeFlags.ExpandFill,
                    TabsVisible         = false
                };
                hsc.AddChild(buildTabs);
            }
        }
        public ConstructionMenu()
        {
            IoCManager.InjectDependencies(this);
            Placement = (PlacementManager)IoCManager.Resolve <IPlacementManager>();
            Placement.PlacementCanceled += OnPlacementCanceled;

            Title = "Construction";

            var hSplitContainer = new HSplitContainer();

            // Left side
            var recipes = new VBoxContainer {
                CustomMinimumSize = new Vector2(150.0f, 0.0f)
            };

            SearchBar = new LineEdit {
                PlaceHolder = "Search"
            };
            RecipeList = new Tree {
                SizeFlagsVertical = SizeFlags.FillExpand, HideRoot = true
            };
            recipes.AddChild(SearchBar);
            recipes.AddChild(RecipeList);
            hSplitContainer.AddChild(recipes);

            // Right side
            var guide = new VBoxContainer();
            var info  = new HBoxContainer();

            InfoIcon  = new TextureRect();
            InfoLabel = new Label
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.ShrinkCenter
            };
            info.AddChild(InfoIcon);
            info.AddChild(InfoLabel);
            guide.AddChild(info);

            var stepsLabel = new Label
            {
                SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
                SizeFlagsVertical   = SizeFlags.ShrinkCenter,
                Text = "Steps"
            };

            guide.AddChild(stepsLabel);

            StepList = new ItemList
            {
                SizeFlagsVertical = SizeFlags.FillExpand, SelectMode = ItemList.ItemListSelectMode.None
            };
            guide.AddChild(StepList);

            var buttonsContainer = new HBoxContainer();

            BuildButton = new Button
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                TextAlign           = Label.AlignMode.Center,
                Text       = "Build!",
                Disabled   = true,
                ToggleMode = false
            };
            EraseButton = new Button
            {
                TextAlign = Label.AlignMode.Center, Text = "Clear Ghosts", ToggleMode = true
            };
            buttonsContainer.AddChild(BuildButton);
            buttonsContainer.AddChild(EraseButton);
            guide.AddChild(buttonsContainer);

            hSplitContainer.AddChild(guide);
            Contents.AddChild(hSplitContainer);

            BuildButton.OnPressed     += OnBuildPressed;
            EraseButton.OnToggled     += OnEraseToggled;
            SearchBar.OnTextChanged   += OnTextEntered;
            RecipeList.OnItemSelected += OnItemSelected;

            PopulatePrototypeList();
            PopulateTree();
        }