Esempio n. 1
0
            public LogEntry(DebugLogWindow window, ref LogEntryDescription desc)
                : base(0, 0, 120, DefaultHeight)
            {
                AnchorPreset = AnchorPresets.HorizontalStretchTop;
                IsScrollable = true;

                _window = window;
                Desc    = desc;
                switch (desc.Level)
                {
                case LogType.Warning:
                    Group = LogGroup.Warning;
                    Icon  = _window.IconWarning;
                    break;

                case LogType.Info:
                    Group = LogGroup.Info;
                    Icon  = _window.IconInfo;
                    break;

                default:
                    Group = LogGroup.Error;
                    Icon  = _window.IconError;
                    break;
                }
            }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DebugLogWindow"/> class.
        /// </summary>
        /// <param name="editor">The editor.</param>
        public DebugLogWindow(Editor editor)
            : base(editor, true, ScrollBars.None)
        {
            Title = "Debug Log";
            OnEditorOptionsChanged(Editor.Options.Options);

            // Toolstrip
            var toolstrip = new ToolStrip(22.0f)
            {
                Parent = this,
            };

            toolstrip.AddButton("Clear", Clear).LinkTooltip("Clears all log entries");
            _clearOnPlayButton  = (ToolStripButton)toolstrip.AddButton("Clear on Play").SetAutoCheck(true).SetChecked(true).LinkTooltip("Clears all log entries on enter playmode");
            _pauseOnErrorButton = (ToolStripButton)toolstrip.AddButton("Pause on Error").SetAutoCheck(true).LinkTooltip("Performs auto pause on error");
            toolstrip.AddSeparator();
            _groupButtons[0] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Error32, () => UpdateLogTypeVisibility(LogGroup.Error, _groupButtons[0].Checked)).SetAutoCheck(true).SetChecked(true).LinkTooltip("Shows/hides error messages");
            _groupButtons[1] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Warning32, () => UpdateLogTypeVisibility(LogGroup.Warning, _groupButtons[1].Checked)).SetAutoCheck(true).SetChecked(true).LinkTooltip("Shows/hides warning messages");
            _groupButtons[2] = (ToolStripButton)toolstrip.AddButton(editor.Icons.Info32, () => UpdateLogTypeVisibility(LogGroup.Info, _groupButtons[2].Checked)).SetAutoCheck(true).SetChecked(true).LinkTooltip("Shows/hides info messages");
            UpdateCount();

            // Split panel
            _split = new SplitPanel(Orientation.Vertical, ScrollBars.Vertical, ScrollBars.Both)
            {
                AnchorPreset  = AnchorPresets.StretchAll,
                Offsets       = new Margin(0, 0, toolstrip.Bottom, 0),
                SplitterValue = 0.8f,
                Parent        = this
            };

            // Info detail info
            _logInfo = new Label
            {
                Parent       = _split.Panel2,
                AutoWidth    = true,
                AutoHeight   = true,
                Margin       = new Margin(4),
                Offsets      = Margin.Zero,
                AnchorPreset = AnchorPresets.StretchAll,
            };

            // Entries panel
            _entriesPanel = new VerticalPanel
            {
                AnchorPreset = AnchorPresets.HorizontalStretchTop,
                Offsets      = Margin.Zero,
                IsScrollable = true,
                Parent       = _split.Panel1,
            };

            // Cache entries icons
            IconInfo    = Editor.Icons.Info32;
            IconWarning = Editor.Icons.Warning32;
            IconError   = Editor.Icons.Error32;

            // Bind events
            Editor.Options.OptionsChanged            += OnEditorOptionsChanged;
            Debug.Logger.LogHandler.SendLog          += LogHandlerOnSendLog;
            Debug.Logger.LogHandler.SendExceptionLog += LogHandlerOnSendExceptionLog;
        }
Esempio n. 3
0
        public override void Draw()
        {
            Vector2      oldpos    = Position;
            Vector2      oldDim    = Dimension;
            Vector2      oldScale  = Scale;
            SpriteHandle oldHandle = handle;

            Vector2 offset = GetOriginOffset(Width, Height, handle);

            offset.Y *= -1;
            Position -= offset;

            Handle = SpriteHandle.TOPLEFT;
            for (int i = 0; i < Text.Length; i++)
            {
                CurrentFrame = Text[i].ToString();
                ResetDimensions();

                Dimension *= oldScale;

                GetBaseDims = true;
                base.Draw();
                GetBaseDims = false;

                PosX += Dimension.X;// *ScaleX;
            }

            Handle    = oldHandle;
            Scale     = oldScale;
            Dimension = oldDim;
            Position  = oldpos;
        }
