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"
30 namespace enigma
{ namespace gui
{
32 /* -------------------- HelpMenu -------------------- */
34 HelpMenu::HelpMenu (const char **helptext_
, int xoffset_
) :
36 ok (new gui::StaticTextButton(N_("Ok"), this)),
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),
48 bool HelpMenu::on_event (const SDL_Event
&e
)
50 if (e
.type
== SDL_MOUSEBUTTONDOWN
&& e
.button
.button
== SDL_BUTTON_RIGHT
)
58 void HelpMenu::on_action (gui::Widget
*w
)
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
);
93 FX_Fade (video::FADEIN
);
97 }} // namespace enigma::gui