#include "UIReference.h" #include "Block.h" #include "Entity.h" UIReference::UIReference() : Framework::ReferenceCounter() {} UITargetReference::UITargetReference() : UIReference() {} Framework::Text UITargetReference::getReferenceId( Framework::Either zTarget, Entity* zActor) const { Framework::Text result(""); if (zTarget.isA()) { result.append() << zTarget.getA()->getDimensionId() << "," << zTarget.getA()->getPos().x << "," << zTarget.getA()->getPos().y << "," << zTarget.getA()->getPos().z; } else { result.append() << zTarget.getB()->getId(); } return result; } UITargetComponentReference::UITargetComponentReference() : UIReference(), componentIndex(0) {} Framework::Text UITargetComponentReference::getReferenceId( Framework::Either zTarget, Entity* zActor) const { Framework::Text result(""); if (zTarget.isA()) { result.append() << zTarget.getA()->getDimensionId() << "," << zTarget.getA()->getPos().x << "," << zTarget.getA()->getPos().y << "," << zTarget.getA()->getPos().z; } else { result.append() << zTarget.getB()->getId(); } result.append() << ":" << componentIndex; return result; } UITActorReference::UITActorReference() : UIReference() {} Framework::Text UITActorReference::getReferenceId( Framework::Either zTarget, Entity* zActor) const { return Framework::Text(zActor->getId()); } UITargetReferenceFactory::UITargetReferenceFactory() : SubTypeFactory() {} JSONObjectValidationBuilder* UITargetReferenceFactory::addToValidator( JSONObjectValidationBuilder* builder) const { return builder; } UITargetReference* UITargetReferenceFactory::fromJson( Framework::JSON::JSONObject* zJson) const { return new UITargetReference(); } Framework::JSON::JSONObject* UITargetReferenceFactory::toJsonObject( UITargetReference* zObject) const { return new Framework::JSON::JSONObject(); } const char* UITargetReferenceFactory::getTypeToken() const { return "target"; } UITActorReferenceFactory::UITActorReferenceFactory() : SubTypeFactory() {} JSONObjectValidationBuilder* UITActorReferenceFactory::addToValidator( JSONObjectValidationBuilder* builder) const { return builder; } UITActorReference* UITActorReferenceFactory::fromJson( Framework::JSON::JSONObject* zJson) const { return new UITActorReference(); } Framework::JSON::JSONObject* UITActorReferenceFactory::toJsonObject( UITActorReference* zObject) const { return new Framework::JSON::JSONObject(); } const char* UITActorReferenceFactory::getTypeToken() const { return "actor"; } UITargetComponentReferenceFactory::UITargetComponentReferenceFactory() : SubTypeFactory() {} JSONObjectValidationBuilder* UITargetComponentReferenceFactory::addToValidator( JSONObjectValidationBuilder* builder) const { return builder->withRequiredNumber("componentIndex") ->whichIsGreaterOrEqual(0) ->finishNumber(); } UITargetComponentReference* UITargetComponentReferenceFactory::fromJson( Framework::JSON::JSONObject* zJson) const { UITargetComponentReference* result = new UITargetComponentReference(); result->componentIndex = (int)zJson->zValue("componentIndex")->asNumber()->getNumber(); return result; } Framework::JSON::JSONObject* UITargetComponentReferenceFactory::toJsonObject( UITargetComponentReference* zObject) const { Framework::JSON::JSONObject* result = new Framework::JSON::JSONObject(); result->addValue("componentIndex", new Framework::JSON::JSONNumber(zObject->componentIndex)); return result; } const char* UITargetComponentReferenceFactory::getTypeToken() const { return "targetComponent"; }