Skip to content

Commit

Permalink
temp checkin for editor/debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
Thraka committed Jan 4, 2022
1 parent e7fac19 commit ab58ae4
Show file tree
Hide file tree
Showing 17 changed files with 281 additions and 45 deletions.
3 changes: 1 addition & 2 deletions SadConsole.Debug.MonoGame/ExtensionsColorNumerics.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using SadRogue.Primitives;

namespace SadConsole.Numerics
namespace System.Numerics
{
/// <summary>
/// Extensions to convert <see cref="Vector4"/> to/from <see cref="Color"/>.
Expand Down
1 change: 0 additions & 1 deletion SadConsole.Debug.MonoGame/GuiOutputPreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Numerics;
using System.Text;
using ImGuiNET;
using SadConsole.Numerics;
using SadConsole.ImGuiSystem;

namespace SadConsole.Debug.MonoGame
Expand Down
1 change: 0 additions & 1 deletion SadConsole.Debug.MonoGame/GuiScreenObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Reflection;
using ImGuiNET;
using System.Numerics;
using SadConsole.Numerics;
using SadRogue.Primitives;
using SadConsole.ImGuiSystem;

Expand Down
1 change: 0 additions & 1 deletion SadConsole.Debug.MonoGame/GuiState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using SadConsole.Numerics;

namespace SadConsole.Debug.MonoGame
{
Expand Down
1 change: 0 additions & 1 deletion SadConsole.Debug.MonoGame/GuiSurfacePreview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Numerics;
using System.Text;
using ImGuiNET;
using SadConsole.Numerics;
using SadConsole.ImGuiSystem;

namespace SadConsole.Debug.MonoGame
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Numerics;
using System.Text;
using ImGuiNET;
using SadConsole.Numerics;
using SadRogue.Primitives;

namespace SadConsole.Debug.MonoGame.ImGuiObjects
Expand Down
4 changes: 2 additions & 2 deletions SadConsole.Debug.MonoGame/ImGuiSystem/ImGuiExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Text;
using ImGuiNET;
using Microsoft.Xna.Framework.Graphics;
using SadConsole.Numerics;

namespace SadConsole.ImGuiSystem
{
Expand Down Expand Up @@ -47,6 +46,7 @@ public static void DrawTextureChild(string id, bool border, int zoomMode, IntPtr
ImGui.EndChild();
}


public static void CenterNextWindow() =>
ImGui.SetNextWindowPos(ImGui.GetIO().DisplaySize / 2f, ImGuiCond.Appearing, new System.Numerics.Vector2(0.5f, 0.5f));
}
}
38 changes: 19 additions & 19 deletions SadConsole.Debug.MonoGame/SadConsole.Debugger.MonoGame.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions SadConsoleEditor.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31825.309
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SadConsole", "SadConsole\SadConsole.csproj", "{47532D92-BB78-493A-A693-CC3687F609F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SadConsole.Host.MonoGame", "SadConsole.Host.MonoGame\SadConsole.Host.MonoGame.csproj", "{F02A2B3B-706E-4277-9CE2-B47733CCB22F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SadConsole.Extended", "SadConsole.Extended\SadConsole.Extended.csproj", "{33F13C14-A4E4-467A-BBBC-14A0F7408E77}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SadConsole.Debug.MonoGame", "SadConsole.Debug.MonoGame\SadConsole.Debug.MonoGame.csproj", "{3D40BD49-A118-4655-8452-8CFAE677847A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Editor", "Samples\Editor\Editor.csproj", "{2972BDC7-1337-4BDC-8C37-99227A7861FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{47532D92-BB78-493A-A693-CC3687F609F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47532D92-BB78-493A-A693-CC3687F609F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47532D92-BB78-493A-A693-CC3687F609F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47532D92-BB78-493A-A693-CC3687F609F6}.Release|Any CPU.Build.0 = Release|Any CPU
{F02A2B3B-706E-4277-9CE2-B47733CCB22F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F02A2B3B-706E-4277-9CE2-B47733CCB22F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F02A2B3B-706E-4277-9CE2-B47733CCB22F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F02A2B3B-706E-4277-9CE2-B47733CCB22F}.Release|Any CPU.Build.0 = Release|Any CPU
{33F13C14-A4E4-467A-BBBC-14A0F7408E77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33F13C14-A4E4-467A-BBBC-14A0F7408E77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33F13C14-A4E4-467A-BBBC-14A0F7408E77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33F13C14-A4E4-467A-BBBC-14A0F7408E77}.Release|Any CPU.Build.0 = Release|Any CPU
{3D40BD49-A118-4655-8452-8CFAE677847A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D40BD49-A118-4655-8452-8CFAE677847A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D40BD49-A118-4655-8452-8CFAE677847A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D40BD49-A118-4655-8452-8CFAE677847A}.Release|Any CPU.Build.0 = Release|Any CPU
{2972BDC7-1337-4BDC-8C37-99227A7861FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2972BDC7-1337-4BDC-8C37-99227A7861FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2972BDC7-1337-4BDC-8C37-99227A7861FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2972BDC7-1337-4BDC-8C37-99227A7861FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55A32531-B44C-4843-9FC5-052AAE7525A3}
EndGlobalSection
EndGlobal
11 changes: 7 additions & 4 deletions Samples/Editor/Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
</PropertyGroup>

<PropertyGroup>
<UseProjectReferences>true</UseProjectReferences>
<UseProjectReferences>false</UseProjectReferences>
</PropertyGroup>

<ItemGroup>
<ProjectReference Condition=" '$(UseProjectReferences)' == 'true' " Include="..\..\SadConsole.Host.MonoGame\SadConsole.Host.MonoGame.csproj" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole.Host.MonoGame" Version="9.0.0-beta3" />
<ProjectReference Include="..\..\SadConsole.Debug.MonoGame\SadConsole.Debug.MonoGame.csproj" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole.Host.MonoGame" Version="9.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Condition=" '$(UseProjectReferences)' == 'true' " Include="..\..\SadConsole.Extended\SadConsole.Extended.csproj" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole.Extended" Version="9.2.0" />

<ProjectReference Condition=" '$(UseProjectReferences)' == 'true' " Include="..\..\SadConsole\SadConsole.csproj" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole" Version="9.0.0-beta3" />
<PackageReference Condition=" '$(UseProjectReferences)' != 'true' " Include="SadConsole" Version="9.2.0" />

<ProjectReference Include="..\..\SadConsole.Debug.MonoGame\SadConsole.Debug.MonoGame.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
30 changes: 24 additions & 6 deletions Samples/Editor/GuiParts/GuiNewFileWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,55 @@ namespace SadConsole.Editor.GuiParts
public class GuiNewFileWindow: ImGuiWindow
{
private int _documentSelectedIndex;
private string _documentName = "";
public Model.Document Document = new Model.Document() { DocumentType = Model.Document.Types.Surface, Settings = new Model.DocumentSurfaceSettings() };

public GuiNewFileWindow()
{
Title = "New file";

}

public override void BuildUI(ImGuiRenderer renderer)
{
if (IsOpen)
{
if (ImGui.Begin(Title, ref IsOpen, ImGuiWindowFlags.Modal | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoDocking | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse))
ImGui.OpenPopup(Title);

ImGuiExt.CenterNextWindow();
ImGui.SetNextWindowSize(new System.Numerics.Vector2(350, -1));
if (ImGui.BeginPopupModal(Title, ref IsOpen, ImGuiWindowFlags.NoResize))
{
ImGui.Text("Document Type:");
if (ImGui.ListBox("##Document Type", ref _documentSelectedIndex, new[] { "Surface", "Animation" }, 2))
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
if (ImGui.ListBox("##Document Type", ref _documentSelectedIndex, new[] { "Surface", "Scene", "Animation" }, 3))
{

Document = _documentSelectedIndex switch
{
_ => new Model.Document() { DocumentType = Model.Document.Types.Surface, Settings = new Model.DocumentSurfaceSettings() },
};
}

ImGui.Text($"id: {_documentSelectedIndex}");
ImGui.Separator();

ImGui.Text("Name");
ImGui.InputText("##name", ref Document.Name, 50);

ImGui.Separator();

Document.Settings.BuildUINew(renderer);

ImGui.Separator();

if (ImGui.Button("Cancel")) { DialogResult = false; IsOpen = false; }

// Right-align button
float pos = ImGui.GetItemRectSize().X + ImGui.GetStyle().ItemSpacing.X;
ImGui.SameLine(ImGui.GetWindowWidth() - pos);
if (ImGui.Button("Create")) { DialogResult = true; IsOpen = false; }


ImGui.EndPopup();
}
ImGui.End();
}
else
{
Expand Down
33 changes: 33 additions & 0 deletions Samples/Editor/GuiParts/GuiSidePane.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using ImGuiNET;
using SadConsole.ImGuiSystem;

namespace SadConsole.Editor.GuiParts
{
public class GuiSidePane : ImGuiObjectBase
{
private int _selectedDocIndex;

public override void BuildUI(ImGuiRenderer renderer)
{
ImGui.SetNextWindowSize(new Vector2(200, ImGui.GetIO().DisplaySize.Y / 3), ImGuiCond.Appearing);

ImGui.Begin("Documents", ImGuiWindowFlags.NoCollapse);
{

ImGui.ListBox("##documentslist", ref _selectedDocIndex, ImGuiCore.State.OpenDocumentTitles, ImGuiCore.State.OpenDocuments.Length);

if (ImGuiCore.State.OpenDocuments.Length > 0)
{
ImGuiCore.State.OpenDocuments[ImGuiCore.State.SelectedDocumentIndex].Settings.BuildUIEdit(renderer, true);
}
}
ImGui.End();
}
}
}
23 changes: 21 additions & 2 deletions Samples/Editor/GuiParts/GuiTopBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ namespace SadConsole.Editor.GuiParts
{
public class GuiTopBar : ImGuiObjectBase
{

private bool _showDemoWindow;
private bool _debug;

public override void BuildUI(ImGuiRenderer renderer)
{
if (_debug)
{
_debug = false;
System.Diagnostics.Debugger.Break();
}

if (ImGui.BeginMainMenuBar())
{
if (ImGui.BeginMenu("File"))
Expand All @@ -25,7 +32,6 @@ public override void BuildUI(ImGuiRenderer renderer)

}


ImGui.EndMenu();
}

Expand All @@ -34,13 +40,26 @@ public override void BuildUI(ImGuiRenderer renderer)
//if (ImGui.MenuItem("Show SadConsole game", "s", ref GuiState.ShowSadConsoleRendering, true))
// GuiState.RaiseShowSadConsoleRenderingChanged();

ImGui.MenuItem("Show demo", "s", ref _showDemoWindow);

//ImGui.MenuItem("Show surface preview", "p", ref GuiState.ShowSurfacePreview, true);
//ImGui.MenuItem("Show final output", "o", ref GuiState.GuiFinalOutputWindow.IsOpen, true);
ImGui.EndMenu();
}

if (ImGui.BeginMenu("Debug"))
{
if (ImGui.MenuItem("Pause", "p"))
_debug = true;

ImGui.EndMenu();
}

ImGui.EndMainMenuBar();
}

if (_showDemoWindow)
ImGui.ShowDemoWindow();
}
}
}
Loading

0 comments on commit ab58ae4

Please sign in to comment.