コード例 #1
0
        public static void Render(Area Area)
        {
            CheatWindow.Render();
            AreaDebug.Render(Area);
            DebugWindow.Render();

            imgui.LocaleEditor.Render();
            debug.PoolEditor.Render();
            state.ItemEditor.Render();
            RenderSettings();
            Lights.RenderDebug();
            SaveDebug.RenderDebug();
            LevelLayerDebug.Render();
            LootTableEditor.Render();
            assets.achievements.Achievements.RenderDebug();

            RunStatistics.RenderDebug();

            if (Rooms && ImGui.Begin("Rooms", ImGuiWindowFlags.AlwaysAutoResize))
            {
                var p = LocalPlayer.Locate(Area);

                if (p != null)
                {
                    var rm = p.GetComponent <RoomComponent>().Room;
                    var rn = new List <Room>();

                    foreach (var r in Area.Tagged[Tags.Room])
                    {
                        rn.Add((Room)r);
                    }

                    rn.Sort((a, b) => a.Type.CompareTo(b.Type));

                    foreach (var r in rn)
                    {
                        var v = rm == r;

                        if (ImGui.Selectable($"{r.Type}#{r.Y}", ref v) && v)
                        {
                            p.Center = r.Center;
                        }
                    }
                }

                ImGui.End();
            }

            ImGui.SetNextWindowPos(new Vector2(Engine.Instance.GetScreenWidth() - size.X - 10, Engine.Instance.GetScreenHeight() - size.Y - 10));
            ImGui.Begin("Windows", ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar);

            if (ImGui.Button("Hide"))
            {
                Debug = Entities = RunInfo = Console = ItemEditor = LevelEditor = LocaleEditor = Rooms = Settings = PoolEditor = LootTable = false;
            }

            ImGui.SameLine();

            if (ImGui.Button("Show"))
            {
                Debug = Entities = RunInfo = Console = ItemEditor = LevelEditor = LocaleEditor = Rooms = Settings = PoolEditor = LootTable = true;
            }

            ImGui.Separator();

            ImGui.Checkbox("Cheats", ref Cheats);
            ImGui.Checkbox("Entities", ref Entities);
            ImGui.Checkbox("Run Info", ref RunInfo);
            ImGui.Checkbox("Console", ref Console);
            ImGui.Checkbox("Item Editor", ref ItemEditor);
            ImGui.Checkbox("Level Editor", ref LevelEditor);
            ImGui.Checkbox("Layer Debug", ref LayerDebug);
            ImGui.Checkbox("Locale Editor", ref LocaleEditor);
            ImGui.Checkbox("Debug", ref Debug);
            ImGui.Checkbox("Rooms", ref Rooms);
            ImGui.Checkbox("Settings", ref Settings);
            ImGui.Checkbox("Lighting", ref Lighting);
            ImGui.Checkbox("Achievements", ref Achievements);
            ImGui.Checkbox("Save", ref Save);
            ImGui.Checkbox("Pool Editor", ref PoolEditor);
            ImGui.Checkbox("Loot Table Editor", ref LootTable);

            size = ImGui.GetWindowSize();
            ImGui.End();
        }
コード例 #2
0
        public static void Render()
        {
            ImGui.SetNextWindowSize(size, ImGuiCond.Once);

            if (!ImGui.Begin("Entity placer"))
            {
                ImGui.End();
                open = false;
                return;
            }

            open = true;

            var down    = !ImGui.GetIO().WantCaptureMouse&& Input.Mouse.CheckLeftButton;
            var clicked = !ImGui.GetIO().WantCaptureMouse&& MouseData.HadClick;

            if (Input.Keyboard.IsDown(Keys.LeftControl, true))
            {
                if (entity != null)
                {
                    if (Input.Keyboard.WasPressed(Keys.C, true))
                    {
                        copy = entity.GetType();
                    }

                    if (copy != null && Input.Keyboard.WasPressed(Keys.V, true))
                    {
                        var od = currentType;
                        currentType = copy;
                        CreateEntity(false);
                        currentType = od;
                    }

                    if (Input.Keyboard.WasPressed(Keys.D, true))
                    {
                        entity.Done = true;
                        entity      = null;
                    }
                }
            }

            ImGui.Checkbox("Move", ref move);            /*) {
                                                          * if (entityMode != 0) {
                                                          * RemoveEntity();
                                                          * }
                                                          * }*/

            if (!move && entity != null)
            {
                var mouse = Input.Mouse.GamePosition;

                if (SnapToGrid)
                {
                    mouse.X = (float)Math.Floor(mouse.X / 16) * 16;
                    mouse.Y = (float)Math.Floor(mouse.Y / 16) * 16;
                }

                mouse += new Vector2(8 - entity.Width / 2f, 8 - entity.Height / 2f);

                if (Center)
                {
                    entity.Center = mouse;
                }
                else
                {
                    entity.Position = mouse;
                }

                if (clicked)
                {
                    CreateEntity(false);
                }
            }
            else if (move)
            {
                var    mouse    = Input.Mouse.GamePosition;
                Entity selected = null;

                foreach (var e in Editor.Area.Entities.Entities)
                {
                    if (e.OnScreen && AreaDebug.PassFilter(e) && !(e is Firefly || e is WindFx || e is Lock))
                    {
                        if (e.Contains(mouse))
                        {
                            selected = e;
                        }
                    }
                }

                HoveredEntity = selected;

                if (clicked)
                {
                    entity = selected;

                    if (selected != null)
                    {
                        AreaDebug.ToFocus = entity;
                        offset            = entity.Position - mouse;
                    }
                }
                else if (entity != null && (down && entity.Contains(mouse) || Input.Keyboard.IsDown(Keys.LeftAlt, true)))
                {
                    mouse += offset;

                    if (SnapToGrid)
                    {
                        mouse.X = (float)Math.Round(mouse.X / 16) * 16;
                        mouse.Y = (float)Math.Round(mouse.Y / 16) * 16;
                    }

                    mouse += new Vector2(8 - entity.Width / 2f, 8 - entity.Height / 2f);

                    if (Center)
                    {
                        entity.Center = mouse;
                    }
                    else
                    {
                        entity.Position = mouse;
                    }
                }
            }

            ImGui.Checkbox("Snap to grid", ref SnapToGrid);
            ImGui.SameLine();
            ImGui.Checkbox("Center", ref Center);

            if (entity != null)
            {
                ImGui.Separator();
                ImGui.Text(entity.GetType().Name);

                if (ImGui.Button("Open debug"))
                {
                    AreaDebug.ToFocus = entity;
                }

                ImGui.Separator();
            }

            filter.Draw("");
            var i = 0;

            ImGui.Separator();
            var h = ImGui.GetStyle().ItemSpacing.Y;

            ImGui.BeginChild("ScrollingRegionConsole", new System.Numerics.Vector2(0, -h),
                             false, ImGuiWindowFlags.HorizontalScrollbar);

            foreach (var t in Types)
            {
                if (filter.PassFilter(t.Name))
                {
                    if (ImGui.Selectable(t.Name, selected == i))
                    {
                        selected = i;

                        currentType = t.Type;
                        CreateEntity();
                    }
                }

                i++;
            }

            ImGui.EndChild();
            ImGui.End();
        }