bool
   PreSaveLimitationsCheck::CheckLimitations(PersistenceMode mode, std::shared_ptr<DomainAlias> domainAlias, String &resultDescription)
   {
      if (mode == PersistenceModeRestore)
         return true;


      std::shared_ptr<const Domain> pDomain = CacheContainer::Instance()->GetDomain(domainAlias->GetName());

      if (pDomain)
      {
         resultDescription = "Another domain with this name already exists.";
         return false;
      }

      // Check if there's a domain alias with this name. If so, this domain would be a duplciate.
      std::shared_ptr<DomainAliases> pDomainAliases = ObjectCache::Instance()->GetDomainAliases();
      std::shared_ptr<DomainAlias> pDomainAlias = pDomainAliases->GetItemByName(domainAlias->GetName());
      if (pDomainAlias && (domainAlias->GetID() == 0 || domainAlias->GetID() != pDomainAlias->GetID()))
      {
         resultDescription = "A domain alias with this name already exists.";
         return false;
      }

      return true;
   }
Example #2
0
	void Shader::BindMesh(const std::shared_ptr<Mesh> &mesh)
	{
		if (mesh->GetDirty())
			mesh->UpdateBuffer();

		if (m_Dirty || mesh->GetDirty() || mesh->Indices.GetDirty())
			return;

		int lPos = glGetAttribLocation(m_Program, mesh->Positions.Name.c_str());
		int lNormal = glGetAttribLocation(m_Program, mesh->Normals.Name.c_str());
		int lUV = glGetAttribLocation(m_Program, mesh->UVs.Name.c_str());

		glBindVertexArray(mesh->m_VAO);

		if (lPos != -1)
		{
			if (!mesh->Positions.GetDirty())
			{
				glBindBuffer(GL_ARRAY_BUFFER, mesh->Positions.GetID());
				glVertexAttribPointer(lPos, 3, GL_FLOAT, GL_FALSE, 0, 0);
				glEnableVertexAttribArray(lPos);
			}
			else
			{
				LOGW << "Mesh " + mesh->GetName() + " Position data dirty!";
			}
		}
		if (lNormal != -1)
		{
			if (!mesh->Normals.GetDirty())
			{
				glBindBuffer(GL_ARRAY_BUFFER, mesh->Normals.GetID());
				glVertexAttribPointer(lNormal, 3, GL_FLOAT, GL_FALSE, 0, 0);
				glEnableVertexAttribArray(lNormal);
			}
			else
			{
				LOGW << "Mesh " + mesh->GetName() + " Normal data dirty!";
			}
		}
		if (lUV != -1)
		{
			if (!mesh->UVs.GetDirty())
			{
				glBindBuffer(GL_ARRAY_BUFFER, mesh->UVs.GetID());
				glVertexAttribPointer(lUV, 2, GL_FLOAT, GL_FALSE, 0, 0);
				glEnableVertexAttribArray(lUV);
			}
			else
			{
				LOGW << "Mesh " + mesh->GetName() + " UV data dirty!";
			}
		}

		glBindBuffer(GL_ARRAY_BUFFER, 0);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->Indices.GetID());
	}
