|
| 1 | +/* |
| 2 | + * Copyright 2011 OpenXcom Developers. |
| 3 | + * |
| 4 | + * This file is part of OpenXcom. |
| 5 | + * |
| 6 | + * OpenXcom is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * OpenXcom is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License |
| 17 | + * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | + |
| 20 | +#include <sstream> |
| 21 | + |
| 22 | +#include "Ufopaedia.h" |
| 23 | +#include "ArticleStateBaseFacility.h" |
| 24 | +#include "../Ruleset/ArticleDefinition.h" |
| 25 | +#include "../Ruleset/RuleBaseFacility.h" |
| 26 | +#include "../Engine/Game.h" |
| 27 | +#include "../Engine/Palette.h" |
| 28 | +#include "../Engine/Surface.h" |
| 29 | +#include "../Engine/Language.h" |
| 30 | +#include "../Resource/ResourcePack.h" |
| 31 | +#include "../Interface/Text.h" |
| 32 | +#include "../Interface/TextButton.h" |
| 33 | +#include "../Interface/TextList.h" |
| 34 | + |
| 35 | +namespace OpenXcom |
| 36 | +{ |
| 37 | + |
| 38 | + ArticleStateBaseFacility::ArticleStateBaseFacility(Game *game, ArticleDefinitionBaseFacility *defs) : ArticleState(game, defs->id) |
| 39 | + { |
| 40 | + // add screen elements |
| 41 | + _txtTitle = new Text(140, 32, 10, 24); |
| 42 | + |
| 43 | + // Set palette |
| 44 | + _game->setPalette(_game->getResourcePack()->getPalette("PALETTES.DAT_1")->getColors()); |
| 45 | + |
| 46 | + ArticleState::initLayout(); |
| 47 | + |
| 48 | + // add other elements |
| 49 | + add(_txtTitle); |
| 50 | + |
| 51 | + // Set up objects |
| 52 | + _game->getResourcePack()->getSurface("BACK09.SCR")->blit(_bg); |
| 53 | + _btnOk->setColor(Palette::blockOffset(4)+2); |
| 54 | + _btnPrev->setColor(Palette::blockOffset(4)+2); |
| 55 | + _btnNext->setColor(Palette::blockOffset(4)+2); |
| 56 | + |
| 57 | + _txtTitle->setColor(Palette::blockOffset(13)+10); |
| 58 | + _txtTitle->setBig(); |
| 59 | + _txtTitle->setAlign(ALIGN_LEFT); |
| 60 | + _txtTitle->setWordWrap(true); |
| 61 | + _txtTitle->setText(Ufopaedia::buildText(_game, defs->title)); |
| 62 | + |
| 63 | + /* |
| 64 | + for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i) |
| 65 | + { |
| 66 | + // Draw facility shape |
| 67 | + int num = 0; |
| 68 | + for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); y++) |
| 69 | + { |
| 70 | + for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); x++) |
| 71 | + { |
| 72 | + Surface *frame; |
| 73 | + |
| 74 | + if ((*i)->getBuildTime() == 0) |
| 75 | + frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num); |
| 76 | + else |
| 77 | + frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num + 2 + (*i)->getRules()->getSize()); |
| 78 | + |
| 79 | + frame->setX(x * GRID_SIZE); |
| 80 | + frame->setY(y * GRID_SIZE); |
| 81 | + frame->blit(this); |
| 82 | + |
| 83 | + num++; |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + */ |
| 88 | + |
| 89 | + /* |
| 90 | + _image = new Surface(160, 52, 160, 6); |
| 91 | + add(_image); |
| 92 | + |
| 93 | + Surface *graphic = _game->getResourcePack()->getSurface("INTERWIN.DAT"); |
| 94 | + graphic->setX(0); |
| 95 | + graphic->setY(0); |
| 96 | + graphic->getCrop()->x = 0; |
| 97 | + graphic->getCrop()->y = 0; |
| 98 | + graphic->getCrop()->w = 160; |
| 99 | + graphic->getCrop()->h = 52; |
| 100 | + _image->drawRect(graphic->getCrop(), 15); |
| 101 | + graphic->getCrop()->y = 140 + 52 * defs->ufo->getSprite(); |
| 102 | + graphic->getCrop()->h = 52; |
| 103 | + graphic->blit(_image); |
| 104 | + */ |
| 105 | + |
| 106 | + _txtInfo = new Text(300, 90, 10, 104); |
| 107 | + add(_txtInfo); |
| 108 | + |
| 109 | + _txtInfo->setColor(Palette::blockOffset(13)+10); |
| 110 | + _txtInfo->setAlign(ALIGN_LEFT); |
| 111 | + _txtInfo->setWordWrap(true); |
| 112 | + _txtInfo->setText(Ufopaedia::buildText(_game, defs->text)); |
| 113 | + |
| 114 | + _lstInfo = new TextList(300, 60, 10, 42); |
| 115 | + add(_lstInfo); |
| 116 | + |
| 117 | + _lstInfo->setColor(Palette::blockOffset(13)+10); |
| 118 | + _lstInfo->setColumns(2, 140, 40); |
| 119 | + _lstInfo->setDot(true); |
| 120 | + |
| 121 | + std::wstringstream ss; |
| 122 | + ss.str(L"");ss.clear(); |
| 123 | + ss << defs->facility->getBuildTime(); |
| 124 | + ss << _game->getLanguage()->getString("STR_DAYS"); |
| 125 | + _lstInfo->addRow(2, _game->getLanguage()->getString("STR_CONSTRUCTION_TIME").c_str(), ss.str().c_str()); |
| 126 | + _lstInfo->getCell(0, 1)->setColor(Palette::blockOffset(13)+0); |
| 127 | + |
| 128 | + ss.str(L"");ss.clear(); |
| 129 | + ss << Text::formatFunding(defs->facility->getBuildCost()); |
| 130 | + _lstInfo->addRow(2, _game->getLanguage()->getString("STR_CONSTRUCTION_COST").c_str(), ss.str().c_str()); |
| 131 | + _lstInfo->getCell(1, 1)->setColor(Palette::blockOffset(13)+0); |
| 132 | + |
| 133 | + ss.str(L"");ss.clear(); |
| 134 | + ss << Text::formatFunding(defs->facility->getMonthlyCost()); |
| 135 | + _lstInfo->addRow(2, _game->getLanguage()->getString("STR_MAINTENANCE_COST").c_str(), ss.str().c_str()); |
| 136 | + _lstInfo->getCell(2, 1)->setColor(Palette::blockOffset(13)+0); |
| 137 | + |
| 138 | + _lstInfo->draw(); |
| 139 | + } |
| 140 | + |
| 141 | + ArticleStateBaseFacility::~ArticleStateBaseFacility() |
| 142 | + {} |
| 143 | + |
| 144 | +} |
0 commit comments