示例#1
0
void CPetGlyphs::highlight(int index) {
	if (index >= 0) {
		setSelectedIndex(index);
		changeHighlight(index);
		makePetDirty();
	}
}
示例#2
0
bool CPetGlyphs::MouseButtonDownMsg(const Point &pt) {
	if (_scrollLeft.contains2(pt)) {
		scrollLeft();
		return true;
	}

	if (_scrollRight.contains2(pt)) {
		scrollRight();
		return true;
	}

	for (int idx = 0; idx < _numVisibleGlyphs; ++idx) {
		Rect glyphRect = getRect(idx);
		if (glyphRect.contains(pt)) {
			int index = getItemIndex(idx);
			CPetGlyph *glyph = getGlyph(index);
			if (glyph) {
				if (_highlightIndex == index) {
					glyph->selectGlyph(glyphRect, pt);
					glyph->updateTooltip();
				} else {
					changeHighlight(index);
					makePetDirty();
				}

				return true;
			}
		}
	}

	if (_highlightIndex != -1) {
		CPetGlyph *glyph = getGlyph(_highlightIndex);

		if (glyph) {
			if (glyph->MouseButtonDownMsg(pt))
				return true;

			if (!(_flags & GFLAG_2)) {
				changeHighlight(-1);
				makePetDirty();
			}
		}
	}

	return false;
}
示例#3
0
void CPetGlyphs::decSelection() {
	if (_highlightIndex > 0) {
		if (getHighlightedIndex(_highlightIndex) == 0)
			scrollLeft();

		changeHighlight(_highlightIndex - 1);
		makePetDirty();
	}
}
示例#4
0
void CPetGlyphs::incSelection() {
	if (_highlightIndex >= 0 && _highlightIndex < ((int)size() - 1)) {
		if (getHighlightedIndex(_highlightIndex) >= (_numVisibleGlyphs - 1))
			scrollRight();

		changeHighlight(_highlightIndex + 1);
		makePetDirty();
	}
}
示例#5
0
void CPetGlyphs::scrollLeft() {
	if (_firstVisibleIndex > 0) {
		setFirstVisible(_firstVisibleIndex - 1);
		if (_highlightIndex != -1) {
			int index = getHighlightedIndex(_highlightIndex);
			if (index == -1)
				changeHighlight(_highlightIndex - 1);
		}

		makePetDirty();
	}
}
示例#6
0
void CPetGlyphs::scrollRight() {
	int count = size();
	int right = count - _numVisibleGlyphs;

	if (_firstVisibleIndex < right) {
		setFirstVisible(_firstVisibleIndex + 1);
		if (_highlightIndex != -1) {
			int index = getHighlightedIndex(_highlightIndex);
			if (index == -1)
				changeHighlight(_highlightIndex + 1);
		}

		makePetDirty();
	}
}
示例#7
0
void CPetGlyphs::removeInvalid() {
	if (!areItemsValid()) {
		changeHighlight(-1);

		for (iterator i = begin(); i != end(); ) {
			CPetGlyph *glyph = *i;

			if (!glyph->isValid()) {
				i = erase(i);
				delete glyph;
			} else {
				++i;
			}
		}

		int max = MAX((int)size() - _numVisibleGlyphs, 0);
		_firstVisibleIndex = CLIP(_firstVisibleIndex, 0, max);
	}
}
void ShipModulesControllerSystem::processEntities(const vector<Entity*>& p_entities)
{
	// Process all modules
	for (unsigned int i = 0; i < p_entities.size(); i++)
	{
		NetworkSynced* netSync = static_cast<NetworkSynced*>(p_entities[i]->getComponent(ComponentType::NetworkSynced));
		
		for (unsigned int j = 0; j < m_toActivate.size(); j++)
		{
			if (m_toActivate[j] == netSync->getNetworkOwner())
			{
				//Do Activate
				setActivation(p_entities[i], true);
				m_toActivate[j] = m_toActivate.back();
				m_toActivate.pop_back();
				j--;
			}
		}
		for (unsigned int j = 0; j < m_toDeactivate.size(); j++)
		{
			if (m_toDeactivate[j] == netSync->getNetworkOwner())
			{
				//Do Deactivate
				setActivation(p_entities[i], false);
				m_toDeactivate[j] = m_toDeactivate.back();
				m_toDeactivate.pop_back();
				j--;
			}
		}
		for (unsigned int j = 0; j < m_toHighlight.size(); j++)
		{
			if (m_toHighlight[j].id == netSync->getNetworkOwner())
			{
				//Do highlight
				changeHighlight(p_entities[i], m_toHighlight[j].slot,
					m_toHighlight[j].status);
				m_toHighlight[j] = m_toHighlight.back();
				m_toHighlight.pop_back();
				j--;
			}
		}	

		//Check to see if modules should be dropped
		pair<float,int> massBoosters(0.0f,0);
		checkDrop_ApplyScoreAndDamage(p_entities[i],massBoosters);

		// send mass and booster count to client
		if(static_cast<TimerSystem*>(m_world->getSystem(SystemType::TimerSystem))->
			checkTimeInterval(TimerIntervals::EverySecond))
		{
			// add ship mass too!
			float shipmass=0.0f;
			PhysicsBody* body = static_cast<PhysicsBody*>(
				p_entities[i]->getComponent(ComponentType::PhysicsBody));
			shipmass = m_physicsSystem->getController()->getBody(body->m_id)->GetMass();
			//
			sendMassBoostersTotal(netSync->getNetworkOwner(),
				50.0f*(1.5f*shipmass+0.4f*massBoosters.first),massBoosters.second);
		}

		//Check if the player has recieved enough damage score for it to be applied
		PlayerSystem* playerSys = static_cast<PlayerSystem*>
			(m_world->getSystem(SystemType::PlayerSystem));

		NetworkSynced* sync = static_cast<NetworkSynced*>(p_entities[i]->getComponent(ComponentType::NetworkSynced));

		PlayerComponent* scoreComponent = playerSys->getPlayerCompFromNetworkComp(sync);
		if (scoreComponent)
		{
			Transform* trans = static_cast<Transform*>(p_entities[i]->getComponent(ComponentType::Transform));
			if (scoreComponent->getDealtDamageScore() > 5)
			{
				setScoreEffect(sync->getNetworkOwner(), trans, (int)(scoreComponent->getDealtDamageScore()+0.5f));
				scoreComponent->applyDealtDamageScore();
			}
		}
	}
}
示例#9
0
void CPetGlyphs::clear() {
	changeHighlight(-1);
	destroyContents();
	_firstVisibleIndex = 0;
}