
#include "stdafx.h"
#include "Game.h"
#include <FSTREAM>

void CDuch::Draw()
{
	std::list<TDuch>::iterator i = _vData.begin();
	for(; i != _vData.end(); i++)
	{
		glPushAttrib( GL_ENABLE_BIT );
		glDisable( GL_FOG );
		C_3DOBJECT_0 obj( _texID, i->pos.x, i->pos.y, i->pos.z, i->vel.width, i->vel.height, 0.0f );
		obj.SetBlend(1);
		obj.SetColorf(1,1, i->live);
		obj.Render();
		glPopAttrib();
	}
}

void CDuch::Move( )
{
	std::list<TDuch>::iterator i = _vData.begin();
	for(; i != _vData.end(); i++)
	{
		i->live -= i->speed;
		i->pos.y += i->speed;
		if( i->live < 0 ) i = _vData.erase( i );
		
	}
}

void CDuch::Add( CVector3 pos, TVel vel )
{
	TDuch t;
	t.pos = pos;
	t.vel = vel;
	t.live = 1.0f;
	t.speed = 0.005f;
	_vData.push_back( t );
}

void DrawBlesk( CVector3 pos, TVel vel, float blend )
{
	glPushAttrib( GL_ENABLE_BIT );
	glDisable( GL_FOG );
	uint texture_id = g_texBlesk[ (rand()%3) ];
	C_3DOBJECT_0 obj( TM.GetIdTexture( texture_id ), pos.x, pos.y, pos.z, vel.width, vel.height ,0.0f );
	obj.SetBlend(1);
	glColor4f(1,1,1, blend);
	obj.Render();
	glPopAttrib();
}

void DrawVyberMenu( )
{
	static float blend = 0.6f;
	static float vel = 41.0f;
	static float vel_plus = (2.0f*60)/g_fps.GetFPS();
	vel += vel_plus;
	if( vel > 140 || vel < 40 ) vel_plus = -vel_plus; 
	std::string text = W_GetString( "ID_BUTTON%d", g_aktKolo+1 );
	TPoint pos = VratPosTlac( menu_vyber, text );
	float w=vel, h=vel;
	C_2DOBJECT_0 obj( TM.GetIdTexture( g_textures[33] ), pos.x-w/2, pos.y-h/2, w, h );
	glColor4f(1,1,1, blend );
	obj.SetBlend(1);
	obj.SetAplha(0);
	obj.SetNoBlend(1);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	obj.Render();

	// Vyzkum zvyrazneni
	if( g_showUpozVyz && g_aktKolo == 1 )
	{
		int iFontSize = (SCRWidth)/(70);
		C_BASEGUI_0 *base = menu_vyber.GetPointerObject("ID_BUT_VYZ");
		TRect rect = base->GetRect();
		g_font.Print(rect.x+rect.width+20,rect.y+rect.height/2-iFontSize/2, " <<< Ve výzkumu můžete zkoumat nové technologie! !!! ");
		C_BUTTON_0 *button = (C_BUTTON_0*)base;
		button->GetTextureId();
	
		static float blend2 = 1.0f;
		static float zes = 0.0f;
		zes += (1*60)/g_fps.GetFPS();
		blend2 -= (0.01f*60)/g_fps.GetFPS();
		if( blend2 <= 0.2f )
		{
			blend2 = 1.0f;
			zes = 0.0f;
		}
		C_2DOBJECT_0 obj1( button->GetTextureId(), rect.x-zes,rect.y-zes, rect.width+zes*2, rect.height+zes*2 );
		glColor4f(1,1,1, blend2 );
		obj1.SetBlend(1);
		obj1.SetAplha(0);
		obj1.SetNoBlend(1);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		if( !g_butVyzMove ) obj1.Render();
		else
		{
			blend2 = 1.0f;
			zes = 0.0f;
		}	
	}
}