1 /*
2 * Abuse - dark 2D side-scrolling platform game
3 * Copyright (c) 1995 Crack dot Com
4 * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5 *
6 * This software was released into the Public Domain. As with most public
7 * domain software, no warranty is made or implied by Crack dot Com, by
8 * Jonathan Clark, or by Sam Hocevar.
9 */
10
11 #if defined HAVE_CONFIG_H
12 # include "config.h"
13 #endif
14
15 #include "common.h"
16
17 #include "help.h"
18 #include "game.h"
19 #include "netcfg.h"
20
21 int total_help_screens;
22 int *help_screens;
23 static int help_page=0;
24
25 void fade_in(image *im, int steps);
26 void fade_out(int steps);
27
draw_help()28 void draw_help()
29 {
30 image *im=cache.img(help_screens[help_page]);
31 int x1=xres/2-im->Size().x/2,y1=yres/2-im->Size().y/2;
32 int x2=x1+im->Size().x,y2=y1+im->Size().y;
33 im->put_image(screen,x1,y1);
34 screen->bar(0,0,x1-1,yres,0);
35 screen->bar(0,0,xres,y1-1,0);
36 screen->bar(x2,y1,xres,yres,0);
37 screen->bar(x1,y2,x2,yres,0);
38 }
39
help_handle_event(event & ev)40 void help_handle_event(event &ev)
41 {
42 if (ev.window!=NULL) return ;
43
44 if (the_game->state!=HELP_STATE)
45 {
46 if (ev.type==EV_KEY && (ev.key=='h' || ev.key=='?' || ev.key==JK_F1) && help_screens)
47 {
48 if (!main_net_cfg || (main_net_cfg->state!=net_configuration::SERVER && main_net_cfg->state!=net_configuration::CLIENT))
49 {
50 the_game->state=HELP_STATE;
51 help_page=0;
52 }
53 }
54 } else if (ev.type==EV_KEY)
55 {
56 if (ev.key==JK_ESC || help_page>=total_help_screens-1)
57 {
58 the_game->state=RUN_STATE;
59 the_game->draw(0);
60 }
61 else
62 help_page++;
63 }
64 }
65