ScummVM API documentation
dialogmenu.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef STARK_UI_MENU_DIALOG_H
23 #define STARK_UI_MENU_DIALOG_H
24 
25 #include "engines/stark/ui/menu/locationscreen.h"
26 #include "engines/stark/visual/text.h"
27 
28 namespace Stark {
29 
30 class ChapterTitleText;
31 class DialogLineText;
32 
37 public:
38  DialogScreen(Gfx::Driver *gfx, Cursor *cursor);
39  virtual ~DialogScreen();
40 
41  // StaticLocationScreen API
42  void open() override;
43  void close() override;
44  void onScreenChanged() override;
45 
46  void onDialogClick(uint logIndex);
47 
48 protected:
49  // Window API
50  void onRender() override;
51 
52 private:
53  static const uint _dialogTitleWidgetOffset = 8;
54 
55  enum WidgetIndex {
56  kWidgetIndexBack = 3,
57  kWidgetIndexNext = 4,
58  kWidgetLogBack = 5,
59  kWidgetIndex = 6,
60  kWidgetLogNext = 7
61  };
62 
63  Gfx::RenderEntry *_indexFrame, *_logFrame;
64  uint _startTitleIndex, _nextTitleIndex, _startLineIndex, _nextLineIndex;
65  uint _curMaxChapter, _curLogIndex;
66  Common::Array<ChapterTitleText *> _chapterTitleTexts;
67  Common::Array<uint> _prevTitleIndexStack;
68  Common::Array<DialogLineText *> _dialogLineTexts;
69  Common::Array<uint> _prevLineIndexStack;
70 
71  void loadIndex();
72  void loadDialog();
73 
74  void backHandler();
75  void indexBackHandler();
76  void indexNextHandler();
77  void logBackHandler();
78  void backIndexHandler();
79  void logNextHandler();
80 
81  void freeLogTitleWidgets();
82  void freeChapterTitleTexts();
83  void freeDialogLineTexts();
84  void freeResources();
85 };
86 
91 public:
92  ChapterTitleText(Gfx::Driver *gfx, uint chapter);
93  ~ChapterTitleText() {}
94 
95  void setPosition(const Common::Point &pos) { _pos = pos; }
96  uint getHeight() { return _text.getRect().bottom - _text.getRect().top; }
97 
98  void render() { _text.render(_pos); }
99  void onScreenChanged() { _text.reset(); }
100 
101 private:
102  const Gfx::Color _color = Gfx::Color(0x68, 0x05, 0x04);
103 
104  Common::Point _pos;
105  VisualText _text;
106 };
107 
112 public:
113  DialogLineText(Gfx::Driver *gfx, uint logIndex, uint lineIndex, uint boxWidth);
114  ~DialogLineText() {}
115 
116  void setPosition(const Common::Point &pos);
117  uint getHeight() { return _nameHeight + _lineHeight + 4; }
118 
119  void render() {
120  _nameText.render(_namePos);
121  _lineText.render(_linePos);
122  }
123 
124  void onScreenChanged() {
125  _nameText.reset();
126  _lineText.reset();
127  }
128 
129 private:
130  const Gfx::Color _textColorApril = Gfx::Color(0x68, 0x05, 0x04);
131  const Gfx::Color _textColorNormal = Gfx::Color(0x1E, 0x1E, 0x96);
132 
133  Common::Point _namePos, _linePos;
134  VisualText _nameText, _lineText;
135 
136  uint _nameWidth, _nameHeight, _lineHeight, _boxWidth;
137 };
138 
143 public:
144  DialogTitleWidget(DialogScreen *screen, Gfx::Driver *gfx, uint logIndex);
145  virtual ~DialogTitleWidget() {}
146 
147  void setPosition(const Common::Point &pos) { _pos = pos; }
148  uint getHeight() { return _height; }
149  uint getChapter() { return _chapter; }
150 
151  // StaticLocationWidget API
152  void render() override { _text.render(_pos); }
153  bool isMouseInside(const Common::Point &mousePos) const override;
154  void onClick() override;
155  void onMouseMove(const Common::Point &mousePos) override {
156  _text.setColor(isMouseInside(mousePos) ? _textColorHovered : _textColorDefault);
157  }
158  void onScreenChanged() override;
159 
160 private:
161  const Gfx::Color _textColorHovered = Gfx::Color(0x1E, 0x1E, 0x96);
162  const Gfx::Color _textColorDefault = Gfx::Color(0x00, 0x00, 0x00);
163 
164  uint _logIndex, _chapter;
165  int _width, _height;
166  Common::Point _pos;
167  VisualText _text;
168 
169  DialogScreen *_screen;
170 };
171 
172 } // End of namespace Stark
173 
174 #endif // STARK_UI_MENU_DIALOG_H
void render() override
Definition: dialogmenu.h:152
void close() override
Definition: dialogmenu.h:142
Definition: locationscreen.h:92
void render() override
Definition: screen.h:86
Definition: array.h:52
void onMouseMove(const Common::Point &mousePos) override
Definition: dialogmenu.h:155
Definition: driver.h:44
Definition: cursor.h:45
bool isMouseInside() const
void open() override
Definition: dialogmenu.h:111
Definition: locationscreen.h:46
Definition: text.h:44
Definition: console.h:27
Definition: rect.h:45
void onScreenChanged() override
Definition: color.h:30
Definition: dialogmenu.h:36
Definition: dialogmenu.h:90
Definition: renderentry.h:67