Ejemplo n.º 1
0
void TGLapp::replaybrowser_draw(void)
{
//	char buffer[255];

	glClearColor(0,0,0,1);
    glClear(GL_COLOR_BUFFER_BIT);

	TGLinterface::draw();

	if (m_rb_replay_selected!=-1) {
		int i=m_rb_replay_selected-m_sr_first_replay;
		if (i>=0 && i<SAVEREPLAY_REPLAYSPERPAGE) {
			glColor4f(0.5f,0.5f,1,0.7f);
			glBegin(GL_POLYGON);
			glVertex3f(15,float(40+i*22),0);
			glVertex3f(585,float(40+i*22),0);
			glVertex3f(585,float(60+i*22),0);
			glVertex3f(15,float(60+i*22),0);
			glEnd();
		} // if
	} // if 

	if (m_rb_mouse_over_replay!=-1) {
		float f;
		f=float(0.7+0.2*sin((m_state_cycle)*0.3F));
		glColor4f(0.5f,1,0.5f,f);
		glBegin(GL_POLYGON);
		glVertex3f(15,float(40+m_rb_mouse_over_replay*22),0);
		glVertex3f(585,float(40+m_rb_mouse_over_replay*22),0);
		glVertex3f(585,float(60+m_rb_mouse_over_replay*22),0);
		glVertex3f(15,float(60+m_rb_mouse_over_replay*22),0);
		glEnd();
	} // if 

	// show the list of files:
	{
		int i,j;
		char *info;		

		for(j=0,i=m_sr_first_replay;i<m_sr_first_replay+SAVEREPLAY_REPLAYSPERPAGE && i<m_sr_replay_names.Length();i++,j++) {
			{
				int old[4];
				bool old_scissor=false;

				glGetIntegerv(GL_SCISSOR_BOX,old);
				if (glIsEnabled(GL_SCISSOR_TEST)) old_scissor=true;
				glEnable(GL_SCISSOR_TEST);
				glScissor(10,0,200,480);
				TGLinterface::print_left(m_sr_replay_names[i],m_font16,20,float(60+j*22));
				glScissor(old[0],old[1],old[2],old[3]);
				if (!old_scissor) glDisable(GL_SCISSOR_TEST);
			}

			TGLinterface::print_left("-",m_font16,220,float(60+j*22));			

			info=m_sr_replay_info[i];
			if (info!=0) {

				TGLinterface::print_left(info,m_font16,250,float(60+j*22));

			} // if 
		} // for
	} 

	switch(m_state_fading) {
	case 0:	
			{
				float f=0;
				f=abs(int(25-m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	case 1:
			break;
	case 2:
			{
				float f=0;
				f=abs(int(m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	} // switch
} /* TGLapp::replaybrowser_draw */ 
void TGLapp::levelpackscreen_draw(void)
{
	char buffer[256];
	float replay_full_factor=0;

	glClearColor(0,0,0,1);
    glClear(GL_COLOR_BUFFER_BIT);

	TGLinterface::draw();

	// Draw scores:
	sprintf(buffer,"Total Points: %i",m_player_profile->get_points());
	TGLinterface::print_left(buffer,m_font16,230,40);
	sprintf(buffer,"Level Pack Points: %i",m_player_profile->get_points(m_current_levelpack->m_id));
	TGLinterface::print_left(buffer,m_font16,230,60);

	
	// Draw Selected ship:
	{
		int i,s;
		GLTile *t;

		for(i=-1;i<2;i++) {
			s= indexOf<int>(m_player_profile->m_ships, m_selected_ship)+i;
			if (s>=0 && s<m_player_profile->m_ships.size()) {
				t=m_GLTM->get(TGL::ship_tiles[getAt<int>(m_player_profile->m_ships, s)]);

				if (i==0) {
					t->draw(495,160,0,0,1);
				} else {
					t->draw(1,1,1,0.33f,float(495+i*48),160,0,0,0.66f);
				} // if 

			} // if
		} // for

		TGLinterface::print_center(TGL::ship_names[m_selected_ship],m_font32,495,220);
	}

	switch(m_lp_replay_mode) {
	case 0:
			replay_full_factor=0;
			break;
	case 1:
			{
				float f=0;
				f=abs(m_lp_replay_timmer)/25.0F;
				fade_in_alpha(f);
				replay_full_factor=f;
			}
			break;
	case 2: fade_in_alpha(1);
			replay_full_factor=1;
			break;
	case 3:
			{
				float f=0;
				f=abs(25-m_lp_replay_timmer)/25.0F;
				fade_in_alpha(f);
				replay_full_factor=f;
			}
			break;
	} // switch

	// Draw tutorial:
	{
		if (m_lp_tutorial_game!=0) {
			int old[4];

			glGetIntegerv(GL_VIEWPORT,old);
			glViewport(int(380*(1-replay_full_factor)),int(80*(1-replay_full_factor)), 
					   int(SCREEN_X*replay_full_factor+230*(1-replay_full_factor)),int(SCREEN_Y*replay_full_factor+172*(1-replay_full_factor)));
            glScissor(int(380*(1-replay_full_factor)),int(80*(1-replay_full_factor)),
                      int(SCREEN_X*replay_full_factor+230*(1-replay_full_factor)),int(SCREEN_Y*replay_full_factor+172*(1-replay_full_factor)));
            glEnable(GL_SCISSOR_TEST);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			m_lp_tutorial_game->draw(1.0, m_GLTM);
            glDisable(GL_SCISSOR_TEST);
			glViewport(old[0],old[1],old[2],old[3]);
            
			{
				float f=0.6f+0.4f*float(sin(m_state_cycle*0.1));

				if (m_lp_replay_mode==0 || m_lp_replay_mode==1) TGLinterface::print_center("Press F to maximize",m_font16,320*replay_full_factor+495*(1-replay_full_factor),20*replay_full_factor+250*(1-replay_full_factor),1,1,1,f);
				if (m_lp_replay_mode==2 || m_lp_replay_mode==3) TGLinterface::print_center("Press F to minimize",m_font16,320*replay_full_factor+495*(1-replay_full_factor),20*replay_full_factor+250*(1-replay_full_factor),1,1,1,f);
			}

			{
				int i,j;
				float y;
				char buffer[128];
				char *tmp=0;

				/* Text messages in replays */ 
				{
                    for(TextNode *n:m_lp_tutorial_replay_text) {
						if (n->m_time<m_lp_tutorial_game->get_cycle()) tmp = n->m_text;
					} // while 
				}

				if (tmp!=0) {
					i=0;
					y=445*replay_full_factor+425*(1-replay_full_factor);
					while(tmp[i]!=0) {
						for(j=0;tmp[i]!=0 && tmp[i]!='/';i++,j++) buffer[j]=tmp[i];
						buffer[j]=0;
						if (tmp[i]=='/') i++;
						TGLinterface::print_center(buffer,m_font16,320*replay_full_factor+495*(1-replay_full_factor),y);
						y+=20;
					} // while

				} // if 
			} 
		} else {
			TGLinterface::print_center("No tutorial available",m_font16,320*replay_full_factor+495*(1-replay_full_factor),240*replay_full_factor+300*(1-replay_full_factor));
		} // if 
	} 

	switch(m_state_fading) {
	case 0:	
			{
				float f=0;
				f=abs(int(25-m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	case 1:
			break;
	case 2:
			{
				float f=0;
				f=abs(int(m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	} // switch
} /* TGLapp::levelpackscreen_draw */ 
Ejemplo n.º 3
0
void TGLapp::postgame_draw(void)
{
	char buffer[255];
	glClearColor(0,0,0,1);
    glClear(GL_COLOR_BUFFER_BIT);

	{
		int time=-1;
		int fuel_used = -1;
		int shots = -1;
		float max_speed = 0.0f;
		float average_speed = 0.0f;
		int enemies_killed = -1;
		float accuracy = 0.0f;

		if (m_game->get_game_result()==1) {
			TGLinterface::print_center("Congratulations!",m_font32,320,96);
			time=m_game_replay->get_length();
		} else {
			TGLinterface::print_center("Better luck next time...",m_font16,320,96);
		} // if 

		fuel_used = m_game_replay->get_fuel_used();
		shots = m_game_replay->get_n_shots();
		max_speed = m_game_replay->get_max_speed();
		average_speed = m_game_replay->get_average_speed();

		if (time!=-1) {
			int mins,secs,milis;
			milis=time*18;
			secs=milis/1000;
			milis=milis%1000;
			mins=secs/60;
			secs=secs%60;
			sprintf(buffer,"Time taken: %i:%.2i:%.2i",mins,secs,milis/10);
		} else {
			sprintf(buffer,"Time taken: --:--:--");
		} // if 
		TGLinterface::print_center(buffer,m_font16,320,125);

		sprintf(buffer,"Fuel used: %i    Shots: %i",fuel_used,shots);
		TGLinterface::print_center(buffer,m_font16,320,145);

		sprintf(buffer,"Max speed: %.2f    Average Speed: %.2f",max_speed,average_speed);
		TGLinterface::print_center(buffer,m_font16,320,165);

		sprintf(buffer,"Current score: %i",m_player_profile->get_points());
		TGLinterface::print_center(buffer,m_font16,320,200);
		
		if (m_ship_unlocked!=-1) {
			sprintf(buffer,"New ship unlocked: '%s'!",TGL::ship_names[m_ship_unlocked]);
		} // if 
		TGLinterface::print_center(buffer,m_font16,320,225);
	}

	TGLinterface::draw();

	switch(m_state_fading) {
	case 0:	
			{
				float f=0;
				f=abs(int(25-m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	case 1:
			break;
	case 2:
			{
				float f=0;
				f=abs(int(m_state_fading_cycle))/25.0F;

				fade_in_alpha(f);
			}
			break;
	} // switch
} /* TGLapp::postgame_draw */