List Serialization and Editor for Scripts #193
|
@ -18,12 +18,9 @@ of DigiPen Institute of Technology is prohibited.
|
|||
#include "Editor/Editor.hxx"
|
||||
// STL Includes
|
||||
#include <memory>
|
||||
// External Dependencies
|
||||
#include "Editor/SHEditorUI.h"
|
||||
// Project Headers
|
||||
#include "Components/Component.hxx"
|
||||
#include "Scripts/ScriptStore.hxx"
|
||||
#include "Utility/Convert.hxx"
|
||||
#include "Utility/Debug.hxx"
|
||||
#include "Serialisation/ReflectionUtilities.hxx"
|
||||
#include "Editor/IconsMaterialDesign.h"
|
||||
|
@ -163,9 +160,11 @@ namespace SHADE
|
|||
renderFieldInInspector<int , Byte >(field, object, SHEditorUI::InputInt , &isHovered) ||
|
||||
renderFieldInInspector<bool , bool >(field, object, SHEditorUI::InputCheckbox, &isHovered) ||
|
||||
renderFieldInInspector<float , float >(field, object, SHEditorUI::InputFloat , &isHovered) ||
|
||||
renderFieldInInspector<double, double >(field, object, SHEditorUI::InputDouble , &isHovered) ||
|
||||
renderFieldInInspector<SHVec2, Vector2>(field, object, SHEditorUI::InputVec2 , &isHovered) ||
|
||||
renderFieldInInspector<SHVec3, Vector3>(field, object, SHEditorUI::InputVec3 , &isHovered);
|
||||
renderFieldInInspector<double , double >(field, object, SHEditorUI::InputDouble , &isHovered) ||
|
||||
renderFieldInInspector<SHVec2 , Vector2 >(field, object, SHEditorUI::InputVec2 , &isHovered) ||
|
||||
renderFieldInInspector<SHVec3 , Vector3 >(field, object, SHEditorUI::InputVec3 , &isHovered) ||
|
||||
renderFieldInInspector<uint32_t , GameObject >(field, object, nullptr , &isHovered) ||
|
||||
renderFieldInInspector<std::string, System::String^>(field, object, nullptr , &isHovered);
|
||||
|
||||
if (!MODIFIED_PRIMITIVE)
|
||||
{
|
||||
|
@ -187,40 +186,6 @@ namespace SHADE
|
|||
registerUndoAction(object, field, val, oldVal);
|
||||
}
|
||||
}
|
||||
else if (field->FieldType == String::typeid)
|
||||
{
|
||||
// Prevent issues where String^ is null due to being empty
|
||||
String^ stringVal = safe_cast<String^>(field->GetValue(object));
|
||||
if (stringVal == nullptr)
|
||||
{
|
||||
stringVal = "";
|
||||
}
|
||||
|
||||
// Actual Field
|
||||
std::string val = Convert::ToNative(stringVal);
|
||||
std::string oldVal = val;
|
||||
if (SHEditorUI::InputTextField(Convert::ToNative(field->Name), val, &isHovered))
|
||||
{
|
||||
field->SetValue(object, Convert::ToCLI(val));
|
||||
registerUndoAction(object, field, Convert::ToCLI(val), Convert::ToCLI(oldVal));
|
||||
}
|
||||
}
|
||||
else if (field->FieldType == GameObject::typeid)
|
||||
{
|
||||
GameObject gameObj = safe_cast<GameObject>(field->GetValue(object));
|
||||
uint32_t entityId = gameObj.GetEntity();
|
||||
if (SHEditorUI::InputGameObjectField(Convert::ToNative(field->Name), entityId, &isHovered, !gameObj))
|
||||
{
|
||||
GameObject newVal = GameObject(entityId);
|
||||
if (entityId != MAX_EID)
|
||||
{
|
||||
// Null GameObject set
|
||||
newVal = GameObject(entityId);
|
||||
}
|
||||
field->SetValue(object, newVal);
|
||||
registerUndoAction(object, field, newVal, gameObj);
|
||||
}
|
||||
}
|
||||
// Any List
|
||||
else if (field->FieldType->IsGenericType && field->FieldType->GetGenericTypeDefinition() == System::Collections::Generic::List<int>::typeid->GetGenericTypeDefinition())
|
||||
{
|
||||
|
|
|
@ -16,6 +16,10 @@ of DigiPen Institute of Technology is prohibited.
|
|||
|
||||
// Primary Include
|
||||
#include "Editor.hxx"
|
||||
// External Dependencies
|
||||
#include "Editor/SHEditorUI.h"
|
||||
// Project Includes
|
||||
#include "Utility/Convert.hxx"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
|
@ -102,6 +106,41 @@ namespace SHADE
|
|||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
template<>
|
||||
bool Editor::renderFieldInInspector<std::string, System::String^>(const std::string& fieldName, System::String^% managedVal, EditorFieldFunc<std::string>, bool* isHovered, RangeAttribute^)
|
||||
{
|
||||
// Prevent issues where String^ is null due to being empty
|
||||
if (managedVal == nullptr)
|
||||
managedVal = "";
|
||||
|
||||
// Actual Field
|
||||
std::string val = Convert::ToNative(managedVal);
|
||||
if (SHEditorUI::InputTextField(fieldName, val, isHovered))
|
||||
{
|
||||
managedVal = Convert::ToCLI(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
template<>
|
||||
bool Editor::renderFieldInInspector<uint32_t, GameObject>(const std::string& fieldName, GameObject% managedVal, EditorFieldFunc<uint32_t>, bool* isHovered, RangeAttribute^)
|
||||
{
|
||||
uint32_t entityId = managedVal.GetEntity();
|
||||
if (SHEditorUI::InputGameObjectField(fieldName, entityId, isHovered, !managedVal))
|
||||
{
|
||||
GameObject newVal = GameObject(entityId);
|
||||
if (entityId != MAX_EID)
|
||||
{
|
||||
// Null GameObject set
|
||||
newVal = GameObject(entityId);
|
||||
}
|
||||
managedVal = newVal;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue