Added initial implementation of script inspector
This commit is contained in:
parent
a57c4d0d73
commit
7010e1b688
|
@ -12,6 +12,8 @@
|
||||||
#include "Editor/SHEditorWidgets.hpp"
|
#include "Editor/SHEditorWidgets.hpp"
|
||||||
#include "SHEditorComponentView.hpp"
|
#include "SHEditorComponentView.hpp"
|
||||||
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
||||||
|
#include "Scripting/SHScriptEngine.h"
|
||||||
|
#include "ECS_Base/Managers/SHSystemManager.h"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
@ -61,6 +63,11 @@ namespace SHADE
|
||||||
DrawAddComponentButton<SHRenderable>(eid);
|
DrawAddComponentButton<SHRenderable>(eid);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render Scripts
|
||||||
|
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||||
|
scriptEngine->RenderScriptsInInspector(eid);
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,103 +10,141 @@ Reproduction or disclosure of this file or its contents without the prior writte
|
||||||
of DigiPen Institute of Technology is prohibited.
|
of DigiPen Institute of Technology is prohibited.
|
||||||
*//*************************************************************************************/
|
*//*************************************************************************************/
|
||||||
// Precompiled Header
|
// Precompiled Header
|
||||||
#include <pch.h>
|
#include "SHpch.h"
|
||||||
// Primary Header
|
// Primary Header
|
||||||
#include "Editor/EditorUI.h"
|
#include "SHEditorUI.h"
|
||||||
// External Dependencies
|
// External Dependencies
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
// Project Headers
|
|
||||||
#include "Core/Resource/ResourceManager.h"
|
|
||||||
#include "Editor/ImGuiExtensions.h"
|
|
||||||
#include "Editor/Editor.h"
|
|
||||||
|
|
||||||
namespace Pls
|
namespace SHADE
|
||||||
{
|
{
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - ID Stack */
|
/* ImGui Wrapper Functions - ID Stack */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void EditorUI::PushID(const std::string& id)
|
void SHEditorUI::PushID(const std::string& id)
|
||||||
{
|
{
|
||||||
ImGui::PushID(id.c_str());
|
ImGui::PushID(id.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorUI::PushID(int id)
|
void SHEditorUI::PushID(int id)
|
||||||
{
|
{
|
||||||
ImGui::PushID(id);
|
ImGui::PushID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorUI::PopID()
|
void SHEditorUI::PopID()
|
||||||
{
|
{
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Indent */
|
/* ImGui Wrapper Functions - Indent */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void EditorUI::Indent()
|
void SHEditorUI::Indent()
|
||||||
{
|
{
|
||||||
ImGui::Indent();
|
ImGui::Indent();
|
||||||
}
|
}
|
||||||
void EditorUI::Unindent()
|
void SHEditorUI::Unindent()
|
||||||
{
|
{
|
||||||
ImGui::Unindent();
|
ImGui::Unindent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Organisers */
|
/* ImGui Wrapper Functions - Organizers */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
bool EditorUI::CollapsingHeader(const std::string& title)
|
bool SHEditorUI::CollapsingHeader(const std::string& title)
|
||||||
{
|
{
|
||||||
return ImGui::CollapsingHeader(title.c_str());
|
return ImGui::CollapsingHeader(title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
void SHEditorUI::SameLine()
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorUI::Separator()
|
||||||
|
{
|
||||||
|
ImGui::Separator();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHEditorUI::BeginMenu(const std::string& label)
|
||||||
|
{
|
||||||
|
return ImGui::BeginMenu(label.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHEditorUI::BeginMenu(const std::string& label, const char* icon)
|
||||||
|
{
|
||||||
|
return ImGui::BeginMenu(std::format("{} {}", icon, label.data()).data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorUI::EndMenu()
|
||||||
|
{
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Pop Ups */
|
/* ImGui Wrapper Functions - Pop Ups */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
bool EditorUI::BeginPopup(const std::string& label)
|
bool SHEditorUI::BeginPopup(const std::string& label)
|
||||||
{
|
{
|
||||||
return ImGui::BeginPopup(label.c_str());
|
return ImGui::BeginPopup(label.c_str());
|
||||||
}
|
}
|
||||||
void EditorUI::EndPopup()
|
|
||||||
|
bool SHEditorUI::BeginPopupContextItem(const std::string& label)
|
||||||
|
{
|
||||||
|
return ImGui::BeginPopupContextItem(label.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SHEditorUI::EndPopup()
|
||||||
{
|
{
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
void EditorUI::OpenPopup(const std::string& label)
|
void SHEditorUI::OpenPopup(const std::string& label)
|
||||||
{
|
{
|
||||||
ImGui::OpenPopup(label.c_str());
|
ImGui::OpenPopup(label.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUI::MenuItem(const std::string& label)
|
bool SHEditorUI::MenuItem(const std::string& label)
|
||||||
{
|
{
|
||||||
return ImGui::MenuItem(label.c_str());
|
return ImGui::MenuItem(label.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Widgets */
|
/* ImGui Wrapper Functions - Widgets */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void EditorUI::Text(const std::string& title)
|
void SHEditorUI::Text(const std::string& title)
|
||||||
{
|
{
|
||||||
ImGui::Text(title.c_str());
|
ImGui::Text(title.c_str());
|
||||||
}
|
}
|
||||||
bool EditorUI::SmallButton(const std::string& title)
|
bool SHEditorUI::SmallButton(const std::string& title)
|
||||||
{
|
{
|
||||||
return ImGui::SmallButton(title.c_str());
|
return ImGui::SmallButton(title.c_str());
|
||||||
}
|
}
|
||||||
bool EditorUI::Button(const std::string& title)
|
bool SHEditorUI::Button(const std::string& title)
|
||||||
{
|
{
|
||||||
return ImGui::Button(title.c_str());
|
return ImGui::Button(title.c_str());
|
||||||
}
|
}
|
||||||
bool EditorUI::InputCheckbox(const std::string& label, bool& value)
|
|
||||||
|
bool SHEditorUI::Selectable(const std::string& label)
|
||||||
|
{
|
||||||
|
return ImGui::Selectable(label.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHEditorUI::Selectable(const std::string& label, const char* icon)
|
||||||
|
{
|
||||||
|
return ImGui::Selectable(std::format("{} {}", icon, label).data());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SHEditorUI::InputCheckbox(const std::string& label, bool& value)
|
||||||
{
|
{
|
||||||
return ImGui::Checkbox(label.c_str(), &value);
|
return ImGui::Checkbox(label.c_str(), &value);
|
||||||
}
|
}
|
||||||
bool EditorUI::InputInt(const std::string& label, int& value)
|
bool SHEditorUI::InputInt(const std::string& label, int& value)
|
||||||
{
|
{
|
||||||
return ImGui::InputInt(label.c_str(), &value,
|
return ImGui::InputInt(label.c_str(), &value,
|
||||||
1, 10,
|
1, 10,
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
}
|
}
|
||||||
bool EditorUI::InputUnsignedInt(const std::string& label, unsigned int& value)
|
bool SHEditorUI::InputUnsignedInt(const std::string& label, unsigned int& value)
|
||||||
{
|
{
|
||||||
int signedVal = static_cast<int>(value);
|
int signedVal = static_cast<int>(value);
|
||||||
const bool CHANGED = InputInt(label, signedVal);
|
const bool CHANGED = InputInt(label, signedVal);
|
||||||
|
@ -117,26 +155,26 @@ namespace Pls
|
||||||
}
|
}
|
||||||
return CHANGED;
|
return CHANGED;
|
||||||
}
|
}
|
||||||
bool EditorUI::InputFloat(const std::string& label, float& value)
|
bool SHEditorUI::InputFloat(const std::string& label, float& value)
|
||||||
{
|
{
|
||||||
return ImGui::InputFloat(label.c_str(), &value,
|
return ImGui::InputFloat(label.c_str(), &value,
|
||||||
0.1f, 1.0f, "%.3f",
|
0.1f, 1.0f, "%.3f",
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
}
|
}
|
||||||
bool EditorUI::InputDouble(const std::string& label, double& value)
|
bool SHEditorUI::InputDouble(const std::string& label, double& value)
|
||||||
{
|
{
|
||||||
return ImGui::InputDouble(label.c_str(), &value,
|
return ImGui::InputDouble(label.c_str(), &value,
|
||||||
0.1, 1.0, "%.3f",
|
0.1, 1.0, "%.3f",
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
}
|
}
|
||||||
bool EditorUI::InputAngle(const std::string& label, double& value)
|
bool SHEditorUI::InputAngle(const std::string& label, double& value)
|
||||||
{
|
{
|
||||||
return ImGui::InputDouble(label.c_str(), &value,
|
return ImGui::InputDouble(label.c_str(), &value,
|
||||||
1.0, 45.0, "%.3f",
|
1.0, 45.0, "%.3f",
|
||||||
ImGuiInputTextFlags_EnterReturnsTrue);
|
ImGuiInputTextFlags_EnterReturnsTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUI::InputSlider(const std::string& label, double min, double max, double& value)
|
bool SHEditorUI::InputSlider(const std::string& label, double min, double max, double& value)
|
||||||
{
|
{
|
||||||
float val = static_cast<float>(value);
|
float val = static_cast<float>(value);
|
||||||
const bool CHANGED = ImGui::SliderFloat(label.c_str(), &val,
|
const bool CHANGED = ImGui::SliderFloat(label.c_str(), &val,
|
||||||
|
@ -152,7 +190,7 @@ namespace Pls
|
||||||
return CHANGED;
|
return CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUI::InputVec2(const std::string& label, vec2& value)
|
bool SHEditorUI::InputVec2(const std::string& label, SHVec2& value)
|
||||||
{
|
{
|
||||||
float vec[2] =
|
float vec[2] =
|
||||||
{
|
{
|
||||||
|
@ -168,7 +206,7 @@ namespace Pls
|
||||||
}
|
}
|
||||||
return CHANGED;
|
return CHANGED;
|
||||||
}
|
}
|
||||||
bool EditorUI::InputVec3(const std::string& label, vec3& value)
|
bool SHEditorUI::InputVec3(const std::string& label, SHVec3& value)
|
||||||
{
|
{
|
||||||
float vec[3] =
|
float vec[3] =
|
||||||
{
|
{
|
||||||
|
@ -187,7 +225,7 @@ namespace Pls
|
||||||
return CHANGED;
|
return CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUI::InputSliderVec3(const std::string& label, double min, double max, vec3& value)
|
bool SHEditorUI::InputSliderVec3(const std::string& label, double min, double max, SHVec3& value)
|
||||||
{
|
{
|
||||||
float vec[3] =
|
float vec[3] =
|
||||||
{
|
{
|
||||||
|
@ -207,29 +245,7 @@ namespace Pls
|
||||||
return CHANGED;
|
return CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUI::InputColor(const std::string& label, GFX::Color& value)
|
bool SHEditorUI::InputTextField(const std::string& label, std::string& value)
|
||||||
{
|
|
||||||
float color[4] =
|
|
||||||
{
|
|
||||||
value.R,
|
|
||||||
value.G,
|
|
||||||
value.B,
|
|
||||||
value.A
|
|
||||||
};
|
|
||||||
const bool CHANGED = ImGui::ColorEdit4(label.c_str(), color,
|
|
||||||
ImGuiColorEditFlags_AlphaBar |
|
|
||||||
ImGuiColorEditFlags_AlphaPreview |
|
|
||||||
ImGuiColorEditFlags_Float);
|
|
||||||
if (CHANGED)
|
|
||||||
{
|
|
||||||
value.R = color[0];
|
|
||||||
value.G = color[1];
|
|
||||||
value.B = color[2];
|
|
||||||
value.A = std::clamp(color[3], 0.f, 1.f);
|
|
||||||
}
|
|
||||||
return CHANGED;
|
|
||||||
}
|
|
||||||
bool EditorUI::InputTextField(const std::string& label, std::string& value)
|
|
||||||
{
|
{
|
||||||
std::array<char, TEXT_FIELD_MAX_LENGTH> buffer = { '\0' };
|
std::array<char, TEXT_FIELD_MAX_LENGTH> buffer = { '\0' };
|
||||||
strcpy_s(buffer.data(), TEXT_FIELD_MAX_LENGTH, value.c_str());
|
strcpy_s(buffer.data(), TEXT_FIELD_MAX_LENGTH, value.c_str());
|
||||||
|
@ -241,7 +257,7 @@ namespace Pls
|
||||||
return CHANGED;
|
return CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUI::InputEnumCombo(const std::string& label, int& v, const std::vector<std::string>& enumNames)
|
bool SHEditorUI::InputEnumCombo(const std::string& label, int& v, const std::vector<std::string>& enumNames)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Clamp input value
|
// Clamp input value
|
||||||
|
@ -266,156 +282,4 @@ namespace Pls
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorUI::InputTextureDropDown(const std::string& label, Resource::Snowflake& v)
|
|
||||||
{
|
|
||||||
static std::vector<std::reference_wrapper<Resource>> resources;
|
|
||||||
|
|
||||||
// Register texture popup
|
|
||||||
bool hasChanges = false;
|
|
||||||
if (ImGui::BeginPopup("Texture Menu"))
|
|
||||||
{
|
|
||||||
if (ImGui::Button("None"))
|
|
||||||
{
|
|
||||||
v = Resource::INVALID_SNOWFLAKE;
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
}
|
||||||
for (auto& rscWrapper : resources)
|
|
||||||
{
|
|
||||||
Resource& rsc = rscWrapper.get();
|
|
||||||
|
|
||||||
ImGui::PushID(static_cast<int>(rsc.GetID()));
|
|
||||||
|
|
||||||
const GFX::Texture* TEX = rsc.LoadTexture();
|
|
||||||
if (TEX == nullptr)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const ImTextureID TEX_ID = reinterpret_cast<void*>(static_cast<intptr_t>(TEX->GetHandle()));
|
|
||||||
const std::string NAME = rsc.GetPath().filename().string();
|
|
||||||
const std::string FP = rsc.GetPath().string();
|
|
||||||
if (ImGui::ImageButtonWithText(TEX_ID, NAME.c_str()))
|
|
||||||
{
|
|
||||||
v = rsc.GetID();
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
ImGui::TextDisabled(FP.c_str());
|
|
||||||
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get texture ID of resource
|
|
||||||
ImTextureID texID = 0;
|
|
||||||
std::string texName = "None";
|
|
||||||
Resource* rsc = ResourceManager::Find(v);
|
|
||||||
if (rsc)
|
|
||||||
{
|
|
||||||
// File
|
|
||||||
if (rsc->IsType<GFX::Texture>())
|
|
||||||
{
|
|
||||||
GFX::Texture* tex = rsc->LoadTexture();
|
|
||||||
if (tex)
|
|
||||||
{
|
|
||||||
texID = reinterpret_cast<void*>(static_cast<intptr_t>(tex->GetHandle()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO (Clarence): replace with missing texture image
|
|
||||||
texID = Editor::Editor::GetInternalTexture("scene.png");
|
|
||||||
}
|
|
||||||
texName = rsc->GetPath().filename().string();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show texture selection menu
|
|
||||||
if (ImGui::ImageButtonWithText(texID, texName.c_str(), label.c_str()))
|
|
||||||
{
|
|
||||||
resources = ResourceManager::FindAllOfType<GFX::Texture>();
|
|
||||||
ImGui::OpenPopup("Texture Menu");
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasChanges;
|
|
||||||
}
|
|
||||||
bool EditorUI::InputFontDropDown(const char* label, Resource::Snowflake& v)
|
|
||||||
{
|
|
||||||
static std::vector<std::reference_wrapper<Resource>> resources;
|
|
||||||
|
|
||||||
// Register texture popup
|
|
||||||
bool hasChanges = false;
|
|
||||||
if (ImGui::BeginPopup("Font Menu"))
|
|
||||||
{
|
|
||||||
if (ImGui::Button("None"))
|
|
||||||
{
|
|
||||||
v = Resource::INVALID_SNOWFLAKE;
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
for (auto& rscWrapper : resources)
|
|
||||||
{
|
|
||||||
Resource& rsc = rscWrapper.get();
|
|
||||||
|
|
||||||
ImGui::PushID(static_cast<int>(rsc.GetID()));
|
|
||||||
|
|
||||||
const GFX::Font* FONT = rsc.LoadFont();
|
|
||||||
if (FONT == nullptr)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const std::string NAME = rsc.GetPath().filename().string();
|
|
||||||
const std::string FP = rsc.GetPath().string();
|
|
||||||
if (ImGui::Button(NAME.c_str()))
|
|
||||||
{
|
|
||||||
v = rsc.GetID();
|
|
||||||
ImGui::CloseCurrentPopup();
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
ImGui::TextDisabled(FP.c_str());
|
|
||||||
|
|
||||||
ImGui::PopID();
|
|
||||||
}
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get font ID of resource
|
|
||||||
ImTextureID fontID = 0;
|
|
||||||
std::string fontName = "None";
|
|
||||||
Resource* rsc = ResourceManager::Find(v);
|
|
||||||
|
|
||||||
if (rsc)
|
|
||||||
{
|
|
||||||
// File
|
|
||||||
if (rsc)
|
|
||||||
{
|
|
||||||
GFX::Font* font = rsc->LoadFont();
|
|
||||||
if (font)
|
|
||||||
{
|
|
||||||
fontID = reinterpret_cast<void*>(static_cast<intptr_t>(font->GetID()));
|
|
||||||
if (font->CreatedThisFrame())
|
|
||||||
{
|
|
||||||
font->OnCreate() = false;
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO (Clarence): replace with missing texture image
|
|
||||||
fontID = Editor::Editor::GetInternalFont("selawk.tff");
|
|
||||||
}
|
|
||||||
fontName = rsc->GetPath().filename().string();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show font selection menu
|
|
||||||
if (ImGui::ButtonWithText(fontName.c_str(), label))
|
|
||||||
{
|
|
||||||
resources = ResourceManager::FindAllOfType<GFX::Font>();
|
|
||||||
ImGui::OpenPopup("Font Menu");
|
|
||||||
}
|
|
||||||
|
|
||||||
return hasChanges;
|
|
||||||
}
|
|
||||||
} // namespace PlushieEngine
|
|
||||||
|
|
|
@ -1,35 +1,31 @@
|
||||||
/************************************************************************************//*!
|
/************************************************************************************//*!
|
||||||
\file EditorUI.h
|
\file SHEditorUI.h
|
||||||
\author Tng Kah Wei, kahwei.tng, 390009620 (50%)
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
\par email: kahwei.tng\@digipen.edu
|
\par email: kahwei.tng\@digipen.edu
|
||||||
\author Tay Yan Chong Clarence, t.yanchongclarence, 620008720 (50%)
|
|
||||||
\par email: t.yanchongclarence\@digipen.edu
|
\par email: t.yanchongclarence\@digipen.edu
|
||||||
\date Nov 7, 2021
|
\date Sep 27, 2022
|
||||||
\brief Defines a class that encapsulates the running of a Plushie Engine
|
\brief Defines a class that contains wrapper functions for ImGui.
|
||||||
application.
|
|
||||||
|
|
||||||
Copyright (C) 2021 DigiPen Institute of Technology.
|
Copyright (C) 2022 DigiPen Institute of Technology.
|
||||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||||
of DigiPen Institute of Technology is prohibited.
|
of DigiPen Institute of Technology is prohibited.
|
||||||
*//*************************************************************************************/
|
*//*************************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
// Platform Defines
|
|
||||||
#include "PlushieDefines.h"
|
|
||||||
// Standard Library
|
// Standard Library
|
||||||
#include <functional> // std::function
|
#include <functional> // std::function
|
||||||
#include <string> // std::string
|
#include <string> // std::string
|
||||||
|
// Project Includes
|
||||||
|
#include "Math/Vector/SHVec2.h"
|
||||||
|
#include "Math/Vector/SHVec3.h"
|
||||||
|
#include "Math/Vector/SHVec4.h"
|
||||||
|
#include "Math/SHMatrix.h"
|
||||||
|
|
||||||
#include "Core/Resource/Resource.h"
|
namespace SHADE
|
||||||
#include "Graphics/Color.h"
|
|
||||||
#include "Math/Vector2.h"
|
|
||||||
#include "Math/Vector3.h"
|
|
||||||
|
|
||||||
namespace Pls
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Static class that contains useful functions for Editor UI using ImGui.
|
/// Static class that contains useful functions for Editor UI using ImGui.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class PLS_API EditorUI final
|
class SH_API SHEditorUI final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
@ -81,7 +77,7 @@ namespace Pls
|
||||||
static void Unindent();
|
static void Unindent();
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Organisers */
|
/* ImGui Wrapper Functions - Organizers */
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a collapsing title header.
|
/// Creates a collapsing title header.
|
||||||
|
@ -91,6 +87,15 @@ namespace Pls
|
||||||
/// <param name="title">Label for the header.</param>
|
/// <param name="title">Label for the header.</param>
|
||||||
/// <returns>True if the header is open, false otherwise.</returns>
|
/// <returns>True if the header is open, false otherwise.</returns>
|
||||||
static bool CollapsingHeader(const std::string& title);
|
static bool CollapsingHeader(const std::string& title);
|
||||||
|
static void SameLine();
|
||||||
|
static void Separator();
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* ImGui Wrapper Functions - Menu */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
static bool BeginMenu(const std::string& label);
|
||||||
|
static bool BeginMenu(const std::string& label, const char* icon);
|
||||||
|
static void EndMenu();
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Pop Ups */
|
/* ImGui Wrapper Functions - Pop Ups */
|
||||||
|
@ -103,6 +108,7 @@ namespace Pls
|
||||||
/// <param name="label">Label used to identify this widget.</param>
|
/// <param name="label">Label used to identify this widget.</param>
|
||||||
/// <returns>Whether or not the pop up is open.</returns>
|
/// <returns>Whether or not the pop up is open.</returns>
|
||||||
static bool BeginPopup(const std::string& label);
|
static bool BeginPopup(const std::string& label);
|
||||||
|
static bool BeginPopupContextItem(const std::string& label);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks the end of a definition of a mini pop up that can show options.
|
/// Marks the end of a definition of a mini pop up that can show options.
|
||||||
/// <br/>
|
/// <br/>
|
||||||
|
@ -150,6 +156,8 @@ namespace Pls
|
||||||
/// <param name="title">Text to display.</param>
|
/// <param name="title">Text to display.</param>
|
||||||
/// <returns>True if button was pressed.</returns>
|
/// <returns>True if button was pressed.</returns>
|
||||||
static bool Button(const std::string& title);
|
static bool Button(const std::string& title);
|
||||||
|
static bool Selectable(const std::string& label);
|
||||||
|
static bool Selectable(const std::string& label, const char* icon);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a checkbox widget for boolean input.
|
/// Creates a checkbox widget for boolean input.
|
||||||
/// <br/>
|
/// <br/>
|
||||||
|
@ -227,7 +235,7 @@ namespace Pls
|
||||||
/// <param name="label">Label used to identify this widget.</param>
|
/// <param name="label">Label used to identify this widget.</param>
|
||||||
/// <param name="value">Reference to the variable to store the result.</param>
|
/// <param name="value">Reference to the variable to store the result.</param>
|
||||||
/// <returns>True if the value was changed.</returns>
|
/// <returns>True if the value was changed.</returns>
|
||||||
static bool InputVec2(const std::string& label, vec2& value);
|
static bool InputVec2(const std::string& label, SHVec2& value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a 3x double field widget for Vector3 input.
|
/// Creates a 3x double field widget for Vector3 input.
|
||||||
/// <br/>
|
/// <br/>
|
||||||
|
@ -236,7 +244,7 @@ namespace Pls
|
||||||
/// <param name="label">Label used to identify this widget.</param>
|
/// <param name="label">Label used to identify this widget.</param>
|
||||||
/// <param name="value">Reference to the variable to store the result.</param>
|
/// <param name="value">Reference to the variable to store the result.</param>
|
||||||
/// <returns>True if the value was changed.</returns>
|
/// <returns>True if the value was changed.</returns>
|
||||||
static bool InputVec3(const std::string& label, vec3& value);
|
static bool InputVec3(const std::string& label, SHVec3& value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a 3x double slider field widget for Vector3 input.
|
/// Creates a 3x double slider field widget for Vector3 input.
|
||||||
/// <br/>
|
/// <br/>
|
||||||
|
@ -247,16 +255,7 @@ namespace Pls
|
||||||
/// <param name="max">Maximum value of the slider.</param>
|
/// <param name="max">Maximum value of the slider.</param>
|
||||||
/// <param name="value">Reference to the variable to store the result.</param>
|
/// <param name="value">Reference to the variable to store the result.</param>
|
||||||
/// <returns>True if the value was changed.</returns>
|
/// <returns>True if the value was changed.</returns>
|
||||||
static bool InputSliderVec3(const std::string& label, double min, double max, vec3& value);
|
static bool InputSliderVec3(const std::string& label, double min, double max, SHVec3& value);
|
||||||
/// <summary>
|
|
||||||
/// Creates a colour field widget for Color input.
|
|
||||||
/// <br/>
|
|
||||||
/// Wraps up ImGui::ColorEdit4().
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="label">Label used to identify this widget.</param>
|
|
||||||
/// <param name="value">Reference to the variable to store the result.</param>
|
|
||||||
/// <returns>True if the value was changed.</returns>
|
|
||||||
static bool InputColor(const std::string& label, GFX::Color& value);
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a text field widget for string input.
|
/// Creates a text field widget for string input.
|
||||||
/// <br/>
|
/// <br/>
|
||||||
|
@ -274,8 +273,8 @@ namespace Pls
|
||||||
/// <param name="v">The reference to the value to modify.</param>
|
/// <param name="v">The reference to the value to modify.</param>
|
||||||
/// <param name="maxVal">The maximum value of the enum.</param>
|
/// <param name="maxVal">The maximum value of the enum.</param>
|
||||||
/// <param name="toStrFn">
|
/// <param name="toStrFn">
|
||||||
/// Conversion function from the type of enum
|
/// Conversion function from the type of enum to C-style string.
|
||||||
/// to C-style string.</param>
|
/// </param>
|
||||||
/// <returns>Whether the value was modified.</returns>
|
/// <returns>Whether the value was modified.</returns>
|
||||||
template<typename Enum>
|
template<typename Enum>
|
||||||
static bool InputEnumCombo(const std::string& label, Enum& v, int maxVal, std::function<const char*(Enum)> toStrFn);
|
static bool InputEnumCombo(const std::string& label, Enum& v, int maxVal, std::function<const char*(Enum)> toStrFn);
|
||||||
|
@ -287,26 +286,12 @@ namespace Pls
|
||||||
/// <param name="enumNames">Vector of names for each enumeration value.</param>
|
/// <param name="enumNames">Vector of names for each enumeration value.</param>
|
||||||
/// <returns>Whether the value was modified.</returns>
|
/// <returns>Whether the value was modified.</returns>
|
||||||
static bool InputEnumCombo(const std::string& label, int& v, const std::vector<std::string>& enumNames);
|
static bool InputEnumCombo(const std::string& label, int& v, const std::vector<std::string>& enumNames);
|
||||||
/// <summary>
|
|
||||||
/// Creates a drop down widget for texture selection.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="label">The name of the input.</param>
|
|
||||||
/// <param name="v">The reference to the value to modify.</param>
|
|
||||||
/// <returns>Whether the value was modified.</returns>
|
|
||||||
static bool InputTextureDropDown(const std::string& label, Resource::Snowflake& v);
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a drop down widget for font selection.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="label">The name of the input.</param>
|
|
||||||
/// <param name="v">The reference to the value to modify.</param>
|
|
||||||
/// <returns>Whether the value was modified.</returns>
|
|
||||||
static bool InputFontDropDown(const char* label, Resource::Snowflake& v);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Prevent instantiation of this static class
|
// Prevent instantiation of this static class
|
||||||
EditorUI() = delete;
|
SHEditorUI() = delete;
|
||||||
};
|
};
|
||||||
} // namespace PlushieEngine
|
}
|
||||||
|
|
||||||
#include "EditorUI.hpp"
|
#include "SHEditorUI.hpp"
|
|
@ -1,24 +1,26 @@
|
||||||
/************************************************************************************//*!
|
/************************************************************************************//*!
|
||||||
\file EditorUI.hpp
|
\file SHEditorUI.hpp
|
||||||
\author Tay Yan Chong Clarence, t.yanchongclarence, 620008720
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
\par email: t.yanchongclarence\@digipen.edu
|
\par email: kahwei.tng\@digipen.edu
|
||||||
\date Nov 8, 2021
|
\date Sep 27, 2022
|
||||||
\brief Contains the implementation of editor inspector template functions.
|
\brief Contains the implementation of editor inspector template functions.
|
||||||
|
|
||||||
Copyright (C) 2021 DigiPen Institute of Technology.
|
Copyright (C) 2022 DigiPen Institute of Technology.
|
||||||
Reproduction or disclosure of this file or its contents without the prior written consent
|
Reproduction or disclosure of this file or its contents without the prior written consent
|
||||||
of DigiPen Institute of Technology is prohibited.
|
of DigiPen Institute of Technology is prohibited.
|
||||||
*//*************************************************************************************/
|
*//*************************************************************************************/
|
||||||
// Primary Header
|
// Primary Header
|
||||||
#include "EditorUI.h"
|
#include "SHEditorUI.h"
|
||||||
|
// External Dependencies
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace Pls
|
namespace SHADE
|
||||||
{
|
{
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* ImGui Wrapper Functions - Widgets */
|
/* ImGui Wrapper Functions - Widgets */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
template<typename Enum>
|
template<typename Enum>
|
||||||
inline bool EditorUI::InputEnumCombo(const std::string& label, Enum& v, int maxVal, std::function<const char* (Enum)> toStrFn)
|
inline bool SHEditorUI::InputEnumCombo(const std::string& label, Enum& v, int maxVal, std::function<const char* (Enum)> toStrFn)
|
||||||
{
|
{
|
||||||
std::vector<Enum> values;
|
std::vector<Enum> values;
|
||||||
for (int i = 0; i <= maxVal; ++i)
|
for (int i = 0; i <= maxVal; ++i)
|
||||||
|
@ -46,4 +48,4 @@ namespace Pls
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
} // namespace PlushieEngine
|
}
|
||||||
|
|
|
@ -89,10 +89,6 @@ namespace SHADE
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlink events
|
|
||||||
/*ECS::OnEntityCreated -= onEntityCreate;
|
|
||||||
ECS::OnEntityDestroy -= onEntityDestroy;*/
|
|
||||||
|
|
||||||
// Clean up the CSharp Engine
|
// Clean up the CSharp Engine
|
||||||
csEngineExit();
|
csEngineExit();
|
||||||
|
|
||||||
|
@ -152,9 +148,9 @@ namespace SHADE
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* Script Editor Functions */
|
/* Script Editor Functions */
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void SHScriptEngine::RenderScriptsInInspector(const SHEntity& entity) const
|
void SHScriptEngine::RenderScriptsInInspector(EntityID entity) const
|
||||||
{
|
{
|
||||||
csEditorRenderScripts(entity.GetEID());
|
csEditorRenderScripts(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -397,13 +393,13 @@ namespace SHADE
|
||||||
DEFAULT_CSHARP_LIB_NAME,
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
DEFAULT_CSHARP_NAMESPACE + ".ScriptStore",
|
DEFAULT_CSHARP_NAMESPACE + ".ScriptStore",
|
||||||
"SerialiseScriptsYaml"
|
"SerialiseScriptsYaml"
|
||||||
);
|
);*/
|
||||||
csEditorRenderScripts = dotNet.GetFunctionPtr<CsScriptEditorFuncPtr>
|
csEditorRenderScripts = dotNet.GetFunctionPtr<CsScriptEditorFuncPtr>
|
||||||
(
|
(
|
||||||
DEFAULT_CSHARP_LIB_NAME,
|
DEFAULT_CSHARP_LIB_NAME,
|
||||||
DEFAULT_CSHARP_NAMESPACE + ".Editor",
|
DEFAULT_CSHARP_NAMESPACE + ".Editor",
|
||||||
"RenderScriptsInInspector"
|
"RenderScriptsInInspector"
|
||||||
);*/
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHScriptEngine::registerEvents()
|
void SHScriptEngine::registerEvents()
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace SHADE
|
||||||
/// rendering code.
|
/// rendering code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The Entity to render the Scripts of.</param>
|
/// <param name="entity">The Entity to render the Scripts of.</param>
|
||||||
void RenderScriptsInInspector(const SHEntity& entity) const;
|
void RenderScriptsInInspector(EntityID entity) const;
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
/* Static Utility Functions */
|
/* Static Utility Functions */
|
||||||
|
|
|
@ -17,15 +17,17 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
// Primary Header
|
// Primary Header
|
||||||
#include "Editor/Editor.hxx"
|
#include "Editor/Editor.hxx"
|
||||||
// External Dependencies
|
// External Dependencies
|
||||||
#include "Editor/SHEditorUI::.h"
|
#include "Editor/SHEditorUI.h"
|
||||||
// Project Headers
|
// Project Headers
|
||||||
#include "Components/Component.hxx"
|
#include "Components/Component.hxx"
|
||||||
#include "Scripts/ScriptStore.hxx"
|
#include "Scripts/ScriptStore.hxx"
|
||||||
#include "Utility/Convert.hxx"
|
#include "Utility/Convert.hxx"
|
||||||
#include "Utility/Debug.hxx"
|
#include "Utility/Debug.hxx"
|
||||||
#include "Serialisation/ReflectionUtilities.hxx"
|
#include "Serialisation/ReflectionUtilities.hxx"
|
||||||
|
#include "Editor/IconsMaterialDesign.h"
|
||||||
|
|
||||||
// Using Directives
|
// Using Directives
|
||||||
|
using namespace System;
|
||||||
using namespace System::Collections::Generic;
|
using namespace System::Collections::Generic;
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------*/
|
||||||
|
@ -46,7 +48,7 @@ using namespace System::Collections::Generic;
|
||||||
(field->FieldType == MANAGED_TYPE::typeid) \
|
(field->FieldType == MANAGED_TYPE::typeid) \
|
||||||
{ \
|
{ \
|
||||||
NATIVE_TYPE val = safe_cast<NATIVE_TYPE>(field->GetValue(object)); \
|
NATIVE_TYPE val = safe_cast<NATIVE_TYPE>(field->GetValue(object)); \
|
||||||
if (SHEditorUI::::FUNC(Convert::ToNative(field->Name), val)) \
|
if (SHEditorUI::FUNC(Convert::ToNative(field->Name), val)) \
|
||||||
{ \
|
{ \
|
||||||
field->SetValue(object, val); \
|
field->SetValue(object, val); \
|
||||||
} \
|
} \
|
||||||
|
@ -67,7 +69,7 @@ using namespace System::Collections::Generic;
|
||||||
(field->FieldType == MANAGED_TYPE::typeid) \
|
(field->FieldType == MANAGED_TYPE::typeid) \
|
||||||
{ \
|
{ \
|
||||||
NATIVE_TYPE val = Convert::ToNative(safe_cast<MANAGED_TYPE>(field->GetValue(object))); \
|
NATIVE_TYPE val = Convert::ToNative(safe_cast<MANAGED_TYPE>(field->GetValue(object))); \
|
||||||
if (SHEditorUI::::FUNC(Convert::ToNative(field->Name), val)) \
|
if (SHEditorUI::FUNC(Convert::ToNative(field->Name), val)) \
|
||||||
{ \
|
{ \
|
||||||
field->SetValue(object, Convert::ToCLI(val)); \
|
field->SetValue(object, Convert::ToCLI(val)); \
|
||||||
} \
|
} \
|
||||||
|
@ -99,10 +101,31 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render Add Script
|
// Render Add Script
|
||||||
//RenderScriptAddButton(entity);
|
RenderScriptAddButton(entity);
|
||||||
SAFE_NATIVE_CALL_END_N("SHADE_Managed.Editor.RenderScriptsInInspector")
|
SAFE_NATIVE_CALL_END_N("SHADE_Managed.Editor.RenderScriptsInInspector")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::RenderScriptAddButton(Entity entity)
|
||||||
|
{
|
||||||
|
// Get list of Scripts
|
||||||
|
auto scriptTypes = ScriptStore::GetAvailableScriptList();
|
||||||
|
|
||||||
|
// Define pop up
|
||||||
|
if (SHEditorUI::BeginMenu("Add Script", ICON_MD_LIBRARY_ADD))
|
||||||
|
{
|
||||||
|
for each (Type ^ type in scriptTypes)
|
||||||
|
{
|
||||||
|
if (SHEditorUI::Selectable(Convert::ToNative(type->Name)))
|
||||||
|
{
|
||||||
|
// Add the script
|
||||||
|
ScriptStore::AddScriptViaName(entity, type->Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SHEditorUI::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
/* Helper Functions */
|
/* Helper Functions */
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
@ -110,30 +133,23 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
// Constants
|
// Constants
|
||||||
const std::string LABEL = Convert::ToNative(script->GetType()->Name);
|
const std::string LABEL = Convert::ToNative(script->GetType()->Name);
|
||||||
const char* CONTEXT_MENU_ID = "scriptContextMenu";
|
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
SHEditorUI::::PushID(index);
|
SHEditorUI::PushID(index);
|
||||||
if (SHEditorUI::::CollapsingHeader(LABEL))
|
if (SHEditorUI::CollapsingHeader(LABEL))
|
||||||
{
|
{
|
||||||
SHEditorUI::::PushID(LABEL);
|
SHEditorUI::PushID(LABEL);
|
||||||
SHEditorUI::::Indent();
|
SHEditorUI::Indent();
|
||||||
{
|
{
|
||||||
// Define context menu
|
// Right Click Menu
|
||||||
if (SHEditorUI::::BeginPopup(CONTEXT_MENU_ID))
|
if (SHEditorUI::BeginPopupContextItem("scriptContextMenu"))
|
||||||
{
|
{
|
||||||
if (SHEditorUI::::MenuItem("Remove Script"))
|
if (SHEditorUI::Selectable("Delete Script", ICON_MD_DELETE))
|
||||||
{
|
{
|
||||||
// Mark script for removal
|
// Mark script for removal
|
||||||
ScriptStore::RemoveScript(entity, script);
|
ScriptStore::RemoveScript(entity, script);
|
||||||
}
|
}
|
||||||
SHEditorUI::::EndPopup();
|
SHEditorUI::EndPopup();
|
||||||
}
|
|
||||||
|
|
||||||
// Context menu button
|
|
||||||
if (SHEditorUI::::SmallButton("..."))
|
|
||||||
{
|
|
||||||
SHEditorUI::::OpenPopup(CONTEXT_MENU_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through all fields and output them
|
// Go through all fields and output them
|
||||||
|
@ -146,16 +162,16 @@ namespace SHADE
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Render the input field for this field
|
// Render the input field for this field
|
||||||
SHEditorUI::::PushID(LABEL + std::to_string(id++));
|
SHEditorUI::PushID(LABEL + std::to_string(id++));
|
||||||
renderFieldInInspector(field, script);
|
renderFieldInInspector(field, script);
|
||||||
SHEditorUI::::PopID();
|
SHEditorUI::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
SHEditorUI::::Unindent();
|
SHEditorUI::Unindent();
|
||||||
SHEditorUI::::PopID();
|
SHEditorUI::PopID();
|
||||||
}
|
}
|
||||||
SHEditorUI::::PopID();
|
SHEditorUI::PopID();
|
||||||
}
|
}
|
||||||
void Editor::renderFieldInInspector(Reflection::FieldInfo^ field, Object^ object)
|
void Editor::renderFieldInInspector(Reflection::FieldInfo^ field, Object^ object)
|
||||||
{
|
{
|
||||||
|
@ -180,13 +196,13 @@ namespace SHADE
|
||||||
}
|
}
|
||||||
|
|
||||||
int val = safe_cast<int>(field->GetValue(object));
|
int val = safe_cast<int>(field->GetValue(object));
|
||||||
if (SHEditorUI::::InputEnumCombo(Convert::ToNative(field->Name), val, nativeEnumNames))
|
if (SHEditorUI::InputEnumCombo(Convert::ToNative(field->Name), val, nativeEnumNames))
|
||||||
{
|
{
|
||||||
field->SetValue(object, val);
|
field->SetValue(object, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if RENDER_FIELD_CASTED(Vector2, vec2, InputVec2)
|
else if RENDER_FIELD_CASTED(Vector2, SHVec2, InputVec2)
|
||||||
else if RENDER_FIELD_CASTED(Vector3, vec3, InputVec3)
|
else if RENDER_FIELD_CASTED(Vector3, SHVec3, InputVec3)
|
||||||
else if (field->FieldType == String::typeid)
|
else if (field->FieldType == String::typeid)
|
||||||
{
|
{
|
||||||
// Prevent issues where String^ is null due to being empty
|
// Prevent issues where String^ is null due to being empty
|
||||||
|
@ -198,7 +214,7 @@ namespace SHADE
|
||||||
|
|
||||||
// Actual Field
|
// Actual Field
|
||||||
std::string val = Convert::ToNative(stringVal);
|
std::string val = Convert::ToNative(stringVal);
|
||||||
if (SHEditorUI::::InputTextField(Convert::ToNative(field->Name), val))
|
if (SHEditorUI::InputTextField(Convert::ToNative(field->Name), val))
|
||||||
{
|
{
|
||||||
field->SetValue(object, Convert::ToCLI(val));
|
field->SetValue(object, Convert::ToCLI(val));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,12 @@ namespace SHADE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">The Entity to render the Scripts of.</param>
|
/// <param name="entity">The Entity to render the Scripts of.</param>
|
||||||
static void RenderScriptsInInspector(Entity entity);
|
static void RenderScriptsInInspector(Entity entity);
|
||||||
|
/// <summary>
|
||||||
|
/// Renders a dropdown button that allows for the addition of PlushieScripts
|
||||||
|
/// onto the specified Entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The Entity to add PlushieScripts to.</param>
|
||||||
|
static void RenderScriptAddButton(Entity entity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -2,6 +2,9 @@ using SHADE;
|
||||||
|
|
||||||
public class TestScript : Script
|
public class TestScript : Script
|
||||||
{
|
{
|
||||||
|
public double Speed = 1.0;
|
||||||
|
public Vector3 ATestVector;
|
||||||
|
public bool ABoolean;
|
||||||
private Transform Transform;
|
private Transform Transform;
|
||||||
private double time = 0.0;
|
private double time = 0.0;
|
||||||
public TestScript(GameObject gameObj) : base(gameObj) {}
|
public TestScript(GameObject gameObj) : base(gameObj) {}
|
||||||
|
@ -21,7 +24,7 @@ public class TestScript : Script
|
||||||
}
|
}
|
||||||
protected override void update()
|
protected override void update()
|
||||||
{
|
{
|
||||||
time += 0.16;
|
time += Speed * 0.16;
|
||||||
Transform.GlobalPosition = new Vector3(System.Math.Sin(time), System.Math.Cos(time), 0.0f);
|
Transform.GlobalPosition = new Vector3(System.Math.Sin(time), System.Math.Cos(time), 0.0f);
|
||||||
}
|
}
|
||||||
protected override void onDestroy()
|
protected override void onDestroy()
|
||||||
|
|
Loading…
Reference in New Issue