Beispiel #1
0
void ItemTaskGroup::nextItem()
{
	onProgressUpdate(100);

	UserCore::Item::ItemHandleI* item = getActiveItem();

	if (item)
		item->delHelper(this);

	if (m_uiActiveItem+1 >=  m_vWaitingList.size())
	{
		m_uiLastActive = m_uiActiveItem;
		m_uiActiveItem = UINT_MAX;

		if (m_bFinal)
			finish();
	}
	else
	{
		if (m_uiLastActive != UINT_MAX)
		{
			m_uiActiveItem = m_uiLastActive;
			m_uiLastActive = UINT_MAX;
		}

		m_uiActiveItem++;

		item = getActiveItem();
		item->addHelper(this);
		startAction(dynamic_cast<UserCore::Item::ItemHandle*>(item));
	}
}
Beispiel #2
0
void ItemTaskGroup::start()
{
	m_bStarted = true;

	if (!getActiveItem())
		nextItem();
}
Beispiel #3
0
void ItemTaskGroup::finalize()
{
	m_bFinal = true;

	if (!getActiveItem())
		finish();
}
Beispiel #4
0
void CharacterObject::useItem(bool active, bool primary)
{
	if( getActiveItem() ) {
		if( primary ) {
			if (active)
				currentState.primaryStartTime = engine->getGameTime() * 1000.f;
			else
				currentState.primaryEndTime = engine->getGameTime() * 1000.f;
			currentState.primaryActive = active;
			getActiveItem()->primary(this);
		}
		else {
			currentState.secondaryActive = active;
			getActiveItem()->secondary(this);
		}
	}
}
Beispiel #5
0
void ItemTaskGroup::onProgressUpdate(uint32 progress)
{
	MCFCore::Misc::ProgressInfo i;

	i.percent = progress;

	if (getActiveItem())
		i.totalAmmount = getActiveItem()->getItemInfo()->getId().toInt64();

	m_TaskListLock.lock();
	for (size_t x=0; x<m_vTaskList.size(); x++)
	{
		if (m_vTaskList[x]->getItemHandle() != getActiveItem())
			m_vTaskList[x]->onMcfProgressEvent(i);
	}
	m_TaskListLock.unlock();
}
Beispiel #6
0
void Scene::removeGroup(LayerGroup *group)
{
	if(group == NULL)
		return;

	int index = indexOfGroup(group);
	if(index < 0)
		return; // Not in scene
	const GroupInfo &info = m_groups.at(index);

	// Clean up
	SceneItem *groupItem = info.sceneItem;
	if(getActiveItem() == groupItem)
		setActiveItem(NULL);
	if(m_isVisible && info.isVisible)
		group->derefVisible();

	// Disconnect to group signals. If the object is destructing then
	// disconnecting results in crashing.
	if(!m_isDestructing) {
		disconnect(group, &LayerGroup::groupChanged,
			this, &Scene::groupChanged);
		disconnect(group, &LayerGroup::layerAdded,
			this, &Scene::layerAdded);
		disconnect(group, &LayerGroup::destroyingLayer,
			this, &Scene::destroyingLayer);
		disconnect(group, &LayerGroup::layerMoved,
			this, &Scene::layerMoved);
		disconnect(group, &LayerGroup::layerChanged,
			this, &Scene::layerChanged);
	}

	// Remove group and layer scene items
	emit removingItem(groupItem); // Expected to be first
	delete groupItem;
	const LayerList &layers = group->getLayers();
	for(int i = 0; i < layers.size(); i++) {
		Layer *layer = layers.at(i);
		emit removingItem(m_layerSceneItems[layer]);
		m_layerSceneItems.remove(layer);
	}

	// Actually remove from the group list
	m_groups.remove(index);

	// As we cannot detect if the shared state has changed when a scene is
	// deleted we just blindly assume that if a group is no longer shared then
	// its shared state has changed.
	if(!group->isShared())
		group->groupChanged(group); // Remote emit

	// Delete any group that is no longer in a scene. We don't do this while
	// destructing as this scene object has already been removed from the
	// profile meaning the second and later groups will be pruned before we
	// dereference them here.
	if(!m_isDestructing)
		m_profile->pruneLayerGroups();
}
Beispiel #7
0
bool ItemTaskGroup::addItem(UserCore::Item::ItemHandleI* item)
{
	if (!item)
		return false;

	UserCore::Item::ItemHandle* handle = dynamic_cast<UserCore::Item::ItemHandle*>(item);

	if (!handle)
		return false;

	if (!handle->setTaskGroup(this))
		return false;

	m_ListLock.lock();
	for (size_t x=0; x<m_vWaitingList.size(); x++)
	{
		if (m_vWaitingList[x] == handle)
			return true;
	}

	m_vWaitingList.push_back(handle);
	m_ListLock.unlock();

	if (m_bStarted && m_uiActiveItem == UINT_MAX)
		nextItem();

	uint32 p=m_vWaitingList.size();

	m_TaskListLock.lock();
	for (size_t x=0; x<m_vTaskList.size(); x++)
	{
		if (m_vTaskList[x]->getItemHandle() != getActiveItem())
			m_vTaskList[x]->onProgUpdateEvent(p);
	}
	m_TaskListLock.unlock();

	return true;
}
Beispiel #8
0
bool ItemTaskGroup::removeItem(UserCore::Item::ItemHandleI* item)
{
	if (!item)
		return false;

	UserCore::Item::ItemHandle* handle = dynamic_cast<UserCore::Item::ItemHandle*>(item);

	if (!handle)
		return false;

	bool found = false;

	m_ListLock.lock();
	for (size_t x=0; x<m_vWaitingList.size(); x++)
	{
		if (m_vWaitingList[x] == handle)
		{
			found = true;
			m_vWaitingList.erase(m_vWaitingList.begin()+x);
			break;
		}
	}
	m_ListLock.unlock();

	if (found)
		handle->setTaskGroup(nullptr);

	uint32 p=m_vWaitingList.size();
	m_TaskListLock.lock();
	for (size_t x=0; x<m_vTaskList.size(); x++)
	{
		if (m_vTaskList[x]->getItemHandle() != getActiveItem())
			m_vTaskList[x]->onProgUpdateEvent(p);
	}
	m_TaskListLock.unlock();

	return true;
}