Example #3
0
void Inventory::AddItem(std::shared_ptr<Item> & item)
{
	if (m_itemList.empty() || !item.get()->IsStackable())
	{
		m_itemList.push_back(item);
	}
	else
	{
		std::vector<std::shared_ptr<Item>>::iterator it = m_itemList.begin();
		bool found = false;
		while (it != m_itemList.end())
		{
			// check if items match
			if (item->GetName() == it->get()->GetName())
			{
				// if they match don't add item just increase stack count
				it->get()->SetStackCount(1);
				found = true;
				break;
			}
			else
			{
				it++;
			}
		}
		if (!found)
		{
			m_itemList.push_back(item);
		}
	}
}
Example #4
0
void Merchant::PerformCharacteristic(std::shared_ptr<GameManager> manager, std::shared_ptr<Player> player)
{
	std::shared_ptr<Socket> socket = player->GetSocket();
	std::vector<std::shared_ptr<BuildCard>> builded_cards_list = player->GetBuildedBuildings();

	int counter = 0;
	for (int i = 0; i < builded_cards_list.size(); i++)
	{
		std::shared_ptr<BuildCard> build_card = builded_cards_list.at(i);
		if (build_card->GetColor() == CardColor::GREEN)
		{
			player->AddGold(1);
			counter++;
		}
	}

	std::shared_ptr<NetworkServices> networkServices = manager->GetNetworkServices();
	networkServices->WriteToClient("You received " + std::to_string(counter) + " gold.", socket, true);

	// Set used characteristic on true
	player->SetUsedCharacteristic(true);

	// Let the other players know what happend
	networkServices->WriteToAllClients(player->GetName() + " received " + std::to_string(counter) + " gold.");
}
Example #5
0
   void 
   WorkQueue::ExecuteTask(std::shared_ptr<Task> pTask)
   {
      {
         boost::lock_guard<boost::recursive_mutex> guard(runningTasksMutex_);
         runningTasks_.insert(pTask);
      }

      LOG_DEBUG(Formatter::Format("Executing task {0} in work queue {1}", pTask->GetName(), queue_name_));
      
      String descriptive_name = Formatter::Format("Task-{0}", pTask->GetName());
      boost::function<void()> func = boost::bind( &Task::Run, pTask );
      ExceptionHandler::Run(descriptive_name, func);

      RemoveRunningTask_(pTask);
   }
Example #6
0
void SkexmlParser::WriteNode(std::stringstream &xml_string, std::shared_ptr<Node> node, std::ofstream &file) {
    std::string node_name = node->GetName();
    if(node_name == "LongDescription")
    {
        int x = 0;
    }
    xml_string << "[" << node_name << "]" << "\r\n";
    std::string list = node->GetAttribute("List");
    if(list != "") {
        auto items = Tokenizer::GetAllTokens(list, ';');
        for(auto item : items)
        {
            xml_string << item << "\r\n";
        }
    }
    else {
        std::map<std::string, std::string> attributes = node->GetAttributes();
        for (auto &kv : attributes) {
            std::string name = kv.first;
            if(name=="List")
                continue;
            std::string value = kv.second;
            xml_string << "[" << name << "]" << value << "[/" << name << "]" << "\r\n";
        }
    }
    std::map<std::string, std::shared_ptr<Node>> children = node->GetChildren();
    for(auto &kv : children)
    {
        std::shared_ptr<Node> value = kv.second;
        WriteNode(xml_string, value, file);
    }
    xml_string << "[/" << node_name << "]" << "\r\n";
}
/**
 * Constructor.
 * @param status The player status.
 * @param target The target player (may not be @c nullptr).
 * @param subject The subject player (may not be @c nullptr).
 */
PlayerStatusAnnouncement::PlayerStatusAnnouncement(Status::status_t status,
	std::shared_ptr<Player::Player> target,
	std::shared_ptr<Player::Player> subject) :
	SUPER(subject->GetName(), RenderStatusText(status, *subject), target),
	subject(subject)
{
}
void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device)
{
  {
    std::lock_guard<std::mutex> lk(m_devices_mutex);
    // Try to find an ID for this device
    int id = 0;
    while (true)
    {
      const auto it =
          std::find_if(m_devices.begin(), m_devices.end(), [&device, &id](const auto& d) {
            return d->GetSource() == device->GetSource() && d->GetName() == device->GetName() &&
                   d->GetId() == id;
          });
      if (it == m_devices.end())  // no device with the same name with this ID, so we can use it
        break;
      else
        id++;
    }
    device->SetId(id);

    NOTICE_LOG(SERIALINTERFACE, "Added device: %s", device->GetQualifiedName().c_str());
    m_devices.emplace_back(std::move(device));
  }

  if (!m_is_populating_devices)
    InvokeDevicesChangedCallbacks();
}
Example #9
0
   void 
   WorkQueue::AddTask(std::shared_ptr<Task> pTask)
   {
      LOG_DEBUG(Formatter::Format("Adding task {0} to work queue {1}", pTask->GetName(), queue_name_));

      // Post a wrapped task into the queue.
      std::function<void ()> func = std::bind(&WorkQueue::ExecuteTask, this, pTask);
      io_service_.post( func );
   }
