Beispiel #1
0
Datei: scores.c Projekt: 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();
	
}
Beispiel #2
0
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);
	
}