Variant ReflectedGroupItem::getData( int column, size_t roleId ) const { auto obj = getRootObject(); if (obj == nullptr) { return Variant(); } auto definition = getDefinition(); if (definition == nullptr) { return Variant(); } if (roleId == IndexPathRole::roleId_) { if (parent_ == nullptr) { return displayName_; } std::string parentIndexPath = parent_->getPath(); return parentIndexPath + displayName_; } else if (roleId == ObjectRole::roleId_) { return getObject();; } else if (roleId == RootObjectRole::roleId_) { return getRootObject(); } if (roleId == ValueRole::roleId_) { auto collectionHolder = std::make_shared< CollectionHolder< Variants > >(); Variants& childValues_ = collectionHolder->storage(); getChildValues(childValues_); return std::move( Collection( collectionHolder ) ); } return Variant(); }
ObjectHandle ReflectedCollectionEraseCommand::execute(const ObjectHandle& arguments) const { auto commandArgs = arguments.getBase<ReflectedCollectionEraseCommandParameters>(); auto objManager = definitionManager_.getObjectManager(); assert(objManager != nullptr); auto object = objManager->getObject(commandArgs->id_); if (!object.isValid()) { return CommandErrorCode::INVALID_ARGUMENTS; } auto property = object.getDefinition(definitionManager_)->bindProperty(commandArgs->path_.c_str(), object); if (property.isValid() == false) { return CommandErrorCode::INVALID_ARGUMENTS; } Collection collection; auto value = property.getValue(); if (!value.tryCast(collection)) { return CommandErrorCode::INVALID_ARGUMENTS; } auto it = collection.find(commandArgs->key_); if (it == collection.end()) { return CommandErrorCode::INVALID_VALUE; } commandArgs->value_ = *it; commandArgs->erased_ = property.erase(commandArgs->key_); if (!commandArgs->erased_) { return CommandErrorCode::INVALID_VALUE; } return nullptr; }
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(const Vector3 &location, const Color &base) { AtmosphereDefinition *definition = getDefinition(); AtmosphereResult result; // Get base perspective switch (definition->model) { case AtmosphereDefinition::ATMOSPHERE_MODEL_BRUNETON: result = model->applyAerialPerspective(location, base); break; default: ; } // Apply god rays ponderation result.inscattering = parent->getGodRaysSampler()->apply(COLOR_BLACK, result.inscattering, location); // Apply weather effects _applyWeatherEffects(definition, &result); return result; }
bool DivNode::isChildTypeAllowed(const string& sType) { return getDefinition()->isChildAllowed(sType); }
bool BaseGenericObject::add(const char* name, const Variant& value, MetaData metadata, bool enableNotification) { return !getDefinition()->bindProperty(name, getDerivedType()).isValid() && addProperty(name, value, std::move(metadata), enableNotification); }
Vector3 BaseAtmosphereRenderer::getSunDirection(bool) const { return getDefinition()->childSun()->getDirection(); }
AtmosphereResult SoftwareBrunetonAtmosphereRenderer::getSkyColor(const Vector3 &direction) { AtmosphereDefinition *definition; Vector3 sun_direction, sun_position, camera_location; Color base; definition = getDefinition(); camera_location = parent->getCameraLocation(VECTOR_ZERO); sun_direction = getSunDirection(); Vector3 direction_norm = direction.normalize(); sun_position = sun_direction.scale(SUN_DISTANCE_SCALED); base = COLOR_BLACK; // Get night sky base = base.add(parent->getNightSky()->getColor(camera_location.y, direction_norm)); // Get sun shape /*if (v3Dot(sun_direction, direction) >= 0) { double sun_radius = definition->sun_radius * SUN_RADIUS_SCALED * 5.0; // FIXME Why should we multiply by 5 ? Vector3 hit1, hit2; int hits = euclidRayIntersectSphere(camera_location, direction, sun_position, sun_radius, &hit1, &hit2); if (hits > 1) { double dist = v3Norm(v3Sub(hit2, hit1)) / sun_radius; // distance between intersection points (relative to radius) Color sun_color = definition->sun_color; sun_color.r *= 100.0; sun_color.g *= 100.0; sun_color.b *= 100.0; if (dist <= 0.05) { sun_color.r *= 1.0 - dist / 0.05; sun_color.g *= 1.0 - dist / 0.05; sun_color.b *= 1.0 - dist / 0.05; } base = sun_color; } }*/ // Get scattering AtmosphereResult result; Vector3 location = camera_location.add(direction_norm.scale(6421.0)); switch (definition->model) { case AtmosphereDefinition::ATMOSPHERE_MODEL_BRUNETON: result = model->getSkyColor(camera_location, direction_norm, sun_position, base); break; default: result = BaseAtmosphereRenderer::applyAerialPerspective(location, result.base); } // Apply god rays ponderation result.inscattering = parent->getGodRaysSampler()->apply(COLOR_BLACK, result.inscattering, location); // Apply weather effects _applyWeatherEffects(definition, &result); return result; }
string FieldSet::definitionHash() { string s = getDefinition(); return generateSHA(s); }
void TalkyUnit::onUserDataType(string name) { Definition* definition = getDefinition(name); currentDeclarationType = DLT_USER; userTypeDefinition = definition; }
void TalkyUnit::onNewUserArray(string name) { Definition* definition = getDefinition(name); currentDeclarationType = DLT_ARRAY; userTypeDefinition = definition; }
ActionsManager::ActionDefinition::State Action::getState() const { ActionsManager::ActionDefinition::State state; state.statusTip = statusTip(); state.toolTip = toolTip(); state.text = (m_flags.testFlag(IsOverridingTextFlag) ? QCoreApplication::translate("actions", m_overrideText.toUtf8().constData()) : getDefinition().getText()); state.icon = icon(); state.isEnabled = isEnabled(); state.isChecked = isChecked(); return state; }
/** * @brief Grammar::addRule Adds the specified relationship by creating and adding a pair in the multimap * @param define This is the LHS of the definition. This is what is being defined, i.e. the key * @param rule This is the RHS. This is the definition, i.e. the value * NOTE: This will take care of the empty sentence definition */ void Grammar::addRule(const GrammarPhrase &define, const GPlist &rule){ std::vector<GPlist> g = getDefinition(define); if(g.empty()) _grammar.erase(define); _grammar.insert(mmap::value_type(define,rule)); }
string FieldSet::definitionHash() { return generateSHA(getDefinition()); }
DefinitionsPtr JsonSchema::readRef(std::string m_ref) { std::string delimiter1 = "#"; std::string delimiter2 = "/"; std::string fileName; if (! m_ref.empty()) { std::size_t pos = m_ref.find(delimiter1); if ( (pos = m_ref.find(delimiter1)) != std::string::npos) { fileName = m_ref.substr(0, pos); m_ref.erase(0, pos); } m_ref.erase(0, delimiter1 .length()); std::string defName; if (! m_ref.empty()) { m_ref.erase(0, delimiter2 .length()); std::string keyName; if ( (pos = m_ref.find(delimiter2)) != std::string::npos) { keyName = m_ref.substr(0, pos); m_ref.erase(0, pos + delimiter2.length()); if (keyName == "definitions") { if ( (pos = m_ref.find(delimiter2)) != std::string::npos) { defName = m_ref.substr(0, pos); } else if (! m_ref.empty()) { defName = m_ref; } } } } if (!fileName.empty()) { if (!(defName.empty())) { cJSON *m_json = m_includeResolver->readToJson(fileName); JsonSchemaPtr Refparser = std::make_shared<JsonSchema>(m_json, m_includeResolver); DefinitionsPtr definition = Refparser->getDefinition(defName); if (definition == nullptr) throw JsonException("Definition Name Incorrect"); return definition; } } else { if (!(defName.empty())) { if (getDefinition(defName) == nullptr) throw JsonException("Definition Name Incorrect"); return getDefinition(defName); } } } throw JsonException("Definition Name Empty"); return nullptr; }
//--------------------------------------------------------------------------------- QString MagicRules::constructCustomizedSpell(const QString &p_id, const QString &p_customValue, const QString &p_translation) { // Construct new ID const MagicAbilityDefinition& originalAbility = getDefinition(p_id); QString newID = p_id + "_" + p_customValue; // If a spell with that ID already exists, don't add it again if (_definitions.find(newID) != _definitions.end()) { return newID; } // Create the new spell MagicAbilityDefinition* newAbility = new MagicAbilityDefinition(); // Misc newAbility->id = newID; newAbility->customString = p_customValue; newAbility->requiresCustom = false; newAbility->customChoices = originalAbility.customChoices; newAbility->isUserDefined = true; newAbility->base = originalAbility.id; newAbility->parent = originalAbility.parent; newAbility->children = originalAbility.children; newAbility->isCategory = originalAbility.isCategory; newAbility->parent->children.push_back(newAbility); // Effects for (unsigned int i = 0; i < originalAbility.effects.size(); ++i) { newAbility->effects.push_back(new Effect(*(originalAbility.effects[i]))); EffectSource source; source.magicAbility = newAbility; newAbility->effects.back()->setSource(source); } // Translations newAbility->translations = originalAbility.translations; QMap<QString, QString>::iterator it; for (it = newAbility->translations.begin(); it != newAbility->translations.end(); ++it) { it.value().append(" (" + p_translation + ")"); } // Types newAbility->abilityType = originalAbility.abilityType; switch (newAbility->abilityType) { case MAGICABILITYTYPE_SPELL: newAbility->spell = originalAbility.spell; _spellDefinitions[newID] = newAbility->spell; break; case MAGICABILITYTYPE_ADEPT_POWER: newAbility->adeptPower = originalAbility.adeptPower; _adeptPowerDefinitions[newID] = newAbility->adeptPower; break; case MAGICABILITYTYPE_COMPLEX_FORM: newAbility->complexForm = originalAbility.complexForm; _complexFormDefinitions[newID] = newAbility->complexForm; break; default: break; } // Add the skill _definitions[newID] = newAbility; return newID; }