TemplateDescriptor::TemplateDescriptor(std::shared_ptr<rmscore::core::
                                                       ProtectionPolicy>policy)
  : m_id(policy->GetId())
  , m_name(policy->GetName())
  , m_description(policy->GetDescription())
{
  if (policy->IsAdhoc()) {
    throw exceptions::RMSInvalidArgumentException("Invalid policy");
  }
}
void VariateManagerWithHorizonHeader::UpdateWidget(const std::shared_ptr<TVariate> newVariate, QTreeWidget* treeWidget, QTreeWidgetItem* variateItem)
{
	assert(typeid(*variateItem) == typeid(TreeWidgetItemWithSymbol));

	auto item = dynamic_cast<TreeWidgetItemWithSymbol*>(variateItem);
	assert(newVariate->GetTypeName() == item->GetSymbol().GetTypeName());

	variateItem->setText(1, newVariate->GetName());
	item->SetSymbol(newVariate->GetSymbol());
	VariateWidgetMap::GetVariateWidget(newVariate->GetTypeName())->UpdateWidgetValue(newVariate, treeWidget, variateItem);
}
Example #12
0
bool PlatformManager::AddPlatform(std::shared_ptr<gd::Platform> newPlatform)
{
    for (std::size_t i = 0;i<platformsLoaded.size();++i)
    {
        if ( platformsLoaded[i]->GetName() == newPlatform->GetName() )
            return false;
    }

    platformsLoaded.push_back(newPlatform);
    return true;
}
void ServerChannel::SendEntity(std::shared_ptr<Level> level, std::shared_ptr<Entity> entity, std::shared_ptr<sockaddr_in> addr, int addr_size)
{
	ServerSendEntity data;
	data.entity.info.type = ServerHelper::GetEntityType(entity);
	data.entity.info.id = entity->Id;
	data.entity.info.category = NetHelper::EncodeCategory(entity->category);
	data.entity.location.map_id = level->Id();
	data.entity.location.position = entity->Sprite->Position;
	data.entity.view.animation = NetHelper::EncodeAnimation(entity->Sprite->CurrentAnimation);
	if (Send(data, addr, addr_size) == WSAECONNRESET)
		handleConnectionClose(addr);

	if (!entity->GetName().empty())
	{
		ServerSendEntityName nameData;
		nameData.entity_id = entity->Id;
		strcpy_s(nameData.name, entity->GetName().c_str());
		if (Send(nameData, addr, addr_size) == WSAECONNRESET)
			handleConnectionClose(addr);
	}
}
Example #14
0
bool Platform::AddExtension(std::shared_ptr<gd::PlatformExtension> extension) {
  if (!extension) return false;

  std::cout << "Loading " << extension->GetName() << "...";
  if (IsExtensionLoaded(extension->GetName())) {
    std::cout << " (replacing existing extension)";
    RemoveExtension(extension->GetName());
  }
  std::cout << std::endl;

  extensionsLoaded.push_back(extension);

  // Load all creation/destruction functions for objects provided by the
  // extension
  vector<gd::String> objectsTypes = extension->GetExtensionObjectsTypes();
  for (std::size_t i = 0; i < objectsTypes.size(); ++i) {
    creationFunctionTable[objectsTypes[i]] =
        extension->GetObjectCreationFunctionPtr(objectsTypes[i]);
  }

  return true;
}
Example #15
0
bool Platform::AddExtension(std::shared_ptr<gd::PlatformExtension> extension)
{
    std::cout << extension->GetName();
    for (std::size_t i =0;i<extensionsLoaded.size();++i)
    {
    	if ( extensionsLoaded[i]->GetName() == extension->GetName() ) {
            std::cout << "(Already loaded!)" << std::endl;
    	    return false;
        }
    }

    //Load all creation/destruction functions for objects provided by the extension
    vector < gd::String > objectsTypes = extension->GetExtensionObjectsTypes();
    for ( std::size_t i = 0; i < objectsTypes.size();++i)
    {
        creationFunctionTable[objectsTypes[i]] = extension->GetObjectCreationFunctionPtr(objectsTypes[i]);
    }

    extensionsLoaded.push_back(extension);
    std::cout << ", ";
    return true;
}
Example #16
0
void Equipment::LevelUp(std::shared_ptr<PartyMember> target)
{
    m_level[target]++;
    auto it = m_skillsToLearn.find(m_level[target]);
    if(it != m_skillsToLearn.end())
    {
        target->AddSkill(it->second);

        std::vector<std::string> stringValues;
        stringValues.push_back(target->GetName());
        stringValues.push_back(it->second->GetName());
        SceneManagerMessage* sm = new SceneManagerMessage(Localization::GetInstance()->GetLocalizationWithStrings("character.learn_skill", &stringValues));
        GameController::getInstance()->LoadSceneManagerBefore(sm);
    }
}
Example #17
0
void TContainerHolder::Unlink(TScopedLock &holder_lock, std::shared_ptr<TContainer> c) {
    for (auto name: c->GetChildren()) {
        std::shared_ptr<TContainer> child;
        if (Get(name, child))
            continue;

        Unlink(holder_lock, child);
    }

    c->Destroy(holder_lock);

    TError error = IdMap.Put(c->GetId());
    PORTO_ASSERT(!error);
    Containers.erase(c->GetName());
    Statistics->Created--;
}
Example #18
0
void ProjectsListView::AddProjectType(std::shared_ptr<ProjectType> projectType, bool isNoCategory)
{
    std::unique_ptr<UiProjectType> uiProjectType(new UiProjectType());
    UiProjectType &r_uiProjectType = *uiProjectType.get();

    r_uiProjectType.m_isNoCategory = isNoCategory;
    r_uiProjectType.m_typeTreeItem = new QTreeWidgetItem();
    QTreeWidgetItem *treeItem = r_uiProjectType.m_typeTreeItem;
    treeItem->setData(0, QTWI_ROLE_IS_PROJECT, false);
    treeItem->setData(0, Qt::DecorationRole, QIcon(":/icons/folder.png"));

    qint32 typeId = 0;
    if(!isNoCategory)
    {
        r_uiProjectType.m_projectType = projectType;

        treeItem->setText(0, projectType->GetName());
        treeItem->setData(0, QTWI_ROLE_OBJ_ID, projectType->GetProjectTypeId());

        typeId = projectType->GetProjectTypeId();
    }
    else
    {
        treeItem->setText(0, "Projets sans type");
        treeItem->setData(0, QTWI_ROLE_OBJ_ID, 0);

        QFont italicCopy = treeItem->font(0);
        italicCopy.setItalic(true);
        treeItem->setFont(0, italicCopy);
    }

    m_projectTypeIdMap.insert(std::make_pair(typeId, std::move(uiProjectType)));
    if(!m_noTypeItemPresent)
    {
        m_rui.tvProjects->addTopLevelItem(r_uiProjectType.m_typeTreeItem);
    }
    else
    {
        int count = m_rui.tvProjects->topLevelItemCount();
        m_rui.tvProjects->insertTopLevelItem(count - 1, r_uiProjectType.m_typeTreeItem);
    }

    if(isNoCategory)
    {
        m_noTypeItemPresent = true;
    }
}
   bool 
   PreSaveLimitationsCheck::CheckLimitations(PersistenceMode mode, std::shared_ptr<Route> route, String &resultDescription)
   {
      if (mode == PersistenceModeRestore)
         return true;

      std::shared_ptr<Routes> pRoutes = Configuration::Instance()->GetSMTPConfiguration()->GetRoutes();

      std::shared_ptr<Route> existingRoute = pRoutes->GetItemByName(route->GetName());
      if (existingRoute && existingRoute->GetID() != route->GetID())
      {
        resultDescription = "Another route with this name already exists.";
        return false;  
      }
 
      return true;
   }
