Can now edit text of text nodes and fetch any other nodes in the DOM from ID

This commit is contained in:
antopilo
2024-09-13 01:25:41 -04:00
parent 3b148b76c4
commit 4c76e9e493
2 changed files with 19 additions and 14 deletions

View File

@@ -18,12 +18,12 @@ UUID UUIDFromString(const std::string& input)
return std::stoull(input);
}
uint64_t FindChildByIDIcall(const Coral::String& canvasUUID, const Coral::String& id, const Coral::String& id2)
Coral::String FindChildByIDIcall(const Coral::String& canvasUUID, const Coral::String& id, const Coral::String& id2)
{
if (!ResourceManager::IsResourceLoaded(UUIDFromString(canvasUUID)))
{
Logger::Log("Error finding child, canvas is not loaded.", ".net/ui", CRITICAL);
return UUID(0);
return Coral::String::New(std::to_string(0));
}
Ref<UIResource> uiResource = ResourceManager::GetResource<UIResource>(UUIDFromString(canvasUUID));
@@ -32,13 +32,13 @@ uint64_t FindChildByIDIcall(const Coral::String& canvasUUID, const Coral::String
searchNode != nullptr)
{
Ref<Node> foundNode;
if (foundNode->FindChildByID(id2, foundNode))
if (searchNode->FindChildByID(id2, foundNode))
{
return foundNode->GetScriptingID();
return Coral::String::New(std::to_string(foundNode->GetScriptingID()));
}
}
return UUID(0);
return Coral::String::New(std::to_string(0));
}
bool HasNativeInstanceICall(const Coral::String& canvasUUID, const Coral::String& nodeUUID, const Coral::String& nodeUUID2)

View File

@@ -71,13 +71,20 @@ namespace Nuake.Net
public class Node
{
internal static unsafe delegate*<NativeString, NativeString, NativeString, NativeString, ulong> FindChildByIDICall;
internal static unsafe delegate*<NativeString, NativeString, NativeString, NativeString> FindChildByIDICall;
internal static unsafe delegate*<NativeString, NativeString, NativeString, bool> HasNativeInstanceICall;
internal static unsafe delegate*<NativeString, NativeString, NativeInstance<Node>> GetNativeInstanceNodeICall;
public string UUID;
public string CanvasUUID;
public Node() { }
public Node(string handle, string canvasHandle )
{
UUID = handle;
CanvasUUID = canvasHandle;
}
public string ID { get; set; } = "";
public List<string> Classes { get; set; } = new();
@@ -94,13 +101,13 @@ namespace Nuake.Net
{
Engine.Log("Calling FindChildByIDICall with params: " + CanvasUUID + " , " + UUID + " , " + id);
ulong uuid = FindChildByIDICall(CanvasUUID, CanvasUUID, UUID, id);
if (uuid == 0)
NativeString uuid = FindChildByIDICall(CanvasUUID, UUID, id);
if (uuid.ToString() == "0")
{
throw new Exception("Node not found");
}
Node? newNode = null;
T? newNode = null;
//if (HasNativeInstanceICall(CanvasUUID, CanvasUUID, UUID))
//{
// NativeInstance<Node> handle;
@@ -110,11 +117,9 @@ namespace Nuake.Net
if(newNode == null)
{
newNode = new Node()
{
UUID = uuid.ToString(),
CanvasUUID = CanvasUUID
};
newNode = Activator.CreateInstance<T>();
newNode.UUID = uuid;
newNode.CanvasUUID = CanvasUUID;
return newNode as T;
}