Exemple #1
0
        public override void Render <TSurface, TSource>(ScreenRenderer <TSurface, TSource> r)
        {
            if (!ModalVisible)
            {
                return;
            }
            SelectedIndex = Math.Max(-1, Math.Min(SelectedIndex, Owner.Entities.Count - 1));
            StartOffset   = Math.Max(-1, Math.Min(StartOffset, Owner.Entities.Count - 1));
            var layer = r.GetLayerGraphics("hi_res_overlay");

            int y = 14;
            int x = EditorRendering.SidebarX + EditorRendering.SidebarMargin + 4;

            List <Entity> entities = Owner.Entities.ToList();
            int           index    = StartOffset;

            for (; index < entities.Count; index++)
            {
                if (index == -1)
                {
                    GUIButton button = new GUIButton(new Vector2D(x - 4 + EditorRendering.SidebarMargin, y), "Add Entity", new EntityComponentSystem.Util.Rectangle(0, 0, EditorRendering.SidebarWidth - 4 * EditorRendering.SidebarMargin, 24))
                    {
                        TextSize = 2
                    };
                    button.Highlighted = SelectedIndex == -1;
                    button.Render(r, layer, Vector2D.Empty);

                    y += 24 + 8;
                }
                else
                {
                    Entity entity = entities[index];
                    if (index == SelectedIndex)
                    {
                        layer.FillRect(new System.Drawing.Rectangle(x - 4, y, EditorRendering.SidebarWidth - 2 * EditorRendering.SidebarMargin, 20), ModalActive ? Color.CornflowerBlue : Color.FromArgb(63, 63, 70));
                    }
                    TextUnit label = new TextUnit(entity.Name);
                    label.Render <TSurface, TSource>(r, layer, new Point(x, y + 2), 2);
                    y += 20;
                    if (y > 720 - 16)
                    {
                        break;
                    }
                }
            }
            AmountVisible = index - StartOffset - 1;

            if (RemoveTimer > 0 && SelectedIndex >= 0)
            {
                TextUnit            removingLabel = new TextUnit("Removing " + entities[SelectedIndex].Name + new string('.', RemoveTimer / 25));
                System.Drawing.Size labelSize     = removingLabel.GetSize(3);
                removingLabel.Render(r, layer, new Point(EditorRendering.SidebarX - labelSize.Width, layer.GetSize().Height - labelSize.Height), 3);
            }
        }
Exemple #2
0
            public override ICollection <GUIObject> Render()
            {
                var ret = new List <GUIObject>(VisibleElementCount + 6)
                {
                    _wrap, _listWrap
                };

                ret.AddRange(_nextButton.Render());
                ret.AddRange(_prevButton.Render());
                ret.AddRange(_list);

                return(ret);
            }
Exemple #3
0
            public override ICollection <GUIObject> Render()
            {
                var items = new List <GUIObject>()
                {
                    _window, _titleElement
                };

                items.AddRange(_closeButton.Render());
                items.Add(_bodyElement);

                if (_body != null)
                {
                    items.AddRange(_body.Render());
                }

                return(items);
            }