Example #20
0
void Renderer::SetUnderlineHelper( const std::shared_ptr< MenuItem > &menuItem )
{
	if ( !menuItem || !menuItem->HasValidTexture() || !menuItem->HasUnderlineChanged()  )
		return;

	SDL_Color clr = colorConfig.textColor;
	int style = 0;

	if ( menuItem->IsSelected()  )
	{
		clr = SDL_Color{ 0, 200, 200, 255};
		style = TTF_STYLE_UNDERLINE | TTF_STYLE_ITALIC;
	}

	SDL_Rect r = menuItem->GetRect();
	menuItem->SetTexture( RenderHelpers::RenderTextTexture_Blended( mediumFont, menuItem->GetName(), clr, r, renderer, style ) );
	menuItem->SetRect( r );
}
   bool
   PersistentAlias::SaveObject(std::shared_ptr<Alias> pAlias, String &sErrorMessage, PersistenceMode mode)
   {
      if (!PreSaveLimitationsCheck::CheckLimitations(mode, pAlias, sErrorMessage))
         return false;

      SQLStatement oStatement;
      
      oStatement.SetTable("hm_aliases");

      oStatement.AddColumnInt64("aliasdomainid", pAlias->GetDomainID());
      oStatement.AddColumn("aliasname", pAlias->GetName());
      oStatement.AddColumn("aliasvalue", pAlias->GetValue());
      oStatement.AddColumn("aliasactive", pAlias->GetIsActive());

      if (pAlias->GetID() == 0)
      {
         oStatement.SetStatementType(SQLStatement::STInsert);
         oStatement.SetIdentityColumn("aliasid");
      }
      else
      {
         oStatement.SetStatementType(SQLStatement::STUpdate);

         String sWhere;
         sWhere.Format(_T("aliasid = %I64d"), pAlias->GetID());
         oStatement.SetWhereClause(sWhere);
      }

      bool bNewObject = pAlias->GetID() == 0;

      // Save and fetch ID
      __int64 iDBID = 0;
      bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
      if (bRetVal && bNewObject)
         pAlias->SetID((int) iDBID);

      Cache<Alias>::Instance()->RemoveObject(pAlias);

      return bRetVal;
   }
