~ubuntu-branches/ubuntu/intrepid/enigma/intrepid

« back to all changes in this revision

Viewing changes to src/help.cc

  • Committer: Bazaar Package Importer
  • Author(s): Erich Schubert
  • Date: 2005-08-28 15:30:09 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050828153009-sky64kb6tcq37xt5
Tags: 0.92.1-1
* New upstream subversion checkout
* Remove menu.s3m, which we are allowed to distributed but not to modify
  also copyright notice is confusing... (Closes: #321669)
* Rebuild with new libzipios (Closes: #325405)
  I hope this works without a versioned build-dependency
* Added "enigma replaces enigma-data" for upgrades (Closes: #308558)
* Added notes about the fonts copyright.
* updated to policy 3.6.2.1 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2003,2004 Daniel Heck, Ralf Westram
3
 
 *
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.
8
 
 *
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.
13
 
 *
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
 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17
 
 *
18
 
 * $Id: help.cc,v 1.5 2004/05/22 13:04:31 dheck Exp $
19
 
 */
20
 
 
21
 
#include "enigma.hh"
22
 
#include "gui.hh"
23
 
#include "px/px.hh"
24
 
#include "help.hh"
25
 
#include "video.hh"
26
 
#include "nls.hh"
27
 
 
28
 
using namespace enigma;
29
 
using namespace px;
30
 
using namespace std;
31
 
 
32
 
struct HelpMenuConfig {
33
 
    int         x0, x1;         // x coordinates of first and second column
34
 
    int         y0;             // y coordinate
35
 
    int         yskip;
36
 
    std::string fontname;
37
 
 
38
 
    HelpMenuConfig (int xoffset) {
39
 
        x0       = 60;
40
 
        x1       = x0 + xoffset;
41
 
        y0       = 60;
42
 
        yskip    = 30;
43
 
        fontname = "menufont";
44
 
    }
45
 
};
46
 
 
47
 
class HelpMenu : public gui::Menu {
48
 
public:
49
 
    HelpMenu (const char **helptext_, int xoffset);
50
 
private:
51
 
    bool on_event           (const SDL_Event &e);
52
 
    void on_action          (gui::Widget *w);
53
 
    void draw_background    (px::GC &gc);
54
 
 
55
 
    const char     **helptext;
56
 
    gui::Widget     *ok;
57
 
    HelpMenuConfig   cfg;
58
 
};
59
 
 
60
 
/* -------------------- HelpMenu -------------------- */
61
 
 
62
 
HelpMenu::HelpMenu (const char **helptext_, int xoffset_) : 
63
 
    helptext    (helptext_),
64
 
    ok          (new gui::StaticTextButton("Ok", this)),
65
 
    cfg         (xoffset_)
66
 
{
67
 
    add(ok, Rect(640-170,480-60,150,40));
68
 
}
69
 
 
70
 
bool HelpMenu::on_event (const SDL_Event &e) 
71
 
{
72
 
    if (e.type == SDL_MOUSEBUTTONDOWN && e.button.button == SDL_BUTTON_RIGHT) 
73
 
    {
74
 
        Menu::quit();
75
 
        return true;
76
 
    }
77
 
    return false;
78
 
}
79
 
 
80
 
void HelpMenu::on_action (gui::Widget *w) 
81
 
{
82
 
    if (w == ok)
83
 
        Menu::quit();
84
 
}
85
 
 
86
 
void HelpMenu::draw_background (px::GC &gc) 
87
 
{
88
 
    blit(gc, 0,0, enigma::GetImage("menu_bg", ".jpg"));
89
 
    Font *f = enigma::GetFont(cfg.fontname.c_str());
90
 
 
91
 
    int y = cfg.y0;
92
 
    for (int i = 0; helptext[i]; i += 2) 
93
 
    {
94
 
        f->render (gc, cfg.x0, y, _(helptext[i]));
95
 
        f->render (gc, cfg.x1, y, _(helptext[i+1]));
96
 
        y += cfg.yskip;
97
 
    }
98
 
}
99
 
 
100
 
/* -------------------- Functions -------------------- */
101
 
 
102
 
void enigma::displayHelp(const char **helptext, int xoffset) 
103
 
{
104
 
    FX_Fade (video::FADEOUT);
105
 
    HelpMenu menu(helptext, xoffset);
106
 
    menu.draw_all();
107
 
    FX_Fade (video::FADEIN);
108
 
    menu.manage();
109
 
}
110