Exemple #4
0
        public override void Render <TSurface, TSource>(ScreenRenderer <TSurface, TSource> r)
        {
            if (!ModalVisible)
            {
                return;
            }

            var layer = r.GetLayerGraphics("hi_res_overlay");

            System.Drawing.Rectangle sidebar = new System.Drawing.Rectangle(EditorRendering.SidebarX, 0, EditorRendering.SidebarWidth, 720);

            layer.FillRect(sidebar, Color.FromArgb(45, 45, 48));
            layer.FillRect(new System.Drawing.Rectangle(sidebar.X + EditorRendering.SidebarMargin, sidebar.Y + EditorRendering.SidebarMargin, sidebar.Width - 2 * EditorRendering.SidebarMargin, sidebar.Height - 2 * EditorRendering.SidebarMargin), Color.FromArgb(37, 37, 38));

            int x = EditorRendering.SidebarX + 2 * EditorRendering.SidebarMargin;
            int y = EditorRendering.SidebarMargin + 4;

            new TextUnit(EntityViewSystem.ObjectIcon, "Edit sprite animations", Color.White).Render(r, layer, new Point(x, y), 2);
            y += 20;

            layer.FillRect(new System.Drawing.Rectangle(x - 2 * EditorRendering.SidebarMargin, y, EditorRendering.SidebarWidth - 2 * EditorRendering.SidebarMargin, 3), Color.FromArgb(45, 45, 48));
            y += 8;

            AnimationRenderOffsets.Clear();

            int startY = 0;

            int index = 0;

            foreach (ObjectSummary animation in Animations.Select(a => new ObjectSummary(Owner, a)))
            {
                AnimationRenderOffsets.Add(y);

                bool doRender = index >= ListFromIndex;
                if (index == ListFromIndex)
                {
                    startY = y;
                    y      = 2 * EditorRendering.SidebarMargin + 20 + 22 + 20 + 8;
                }

                if (index == SelectedAnimationIndex && doRender)
                {
                    layer.FillRect(new System.Drawing.Rectangle(x - 4, y - 2, EditorRendering.SidebarWidth - 2 * EditorRendering.SidebarMargin, 20), ComponentLocked ? Color.FromArgb(63, 63, 70) : Color.CornflowerBlue);
                }
                if (doRender)
                {
                    new TextUnit(
                        //new Sprite("editor", new Rectangle(0, 0, 16, 16), new Rectangle(0, 32, 16, 16)),
                        "Animation " + (index + 1))
                    .Render(r, layer, new Point(x, y), 2);
                }
                y += 24;

                int memberIndex = 0;
                foreach (IMemberSummary member in animation.Members.Values)
                {
                    if (doRender)
                    {
                        TextUnit label = member.Label;
                        label.Color = ComponentLocked && SelectedAnimationIndex == index ? (memberIndex == SelectedPropertyIndex ? Color.CornflowerBlue : Color.White) : Color.Gray;
                        label.Render(r, layer, new Point(x + 8, y), 1);
                    }
                    y += 16;
                    memberIndex++;
                }

                y += 16;

                index++;
            }

            {
                AnimationRenderOffsets.Add(y);
                GUIButton button = new GUIButton(new Vector2D(x, y), "Add Animation", new Rectangle(0, 0, EditorRendering.SidebarWidth - 4 * EditorRendering.SidebarMargin, 24))
                {
                    TextSize = 2
                };
                button.Highlighted = SelectedAnimationIndex == Animations.Count;
                button.Render(r, layer, Vector2D.Empty);

                for (int i = 0; i < ListFromIndex; i++)
                {
                    AnimationRenderOffsets[i] -= startY;
                }
                index++;
                y += 32;
            }


            if (RemoveTimer > 0 && SelectedAnimationIndex >= 0 && SelectedAnimationIndex < Animations.Count)
            {
                TextUnit            removingLabel = new TextUnit("Removing Animation " + (SelectedAnimationIndex + 1) + new string('.', RemoveTimer / 25));
                System.Drawing.Size labelSize     = removingLabel.GetSize(3);
                removingLabel.Render(r, layer, new Point(EditorRendering.SidebarX - labelSize.Width, layer.GetSize().Height - labelSize.Height), 3);
            }
        }
