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

Last change on this file since 655 was 655, checked in by Sam Hocevar, 8 years ago

imlib: refactor a few image methods so that they use vec2i.

File size: 1.6 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, 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
21int total_help_screens;
22int *help_screens;
23static int help_page=0;
24
25void fade_in(image *im, int steps);
26void fade_out(int steps);
27
28void 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  main_screen->PutImage(im, vec2i(x1, y1));
34  main_screen->Bar(vec2i(0, 0), vec2i(x1 - 1, yres), 0);
35  main_screen->Bar(vec2i(0, 0), vec2i(xres, y1 - 1), 0);
36  main_screen->Bar(vec2i(x2, y1), vec2i(xres, yres), 0);
37  main_screen->Bar(vec2i(x1, y2), vec2i(x2, yres), 0);
38}
39
40void 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}
Note: See TracBrowser for help on using the repository browser.