Exemple #1
0
        public LatheQueueMenu()
        {
            Title = "Lathe Queue";

            var margin = new MarginContainer()
            {
                MarginTop    = 5f,
                MarginLeft   = 5f,
                MarginRight  = -5f,
                MarginBottom = -5f,
            };

            margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var vBox = new VBoxContainer();

            vBox.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var descMargin = new MarginContainer()
            {
                MarginTop             = 5f,
                MarginLeft            = 5f,
                MarginRight           = -5f,
                MarginBottom          = -5f,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 2,
            };

            var hBox = new HBoxContainer()
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
            };

            Icon = new TextureRect()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 2,
            };

            var vBoxInfo = new VBoxContainer()
            {
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3,
            };

            NameLabel = new Label()
            {
                RectClipContent     = true,
                SizeFlagsHorizontal = SizeFlags.Fill,
            };

            Description = new Label()
            {
                RectClipContent     = true,
                SizeFlagsVertical   = SizeFlags.FillExpand,
                SizeFlagsHorizontal = SizeFlags.Fill,
            };

            QueueList = new ItemList()
            {
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3,
                SelectMode            = ItemList.ItemListSelectMode.None
            };

            vBoxInfo.AddChild(NameLabel);
            vBoxInfo.AddChild(Description);

            hBox.AddChild(Icon);
            hBox.AddChild(vBoxInfo);

            descMargin.AddChild(hBox);

            vBox.AddChild(descMargin);
            vBox.AddChild(QueueList);

            margin.AddChild(vBox);

            Contents.AddChild(margin);

            ClearInfo();
        }
        public InstrumentMenu(InstrumentBoundUserInterface owner)
        {
            IoCManager.InjectDependencies(this);
            Title = "Instrument";

            _owner = owner;

            _owner.Instrument.OnMidiPlaybackEnded += InstrumentOnMidiPlaybackEnded;

            var margin = new MarginContainer()
            {
                SizeFlagsVertical   = SizeFlags.FillExpand,
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                MarginTop           = 5f,
                MarginLeft          = 5f,
                MarginRight         = -5f,
                MarginBottom        = -5f,
            };

            margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var vBox = new VBoxContainer()
            {
                SizeFlagsVertical  = SizeFlags.FillExpand,
                SeparationOverride = 5,
            };

            vBox.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var hBoxTopButtons = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
                Align = BoxContainer.AlignMode.Center
            };

            midiInputButton = new Button()
            {
                Text                  = "MIDI Input",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
                ToggleMode            = true,
                Pressed               = _owner.Instrument.IsInputOpen,
            };

            midiInputButton.OnToggled += MidiInputButtonOnOnToggled;

            var topSpacer = new Control()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 2,
            };

            var midiFileButton = new Button()
            {
                Text                  = "Open File",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
            };

            midiFileButton.OnPressed += MidiFileButtonOnOnPressed;

            var hBoxBottomButtons = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
                Align = BoxContainer.AlignMode.Center
            };

            midiLoopButton = new Button()
            {
                Text                  = "Loop",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
                ToggleMode            = true,
                Disabled              = !_owner.Instrument.IsMidiOpen,
                Pressed               = _owner.Instrument.LoopMidi,
            };

            midiLoopButton.OnToggled += MidiLoopButtonOnOnToggled;

            var bottomSpacer = new Control()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 2,
            };

            midiStopButton = new Button()
            {
                Text                  = "Stop",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
                Disabled              = !_owner.Instrument.IsMidiOpen,
            };

            midiStopButton.OnPressed += MidiStopButtonOnPressed;

            hBoxBottomButtons.AddChild(midiLoopButton);
            hBoxBottomButtons.AddChild(bottomSpacer);
            hBoxBottomButtons.AddChild(midiStopButton);

            hBoxTopButtons.AddChild(midiInputButton);
            hBoxTopButtons.AddChild(topSpacer);
            hBoxTopButtons.AddChild(midiFileButton);

            vBox.AddChild(hBoxTopButtons);
            vBox.AddChild(hBoxBottomButtons);

            margin.AddChild(vBox);

            Contents.AddChild(margin);
        }