Example #22
0
bool WignerDStrategy::execute(ParameterList& paras,
		std::shared_ptr<AbsParameter>& out)
{
#ifdef DEBUG
	if( checkType != out->type() ) {
		throw( WrongParType( std::string("Output Type ")
		+ParNames[out->type()]+std::string(" conflicts expected type ")
		+ParNames[checkType]+std::string(" of ")+name+" Wigner strat") );
		return false;
	}
#endif

	double _inSpin = paras.GetDoubleParameter(0)->GetValue();
	double _outSpin1 = paras.GetDoubleParameter(1)->GetValue();
	double _outSpin2 = paras.GetDoubleParameter(2)->GetValue();

	ComPWA::Physics::DPKinematics::DalitzKinematics* kin =
			dynamic_cast<ComPWA::Physics::DPKinematics::DalitzKinematics*>(
			Kinematics::instance()
	);

	std::shared_ptr<MultiDouble> _angle = paras.GetMultiDouble(0);

	std::vector<double> results(_angle->GetNValues(), 0.);
	for(unsigned int ele=0; ele<_angle->GetNValues(); ele++){
		try{
			results.at(ele)=AmpWigner2::dynamicalFunction(
					_inSpin,_outSpin1,_outSpin2,_angle->GetValue(ele)
			);
		} catch (std::exception &ex) {
			BOOST_LOG_TRIVIAL(error) << "WignerDStrategy::execute() | "
					<<ex.what();
			throw std::runtime_error("WignerDStrategy::execute() | "
					"Evaluation of dynamical function failed!");
		}
	}//end element loop
	out = std::shared_ptr<AbsParameter>(
			new MultiDouble(out->GetName(),results));

	return true;
}
void ProjectVariatesXmlManager::WriteVariate(QXmlStreamWriter& writer, std::shared_ptr<TVariate> variate) const
{
	writer.writeStartElement("Variate");

	writer.writeTextElement("Name",variate->GetName());
	writer.writeTextElement("Type", variate->GetTypeName());
	
	if (typeid(*variate)==typeid(TInteger))
	{
		writer.writeTextElement("Value", QString::number(std::dynamic_pointer_cast<TInteger>(variate)->GetValue()));
	}
	else if (typeid(*variate) == typeid(TDouble))
	{
		writer.writeTextElement("Value", QString::number(std::dynamic_pointer_cast<TDouble>(variate)->GetValue()));
	}
	else if (typeid(*variate) == typeid(TString))
	{
		writer.writeTextElement("Value", std::dynamic_pointer_cast<TString>(variate)->GetValue());
	}
	else if (typeid(*variate) == typeid(TBool))
	{
		auto value = std::dynamic_pointer_cast<TBool>(variate)->GetValue();
		QString valueName = "TRUE";
		if (!value)
		{
			valueName = "FALSE";
		}
		writer.writeTextElement("Value", valueName);
	}
	else
	{
		auto valueNames = std::dynamic_pointer_cast<TComplex>(variate)->GetValueNames();
		auto values = std::dynamic_pointer_cast<TComplex>(variate)->GetValues();
		for (size_t i = 0; i < values.size();++i)
		{
			writer.writeTextElement(valueNames.at(i), values.at(i)->ToStrings().at(0));
		}
	}

	writer.writeEndElement();
}
   void 
   Configuration::OnPropertyChanged(std::shared_ptr<Property> pProperty)
   {
      String sPropertyName = pProperty->GetName();
      if (sPropertyName == PROPERTY_LOGGING)
      {
         // Activate the logger.
         Logger::Instance()->SetLogMask(pProperty->GetLongValue());
      }
      else if (sPropertyName == PROPERTY_AWSTATSENABLED)
      {
         AWStats::SetEnabled(GetAWStatsEnabled());
      }
      else
      {
         CacheContainer::Instance()->OnPropertyChanged(pProperty);
         Application::Instance()->OnPropertyChanged(pProperty);
      } 

      if (smtp_configuration_)
         smtp_configuration_->OnPropertyChanged(pProperty);
   }