Esempio n. 4
0
 private Item(string text, DragData dragData, SpriteHandle icon)
     : base(false, icon, icon)
 {
     Text       = text;
     Height     = 20;
     TextMargin = new Margin(-5.0f, 2.0f, 2.0f, 2.0f);
     _dragData  = dragData;
 }
Esempio n. 5
0
        /// <summary>
        /// Adds sprite image to the layout.
        /// </summary>
        /// <param name="sprite">The sprite.</param>
        /// <returns>The created element.</returns>
        public ImageElement Image(SpriteHandle sprite)
        {
            var element = new ImageElement();

            element.Image.Brush = new SpriteBrush(sprite);
            OnAddElement(element);
            return(element);
        }
Esempio n. 6
0
        /// <summary>
        /// Finishes the rendering and updates the item thumbnail.
        /// </summary>
        /// <param name="icon">The icon.</param>
        public void FinishRender(ref SpriteHandle icon)
        {
            if (State != States.Prepared)
            {
                throw new InvalidOperationException();
            }

            Item.Thumbnail = icon;

            State = States.Rendered;
        }
Esempio n. 7
0
        public void Draw(string text, SharpDX.Color color, int x, int y)
        {
            if (!IsDrawing)
            {
                Core.EndAllDrawing(Core.RenderingType.Sprite);
                SpriteHandle.Begin();
                IsDrawing = true;
            }

            // Draw the text
            TextHandle.DrawText(SpriteHandle, text, x, y, color);
        }