Exemple #3
0
        public LatheMenu(LatheBoundUserInterface owner = null)
        {
            IoCManager.InjectDependencies(this);

            Owner = owner;

            Title = "Lathe Menu";

            var margin = new MarginContainer()
            {
                SizeFlagsVertical   = SizeFlags.FillExpand,
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                MarginTop           = 5f,
                MarginLeft          = 5f,
                MarginRight         = -5f,
                MarginBottom        = -5f,
            };

            margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var vBox = new VBoxContainer()
            {
                SizeFlagsVertical  = SizeFlags.FillExpand,
                SeparationOverride = 5,
            };

            vBox.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var hBoxButtons = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
            };

            QueueButton = new Button()
            {
                Text                  = "Queue",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
            };

            ServerConnectButton = new Button()
            {
                Text                  = "Server list",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
            };

            ServerSyncButton = new Button()
            {
                Text                  = "Sync",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
            };

            var spacer = new Control()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3,
            };

            spacer.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var hBoxFilter = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1
            };

            SearchBar = new LineEdit()
            {
                PlaceHolder           = "Search Designs",
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3
            };

            SearchBar.OnTextChanged += Populate;

            var filterButton = new Button()
            {
                Text                  = "Filter",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsStretchRatio = 1,
                Disabled              = true,
            };

            Items = new ItemList()
            {
                SizeFlagsStretchRatio = 8,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SelectMode            = ItemList.ItemListSelectMode.Button,
            };

            Items.OnItemSelected += ItemSelected;

            AmountLineEdit = new LineEdit()
            {
                PlaceHolder         = "Amount",
                Text                = "1",
                SizeFlagsHorizontal = SizeFlags.FillExpand,
            };

            AmountLineEdit.OnTextChanged += PopulateDisabled;

            Materials = new ItemList()
            {
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3
            };

            hBoxButtons.AddChild(spacer);
            if (Owner?.Database is ProtolatheDatabaseComponent database)
            {
                hBoxButtons.AddChild(ServerConnectButton);
                hBoxButtons.AddChild(ServerSyncButton);
                database.OnDatabaseUpdated += Populate;
            }
            hBoxButtons.AddChild(QueueButton);

            hBoxFilter.AddChild(SearchBar);
            hBoxFilter.AddChild(filterButton);

            vBox.AddChild(hBoxButtons);
            vBox.AddChild(hBoxFilter);
            vBox.AddChild(Items);
            vBox.AddChild(AmountLineEdit);
            vBox.AddChild(Materials);

            margin.AddChild(vBox);

            Contents.AddChild(margin);
        }
        protected override void Initialize()
        {
            base.Initialize();
            IoCManager.InjectDependencies(this);

            HideOnClose = true;
            Title       = "Lathe Menu";
            Visible     = false;

            var margin = new MarginContainer()
            {
                SizeFlagsVertical   = SizeFlags.FillExpand,
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                MarginTop           = 5f,
                MarginLeft          = 5f,
                MarginRight         = -5f,
                MarginBottom        = -5f,
            };

            margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var vbox = new VBoxContainer()
            {
                SizeFlagsVertical  = SizeFlags.FillExpand,
                SeparationOverride = 5,
            };

            vbox.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var hboxButtons = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
            };

            QueueButton = new Button()
            {
                Text                  = "Queue",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
            };

            var spacer = new Control()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3,
            };

            spacer.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var hboxFilter = new HBoxContainer()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1
            };

            SearchBar = new LineEdit()
            {
                PlaceHolder           = "Search Designs",
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3
            };

            SearchBar.OnTextChanged += Populate;

            var filterButton = new Button()
            {
                Text                  = "Filter",
                TextAlign             = Button.AlignMode.Center,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 1,
                Disabled              = true,
            };

            Items = new ItemList()
            {
                SizeFlagsStretchRatio = 8,
                SizeFlagsVertical     = SizeFlags.FillExpand,
            };



            Items.OnItemSelected += ItemSelected;

            AmountLineEdit = new LineEdit()
            {
                PlaceHolder         = "Amount",
                Text                = "1",
                SizeFlagsHorizontal = SizeFlags.FillExpand,
            };

            AmountLineEdit.OnTextChanged += PopulateDisabled;

            Materials = new ItemList()
            {
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3
            };

            hboxButtons.AddChild(spacer);
            hboxButtons.AddChild(QueueButton);

            hboxFilter.AddChild(SearchBar);
            hboxFilter.AddChild(filterButton);

            vbox.AddChild(hboxButtons);
            vbox.AddChild(hboxFilter);
            vbox.AddChild(Items);
            vbox.AddChild(AmountLineEdit);
            vbox.AddChild(Materials);

            margin.AddChild(vbox);

            Contents.AddChild(margin);
        }
        protected override void Initialize()
        {
            base.Initialize();

            HideOnClose = true;
            Title       = "Lathe Queue";
            Visible     = false;

            var margin = new MarginContainer()
            {
                MarginTop    = 5f,
                MarginLeft   = 5f,
                MarginRight  = -5f,
                MarginBottom = -5f,
            };

            margin.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var vbox = new VBoxContainer();

            vbox.SetAnchorAndMarginPreset(LayoutPreset.Wide);

            var descMargin = new MarginContainer()
            {
                MarginTop             = 5f,
                MarginLeft            = 5f,
                MarginRight           = -5f,
                MarginBottom          = -5f,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 2,
            };

            var hbox = new HBoxContainer()
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
            };

            Icon = new TextureRect()
            {
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 2,
            };

            var vboxInfo = new VBoxContainer()
            {
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3,
            };

            NameLabel = new Label()
            {
                RectClipContent     = true,
                SizeFlagsHorizontal = SizeFlags.Fill,
            };

            Description = new Label()
            {
                RectClipContent     = true,
                SizeFlagsVertical   = SizeFlags.FillExpand,
                SizeFlagsHorizontal = SizeFlags.Fill,
            };

            QueueList = new ItemList()
            {
                SizeFlagsHorizontal   = SizeFlags.Fill,
                SizeFlagsVertical     = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 3,
                SelectMode            = ItemList.ItemListSelectMode.None
            };

            vboxInfo.AddChild(NameLabel);
            vboxInfo.AddChild(Description);

            hbox.AddChild(Icon);
            hbox.AddChild(vboxInfo);

            descMargin.AddChild(hbox);

            vbox.AddChild(descMargin);
            vbox.AddChild(QueueList);

            margin.AddChild(vbox);

            Contents.AddChild(margin);

            ClearInfo();
        }