Cleaned up UI and added a way to build .net project from the editor

This commit is contained in:
Antoine Pilote
2023-10-27 01:32:17 -04:00
parent cb51ecc119
commit 6ef9521059
10 changed files with 76 additions and 7 deletions

View File

@@ -128,12 +128,26 @@ namespace Nuake {
if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5)))
{
SceneSnapshot = Engine::GetCurrentScene()->Copy();
ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
Engine::EnterPlayMode();
}
if (ImGui::BeginItemTooltip())
{
ImGui::Text("Build & Play");
ImGui::EndTooltip();
}
}
ImGui::SameLine();
const bool wasPlayMode = Engine::IsPlayMode();
if (!wasPlayMode)
{
ImGui::BeginDisabled();
}
if ((ImGui::Button(ICON_FA_STOP, ImVec2(30, 30)) || Input::IsKeyPressed(GLFW_KEY_F8)) && Engine::IsPlayMode())
{
Engine::ExitPlayMode();
@@ -142,6 +156,19 @@ namespace Nuake {
Selection = EditorSelection();
}
if(!wasPlayMode)
{
ImGui::EndDisabled();
}
else
{
if (ImGui::BeginItemTooltip())
{
ImGui::Text("Exit play mode");
ImGui::EndTooltip();
}
}
//if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5) && !Engine::IsPlayMode()))
//{
@@ -173,7 +200,7 @@ namespace Nuake {
ImGui::SameLine();
const int sizeofRightPart = 160;
const int sizeofRightPart = 156;
ImGui::Dummy(ImVec2(ImGui::GetContentRegionAvail().x - sizeofRightPart, 30));
@@ -206,6 +233,25 @@ namespace Nuake {
ImGui::EndChild();
ImGui::SameLine();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 2));
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0));
if (ImGui::Button(ICON_FA_HAMMER, ImVec2(30, 30)))
{
Nuake::ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject());
}
if (ImGui::BeginItemTooltip())
{
ImGui::Text("Built .Net project");
ImGui::EndTooltip();
}
ImGui::PopStyleColor();
ImGui::PopStyleVar();
ImGui::PopStyleColor();
ImGui::PopStyleVar();

View File

@@ -63,7 +63,6 @@ namespace Nuake {
m_ListenerPosition = position;
m_ListenerDirection = direction;
m_ListenerUp = up;
m_Soloud->set3dListenerParameters(m_ListenerPosition.x, m_ListenerPosition.y, m_ListenerPosition.z,
m_ListenerDirection.x, m_ListenerDirection.y, m_ListenerDirection.z,
m_ListenerUp.x, m_ListenerUp.y, m_ListenerUp.z

View File

@@ -139,6 +139,16 @@ namespace Nuake {
return path;
}
void OS::CompileSln(const std::string& slnPath)
{
int result = system(std::string("dotnet build " + slnPath).c_str());
if (result != 0)
{
Logger::Log("Failed to execute `dotnet build` command.", "OS", CRITICAL);
}
}
void OS::OpenURL(const std::string& url)
{
#ifdef NK_WIN

View File

@@ -19,5 +19,6 @@ namespace Nuake
static void OpenTrenchbroomMap(const std::string& filePath);
static void OpenURL(const std::string& url);
static std::string GetConfigFolderPath();
static void CompileSln(const std::string& slnPath);
};
}

View File

@@ -47,7 +47,7 @@ namespace Nuake
sanitizedKeyword = std::regex_replace(sanitizedKeyword, std::regex("[ _-]+"), "");
// Convert to lowercase
std::transform(sanitizedKeyword.begin(), sanitizedKeyword.end(), sanitizedKeyword.begin(), ::tolower);
//std::transform(sanitizedKeyword.begin(), sanitizedKeyword.end(), sanitizedKeyword.begin(), ::tolower);
return sanitizedKeyword;
}

View File

@@ -34,7 +34,7 @@ namespace Nuake
Vector3 direction = currentCamera->GetDirection();
if (Engine::IsPlayMode())
{
direction *= Vector3(-1, -1, -1);
direction *= -1.0f;
}
audioManager.SetListenerPosition(currentCamera->GetTranslation(), std::move(direction), currentCamera->GetUp());

View File

@@ -137,7 +137,6 @@ namespace Nuake
catch (std::exception* e)
{
}
}
auto& scriptingEngineNet = ScriptingEngineNet::Get();

View File

@@ -101,6 +101,18 @@ namespace Nuake
m_EntityToManagedObjects.clear();
}
void ScriptingEngineNet::BuildProjectAssembly(Ref<Project> project)
{
const std::string sanitizedProjectName = String::Sanitize(project->Name);
if (!FileSystem::FileExists(sanitizedProjectName + ".sln"))
{
Logger::Log("Couldn't find .net solution. Have you created a solution?", ".net", CRITICAL);
return;
}
OS::CompileSln(FileSystem::Root + sanitizedProjectName + ".sln");
}
void ScriptingEngineNet::LoadProjectAssembly(Ref<Project> project)
{
const std::string sanitizedProjectName = String::Sanitize(project->Name);

View File

@@ -49,6 +49,7 @@ namespace Nuake {
void Initialize();
void Uninitialize();
void BuildProjectAssembly(Ref<Project> project);
void LoadProjectAssembly(Ref<Project> project);
void RegisterEntityScript(Entity& entity);

View File

@@ -308,7 +308,7 @@ namespace Nuake
ImVec4* colors = ImGui::GetStyle().Colors;
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.148f, 0.148f, 0.148f, 1.00f);
colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
colors[ImGuiCol_Border] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
@@ -317,7 +317,7 @@ namespace Nuake
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.09f, 0.09f, 0.09f, 1.00f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.13f, 0.13f, 0.13f, 1.00f);
colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.078, 0.078, 0.078, 1.00f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.00f);
@@ -350,6 +350,7 @@ namespace Nuake
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
colors[ImGuiCol_Border] = ImVec4(0.078f, 0.078f, 0.078f, 1.00f);
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f);
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
colors[ImGuiCol_TableBorderLight] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);