void PropertyChangeAction::SetProperties(Vector<DataNode>& values) { Vector<SceneEditableObject*> objects = objectsIds.Select<SceneEditableObject*>([](SceneUID id) { return o2Scene.GetEditableObjectByID(id); }); const Type* componentType = nullptr; String finalPropertyPath = propertyPath; if (propertyPath.StartsWith("component:")) { int c = ((String)"component:").Length(); String typeName = propertyPath.SubStr(c, propertyPath.Find('/', c)); c += typeName.Length() + 1; finalPropertyPath.Erase(0, c); componentType = o2Reflection.GetType(typeName); } int i = 0; for (auto object : objects) { if (!object) { continue; i++; } FieldInfo* fi = nullptr; void* ptr = nullptr; if (componentType) { if (Actor* actor = dynamic_cast<Actor*>(object)) { Component* component = actor->GetComponent(componentType); if (component) ptr = component->GetType().GetFieldPtr(component, finalPropertyPath, fi); } } else { auto objectType = dynamic_cast<const ObjectType*>(&object->GetType()); if (objectType) { void* realTypeObject = objectType->DynamicCastFromIObject(dynamic_cast<IObject*>(object)); ptr = objectType->GetFieldPtr(realTypeObject, finalPropertyPath, fi); } } if (fi && ptr) fi->Deserialize(ptr, values[i]); object->OnChanged(); i++; } }
// get value into a wxVariant bool wxDBase::GetValueByRow(wxVariant* var, unsigned int row, unsigned int col) { bool ok = SetPosition(row); // unconst if (ok) switch (GetFieldType(GetFieldPtr(col))) { case DBF_DATA_TYPE_INTEGER: { long n; ok = Read(col, &n); if (ok) var->operator=(n); break; } case DBF_DATA_TYPE_FLOAT : { double n; ok = Read(col, &n); if (ok) var->operator=(n); break; } case DBF_DATA_TYPE_DATE : { wxDateTime n; ok = Read(col, &n); if (ok) var->operator=(n); break; } case DBF_DATA_TYPE_BOOLEAN: { bool n; ok = Read(col, &n); if (ok) var->operator=(n); break; } case DBF_DATA_TYPE_MEMO : case DBF_DATA_TYPE_CHAR : { wxString str; /*ok = */Read(col, &str); if (ok) { var->operator=(str); } break; } case DBF_DATA_TYPE_UNKNOWN: default: ok = false; break; } return ok; }
wxString wxDBase::GetColType(unsigned int col) { switch (GetFieldType(GetFieldPtr(col))) { case DBF_DATA_TYPE_INTEGER: return wxT("long"); case DBF_DATA_TYPE_FLOAT : return wxT("double"); case DBF_DATA_TYPE_DATE : return wxT("datetime"); case DBF_DATA_TYPE_BOOLEAN: return wxT("bool"); case DBF_DATA_TYPE_MEMO : case DBF_DATA_TYPE_CHAR : case DBF_DATA_TYPE_UNKNOWN: default: return wxT("string"); } }