aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/dialogs.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-01-17 17:57:10 -0500
committerPaul Gilbert2016-01-17 17:57:10 -0500
commit5afdf3277ebe6ea334b928d20e54d9acac69c377 (patch)
tree7b721988caceb9ce633eb1503ad6e68c91940205 /engines/mads/dialogs.cpp
parentbd3f64a8cf95278aa9ec70ce29d0c50f48a2e4a9 (diff)
downloadscummvm-rg350-5afdf3277ebe6ea334b928d20e54d9acac69c377.tar.gz
scummvm-rg350-5afdf3277ebe6ea334b928d20e54d9acac69c377.tar.bz2
scummvm-rg350-5afdf3277ebe6ea334b928d20e54d9acac69c377.zip
MADS: Beginnings of loading Phantom-style dialogs
Diffstat (limited to 'engines/mads/dialogs.cpp')
-rw-r--r--engines/mads/dialogs.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 80036601b4..14aa41eb30 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -29,6 +29,12 @@
namespace MADS {
+enum PopupEdge {
+ EDGE_UPPER_LEFT = 0, EDGE_UPPER_RIGHT = 1, EDGE_LOWER_LEFT = 2,
+ EDGE_LOWER_RIGHT = 3, EDGE_LEFT = 4, EDGE_RIGHT = 5, EDGE_TOP = 6,
+ EDGE_BOTTOM = 7, EDGE_UPPER_CENTER = 8
+};
+
Dialog::Dialog(MADSEngine *vm)
: _vm(vm), _savedSurface(nullptr), _position(Common::Point(-1, -1)),
_width(0), _height(0) {
@@ -140,15 +146,34 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo
TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
const Common::Point &pos, int maxChars)
: Dialog(vm) {
- _vm = vm;
_font = _vm->_font->getFont(fontName);
_position = pos;
+ _icon = nullptr;
+ _edgeSeries = nullptr;
+ _piecesPerCenter = 0;
+ _vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK);
+ _piecesPerCenter = 0;
+
+ init(maxChars);
+}
+TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
+ const Common::Point &pos, MSurface *icon, int maxTextChars): Dialog(vm) {
+ _font = _vm->_font->getFont(fontName);
+ _position = pos;
+ _icon = icon;
+ _edgeSeries = new SpriteAsset(_vm, "box.ss", PALFLAG_RESERVED);
_vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK);
+ _piecesPerCenter = _edgeSeries->getFrame(EDGE_UPPER_CENTER)->w / _edgeSeries->getFrame(EDGE_BOTTOM)->w;
- _innerWidth = (_font->maxWidth() + 1) * maxChars;
+ int maxLen = estimatePieces(maxTextChars);
+ init(maxLen);
+}
+
+void TextDialog::init(int maxTextChars) {
+ _innerWidth = (_font->maxWidth() + 1) * maxTextChars;
_width = _innerWidth + 10;
- _lineSize = maxChars * 2;
+ _lineSize = maxTextChars * 2;
_lineWidth = 0;
_currentX = 0;
_numLines = 0;
@@ -157,7 +182,16 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
_askXp = 0;
}
+int TextDialog::estimatePieces(int maxLen) {
+ int fontLen = (_font->maxWidth() + 1) * maxLen;
+ int pieces = ((fontLen - 1) / _edgeSeries->getFrame(EDGE_TOP)->w) + 1;
+ int estimate = (maxLen - _piecesPerCenter) / 2;
+
+ return estimate;
+}
+
TextDialog::~TextDialog() {
+ delete _edgeSeries;
}
void TextDialog::addLine(const Common::String &line, bool underline) {
@@ -275,10 +309,6 @@ void TextDialog::setLineXp(int xp) {
_lineXp[_numLines] = xp;
}
-void TextDialog::addIcon(MSprite *frame) {
- warning("TODO: addIcon");
-}
-
void TextDialog::draw() {
if (!_lineWidth)
--_numLines;