Make the scores menu into a window
This commit is contained in:
parent
afa0d75fb6
commit
ff1c8547f3
|
@ -3,6 +3,7 @@ D2X-Rebirth Changelog
|
||||||
20100207
|
20100207
|
||||||
--------
|
--------
|
||||||
main/game.c, main/gameseq.c, main/inferno.c, main/inferno.h, main/menu.c, main/newdemo.c: Create the main event loop and use it for the game and main menu
|
main/game.c, main/gameseq.c, main/inferno.c, main/inferno.h, main/menu.c, main/newdemo.c: Create the main event loop and use it for the game and main menu
|
||||||
|
main/scores.c: Make the scores menu into a window
|
||||||
|
|
||||||
20100206
|
20100206
|
||||||
--------
|
--------
|
||||||
|
|
142
main/scores.c
142
main/scores.c
|
@ -25,6 +25,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#include "scores.h"
|
#include "scores.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "pstypes.h"
|
#include "pstypes.h"
|
||||||
|
#include "window.h"
|
||||||
#include "gr.h"
|
#include "gr.h"
|
||||||
#include "key.h"
|
#include "key.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
@ -327,42 +328,61 @@ void scores_draw_item( int i, stats_info * stats )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void scores_view(int citem)
|
typedef struct scores_menu
|
||||||
{
|
{
|
||||||
|
int citem;
|
||||||
fix t1;
|
fix t1;
|
||||||
int i,done,looper;
|
int looper;
|
||||||
|
} scores_menu;
|
||||||
|
|
||||||
|
int scores_handler(window *wind, d_event *event, scores_menu *menu)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
int k;
|
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 };
|
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 };
|
||||||
grs_canvas canvas;
|
|
||||||
int w = FSPACX(290), h = FSPACY(170);
|
int w = FSPACX(290), h = FSPACY(170);
|
||||||
|
|
||||||
gr_palette_load( gr_palette );
|
switch (event->type)
|
||||||
newmenu_close();
|
{
|
||||||
|
case EVENT_KEY_COMMAND:
|
||||||
|
k = ((d_event_keycommand *)event)->keycode;
|
||||||
|
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(get_scores_filename());
|
||||||
|
scores_view(menu->citem); // create new scores window
|
||||||
|
window_close(wind); // then remove the old one
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KEY_BACKSP: Int3(); k = 0; break;
|
||||||
|
case KEY_PRINT_SCREEN: save_screen_shot(0); k = 0; break;
|
||||||
|
|
||||||
ReshowScores:
|
case KEY_ENTER:
|
||||||
scores_read();
|
case KEY_SPACEBAR:
|
||||||
|
case KEY_ESC:
|
||||||
|
window_close(wind);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
set_screen_mode(SCREEN_MENU);
|
case EVENT_IDLE:
|
||||||
|
|
||||||
gr_set_current_canvas(NULL);
|
|
||||||
|
|
||||||
gr_init_sub_canvas(&canvas, &grd_curscreen->sc_canvas, (SWIDTH - FSPACX(320))/2, (SHEIGHT - FSPACY(200))/2, FSPACX(320), FSPACY(200));
|
|
||||||
|
|
||||||
game_flush_inputs();
|
|
||||||
|
|
||||||
done = 0;
|
|
||||||
looper = 0;
|
|
||||||
|
|
||||||
while(!done) {
|
|
||||||
timer_delay2(50);
|
timer_delay2(50);
|
||||||
|
|
||||||
|
//see if redbook song needs to be restarted
|
||||||
|
RBACheckFinishedHook();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVENT_WINDOW_DRAW:
|
||||||
gr_set_current_canvas(NULL);
|
gr_set_current_canvas(NULL);
|
||||||
gr_flip();
|
|
||||||
#ifdef OGL
|
#ifdef OGL
|
||||||
nm_draw_background1(Menu_pcx_name);
|
nm_draw_background1(Menu_pcx_name);
|
||||||
#endif
|
#endif
|
||||||
nm_draw_background(((SWIDTH-w)/2)-BORDERX,((SHEIGHT-h)/2)-BORDERY,((SWIDTH-w)/2)+w+BORDERX,((SHEIGHT-h)/2)+h+BORDERY);
|
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(&canvas);
|
gr_set_current_canvas(window_get_canvas(wind));
|
||||||
|
|
||||||
grd_curcanv->cv_font = MEDIUM3_FONT;
|
grd_curcanv->cv_font = MEDIUM3_FONT;
|
||||||
|
|
||||||
|
@ -377,7 +397,7 @@ ReshowScores:
|
||||||
gr_string( FSPACX(210), FSPACY(50), TXT_LEVELS );
|
gr_string( FSPACX(210), FSPACY(50), TXT_LEVELS );
|
||||||
gr_string( FSPACX(253), FSPACY(50), TXT_TIME );
|
gr_string( FSPACX(253), FSPACY(50), TXT_TIME );
|
||||||
|
|
||||||
if ( citem < 0 )
|
if ( menu->citem < 0 )
|
||||||
gr_string( 0x8000, FSPACY(175), TXT_PRESS_CTRL_R );
|
gr_string( 0x8000, FSPACY(175), TXT_PRESS_CTRL_R );
|
||||||
|
|
||||||
gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
|
gr_set_fontcolor( BM_XRGB(28,28,28), -1 );
|
||||||
|
@ -389,45 +409,53 @@ ReshowScores:
|
||||||
scores_draw_item( i, &Scores.stats[i] );
|
scores_draw_item( i, &Scores.stats[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( citem > -1 ) {
|
if ( menu->citem > -1 ) {
|
||||||
|
|
||||||
t1 = timer_get_fixed_seconds();
|
gr_set_fontcolor( BM_XRGB(7+fades[menu->looper],7+fades[menu->looper],7+fades[menu->looper]), -1 );
|
||||||
while ( timer_get_fixed_seconds() < t1+F1_0/128 );
|
if (timer_get_fixed_seconds() >= menu->t1+F1_0/128)
|
||||||
|
{
|
||||||
|
menu->t1 = timer_get_fixed_seconds();
|
||||||
|
menu->looper++;
|
||||||
|
if (menu->looper>63) menu->looper=0;
|
||||||
|
}
|
||||||
|
|
||||||
gr_set_fontcolor( BM_XRGB(7+fades[looper],7+fades[looper],7+fades[looper]), -1 );
|
if ( menu->citem == MAX_HIGH_SCORES )
|
||||||
looper++;
|
|
||||||
if (looper>63) looper=0;
|
|
||||||
if ( citem == MAX_HIGH_SCORES )
|
|
||||||
scores_draw_item( MAX_HIGH_SCORES, &Last_game );
|
scores_draw_item( MAX_HIGH_SCORES, &Last_game );
|
||||||
else
|
else
|
||||||
scores_draw_item( citem, &Scores.stats[citem] );
|
scores_draw_item( menu->citem, &Scores.stats[menu->citem] );
|
||||||
}
|
}
|
||||||
|
|
||||||
//see if redbook song needs to be restarted
|
|
||||||
RBACheckFinishedHook();
|
|
||||||
|
|
||||||
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 ) {
|
|
||||||
PHYSFS_delete(get_scores_filename());
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gr_set_current_canvas(NULL);
|
gr_set_current_canvas(NULL);
|
||||||
game_flush_inputs();
|
break;
|
||||||
|
|
||||||
|
case EVENT_WINDOW_CLOSE:
|
||||||
|
d_free(menu);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void scores_view(int citem)
|
||||||
|
{
|
||||||
|
scores_menu *menu;
|
||||||
|
|
||||||
|
MALLOC(menu, scores_menu, 1);
|
||||||
|
if (!menu)
|
||||||
|
return;
|
||||||
|
|
||||||
|
menu->citem = citem;
|
||||||
|
menu->t1 = timer_get_fixed_seconds();
|
||||||
|
menu->looper = 0;
|
||||||
|
|
||||||
|
newmenu_close();
|
||||||
|
|
||||||
|
scores_read();
|
||||||
|
|
||||||
|
set_screen_mode(SCREEN_MENU);
|
||||||
|
|
||||||
|
window_create(&grd_curscreen->sc_canvas, (SWIDTH - FSPACX(320))/2, (SHEIGHT - FSPACY(200))/2, FSPACX(320), FSPACY(200),
|
||||||
|
(int (*)(window *, d_event *, void *))scores_handler, menu);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue