diff options
Diffstat (limited to 'engines/bladerunner/dialogue_menu.cpp')
-rw-r--r-- | engines/bladerunner/dialogue_menu.cpp | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/engines/bladerunner/dialogue_menu.cpp b/engines/bladerunner/dialogue_menu.cpp index e13e69cbd0..2d55deee3f 100644 --- a/engines/bladerunner/dialogue_menu.cpp +++ b/engines/bladerunner/dialogue_menu.cpp @@ -33,14 +33,10 @@ #include "common/rect.h" #include "common/util.h" -#define LINE_HEIGHT 9 -#define BORDER_SIZE 10 - namespace BladeRunner { -DialogueMenu::DialogueMenu(BladeRunnerEngine *vm) - : _vm(vm) -{ +DialogueMenu::DialogueMenu(BladeRunnerEngine *vm) { + _vm = vm; reset(); _textResource = new TextResource(_vm); _shapes.reserve(8); @@ -56,7 +52,7 @@ DialogueMenu::~DialogueMenu() { delete _textResource; } -bool DialogueMenu::loadText(const char *name) { +bool DialogueMenu::loadText(const Common::String &name) { bool r = _textResource->open(name); if (!r) { error("Failed to load dialogue menu text"); @@ -104,15 +100,15 @@ bool DialogueMenu::clearList() { } bool DialogueMenu::addToList(int answer, bool done, int priorityPolite, int priorityNormal, int prioritySurly) { - if (_listSize >= 10) { + if (_listSize >= kMaxItems) { return false; } if (getAnswerIndex(answer) != -1) { return false; } - const char *text = _textResource->getText(answer); - if (!text || strlen(text) >= 50) { + const Common::String &text = _textResource->getText(answer); + if (text.empty() || text.size() >= 50) { return false; } @@ -145,8 +141,9 @@ bool DialogueMenu::addToListNeverRepeatOnceSelected(int answer, int priorityPoli } int DialogueMenu::queryInput() { - if (!_isVisible || _listSize == 0) + if (!_isVisible || _listSize == 0) { return -1; + } int answer = -1; if (_listSize == 1) { @@ -230,15 +227,15 @@ int DialogueMenu::queryInput() { return answer; } -int DialogueMenu::listSize() { +int DialogueMenu::listSize() const { return _listSize; } -bool DialogueMenu::isVisible() { +bool DialogueMenu::isVisible() const { return _isVisible; } -bool DialogueMenu::isOpen() { +bool DialogueMenu::isOpen() const { return _isVisible || _waitingForInput; } @@ -247,7 +244,7 @@ void DialogueMenu::tick(int x, int y) { return; } - int line = (y - (_screenY + BORDER_SIZE)) / LINE_HEIGHT; + int line = (y - (_screenY + kBorderSize)) / kLineHeight; line = CLIP(line, 0, _listSize - 1); _selectedItemIndex = line; @@ -289,13 +286,13 @@ void DialogueMenu::draw(Graphics::Surface &s) { const int x1 = _screenX; const int y1 = _screenY; - const int x2 = _screenX + BORDER_SIZE + _maxItemWidth; - const int y2 = _screenY + BORDER_SIZE + _listSize * LINE_HEIGHT; + const int x2 = _screenX + kBorderSize + _maxItemWidth; + const int y2 = _screenY + kBorderSize + _listSize * kLineHeight; darkenRect(s, x1 + 8, y1 + 8, x2 + 2, y2 + 2); - int x = x1 + BORDER_SIZE; - int y = y1 + BORDER_SIZE; + int x = x1 + kBorderSize; + int y = y1 + kBorderSize; Common::Point mouse = _vm->getMousePos(); if (mouse.x >= x && mouse.x < x2) { @@ -315,7 +312,7 @@ void DialogueMenu::draw(Graphics::Surface &s) { _shapes[4].draw(s, x2, y); uint16 color = ((_items[i].colorIntensity >> 1) << 10) | ((_items[i].colorIntensity >> 1) << 6) | _items[i].colorIntensity; _vm->_mainFont->drawColor(_items[i].text, s, x, y, color); - y += LINE_HEIGHT; + y += kLineHeight; } for (; x != x2; ++x) { _shapes[6].draw(s, x, y1); @@ -323,7 +320,7 @@ void DialogueMenu::draw(Graphics::Surface &s) { } } -int DialogueMenu::getAnswerIndex(int answer) { +int DialogueMenu::getAnswerIndex(int answer) const { for (int i = 0; i != _listSize; ++i) { if (_items[i].answerValue == answer) { return i; @@ -333,7 +330,7 @@ int DialogueMenu::getAnswerIndex(int answer) { return -1; } -const char *DialogueMenu::getText(int id) { +const char *DialogueMenu::getText(int id) const { return _textResource->getText((uint32)id); } @@ -344,8 +341,8 @@ void DialogueMenu::calculatePosition(int unusedX, int unusedY) { } _maxItemWidth += 2; - int w = BORDER_SIZE + _shapes[4].getWidth() + _maxItemWidth; - int h = BORDER_SIZE + _shapes[7].getHeight() + LINE_HEIGHT * _listSize; + int w = kBorderSize + _shapes[4].getWidth() + _maxItemWidth; + int h = kBorderSize + _shapes[7].getHeight() + kLineHeight * _listSize; _screenX = _centerX - w / 2; _screenY = _centerY - h / 2; @@ -361,7 +358,7 @@ void DialogueMenu::mouseUp() { _waitingForInput = false; } -bool DialogueMenu::waitingForInput() { +bool DialogueMenu::waitingForInput() const { return _waitingForInput; } @@ -370,7 +367,7 @@ void DialogueMenu::clear() { _waitingForInput = false; _selectedItemIndex = 0; _listSize = 0; - for (int i = 0; i != 10; ++i) { + for (int i = 0; i != kMaxItems; ++i) { _items[i].text.clear(); _items[i].answerValue = -1; _items[i].isDone = 0; @@ -380,7 +377,7 @@ void DialogueMenu::clear() { _items[i].colorIntensity = 0; } _neverRepeatListSize = 0; - for (int i = 0; i != 100; ++i) { + for (int i = 0; i != kMaxRepeatHistory; ++i) { _neverRepeatValues[i] = -1; _neverRepeatWasSelected[i] = false; } @@ -402,7 +399,7 @@ void DialogueMenu::darkenRect(Graphics::Surface &s, int x1, int y1, int x2, int if (x1 < x2 && y1 < y2) { for (int y = y1; y != y2; ++y) { for (int x = x1; x != x2; ++x) { - uint16 *p = (uint16*)s.getBasePtr(x, y); + uint16 *p = (uint16 *)s.getBasePtr(x, y); *p = (*p & 0x739C) >> 1; // 0 11100 11100 11100 } } |