File: dialogmenu.h

package info (click to toggle)
scummvm 2.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 450,268 kB
  • sloc: cpp: 4,297,604; asm: 28,322; python: 12,901; sh: 11,219; java: 8,477; xml: 7,843; perl: 2,633; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (174 lines) | stat: -rw-r--r-- 4,526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef STARK_UI_MENU_DIALOG_H
#define STARK_UI_MENU_DIALOG_H

#include "engines/stark/ui/menu/locationscreen.h"
#include "engines/stark/visual/text.h"

namespace Stark {

class ChapterTitleText;
class DialogLineText;

/**
 * The conversation log menu
 */
class DialogScreen : public StaticLocationScreen {
public:
	DialogScreen(Gfx::Driver *gfx, Cursor *cursor);
	virtual ~DialogScreen();

	// StaticLocationScreen API
	void open() override;
	void close() override;
	void onScreenChanged() override;

	void onDialogClick(uint logIndex);

protected:
	// Window API
	void onRender() override;

private:
	static const uint _dialogTitleWidgetOffset = 8;

	enum WidgetIndex {
		kWidgetIndexBack = 3,
		kWidgetIndexNext = 4,
		kWidgetLogBack = 5,
		kWidgetIndex = 6,
		kWidgetLogNext = 7
	};

	Gfx::RenderEntry *_indexFrame, *_logFrame;
	uint _startTitleIndex, _nextTitleIndex, _startLineIndex, _nextLineIndex;
	uint _curMaxChapter, _curLogIndex;
	Common::Array<ChapterTitleText *> _chapterTitleTexts;
	Common::Array<uint> _prevTitleIndexStack;
	Common::Array<DialogLineText *> _dialogLineTexts;
	Common::Array<uint> _prevLineIndexStack;

	void loadIndex();
	void loadDialog();

	void backHandler();
	void indexBackHandler();
	void indexNextHandler();
	void logBackHandler();
	void backIndexHandler();
	void logNextHandler();

	void freeLogTitleWidgets();
	void freeChapterTitleTexts();
	void freeDialogLineTexts();
	void freeResources();
};

/**
 * The chapter title displayed on the menu
 */
class ChapterTitleText {
public:
	ChapterTitleText(Gfx::Driver *gfx, uint chapter);
	~ChapterTitleText() {}

	void setPosition(const Common::Point &pos) { _pos = pos; }
	uint getHeight() { return _text.getRect().bottom - _text.getRect().top; }

	void render() { _text.render(_pos); }
	void onScreenChanged() { _text.reset(); }

private:
	const Gfx::Color _color = Gfx::Color(0x68, 0x05, 0x04);

	Common::Point _pos;
	VisualText _text;
};

/**
 * The dialog text displayed
 */
class DialogLineText {
public:
	DialogLineText(Gfx::Driver *gfx, uint logIndex, uint lineIndex, uint boxWidth);
	~DialogLineText() {}

	void setPosition(const Common::Point &pos);
	uint getHeight() { return _nameHeight + _lineHeight + 4; }

	void render() {
		_nameText.render(_namePos);
		_lineText.render(_linePos);
	}

	void onScreenChanged() {
		_nameText.reset();
		_lineText.reset();
	}

private:
	const Gfx::Color _textColorApril = Gfx::Color(0x68, 0x05, 0x04);
	const Gfx::Color _textColorNormal = Gfx::Color(0x1E, 0x1E, 0x96);

	Common::Point _namePos, _linePos;
	VisualText _nameText, _lineText;

	uint _nameWidth, _nameHeight, _lineHeight, _boxWidth;
};

/**
 * The dialog widget
 */
class DialogTitleWidget : public StaticLocationWidget {
public:
	DialogTitleWidget(DialogScreen *screen, Gfx::Driver *gfx, uint logIndex);
	virtual ~DialogTitleWidget() {}

	void setPosition(const Common::Point &pos) { _pos = pos; }
	uint getHeight() { return _height; }
	uint getChapter() { return _chapter; }

	// StaticLocationWidget API
	void render() override { _text.render(_pos); }
	bool isMouseInside(const Common::Point &mousePos) const override;
	void onClick() override;
	void onMouseMove(const Common::Point &mousePos) override {
		_text.setColor(isMouseInside(mousePos) ? _textColorHovered : _textColorDefault);
	}
	void onScreenChanged() override;

private:
	const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
	const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);

	uint _logIndex, _chapter;
	int _width, _height;
	Common::Point _pos;
	VisualText _text;

	DialogScreen *_screen;
};

} // End of namespace Stark

#endif // STARK_UI_MENU_DIALOG_H