Added reload of levels on F7 (Update levelpack) to ease the test of changes.
[enigmagame.git] / src / gui / HelpMenu.cc
blob2247a3e1145cbf21a03daaa99d27120a8ced989b
1 /*
2 * Copyright (C) 2003,2004 Daniel Heck, Ralf Westram
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "gui/HelpMenu.hh"
21 #include "enigma.hh"
22 #include "video.hh"
23 #include "nls.hh"
25 #include <cassert>
27 using namespace ecl;
28 using namespace std;
30 namespace enigma { namespace gui {
32 /* -------------------- HelpMenu -------------------- */
34 HelpMenu::HelpMenu (const char **helptext_, int xoffset_) :
35 helptext (helptext_),
36 ok (new gui::StaticTextButton(N_("Ok"), this)),
37 cfg (xoffset_)
39 const video::VMInfo &vminfo = *video::GetInfo();
40 const int vshrink = vminfo.width < 640 ? 1 : 0;
42 add(ok, Rect(vminfo.width - (vshrink ? 85 : 170),
43 vminfo.height - (vshrink ? 30 : 60),
44 vshrink ? 75 : 150,
45 vshrink ? 20 : 40));
48 bool HelpMenu::on_event (const SDL_Event &e)
50 if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_RIGHT)
52 Menu::quit();
53 return true;
55 return false;
58 void HelpMenu::on_action (gui::Widget *w)
60 if (w == ok)
61 Menu::quit();
64 void HelpMenu::draw_background (ecl::GC &gc)
66 const video::VMInfo &vminfo = *video::GetInfo();
67 const int vshrink = vminfo.width < 640 ? 1 : 0;
69 blit(gc, 0,0, enigma::GetImage("menu_bg", ".jpg"));
70 Font *f = enigma::GetFont(cfg.fontname.c_str());
72 int x = (vminfo.width - (vshrink ? 320 : 640))/2;
73 int y = (cfg.y0/(vshrink?2:1)) + (vminfo.height - (vshrink?240:480))/2;
74 for (int i = 0; helptext[i]; i += 2)
76 assert(helptext[i+1]);
77 // If assert stops here, and you've worked on the game
78 // help menu, check Client::show_help(): Here one of
79 // the text lines is redefined. Correct the line number.
80 f->render (gc, cfg.x0/(vshrink?2:1) + x, y, _(helptext[i])); // translate
81 f->render (gc, cfg.x1/(vshrink?2:1) + x, y, _(helptext[i+1])); // translate
82 y += cfg.yskip/(vshrink?2:1);
86 /* -------------------- Functions -------------------- */
88 void displayHelp(const char **helptext, int xoffset)
90 FX_Fade (video::FADEOUT);
91 HelpMenu menu(helptext, xoffset);
92 menu.draw_all();
93 FX_Fade (video::FADEIN);
94 menu.manage();
97 }} // namespace enigma::gui