Example #25
0
void Builder::PerformCharacteristic(std::shared_ptr<GameManager> manager, std::shared_ptr<Player> player)
{
	std::string output = "";
	std::shared_ptr<Player> chosen_player;
	std::shared_ptr<Socket> socket = player->GetSocket();
	std::shared_ptr<NetworkServices> networkServices = manager->GetNetworkServices();

	// Get 2 new cards
	std::vector<std::shared_ptr<BuildCard>> received_cards = manager->TakeCards(2);
	player->AddBuildCards(received_cards);

	// Show the cards
	ShowBuildCards(manager, player, received_cards);

	// Set used characteristic on true
	player->SetUsedCharacteristic(true);

	// Let all the other players know what happend
	output.clear();
	output.append(player->GetName() + " received 2 new cards.\n");
	networkServices->WriteToAllExceptCurrent(output, player);
}
Example #26
0
	void PrelightPipeline::DrawRenderable(const std::shared_ptr<Pass> &pass, const std::shared_ptr<SceneNode> &node)
	{
		auto render = node->GetComponent<MeshRender>();
		if (render == nullptr || !render->GetRenderable())
			return;

		auto mesh = render->GetMesh();
		auto material = render->GetMaterial();
		auto shader = material->GetShaderForPass(pass->GetRenderIndex());

		if (shader == nullptr)
			shader = pass->GetShader(material->GetShaderType());

		if (shader == nullptr)
		{
			LOGW << "Failed to draw " << node->GetName() << ", data incomplete!";
			return;
		}

		shader->Bind();
		shader->BindCamera(m_CurrentCamera);
		shader->BindMatrix(Matrix4::WORLD_MATRIX, node->GetWorldMatrix());

		shader->BindMesh(mesh);
		shader->BindMaterial(material);

		for (unsigned int i = 0; i < pass->GetTextureCount(true); i++)
		{
			auto ptr = pass->GetTextureAt(i, true);
			shader->BindTexture(ptr->GetName(), ptr);
		}

		glDrawElements(GL_TRIANGLES, mesh->Indices.Data.size(), GL_UNSIGNED_INT, 0);

		shader->UnBind();

		m_DrawCall++;
	}