Exemple #5
0
        public override void Render <TSurface, TSource>(ScreenRenderer <TSurface, TSource> r)
        {
            if (!ModalVisible)
            {
                return;
            }
            if (!Owner.Entities.ContainsId(Selected))
            {
                return;
            }

            var layer = r.GetLayerGraphics("hi_res_overlay");

            Entity entity = Owner.Entities[Selected];

            int x = EditorRendering.SidebarX + 2 * EditorRendering.SidebarMargin;
            int y = EditorRendering.SidebarMargin + 4;

            new TextUnit(ObjectIcon, entity.Name, SelectedComponentIndex == -2 ? Color.CornflowerBlue : Color.White).Render(r, layer, new Point(x, y), 2);
            y += 20;
            new TextUnit("ID: " + Selected, Color.DarkGray).Render(r, layer, new Point(x, y), 1);
            y += 22;

            if (SelectedComponentIndex == -1)
            {
                layer.FillRect(new System.Drawing.Rectangle(x - 4, y - 2, EditorRendering.SidebarWidth - 2 * EditorRendering.SidebarMargin, 20), Color.CornflowerBlue);
            }
            SetCheckboxChecked(entity.Active);
            new TextUnit(CheckboxIcon, "Active").Render(r, layer, new Point(x, y), 2);

            y += 20;

            layer.FillRect(new System.Drawing.Rectangle(x - 2 * EditorRendering.SidebarMargin, y, EditorRendering.SidebarWidth - 2 * EditorRendering.SidebarMargin, 3), Color.FromArgb(45, 45, 48));
            y += 8;

            ComponentRenderOffsets.Clear();

            int startY = 0;

            int index = 0;

            foreach (ComponentSummary component in Helper.Components.Values)
            {
                ComponentRenderOffsets.Add(y);

                bool doRender = index >= ListFromIndex;
                if (index == ListFromIndex)
                {
                    startY = y;
                    y      = 2 * EditorRendering.SidebarMargin + 20 + 22 + 20 + 8;
                }

                if (index == SelectedComponentIndex && doRender)
                {
                    layer.FillRect(new System.Drawing.Rectangle(x - 4, y - 2, EditorRendering.SidebarWidth - 2 * EditorRendering.SidebarMargin, 20), ComponentLocked ? Color.FromArgb(63, 63, 70) : Color.CornflowerBlue);
                }
                if (doRender)
                {
                    new TextUnit(
                        //new Sprite("editor", new Rectangle(0, 0, 16, 16), new Rectangle(0, 32, 16, 16)),
                        component.ComponentName)
                    .Render(r, layer, new Point(x, y), 2);
                }
                y += 24;

                int memberIndex = 0;
                foreach (IMemberSummary member in component.Members.Values)
                {
                    if (doRender)
                    {
                        TextUnit label = member.Label;
                        label.Color = ComponentLocked && SelectedComponentIndex == index ? (memberIndex == SelectedPropertyIndex ? Color.CornflowerBlue : Color.White) : Color.Gray;
                        label.Render(r, layer, new Point(x + 8, y), 1);
                    }
                    y += 16;
                    memberIndex++;
                }

                y += 16;

                index++;
            }

            {
                ComponentRenderOffsets.Add(y);
                GUIButton button = new GUIButton(new Vector2D(x, y), "Add Component", new Rectangle(0, 0, EditorRendering.SidebarWidth - 4 * EditorRendering.SidebarMargin, 24))
                {
                    TextSize = 2
                };
                button.Highlighted = SelectedComponentIndex == Helper.Components.Count;
                button.Render(r, layer, Vector2D.Empty);

                for (int i = 0; i < ListFromIndex; i++)
                {
                    ComponentRenderOffsets[i] -= startY;
                }
                index++;
                y += 32;
            }
            {
                ComponentRenderOffsets.Add(y);
                GUIButton button = new GUIButton(new Vector2D(x, y), "Save Prefab", new Rectangle(0, 0, EditorRendering.SidebarWidth - 4 * EditorRendering.SidebarMargin, 24))
                {
                    TextSize = 2
                };
                button.Highlighted = SelectedComponentIndex == Helper.Components.Count + 1;
                button.Render(r, layer, Vector2D.Empty);

                for (int i = 0; i < ListFromIndex; i++)
                {
                    ComponentRenderOffsets[i] -= startY;
                }
                index++;
                y += 32;
            }

            if (RemoveTimer > 0 && SelectedComponentIndex >= 0 && SelectedComponentIndex < Helper.Components.Count)
            {
                TextUnit            removingLabel = new TextUnit("Removing " + Helper.Components.ElementAt(SelectedComponentIndex).Key + new string('.', RemoveTimer / 25));
                System.Drawing.Size labelSize     = removingLabel.GetSize(3);
                removingLabel.Render(r, layer, new Point(EditorRendering.SidebarX - labelSize.Width, layer.GetSize().Height - labelSize.Height), 3);
            }
        }