Ejemplo n.º 1
0
int Menu::update(int mousex, int mousey, int click)
{
	static int oldw = 0, oldh = 0;
	static Uint32 oldflags;
	int i;
	MenuItem *m;

	painted = false;
	
	
	// se a resolucao mudou
	if (oldw != SDL_GetVideoSurface()->w || oldh != SDL_GetVideoSurface()->h ||
	 oldflags != SDL_GetVideoSurface()->flags )
	{
		oldw = SDL_GetVideoSurface()->w;
		oldh = SDL_GetVideoSurface()->h;
		oldflags = SDL_GetVideoSurface()->flags;
		reconfigureDisplay();
		paint();
	}
	
	// XXX - nao sei por que, mas fica lento se tirar isso
	::EscreveString(0, 0, " ");
	
	for (i = 0; i < items.size(); i++)
	{
		m = items[i];

		if (m->contains(mousex, mousey))
		{
			if (m != selected) {
				selected = m;
				paint();
			}
			if (click)
				return m->getId();
			else
				return 0;
		}
	}
	
	return 0;
}