mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Implemented Entity and Component Drop-Targets and added Name property for entities
- Also fixed non generic GetComponent - Use UUID as Drag-Drop value for entities - Removed unused methods from ComponentEditWindow - Started a marginally type-safe version of ImGui.Payload
This commit is contained in:
@@ -16,6 +16,15 @@ namespace ImGui
|
||||
{
|
||||
using internal GlitchyEngine.Math;
|
||||
|
||||
struct Payload<T> where T : struct
|
||||
{
|
||||
public ImGui.Payload* Payload;
|
||||
|
||||
public T Data => *(T*)Payload.Data;
|
||||
|
||||
public static ImGui.Payload* operator ->(Payload<T> self) => self.Payload;
|
||||
}
|
||||
|
||||
extension ImGui
|
||||
{
|
||||
extension Vec2
|
||||
@@ -30,6 +39,21 @@ namespace ImGui
|
||||
public static explicit operator Vec4(float4 v) => .(v.X, v.Y, v.Z, v.W);
|
||||
}
|
||||
|
||||
public static Payload<T>? AcceptDragDropPayload<T>(char8* type, DragDropFlags flags = .None) where T : struct
|
||||
{
|
||||
ImGui.Payload* payload = ImGui.AcceptDragDropPayload(type, flags);
|
||||
|
||||
if (payload == null)
|
||||
return null;
|
||||
|
||||
Log.ClientLogger.AssertDebug(payload.DataSize >= sizeof(T));
|
||||
|
||||
var typedPayload = Payload<T>();
|
||||
typedPayload.Payload = payload;
|
||||
|
||||
return typedPayload;
|
||||
}
|
||||
|
||||
/*public static bool IsItemJustDeactivated()
|
||||
{
|
||||
return IsItemDeactivatedAfterEdit();
|
||||
|
||||
@@ -300,6 +300,28 @@ static class ScriptGlue
|
||||
entity.RemoveComponent<ScriptComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
[RegisterCall("ScriptGlue::Entity_GetName")]
|
||||
static MonoString* Entity_GetName(UUID entityId)
|
||||
{
|
||||
Entity entity = ScriptEngine.Context.GetEntityByID(entityId);
|
||||
|
||||
MonoString* name = Mono.mono_string_new_len(ScriptEngine.[Friend]s_AppDomain, entity.Name.Ptr, (.)entity.Name.Length);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
[RegisterCall("ScriptGlue::Entity_SetName")]
|
||||
static void Entity_SetName(UUID entityId, MonoString* name)
|
||||
{
|
||||
Entity entity = ScriptEngine.Context.GetEntityByID(entityId);
|
||||
|
||||
char8* rawName = Mono.mono_string_to_utf8(name);
|
||||
|
||||
entity.Name = StringView(rawName);
|
||||
|
||||
Mono.mono_free(rawName);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user