Example #27
0
void Plantable::Plant(std::shared_ptr<Item> sourceItem)
{
   auto x = Player::Get().GetPositionX();
   auto y = Player::Get().GetPositionY();
   auto currentLandmark = GameState::Get().GetCurrentLandmark();
   auto currentTile = currentLandmark->GetTile(x, y);

   if (currentTile.TileType != TileType::Tilled) {
      GameState::Get().AddLogMessage("You can only plant on tilled land!");
      return;
   }

   auto item = currentLandmark->GetItem(x, y);
   if (item != nullptr) {
      GameState::Get().AddLogMessageFmt("Cannot plant, %s is on the ground here.", item->GetName().c_str());
      return;
   }

   auto crop = GameState::Get().GetItemFromItemDatabase(this->Crop);
   crop->SetCount(1);
   currentLandmark->AddItem(x, y, crop);

   auto growableInterface = crop->GetInterface<Growable>(ItemInterfaceType::Growable);
   if (growableInterface != nullptr) {
      growableInterface->StartGrowing(crop);
   }

   sourceItem->RemoveOne();
   // Equip another item if we can find one
   for (auto item : Player::Get().GetInventory()) {
      if (item->ItemTarget->GetName() != sourceItem->GetName()) {
         continue;
      }

      Player::Get().EquipFromInventory(item->ItemTarget);
      break;
   }
}
void ProjectTypesListView::AddProjectType(std::shared_ptr<ProjectType> projectType)
{
    auto ptr = std::unique_ptr<UiProjectType>(new UiProjectType());
    UiProjectType &uiProject = *ptr;
    uiProject.m_projectType = projectType;

    qint32 typeId = projectType->GetProjectTypeId();
    m_projectTypeIdMap.insert(std::make_pair(
                                  typeId,
                                  std::move(ptr)
                              ));

    int newRowIndex = m_rui.tblProjectTypes->rowCount();
    m_rui.tblProjectTypes->insertRow(newRowIndex);

    QVariant tag = QVariant::fromValue(typeId);

    auto nameItem = new QTableWidgetItem();
    nameItem->setData(Qt::UserRole, tag);
    nameItem->setText(projectType->GetName());
    nameItem->setData(Qt::DecorationRole, QImage(":/icons/folder.png"));
    m_rui.tblProjectTypes->setItem(newRowIndex, 0, nameItem);
    uiProject.m_nameItem = nameItem;
}
   bool
   PreSaveLimitationsCheck::CheckLimitations(PersistenceMode mode, std::shared_ptr<Alias> alias, String &resultDescription)
   {
      if (mode == PersistenceModeRestore)
         return true;

      std::shared_ptr<Domain> domain = GetDomain(alias->GetDomainID());

      if (GetDuplicateExist(domain, TypeAlias, alias->GetID(), alias->GetName()))      
         return DuplicateError(resultDescription);

      if (alias->GetID() == 0)
      {
         if (domain->GetMaxNoOfAliasesEnabled() && 
             domain->GetAliases()->GetCount() >= domain->GetMaxNoOfAliases())
         {
            resultDescription = "The maximum number of aliases have been created.";
            return false;
         }
      }


      return true;
   }
Example #30
0
void ProjectsListView::AddProject(std::shared_ptr<Project> project)
{   
    m_projectIdMap.insert(std::make_pair(
        project->GetIdProject(),
        std::unique_ptr<UiProject>(new UiProject())
    ));
    UiProject &uiProject = *m_projectIdMap[project->GetIdProject()];
    uiProject.m_project = project;
    uiProject.m_lastTypeId = project->GetIdTypeProject();
    uiProject.m_lastTypeIdSet = project->IsProjectTypeSet();

    QTreeWidgetItem *treeItem = new QTreeWidgetItem();
    treeItem->setText(0, project->GetName());
    treeItem->setData(0, QTWI_ROLE_OBJ_ID, project->GetIdProject());
    treeItem->setData(0, QTWI_ROLE_IS_PROJECT, true);
    treeItem->setData(0, Qt::DecorationRole, QIcon(":/icons/book.png"));
    uiProject.m_projectTreeItem = treeItem;

    qint32 uiProjectTypeId = project->IsProjectTypeSet() ?
        project->GetIdTypeProject() : 0;

    UiProjectType &uiType = *m_projectTypeIdMap[uiProjectTypeId];
    uiType.m_typeTreeItem->addChild(treeItem);
}