Compare commits
5 Commits
main
...
546b7feca7
Author | SHA1 | Date | |
---|---|---|---|
546b7feca7 | |||
36a134170a | |||
6e41c2579c | |||
2afbd9defe | |||
f978c49532 |
64
Nerfed.Compiler/CSProject.cs
Normal file
64
Nerfed.Compiler/CSProject.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Nerfed.Compiler;
|
||||
|
||||
public class CSProject
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Guid { get; set; }
|
||||
//public bool IsEditor { get; set; }
|
||||
// Add platform stuff here..?
|
||||
// Add dll's here..?
|
||||
// Add dependencies here..?
|
||||
|
||||
public static bool Create(string projectFilePath, string name, out CSProject project)
|
||||
{
|
||||
project = null;
|
||||
|
||||
if (File.Exists(projectFilePath))
|
||||
{
|
||||
Console.WriteLine($"ERROR: File already exists!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create project file.
|
||||
project = new CSProject
|
||||
{
|
||||
Name = name,
|
||||
Guid = System.Guid.NewGuid().ToString("B").ToUpper(),
|
||||
};
|
||||
|
||||
Save(project, projectFilePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Save(CSProject project, string projectFilePath)
|
||||
{
|
||||
string jsonString = JsonSerializer.Serialize(project, CSProjectContext.Default.CSProject);
|
||||
|
||||
File.WriteAllText(projectFilePath, jsonString);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Open(string projectFilePath, out CSProject project)
|
||||
{
|
||||
string jsonString = File.ReadAllText(projectFilePath);
|
||||
project = JsonSerializer.Deserialize(jsonString, CSProjectContext.Default.CSProject);
|
||||
|
||||
if (project == null)
|
||||
{
|
||||
Console.WriteLine($"ERROR: Could not open {typeof(CSProject)}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(CSProject))]
|
||||
public partial class CSProjectContext : JsonSerializerContext
|
||||
{
|
||||
}
|
231
Nerfed.Compiler/Compiler.cs
Normal file
231
Nerfed.Compiler/Compiler.cs
Normal file
@ -0,0 +1,231 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Nerfed.Compiler;
|
||||
|
||||
public static class Compiler
|
||||
{
|
||||
public const string CSProjectFileName = ".csproject";
|
||||
public const string CSProjFileName = ".csproj";
|
||||
|
||||
public static bool Compile(string projectFilePath, string configuration = "Debug")
|
||||
{
|
||||
string projectPath = Path.GetDirectoryName(projectFilePath);
|
||||
|
||||
if (!File.Exists(projectFilePath))
|
||||
{
|
||||
Console.WriteLine($"ERROR: Project file not found at {projectPath}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Project.Open(projectFilePath, out Project project))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Check project version, to make sure we can compile it or something...
|
||||
|
||||
// Generate solution.
|
||||
GenerateSolution(projectPath, project, out string solutionFilePath);
|
||||
|
||||
// Compile solution.
|
||||
ProcessStartInfo processInfo = new()
|
||||
{
|
||||
WorkingDirectory = Path.GetDirectoryName(solutionFilePath),
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardOutput = true,
|
||||
};
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
processInfo.FileName = "/bin/bash";
|
||||
processInfo.Arguments = $"-c \"dotnet build '{Path.GetFileName(solutionFilePath)}'\"" + (string.IsNullOrWhiteSpace(configuration) ? $" --configuration {configuration}" : "");
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
processInfo.FileName = "cmd.exe";
|
||||
processInfo.Arguments = $"/c dotnet build \"{Path.GetFileName(solutionFilePath)}\"" + (string.IsNullOrWhiteSpace(configuration) ? $" --configuration {configuration}" : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"ERROR: Platform not supported!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Process process = Process.Start(processInfo) ?? throw new Exception();
|
||||
process.OutputDataReceived += (sender, dataArgs) => {
|
||||
string data = dataArgs.Data;
|
||||
|
||||
if (data is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine(data);
|
||||
};
|
||||
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
process.ErrorDataReceived += (sender, dataArgs) => {
|
||||
if (dataArgs.Data is not null)
|
||||
{
|
||||
Console.WriteLine(dataArgs.Data);
|
||||
}
|
||||
};
|
||||
|
||||
process.WaitForExit();
|
||||
|
||||
int exitCode = process.ExitCode;
|
||||
process.Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void GenerateSolution(string projectPath, Project project, out string solutionPath)
|
||||
{
|
||||
// Clear files.
|
||||
string[] csProjectFiles = Directory.GetFiles(projectPath, $"*{CSProjFileName}", SearchOption.TopDirectoryOnly);
|
||||
foreach (string csProjFile in csProjectFiles)
|
||||
{
|
||||
File.Delete(csProjFile);
|
||||
}
|
||||
|
||||
// Generate projects.
|
||||
string[] csProjectFilePaths = Directory.GetFiles(projectPath, CSProjectFileName, SearchOption.AllDirectories);
|
||||
foreach (string csProjectFilePath in csProjectFilePaths)
|
||||
{
|
||||
GenerateCSProject(csProjectFilePath, projectPath);
|
||||
}
|
||||
|
||||
// Generate solution.
|
||||
string[] csProjPaths = Directory.GetFiles(projectPath, $"*{CSProjFileName}", SearchOption.TopDirectoryOnly);
|
||||
string[] csProjGuids = new string[csProjPaths.Length];
|
||||
for (int i = 0; i < csProjPaths.Length; i++)
|
||||
{
|
||||
csProjGuids[i] = Guid.NewGuid().ToString("B").ToUpper();
|
||||
}
|
||||
|
||||
StringBuilder solutionContent = new StringBuilder();
|
||||
|
||||
// Write the solution file header
|
||||
solutionContent.AppendLine("Microsoft Visual Studio Solution File, Format Version 12.00");
|
||||
solutionContent.AppendLine("# Visual Studio Version 17");
|
||||
solutionContent.AppendLine("VisualStudioVersion = 17.10.35013.160");
|
||||
solutionContent.AppendLine("MinimumVisualStudioVersion = 10.0.40219.1");
|
||||
|
||||
// Add each project to the solution file
|
||||
for (int i = 0; i < csProjPaths.Length; i++)
|
||||
{
|
||||
string csProjPath = csProjPaths[i];
|
||||
string projectGuid = csProjGuids[i];
|
||||
string projectName = Path.GetFileNameWithoutExtension(csProjPath);
|
||||
string projectRelativePath = Path.GetRelativePath(projectPath, csProjPath);
|
||||
// FAE04EC0-301F-11D3-BF4B-00C04F79EFBC for C# projects.
|
||||
solutionContent.AppendLine($"Project(\"{{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}}\") = \"{projectName}\", \"{projectRelativePath}\", \"{projectGuid}\"");
|
||||
solutionContent.AppendLine("EndProject");
|
||||
}
|
||||
|
||||
// Add global sections (these can be extended as needed)
|
||||
solutionContent.AppendLine("Global");
|
||||
solutionContent.AppendLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution");
|
||||
solutionContent.AppendLine(" Test|x64 = Test|x64");
|
||||
solutionContent.AppendLine(" Release|x64 = Release|x64");
|
||||
solutionContent.AppendLine(" Debug|x64 = Debug|x64");
|
||||
solutionContent.AppendLine(" EndGlobalSection");
|
||||
solutionContent.AppendLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution");
|
||||
|
||||
for (int i = 0; i < csProjPaths.Length; i++)
|
||||
{
|
||||
string projectGuid = csProjGuids[i];
|
||||
solutionContent.AppendLine($" {projectGuid}.Test|x64.ActiveCfg = Test|x64");
|
||||
solutionContent.AppendLine($" {projectGuid}.Test|x64.Build.0 = Test|x64");
|
||||
solutionContent.AppendLine($" {projectGuid}.Release|x64.ActiveCfg = Release|x64");
|
||||
solutionContent.AppendLine($" {projectGuid}.Release|x64.Build.0 = Release|x64");
|
||||
solutionContent.AppendLine($" {projectGuid}.Debug|x64.ActiveCfg = Debug|x64");
|
||||
solutionContent.AppendLine($" {projectGuid}.Debug|x64.Build.0 = Debug|x64");
|
||||
}
|
||||
|
||||
solutionContent.AppendLine(" EndGlobalSection");
|
||||
solutionContent.AppendLine(" GlobalSection(SolutionProperties) = preSolution");
|
||||
solutionContent.AppendLine(" HideSolutionNode = FALSE");
|
||||
solutionContent.AppendLine(" EndGlobalSection");
|
||||
solutionContent.AppendLine("EndGlobal");
|
||||
|
||||
// Write the solution file content to disk
|
||||
string solutionName = project.Name + ".sln";
|
||||
string filePath = Path.Combine(projectPath, solutionName);
|
||||
File.WriteAllText(filePath, solutionContent.ToString());
|
||||
|
||||
solutionPath = filePath;
|
||||
}
|
||||
|
||||
private static void GenerateCSProject(string csProjectFilePath, string projectPath)
|
||||
{
|
||||
if (!File.Exists(csProjectFilePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string jsonString = File.ReadAllText(csProjectFilePath);
|
||||
CSProject csProject = JsonSerializer.Deserialize(jsonString, CSProjectContext.Default.CSProject);
|
||||
|
||||
Assembly[] loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
Assembly runtimeAssembly = loadedAssemblies.FirstOrDefault(assembly => assembly.GetName().Name == "Nerfed.Runtime") ?? throw new Exception("Failed to find Runtime Assembly!");
|
||||
|
||||
// TODO: get all dependencies.
|
||||
// TODO: properly get assemblies.
|
||||
|
||||
StringBuilder projectContent = new StringBuilder();
|
||||
|
||||
projectContent.AppendLine("<Project Sdk=\"Microsoft.NET.Sdk\">");
|
||||
|
||||
projectContent.AppendLine(" <PropertyGroup>");
|
||||
projectContent.AppendLine(" <TargetFramework>net8.0</TargetFramework>");
|
||||
projectContent.AppendLine(" <ImplicitUsings>enable</ImplicitUsings>");
|
||||
projectContent.AppendLine(" <Nullable>disable</Nullable>");
|
||||
projectContent.AppendLine(" <PublishAot>true</PublishAot>");
|
||||
projectContent.AppendLine(" <InvariantGlobalization>true</InvariantGlobalization>");
|
||||
projectContent.AppendLine(" <AllowUnsafeBlocks>true</AllowUnsafeBlocks>");
|
||||
projectContent.AppendLine(" <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>");
|
||||
projectContent.AppendLine(" <IsPackable>false</IsPackable>");
|
||||
projectContent.AppendLine(" <Configurations>Debug;Test;Release</Configurations>");
|
||||
projectContent.AppendLine(" <Platforms>x64</Platforms>");
|
||||
projectContent.AppendLine(" </PropertyGroup>");
|
||||
|
||||
projectContent.AppendLine(" <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Debug|x64' \">");
|
||||
projectContent.AppendLine(" <DefineConstants>TRACE;LOG_INFO;PROFILING</DefineConstants>");
|
||||
projectContent.AppendLine(" </PropertyGroup>");
|
||||
|
||||
projectContent.AppendLine(" <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Test|x64' \">");
|
||||
projectContent.AppendLine(" <DefineConstants>TRACE;LOG_ERROR;PROFILING</DefineConstants>");
|
||||
projectContent.AppendLine(" <Optimize>true</Optimize>");
|
||||
projectContent.AppendLine(" </PropertyGroup>");
|
||||
|
||||
projectContent.AppendLine(" <PropertyGroup Condition=\" '$(Configuration)|$(Platform)' == 'Release|x64' \">");
|
||||
projectContent.AppendLine(" <DefineConstants>TRACE;LOG_ERROR</DefineConstants>");
|
||||
projectContent.AppendLine(" <Optimize>true</Optimize>");
|
||||
projectContent.AppendLine(" </PropertyGroup>");
|
||||
|
||||
projectContent.AppendLine(" <ItemGroup>");
|
||||
projectContent.AppendLine($" <Compile Include=\"{csProjectFilePath}/**/*.cs\"/>");
|
||||
projectContent.AppendLine(" </ItemGroup>");
|
||||
|
||||
projectContent.AppendLine(" <ItemGroup>");
|
||||
projectContent.AppendLine(" <Reference Include=\"Nerfed.Runtime\">");
|
||||
projectContent.AppendLine($" <HintPath>{runtimeAssembly.Location}</HintPath>");
|
||||
projectContent.AppendLine(" <Private>false</Private>");
|
||||
projectContent.AppendLine(" </Reference>");
|
||||
projectContent.AppendLine(" </ItemGroup>");
|
||||
|
||||
projectContent.AppendLine("</Project>");
|
||||
|
||||
string projectName = csProject.Name + ".csproj";
|
||||
string filePath = Path.Combine(projectPath, projectName);
|
||||
File.WriteAllText(filePath, projectContent.ToString());
|
||||
}
|
||||
}
|
26
Nerfed.Compiler/Nerfed.Compiler.csproj
Normal file
26
Nerfed.Compiler/Nerfed.Compiler.csproj
Normal file
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Configurations>Debug;Test;Release</Configurations>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Test|x64' ">
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
10
Nerfed.Compiler/Program.cs
Normal file
10
Nerfed.Compiler/Program.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Nerfed.Compiler
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
internal static void Main(string[] args)
|
||||
{
|
||||
Compiler.Compile(args[0], args[1]);
|
||||
}
|
||||
}
|
||||
}
|
50
Nerfed.Compiler/Project.cs
Normal file
50
Nerfed.Compiler/Project.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Nerfed.Compiler;
|
||||
|
||||
public class Project
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public static bool Create(string path, string name, out Project project)
|
||||
{
|
||||
// Create project file.
|
||||
project = new Project
|
||||
{
|
||||
Name = name,
|
||||
};
|
||||
|
||||
Save(project, path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Save(Project project, string projectFilePath)
|
||||
{
|
||||
string jsonString = JsonSerializer.Serialize(project, ProjectContext.Default.Project);
|
||||
|
||||
File.WriteAllText(projectFilePath, jsonString);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Open(string path, out Project project)
|
||||
{
|
||||
string jsonString = File.ReadAllText(path);
|
||||
project = JsonSerializer.Deserialize(jsonString, ProjectContext.Default.Project);
|
||||
|
||||
if (project == null)
|
||||
{
|
||||
Console.WriteLine($"ERROR: Could not open {typeof(Project)}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonSerializable(typeof(Project))]
|
||||
public partial class ProjectContext : JsonSerializerContext
|
||||
{
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using ImGuiNET;
|
||||
using Nerfed.Editor.Project;
|
||||
using Nerfed.Runtime;
|
||||
using Nerfed.Runtime.Graphics;
|
||||
using Nerfed.Runtime.Gui;
|
||||
@ -56,6 +57,7 @@ namespace Nerfed.Editor
|
||||
}
|
||||
ImGui.EndMenu();
|
||||
}
|
||||
|
||||
ImGui.EndMainMenuBar();
|
||||
}
|
||||
}
|
||||
@ -66,6 +68,8 @@ namespace Nerfed.Editor
|
||||
UpdateDock();
|
||||
|
||||
ImGui.ShowDemoWindow();
|
||||
|
||||
ProjectGui.OnGui();
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Nerfed.Compiler\Nerfed.Compiler.csproj" />
|
||||
<ProjectReference Include="..\Nerfed.Runtime\Nerfed.Runtime.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
135
Nerfed.Editor/Project/Project.cs
Normal file
135
Nerfed.Editor/Project/Project.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using Nerfed.Runtime;
|
||||
|
||||
namespace Nerfed.Editor.Project;
|
||||
|
||||
internal static class EditorProject
|
||||
{
|
||||
internal static Compiler.Project Project { get; private set; }
|
||||
internal static string ProjectFilePath { get; private set; }
|
||||
internal static string ProjectSolutionFilePath { get; private set; }
|
||||
internal static string ProjectPath { get; private set; }
|
||||
internal static string ProjectContentPath { get; private set; }
|
||||
internal static string ProjectTempPath { get; private set; }
|
||||
|
||||
internal static bool Create(string projectFilePath, string projectName)
|
||||
{
|
||||
Close();
|
||||
|
||||
if (!Compiler.Project.Create(projectFilePath, projectName, out Compiler.Project project))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Open(projectFilePath);
|
||||
|
||||
Log.Info($"Succesfully created project.");
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static bool Open(string path)
|
||||
{
|
||||
Close();
|
||||
|
||||
if(!Compiler.Project.Open(path, out Compiler.Project project))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Project = project;
|
||||
ProjectFilePath = path;
|
||||
ProjectPath = Path.GetDirectoryName(path);
|
||||
|
||||
string projectSolutionFilePath = Path.Combine(ProjectPath, Project.Name + ".sln");
|
||||
if (File.Exists(projectSolutionFilePath))
|
||||
{
|
||||
ProjectSolutionFilePath = projectSolutionFilePath;
|
||||
}
|
||||
|
||||
SetupDefaultFolders();
|
||||
Compile();
|
||||
|
||||
Log.Info($"Opened project: {project.Name}");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void Close()
|
||||
{
|
||||
Project = null;
|
||||
ProjectFilePath = string.Empty;
|
||||
ProjectSolutionFilePath = string.Empty;
|
||||
ProjectPath = string.Empty;
|
||||
ProjectContentPath = string.Empty;
|
||||
ProjectTempPath = string.Empty;
|
||||
}
|
||||
|
||||
internal static bool Save()
|
||||
{
|
||||
if(Project == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Compiler.Project.Save(Project, ProjectFilePath);
|
||||
}
|
||||
|
||||
internal static void Compile()
|
||||
{
|
||||
if(Project == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Nerfed.Compiler.Compiler.Compile(ProjectFilePath, "Debug");
|
||||
}
|
||||
|
||||
internal static void GenerateSolution()
|
||||
{
|
||||
if(Project == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Nerfed.Compiler.Compiler.GenerateSolution(ProjectPath, Project, out string solutionFilePath);
|
||||
ProjectSolutionFilePath = solutionFilePath;
|
||||
}
|
||||
|
||||
private static void SetupDefaultFolders()
|
||||
{
|
||||
if (Project == null || ProjectPath == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string contentPath = Path.Combine(ProjectPath, "Content");
|
||||
if (!Directory.Exists(contentPath))
|
||||
{
|
||||
Directory.CreateDirectory(contentPath);
|
||||
}
|
||||
ProjectContentPath = contentPath;
|
||||
string scriptsPath = Path.Combine(ProjectContentPath, "Scripts");
|
||||
if (!Directory.Exists(scriptsPath))
|
||||
{
|
||||
Directory.CreateDirectory(scriptsPath);
|
||||
}
|
||||
string scriptsRuntimePath = Path.Combine(scriptsPath, "Runtime");
|
||||
if (!Directory.Exists(scriptsRuntimePath))
|
||||
{
|
||||
Directory.CreateDirectory(scriptsRuntimePath);
|
||||
}
|
||||
|
||||
// Test create csproject.
|
||||
string gameplayRuntimePath = Path.Combine(scriptsRuntimePath, ".csproject");
|
||||
if (!File.Exists(gameplayRuntimePath))
|
||||
{
|
||||
Compiler.CSProject.Create(gameplayRuntimePath, "Gameplay", out Compiler.CSProject project);
|
||||
}
|
||||
|
||||
string tempPath = Path.Combine(ProjectPath, "Temp");
|
||||
if (!Directory.Exists(tempPath))
|
||||
{
|
||||
Directory.CreateDirectory(tempPath);
|
||||
}
|
||||
ProjectTempPath = tempPath;
|
||||
}
|
||||
}
|
68
Nerfed.Editor/Project/ProjectGui.cs
Normal file
68
Nerfed.Editor/Project/ProjectGui.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using ImGuiNET;
|
||||
|
||||
namespace Nerfed.Editor.Project
|
||||
{
|
||||
internal static class ProjectGui
|
||||
{
|
||||
private static string projectPath = string.Empty;
|
||||
private static string projectName = string.Empty;
|
||||
private static string projectFilePath = string.Empty;
|
||||
|
||||
internal static void OnGui()
|
||||
{
|
||||
ImGui.Begin("Project");
|
||||
ImGui.BeginGroup();
|
||||
|
||||
ImGui.InputText("Project Path", ref projectPath, 512);
|
||||
ImGui.InputText("Project Name", ref projectName, 512);
|
||||
|
||||
string newProjectFilePath = Path.Combine(projectPath, ".project");
|
||||
ImGui.Text(newProjectFilePath);
|
||||
|
||||
if (ImGui.Button("Create Project"))
|
||||
{
|
||||
EditorProject.Create(newProjectFilePath, projectName);
|
||||
}
|
||||
|
||||
ImGui.EndGroup();
|
||||
ImGui.BeginGroup();
|
||||
|
||||
ImGui.InputText("Project File Path", ref projectFilePath, 512);
|
||||
if (ImGui.Button("Open Project"))
|
||||
{
|
||||
EditorProject.Open(projectFilePath);
|
||||
}
|
||||
|
||||
ImGui.Text("Loaded project: ");
|
||||
if(EditorProject.Project != null)
|
||||
{
|
||||
ImGui.Text(EditorProject.Project.Name);
|
||||
ImGui.Text(EditorProject.ProjectFilePath);
|
||||
ImGui.Text(EditorProject.ProjectSolutionFilePath);
|
||||
ImGui.Text(EditorProject.ProjectPath);
|
||||
ImGui.Text(EditorProject.ProjectContentPath);
|
||||
ImGui.Text(EditorProject.ProjectTempPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text("None");
|
||||
}
|
||||
|
||||
ImGui.EndGroup();
|
||||
ImGui.BeginGroup();
|
||||
|
||||
if (ImGui.Button("Generate Solution"))
|
||||
{
|
||||
EditorProject.GenerateSolution();
|
||||
}
|
||||
|
||||
if (ImGui.Button("Compile"))
|
||||
{
|
||||
EditorProject.Compile();
|
||||
}
|
||||
|
||||
ImGui.EndGroup();
|
||||
ImGui.End();
|
||||
}
|
||||
}
|
||||
}
|
@ -32,12 +32,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Libraries\SDL2CS\src\SDL2.cs"/>
|
||||
<Compile Include="Libraries\RefreshCS\RefreshCS.cs"/>
|
||||
<Compile Include="Libraries\FAudio\csharp\FAudio.cs"/>
|
||||
<Compile Include="Libraries\WellspringCS\WellspringCS.cs"/>
|
||||
<Compile Include="Libraries\dav1dfile\csharp\dav1dfile.cs"/>
|
||||
<Compile Include="Libraries\ImGui.NET\src\ImGui.NET\**\*.cs"/>
|
||||
<Compile Include="Libraries\SDL2CS\src\SDL2.cs" />
|
||||
<Compile Include="Libraries\RefreshCS\RefreshCS.cs" />
|
||||
<Compile Include="Libraries\FAudio\csharp\FAudio.cs" />
|
||||
<Compile Include="Libraries\WellspringCS\WellspringCS.cs" />
|
||||
<Compile Include="Libraries\dav1dfile\csharp\dav1dfile.cs" />
|
||||
<Compile Include="Libraries\ImGui.NET\src\ImGui.NET\**\*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
48
Nerfed.sln
48
Nerfed.sln
@ -5,38 +5,46 @@ VisualStudioVersion = 17.10.35013.160
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nerfed.Runtime", "Nerfed.Runtime\Nerfed.Runtime.csproj", "{98E09BAF-587F-4238-89BD-7693C036C233}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nerfed.Builder", "Nerfed.Builder\Nerfed.Builder.csproj", "{1B88DE56-2AD8-441E-9B10-073AA43840BF}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nerfed.Builder", "Nerfed.Builder\Nerfed.Builder.csproj", "{1B88DE56-2AD8-441E-9B10-073AA43840BF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nerfed.Editor", "Nerfed.Editor\Nerfed.Editor.csproj", "{FF7D032D-7F0B-4700-A818-0606D66AECF8}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nerfed.Editor", "Nerfed.Editor\Nerfed.Editor.csproj", "{FF7D032D-7F0B-4700-A818-0606D66AECF8}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF} = {1B88DE56-2AD8-441E-9B10-073AA43840BF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nerfed.Compiler", "Nerfed.Compiler\Nerfed.Compiler.csproj", "{3DFEB8A4-5354-41EA-A249-27ADC7F666CF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Test|x64 = Test|x64
|
||||
Release|x64 = Release|x64
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
Test|x64 = Test|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Test|x64.ActiveCfg = Test|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Test|x64.Build.0 = Test|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Release|x64.ActiveCfg = Release|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Release|x64.Build.0 = Release|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Debug|x64.Build.0 = Debug|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Test|x64.ActiveCfg = Test|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Test|x64.Build.0 = Test|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Release|x64.ActiveCfg = Release|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Release|x64.Build.0 = Release|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Debug|x64.Build.0 = Debug|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Test|x64.ActiveCfg = Test|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Test|x64.Build.0 = Test|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Release|x64.ActiveCfg = Release|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Release|x64.Build.0 = Release|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Debug|x64.Build.0 = Debug|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Release|x64.ActiveCfg = Release|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Release|x64.Build.0 = Release|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Test|x64.ActiveCfg = Test|x64
|
||||
{98E09BAF-587F-4238-89BD-7693C036C233}.Test|x64.Build.0 = Test|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Debug|x64.Build.0 = Debug|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Release|x64.ActiveCfg = Release|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Release|x64.Build.0 = Release|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Test|x64.ActiveCfg = Test|x64
|
||||
{1B88DE56-2AD8-441E-9B10-073AA43840BF}.Test|x64.Build.0 = Test|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Debug|x64.Build.0 = Debug|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Release|x64.ActiveCfg = Release|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Release|x64.Build.0 = Release|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Test|x64.ActiveCfg = Test|x64
|
||||
{FF7D032D-7F0B-4700-A818-0606D66AECF8}.Test|x64.Build.0 = Test|x64
|
||||
{3DFEB8A4-5354-41EA-A249-27ADC7F666CF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3DFEB8A4-5354-41EA-A249-27ADC7F666CF}.Debug|x64.Build.0 = Debug|x64
|
||||
{3DFEB8A4-5354-41EA-A249-27ADC7F666CF}.Release|x64.ActiveCfg = Release|x64
|
||||
{3DFEB8A4-5354-41EA-A249-27ADC7F666CF}.Release|x64.Build.0 = Release|x64
|
||||
{3DFEB8A4-5354-41EA-A249-27ADC7F666CF}.Test|x64.ActiveCfg = Test|x64
|
||||
{3DFEB8A4-5354-41EA-A249-27ADC7F666CF}.Test|x64.Build.0 = Test|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
Reference in New Issue
Block a user