aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-12-09 12:49:23 +0100
committerEinar Johan Trøan Sømåen2012-12-09 12:49:23 +0100
commit2ede3f58a0c0522665daa8cff745da0a9b62c0b6 (patch)
tree637e2249c5586ed451b47ac9b132e71328502b5e /engines/wintermute
parent7ff74312a0c0c698a1c7044f82bb02c8db7794d3 (diff)
downloadscummvm-rg350-2ede3f58a0c0522665daa8cff745da0a9b62c0b6.tar.gz
scummvm-rg350-2ede3f58a0c0522665daa8cff745da0a9b62c0b6.tar.bz2
scummvm-rg350-2ede3f58a0c0522665daa8cff745da0a9b62c0b6.zip
WINTERMUTE: Privatize members of AdResponseBox
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/ad/ad_game.cpp24
-rw-r--r--engines/wintermute/ad/ad_response.h2
-rw-r--r--engines/wintermute/ad/ad_response_box.cpp27
-rw-r--r--engines/wintermute/ad/ad_response_box.h38
4 files changed, 65 insertions, 26 deletions
diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp
index 4481b774c1..904aad9fdb 100644
--- a/engines/wintermute/ad/ad_game.cpp
+++ b/engines/wintermute/ad/ad_game.cpp
@@ -542,7 +542,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
res->_responseType = RESPONSE_ONCE_GAME;
}
- _responseBox->_responses.add(res);
+ _responseBox->addResponse(res);
}
} else {
script->runtimeError("Game.AddResponse: response box is not defined");
@@ -584,15 +584,15 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
if (_responseBox) {
_responseBox->weedResponses();
- if (_responseBox->_responses.size() == 0) {
+ if (_responseBox->getNumResponses() == 0) {
stack->pushNULL();
return STATUS_OK;
}
- if (_responseBox->_responses.size() == 1 && autoSelectLast) {
- stack->pushInt(_responseBox->_responses[0]->_iD);
- _responseBox->handleResponse(_responseBox->_responses[0]);
+ if (_responseBox->getNumResponses() == 1 && autoSelectLast) {
+ stack->pushInt(_responseBox->getIdForResponseNum(0));
+ _responseBox->handleResponseNum(0);
_responseBox->clearResponses();
return STATUS_OK;
}
@@ -617,7 +617,7 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
stack->correctParams(0);
if (_responseBox) {
_responseBox->weedResponses();
- stack->pushInt(_responseBox->_responses.size());
+ stack->pushInt(_responseBox->getNumResponses());
} else {
script->runtimeError("Game.GetNumResponses: response box is not defined");
stack->pushNULL();
@@ -754,8 +754,8 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack,
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetResponsesWindow") == 0 || strcmp(name, "GetResponseWindow") == 0) {
stack->correctParams(0);
- if (_responseBox && _responseBox->_window) {
- stack->pushNative(_responseBox->_window, true);
+ if (_responseBox && _responseBox->getResponseWindow()) {
+ stack->pushNative(_responseBox->getResponseWindow(), true);
} else {
stack->pushNULL();
}
@@ -983,10 +983,10 @@ ScValue *AdGame::scGetProperty(const Common::String &name) {
// LastResponse (RO)
//////////////////////////////////////////////////////////////////////////
else if (name == "LastResponse") {
- if (!_responseBox || !_responseBox->_lastResponseText) {
+ if (!_responseBox || !_responseBox->getLastResponseText()) {
_scValue->setString("");
} else {
- _scValue->setString(_responseBox->_lastResponseText);
+ _scValue->setString(_responseBox->getLastResponseText());
}
return _scValue;
}
@@ -995,10 +995,10 @@ ScValue *AdGame::scGetProperty(const Common::String &name) {
// LastResponseOrig (RO)
//////////////////////////////////////////////////////////////////////////
else if (name == "LastResponseOrig") {
- if (!_responseBox || !_responseBox->_lastResponseTextOrig) {
+ if (!_responseBox || !_responseBox->getLastResponseTextOrig()) {
_scValue->setString("");
} else {
- _scValue->setString(_responseBox->_lastResponseTextOrig);
+ _scValue->setString(_responseBox->getLastResponseTextOrig());
}
return _scValue;
}
diff --git a/engines/wintermute/ad/ad_response.h b/engines/wintermute/ad/ad_response.h
index 0ba88cf2e8..2119067d3e 100644
--- a/engines/wintermute/ad/ad_response.h
+++ b/engines/wintermute/ad/ad_response.h
@@ -43,7 +43,7 @@ public:
bool setIconHover(const char *filename);
bool setIconPressed(const char *filename);
void setText(const char *text);
- int _iD;
+ int32 _iD;
BaseSprite *_icon;
BaseSprite *_iconHover;
BaseSprite *_iconPressed;
diff --git a/engines/wintermute/ad/ad_response_box.cpp b/engines/wintermute/ad/ad_response_box.cpp
index fb31aa0bb8..45fd33d222 100644
--- a/engines/wintermute/ad/ad_response_box.cpp
+++ b/engines/wintermute/ad/ad_response_box.cpp
@@ -96,6 +96,9 @@ AdResponseBox::~AdResponseBox() {
_waitingScript = NULL;
}
+uint32 AdResponseBox::getNumResponses() const {
+ return _responses.size();
+}
//////////////////////////////////////////////////////////////////////////
void AdResponseBox::clearResponses() {
@@ -627,6 +630,30 @@ void AdResponseBox::setLastResponseText(const char *text, const char *textOrig)
BaseUtils::setString(&_lastResponseTextOrig, textOrig);
}
+const char *AdResponseBox::getLastResponseText() const {
+ return _lastResponseText;
+}
+
+const char *AdResponseBox::getLastResponseTextOrig() const {
+ return _lastResponseTextOrig;
+}
+
+UIWindow *AdResponseBox::getResponseWindow() {
+ return _window;
+}
+
+void AdResponseBox::addResponse(AdResponse *response) {
+ _responses.add(response);
+}
+
+int32 AdResponseBox::getIdForResponseNum(uint32 num) const {
+ assert(num < _responses.size());
+ return _responses[num]->_iD;
+}
+
+bool AdResponseBox::handleResponseNum(uint32 num) {
+ return handleResponse(_responses[num]);
+}
//////////////////////////////////////////////////////////////////////////
bool AdResponseBox::handleResponse(AdResponse *response) {
diff --git a/engines/wintermute/ad/ad_response_box.h b/engines/wintermute/ad/ad_response_box.h
index 35f8cb6347..3b180062b6 100644
--- a/engines/wintermute/ad/ad_response_box.h
+++ b/engines/wintermute/ad/ad_response_box.h
@@ -44,10 +44,14 @@ public:
BaseObject *getPrevAccessObject(BaseObject *CurrObject);
bool getObjects(BaseArray<UIObject *> &objects, bool interactiveOnly);
+ void addResponse(AdResponse* response);
bool handleResponse(AdResponse *response);
+ bool handleResponseNum(uint32 num);
+ int32 getIdForResponseNum(uint32 num) const;
void setLastResponseText(const char *text, const char *textOrig);
- char *_lastResponseText;
- char *_lastResponseTextOrig;
+ const char *getLastResponseText() const;
+ const char *getLastResponseTextOrig() const;
+
DECLARE_PERSISTENT(AdResponseBox, BaseObject)
ScScript *_waitingScript;
virtual bool listen(BaseScriptHolder *param1, uint32 param2);
@@ -59,27 +63,35 @@ public:
bool weedResponses();
bool display();
- int _spacing;
- int _scrollOffset;
- BaseFont *_fontHover;
- BaseFont *_font;
+
bool createButtons();
bool invalidateButtons();
void clearButtons();
void clearResponses();
AdResponseBox(BaseGame *inGame);
virtual ~AdResponseBox();
- BaseArray<AdResponse *> _responses;
- BaseArray<UIButton *> _respButtons;
- UIWindow *_window;
- UIWindow *_shieldWindow;
+
+ bool loadFile(const char *filename);
+ bool loadBuffer(byte *buffer, bool complete = true);
+ virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent);
+
+ UIWindow *getResponseWindow();
+ uint32 getNumResponses() const;
+private:
+ int _spacing;
+ int _scrollOffset;
+ BaseFont *_fontHover;
+ BaseFont *_font;
bool _horizontal;
Rect32 _responseArea;
int _verticalAlign;
TTextAlign _align;
- bool loadFile(const char *filename);
- bool loadBuffer(byte *buffer, bool complete = true);
- virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent);
+ BaseArray<UIButton *> _respButtons;
+ BaseArray<AdResponse *> _responses;
+ UIWindow *_shieldWindow;
+ char *_lastResponseText;
+ char *_lastResponseTextOrig;
+ UIWindow *_window;
};
} // end of namespace Wintermute