Esempio n. 8
0
        /// <summary>
        /// Adds the button.
        /// </summary>
        /// <param name="sprite">The icon sprite.</param>
        /// <param name="onClick">The custom action to call on button clicked.</param>
        /// <returns>The button.</returns>
        public ToolStripButton AddButton(SpriteHandle sprite, Action onClick = null)
        {
            var button = new ToolStripButton(ItemsHeight, ref sprite)
            {
                Parent = this,
            };

            if (onClick != null)
            {
                button.Clicked += onClick;
            }
            return(button);
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CarveTab"/> class.
        /// </summary>
        /// <param name="icon">The icon.</param>
        /// <param name="editor">The editor instance.</param>
        public CarveTab(SpriteHandle icon, Editor editor)
            : base(string.Empty, icon)
        {
            Level.SceneLoaded += OnSceneLoaded;
            Editor             = editor;
            Editor.SceneEditing.SelectionChanged += OnSelectionChanged;

            Selected += OnSelected;

            _modes = new Tabs
            {
                Orientation  = Orientation.Vertical,
                UseScroll    = true,
                Offsets      = Margin.Zero,
                AnchorPreset = AnchorPresets.StretchAll,
                TabsSize     = new Vector2(50, 32),
                Parent       = this
            };

            // Init tool modes
            InitSculptMode();
            InitPaintMode();
            InitEditMode();

            _modes.SelectedTabIndex = 0;

            _noTerrainPanel = new ContainerControl
            {
                AnchorPreset    = AnchorPresets.StretchAll,
                Offsets         = Margin.Zero,
                BackgroundColor = Style.Current.Background,
                Parent          = this
            };
            var noTerrainLabel = new Label
            {
                Text         = "Select terrain to edit\nor\n\n\n\n",
                AnchorPreset = AnchorPresets.StretchAll,
                Offsets      = Margin.Zero,
                Parent       = _noTerrainPanel
            };

            _createTerrainButton = new Button
            {
                Text         = "Create new terrain",
                AnchorPreset = AnchorPresets.MiddleCenter,
                Offsets      = new Margin(-60, 120, -12, 24),
                Parent       = _noTerrainPanel,
                Enabled      = false
            };
            _createTerrainButton.Clicked += OnCreateNewTerrainClicked;
        }
Esempio n. 10
0
        public void Draw(string text, SharpDX.Color color, params Rectangle[] positions)
        {
            if (!IsDrawing)
            {
                Core.EndAllDrawing(Core.RenderingType.Sprite);
                SpriteHandle.Begin();
                IsDrawing = true;
            }

            // Draw the text
            foreach (var pos in positions)
            {
                TextHandle.DrawText(SpriteHandle, text, pos, DrawFlags, new ColorBGRA(color.R, color.G, color.B, color.A));
            }
        }
Esempio n. 11
0
        public void Draw()
        {
            if (FullCrop)
            {
                return;
            }

            if (!IsDrawing)
            {
                Core.EndAllDrawing(Core.RenderingType.Sprite);
                SpriteHandle.Begin();
                IsDrawing = true;
            }

            // Draw the text
            TextHandle.DrawText(SpriteHandle, DisplayedText, PositionRectangle, DrawFlags, _color);
        }
Esempio n. 12
0
    public bool Button(Vec2 position, Vec2 size, string text, SpriteHandle spriteHandle, bool scaleToFit = false)
    {
        var sprites = spriteHandle.SpriteDef?.SpriteSheetName != null?
                      Resources.LoadAll(spriteHandle.SpriteDef.SpriteSheetName) : Array.Empty <UnityEngine.Object>();

        var sprite  = sprites.Length > 0 ? (Sprite)sprites[spriteHandle.SpriteDef.X + spriteHandle.SpriteDef.Y * 16] : null;
        var posRect = new Rect(new Vector2(position.X, position.Y), new Vector2(size.X, size.Y));
        var pressed = GUI.Button(posRect, new GUIContent()
        {
            text = text
        });

        if (sprite != null)
        {
            GUI.DrawTextureWithTexCoords(posRect, sprite.texture, sprite.rect);
        }
        return(pressed);
    }
Esempio n. 13
0
        /// <summary>
        /// Releases the thumbnail ans frees the sprite slot used by it.
        /// </summary>
        /// <param name="sprite">The sprite.</param>
        public void ReleaseThumbnail(SpriteHandle sprite)
        {
            if (!sprite.IsValid)
            {
                return;
            }

            for (var i = 0; i < _atlases.Count; i++)
            {
                var atlas = _atlases[i];
                if (atlas.Texture == sprite.Atlas)
                {
                    atlas.Count--;
                    atlas.SlotsUsage[sprite.Index] = false;

                    _atlases[i] = atlas;
                    break;
                }
            }
        }
Esempio n. 14
0
    public void SpriteGUI(SpriteHandle handle)
    {
        if (!DrawUI)
        {
            return;
        }
        GL.PushMatrix();
        GL.LoadIdentity();
        var position = handle.Position;
        var size     = handle.Size;
        var color    = (Color) new Color32(handle.Color.R, handle.Color.G, handle.Color.B, handle.Color.A);

        //var fillColor = (Color)new Color32(handle.FillColor.R, handle.FillColor.G, handle.FillColor.B, handle.FillColor.A);
        // Optimization hint:
        // Consider Graphics.DrawMeshNow
        //DrawRect(position, size, fillColor);
        DrawRect(position, Vec2.New(size.X, 1), color);
        DrawRect(position + Vec2.New(0, size.Y), Vec2.New(size.X, 1), color);
        DrawRect(position, Vec2.New(1, size.Y), color);
        DrawRect(position + Vec2.New(size.X, 0), Vec2.New(1, size.Y), color);
        GL.PopMatrix();
    }
Esempio n. 15
0
        public static Vector2 GetOriginOffset(float width, float height, SpriteHandle handle)
        {
            Vector2 Origin = Vector2.Zero;

            switch (handle)
            {
            case SpriteHandle.TOPLEFT:
                Origin = Vector2.Zero;
                break;

            case SpriteHandle.CENTER:
                Origin.X += width / 2.0f;
                Origin.Y += height / 2.0f;
                break;

            case SpriteHandle.CENTERLEFT:
                Origin.Y += height / 2.0f;
                break;

            case SpriteHandle.CENTERRIGHT:
                Origin.X += width;
                Origin.Y += height / 2.0f;
                break;

            case SpriteHandle.BOTTOMCENTER:
                Origin.X += width / 2.0f;
                Origin.Y += height;
                break;

            case SpriteHandle.TOPCENTER:
                Origin.X += width / 2.0f;
                break;
            }

            return(Origin);
        }
Esempio n. 16
0
 public SearchResultTreeNode(SpriteHandle icon)
     : base(false, icon, icon)
 {
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonAssetItem"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="typeName">Name of the resource type.</param>
 /// <param name="thumbnail">Asset icon.</param>
 public JsonAssetItem(string path, Guid id, string typeName, SpriteHandle thumbnail)
     : base(path, typeName, ref id)
 {
     _thumbnail = thumbnail;
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpriteBrush"/> struct.
 /// </summary>
 /// <param name="sprite">The sprite.</param>
 public SpriteBrush(SpriteHandle sprite)
 {
     Sprite = sprite;
 }
Esempio n. 19
0
 public SpriteEntry(SpriteAtlas atlas, int index)
 {
     Sprite = new SpriteHandle(atlas, index);
 }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomSettingsProxy"/> class.
 /// </summary>
 /// <param name="type">The settings asset type (must be subclass of SettingsBase type).</param>
 /// <param name="name">The name of the entry in the custom settings (via <see cref="Engine.GetCustomSettings"/>).</param>
 /// <param name="thumbnail">Asset icon.</param>
 public CustomSettingsProxy(Type type, string name, SpriteHandle thumbnail)
     : base(type, thumbnail)
 {
     CustomName = name;
 }
Esempio n. 21
0
        private void OnEnd(RenderTask task, GPUContext context)
        {
            // Pick the atlas or create a new one
            int atlasIndex = -1;

            for (int i = 0; i < _atlases.Count; i++)
            {
                if (!_atlases[i].IsFull)
                {
                    atlasIndex = i;
                    break;
                }
            }
            if (atlasIndex == -1)
            {
                // Setup configuration
                var atlasSize   = 1024;
                var atlasFormat = PixelFormat.R8G8B8A8_UNorm;
                var width       = (float)Width;
                var height      = (float)Height;
                var countX      = Mathf.FloorToInt(atlasSize / width);
                var countY      = Mathf.FloorToInt(atlasSize / height);
                var count       = countX * countY;

                // Create sprite atlas texture
                var spriteAtlas = FlaxEngine.Content.CreateVirtualAsset <SpriteAtlas>();
                var data        = new byte[atlasSize * atlasSize * PixelFormatExtensions.SizeInBytes(atlasFormat)];
                var initData    = new TextureBase.InitData
                {
                    Width     = atlasSize,
                    Height    = atlasSize,
                    ArraySize = 1,
                    Format    = atlasFormat,
                    Mips      = new[]
                    {
                        new TextureBase.InitData.MipData
                        {
                            Data       = data,
                            RowPitch   = data.Length / atlasSize,
                            SlicePitch = data.Length
                        },
                    },
                };
                spriteAtlas.Init(ref initData);

                // Setup sprite atlas slots (each per thumbnail)
                var thumbnailSizeUV = new Vector2(width / atlasSize, height / atlasSize);
                for (int i = 0; i < count; i++)
                {
                    var x = i % countX;
                    var y = i / countX;
                    var s = new Sprite
                    {
                        Name = string.Empty,
                        Area = new Rectangle(new Vector2(x, y) * thumbnailSizeUV, thumbnailSizeUV),
                    };
                    spriteAtlas.AddSprite(s);
                }

                // Add atlas to the cached ones
                atlasIndex = _atlases.Count;
                _atlases.Add(new Atlas
                {
                    Texture    = spriteAtlas,
                    SlotsUsage = new BitArray(count, false),
                    Count      = 0,
                });
            }

            // Skip ending if the atlas is not loaded yet (streaming backend uploads texture to GPU or sth)
            var atlas = _atlases[atlasIndex];

            if (atlas.Texture.ResidentMipLevels == 0)
            {
                return;
            }

            // Pick the sprite slot from the atlas
            var spriteIndex = -1;

            for (int i = 0; i < atlas.SlotsUsage.Count; i++)
            {
                if (atlas.SlotsUsage[i] == false)
                {
                    atlas.SlotsUsage[i] = true;
                    spriteIndex         = i;
                    break;
                }
            }
            if (spriteIndex == -1)
            {
                throw new FlaxException();
            }
            atlas.Count++;
            _atlases[atlasIndex] = atlas;
            var sprite = new SpriteHandle(atlas.Texture, spriteIndex);

            // Copy output frame to the sprite atlas slot
            var spriteLocation = sprite.Location;

            context.CopyTexture(atlas.Texture.Texture, 0, (uint)spriteLocation.X, (uint)spriteLocation.Y, 0, _output, 0);

            // Link sprite to the UI
            var req = _queue[0];

            req.Media.OnThumbnailRenderingEnd((SceneRenderTask)task, context, ref req, ref sprite);

            // End
            _queue.RemoveAt(0);
            task.Enabled = false;
        }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsProxy"/> class.
 /// </summary>
 /// <param name="type">The settings asset type (must be subclass of SettingsBase type).</param>
 /// <param name="thumbnail">Asset icon.</param>
 public SettingsProxy(Type type, SpriteHandle thumbnail)
 {
     _type      = type;
     TypeName   = type.FullName;
     _thumbnail = thumbnail;
 }
Esempio n. 23
0
        /// <summary>
        /// Called when thumbnail rendering ends. The task output buffer contains ready frame.
        /// </summary>
        /// <param name="task">The scene rendering task to customize.</param>
        /// <param name="context">The GPU rendering context.</param>
        /// <param name="req">The request data.</param>
        /// <param name="sprite">The thumbnail sprite.</param>
        public void OnThumbnailRenderingEnd(SceneRenderTask task, GPUContext context, ref CameraCutThumbnailRenderer.Request req, ref SpriteHandle sprite)
        {
            var image = _thumbnails[req.ThumbnailIndex];

            if (image == null)
            {
                if (req.ThumbnailIndex == 0)
                {
                    image = new Image
                    {
                        AnchorPreset = AnchorPresets.MiddleLeft,
                        Parent       = this,
                        Bounds       = new Rectangle(2, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
                    };
                }
                else if (req.ThumbnailIndex == 1)
                {
                    image = new Image
                    {
                        AnchorPreset = AnchorPresets.MiddleRight,
                        Parent       = this,
                        Bounds       = new Rectangle(Width - 2 - CameraCutThumbnailRenderer.Width, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
                    };
                }
                else
                {
                    image = new Image
                    {
                        AnchorPreset = AnchorPresets.MiddleCenter,
                        Parent       = this,
                        Bounds       = new Rectangle(Width * 0.5f - 1 - CameraCutThumbnailRenderer.Width * 0.5f, 2, CameraCutThumbnailRenderer.Width, CameraCutThumbnailRenderer.Height),
                    };
                }
                image.UnlockChildrenRecursive();
                _thumbnails[req.ThumbnailIndex] = image;
                UpdateUI();
            }
            else if (image.Brush != null)
            {
                Timeline.CameraCutThumbnailRenderer.ReleaseThumbnail(((SpriteBrush)image.Brush).Sprite);
                image.Brush = null;
            }

            image.Brush = new SpriteBrush(sprite);
        }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tab"/> class.
 /// </summary>
 /// <param name="icon">The icon.</param>
 public Tab(SpriteHandle icon)
     : this(string.Empty, icon)
 {
 }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tab"/> class.
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="icon">The icon.</param>
 public Tab(string text, SpriteHandle icon)
 {
     Text = text;
     Icon = icon;
 }
Esempio n. 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonAssetItem"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="typeName">Name of the resource type.</param>
 public JsonAssetItem(string path, Guid id, string typeName)
     : base(path, typeName, ref id)
 {
     _thumbnail = Editor.Instance.Icons.Json128;
 }
Esempio n. 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpawnTab"/> class.
        /// </summary>
        /// <param name="icon">The icon.</param>
        /// <param name="editor">The editor instance.</param>
        public SpawnTab(SpriteHandle icon, Editor editor)
            : base(string.Empty, icon)
        {
            Editor    = editor;
            Selected += tab => Editor.Windows.EditWin.Viewport.SetActiveMode <TransformGizmoMode>();
            ScriptsBuilder.ScriptsReload += OnScriptsReload;

            var actorGroups = new Tabs
            {
                Orientation  = Orientation.Vertical,
                UseScroll    = true,
                AnchorPreset = AnchorPresets.StretchAll,
                Offsets      = Margin.Zero,
                TabsSize     = new Vector2(120, 32),
                Parent       = this,
            };

            _groupSearch = CreateGroupWithList(actorGroups, "Search", 26);
            _searchBox   = new TextBox
            {
                AnchorPreset  = AnchorPresets.HorizontalStretchTop,
                WatermarkText = "Search...",
                Parent        = _groupSearch.Parent.Parent,
                Bounds        = new Rectangle(4, 4, actorGroups.Width - 8, 18),
            };
            _searchBox.TextChanged += OnSearchBoxTextChanged;

            var groupBasicModels = CreateGroupWithList(actorGroups, "Basic Models");

            groupBasicModels.AddChild(CreateEditorAssetItem("Cube", "Primitives/Cube.flax"));
            groupBasicModels.AddChild(CreateEditorAssetItem("Sphere", "Primitives/Sphere.flax"));
            groupBasicModels.AddChild(CreateEditorAssetItem("Plane", "Primitives/Plane.flax"));
            groupBasicModels.AddChild(CreateEditorAssetItem("Cylinder", "Primitives/Cylinder.flax"));
            groupBasicModels.AddChild(CreateEditorAssetItem("Cone", "Primitives/Cone.flax"));
            groupBasicModels.AddChild(CreateEditorAssetItem("Capsule", "Primitives/Capsule.flax"));

            var groupLights = CreateGroupWithList(actorGroups, "Lights");

            groupLights.AddChild(CreateActorItem("Directional Light", typeof(DirectionalLight)));
            groupLights.AddChild(CreateActorItem("Point Light", typeof(PointLight)));
            groupLights.AddChild(CreateActorItem("Spot Light", typeof(SpotLight)));
            groupLights.AddChild(CreateActorItem("Sky Light", typeof(SkyLight)));

            var groupVisuals = CreateGroupWithList(actorGroups, "Visuals");

            groupVisuals.AddChild(CreateActorItem("Camera", typeof(Camera)));
            groupVisuals.AddChild(CreateActorItem("Environment Probe", typeof(EnvironmentProbe)));
            groupVisuals.AddChild(CreateActorItem("Skybox", typeof(Skybox)));
            groupVisuals.AddChild(CreateActorItem("Sky", typeof(Sky)));
            groupVisuals.AddChild(CreateActorItem("Exponential Height Fog", typeof(ExponentialHeightFog)));
            groupVisuals.AddChild(CreateActorItem("PostFx Volume", typeof(PostFxVolume)));
            groupVisuals.AddChild(CreateActorItem("Decal", typeof(Decal)));
            groupVisuals.AddChild(CreateActorItem("Particle Effect", typeof(ParticleEffect)));

            var groupPhysics = CreateGroupWithList(actorGroups, "Physics");

            groupPhysics.AddChild(CreateActorItem("Rigid Body", typeof(RigidBody)));
            groupPhysics.AddChild(CreateActorItem("Character Controller", typeof(CharacterController)));
            groupPhysics.AddChild(CreateActorItem("Box Collider", typeof(BoxCollider)));
            groupPhysics.AddChild(CreateActorItem("Sphere Collider", typeof(SphereCollider)));
            groupPhysics.AddChild(CreateActorItem("Capsule Collider", typeof(CapsuleCollider)));
            groupPhysics.AddChild(CreateActorItem("Mesh Collider", typeof(MeshCollider)));
            groupPhysics.AddChild(CreateActorItem("Fixed Joint", typeof(FixedJoint)));
            groupPhysics.AddChild(CreateActorItem("Distance Joint", typeof(DistanceJoint)));
            groupPhysics.AddChild(CreateActorItem("Slider Joint", typeof(SliderJoint)));
            groupPhysics.AddChild(CreateActorItem("Spherical Joint", typeof(SphericalJoint)));
            groupPhysics.AddChild(CreateActorItem("Hinge Joint", typeof(HingeJoint)));
            groupPhysics.AddChild(CreateActorItem("D6 Joint", typeof(D6Joint)));

            var groupOther = CreateGroupWithList(actorGroups, "Other");

            groupOther.AddChild(CreateActorItem("Animated Model", typeof(AnimatedModel)));
            groupOther.AddChild(CreateActorItem("Bone Socket", typeof(BoneSocket)));
            groupOther.AddChild(CreateActorItem("CSG Box Brush", typeof(BoxBrush)));
            groupOther.AddChild(CreateActorItem("Audio Source", typeof(AudioSource)));
            groupOther.AddChild(CreateActorItem("Audio Listener", typeof(AudioListener)));
            groupOther.AddChild(CreateActorItem("Empty Actor", typeof(EmptyActor)));
            groupOther.AddChild(CreateActorItem("Scene Animation", typeof(SceneAnimationPlayer)));
            groupOther.AddChild(CreateActorItem("Nav Mesh Bounds Volume", typeof(NavMeshBoundsVolume)));
            groupOther.AddChild(CreateActorItem("Nav Link", typeof(NavLink)));
            groupOther.AddChild(CreateActorItem("Nav Modifier Volume", typeof(NavModifierVolume)));
            groupOther.AddChild(CreateActorItem("Spline", typeof(Spline)));

            var groupGui = CreateGroupWithList(actorGroups, "GUI");

            groupGui.AddChild(CreateActorItem("UI Control", typeof(UIControl)));
            groupGui.AddChild(CreateActorItem("UI Canvas", typeof(UICanvas)));
            groupGui.AddChild(CreateActorItem("Text Render", typeof(TextRender)));
            groupGui.AddChild(CreateActorItem("Sprite Render", typeof(SpriteRender)));

            actorGroups.SelectedTabIndex = 1;
        }
Esempio n. 28
0
        private void OnRender(RenderTask task, GPUContext context)
        {
            lock (_requests)
            {
                // Check if there is ready next asset to render thumbnail for it
                // But don't check whole queue, only a few items
                var request = GetReadyRequest(10);
                if (request == null)
                {
                    // Disable task
                    _task.Enabled = false;
                    return;
                }

                // Find atlas with an free slot
                var atlas = GetValidAtlas();
                if (atlas == null)
                {
                    // Error
                    _task.Enabled = false;
                    _requests.Clear();
                    Editor.LogError("Failed to get atlas.");
                    return;
                }

                // Wait for atlas being loaded
                if (!atlas.IsReady)
                {
                    return;
                }

                // Setup
                _guiRoot.RemoveChildren();
                _guiRoot.AccentColor = request.Proxy.AccentColor;

                // Call proxy to prepare for thumbnail rendering
                request.Proxy.OnThumbnailDrawBegin(request, _guiRoot, context);
                _guiRoot.UnlockChildrenRecursive();

                // Draw preview
                context.Clear(_output.View(), Color.Black);
                Render2D.CallDrawing(_guiRoot, context, _output);

                // Call proxy and cleanup UI (delete create controls, shared controls should be unlinked during OnThumbnailDrawEnd event)
                request.Proxy.OnThumbnailDrawEnd(request, _guiRoot);
                _guiRoot.DisposeChildren();

                // Copy backbuffer with rendered preview into atlas
                SpriteHandle icon = atlas.OccupySlot(_output, request.Item.ID);
                if (!icon.IsValid)
                {
                    // Error
                    _task.Enabled = false;
                    _requests.Clear();
                    Editor.LogError("Failed to occupy previews cache atlas slot.");
                    return;
                }

                // End
                request.FinishRender(ref icon);
                RemoveRequest(request);
            }
        }
Esempio n. 29
0
 public PlatformData(PlatformType type, SpriteHandle icon, string name)
 {
     PlatformType = type;
     Icon         = icon;
     PlatformName = name;
 }
Esempio n. 30
0
        public static Vector2 GetOriginOffset(float width, float height, SpriteHandle handle)
        {
            Vector2 Origin = Vector2.Zero;
            switch (handle)
            {
                case SpriteHandle.TOPLEFT:
                    Origin = Vector2.Zero;
                    break;
                case SpriteHandle.CENTER:
                    Origin.X += width / 2.0f;
                    Origin.Y += height / 2.0f;
                    break;
                case SpriteHandle.CENTERLEFT:
                    Origin.Y += height / 2.0f;
                    break;
                case SpriteHandle.CENTERRIGHT:
                    Origin.X += width;
                    Origin.Y += height / 2.0f;
                    break;
                case SpriteHandle.BOTTOMCENTER:
                    Origin.X += width / 2.0f;
                    Origin.Y += height;
                    break;
                case SpriteHandle.TOPCENTER:
                    Origin.X += width / 2.0f;
                    break;
            }

            return Origin;
        }
 public Node(VisualScript script, uint nodeId, SpriteHandle iconCollapsed, SpriteHandle iconOpened)
     : base(false, iconCollapsed, iconOpened)
 {
     Tag = new NodeInfo(script, nodeId);
 }
Esempio n. 32
0
 // todo: fix if broken
 public Vector2 GetPositionAtHandle(SpriteHandle handle)
 {
     return Position + GetOriginOffset(Width, Height, handle);
 }