ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

dialogmenu.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_UI_MENU_DIALOG_H
00024 #define STARK_UI_MENU_DIALOG_H
00025 
00026 #include "engines/stark/ui/menu/locationscreen.h"
00027 
00028 #include "engines/stark/visual/text.h"
00029 
00030 namespace Stark {
00031 
00032 class ChapterTitleText;
00033 class DialogLineText;
00034 
00038 class DialogScreen : public StaticLocationScreen {
00039 public:
00040     DialogScreen(Gfx::Driver *gfx, Cursor *cursor);
00041     virtual ~DialogScreen();
00042 
00043     // StaticLocationScreen API
00044     void open() override;
00045     void close() override;
00046     void onScreenChanged() override;
00047 
00048     void onDialogClick(uint logIndex);
00049 
00050 protected:
00051     // Window API
00052     void onRender() override;
00053 
00054 private:
00055     static const uint _dialogTitleWidgetOffset = 8;
00056 
00057     enum WidgetIndex {
00058         kWidgetIndexBack = 3,
00059         kWidgetIndexNext = 4,
00060         kWidgetLogBack = 5,
00061         kWidgetIndex = 6,
00062         kWidgetLogNext = 7
00063     };
00064 
00065     Gfx::RenderEntry *_indexFrame, *_logFrame;
00066     uint _startTitleIndex, _nextTitleIndex, _startLineIndex, _nextLineIndex;
00067     uint _curMaxChapter, _curLogIndex;
00068     Common::Array<ChapterTitleText *> _chapterTitleTexts;
00069     Common::Array<uint> _prevTitleIndexStack;
00070     Common::Array<DialogLineText *> _dialogLineTexts;
00071     Common::Array<uint> _prevLineIndexStack;
00072 
00073     void loadIndex();
00074     void loadDialog();
00075 
00076     void backHandler();
00077     void indexBackHandler();
00078     void indexNextHandler();
00079     void logBackHandler();
00080     void backIndexHandler();
00081     void logNextHandler();
00082 
00083     void freeLogTitleWidgets();
00084     void freeChapterTitleTexts();
00085     void freeDialogLineTexts();
00086     void freeResources();
00087 };
00088 
00092 class ChapterTitleText {
00093 public:
00094     ChapterTitleText(Gfx::Driver *gfx, uint chapter);
00095     ~ChapterTitleText() {}
00096 
00097     void setPosition(const Common::Point &pos) { _pos = pos; }
00098     uint getHeight() { return _text.getRect().bottom - _text.getRect().top; }
00099 
00100     void render() { _text.render(_pos); }
00101     void onScreenChanged() { _text.resetTexture(); }
00102 
00103 private:
00104     static const Color _color;
00105 
00106     Common::Point _pos;
00107     VisualText _text;
00108 };
00109 
00113 class DialogLineText {
00114 public:
00115     DialogLineText(Gfx::Driver *gfx, uint logIndex, uint lineIndex, uint boxWidth);
00116     ~DialogLineText() {}
00117 
00118     void setPosition(const Common::Point &pos);
00119     uint getHeight() { return _nameHeight + _lineHeight + 4; }
00120 
00121     void render() {
00122         _nameText.render(_namePos);
00123         _lineText.render(_linePos);
00124     }
00125 
00126     void onScreenChanged() {
00127         _nameText.resetTexture();
00128         _lineText.resetTexture();
00129     }
00130 
00131 private:
00132     static const Color _textColorApril;
00133     static const Color _textColorNormal;
00134 
00135     Common::Point _namePos, _linePos;
00136     VisualText _nameText, _lineText;
00137 
00138     uint _nameWidth, _nameHeight, _lineHeight, _boxWidth;
00139 };
00140 
00144 class DialogTitleWidget : public StaticLocationWidget {
00145 public:
00146     DialogTitleWidget(DialogScreen *screen, Gfx::Driver *gfx, uint logIndex);
00147     virtual ~DialogTitleWidget() {}
00148 
00149     void setPosition(const Common::Point &pos) { _pos = pos; }
00150     uint getHeight() { return _height; }
00151     uint getChapter() { return _chapter; }
00152 
00153     // StaticLocationWidget API
00154     void render() override { _text.render(_pos); }
00155     bool isMouseInside(const Common::Point &mousePos) const override;
00156     void onClick() override;
00157     void onMouseMove(const Common::Point &mousePos) override {
00158         _text.setColor(isMouseInside(mousePos) ? _textColorHovered : _textColorDefault);
00159     }
00160     void onScreenChanged() override;
00161 
00162 private:
00163     static const Color _textColorHovered;
00164     static const Color _textColorDefault;
00165 
00166     uint _logIndex, _chapter;
00167     int _width, _height;
00168     Common::Point _pos;
00169     VisualText _text;
00170 
00171     DialogScreen *_screen;
00172 };
00173 
00174 } // End of namespace Stark
00175 
00176 #endif // STARK_UI_MENU_DIALOG_H


Generated on Sat Sep 14 2019 05:01:24 for ResidualVM by doxygen 1.7.1
curved edge   curved edge