| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "MenuHelp.h" |
| 10 |
|
| 11 |
#include "Path.h" |
| 12 |
#include "WiPara.h" |
| 13 |
|
| 14 |
#include "Labels.h" |
| 15 |
#include "Font.h" |
| 16 |
#include "HelpInput.h" |
| 17 |
#include "OptionAgent.h" |
| 18 |
#include "SurfaceTool.h" |
| 19 |
|
| 20 |
//----------------------------------------------------------------- |
| 21 |
MenuHelp::MenuHelp() |
| 22 |
{ |
| 23 |
Font usedFont(Path::dataReadPath("font/font_menu.ttf"), 14); |
| 24 |
SDL_Color usedColor = {255, 255, 255, 255}; |
| 25 |
|
| 26 |
Labels labels(Path::dataReadPath("script/labels.lua")); |
| 27 |
m_help = new WiPara(labels.getLabel("help"), usedFont, usedColor); |
| 28 |
|
| 29 |
takeHandler(new HelpInput(this)); |
| 30 |
registerDrawable(this); |
| 31 |
registerDrawable(m_help); |
| 32 |
} |
| 33 |
//----------------------------------------------------------------- |
| 34 |
MenuHelp::~MenuHelp() |
| 35 |
{ |
| 36 |
delete m_help; |
| 37 |
} |
| 38 |
//----------------------------------------------------------------- |
| 39 |
/** |
| 40 |
* Display help centerd on screen. |
| 41 |
*/ |
| 42 |
void |
| 43 |
MenuHelp::own_initState() |
| 44 |
{ |
| 45 |
own_resumeState(); |
| 46 |
} |
| 47 |
//----------------------------------------------------------------- |
| 48 |
/** |
| 49 |
* Help will be centred on screen. |
| 50 |
*/ |
| 51 |
void |
| 52 |
MenuHelp::own_resumeState() |
| 53 |
{ |
| 54 |
int contentW = m_help->getW(); |
| 55 |
int contentH = m_help->getH(); |
| 56 |
OptionAgent *options = OptionAgent::agent(); |
| 57 |
int screenW = options->getAsInt("screen_width"); |
| 58 |
int screenH = options->getAsInt("screen_height"); |
| 59 |
|
| 60 |
m_help->setShift( |
| 61 |
V2((screenW - contentW) / 2, (screenH - contentH) / 2)); |
| 62 |
} |
| 63 |
//----------------------------------------------------------------- |
| 64 |
void |
| 65 |
MenuHelp::drawOn(SDL_Surface *screen) |
| 66 |
{ |
| 67 |
SDL_Color gray = {0x00, 0x00, 0x00, 129}; |
| 68 |
SurfaceTool::alphaFill(screen, NULL, gray); |
| 69 |
} |
| 70 |
|