Beispiel #1
0
inline void	RefreshSelector(Game_Screen* gs)
{
	if (gs->refreshSelector == false)
		return ;
	Cam*	c;
	int16_t	newX;
	int16_t	newY;
	int16_t	newW;
	int16_t	newH;

	c = Cam::GetInstance();
	if (gs->nXSelector >= gs->xSelector)
	{
		newX = gs->xSelector;
		newW = gs->nXSelector - gs->xSelector;
	}
	else
	{
		newX = gs->nXSelector;
		newW = gs->xSelector - gs->nXSelector;
	}
	if (gs->nYSelector >= gs->ySelector)
	{
		newY = gs->ySelector;
		newH = gs->nYSelector - gs->ySelector;
	}
	else
	{
		newY = gs->nYSelector;
		newH = gs->ySelector - gs->nYSelector;
	}
//	std::cout << "SetPos(" << newX - c->GetOffsetX() << ", " << newY - c->GetOffsetY() << ")" << std::endl;
//	std::cout << "SetDim(" << newW << ", " << newH << ")" << std::endl;
	if (newX - c->GetOffsetX() >= UI_WIDTH ||
	    newY - c->GetOffsetY() >= UI_HEIGHT ||
	    newX - c->GetOffsetX() + newW >= UI_WIDTH ||
	    newY - c->GetOffsetY() + newH >= UI_HEIGHT)
	{
		gs->refreshSelector = false;
		return ;
	}
	gs->selector.SetPos(newX - c->GetOffsetX(), newY - c->GetOffsetY());
	gs->selector.SetDimension(newW, newH);
	gs->refreshSelector = false;
}
Beispiel #2
0
int	Map_Drawable::RefreshToSurface(ID::Surface* s,
				       int x, int y)
{
	Game*					g;
	Cam*					c;
	Map*					m;
	Light_Drawable*				cases;
	uint32_t				i;
//	uint32_t				indexSaver;
	uint32_t				tmpSaver;
	std::list<Unit*>::iterator		itU;
	std::list<Unit*>::iterator		endU;
	int					xMin;
	int					yMin;
	int					xMax;
	int					yMax;
	int					offsetCamX;
	int					offsetCamY;
	ID::Draw_Geometry_Circle*		focus;
	double					xU;
	double					yU;
	bool					selected;

	g = Game::GetInstance();
	c = Cam::GetInstance();
	m = Map::GetInstance();
	focus = ID::Draw_Geometry_Circle::GetInstance();

	if (this->__RefreshGrounds(UNDER_BACKGROUND, ON_BACKGROUND, s, x, y) == -1)
		return -1;

	cases = c->GetCases();
	offsetCamX = c->GetOffsetX();
	offsetCamY = c->GetOffsetY();
	xMax = c->GetCameraWidth() / CASE_SIDE_PIXELS;
	yMax = c->GetCameraHeight() / CASE_SIDE_PIXELS;
//	indexSaver = ((c->GetY() / CASE_SIDE_PIXELS) -
//		      (c->GetCameraHeightRayon() / CASE_SIDE_PIXELS)) *
//		     (c->GetMapWidth() / CASE_SIDE_PIXELS) +
//		     (c->GetX() / CASE_SIDE_PIXELS - c->GetCameraWidthRayon() / CASE_SIDE_PIXELS);
	tmpSaver = g->currentTick;
	yMin = 0;
	while (yMin < yMax)
	{
		xMin = 0;
		i = ((yMin + (c->GetOffsetY() / CASE_SIDE_PIXELS)) *
		     (c->GetMapWidth() / CASE_SIDE_PIXELS)) +
		    (c->GetOffsetX() / CASE_SIDE_PIXELS);
		while (xMin < xMax)
		{
			itU = m->cases[i].units.begin();
			endU = m->cases[i].units.end();
			while (itU != endU)
			{
				if (((*itU)->GetModel()->GetType() == TYPE_GROUND ||
				     (*itU)->GetModel()->GetType() == 3) &&
				    (*itU)->GetUpdateSaver() != tmpSaver)
				{
					(*itU)->SetUpdateSaver(tmpSaver);
					(*itU)->GetPositionXY(&xU, &yU);
					selected = (*itU)->GetTickSelection() == g->lastSelection;
					focus->Draw(s,
						    xU * CASE_SIDE_PIXELS - offsetCamX,
						    yU * CASE_SIDE_PIXELS - offsetCamY,
						    (*itU)->GetModel()->GetSize(),
						    selected,
						    &(m->_colorsPalette[(*itU)->GetPlayer()->GetID()]));
				}
				++itU;
			}
			++xMin;
			++i;
		}
		++yMin;
	}

	if (this->__RefreshGrounds(MIDDLEGROUND, MIDDLEGROUND, s, x, y) == -1)
		return -1;

	tmpSaver = g->currentTick + 1;
//	i = indexSaver;
	yMin = 0;
//	std::cout << "- - - - - - - - \n";
	while (yMin < yMax)
	{
		xMin = 0;
		i = ((yMin + (c->GetOffsetY() / CASE_SIDE_PIXELS)) *
		     (c->GetMapWidth() / CASE_SIDE_PIXELS)) +
		    (c->GetOffsetX() / CASE_SIDE_PIXELS);
		while (xMin < xMax)
		{
			itU = m->cases[i].units.begin();
			endU = m->cases[i].units.end();
//			std::cout << i << "	";
			while (itU != endU)
			{
				if (((*itU)->GetModel()->GetType() == TYPE_AIR ||
				     (*itU)->GetModel()->GetType() == 4) &&
				    (*itU)->GetUpdateSaver() != tmpSaver)
				{
//					std::cout << "|";
					(*itU)->SetUpdateSaver(tmpSaver);
					(*itU)->GetPositionXY(&xU, &yU);
					selected = ((*itU)->GetTickSelection() == g->lastSelection);
					focus->Draw(s,
						    xU * CASE_SIDE_PIXELS - offsetCamX,
						    yU * CASE_SIDE_PIXELS - offsetCamY,
						    (*itU)->GetModel()->GetSize(),
						    selected,
						    &(m->_colorsPalette[(*itU)->GetPlayer()->GetID()]));
				}
				++itU;
			}
			++xMin;
			++i;
		}
//		std::cout << "\n";
		++yMin;
	}

	if (this->__RefreshGrounds(HIGHGROUND, HIGHGROUND, s, x, y) == -1)
		return -1;

	tmpSaver = g->currentTick - 1;
	//i = indexSaver;
	yMin = 0;
	while (yMin < yMax)
	{
		i = ((yMin + (c->GetOffsetY() / CASE_SIDE_PIXELS)) *
		     (c->GetMapWidth() / CASE_SIDE_PIXELS)) +
		    (c->GetOffsetX() / CASE_SIDE_PIXELS);
		xMin = 0;
		while (xMin < xMax)
		{
			itU = m->cases[i].units.begin();
			endU = m->cases[i].units.end();
			while (itU != endU)
			{
				if ((*itU)->GetUpdateSaver() != tmpSaver)
				{
					(*itU)->SetUpdateSaver(tmpSaver);
					(*itU)->GetPositionXY(&xU, &yU);
					this->__RefreshBars(s,
							    xU * CASE_SIDE_PIXELS - offsetCamX - (*itU)->GetModel()->GetSize(),
							    yU * CASE_SIDE_PIXELS - offsetCamY - (*itU)->GetModel()->GetSize() - 5,
							    (*itU)->GetModel()->GetSize(),
							    (*itU)->GetHP(),
							    (*itU)->GetModel()->GetHPMax());
				}
				++itU;
			}
			++xMin;
			++i;
		}
		++yMin;
	}

	if (this->__RefreshGrounds(FOREGROUND, FOREGROUND, s, x, y) == -1)
		return -1;

	this->SetInvalidate(false);
	return 0;
}