1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "bladerunner/ui/kia_section_help.h"
24 
25 #include "bladerunner/bladerunner.h"
26 #include "bladerunner/shape.h"
27 #include "bladerunner/text_resource.h"
28 #include "bladerunner/ui/kia.h"
29 #include "bladerunner/ui/ui_container.h"
30 #include "bladerunner/ui/ui_scroll_box.h"
31 
32 namespace BladeRunner {
33 
KIASectionHelp(BladeRunnerEngine * vm)34 KIASectionHelp::KIASectionHelp(BladeRunnerEngine *vm) : KIASectionBase(vm) {
35 	_uiContainer = new UIContainer(_vm);
36 	_scrollBox   = new UIScrollBox(_vm, nullptr, this, 1024, 0, false, Common::Rect(135, 145, 461, 385), Common::Rect(506, 160, 506, 350));
37 
38 	_uiContainer->add(_scrollBox);
39 }
40 
~KIASectionHelp()41 KIASectionHelp::~KIASectionHelp() {
42 	_uiContainer->clear();
43 	delete _scrollBox;
44 	delete _uiContainer;
45 }
46 
open()47 void KIASectionHelp::open() {
48 	TextResource textResource(_vm);
49 	if (!textResource.open("HELP")) {
50 		return;
51 	}
52 
53 	_scrollBox->clearLines();
54 
55 	for (int i = 0; i < textResource.getCount(); ++i) {
56 		Common::String textLine = textResource.getText(i);
57 		int flags = 0x04;
58 		if (textLine.firstChar() == ' ') {
59 			flags = 0x00;
60 		}
61 		_scrollBox->addLine(textLine, -1, flags);
62 	}
63 
64 	_scrollBox->show();
65 }
66 
close()67 void KIASectionHelp::close() {
68 	_scrollBox->hide();
69 }
70 
draw(Graphics::Surface & surface)71 void KIASectionHelp::draw(Graphics::Surface &surface) {
72 	_vm->_kia->_shapes->get(69)->draw(surface, 501, 123);
73 	_uiContainer->draw(surface);
74 }
75 
handleMouseMove(int mouseX,int mouseY)76 void KIASectionHelp::handleMouseMove(int mouseX, int mouseY) {
77 	_uiContainer->handleMouseMove(mouseX, mouseY);
78 }
79 
handleMouseDown(bool mainButton)80 void KIASectionHelp::handleMouseDown(bool mainButton) {
81 	_uiContainer->handleMouseDown(!mainButton);
82 }
83 
handleMouseUp(bool mainButton)84 void KIASectionHelp::handleMouseUp(bool mainButton) {
85 	_uiContainer->handleMouseUp(!mainButton);
86 }
87 
handleMouseScroll(int direction)88 void KIASectionHelp::handleMouseScroll(int direction) {
89 	_uiContainer->handleMouseScroll(direction);
90 }
91 
92 } // End of namespace BladeRunner
93