Example #1
0
void scores_view(int citem)
{
	fix time_out_value;
	fix t1;
	int i,done,looper;
	int k;
	byte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };

ReshowScores:
	scores_read();

	set_screen_mode(SCREEN_MENU);
	
	gr_set_current_canvas(NULL);
	
	nm_draw_background(0,0,grd_curcanv->cv_bitmap.bm_w, grd_curcanv->cv_bitmap.bm_h );

	grd_curcanv->cv_font = Gamefonts[GFONT_MEDIUM_3];

	gr_string( 0x8000, 15, TXT_HIGH_SCORES );

	grd_curcanv->cv_font = Gamefonts[GFONT_SMALL];

	gr_set_fontcolor( BM_XRGB(31,26,5), -1 );
	gr_string(  31+33+XX, 46+7+YY, TXT_NAME );
	gr_string(  82+33+XX, 46+7+YY, TXT_SCORE );
	gr_string( 127+33+XX, 46+7+YY, TXT_SKILL );
	gr_string( 170+33+XX, 46+7+YY, TXT_LEVELS );
//	gr_string( 202, 46, "Kills" );
//	gr_string( 234, 46, "Rescues" );
	gr_string( 288-42+XX, 46+7+YY, TXT_TIME );

	if ( citem < 0 )	
		gr_string( 0x8000, 175, TXT_PRESS_CTRL_R );

	gr_set_fontcolor( BM_XRGB(28,28,28), -1 );

	gr_printf( 0x8000, 31, "%c%s%c  - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name );
	
	for (i=0; i<MAX_HIGH_SCORES; i++ )		{
		if (i==0)	{
			gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
		} else {
			gr_set_fontcolor( gr_fade_table[BM_XRGB(28,28,28)+((28-i*2)*256)], -1 );
		}														 
		scores_draw_item( i, &Scores.stats[i] );
	}

	gr_palette_fade_in( gr_palette,32, 0);

	game_flush_inputs();

	done = 0;
	looper = 0;

	time_out_value = timer_get_fixed_seconds()+i2f(60*5);
	while(!done)	{
		if ( citem > -1 )	{
	
			t1	= timer_get_fixed_seconds();
			if ( t1 > time_out_value ) done = 1;
			while ( timer_get_fixed_seconds() < t1+F1_0/128 );	

			gr_set_fontcolor( gr_fade_table[fades[looper]*256+BM_XRGB(28,28,28)], -1 );
			looper++;
			if (looper>63) looper=0;
			if ( citem ==  MAX_HIGH_SCORES )
				scores_draw_item( MAX_HIGH_SCORES, &Last_game );
			else
				scores_draw_item( citem, &Scores.stats[citem] );
		}

		for (i=0; i<4; i++ )	
			if (joy_get_button_down_cnt(i)>0) done=1;
		for (i=0; i<3; i++ )	
			if (mouse_button_down_count(i)>0) done=1;

		k = key_inkey();
		switch( k )	{
		case KEY_CTRLED+KEY_R:		
			if ( citem < 0 )		{
				// Reset scores...
				if ( nm_messagebox( NULL, 2,  TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 )	{
					remove( get_scores_filename() );
					gr_palette_fade_out( gr_palette, 32, 0 );
					goto ReshowScores;
				}
			}
			break;
		case KEY_BACKSP:				Int3(); k = 0; break;
		case KEY_PRINT_SCREEN:		save_screen_shot(0); k = 0; break;
			
		case KEY_ENTER:
		case KEY_SPACEBAR:
		case KEY_ESC:
			done=1;
			break;
		}
	}

// Restore background and exit
	gr_palette_fade_out( gr_palette, 32, 0 );
	gr_set_current_canvas(NULL);

	game_flush_inputs();
	
}
Example #2
0
File: scores.c Project: paud/d2x-xl
void scores_view(int citem)
{
	fix t0 = 0, t1;
	int c,i,done,looper;
	int k, bRedraw = 0;
	sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };
	bkg bg;
	
	memset (&bg, 0, sizeof (bg));

ReshowScores:
	scores_read();

	SetScreenMode(SCREEN_MENU);
 
	WINDOS(	DDGrSetCurrentCanvas(NULL),
				GrSetCurrentCanvas(NULL)
	);
	
	xOffs = (grdCurCanv->cv_bitmap.bm_props.w - 640) / 2;
	yOffs = (grdCurCanv->cv_bitmap.bm_props.h - 480) / 2;
	if (xOffs < 0)
		xOffs = 0;
	if (yOffs < 0)
		yOffs = 0; 

	GameFlushInputs();

	done = 0;
	looper = 0;

	while(!done)	{
		if (!bRedraw || gameOpts->menus.nStyle) {
			NMDrawBackground(&bg,xOffs, yOffs, xOffs + 640, xOffs + 480, bRedraw);
			grdCurCanv->cv_font = MEDIUM3_FONT;

		WIN(DDGRLOCK(dd_grd_curcanv));
			GrString( 0x8000, yOffs + LHY(15), TXT_HIGH_SCORES );

			grdCurCanv->cv_font = SMALL_FONT;

			GrSetFontColorRGBi (RGBA_PAL (31,26,5), 1, 0, 0);
			GrString(  xOffs + LHX(31+33+XX), yOffs + LHY(46+7+YY), TXT_NAME );
			GrString(  xOffs + LHX(82+33+XX), yOffs + LHY(46+7+YY), TXT_SCORE );
			GrString( xOffs + LHX(127+33+XX), yOffs + LHY(46+7+YY), TXT_SKILL );
			GrString( xOffs + LHX(170+33+XX), yOffs + LHY(46+7+YY), TXT_LEVELS );
		//	GrString( 202, 46, "Kills" );
		//	GrString( 234, 46, "Rescues" );
			GrString( xOffs + LHX(288-42+XX), yOffs + LHY(46+7+YY), TXT_TIME );

			if ( citem < 0 )	
				GrString( 0x8000, yOffs + LHY(175), TXT_PRESS_CTRL_R );

			GrSetFontColorRGBi (RGBA_PAL (28,28,28), 1, 0, 0);

			//GrPrintF( 0x8000, yOffs + LHY(31), "%c%s%c  - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name );
		WIN(DDGRUNLOCK(dd_grd_curcanv));	

			for (i=0; i<MAX_HIGH_SCORES; i++ )		{
				//@@if (i==0)	{
				//@@	GrSetFontColorRGBi (RGBA_PAL (28,28,28), 1, 0, 0);
				//@@} else {
				//@@	GrSetFontColor( grFadeTable[BM_XRGB(28,28,28)+((28-i*2)*256)], 1, 0, 0);
				//@@}														 
				c = 28 - i * 2;
				GrSetFontColorRGBi (RGBA_PAL (c, c, c), 1, 0, 0);
				scores_draw_item( i, Scores.stats + i);
			}

			GrPaletteFadeIn( NULL,32, 0);

		#ifdef OGL
			if (citem < 0)
				GrUpdate (0);
		#endif
			bRedraw = 1;
			}
		if ( citem > -1 )	{
	
			t1	= TimerGetFixedSeconds();
			//if (t1 - t0 >= F1_0/128 ) 
			{
				t0 = t1;
				//@@GrSetFontColor( grFadeTable[fades[looper]*256+BM_XRGB(28,28,28)], -1 );
				c = 7 + fades [looper];
				GrSetFontColorRGBi (RGBA_PAL (c, c, c), 1, 0, 0);
				if (++looper > 63) 
				 looper=0;
				if ( citem ==  MAX_HIGH_SCORES )
					scores_draw_item( MAX_HIGH_SCORES, &Last_game );
				else
					scores_draw_item( citem, Scores.stats + citem );
				}
			GrUpdate (0);
		}

		for (i=0; i<4; i++ )	
			if (joy_get_button_down_cnt(i)>0) done=1;
		for (i=0; i<3; i++ )	
			if (MouseButtonDownCount(i)>0) done=1;

		//see if redbook song needs to be restarted
		songs_check_redbook_repeat();

	#ifdef WINDOWS
		{
			MSG msg;

			DoMessageStuff(&msg);

			if (_RedrawScreen) {
				_RedrawScreen = FALSE;
				goto ReshowScores;
			}

			DDGRRESTORE;
	 	}
	#endif

		k = KeyInKey();
		switch( k )	{
		case KEY_CTRLED+KEY_R:		
			if ( citem < 0 )		{
				// Reset scores...
				if ( ExecMessageBox( NULL, NULL, 2,  TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 )	{
					CFDelete(get_scores_filename(), gameFolders.szDataDir);
					GrPaletteFadeOut (NULL, 32, 0 );
					goto ReshowScores;
				}
			}
			break;
		case KEY_BACKSP:				Int3(); k = 0; break;
		case KEY_PRINT_SCREEN:		SaveScreenShot (NULL, 0); k = 0; break;
			
		case KEY_ENTER:
		case KEY_SPACEBAR:
		case KEY_ESC:
			done=1;
			break;
		}
	}

// Restore background and exit
	GrPaletteFadeOut (NULL, 32, 0 );

#ifdef WINDOWS
	DDGRRESTORE;
#endif

	WINDOS(	DDGrSetCurrentCanvas(NULL),
				GrSetCurrentCanvas(NULL)
	);

	GameFlushInputs();
	NMRemoveBackground (&bg);
	
}
Example #3
0
File: scores.c Project: btb/d2x
void scores_view(int citem)
{
	grs_canvas *center_canv;
	fix t1;
	int i,done,looper;
	int k;
	sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };

ReshowScores:
	scores_read();

	set_screen_mode(SCREEN_MENU);
 
	gr_set_current_canvas(NULL);
	
	nm_draw_background(0, 0, GWIDTH-1, GHEIGHT-1); // args are x,y,x2,y2 NOT x,y,w,h

	center_canv = gr_create_sub_canvas(grd_curcanv, GWIDTH/2-LHX(160), 0, LHX(320), GHEIGHT);
	gr_set_current_canvas(center_canv);

	grd_curcanv->cv_font = MEDIUM3_FONT;

	gr_string( 0x8000, LHY(15), TXT_HIGH_SCORES );

	grd_curcanv->cv_font = SMALL_FONT;

	gr_set_fontcolor( BM_XRGB(31,26,5), -1 );
	gr_string(  LHX(31+33+XX), LHY(46+7+YY), TXT_NAME );
	gr_string(  LHX(82+33+XX), LHY(46+7+YY), TXT_SCORE );
	gr_string( LHX(127+33+XX), LHY(46+7+YY), TXT_SKILL );
	gr_string( LHX(170+33+XX), LHY(46+7+YY), TXT_LEVELS );
//	gr_string( 202, 46, "Kills" );
//	gr_string( 234, 46, "Rescues" );
	gr_string( LHX(288-42+XX), LHY(46+7+YY), TXT_TIME );

	if ( citem < 0 )	
		gr_string( 0x8000, LHY(175), TXT_PRESS_CTRL_R );

	gr_set_fontcolor( BM_XRGB(28,28,28), -1 );

	gr_printf( 0x8000, LHY(31), "%c%s%c  - %s", 34, Scores.cool_saying, 34, Scores.stats[0].name );

	for (i=0; i<MAX_HIGH_SCORES; i++ )		{
		//@@if (i==0)	{
		//@@	gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
		//@@} else {
		//@@	gr_set_fontcolor( gr_fade_table[BM_XRGB(28,28,28)+((28-i*2)*256)], -1 );
		//@@}														 

		gr_set_fontcolor( BM_XRGB(28-i*2,28-i*2,28-i*2), -1 );
		scores_draw_item( i, &Scores.stats[i] );
	}

	gr_palette_fade_in( gr_palette,32, 0);

#ifdef OGL
	vid_update();
#endif

	game_flush_inputs();

	done = 0;
	looper = 0;

	while(!done)	{
		if ( citem > -1 )	{
	
			t1	= timer_get_fixed_seconds();
			while ( timer_get_fixed_seconds() < t1+F1_0/128 );	

			//@@gr_set_fontcolor( gr_fade_table[fades[looper]*256+BM_XRGB(28,28,28)], -1 );
			gr_set_fontcolor( BM_XRGB(7+fades[looper],7+fades[looper],7+fades[looper]), -1 );
			looper++;
			if (looper>63) looper=0;
			if ( citem ==  MAX_HIGH_SCORES )
				scores_draw_item( MAX_HIGH_SCORES, &Last_game );
			else
				scores_draw_item( citem, &Scores.stats[citem] );
			vid_update();
		}

		for (i=0; i<4; i++ )	
			if (joy_get_button_down_cnt(i)>0) done=1;
		for (i=0; i<3; i++ )	
			if (mouse_button_down_count(i)>0) done=1;

		//see if redbook song needs to be restarted
		songs_check_redbook_repeat();

		k = newmenu_inkey();
		switch( k )	{
		case KEY_CTRLED+KEY_R:		
			if ( citem < 0 )		{
				// Reset scores...
				if ( nm_messagebox( NULL, 2,  TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 )	{
					PHYSFS_delete(get_scores_filename());
					gr_palette_fade_out( gr_palette, 32, 0 );
					goto ReshowScores;
				}
			}
			break;
		case KEY_BACKSP:				Int3(); k = 0; break;
		case KEY_PRINT_SCREEN:		save_screen_shot(0); k = 0; break;
			
		case KEY_ENTER:
		case KEY_SPACEBAR:
		case KEY_ESC:
			done=1;
			break;
		}
	}

// Restore background and exit
	gr_palette_fade_out( gr_palette, 32, 0 );

	gr_set_current_canvas(NULL);
	gr_free_sub_canvas(center_canv);

	game_flush_inputs();
	
}
Example #4
0
int scores_handler(window *wind, d_event *event, scores_menu *menu)
{
	int i;
	int k;
	sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 };
	int w = FSPACX(290), h = FSPACY(170);

	switch (event->type)
	{
		case EVENT_WINDOW_ACTIVATED:
			game_flush_inputs();
			break;
			
		case EVENT_KEY_COMMAND:
			k = event_key_get(event);
			switch( k )	{
				case KEY_CTRLED+KEY_R:		
					if ( menu->citem < 0 )		{
						// Reset scores...
						if ( nm_messagebox( NULL, 2,  TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 )	{
							PHYSFS_delete(SCORES_FILENAME);
							scores_view(&menu->last_game, menu->citem);	// create new scores window
							window_close(wind);			// then remove the old one
						}
					}
					return 1;
					
				case KEY_ENTER:
				case KEY_SPACEBAR:
				case KEY_ESC:
					window_close(wind);
					return 1;
			}
			break;

		case EVENT_MOUSE_BUTTON_DOWN:
		case EVENT_MOUSE_BUTTON_UP:
			if (event_mouse_get_button(event) == MBTN_LEFT || event_mouse_get_button(event) == MBTN_RIGHT)
			{
				window_close(wind);
				return 1;
			}
			break;

		case EVENT_IDLE:
			timer_delay2(50);
			break;

		case EVENT_WINDOW_DRAW:
			gr_set_current_canvas(NULL);
			
			nm_draw_background(((SWIDTH-w)/2)-BORDERX,((SHEIGHT-h)/2)-BORDERY,((SWIDTH-w)/2)+w+BORDERX,((SHEIGHT-h)/2)+h+BORDERY);
			
			gr_set_current_canvas(window_get_canvas(wind));
			
			grd_curcanv->cv_font = MEDIUM3_FONT;
			
			gr_string( 0x8000, FSPACY(15), TXT_HIGH_SCORES );
			
			grd_curcanv->cv_font = GAME_FONT;
			
			gr_set_fontcolor( BM_XRGB(31,26,5), -1 );
			gr_string( FSPACX( 71), FSPACY(50), TXT_NAME );
			gr_string( FSPACX(122), FSPACY(50), TXT_SCORE );
			gr_string( FSPACX(167), FSPACY(50), TXT_SKILL );
			gr_string( FSPACX(210), FSPACY(50), TXT_LEVELS );
			gr_string( FSPACX(253), FSPACY(50), TXT_TIME );
			
			if ( menu->citem < 0 )	
				gr_string( 0x8000, FSPACY(175), TXT_PRESS_CTRL_R );
			
			gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
			
			gr_printf( 0x8000, FSPACY(31), "%c%s%c  - %s", 34, menu->scores.cool_saying, 34, menu->scores.stats[0].name );
			
			for (i=0; i<MAX_HIGH_SCORES; i++ )		{
				gr_set_fontcolor( BM_XRGB(28-i*2,28-i*2,28-i*2), -1 );
				scores_draw_item( i, &menu->scores.stats[i] );
			}
			
			if ( menu->citem > -1 )	{
				
				gr_set_fontcolor( BM_XRGB(7+fades[menu->looper],7+fades[menu->looper],7+fades[menu->looper]), -1 );
				if (timer_query() >= menu->t1+F1_0/128)
				{
					menu->t1 = timer_query();
					menu->looper++;
					if (menu->looper>63) menu->looper=0;
				}

				if ( menu->citem ==  MAX_HIGH_SCORES )
					scores_draw_item( MAX_HIGH_SCORES, &menu->last_game );
				else
					scores_draw_item( menu->citem, &menu->scores.stats[menu->citem] );
			}
			gr_set_current_canvas(NULL);
			break;
			
		case EVENT_WINDOW_CLOSE:
			d_free(menu);
			break;

		default:
			break;
	}
	
	return 0;
}