在管道通信基础上,可进行宿主程序与Godot的双向通信。
先拿属性信息试试手。
static UnicodeString command = "Book.position";
if (InputQuery("输入窗口", "请输入待获取的属性信息", command)) {
TDrStream_Get drGet(THelper::String::GetStringAt(command, L".", 0).Trim(),
THelper::String::GetStringAt(command, L".", 1).Trim());
TDllStream ds;
ds << drGet;
PipeStreamServer->WritePipe(ds, 1000);
}
List *p_list = new List;
bool p_reversed = true;
destObject->get_property_list(p_list, p_reversed);
cofs << "OK";
for (List::Iterator it = p_list->begin(); it != p_list->end(); ++it) {
String content = it->name.ptr();
if (it->class_name.operator String().is_empty() == false)
content += str_format(U"[%s]", it->class_name.operator String().utf8().get_data());
Variant value = destObject->get(it->name);
content += str_format(U" = %s", value.operator String().utf8().get_data());
cofs << content;
}
delete p_list;
132. 13:20:29:829 > 【主线程】 > [Pipe.发送] > 发送数据中内容[DrGraph.28: Request - wait 1000 ms]:
[int]类型 > 值 = 2
[UnicodeString]类型 > 值 = root
[UnicodeString]类型 > 值 = propertyNames
133. 13:20:30:015 > 【主线程】 > [Pipe.Read] > 发送数据[DrGraph.28: Request - wait 1000 ms]成功返回 1837 字节... > PIPE响应中内容[godot -> DrGraph.28: Response - no return]:
[int]类型 > 值 = 3
[UnicodeString]类型 > 值 = OK
[UnicodeString]类型 > 值 = book.gd =
[UnicodeString]类型 > 值 = singlePage = false
[UnicodeString]类型 > 值 = middleBarWidth = 0
[UnicodeString]类型 > 值 = shader_rect[ColorRect] = ShaderRect:
[UnicodeString]类型 > 值 = currentPageMode = false
[UnicodeString]类型 > 值 = currentAreaType = -2
[UnicodeString]类型 > 值 = triggleAreaMoment = 484887
[UnicodeString]类型 > 值 = currentPageIndex = 30
[UnicodeString]类型 > 值 = pageCount = 100
[UnicodeString]类型 > 值 = pageImgPath = res://Pages/
[UnicodeString]类型 > 值 = leftMouseDownMoment = 0
[UnicodeString]类型 > 值 = underAutoTurnPage = false
[UnicodeString]类型 > 值 = leftMouseDownPos = (0, 0)
[UnicodeString]类型 > 值 = dllStream[DllStream] =
[UnicodeString]类型 > 值 = AutoTurnObject =
[UnicodeString]类型 > 值 = Node2D =
[UnicodeString]类型 > 值 = Transform =
[UnicodeString]类型 > 值 = position = (0, 0)
[UnicodeString]类型 > 值 = rotation = 0
[UnicodeString]类型 > 值 = rotation_degrees = 0
[UnicodeString]类型 > 值 = scale = (1, 1)
[UnicodeString]类型 > 值 = skew = 0
[UnicodeString]类型 > 值 = transform = [X: (1, 0), Y: (0, 1), O: (0, 0)]
[UnicodeString]类型 > 值 = global_position = (0, 0)
[UnicodeString]类型 > 值 = global_rotation = 0
[UnicodeString]类型 > 值 = global_rotation_degrees = 0
[UnicodeString]类型 > 值 = global_scale = (1, 1)
[UnicodeString]类型 > 值 = global_skew = 0
[UnicodeString]类型 > 值 = global_transform = [X: (1, 0), Y: (0, 1), O: (0, 0)]
[UnicodeString]类型 > 值 = CanvasItem =
[UnicodeString]类型 > 值 = Visibility =
[UnicodeString]类型 > 值 = visible = true
[UnicodeString]类型 > 值 = modulate = (1, 1, 1, 1)
[UnicodeString]类型 > 值 = self_modulate = (1, 1, 1, 1)
[UnicodeString]类型 > 值 = show_behind_parent = false
[UnicodeString]类型 > 值 = top_level = false
[UnicodeString]类型 > 值 = clip_children = 0
[UnicodeString]类型 > 值 = light_mask = 1
[UnicodeString]类型 > 值 = visibility_layer = 1
[UnicodeString]类型 > 值 = Ordering =
[UnicodeString]类型 > 值 = z_index = 0
[UnicodeString]类型 > 值 = z_as_relative = true
[UnicodeString]类型 > 值 = y_sort_enabled = false
[UnicodeString]类型 > 值 = Texture =
[UnicodeString]类型 > 值 = texture_filter = 0
[UnicodeString]类型 > 值 = texture_repeat = 0
[UnicodeString]类型 > 值 = Material =
[UnicodeString]类型 > 值 = material[CanvasItemMaterial,ShaderMaterial] =
这已具备RTTI的雏形。