public override void BuildUI(ImGuiRenderer renderer) { if (GuiState.ShowSurfacePreview) { ImGui.SetNextWindowBgAlpha(1f); ImGui.SetNextWindowSizeConstraints(new Vector2(200, 200), new Vector2(10000, 10000)); if (ImGui.Begin("Surface preview", ref GuiState.ShowSurfacePreview, ImGuiWindowFlags.HorizontalScrollbar)) { // TODO: // Change this to have a list box that presents the render steps // Select render step checks for IRenderTexture // - Display selected texture // Select render step checks if selected is Output // - Display final texture // TODO: // New window that is an editor type for the parent object // Inspect components to see if entity renderer, controls ui, etc, enable different editors. // Add ability to add those components. // Render output texture if (GuiState._selectedScreenObject is IScreenSurface surface) { if (surface.Renderer?.Output is Host.GameTexture gameTexture) { var texture = renderer.BindTexture(gameTexture.Texture); //var drawPointer = ImGui.GetBackgroundDrawList(); //var startPos = ImGui.GetWindowPos(); var textureSize = new Vector2(gameTexture.Width, gameTexture.Height); //drawPointer.AddRectFilled(startPos, startPos + ImGui.GetWindowSize(), ImGui.GetColorU32(new Vector4(0, 0, 0, 1))); ImGui.Image(texture, textureSize, Vector2.Zero, Vector2.One, Vector4.One, Vector4.One); } else { ImGui.Text("Selected object doesn't have a renderer"); } } else { ImGui.Text("Selected object isn't IScreenSurface"); } } ImGui.End(); } }
public ImGuiHost(GraphicsDeviceManager graphics, Microsoft.Xna.Framework.Game game, bool enableDocking) : base(game) { // Run after (and thus draw on top of) the normal SadConsole MonoGame component DrawOrder = 7; // Run before the normal SadConsole MonoGame component UpdateOrder = 3; _graphics = graphics; _game = game; ImGuiRenderer = new ImGuiRenderer(_game); ImGuiRenderer.RebuildFontAtlas(); ImGuiIOPtr io = ImGui.GetIO(); io.ConfigFlags = io.ConfigFlags |= ImGuiConfigFlags.DockingEnable; }
public abstract void BuildUI(ImGuiRenderer renderer);
public override void BuildUI(ImGuiRenderer renderer) { if (_pauseForEdit) { _pauseForEdit = false; System.Diagnostics.Debugger.Break(); } // 1.Show a simple window ImGui.Begin("Screen objects"); { // Screen objects list ImGui.BeginChild("screen_objects", new Vector2(200, 300), true, ImGuiWindowFlags.MenuBar); { if (ImGui.BeginMenuBar()) { ImGui.Text("Screen objects"); ImGui.EndMenuBar(); } //ImGui.LabelText("Items", ""); foreach (ScreenObjectState item in GuiState.ScreenObjectUniques.Values) { item.Found = false; } CreateScreenObject(GameHost.Instance.Screen); foreach (ScreenObjectState item in GuiState.ScreenObjectUniques.Values.ToArray()) { if (!item.Found) { GuiState.ScreenObjectUniques.Remove(item.Object); } } if (GuiState._selectedScreenObject != null && !GuiState.ScreenObjectUniques.ContainsKey(GuiState._selectedScreenObject)) { GuiState._selectedScreenObject = null; GuiState._selectedScreenObjectState = null; } } ImGui.EndChild(); if (GuiState._selectedScreenObjectState != null) { ImGui.SameLine(); ImGui.BeginChild("selected_object_pane", new Vector2(0, 300), false); { /////// // Position X /////// ImGui.TextColored(Color.AnsiCyanBright.ToVector4(), "Position X: "); ImGui.SameLine(); ImGui.SetNextItemWidth(100); if (ImGui.InputInt("##x", ref GuiState._selectedScreenObjectState.PositionX)) { GuiState._selectedScreenObject.Position = GuiState._selectedScreenObject.Position.WithX(GuiState._selectedScreenObjectState.PositionX); GuiState._selectedScreenObjectState.Refresh(); } /////// // Width /////// ImGui.SameLine(); ImGui.TextColored(Color.AnsiCyanBright.ToVector4(), "Width: "); ImGui.SameLine(); ImGui.SetNextItemWidth(80); if (GuiState._selectedScreenObjectState.IsScreenSurface) { ImGui.Text(((IScreenSurface)GuiState._selectedScreenObject).Surface.Width.ToString()); } else { ImGui.Text("??"); } /////// // Position Y /////// ImGui.TextColored(Color.AnsiCyanBright.ToVector4(), "Position Y: "); ImGui.SameLine(); ImGui.SetNextItemWidth(100); if (ImGui.InputInt("##y", ref GuiState._selectedScreenObjectState.PositionY)) { GuiState._selectedScreenObject.Position = GuiState._selectedScreenObject.Position.WithY(GuiState._selectedScreenObjectState.PositionY); GuiState._selectedScreenObjectState.Refresh(); } /////// // Height /////// ImGui.SameLine(); ImGui.TextColored(Color.AnsiCyanBright.ToVector4(), "Height: "); ImGui.SameLine(); ImGui.SetNextItemWidth(80); if (GuiState._selectedScreenObjectState.IsScreenSurface) { ImGui.Text(((IScreenSurface)GuiState._selectedScreenObject).Surface.Height.ToString()); } else { ImGui.Text("??"); } ImGui.Separator(); } ImGui.EndChild(); } ImGui.Separator(); if (GuiState._selectedScreenObject != null) { if (ImGui.Checkbox("Do draw", ref _toggle_screenObj_doDraw)) { GuiState._selectedScreenObject.IsVisible = _toggle_screenObj_doDraw; } if (ImGui.Button("Fill with random garbage")) { if (GuiState._selectedScreenObject is ScreenSurface surface) { surface.Surface.FillWithRandomGarbage(surface.Font); } } } ImGui.Separator(); if (ImGui.Button("ImGui samples window")) { show_test_window = !show_test_window; } if (ImGui.Button("Break and edit window")) { _pauseForEdit = true; } //ImGui.Image(_imGuiTexture, new Num.Vector2(300, 150), Num.Vector2.Zero, Num.Vector2.One, Num.Vector4.One, Num.Vector4.One); // Here, the previously loaded texture is used } // 2. Show another simple window, this time using an explicit Begin/End pair if (show_another_window) { ImGui.SetNextWindowSize(new Vector2(200, 100), ImGuiCond.FirstUseEver); ImGui.Begin("Another Window", ref show_another_window); ImGui.Text("Hello"); ImGui.End(); } // 3. Show the ImGui test window. Most of the sample code is in ImGui.ShowTestWindow() if (show_test_window) { ImGui.SetNextWindowPos(new Vector2(650, 20), ImGuiCond.FirstUseEver); ImGui.ShowDemoWindow(ref show_test_window); } ImGui.End(); }