2016-02-29 21:20:33 -05:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "titanic/game/speech_dispensor.h"
|
|
|
|
|
|
|
|
namespace Titanic {
|
|
|
|
|
2016-08-28 11:29:23 -04:00
|
|
|
BEGIN_MESSAGE_MAP(CSpeechDispensor, CBackground)
|
|
|
|
ON_MESSAGE(FrameMsg)
|
|
|
|
ON_MESSAGE(MouseButtonUpMsg)
|
|
|
|
ON_MESSAGE(StatusChangeMsg)
|
|
|
|
ON_MESSAGE(ChangeSeasonMsg)
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
CSpeechDispensor::CSpeechDispensor() : CBackground(), _dragItem(nullptr),
|
|
|
|
_fieldE0(0), _state(0), _fieldEC(0), _fieldF8(0), _seasonNum(SEASON_SUMMER) {
|
|
|
|
}
|
|
|
|
|
2016-06-29 19:53:16 -04:00
|
|
|
void CSpeechDispensor::save(SimpleFile *file, int indent) {
|
2016-02-29 21:20:33 -05:00
|
|
|
file->writeNumberLine(1, indent);
|
2016-03-02 22:05:25 -05:00
|
|
|
file->writeNumberLine(_fieldE0, indent);
|
2016-08-28 11:29:23 -04:00
|
|
|
file->writeNumberLine(_state, indent);
|
2016-03-02 22:05:25 -05:00
|
|
|
file->writeNumberLine(_fieldEC, indent);
|
2016-08-28 11:29:23 -04:00
|
|
|
file->writeNumberLine(_itemPos.x, indent);
|
|
|
|
file->writeNumberLine(_itemPos.y, indent);
|
2016-03-02 22:05:25 -05:00
|
|
|
file->writeNumberLine(_fieldF8, indent);
|
2016-08-28 11:29:23 -04:00
|
|
|
file->writeNumberLine(_seasonNum, indent);
|
2016-03-02 22:05:25 -05:00
|
|
|
|
2016-02-29 21:20:33 -05:00
|
|
|
CBackground::save(file, indent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSpeechDispensor::load(SimpleFile *file) {
|
|
|
|
file->readNumber();
|
2016-03-02 22:05:25 -05:00
|
|
|
_fieldE0 = file->readNumber();
|
2016-08-28 11:29:23 -04:00
|
|
|
_state = file->readNumber();
|
2016-03-02 22:05:25 -05:00
|
|
|
_fieldEC = file->readNumber();
|
2016-08-28 11:29:23 -04:00
|
|
|
_itemPos.x = file->readNumber();
|
|
|
|
_itemPos.y = file->readNumber();
|
2016-03-02 22:05:25 -05:00
|
|
|
_fieldF8 = file->readNumber();
|
2016-08-28 11:29:23 -04:00
|
|
|
_seasonNum = (Season)file->readNumber();
|
2016-03-02 22:05:25 -05:00
|
|
|
|
2016-02-29 21:20:33 -05:00
|
|
|
CBackground::load(file);
|
|
|
|
}
|
|
|
|
|
2016-08-28 11:29:23 -04:00
|
|
|
bool CSpeechDispensor::FrameMsg(CFrameMsg *msg) {
|
|
|
|
if (_fieldEC || _seasonNum == 0 || _seasonNum == 3)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
CGameObject *dragObject = getDraggingObject();
|
|
|
|
if (!_dragItem && dragObject && getView() == findView()) {
|
|
|
|
if (dragObject->isEquals("Perch")) {
|
|
|
|
petDisplayMessage(1, "This stick is too short to reach the branches.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dragObject->isEquals("LongStick"))
|
|
|
|
_dragItem = dragObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_dragItem) {
|
|
|
|
Point pt(_itemPos.x + _dragItem->_bounds.left,
|
|
|
|
_itemPos.y + _dragItem->_bounds.top);
|
|
|
|
bool flag = checkPoint(pt, true);
|
|
|
|
|
|
|
|
switch (_state) {
|
|
|
|
case 0:
|
|
|
|
playSound("z#93.wav");
|
|
|
|
if (_seasonNum == SEASON_WINTER) {
|
|
|
|
petDisplayMessage(1, "You cannot get this, it is frozen to the branch.");
|
|
|
|
_fieldE0 = false;
|
|
|
|
_state = 1;
|
|
|
|
} else {
|
|
|
|
if (++_fieldE0 >= 5) {
|
|
|
|
CActMsg actMsg("PlayerGetsSpeechCentre");
|
|
|
|
actMsg.execute("SeasonalAdjust");
|
|
|
|
CSpeechFallsFromTreeMsg fallMsg(pt);
|
|
|
|
fallMsg.execute("SpeechCentre");
|
|
|
|
|
|
|
|
_fieldEC = true;
|
|
|
|
_fieldE0 = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_state = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
_state = 0;
|
|
|
|
++_fieldE0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpeechDispensor::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
|
|
|
if (!_fieldEC) {
|
|
|
|
playSound("z#93.wav");
|
|
|
|
if (_fieldF8) {
|
|
|
|
petDisplayMessage(1, "Sadly, this is out of your reach.");
|
|
|
|
} else {
|
|
|
|
petDisplayMessage(1, "You can't pick this up on account of it being stuck to the branch.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpeechDispensor::StatusChangeMsg(CStatusChangeMsg *msg) {
|
|
|
|
_fieldF8 = msg->_newStatus == 1;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CSpeechDispensor::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
|
|
|
|
_seasonNum = (Season)(((int)_seasonNum + 1) % 4);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-29 21:20:33 -05:00
|
|
|
} // End of namespace Titanic
|