source: abuse/trunk/src/help.cpp @ 528

Last change on this file since 528 was 512, checked in by Sam Hocevar, 11 years ago

imlib: use vec2i for image::size and unroll all necessary changes
everywhere else in the code.

File size: 1.4 KB
Line 
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 or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include "common.h"
14
15#include "help.h"
16#include "game.h"
17#include "netcfg.h"
18
19int total_help_screens;
20int *help_screens;
21static int help_page=0;
22
23void fade_in(image *im, int steps);
24void fade_out(int steps);
25
26void draw_help()
27{
28  image *im=cache.img(help_screens[help_page]);
29  int x1=xres/2-im->Size().x/2,y1=yres/2-im->Size().y/2;
30  int x2=x1+im->Size().x,y2=y1+im->Size().y;
31  im->put_image(screen,x1,y1);
32  screen->bar(0,0,x1-1,yres,0);
33  screen->bar(0,0,xres,y1-1,0);
34  screen->bar(x2,y1,xres,yres,0);
35  screen->bar(x1,y2,x2,yres,0);
36}
37
38void help_handle_event(event &ev)
39{
40  if (ev.window!=NULL) return ;
41
42  if (the_game->state!=HELP_STATE)
43  {
44    if (ev.type==EV_KEY && (ev.key=='h' || ev.key=='?' || ev.key==JK_F1) && help_screens)
45    {
46      if (!main_net_cfg || (main_net_cfg->state!=net_configuration::SERVER && main_net_cfg->state!=net_configuration::CLIENT))
47      {
48    the_game->state=HELP_STATE;
49    help_page=0;
50      }
51    }
52  } else if (ev.type==EV_KEY)
53  {
54    if (ev.key==JK_ESC || help_page>=total_help_screens-1)
55    {
56      the_game->state=RUN_STATE;
57      the_game->draw(0);
58    }
59    else
60      help_page++;
61  }
62}
Note: See TracBrowser for help on using the repository browser.