private void UpdateAssetPicker()
 {
     if (_assetPicker == null)
     {
         _assetPicker = GetChild <AssetPicker>();
         _assetPicker.SelectedItemChanged += SelectedItemChanged;
     }
 }
Exemple #2
0
        /// <summary>
        /// Opens a zone file stored in pack assets.
        /// </summary>
        private async void OpenFromPackOnClick(object sender, EventArgs e)
        {
            await new WaitForUpdate();
            AssetPicker picker = new AssetPicker(AssetType.ZONE, "Load Zone");

            container.Inject(picker);
            picker.Show();
            picker.Focus();

            picker.OnAssetPicked += asset => zoneFactory.LoadZoneFromPacks(asset);
        }
Exemple #3
0
            /// <inheritdoc />
            public override void OnLoaded()
            {
                base.OnLoaded();

                FlaxEngine.Content.AssetReloading += OnAssetReloading;
                FlaxEngine.Content.AssetDisposing += OnContentAssetDisposing;
                _isRegistered = true;

                _assetPicker        = GetChild <AssetPicker>();
                _assetPicker.Bounds = new Rectangle(4, 32.0f, Width - 8, 48.0f);
                UpdateUI();
                _assetPicker.SelectedItemChanged += OnAssetPickerSelectedItemChanged;
            }
Exemple #4
0
            /// <inheritdoc />
            public override void OnDestroy()
            {
                _assetPicker = null;
                _asset       = null;
                if (_isRegistered)
                {
                    _isRegistered = false;
                    FlaxEngine.Content.AssetReloading -= OnAssetReloading;
                    FlaxEngine.Content.AssetDisposing -= OnContentAssetDisposing;
                }

                base.OnDestroy();
            }
Exemple #5
0
            /// <inheritdoc />
            public MultiBlend(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
                : base(id, context, nodeArch, groupArch)
            {
                var layoutOffsetY = FlaxEditor.Surface.Constants.LayoutOffsetY;

                _selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY)
                {
                    HorizontalAlignment = TextAlignment.Near,
                    Text   = "Selected Animation:",
                    Parent = this
                };

                _selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width)
                {
                    Parent = this
                };

                _selectedAnimation.PopupShowing         += OnSelectedAnimationPopupShowing;
                _selectedAnimation.SelectedIndexChanged += OnSelectedAnimationChanged;

                var items = new List <string>(MaxAnimationsCount);

                while (items.Count < MaxAnimationsCount)
                {
                    items.Add(string.Empty);
                }
                _selectedAnimation.Items = items;

                _animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4))
                {
                    Parent = this
                };
                _animationPicker.SelectedItemChanged += OnAnimationPickerItemChanged;

                _animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight)
                {
                    HorizontalAlignment = TextAlignment.Near,
                    Text   = "Speed:",
                    Parent = this
                };

                _animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4)
                {
                    SlideSpeed = 0.01f,
                    Parent     = this
                };
                _animationSpeed.ValueChanged += OnAnimationSpeedValueChanged;
            }
Exemple #6
0
            public AssetNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, Guid assetId)
                : base(id, context, nodeArch, groupArch)
            {
                AssetId = assetId;

                // Init node UI
                var picker = new AssetPicker
                {
                    Location = new Vector2(40, 2 * Constants.LayoutOffsetY),
                    Width    = 100.0f,
                    CanEdit  = false,
                    Parent   = this,
                };
                // TODO: display some asset info like disk size, memory usage, etc.
                var asset = FlaxEngine.Content.LoadAsync <Asset>(AssetId);

                if (asset != null)
                {
                    var path = asset.Path;
                    picker.SelectedAsset = asset;
                    Title       = System.IO.Path.GetFileNameWithoutExtension(path);
                    TooltipText = asset.TypeName + '\n' + path;
                }
                else
                {
                    picker.SelectedID = AssetId;
                    var assetItem = picker.SelectedItem;
                    if (assetItem != null)
                    {
                        Title       = assetItem.ShortName;
                        TooltipText = assetItem.TypeName + '\n' + assetItem.Path;
                    }
                    else
                    {
                        Title = AssetId.ToString();
                    }
                }
                ResizeAuto();
                LayoutHeight = Height;
            }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditTab"/> class.
        /// </summary>
        /// <param name="tab">The parent tab.</param>
        /// <param name="gizmo">The related gizmo.</param>
        public EditTab(CarveTab tab, EditTerrainGizmoMode gizmo)
            : base("Edit")
        {
            CarveTab = tab;
            Gizmo    = gizmo;
            CarveTab.SelectedTerrainChanged += OnSelectionChanged;
            Gizmo.SelectedChunkCoordChanged += OnSelectionChanged;

            // Main panel
            var panel = new Panel(ScrollBars.Both)
            {
                DockStyle = DockStyle.Fill,
                Parent    = this
            };

            // Mode
            var modeLabel = new Label(4, 4, 40, 18)
            {
                HorizontalAlignment = TextAlignment.Near,
                Text   = "Mode:",
                Parent = panel,
            };

            _modeComboBox = new ComboBox(modeLabel.Right + 4, 4, 110)
            {
                Parent = panel,
            };
            _modeComboBox.AddItem("Edit Chunk");
            _modeComboBox.AddItem("Add Patch");
            _modeComboBox.AddItem("Remove Patch");
            _modeComboBox.AddItem("Export terrain");
            _modeComboBox.SelectedIndex         = 0;
            _modeComboBox.SelectedIndexChanged += (combobox) => Gizmo.EditMode = (EditTerrainGizmoMode.Modes)combobox.SelectedIndex;
            Gizmo.ModeChanged += OnGizmoModeChanged;

            // Info
            _selectionInfoLabel = new Label(modeLabel.X, modeLabel.Bottom + 4, 40, 18 * 3)
            {
                VerticalAlignment   = TextAlignment.Near,
                HorizontalAlignment = TextAlignment.Near,
                Parent = panel,
            };

            // Chunk Properties
            _chunkProperties = new Panel(ScrollBars.None)
            {
                Location = new Vector2(_selectionInfoLabel.X, _selectionInfoLabel.Bottom + 4),
                Parent   = panel,
            };
            var chunkOverrideMaterialLabel = new Label(0, 0, 90, 64)
            {
                HorizontalAlignment = TextAlignment.Near,
                Text   = "Override Material",
                Parent = _chunkProperties,
            };

            _chunkOverrideMaterial = new AssetPicker(typeof(MaterialBase), new Vector2(chunkOverrideMaterialLabel.Right + 4, 0))
            {
                Width  = 300.0f,
                Parent = _chunkProperties,
            };
            _chunkOverrideMaterial.SelectedItemChanged += OnSelectedChunkOverrideMaterialChanged;
            _chunkProperties.Size = new Vector2(_chunkOverrideMaterial.Right + 4, _chunkOverrideMaterial.Bottom + 4);

            // Delete patch
            _deletePatchButton = new Button(_selectionInfoLabel.X, _selectionInfoLabel.Bottom + 4)
            {
                Text   = "Delete Patch",
                Parent = panel,
            };
            _deletePatchButton.Clicked += OnDeletePatchButtonClicked;

            // Export terrain
            _exportTerrainButton = new Button(_selectionInfoLabel.X, _selectionInfoLabel.Bottom + 4)
            {
                Text   = "Export terrain",
                Parent = panel,
            };
            _exportTerrainButton.Clicked += OnExportTerrainButtonClicked;

            // Update UI to match the current state
            OnSelectionChanged();
            OnGizmoModeChanged();
        }