Initial commit
This commit is contained in:
755
engines/titanic/pet_control/pet_control.cpp
Normal file
755
engines/titanic/pet_control/pet_control.cpp
Normal file
@@ -0,0 +1,755 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/carry/carry.h"
|
||||
#include "titanic/core/project_item.h"
|
||||
#include "titanic/messages/messages.h"
|
||||
#include "titanic/messages/pet_messages.h"
|
||||
#include "titanic/game_manager.h"
|
||||
#include "titanic/game_state.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
#include "backends/keymapper/keymapper.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPetControl, CGameObject)
|
||||
ON_MESSAGE(MouseButtonDownMsg)
|
||||
ON_MESSAGE(MouseDragStartMsg)
|
||||
ON_MESSAGE(MouseDragMoveMsg)
|
||||
ON_MESSAGE(MouseDragEndMsg)
|
||||
ON_MESSAGE(MouseButtonUpMsg)
|
||||
ON_MESSAGE(MouseDoubleClickMsg)
|
||||
ON_MESSAGE(MouseWheelMsg)
|
||||
ON_MESSAGE(KeyCharMsg)
|
||||
ON_MESSAGE(ActionMsg)
|
||||
ON_MESSAGE(TimerMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
CPetControl::CPetControl() : CGameObject(),
|
||||
_currentArea(PET_CONVERSATION), _inputLockCount(0), _areaLockCount(0),
|
||||
_areaChangeType(-1), _activeNPC(nullptr), _remoteTarget(nullptr),
|
||||
_hiddenRoom(nullptr), _drawBounds(20, 350, 620, 480) {
|
||||
_sections[PET_INVENTORY] = &_inventory;
|
||||
_sections[PET_CONVERSATION] = &_conversations;
|
||||
_sections[PET_REMOTE] = &_remote;
|
||||
_sections[PET_ROOMS] = &_rooms;
|
||||
_sections[PET_REAL_LIFE] = &_realLife;
|
||||
_sections[PET_STARFIELD] = &_starfield;
|
||||
_sections[PET_TRANSLATION] = &_translation;
|
||||
}
|
||||
|
||||
void CPetControl::save(SimpleFile *file, int indent) {
|
||||
// Ensure a remote target name is set if there is one
|
||||
if (_remoteTargetName.empty() && _remoteTarget)
|
||||
_remoteTargetName = _remoteTarget->getName();
|
||||
|
||||
file->writeNumberLine(0, indent);
|
||||
file->writeNumberLine(_currentArea, indent);
|
||||
file->writeQuotedLine(_activeNPCName, indent);
|
||||
file->writeQuotedLine(_remoteTargetName, indent);
|
||||
|
||||
saveAreas(file, indent);
|
||||
CGameObject::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetControl::load(SimpleFile *file) {
|
||||
int val = file->readNumber();
|
||||
isValid();
|
||||
Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
|
||||
|
||||
if (!val) {
|
||||
_currentArea = (PetArea)file->readNumber();
|
||||
_activeNPCName = file->readString();
|
||||
_remoteTargetName = file->readString();
|
||||
|
||||
loadAreas(file, 0);
|
||||
|
||||
if (_currentArea == PET_REAL_LIFE) {
|
||||
keymapper->getKeymap("inv-shortcut")->setEnabled(false);
|
||||
keymapper->getKeymap("real-life")->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
CGameObject::load(file);
|
||||
}
|
||||
|
||||
void CPetControl::reset() {
|
||||
_conversations.reset();
|
||||
_rooms.reset();
|
||||
_remote.reset();
|
||||
_inventory.reset();
|
||||
_starfield.reset();
|
||||
_realLife.reset();
|
||||
_translation.reset();
|
||||
_frame.reset();
|
||||
}
|
||||
|
||||
bool CPetControl::isValid() {
|
||||
return _conversations.isValid(this) &&
|
||||
_rooms.isValid(this) &&
|
||||
_remote.isValid(this) &&
|
||||
_inventory.isValid(this) &&
|
||||
_starfield.isValid(this) &&
|
||||
_realLife.isValid(this) &&
|
||||
_translation.isValid(this) &&
|
||||
_frame.isValid(this);
|
||||
}
|
||||
|
||||
void CPetControl::loadAreas(SimpleFile *file, int param) {
|
||||
_conversations.load(file, param);
|
||||
_rooms.load(file, param);
|
||||
_remote.load(file, param);
|
||||
_inventory.load(file, param);
|
||||
_starfield.load(file, param);
|
||||
_realLife.load(file, param);
|
||||
_translation.load(file, param);
|
||||
_frame.load(file, param);
|
||||
}
|
||||
|
||||
void CPetControl::saveAreas(SimpleFile *file, int indent) {
|
||||
_conversations.save(file, indent);
|
||||
_rooms.save(file, indent);
|
||||
_remote.save(file, indent);
|
||||
_inventory.save(file, indent);
|
||||
_starfield.save(file, indent);
|
||||
_realLife.save(file, indent);
|
||||
_translation.save(file, indent);
|
||||
_frame.save(file, indent);
|
||||
}
|
||||
|
||||
void CPetControl::draw(CScreenManager *screenManager) {
|
||||
CGameManager *gameManager = getGameManager();
|
||||
Rect bounds = _drawBounds;
|
||||
bounds.constrain(gameManager->_bounds);
|
||||
|
||||
if (!bounds.isEmpty()) {
|
||||
if (_areaChangeType >= 0) {
|
||||
_inventory.changed(_areaChangeType);
|
||||
_areaChangeType = -1;
|
||||
}
|
||||
|
||||
_frame.drawFrame(screenManager);
|
||||
|
||||
// Draw the specific area that's currently active
|
||||
_sections[_currentArea]->draw(screenManager);
|
||||
}
|
||||
}
|
||||
|
||||
Rect CPetControl::getBounds() const {
|
||||
return _sections[_currentArea]->getBounds();
|
||||
}
|
||||
|
||||
void CPetControl::postLoad() {
|
||||
CProjectItem *root = getRoot();
|
||||
|
||||
if (!_activeNPCName.empty() && root)
|
||||
_activeNPC = root->findByName(_activeNPCName);
|
||||
if (!_remoteTargetName.empty() && root)
|
||||
_remoteTarget = dynamic_cast<CGameObject *>(root->findByName(_remoteTargetName));
|
||||
|
||||
setArea(_currentArea, true);
|
||||
loaded();
|
||||
}
|
||||
|
||||
void CPetControl::loaded() {
|
||||
_conversations.postLoad();
|
||||
_rooms.postLoad();
|
||||
_remote.postLoad();
|
||||
_inventory.postLoad();
|
||||
_starfield.postLoad();
|
||||
_realLife.postLoad();
|
||||
_translation.postLoad();
|
||||
_frame.postLoad();
|
||||
}
|
||||
|
||||
void CPetControl::enterNode(CNodeItem *node) {
|
||||
getGameManager()->_gameState.enterNode();
|
||||
}
|
||||
|
||||
void CPetControl::enterRoom(CRoomItem *room) {
|
||||
_rooms.enterRoom(room);
|
||||
_remote.enterRoom(room);
|
||||
_inventory.enterRoom(room);
|
||||
}
|
||||
|
||||
void CPetControl::resetRemoteTarget() {
|
||||
_remoteTarget = nullptr;
|
||||
_remoteTargetName.clear();
|
||||
}
|
||||
|
||||
void CPetControl::setActiveNPC(CTrueTalkNPC *npc) {
|
||||
if (_activeNPC != npc) {
|
||||
_activeNPC = npc;
|
||||
|
||||
if (_activeNPC) {
|
||||
_activeNPCName = npc->getName();
|
||||
_conversations.displayNPCName(npc);
|
||||
} else {
|
||||
_activeNPCName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPetControl::setActiveNPC(const CString &name) {
|
||||
_conversations.setActiveNPC(name);
|
||||
}
|
||||
|
||||
void CPetControl::refreshNPC() {
|
||||
_conversations.setNPC(_activeNPCName);
|
||||
}
|
||||
|
||||
void CPetControl::resetActiveNPC() {
|
||||
_activeNPC = nullptr;
|
||||
_activeNPCName = "";
|
||||
}
|
||||
|
||||
PetArea CPetControl::setArea(PetArea newArea, bool forceChange) {
|
||||
if ((!forceChange && newArea == _currentArea) || !isAreaUnlocked())
|
||||
return _currentArea;
|
||||
|
||||
Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
|
||||
if (newArea == PET_REAL_LIFE) {
|
||||
keymapper->getKeymap("inv-shortcut")->setEnabled(false);
|
||||
keymapper->getKeymap("real-life")->setEnabled(true);
|
||||
} else {
|
||||
keymapper->getKeymap("real-life")->setEnabled(false);
|
||||
keymapper->getKeymap("inv-shortcut")->setEnabled(true);
|
||||
}
|
||||
|
||||
// Signal the currently active area that it's being left
|
||||
_sections[_currentArea]->leave();
|
||||
|
||||
// Change the current area
|
||||
PetArea oldArea = _currentArea;
|
||||
_frame.setArea(newArea);
|
||||
_currentArea = newArea;
|
||||
|
||||
// Signal to the new view that it's been activated
|
||||
_sections[_currentArea]->enter(oldArea);
|
||||
|
||||
makeDirty();
|
||||
return newArea;
|
||||
}
|
||||
|
||||
void CPetControl::hideCursor() {
|
||||
_sections[_currentArea]->hideCursor();
|
||||
}
|
||||
|
||||
void CPetControl::showCursor() {
|
||||
_sections[_currentArea]->showCursor();
|
||||
}
|
||||
|
||||
void CPetControl::highlightGlyph(int id) {
|
||||
_sections[_currentArea]->highlight(id);
|
||||
}
|
||||
|
||||
void CPetControl::setRemoteTarget(CGameObject *item) {
|
||||
_remoteTarget = item;
|
||||
if (item)
|
||||
_remoteTargetName = item->getName();
|
||||
else
|
||||
_remoteTargetName.clear();
|
||||
}
|
||||
|
||||
CRoomItem *CPetControl::getHiddenRoom() {
|
||||
if (!_hiddenRoom)
|
||||
_hiddenRoom = CGameObject::getHiddenRoom();
|
||||
|
||||
return _hiddenRoom;
|
||||
}
|
||||
|
||||
CGameObject *CPetControl::getHiddenObject(const CString &name) {
|
||||
CRoomItem *room = getHiddenRoom();
|
||||
return room ? dynamic_cast<CGameObject *>(findUnder(room, name)) : nullptr;
|
||||
}
|
||||
|
||||
bool CPetControl::containsPt(const Common::Point &pt) const {
|
||||
return _drawBounds.contains(pt);
|
||||
}
|
||||
|
||||
bool CPetControl::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
if (!containsPt(msg->_mousePos) || isInputLocked())
|
||||
return false;
|
||||
|
||||
bool result = false;
|
||||
if (isAreaUnlocked())
|
||||
result = _frame.MouseButtonDownMsg(msg);
|
||||
|
||||
if (!result) {
|
||||
result = _sections[_currentArea]->MouseButtonDownMsg(msg);
|
||||
}
|
||||
|
||||
makeDirty();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetControl::MouseDragStartMsg(CMouseDragStartMsg *msg) {
|
||||
if (!containsPt(msg->_mousePos) || isInputLocked())
|
||||
return false;
|
||||
|
||||
return _sections[_currentArea]->MouseDragStartMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetControl::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
|
||||
return _sections[_currentArea]->MouseDragMoveMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetControl::MouseDragEndMsg(CMouseDragEndMsg *msg) {
|
||||
return _sections[_currentArea]->MouseDragEndMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetControl::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
||||
if (!containsPt(msg->_mousePos) || isInputLocked())
|
||||
return false;
|
||||
|
||||
bool result = false;
|
||||
if (isAreaUnlocked())
|
||||
result = _frame.MouseButtonUpMsg(msg);
|
||||
|
||||
if (!result)
|
||||
result = _sections[_currentArea]->MouseButtonUpMsg(msg);
|
||||
|
||||
makeDirty();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetControl::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
|
||||
if (!containsPt(msg->_mousePos) || isInputLocked())
|
||||
return false;
|
||||
|
||||
return _sections[_currentArea]->MouseDoubleClickMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetControl::MouseWheelMsg(CMouseWheelMsg *msg) {
|
||||
if (!containsPt(msg->_mousePos) || isInputLocked())
|
||||
return false;
|
||||
|
||||
return _sections[_currentArea]->MouseWheelMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetControl::KeyCharMsg(CKeyCharMsg *msg) {
|
||||
if (isInputLocked())
|
||||
return false;
|
||||
|
||||
makeDirty();
|
||||
bool result = _sections[_currentArea]->KeyCharMsg(msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetControl::ActionMsg(CActionMsg *msg) {
|
||||
if (isInputLocked())
|
||||
return false;
|
||||
|
||||
bool result = _sections[_currentArea]->ActionMsg(msg);
|
||||
|
||||
if (!result) {
|
||||
switch (msg->_action) {
|
||||
case kActionPETConversation:
|
||||
result = true;
|
||||
setArea(PET_CONVERSATION);
|
||||
break;
|
||||
case kActionPETInventory:
|
||||
result = true;
|
||||
setArea(PET_INVENTORY);
|
||||
break;
|
||||
case kActionPETRemote:
|
||||
result = true;
|
||||
setArea(PET_REMOTE);
|
||||
break;
|
||||
case kActionPETRooms:
|
||||
result = true;
|
||||
setArea(PET_ROOMS);
|
||||
break;
|
||||
case kActionPETRealLife:
|
||||
result = true;
|
||||
setArea(PET_REAL_LIFE);
|
||||
break;
|
||||
case kActionPETTranslation:
|
||||
result = true;
|
||||
setArea(PET_TRANSLATION);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetControl::TimerMsg(CTimerMsg *msg) {
|
||||
if (_timers[msg->_actionVal]._target)
|
||||
_timers[msg->_actionVal]._target->timerExpired(msg->_actionVal);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetControl::drawSquares(CScreenManager *screenManager, int count) {
|
||||
_frame.drawSquares(screenManager, count);
|
||||
}
|
||||
|
||||
CGameObject *CPetControl::dragEnd(const Point &pt) const {
|
||||
return _currentArea == PET_INVENTORY ? _inventory.dragEnd(pt) : nullptr;
|
||||
}
|
||||
|
||||
bool CPetControl::checkDragEnd(CGameObject *item) const {
|
||||
return _sections[_currentArea]->checkDragEnd(item);
|
||||
}
|
||||
|
||||
void CPetControl::displayMessage(StringId stringId, int param) const {
|
||||
CString msg = CString::format(g_vm->_strings[stringId].c_str(), param);
|
||||
_sections[_currentArea]->displayMessage(msg);
|
||||
}
|
||||
|
||||
void CPetControl::displayMessage(const CString &str, int param) const {
|
||||
CString msg = CString::format(str.c_str(), param);
|
||||
_sections[_currentArea]->displayMessage(msg);
|
||||
}
|
||||
|
||||
void CPetControl::addTranslation(StringId id1, StringId id2) {
|
||||
setArea(PET_TRANSLATION);
|
||||
_translation.addTranslation(g_vm->_strings[id1], g_vm->_strings[id2]);
|
||||
}
|
||||
|
||||
void CPetControl::clearTranslation() {
|
||||
_translation.clearTranslation();
|
||||
}
|
||||
|
||||
CGameObject *CPetControl::getFirstObject() const {
|
||||
return dynamic_cast<CGameObject *>(getFirstChild());
|
||||
}
|
||||
|
||||
CGameObject *CPetControl::getNextObject(CGameObject *prior) const {
|
||||
if (!prior || prior->getParent() != this)
|
||||
return nullptr;
|
||||
|
||||
return dynamic_cast<CGameObject *>(prior->getNextSibling());
|
||||
}
|
||||
|
||||
void CPetControl::addToInventory(CGameObject *item) {
|
||||
item->detach();
|
||||
|
||||
if (item->getName() == "CarryParcel") {
|
||||
CCarry *child = dynamic_cast<CCarry *>(getLastChild());
|
||||
if (child)
|
||||
child->detach();
|
||||
|
||||
item->petMoveToHiddenRoom();
|
||||
if (!child)
|
||||
return;
|
||||
|
||||
item = child;
|
||||
}
|
||||
|
||||
item->addUnder(this);
|
||||
_inventory.itemsChanged();
|
||||
|
||||
setArea(PET_INVENTORY);
|
||||
if (_currentArea == PET_INVENTORY)
|
||||
_inventory.highlightItem(item);
|
||||
|
||||
makeDirty();
|
||||
CPETGainedObjectMsg msg;
|
||||
msg.execute(item);
|
||||
}
|
||||
|
||||
void CPetControl::removeFromInventory(CGameObject *item, CTreeItem *newParent,
|
||||
bool refreshUI, bool sendMsg) {
|
||||
if (item && newParent) {
|
||||
item->detach();
|
||||
item->addUnder(newParent);
|
||||
|
||||
if (refreshUI)
|
||||
_inventory.itemRemoved(item);
|
||||
if (sendMsg) {
|
||||
CPETLostObjectMsg lostMsg;
|
||||
lostMsg.execute(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPetControl::removeFromInventory(CGameObject *item, bool refreshUI, bool sendMsg) {
|
||||
CViewItem *view = getGameManager()->getView();
|
||||
removeFromInventory(item, view, refreshUI, sendMsg);
|
||||
}
|
||||
|
||||
void CPetControl::invChange(CGameObject *item) {
|
||||
_inventory.change(item);
|
||||
}
|
||||
|
||||
void CPetControl::moveToHiddenRoom(CTreeItem *item) {
|
||||
CRoomItem *room = getHiddenRoom();
|
||||
if (room) {
|
||||
item->detach();
|
||||
item->addUnder(room);
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetControl::checkNode(const CString &name) {
|
||||
CGameManager *gameManager = getGameManager();
|
||||
if (!gameManager)
|
||||
return true;
|
||||
if (name == "NULL")
|
||||
return false;
|
||||
|
||||
CViewItem *view = gameManager->getView();
|
||||
if (!view)
|
||||
return true;
|
||||
|
||||
CNodeItem *node = view->findNode();
|
||||
if (!node)
|
||||
return true;
|
||||
|
||||
CString viewName = view->getName();
|
||||
CString nodeName = node->getName();
|
||||
CRoomItem *room = getGameManager()->getRoom();
|
||||
|
||||
if (room) {
|
||||
CString roomName = room->getName();
|
||||
CString newNode;
|
||||
|
||||
if (roomName == "1stClassRestaurant") {
|
||||
} else if (nodeName == "Lobby Node") {
|
||||
nodeName = "Node 1";
|
||||
} else if (nodeName == "Entrance Node") {
|
||||
nodeName = "Node 2";
|
||||
} else if (nodeName == "MaitreD Node") {
|
||||
nodeName = "Node 3";
|
||||
} else if (nodeName == "Scraliontis Table Standing Node") {
|
||||
nodeName = "Node 4";
|
||||
} else if (nodeName == "Pellerator Node") {
|
||||
nodeName = "Node 5";
|
||||
} else if (nodeName == "SUB Node") {
|
||||
nodeName = "Node 6";
|
||||
} else if (nodeName == "Phonograph Node") {
|
||||
nodeName = "Node 7";
|
||||
} else if (nodeName == "Scraliontis Table Seated Node") {
|
||||
nodeName = "Node 8";
|
||||
}
|
||||
|
||||
if (roomName == "MusicRoom") {
|
||||
if (nodeName == "Musical Instruments")
|
||||
nodeName = "Node 1";
|
||||
if (nodeName == "Phonograph Node")
|
||||
nodeName = "Node 2";
|
||||
}
|
||||
}
|
||||
|
||||
CString str = CString::format("%s.%s", nodeName.c_str(), viewName.c_str());
|
||||
str = str.right(5);
|
||||
str.toLowercase();
|
||||
|
||||
CString nameLower = name;
|
||||
nameLower.toLowercase();
|
||||
|
||||
return nameLower.contains(str);
|
||||
}
|
||||
|
||||
void CPetControl::syncSoundSettings() {
|
||||
_realLife.syncSoundSettings();
|
||||
}
|
||||
|
||||
void CPetControl::playSound(int soundNum) {
|
||||
CTreeItem *player = getHiddenObject("PETSoundPlayer");
|
||||
if (player) {
|
||||
CPETPlaySoundMsg playMsg(soundNum);
|
||||
playMsg.execute(player);
|
||||
}
|
||||
}
|
||||
|
||||
int CPetControl::canSummonBot(const CString &name) {
|
||||
// If player is the very same view as the NPC, then it's already present
|
||||
if (isBotInView(name))
|
||||
return SUMMON_CAN;
|
||||
|
||||
// Get the room
|
||||
CGameManager *gameManager = getGameManager();
|
||||
if (!gameManager)
|
||||
return SUMMON_CANT;
|
||||
CRoomItem *room = gameManager->getRoom();
|
||||
if (!room)
|
||||
return SUMMON_CANT;
|
||||
|
||||
// WORKAROUND: Handle special disallowed locations
|
||||
if (isBotDisallowedLocation())
|
||||
return SUMMON_CANT;
|
||||
|
||||
// Query current room to see whether the bot can be summoned to it
|
||||
CSummonBotQueryMsg queryMsg(name);
|
||||
return queryMsg.execute(room) ? SUMMON_CAN : SUMMON_CANT;
|
||||
}
|
||||
|
||||
bool CPetControl::isBotInView(const CString &name) const {
|
||||
CGameManager *gameManager = getGameManager();
|
||||
if (!gameManager)
|
||||
return false;
|
||||
CViewItem *view = gameManager->getView();
|
||||
if (!view)
|
||||
return false;
|
||||
|
||||
// Iterate to find NPC
|
||||
for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) {
|
||||
CGameObject *gameObject = dynamic_cast<CGameObject *>(child);
|
||||
if (gameObject) {
|
||||
if (!gameObject->getName().compareToIgnoreCase(name))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetControl::summonBot(const CString &name, int val) {
|
||||
CGameManager *gameManager = getGameManager();
|
||||
if (gameManager) {
|
||||
CRoomItem *room = gameManager->getRoom();
|
||||
|
||||
if (room) {
|
||||
CSummonBotMsg summonMsg(name, val);
|
||||
summonMsg.execute(room);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPetControl::onSummonBot(const CString &name, int val) {
|
||||
CGameObject *bot = findBot(name, getHiddenRoom());
|
||||
if (!bot) {
|
||||
bot = findBot(name, getRoot());
|
||||
}
|
||||
|
||||
if (bot) {
|
||||
removeFromInventory(bot, false, false);
|
||||
|
||||
COnSummonBotMsg summonMsg(val);
|
||||
summonMsg.execute(bot);
|
||||
makeDirty();
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetControl::dismissBot(const CString &name) {
|
||||
CGameManager *gameManager = getGameManager();
|
||||
if (!gameManager)
|
||||
return false;
|
||||
CViewItem *view = gameManager->getView();
|
||||
if (!view)
|
||||
return false;
|
||||
|
||||
bool result = false;
|
||||
CDismissBotMsg dismissMsg;
|
||||
for (CTreeItem *treeItem = view->getFirstChild(); treeItem;
|
||||
treeItem = treeItem->scan(view)) {
|
||||
CGameObject *obj = dynamic_cast<CGameObject *>(treeItem);
|
||||
if (obj) {
|
||||
if (!obj->getName().compareToIgnoreCase(name))
|
||||
result = true;
|
||||
else
|
||||
dismissMsg.execute(treeItem);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetControl::isDoorOrBellbotPresent() const {
|
||||
CGameManager *gameManager = getGameManager();
|
||||
if (!gameManager)
|
||||
return false;
|
||||
CViewItem *view = gameManager->getView();
|
||||
if (!view)
|
||||
return false;
|
||||
|
||||
for (CTreeItem *treeItem = view->getFirstChild(); treeItem;
|
||||
treeItem = treeItem->scan(view)) {
|
||||
CString name = treeItem->getName();
|
||||
if (dynamic_cast<CGameObject *>(treeItem) &&
|
||||
(name.containsIgnoreCase("Doorbot") || name.containsIgnoreCase("BellBot")))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetControl::startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target) {
|
||||
stopPetTimer(timerIndex);
|
||||
_timers[timerIndex]._id = addTimer(timerIndex, firstDuration, duration);
|
||||
_timers[timerIndex]._target = target;
|
||||
setTimerPersisent(_timers[timerIndex]._id, false);
|
||||
}
|
||||
|
||||
void CPetControl::stopPetTimer(uint timerIndex) {
|
||||
if (_timers[timerIndex]._target) {
|
||||
stopTimer(_timers[timerIndex]._id);
|
||||
_timers[timerIndex]._target = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetControl::setTimerPersisent(int id, bool flag) {
|
||||
getGameManager()->setTimerPersisent(id, flag);
|
||||
}
|
||||
|
||||
CGameObject *CPetControl::findBot(const CString &name, CTreeItem *root) {
|
||||
for (CTreeItem *item = root; item; item = item->scan(root)) {
|
||||
if (!item->getName().compareToIgnoreCase(name)) {
|
||||
CGameObject *obj = dynamic_cast<CGameObject *>(item);
|
||||
if (obj)
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CPetControl::isSuccUBusActive() const {
|
||||
if (!_activeNPC)
|
||||
return false;
|
||||
|
||||
CString name = getName();
|
||||
return name.containsIgnoreCase("Succubus") || name.containsIgnoreCase("Sub");
|
||||
}
|
||||
|
||||
void CPetControl::convResetDials(int flag) {
|
||||
if (flag == 1)
|
||||
_conversations.resetDials(_activeNPCName);
|
||||
}
|
||||
|
||||
void CPetControl::resetDials0() {
|
||||
_conversations.resetDials0();
|
||||
}
|
||||
|
||||
PassengerClass CPetControl::getMailDestClass(const CRoomFlags &roomFlags) const {
|
||||
if (!roomFlags.isSuccUBusRoomFlags())
|
||||
return roomFlags.getPassengerClassNum();
|
||||
|
||||
return roomFlags.getSuccUBusClass(roomFlags.getSuccUBusRoomName());
|
||||
}
|
||||
|
||||
void CPetControl::starsSetButtons(int matchIndex, bool isMarkerClose) {
|
||||
_starfield.setButtons(matchIndex, isMarkerClose);
|
||||
if (_currentArea == PET_STARFIELD)
|
||||
_starfield.makePetDirty();
|
||||
}
|
||||
|
||||
void CPetControl::starsSetReference() {
|
||||
_starfield.setHasReference(true);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
609
engines/titanic/pet_control/pet_control.h
Normal file
609
engines/titanic/pet_control/pet_control.h
Normal file
@@ -0,0 +1,609 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_CONTROL_H
|
||||
#define TITANIC_PET_CONTROL_H
|
||||
|
||||
#include "titanic/core/game_object.h"
|
||||
#include "titanic/core/node_item.h"
|
||||
#include "titanic/core/room_item.h"
|
||||
#include "titanic/messages/messages.h"
|
||||
#include "titanic/messages/mouse_messages.h"
|
||||
#include "titanic/pet_control/pet_conversations.h"
|
||||
#include "titanic/pet_control/pet_frame.h"
|
||||
#include "titanic/pet_control/pet_inventory.h"
|
||||
#include "titanic/pet_control/pet_translation.h"
|
||||
#include "titanic/pet_control/pet_starfield.h"
|
||||
#include "titanic/pet_control/pet_real_life.h"
|
||||
#include "titanic/pet_control/pet_remote.h"
|
||||
#include "titanic/pet_control/pet_rooms.h"
|
||||
#include "titanic/support/strings.h"
|
||||
#include "titanic/room_flags.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
enum SummonResult { SUMMON_CANT = 0, SUMMON_PRESENT = 1, SUMMON_CAN = 2 };
|
||||
|
||||
class CPetControl : public CGameObject {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
struct PetEventInfo {
|
||||
int _id;
|
||||
CPetSection *_target;
|
||||
PetEventInfo() : _id(0), _target(nullptr) {}
|
||||
};
|
||||
private:
|
||||
int _inputLockCount;
|
||||
int _areaLockCount;
|
||||
int _areaChangeType;
|
||||
CPetSection *_sections[7];
|
||||
CPetConversations _conversations;
|
||||
CPetInventory _inventory;
|
||||
CPetStarfield _starfield;
|
||||
CPetRemote _remote;
|
||||
CPetRooms _rooms;
|
||||
CPetRealLife _realLife;
|
||||
CPetTranslation _translation;
|
||||
CPetFrame _frame;
|
||||
CString _activeNPCName;
|
||||
CString _remoteTargetName;
|
||||
CRoomItem *_hiddenRoom;
|
||||
Rect _drawBounds;
|
||||
PetEventInfo _timers[2];
|
||||
private:
|
||||
/**
|
||||
* Returns true if the control is in a valid state
|
||||
*/
|
||||
bool isValid();
|
||||
|
||||
/**
|
||||
* Loads data for the individual areas
|
||||
*/
|
||||
void loadAreas(SimpleFile *file, int param);
|
||||
|
||||
/**
|
||||
* Saves data for the individual areas
|
||||
*/
|
||||
void saveAreas(SimpleFile *file, int indent);
|
||||
|
||||
/**
|
||||
* Called at the end of the post game-load handling
|
||||
*/
|
||||
void loaded();
|
||||
|
||||
/**
|
||||
* Returns true if the draw bounds contains the specified point
|
||||
*/
|
||||
bool containsPt(const Common::Point &pt) const;
|
||||
|
||||
/**
|
||||
* Checks whether a designated NPC in present in the current view
|
||||
*/
|
||||
bool isBotInView(const CString &name) const;
|
||||
|
||||
/**
|
||||
* Find a bot under a given root
|
||||
*/
|
||||
CGameObject *findBot(const CString &name, CTreeItem *root);
|
||||
|
||||
/**
|
||||
* Flags whether the timer will be persisent across save & loads
|
||||
*/
|
||||
void setTimerPersisent(int id, bool flag);
|
||||
protected:
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
|
||||
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
|
||||
bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
|
||||
bool MouseDragEndMsg(CMouseDragEndMsg *msg);
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
|
||||
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
|
||||
bool MouseWheelMsg(CMouseWheelMsg *msg);
|
||||
bool KeyCharMsg(CKeyCharMsg *msg);
|
||||
bool ActionMsg(CActionMsg *msg);
|
||||
bool TimerMsg(CTimerMsg *msg);
|
||||
public:
|
||||
PetArea _currentArea;
|
||||
CTreeItem *_activeNPC;
|
||||
CGameObject *_remoteTarget;
|
||||
public:
|
||||
CLASSDEF;
|
||||
CPetControl();
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
|
||||
/**
|
||||
* Allows the item to draw itself
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Gets the bounds occupied by the item
|
||||
*/
|
||||
Rect getBounds() const override;
|
||||
|
||||
/**
|
||||
* Resets the PET, including all the sections within it
|
||||
*/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Called after loading a game has finished
|
||||
*/
|
||||
void postLoad();
|
||||
|
||||
/**
|
||||
* Called when a new node is entered
|
||||
*/
|
||||
void enterNode(CNodeItem *node);
|
||||
|
||||
/**
|
||||
* Called when a new room is entered
|
||||
*/
|
||||
void enterRoom(CRoomItem *room);
|
||||
|
||||
/**
|
||||
* Called to reset the remote target
|
||||
*/
|
||||
void resetRemoteTarget();
|
||||
|
||||
/**
|
||||
* Set the remote target
|
||||
*/
|
||||
void setRemoteTarget(CGameObject *item);
|
||||
|
||||
/**
|
||||
* Sets the currently viewed area within the PET
|
||||
*/
|
||||
PetArea setArea(PetArea newSection, bool forceChange = false);
|
||||
|
||||
/**
|
||||
* Hides the text cursor in the current section, if applicable
|
||||
*/
|
||||
void hideCursor();
|
||||
|
||||
/**
|
||||
* Shows the text cursor in the current section, if applicable
|
||||
*/
|
||||
void showCursor();
|
||||
|
||||
/**
|
||||
* Highlights a glyph item in the currently active section, if applicable
|
||||
*/
|
||||
void highlightGlyph(int id);
|
||||
|
||||
|
||||
/**
|
||||
* Returns a game object used by the PET by name from within the
|
||||
* special hidden room container
|
||||
*/
|
||||
CGameObject *getHiddenObject(const CString &name);
|
||||
|
||||
/**
|
||||
* Returns a reference to the special hidden room container
|
||||
*/
|
||||
CRoomItem *getHiddenRoom();
|
||||
|
||||
/**
|
||||
* Draws squares for showing glyphs inside
|
||||
*/
|
||||
void drawSquares(CScreenManager *screenManager, int count);
|
||||
|
||||
/**
|
||||
* Returns true if the point is within the PET's draw bounds
|
||||
*/
|
||||
bool contains(const Point &pt) const {
|
||||
return _drawBounds.contains(pt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles drag ends within the PET
|
||||
*/
|
||||
CGameObject *dragEnd(const Point &pt) const;
|
||||
|
||||
/**
|
||||
* Handles checking when a drag-drop operation ends
|
||||
*/
|
||||
bool checkDragEnd(CGameObject *item) const;
|
||||
|
||||
/**
|
||||
* Display a message
|
||||
*/
|
||||
void displayMessage(StringId stringId, int param = 0) const;
|
||||
|
||||
/**
|
||||
* Display a message
|
||||
*/
|
||||
void displayMessage(const CString &str, int param = 0) const;
|
||||
|
||||
/**
|
||||
* Switches to the Translation display, and adds a line to it's content
|
||||
*/
|
||||
void addTranslation(StringId id1, StringId id2);
|
||||
|
||||
/**
|
||||
* Clears the translation display
|
||||
*/
|
||||
void clearTranslation();
|
||||
|
||||
/**
|
||||
* Get the first game object stored in the PET
|
||||
*/
|
||||
CGameObject *getFirstObject() const;
|
||||
|
||||
/**
|
||||
* Get the next game object stored in the PET following
|
||||
* the passed game object
|
||||
*/
|
||||
CGameObject *getNextObject(CGameObject *prior) const;
|
||||
|
||||
/**
|
||||
* Adds an item to the PET inventory
|
||||
*/
|
||||
void addToInventory(CGameObject *item);
|
||||
|
||||
/**
|
||||
* Remove an item from the inventory
|
||||
*/
|
||||
void removeFromInventory(CGameObject *item, CTreeItem *newParent,
|
||||
bool refreshUI = true, bool sendMsg = true);
|
||||
|
||||
/**
|
||||
* Remove an item from the inventory
|
||||
*/
|
||||
void removeFromInventory(CGameObject *item, bool refreshUI = true, bool sendMsg = true);
|
||||
|
||||
/**
|
||||
* Called when the status of an item in the inventory has changed
|
||||
*/
|
||||
void invChange(CGameObject *item);
|
||||
|
||||
/**
|
||||
* Moves a tree item from it's original position to be under the hidden room
|
||||
*/
|
||||
void moveToHiddenRoom(CTreeItem *item);
|
||||
|
||||
/**
|
||||
* Sets a change for the PET Area's glyphs. Only applicable when
|
||||
* the Inventory is the active tab
|
||||
*/
|
||||
void setAreaChangeType(int changeType) { _areaChangeType = changeType; }
|
||||
|
||||
bool checkNode(const CString &name);
|
||||
|
||||
/**
|
||||
* Handles updates to the sound levels
|
||||
*/
|
||||
void syncSoundSettings();
|
||||
|
||||
/**
|
||||
* Play a sound
|
||||
*/
|
||||
void playSound(int soundNum);
|
||||
|
||||
/**
|
||||
* Check whether an NPC can be summoned
|
||||
*/
|
||||
int canSummonBot(const CString &name);
|
||||
|
||||
/**
|
||||
* Summon an NPC to the player
|
||||
*/
|
||||
void summonBot(const CString &name, int val);
|
||||
|
||||
/**
|
||||
* Summon a bot to the player
|
||||
*/
|
||||
void onSummonBot(const CString &name, int val);
|
||||
|
||||
/**
|
||||
* Dismiss an NPC
|
||||
*/
|
||||
bool dismissBot(const CString &name);
|
||||
|
||||
/**
|
||||
* Returns true if Doorbot or Bellbot present
|
||||
*/
|
||||
bool isDoorOrBellbotPresent() const;
|
||||
|
||||
/**
|
||||
* Start a timer for a Pet Area
|
||||
*/
|
||||
void startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target);
|
||||
|
||||
/**
|
||||
* Stop a timer
|
||||
*/
|
||||
void stopPetTimer(uint timerIndex);
|
||||
|
||||
/**
|
||||
* Returns true if all input is currently locked (disabled)
|
||||
*/
|
||||
bool isInputLocked() const { return _inputLockCount > 0; }
|
||||
|
||||
/**
|
||||
* Increments the input locked count
|
||||
*/
|
||||
void incInputLocks() { ++_inputLockCount; }
|
||||
|
||||
/**
|
||||
* Decremenst the input locked count
|
||||
*/
|
||||
void decInputLocks() { --_inputLockCount; }
|
||||
|
||||
/**
|
||||
* Returns true if the PET is currently unlocked
|
||||
*/
|
||||
bool isAreaUnlocked() const { return _areaLockCount == 0; }
|
||||
|
||||
/**
|
||||
* Increment the number of PET area (tab) locks
|
||||
*/
|
||||
void incAreaLocks() { ++_areaLockCount; }
|
||||
|
||||
/**
|
||||
* Decrement the number of PET area (tab) locks
|
||||
*/
|
||||
void decAreaLocks() {
|
||||
_areaLockCount = MAX(_areaLockCount - 1, 0);
|
||||
}
|
||||
|
||||
bool isSuccUBusActive() const;
|
||||
|
||||
/*--- CPetConversations methods ---*/
|
||||
|
||||
/**
|
||||
* Sets the active NPC
|
||||
*/
|
||||
void setActiveNPC(const CString &name);
|
||||
|
||||
/**
|
||||
* Sets the actie NPC
|
||||
*/
|
||||
void setActiveNPC(CTrueTalkNPC *npc);
|
||||
|
||||
/**
|
||||
* Refresh the currently active NPC
|
||||
*/
|
||||
void refreshNPC();
|
||||
|
||||
/**
|
||||
* Resets the Active NPC
|
||||
*/
|
||||
void resetActiveNPC();
|
||||
|
||||
/**
|
||||
* Resets NPC in conversations
|
||||
*/
|
||||
void convResetNPC() {
|
||||
_conversations.resetNPC();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the conversation dials back to 0 position
|
||||
*/
|
||||
void resetDials0();
|
||||
|
||||
/**
|
||||
* Resets the dial display in the conversation tab to reflect new values
|
||||
*/
|
||||
void convResetDials(int flag = 1);
|
||||
|
||||
/**
|
||||
* Adds a line to the conversation log
|
||||
*/
|
||||
void convAddLine(const CString &line) {
|
||||
_conversations.addLine(line);
|
||||
}
|
||||
|
||||
/*--- CPetRooms methods ---*/
|
||||
|
||||
/**
|
||||
* Gives the player a new assigned room in the specified passenger class
|
||||
*/
|
||||
void reassignRoom(PassengerClass passClassNum) {
|
||||
_rooms.reassignRoom(passClassNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the current location passenger class
|
||||
*/
|
||||
bool changeLocationClass(PassengerClass newClassNum) {
|
||||
return _rooms.changeLocationClass(newClassNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the player is in the current or previously assigned rooms
|
||||
*/
|
||||
bool isInAssignedRoom() const {
|
||||
return _rooms.isAssignedRoom(getRoomFlags());
|
||||
}
|
||||
|
||||
uint getRoomFlags() const {
|
||||
return _rooms.getRoomFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current elevator number to use for room glyphs
|
||||
*/
|
||||
void setRoomsElevatorNum(int elevNum) {
|
||||
_rooms.setElevatorNum(elevNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current elevator number used by room glyphs
|
||||
*/
|
||||
int getRoomsElevatorNum() const {
|
||||
return _rooms.getElevatorNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current floor number to use for room glyphs
|
||||
*/
|
||||
void setRoomsFloorNum(int floorNum) {
|
||||
_rooms.setFloorNum(floorNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current floor number used by room glyphs
|
||||
*/
|
||||
int getRoomsFloorNum() const {
|
||||
return _rooms.getFloorNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current room number to use for room glyphs
|
||||
*/
|
||||
void setRoomsRoomNum(int roomNum) {
|
||||
_rooms.setRoomNum(roomNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current floor number used by room glyphs
|
||||
*/
|
||||
int getRoomsRoomNum() const {
|
||||
return _rooms.getRoomNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entry number for arriving at the well
|
||||
*/
|
||||
void setRoomsWellEntry(int entryNum) {
|
||||
_rooms.setWellEntry(entryNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entry number used when last arriving at the well
|
||||
*/
|
||||
int getRoomsWellEntry() const {
|
||||
return _rooms.getWellEntry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sub-level an SGT or 2nd class room is on
|
||||
*/
|
||||
void setRoomsSublevel(int level) {
|
||||
_rooms.setSublevel(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current sub-level for a stateroom
|
||||
*/
|
||||
int getRoomsSublevel() const {
|
||||
return _rooms.getSublevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the highlight
|
||||
*/
|
||||
void resetRoomsHighlight() {
|
||||
_rooms.resetHighlight();
|
||||
}
|
||||
|
||||
int getAssignedRoomFlags() const {
|
||||
return _rooms.getAssignedRoomFlags();
|
||||
}
|
||||
|
||||
uint getSpecialRoomFlags(const CString &name) {
|
||||
return CRoomFlags::getSpecialRoomFlags(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the passenger class of the specified room flags
|
||||
*/
|
||||
PassengerClass getMailDestClass(const CRoomFlags &roomFlags) const;
|
||||
|
||||
/**
|
||||
* Returns whether the given room flags specify a location with a SuccUBus
|
||||
*/
|
||||
bool isSuccUBusDest(uint roomFlags) {
|
||||
return CRoomFlags(roomFlags).isSuccUBusDest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the room number for the player's currently assigned room
|
||||
*/
|
||||
int getAssignedRoomNum() const {
|
||||
return _rooms.getAssignedRoomNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the floor number for the player's currently assigned room
|
||||
*/
|
||||
int getAssignedFloorNum() const {
|
||||
return _rooms.getAssignedFloorNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the elevator number for the player's currently assigned room
|
||||
*/
|
||||
int getAssignedElevatorNum() const {
|
||||
return _rooms.getAssignedElevatorNum();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag for whether elevator 4 has yet been fixed
|
||||
*/
|
||||
void setRoomsElevatorBroken(bool flag) {
|
||||
_rooms.setElevatorBroken(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the player is in their 1st class stateroom
|
||||
*/
|
||||
bool isFirstClassSuite() const {
|
||||
return CRoomFlags(getRoomFlags()).isFirstClassSuite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the passed room flags indicate the room has a succubus
|
||||
*/
|
||||
bool isSuccUBusRoom(const CRoomFlags &roomFlags) {
|
||||
return roomFlags.isSuccUBusRoomFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called with a phonograph action for Send, Receive, or Record
|
||||
*/
|
||||
void phonographAction(const CString &action) {
|
||||
// Original had some code that had no effect
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status buttons for the starfield control
|
||||
*/
|
||||
void starsSetButtons(int matchIndex, bool isMarkerClose);
|
||||
|
||||
/**
|
||||
* Sets that the user has the galactic reference material
|
||||
*/
|
||||
void starsSetReference();
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_CONTROL_H */
|
||||
590
engines/titanic/pet_control/pet_conversations.cpp
Normal file
590
engines/titanic/pet_control/pet_conversations.cpp
Normal file
@@ -0,0 +1,590 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_conversations.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/debugger.h"
|
||||
#include "titanic/game_manager.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetConversations::CPetConversations() : CPetSection(),
|
||||
_logChanged(false), _field418(0), _npcNum(-1),
|
||||
_rect1(22, 352, 598, 478) {
|
||||
Rect logRect(85, 18, 513, 87);
|
||||
logRect.translate(20, 350);
|
||||
_log.setBounds(logRect);
|
||||
_log.resize(50);
|
||||
_log.setHasBorder(false);
|
||||
_log.setColor(getColor(2));
|
||||
_log.setup();
|
||||
_log.addLine("Welcome to your PET v1.0a");
|
||||
|
||||
Rect inputRect(85, 95, 513, 135);
|
||||
inputRect.translate(20, 350);
|
||||
_textInput.setBounds(inputRect);
|
||||
_textInput.setHasBorder(false);
|
||||
_textInput.resize(2);
|
||||
_textInput.setMaxCharsPerLine(74);
|
||||
_textInput.setColor(getColor(0));
|
||||
_textInput.setup();
|
||||
|
||||
_npcLevels[0] = _npcLevels[1] = _npcLevels[2] = 0;
|
||||
}
|
||||
|
||||
bool CPetConversations::setup(CPetControl *petControl) {
|
||||
if (petControl && setupControl(petControl))
|
||||
return reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetConversations::reset() {
|
||||
_dials[0].setup(MODE_UNSELECTED, "3PetDial1", _petControl);
|
||||
_dials[1].setup(MODE_UNSELECTED, "3PetDial2", _petControl);
|
||||
_dials[2].setup(MODE_UNSELECTED, "3PetDial3", _petControl);
|
||||
|
||||
_dialBackground.reset("PetDialBack", _petControl);
|
||||
_scrollUp.reset("PetScrollUp", _petControl);
|
||||
_scrollDown.reset("PetScrollDown", _petControl);
|
||||
|
||||
_doorBot.reset("PetCallDoorOut", _petControl, MODE_UNSELECTED);
|
||||
_doorBot.reset("PetCallDoorIn", _petControl, MODE_SELECTED);
|
||||
_bellBot.reset("PetCallBellOut", _petControl, MODE_UNSELECTED);
|
||||
_bellBot.reset("PetCallBellIn", _petControl, MODE_SELECTED);
|
||||
|
||||
_indent.reset("PetSmallCharacterIndent", _petControl);
|
||||
_splitter.reset("PetSplitter", _petControl);
|
||||
|
||||
_npcIcons[0].setup(MODE_UNSELECTED, "3PetSmlDoorbot", _petControl);
|
||||
_npcIcons[1].setup(MODE_UNSELECTED, "3PetSmlDeskbot", _petControl);
|
||||
_npcIcons[2].setup(MODE_UNSELECTED, "3PetSmlLiftbot", _petControl);
|
||||
_npcIcons[3].setup(MODE_UNSELECTED, "3PetSmlParrot", _petControl);
|
||||
_npcIcons[4].setup(MODE_UNSELECTED, "3PetSmlBarbot", _petControl);
|
||||
_npcIcons[5].setup(MODE_UNSELECTED, "3PetSmlChatterbot", _petControl);
|
||||
_npcIcons[6].setup(MODE_UNSELECTED, "3PetSmlBellbot", _petControl);
|
||||
_npcIcons[7].setup(MODE_UNSELECTED, "3PetSmlMaitreD", _petControl);
|
||||
_npcIcons[8].setup(MODE_UNSELECTED, "3PetSmlSuccubus", _petControl);
|
||||
|
||||
if (_petControl->getPassengerClass() == 1) {
|
||||
uint col = getColor(0);
|
||||
_textInput.setColor(col);
|
||||
_textInput.setLineColor(0, col);
|
||||
|
||||
// Replace the log colors with new 1st class ones
|
||||
uint colors1[5], colors2[5];
|
||||
copyColors(2, colors1);
|
||||
copyColors(1, colors2);
|
||||
_log.remapColors(5, colors1, colors2);
|
||||
|
||||
_log.setColor(getColor(2));
|
||||
}
|
||||
|
||||
// WORKAROUND: After loading, mark log as changed so the
|
||||
// current NPC portrait to display gets recalculated
|
||||
_logChanged = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetConversations::draw(CScreenManager *screenManager) {
|
||||
_dialBackground.draw(screenManager);
|
||||
_splitter.draw(screenManager);
|
||||
_dials[0].draw(screenManager);
|
||||
_dials[1].draw(screenManager);
|
||||
_dials[2].draw(screenManager);
|
||||
|
||||
_indent.draw(screenManager);
|
||||
_doorBot.draw(screenManager);
|
||||
_bellBot.draw(screenManager);
|
||||
_scrollUp.draw(screenManager);
|
||||
_scrollDown.draw(screenManager);
|
||||
_log.draw(screenManager);
|
||||
_textInput.draw(screenManager);
|
||||
|
||||
if (_logChanged) {
|
||||
int endIndex = _log.displayEndIndex();
|
||||
if (endIndex >= 0) {
|
||||
int npcNum = _log.getNPCNum(1, endIndex);
|
||||
if (npcNum > 0 && npcNum < 10)
|
||||
_npcNum = npcNum - 1;
|
||||
}
|
||||
|
||||
_logChanged = false;
|
||||
}
|
||||
|
||||
if (_npcNum >= 0)
|
||||
_npcIcons[_npcNum].draw(screenManager);
|
||||
}
|
||||
|
||||
Rect CPetConversations::getBounds() const {
|
||||
Rect rect = _dials[0].getBounds();
|
||||
rect.combine(_dials[1].getBounds());
|
||||
rect.combine(_dials[2].getBounds());
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
bool CPetConversations::isValid(CPetControl *petControl) {
|
||||
return setupControl(petControl);
|
||||
}
|
||||
|
||||
bool CPetConversations::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
if (_scrollDown.MouseButtonDownMsg(msg->_mousePos)) {
|
||||
scrollDown();
|
||||
return true;
|
||||
} else if (_scrollUp.MouseButtonDownMsg(msg->_mousePos)) {
|
||||
scrollUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
return
|
||||
_doorBot.MouseButtonDownMsg(msg->_mousePos) ||
|
||||
_bellBot.MouseButtonDownMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetConversations::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
||||
if (_scrollUp.MouseButtonUpMsg(msg->_mousePos) ||
|
||||
_scrollDown.MouseButtonUpMsg(msg->_mousePos))
|
||||
return true;
|
||||
|
||||
if (_doorBot.MouseButtonUpMsg(msg->_mousePos)) {
|
||||
switch (canSummonBot("DoorBot")) {
|
||||
case SUMMON_CANT:
|
||||
_log.addLine(g_vm->_strings[CANT_SUMMON_DOORBOT], getColor(1));
|
||||
break;
|
||||
case SUMMON_CAN:
|
||||
summonBot("DoorBot");
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Scroll to the bottom of the log
|
||||
scrollToBottom();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_bellBot.MouseButtonUpMsg(msg->_mousePos)) {
|
||||
switch (canSummonBot("BellBot")) {
|
||||
case SUMMON_CANT:
|
||||
_log.addLine(g_vm->_strings[CANT_SUMMON_BELLBOT], getColor(1));
|
||||
break;
|
||||
case SUMMON_CAN:
|
||||
summonBot("BellBot");
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Scroll to the bottom of the log
|
||||
scrollToBottom();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetConversations::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
|
||||
return _scrollDown.MouseDoubleClickMsg(msg->_mousePos)
|
||||
|| _scrollUp.MouseDoubleClickMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetConversations::MouseWheelMsg(CMouseWheelMsg *msg) {
|
||||
if (msg->_wheelUp)
|
||||
scrollUp();
|
||||
else
|
||||
scrollDown();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetConversations::KeyCharMsg(CKeyCharMsg *msg) {
|
||||
Common::KeyState keyState;
|
||||
keyState.ascii = msg->_key;
|
||||
return handleKey(keyState);
|
||||
}
|
||||
|
||||
bool CPetConversations::ActionMsg(CActionMsg *msg) {
|
||||
Common::CustomEventType action;
|
||||
action = msg->_action;
|
||||
|
||||
switch (action) {
|
||||
case kActionPETScrollPageUp:
|
||||
scrollUpPage();
|
||||
return true;
|
||||
case kActionPETScrollPageDown:
|
||||
scrollDownPage();
|
||||
return true;
|
||||
case kActionPETScrollTop:
|
||||
scrollToTop();
|
||||
return true;
|
||||
case kActionPeTScrollBottom:
|
||||
scrollToBottom();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetConversations::displayMessage(const CString &msg) {
|
||||
_log.addLine(msg, getColor(1));
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
void CPetConversations::load(SimpleFile *file, int param) {
|
||||
_textInput.load(file, param);
|
||||
_log.load(file, param);
|
||||
|
||||
for (int idx = 0; idx < TOTAL_DIALS; ++idx)
|
||||
_npcLevels[idx] = file->readNumber();
|
||||
}
|
||||
|
||||
void CPetConversations::postLoad() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void CPetConversations::save(SimpleFile *file, int indent) {
|
||||
_textInput.save(file, indent);
|
||||
_log.save(file, indent);
|
||||
|
||||
for (int idx = 0; idx < TOTAL_DIALS; ++idx)
|
||||
file->writeNumberLine(_npcLevels[idx], indent);
|
||||
}
|
||||
|
||||
void CPetConversations::enter(PetArea oldArea) {
|
||||
resetDials();
|
||||
|
||||
if (_petControl && _petControl->_activeNPC)
|
||||
// Start a timer for the NPC
|
||||
startNPCTimer();
|
||||
|
||||
// Show the text cursor
|
||||
_textInput.showCursor(-2);
|
||||
}
|
||||
|
||||
void CPetConversations::leave() {
|
||||
_textInput.hideCursor();
|
||||
stopNPCTimer();
|
||||
}
|
||||
|
||||
void CPetConversations::timerExpired(int val) {
|
||||
if (val != 1) {
|
||||
CPetSection::timerExpired(val);
|
||||
} else {
|
||||
CString name = _field418 ? _npcName : getActiveNPCName();
|
||||
|
||||
for (int idx = 0; idx < TOTAL_DIALS; ++idx) {
|
||||
if (!_dials[idx].hasActiveMovie())
|
||||
updateDial(idx, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPetConversations::displayNPCName(CGameObject *npc) {
|
||||
const Strings &strings = g_vm->_strings;
|
||||
|
||||
if (npc) {
|
||||
displayMessage(CString());
|
||||
CString msg = strings[TALKING_TO];
|
||||
CString name = npc->getName();
|
||||
int id = 1;
|
||||
|
||||
if (name.containsIgnoreCase("Doorbot")) {
|
||||
msg += strings[DOORBOT_NAME];
|
||||
} else if (name.containsIgnoreCase("Deskbot")) {
|
||||
id = 2;
|
||||
msg += strings[DESKBOT_NAME];
|
||||
} else if (name.containsIgnoreCase("LiftBot")) {
|
||||
id = 3;
|
||||
msg += strings[LIFTBOT_NAME];
|
||||
} else if (name.containsIgnoreCase("Parrot")) {
|
||||
id = 4;
|
||||
msg += strings[PARROT_NAME];
|
||||
} else if (name.containsIgnoreCase("BarBot")) {
|
||||
id = 5;
|
||||
msg += strings[BARBOT_NAME];
|
||||
} else if (name.containsIgnoreCase("ChatterBot")) {
|
||||
id = 6;
|
||||
msg += strings[CHATTERBOT_NAME];
|
||||
} else if (name.containsIgnoreCase("BellBot")) {
|
||||
id = 7;
|
||||
msg += strings[BELLBOT_NAME];
|
||||
} else if (name.containsIgnoreCase("Maitre")) {
|
||||
id = 8;
|
||||
msg += strings[MAITRED_NAME];
|
||||
} else if (name.containsIgnoreCase("Succubus") || name.containsIgnoreCase("Sub")) {
|
||||
id = 9;
|
||||
msg += strings[SUCCUBUS_NAME];
|
||||
} else {
|
||||
msg += strings[UNKNOWN_NAME];
|
||||
}
|
||||
|
||||
_log.setNPC(1, id);
|
||||
displayMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetConversations::setNPC(const CString &name) {
|
||||
_field418 = 0;
|
||||
resetDials(name);
|
||||
startNPCTimer();
|
||||
}
|
||||
|
||||
void CPetConversations::resetNPC() {
|
||||
stopNPCTimer();
|
||||
resetDials("0");
|
||||
}
|
||||
|
||||
void CPetConversations::showCursor() {
|
||||
_textInput.showCursor(-2);
|
||||
}
|
||||
|
||||
void CPetConversations::hideCursor() {
|
||||
_textInput.hideCursor();
|
||||
}
|
||||
|
||||
bool CPetConversations::setupControl(CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
_petControl = petControl;
|
||||
|
||||
_dialBackground.setBounds(Rect(0, 0, 21, 130));
|
||||
_dialBackground.translate(20, 350);
|
||||
|
||||
const Rect rect1(0, 0, 22, 36);
|
||||
_dials[0].setBounds(rect1);
|
||||
_dials[0].translate(20, 359);
|
||||
_dials[1].setBounds(rect1);
|
||||
_dials[1].translate(20, 397);
|
||||
_dials[2].setBounds(rect1);
|
||||
_dials[2].translate(20, 434);
|
||||
|
||||
const Rect rect2(0, 0, 11, 24);
|
||||
_scrollUp.setBounds(rect2);
|
||||
_scrollUp.translate(87, 374);
|
||||
_scrollDown.setBounds(rect2);
|
||||
_scrollDown.translate(87, 421);
|
||||
|
||||
const Rect rect3(0, 0, 39, 39);
|
||||
_doorBot.setBounds(rect3);
|
||||
_doorBot.translate(546, 372);
|
||||
_bellBot.setBounds(rect3);
|
||||
_bellBot.translate(546, 418);
|
||||
|
||||
_indent.setBounds(Rect(0, 0, 37, 70));
|
||||
_indent.translate(46, 374);
|
||||
_splitter.setBounds(Rect(0, 0, 435, 3));
|
||||
_splitter.translate(102, 441);
|
||||
|
||||
const Rect rect4(0, 0, 33, 66);
|
||||
for (int idx = 0; idx < 9; ++idx) {
|
||||
_npcIcons[idx].setBounds(rect4);
|
||||
_npcIcons[idx].translate(48, 376);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetConversations::scrollUp() {
|
||||
_log.scrollUp(CScreenManager::_screenManagerPtr);
|
||||
if (_petControl)
|
||||
_petControl->makeDirty();
|
||||
_logChanged = true;
|
||||
}
|
||||
|
||||
void CPetConversations::scrollDown() {
|
||||
_log.scrollDown(CScreenManager::_screenManagerPtr);
|
||||
if (_petControl)
|
||||
_petControl->makeDirty();
|
||||
_logChanged = true;
|
||||
}
|
||||
|
||||
void CPetConversations::scrollUpPage() {
|
||||
_log.scrollUpPage(CScreenManager::_screenManagerPtr);
|
||||
if (_petControl)
|
||||
_petControl->makeDirty();
|
||||
_logChanged = true;
|
||||
}
|
||||
|
||||
void CPetConversations::scrollDownPage() {
|
||||
_log.scrollDownPage(CScreenManager::_screenManagerPtr);
|
||||
if (_petControl)
|
||||
_petControl->makeDirty();
|
||||
_logChanged = true;
|
||||
}
|
||||
|
||||
void CPetConversations::scrollToTop() {
|
||||
_log.scrollToTop(CScreenManager::_screenManagerPtr);
|
||||
if (_petControl)
|
||||
_petControl->makeDirty();
|
||||
_logChanged = true;
|
||||
}
|
||||
|
||||
void CPetConversations::scrollToBottom() {
|
||||
_log.scrollToBottom(CScreenManager::_screenManagerPtr);
|
||||
if (_petControl)
|
||||
_petControl->makeDirty();
|
||||
_logChanged = true;
|
||||
}
|
||||
|
||||
int CPetConversations::canSummonBot(const CString &name) {
|
||||
return _petControl ? _petControl->canSummonBot(name) : SUMMON_CANT;
|
||||
}
|
||||
|
||||
void CPetConversations::summonBot(const CString &name) {
|
||||
if (_petControl) {
|
||||
if (_petControl->getPassengerClass() >= UNCHECKED) {
|
||||
_petControl->displayMessage(AT_LEAST_3RD_CLASS_FOR_HELP);
|
||||
} else {
|
||||
_petControl->summonBot(name, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPetConversations::startNPCTimer() {
|
||||
_petControl->startPetTimer(1, 1000, 1000, this);
|
||||
}
|
||||
|
||||
void CPetConversations::stopNPCTimer() {
|
||||
_petControl->stopPetTimer(1);
|
||||
}
|
||||
|
||||
TTnpcScript *CPetConversations::getNPCScript(const CString &name) const {
|
||||
if (name.empty() || !_petControl)
|
||||
return nullptr;
|
||||
CGameManager *gameManager = _petControl->getGameManager();
|
||||
if (!gameManager)
|
||||
return nullptr;
|
||||
CTrueTalkManager *trueTalk = gameManager->getTalkManager();
|
||||
if (!trueTalk)
|
||||
return nullptr;
|
||||
|
||||
return trueTalk->getTalker(name);
|
||||
}
|
||||
|
||||
bool CPetConversations::handleKey(const Common::KeyState &keyState) {
|
||||
if (keyState.ascii > 0 && keyState.ascii <= 127
|
||||
&& keyState.ascii != Common::KEYCODE_TAB) {
|
||||
if (_textInput.handleKey(keyState.ascii))
|
||||
// Text line finished, so process line
|
||||
textLineEntered(_textInput.getText());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetConversations::textLineEntered(const CString &textLine) {
|
||||
if (textLine.empty() || !_petControl)
|
||||
return;
|
||||
|
||||
if (_petControl->_activeNPC) {
|
||||
_log.addLine("- " + textLine, getColor(0));
|
||||
|
||||
CTextInputMsg inputMsg(textLine, "");
|
||||
inputMsg.execute(_petControl->_activeNPC);
|
||||
|
||||
if (!inputMsg._response.empty())
|
||||
_log.addLine(inputMsg._response);
|
||||
} else {
|
||||
_log.addLine(g_vm->_strings[NO_ONE_TO_TALK_TO], getColor(1));
|
||||
}
|
||||
|
||||
// Clear input line and scroll log down to end to show response
|
||||
_textInput.setup();
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
void CPetConversations::setActiveNPC(const CString &name) {
|
||||
_npcName = name;
|
||||
_field418 = 1;
|
||||
resetDials();
|
||||
startNPCTimer();
|
||||
}
|
||||
|
||||
void CPetConversations::updateDial(uint dialNum, const CString &npcName) {
|
||||
TTnpcScript *script = getNPCScript(npcName);
|
||||
uint newLevel = getDialLevel(dialNum, script);
|
||||
npcDialChange(dialNum, _npcLevels[dialNum], newLevel);
|
||||
_npcLevels[dialNum] = newLevel;
|
||||
}
|
||||
|
||||
uint CPetConversations::getDialLevel(uint dialNum, TTnpcScript *script, bool flag) {
|
||||
if (!script)
|
||||
return 0;
|
||||
else
|
||||
return MAX(script->getDialLevel(dialNum, flag), 15);
|
||||
}
|
||||
|
||||
void CPetConversations::npcDialChange(uint dialNum, uint oldLevel, uint newLevel) {
|
||||
const uint ascending[2] = { 0, 21 };
|
||||
const uint descending[2] = { 43, 22 };
|
||||
assert(oldLevel <= 100 && newLevel <= 100);
|
||||
|
||||
if (newLevel != oldLevel) {
|
||||
debugC(DEBUG_DETAILED, kDebugScripts, "Dial %d change from %d to %d",
|
||||
dialNum, oldLevel, newLevel);
|
||||
uint src = ascending[0], dest = ascending[1];
|
||||
if (newLevel < oldLevel) {
|
||||
src = descending[0];
|
||||
dest = descending[1];
|
||||
}
|
||||
|
||||
uint val1 = (oldLevel * dest) + (100 - oldLevel) * src;
|
||||
uint startFrame = val1 / 100;
|
||||
|
||||
uint val2 = (newLevel * dest) + (100 - newLevel) * src;
|
||||
uint endFrame = val2 / 100;
|
||||
|
||||
if (startFrame != endFrame)
|
||||
_dials[dialNum].playMovie(startFrame, endFrame);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetConversations::resetDials() {
|
||||
resetDials(getActiveNPCName());
|
||||
}
|
||||
|
||||
void CPetConversations::resetDials(const CString &name) {
|
||||
TTnpcScript *script = getNPCScript(name);
|
||||
|
||||
for (int idx = 0; idx < TOTAL_DIALS; ++idx) {
|
||||
uint oldLevel = _npcLevels[idx];
|
||||
uint newLevel = getDialLevel(idx, script);
|
||||
npcDialChange(idx, oldLevel, newLevel);
|
||||
_npcLevels[idx] = newLevel;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetConversations::resetDials0() {
|
||||
stopNPCTimer();
|
||||
resetDials("0");
|
||||
}
|
||||
|
||||
void CPetConversations::addLine(const CString &line) {
|
||||
_log.addLine(line);
|
||||
scrollToBottom();
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
267
engines/titanic/pet_control/pet_conversations.h
Normal file
267
engines/titanic/pet_control/pet_conversations.h
Normal file
@@ -0,0 +1,267 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_CONVERSATIONS_H
|
||||
#define TITANIC_PET_CONVERSATIONS_H
|
||||
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
#include "titanic/pet_control/pet_gfx_element.h"
|
||||
#include "titanic/true_talk/true_talk_manager.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
#define TOTAL_DIALS 3
|
||||
|
||||
class CPetConversations : public CPetSection {
|
||||
private:
|
||||
CPetGfxElement _scrollUp;
|
||||
CPetGfxElement _scrollDown;
|
||||
CPetGfxElement _dialBackground;
|
||||
CPetGfxElement _dials[TOTAL_DIALS];
|
||||
uint _npcLevels[TOTAL_DIALS];
|
||||
CPetGfxElement _val4;
|
||||
CPetGfxElement _val5;
|
||||
CPetGfxElement _indent;
|
||||
Rect _rect1;
|
||||
CPetGfxElement _doorBot;
|
||||
CPetGfxElement _bellBot;
|
||||
CPetGfxElement _splitter;
|
||||
CPetGfxElement _npcIcons[9];
|
||||
int _npcNum;
|
||||
CTextControl _log;
|
||||
CTextControl _textInput;
|
||||
bool _logChanged;
|
||||
int _field418;
|
||||
CString _npcName;
|
||||
private:
|
||||
/**
|
||||
* Sets up the control
|
||||
*/
|
||||
bool setupControl(CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Scroll up the conversation log
|
||||
*/
|
||||
void scrollUp();
|
||||
|
||||
/**
|
||||
* Scroll down the conversation log
|
||||
*/
|
||||
void scrollDown();
|
||||
|
||||
/**
|
||||
* Scroll up one page in the conversation log
|
||||
*/
|
||||
void scrollUpPage();
|
||||
|
||||
/**
|
||||
* Scroll down one page in the conversation log
|
||||
*/
|
||||
void scrollDownPage();
|
||||
|
||||
/**
|
||||
* Scroll to the top of the conversation log
|
||||
*/
|
||||
void scrollToTop();
|
||||
|
||||
/**
|
||||
* Scroll to the bottom of the conversation log
|
||||
*/
|
||||
void scrollToBottom();
|
||||
|
||||
/**
|
||||
* Check whether an NPC can be summoned
|
||||
*/
|
||||
int canSummonBot(const CString &name);
|
||||
|
||||
/**
|
||||
* Summon an NPC
|
||||
*/
|
||||
void summonBot(const CString &name);
|
||||
|
||||
/**
|
||||
* Get the TrueTalk script associated with a given NPC
|
||||
*/
|
||||
TTnpcScript *getNPCScript(const CString &name) const;
|
||||
|
||||
/**
|
||||
* Handle a keypress
|
||||
*/
|
||||
bool handleKey(const Common::KeyState &keyState);
|
||||
|
||||
/**
|
||||
* Handles an entered text line
|
||||
*/
|
||||
void textLineEntered(const CString &textLine);
|
||||
|
||||
/**
|
||||
* Updates one of the dials with data from a given NPC
|
||||
*/
|
||||
void updateDial(uint dialNum, const CString &npcName);
|
||||
|
||||
/**
|
||||
* Get a dial level
|
||||
*/
|
||||
uint getDialLevel(uint dialNum, TTnpcScript *script, bool flag = true);
|
||||
|
||||
/**
|
||||
* Called when the dial for an NPC is being changed
|
||||
*/
|
||||
void npcDialChange(uint dialNum, uint oldLevel, uint newLevel);
|
||||
public:
|
||||
CPetConversations();
|
||||
~CPetConversations() override {}
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Reset the section
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Get the bounds for the section
|
||||
*/
|
||||
Rect getBounds() const override;
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override;
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override;
|
||||
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) override;
|
||||
bool MouseWheelMsg(CMouseWheelMsg *msg) override;
|
||||
bool KeyCharMsg(CKeyCharMsg *msg) override;
|
||||
bool ActionMsg(CActionMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Display a message
|
||||
*/
|
||||
void displayMessage(const CString &msg) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file, int param) override;
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override;
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Called when a section is switched to
|
||||
*/
|
||||
void enter(PetArea oldArea) override;
|
||||
|
||||
/**
|
||||
* Called when a section is being left, to switch to another area
|
||||
*/
|
||||
void leave() override;
|
||||
|
||||
/**
|
||||
* Called when a previously set up PET timer expires
|
||||
*/
|
||||
void timerExpired(int val) override;
|
||||
|
||||
/**
|
||||
* Display a title for an NPC
|
||||
*/
|
||||
void displayNPCName(CGameObject *npc) override;
|
||||
|
||||
/**
|
||||
* Sets the NPC to use
|
||||
*/
|
||||
void setNPC(const CString &name) override;
|
||||
|
||||
/**
|
||||
* Resets the active NPC
|
||||
*/
|
||||
void resetNPC() override;
|
||||
|
||||
/**
|
||||
* Show the text cursor
|
||||
*/
|
||||
void showCursor() override;
|
||||
|
||||
/**
|
||||
* Hide the text cursor
|
||||
*/
|
||||
void hideCursor() override;
|
||||
|
||||
/**
|
||||
* Set the active NPC
|
||||
*/
|
||||
void setActiveNPC(const CString &name);
|
||||
|
||||
/**
|
||||
* Resets the dials with the data for the currently active NPC
|
||||
*/
|
||||
void resetDials();
|
||||
|
||||
/**
|
||||
* Reset the dials with those for a given NPC
|
||||
*/
|
||||
void resetDials(const CString &name);
|
||||
|
||||
/**
|
||||
* Reset the dials to the '0' position
|
||||
*/
|
||||
void resetDials0();
|
||||
|
||||
/**
|
||||
* Adds a line to the log
|
||||
*/
|
||||
void addLine(const CString &line);
|
||||
|
||||
/**
|
||||
* Starts the NPC timer
|
||||
*/
|
||||
void startNPCTimer();
|
||||
|
||||
/**
|
||||
* Stops the NPC timer
|
||||
*/
|
||||
void stopNPCTimer();
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_CONVERSATIONS_H */
|
||||
72
engines/titanic/pet_control/pet_drag_chev.cpp
Normal file
72
engines/titanic/pet_control/pet_drag_chev.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_drag_chev.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/messages/messages.h"
|
||||
#include "titanic/npcs/succubus.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPetDragChev, CPetGraphic2)
|
||||
ON_MESSAGE(MouseDragStartMsg)
|
||||
ON_MESSAGE(MouseDragMoveMsg)
|
||||
ON_MESSAGE(MouseDragEndMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CPetDragChev::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CPetGraphic2::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetDragChev::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CPetGraphic2::load(file);
|
||||
}
|
||||
|
||||
bool CPetDragChev::MouseDragStartMsg(CMouseDragStartMsg *msg) {
|
||||
getName();
|
||||
return checkStartDragging(msg);
|
||||
}
|
||||
|
||||
bool CPetDragChev::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
|
||||
dragMove(msg->_mousePos);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) {
|
||||
CSuccUBus *succubus = dynamic_cast<CSuccUBus *>(msg->_dropTarget);
|
||||
|
||||
if (succubus) {
|
||||
CSetChevRoomBits chevMsg(_destRoomFlags);
|
||||
chevMsg.execute(succubus);
|
||||
petMoveToHiddenRoom();
|
||||
} else {
|
||||
CPetControl *petControl = getPetControl();
|
||||
if (!petControl || !petControl->contains(msg->_mousePos)
|
||||
|| msg->_mousePos.x >= 528 || !petControl->checkDragEnd(this))
|
||||
petMoveToHiddenRoom();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
51
engines/titanic/pet_control/pet_drag_chev.h
Normal file
51
engines/titanic/pet_control/pet_drag_chev.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_DRAG_CHEV_H
|
||||
#define TITANIC_PET_DRAG_CHEV_H
|
||||
|
||||
#include "titanic/pet_control/pet_graphic2.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetDragChev : public CPetGraphic2 {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
protected:
|
||||
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
|
||||
bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
|
||||
bool MouseDragEndMsg(CMouseDragEndMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_DRAG_CHEV_H */
|
||||
105
engines/titanic/pet_control/pet_element.cpp
Normal file
105
engines/titanic/pet_control/pet_element.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/textconsole.h"
|
||||
#include "titanic/pet_control/pet_element.h"
|
||||
#include "titanic/core/game_object.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetElement::CPetElement() : _mode(MODE_UNSELECTED) {}
|
||||
|
||||
Rect CPetElement::getBounds() const {
|
||||
return Rect();
|
||||
}
|
||||
|
||||
bool CPetElement::MouseButtonDownMsg(const Point &pt) {
|
||||
bool result = _bounds.contains(pt);
|
||||
if (result)
|
||||
setMode(MODE_SELECTED);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetElement::MouseButtonUpMsg(const Point &pt) {
|
||||
bool result = _bounds.contains(pt);
|
||||
if (result)
|
||||
setMode(MODE_UNSELECTED);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetElement::MouseDoubleClickMsg(const Point &pt) const {
|
||||
return _bounds.contains(pt);
|
||||
}
|
||||
|
||||
bool CPetElement::MouseMoveMsg(const Point &pt) {
|
||||
bool result = _bounds.contains(pt);
|
||||
if (result)
|
||||
setMode(MODE_FOCUSED);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetElement::contains2(const Point &pt) const {
|
||||
return _bounds.contains(pt);
|
||||
}
|
||||
|
||||
void CPetElement::playMovie(uint startFrame, uint endFrame) const {
|
||||
CGameObject *gameObject = getObject();
|
||||
|
||||
if (gameObject)
|
||||
gameObject->playMovie(startFrame, endFrame, 0);
|
||||
}
|
||||
|
||||
void CPetElement::changeStatus(int val) const {
|
||||
CGameObject *gameObject = getObject();
|
||||
|
||||
if (gameObject)
|
||||
gameObject->playMovie(val);
|
||||
}
|
||||
|
||||
bool CPetElement::hasActiveMovie() const {
|
||||
CGameObject *gameObject = getObject();
|
||||
return gameObject ? gameObject->hasActiveMovie() : false;
|
||||
}
|
||||
|
||||
void CPetElement::loadFrame(int frameNumber) {
|
||||
CGameObject *gameObject = getObject();
|
||||
if (gameObject)
|
||||
gameObject->loadFrame(frameNumber);
|
||||
}
|
||||
|
||||
int CPetElement::getMovieFrame() const {
|
||||
CGameObject *gameObject = getObject();
|
||||
return gameObject ? gameObject->getMovieFrame() : 0;
|
||||
}
|
||||
|
||||
void CPetElement::setMode(PetElementMode newMode) {
|
||||
if (newMode >= MODE_UNSELECTED && newMode <= MODE_FOCUSED)
|
||||
changeMode(newMode);
|
||||
}
|
||||
|
||||
void CPetElement::setSelected(bool flag) {
|
||||
if (flag)
|
||||
changeMode(MODE_SELECTED);
|
||||
else
|
||||
changeMode(MODE_UNSELECTED);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
153
engines/titanic/pet_control/pet_element.h
Normal file
153
engines/titanic/pet_control/pet_element.h
Normal file
@@ -0,0 +1,153 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_ELEMENT_H
|
||||
#define TITANIC_PET_ELEMENT_H
|
||||
|
||||
#include "titanic/support/simple_file.h"
|
||||
#include "titanic/support/string.h"
|
||||
#include "titanic/core/link_item.h"
|
||||
#include "titanic/messages/mouse_messages.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
enum PetElementMode { MODE_UNSELECTED = 0, MODE_SELECTED = 1, MODE_FOCUSED = 2 };
|
||||
|
||||
class CGameObject;
|
||||
class CPetControl;
|
||||
|
||||
class CPetElement {
|
||||
protected:
|
||||
Rect _bounds;
|
||||
PetElementMode _mode;
|
||||
public:
|
||||
CPetElement();
|
||||
virtual ~CPetElement() {}
|
||||
|
||||
/**
|
||||
* Sets up the element
|
||||
*/
|
||||
virtual void setup(PetElementMode mode, const CString &name,
|
||||
CPetControl *petControl) {}
|
||||
|
||||
/**
|
||||
* Reset the element
|
||||
*/
|
||||
virtual void reset(const CString &name, CPetControl *petControl, PetElementMode mode) {}
|
||||
|
||||
/**
|
||||
* Draw the item
|
||||
*/
|
||||
virtual void draw(CScreenManager *screenManager) {}
|
||||
|
||||
/**
|
||||
* Draw the item
|
||||
*/
|
||||
virtual void draw(CScreenManager *screenManager, const Point &destPos) {}
|
||||
|
||||
/**
|
||||
* Get the bounds for the element
|
||||
*/
|
||||
virtual Rect getBounds() const;
|
||||
|
||||
/**
|
||||
* Handles processing mouse button down messages
|
||||
*/
|
||||
virtual bool MouseButtonDownMsg(const Point &pt);
|
||||
|
||||
/**
|
||||
* Handles processing mouse button up messages
|
||||
*/
|
||||
virtual bool MouseButtonUpMsg(const Point &pt);
|
||||
|
||||
/**
|
||||
* Handles processing mouse button double click messages
|
||||
*/
|
||||
virtual bool MouseDoubleClickMsg(const Point &pt) const;
|
||||
|
||||
/**
|
||||
* Handles processing mouse move messages
|
||||
*/
|
||||
virtual bool MouseMoveMsg(const Point &pt);
|
||||
|
||||
/**
|
||||
* Returns whether the passed point falls inside the item
|
||||
*/
|
||||
virtual bool contains2(const Point &pt) const;
|
||||
|
||||
/**
|
||||
* Plays back a range of frames in the loaded video file for the element
|
||||
*/
|
||||
virtual void playMovie(uint startFrame, uint endFrame) const;
|
||||
|
||||
/**
|
||||
* Change the status of the associated object
|
||||
*/
|
||||
virtual void changeStatus(int newStatus) const;
|
||||
|
||||
/**
|
||||
* Returns true if the object associated with the item has an active movie
|
||||
*/
|
||||
virtual bool hasActiveMovie() const;
|
||||
|
||||
/**
|
||||
* Loads a frame
|
||||
*/
|
||||
virtual void loadFrame(int frameNumber);
|
||||
|
||||
/**
|
||||
* Get the current frame
|
||||
*/
|
||||
virtual int getMovieFrame() const;
|
||||
|
||||
/**
|
||||
* Get the game object associated with this item
|
||||
*/
|
||||
virtual CGameObject *getObject() const { return nullptr; }
|
||||
|
||||
virtual void changeMode(PetElementMode newMode) { _mode = newMode; }
|
||||
|
||||
void setMode(PetElementMode mode);
|
||||
|
||||
/**
|
||||
* Set whether the element is selected
|
||||
*/
|
||||
void setSelected(bool flag);
|
||||
|
||||
/**
|
||||
* Set the bounds for the element
|
||||
*/
|
||||
void setBounds(const Rect &r) { _bounds = r; }
|
||||
|
||||
/**
|
||||
* Translate the position of the element
|
||||
*/
|
||||
void translate(int deltaX, int deltaY) { _bounds.translate(deltaX, deltaY); }
|
||||
|
||||
/**
|
||||
* Translate the position of the element
|
||||
*/
|
||||
void translate(const Point &delta) { _bounds.translate(delta.x, delta.y); }
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_ELEMENT_H */
|
||||
180
engines/titanic/pet_control/pet_frame.cpp
Normal file
180
engines/titanic/pet_control/pet_frame.cpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_frame.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/translation.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
static const PetArea PET_AREAS_EN[5] = {
|
||||
PET_CONVERSATION, PET_INVENTORY, PET_REMOTE,
|
||||
PET_ROOMS, PET_REAL_LIFE
|
||||
};
|
||||
|
||||
static const PetArea PET_AREAS_DE[6] = {
|
||||
PET_CONVERSATION, PET_TRANSLATION, PET_INVENTORY, PET_REMOTE,
|
||||
PET_ROOMS, PET_REAL_LIFE
|
||||
};
|
||||
|
||||
|
||||
CPetFrame::CPetFrame() : CPetSection() {
|
||||
}
|
||||
|
||||
bool CPetFrame::setup(CPetControl *petControl) {
|
||||
if (setPetControl(petControl))
|
||||
return reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetFrame::reset() {
|
||||
if (_petControl) {
|
||||
_background.reset("PetBackground", _petControl, MODE_UNSELECTED);
|
||||
_modeBackground.reset("PetModeBackground", _petControl, MODE_UNSELECTED);
|
||||
|
||||
for (uint idx = 0; idx < _petAreas.size(); ++idx) {
|
||||
CString resName = Common::String::format("PetMode%d", idx + 1);
|
||||
_modeButtons[idx].reset(resName, _petControl, MODE_SELECTED);
|
||||
}
|
||||
|
||||
for (uint idx = 0; idx < ARRAYSIZE(_titles); ++idx) {
|
||||
CString resName = Common::String::format("3Pettitle%d", idx + 1);
|
||||
_titles[idx].setup(MODE_UNSELECTED, resName, _petControl);
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < TOTAL_GLYPHS; ++idx) {
|
||||
CString resName = Common::String::format("PetIndent%d", idx + 1);
|
||||
_squares[idx].reset(resName, _petControl, MODE_UNSELECTED);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetFrame::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
for (uint idx = 0; idx < _petAreas.size(); ++idx) {
|
||||
if (_modeButtons[idx].MouseButtonUpMsg(msg->_mousePos)) {
|
||||
_petControl->setArea(_petAreas[idx]);
|
||||
resetArea();
|
||||
_modeButtons[idx].setMode(MODE_SELECTED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetFrame::isValid(CPetControl *petControl) {
|
||||
bool result = setPetControl(petControl);
|
||||
if (result) {
|
||||
_modeButtons[PET_CONVERSATION].setMode(MODE_UNSELECTED);
|
||||
_modeButtons[PET_REAL_LIFE].setMode(MODE_SELECTED);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CPetFrame::postLoad() {
|
||||
reset();
|
||||
}
|
||||
|
||||
bool CPetFrame::setPetControl(CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
_petControl = petControl;
|
||||
|
||||
// Set up the PET areas we'll have buttons for
|
||||
_petAreas.clear();
|
||||
if (g_language == Common::EN_ANY)
|
||||
_petAreas.assign(&PET_AREAS_EN[0], &PET_AREAS_EN[0] + 5);
|
||||
else
|
||||
_petAreas.assign(&PET_AREAS_DE[0], &PET_AREAS_DE[0] + 6);
|
||||
|
||||
// Set the bounds of the individual elements
|
||||
_background.setBounds(Rect(20, 350, 620, 480));
|
||||
_modeBackground.setBounds(Rect(590, 365, 611, 467));
|
||||
|
||||
// Squares used for holding glyphs in various tabs
|
||||
Rect r(35, 373, 91, 429);
|
||||
for (int idx = 0, xp = 0; idx < TOTAL_GLYPHS; ++idx, xp += 70) {
|
||||
_squares[idx].setBounds(r);
|
||||
_squares[idx].translate(xp, 0);
|
||||
}
|
||||
|
||||
// Draw the mode buttons vertically on the right edge of the PET
|
||||
r = Rect(590, 365, 606, 381);
|
||||
const int YLIST_EN[] = { 7, 27, 45, 66, 84 };
|
||||
const int YLIST_DE[] = { 0, 18, 36, 51, 67, 84 };
|
||||
_modeButtons.resize(_petAreas.size());
|
||||
for (uint idx = 0; idx < _modeButtons.size(); ++idx) {
|
||||
_modeButtons[idx].setBounds(r);
|
||||
_modeButtons[idx].translate(TRANSLATE(4, 0),
|
||||
TRANSLATE(YLIST_EN[idx], YLIST_DE[idx]));
|
||||
}
|
||||
setArea(PET_CONVERSATION);
|
||||
|
||||
if (g_language == Common::EN_ANY) {
|
||||
const int XLIST_EN[] = { 73, 54, 85, 109, 38, 71 };
|
||||
for (uint idx = 0; idx < _petAreas.size(); ++idx) {
|
||||
_titles[idx].setBounds(Rect(0, 0, 110, 11));
|
||||
_titles[idx].translate(608 - XLIST_EN[idx], 471);
|
||||
}
|
||||
} else {
|
||||
for (uint idx = 0; idx < 7; ++idx) {
|
||||
_titles[idx].setBounds(Rect(0, 0, 110, 11));
|
||||
_titles[idx].translate(501, 469);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetFrame::setArea(PetArea newArea) {
|
||||
resetArea();
|
||||
|
||||
for (uint idx = 0; idx < _modeButtons.size(); ++idx) {
|
||||
if (_petAreas[idx] == newArea)
|
||||
_modeButtons[idx].setMode(MODE_SELECTED);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetFrame::resetArea() {
|
||||
for (uint idx = 0; idx < _modeButtons.size(); ++idx)
|
||||
_modeButtons[idx].setMode(MODE_UNSELECTED);
|
||||
}
|
||||
|
||||
void CPetFrame::drawFrame(CScreenManager *screenManager) {
|
||||
_background.draw(screenManager);
|
||||
_modeBackground.draw(screenManager);
|
||||
|
||||
for (uint idx = 0; idx < _modeButtons.size(); ++idx)
|
||||
_modeButtons[idx].draw(screenManager);
|
||||
|
||||
_titles[_petControl->_currentArea].draw(screenManager);
|
||||
}
|
||||
|
||||
void CPetFrame::drawSquares(CScreenManager *screenManager, int count) {
|
||||
count = CLIP(count, 0, TOTAL_GLYPHS);
|
||||
for (int idx = 0; idx < count; ++idx)
|
||||
_squares[idx].draw(screenManager);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
101
engines/titanic/pet_control/pet_frame.h
Normal file
101
engines/titanic/pet_control/pet_frame.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_FRAME_H
|
||||
#define TITANIC_PET_FRAME_H
|
||||
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/pet_control/pet_gfx_element.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
/**
|
||||
* This implements the frame and background for the PET display.
|
||||
* This includes the area buttons and title
|
||||
*/
|
||||
class CPetFrame : public CPetSection {
|
||||
private:
|
||||
Common::Array<PetArea> _petAreas;
|
||||
Common::Array<CPetGfxElement> _modeButtons;
|
||||
CPetGfxElement _titles[7];
|
||||
CPetGfxElement _modeBackground;
|
||||
CPetGfxElement _val2;
|
||||
CPetGfxElement _val3;
|
||||
CPetGfxElement _background;
|
||||
CPetGfxElement _squares[7];
|
||||
private:
|
||||
/**
|
||||
* Called to set the owning PET instance and set some initial state
|
||||
*/
|
||||
bool setPetControl(CPetControl *petControl);
|
||||
public:
|
||||
CPetFrame();
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Handles mouse down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override;
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override { return false; }
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override;
|
||||
|
||||
/**
|
||||
* Called when the current PET area changes
|
||||
*/
|
||||
void setArea(PetArea newArea);
|
||||
|
||||
/**
|
||||
* Reset the currently selected area
|
||||
*/
|
||||
void resetArea();
|
||||
|
||||
/**
|
||||
* Draws the PET frame
|
||||
*/
|
||||
void drawFrame(CScreenManager *screenManager);
|
||||
|
||||
/**
|
||||
* Draws the indent
|
||||
*/
|
||||
void drawSquares(CScreenManager *screenManager, int count);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_FRAME_H */
|
||||
102
engines/titanic/pet_control/pet_gfx_element.cpp
Normal file
102
engines/titanic/pet_control/pet_gfx_element.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/textconsole.h"
|
||||
#include "titanic/core/game_object.h"
|
||||
#include "titanic/pet_control/pet_element.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
void CPetGfxElement::setup(PetElementMode mode, const CString &name,
|
||||
CPetControl *petControl) {
|
||||
switch (mode) {
|
||||
case MODE_UNSELECTED:
|
||||
_object0 = petControl->getHiddenObject(name);
|
||||
break;
|
||||
case MODE_SELECTED:
|
||||
_object1 = petControl->getHiddenObject(name);
|
||||
break;
|
||||
case MODE_FOCUSED:
|
||||
_object2 = petControl->getHiddenObject(name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGfxElement::reset(const CString &name, CPetControl *petControl, PetElementMode mode) {
|
||||
if (!petControl)
|
||||
return;
|
||||
|
||||
CString numString(3);
|
||||
PassengerClass classNum = petControl->getPassengerClass();
|
||||
|
||||
if (classNum >= FIRST_CLASS && classNum <= THIRD_CLASS) {
|
||||
numString = CString(classNum);
|
||||
} else if (classNum == UNCHECKED) {
|
||||
int priorClass = petControl->getPriorClass();
|
||||
if (priorClass == 1)
|
||||
numString = CString(priorClass);
|
||||
}
|
||||
|
||||
CString resName = numString + name;
|
||||
setup(mode, resName, petControl);
|
||||
}
|
||||
|
||||
void CPetGfxElement::draw(CScreenManager *screenManager) {
|
||||
draw(screenManager, Common::Point(_bounds.left, _bounds.top));
|
||||
}
|
||||
|
||||
void CPetGfxElement::draw(CScreenManager *screenManager, const Common::Point &destPos) {
|
||||
CGameObject *obj = getObject();
|
||||
if (!obj)
|
||||
obj = _object0;
|
||||
|
||||
if (obj)
|
||||
obj->draw(screenManager, destPos);
|
||||
}
|
||||
|
||||
Rect CPetGfxElement::getBounds() const {
|
||||
CGameObject *obj = getObject();
|
||||
if (!obj)
|
||||
obj = _object0;
|
||||
|
||||
if (obj && obj->surfaceHasFrame())
|
||||
return _bounds;
|
||||
else
|
||||
return Rect();
|
||||
}
|
||||
|
||||
CGameObject *CPetGfxElement::getObject() const {
|
||||
switch (_mode) {
|
||||
case MODE_UNSELECTED:
|
||||
return _object0;
|
||||
case MODE_SELECTED:
|
||||
return _object1;
|
||||
case MODE_FOCUSED:
|
||||
return _object2;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
79
engines/titanic/pet_control/pet_gfx_element.h
Normal file
79
engines/titanic/pet_control/pet_gfx_element.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_GFX_ELEMENT_H
|
||||
#define TITANIC_PET_GFX_ELEMENT_H
|
||||
|
||||
#include "titanic/pet_control/pet_element.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetGfxElement: public CPetElement {
|
||||
public:
|
||||
CGameObject *_object0;
|
||||
CGameObject *_object1;
|
||||
CGameObject *_object2;
|
||||
public:
|
||||
CPetGfxElement() : CPetElement(), _object0(nullptr), _object1(nullptr),
|
||||
_object2(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the element
|
||||
*/
|
||||
void setup(PetElementMode mode, const CString &name,
|
||||
CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Reset the element
|
||||
*/
|
||||
void reset(const CString &name, CPetControl *petControl,
|
||||
PetElementMode mode = MODE_UNSELECTED) override;
|
||||
|
||||
/**
|
||||
* Draw the item
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Draw the item
|
||||
*/
|
||||
void draw(CScreenManager *screenManager, const Common::Point &destPos) override;
|
||||
|
||||
/**
|
||||
* Get the bounds for the element
|
||||
*/
|
||||
Rect getBounds() const override;
|
||||
|
||||
/**
|
||||
* Get the game object associated with this item
|
||||
*/
|
||||
CGameObject *getObject() const override;
|
||||
|
||||
/**
|
||||
* Gets the explicit bounds set for the graphic element,
|
||||
* ignoring any associated sub-object bounds
|
||||
*/
|
||||
const Rect &getRawBounds() const { return _bounds; }
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_GFX_ELEMENT_H */
|
||||
549
engines/titanic/pet_control/pet_glyphs.cpp
Normal file
549
engines/titanic/pet_control/pet_glyphs.cpp
Normal file
@@ -0,0 +1,549 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
bool CPetGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
_element.setBounds(Rect(0, 0, 52, 50));
|
||||
_owner = owner;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) {
|
||||
_element.translate(pt.x, pt.y);
|
||||
_element.draw(screenManager);
|
||||
_element.translate(-pt.x, -pt.y);
|
||||
}
|
||||
|
||||
void CPetGlyph::updateTooltip() {
|
||||
CTextControl *petText = getPetSection()->getText();
|
||||
if (petText) {
|
||||
petText->setColor(getPetSection()->getColor(0));
|
||||
getTooltip(petText);
|
||||
|
||||
if (_owner)
|
||||
getPetSection()->stopTextTimer();
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetGlyph::contains(const Point &delta, const Point &pt) {
|
||||
translate(delta);
|
||||
bool result = _element.contains2(pt);
|
||||
translateBack(delta);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CPetSection *CPetGlyph::getPetSection() const {
|
||||
return _owner ? _owner->getOwner() : nullptr;
|
||||
}
|
||||
|
||||
CPetControl *CPetGlyph::getPetControl() const {
|
||||
return _owner ? _owner->getPetControl() : nullptr;
|
||||
}
|
||||
|
||||
void CPetGlyph::setName(const CString &name, CPetControl *petControl) {
|
||||
Rect r(0, 0, 52, 52);
|
||||
_element.setBounds(r);
|
||||
_element.reset(name, petControl, MODE_UNSELECTED);
|
||||
}
|
||||
|
||||
bool CPetGlyph::isHighlighted() const {
|
||||
return _owner->isGlyphHighlighted(this);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CPetGlyphs::CPetGlyphs() : _firstVisibleIndex(0), _numVisibleGlyphs(TOTAL_GLYPHS),
|
||||
_highlightIndex(-1), _field1C(-1), _flags(0),
|
||||
_dragGlyph(nullptr), _owner(nullptr) {
|
||||
}
|
||||
|
||||
void CPetGlyphs::setNumVisible(int total) {
|
||||
if (total > 0)
|
||||
_numVisibleGlyphs = total;
|
||||
}
|
||||
|
||||
void CPetGlyphs::clear() {
|
||||
changeHighlight(-1);
|
||||
destroyContents();
|
||||
_firstVisibleIndex = 0;
|
||||
}
|
||||
|
||||
void CPetGlyphs::setup(int numVisible, CPetSection *owner) {
|
||||
setNumVisible(numVisible);
|
||||
_owner = owner;
|
||||
_selection.setBounds(Rect(0, 0, 76, 76));
|
||||
|
||||
int buttonsLeft = numVisible * 70 + 21;
|
||||
|
||||
_scrollLeft.setBounds(Rect(0, 0, 31, 15));
|
||||
_scrollLeft.translate(buttonsLeft + 7, 373);
|
||||
_scrollRight.setBounds(Rect(0, 0, 31, 15));
|
||||
_scrollRight.translate(buttonsLeft + 7, 413);
|
||||
}
|
||||
|
||||
void CPetGlyphs::reset() {
|
||||
if (_owner && _owner->_petControl) {
|
||||
CPetControl *pet = _owner->_petControl;
|
||||
|
||||
_scrollLeft.reset("PetScrollLeft", pet, MODE_UNSELECTED);
|
||||
_scrollRight.reset("PetScrollRight", pet, MODE_UNSELECTED);
|
||||
_selection.reset("PetSelection", pet, MODE_UNSELECTED);
|
||||
|
||||
for (iterator i = begin(); i != end(); ++i) {
|
||||
(*i)->reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::enter() {
|
||||
if (_highlightIndex != -1) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
if (glyph)
|
||||
glyph->enter();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::leave() {
|
||||
if (_highlightIndex != -1) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
if (glyph)
|
||||
glyph->leave();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::draw(CScreenManager *screenManager) {
|
||||
if (_highlightIndex != -1) {
|
||||
int index = getHighlightedIndex(_highlightIndex);
|
||||
if (index != -1) {
|
||||
Point pt = getPosition(index);
|
||||
pt -= Point(12, 13);
|
||||
_selection.translate(pt.x, pt.y);
|
||||
_selection.draw(screenManager);
|
||||
_selection.translate(-pt.x, -pt.y);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through displaying glyphs on the screen
|
||||
int listSize = size();
|
||||
for (int index = 0; index < _numVisibleGlyphs; ++index) {
|
||||
int itemIndex = getItemIndex(index);
|
||||
|
||||
if (itemIndex >= 0 && itemIndex < listSize) {
|
||||
Point pt = getPosition(index);
|
||||
CPetGlyph *glyph = getGlyph(itemIndex);
|
||||
|
||||
if (glyph)
|
||||
glyph->drawAt(screenManager, pt, itemIndex == _highlightIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw scrolling arrows if more than a screen's worth of items are showing
|
||||
if (listSize > _numVisibleGlyphs || (_flags & GFLAG_16)) {
|
||||
_scrollLeft.draw(screenManager);
|
||||
_scrollRight.draw(screenManager);
|
||||
}
|
||||
|
||||
// Handle secondary highlight
|
||||
if (_highlightIndex != -1) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
if (glyph)
|
||||
glyph->draw2(screenManager);
|
||||
}
|
||||
}
|
||||
|
||||
Point CPetGlyphs::getPosition(int index) const {
|
||||
Point tempPoint(37 + index * 70, 375);
|
||||
return tempPoint;
|
||||
}
|
||||
|
||||
Rect CPetGlyphs::getRect(int index) const {
|
||||
Point pt = getPosition(index);
|
||||
return Rect(pt.x, pt.y, pt.x + 52, pt.y + 52);
|
||||
}
|
||||
|
||||
void CPetGlyphs::changeHighlight(int index) {
|
||||
if (index == _highlightIndex)
|
||||
return;
|
||||
|
||||
if (_highlightIndex >= 0 && (_flags & GFLAG_4)) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
if (glyph)
|
||||
glyph->unhighlightCurrent();
|
||||
}
|
||||
|
||||
_highlightIndex = index;
|
||||
if (index >= 0) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
|
||||
if (glyph) {
|
||||
if (_flags & GFLAG_4) {
|
||||
Point pt;
|
||||
int idx = getHighlightedIndex(_highlightIndex);
|
||||
if (idx >= 0)
|
||||
pt = getPosition(idx);
|
||||
|
||||
glyph->highlightCurrent(pt);
|
||||
}
|
||||
|
||||
glyph->updateTooltip();
|
||||
}
|
||||
} else if (_owner) {
|
||||
_owner->removeText();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::highlight(int index) {
|
||||
if (index >= 0) {
|
||||
setSelectedIndex(index);
|
||||
changeHighlight(index);
|
||||
makePetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::highlight(const CPetGlyph *glyph) {
|
||||
highlight(indexOf(glyph));
|
||||
}
|
||||
|
||||
int CPetGlyphs::getHighlightedIndex(int index) const {
|
||||
int idx = index - _firstVisibleIndex;
|
||||
return (idx >= 0 && idx < _numVisibleGlyphs) ? idx : -1;
|
||||
}
|
||||
|
||||
int CPetGlyphs::getItemIndex(int index) const {
|
||||
return _firstVisibleIndex + index;
|
||||
}
|
||||
|
||||
void CPetGlyphs::setSelectedIndex(int index) {
|
||||
if (index >= 0 && index < (int)size() && getHighlightedIndex(index) == -1) {
|
||||
if (_firstVisibleIndex <= index)
|
||||
index -= _numVisibleGlyphs - 1;
|
||||
|
||||
setFirstVisible(index);
|
||||
}
|
||||
}
|
||||
|
||||
CPetGlyph *CPetGlyphs::getGlyph(int index) const {
|
||||
for (const_iterator i = begin(); i != end(); ++i) {
|
||||
if (index-- == 0)
|
||||
return *i;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPetControl *CPetGlyphs::getPetControl() const {
|
||||
return _owner ? _owner->getPetControl() : nullptr;
|
||||
}
|
||||
|
||||
void CPetGlyphs::setFirstVisible(int index) {
|
||||
if (index != _firstVisibleIndex) {
|
||||
_firstVisibleIndex = index;
|
||||
|
||||
if ((_flags & GFLAG_8) && _highlightIndex != -1) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
|
||||
if (glyph) {
|
||||
int idx = getHighlightedIndex(_highlightIndex);
|
||||
if (idx != -1) {
|
||||
Point tempPt = getPosition(idx);
|
||||
glyph->glyphFocused(tempPt, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::scrollLeft() {
|
||||
if (_firstVisibleIndex > 0) {
|
||||
setFirstVisible(_firstVisibleIndex - 1);
|
||||
if (_highlightIndex != -1) {
|
||||
int index = getHighlightedIndex(_highlightIndex);
|
||||
if (index == -1)
|
||||
changeHighlight(_highlightIndex - 1);
|
||||
}
|
||||
|
||||
makePetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::scrollRight() {
|
||||
int count = size();
|
||||
int right = count - _numVisibleGlyphs;
|
||||
|
||||
if (_firstVisibleIndex < right) {
|
||||
setFirstVisible(_firstVisibleIndex + 1);
|
||||
if (_highlightIndex != -1) {
|
||||
int index = getHighlightedIndex(_highlightIndex);
|
||||
if (index == -1)
|
||||
changeHighlight(_highlightIndex + 1);
|
||||
}
|
||||
|
||||
makePetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::makePetDirty() {
|
||||
if (_owner && _owner->_petControl)
|
||||
_owner->_petControl->makeDirty();
|
||||
}
|
||||
|
||||
bool CPetGlyphs::MouseButtonDownMsg(const Point &pt) {
|
||||
if (_scrollLeft.contains2(pt)) {
|
||||
scrollLeft();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_scrollRight.contains2(pt)) {
|
||||
scrollRight();
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < _numVisibleGlyphs; ++idx) {
|
||||
Rect glyphRect = getRect(idx);
|
||||
if (glyphRect.contains(pt)) {
|
||||
int index = getItemIndex(idx);
|
||||
CPetGlyph *glyph = getGlyph(index);
|
||||
if (glyph) {
|
||||
if (_highlightIndex == index) {
|
||||
glyph->selectGlyph(glyphRect, pt);
|
||||
glyph->updateTooltip();
|
||||
} else {
|
||||
changeHighlight(index);
|
||||
makePetDirty();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_highlightIndex != -1) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
|
||||
if (glyph) {
|
||||
if (glyph->MouseButtonDownMsg(pt))
|
||||
return true;
|
||||
|
||||
if (!(_flags & GFLAG_2)) {
|
||||
changeHighlight(-1);
|
||||
makePetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetGlyphs::MouseButtonUpMsg(const Point &pt) {
|
||||
if (_highlightIndex >= 0) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
if (glyph) {
|
||||
if (glyph->MouseButtonUpMsg(pt))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetGlyphs::MouseDragStartMsg(CMouseDragStartMsg *msg) {
|
||||
if (!(_flags & GFLAG_1) && _highlightIndex >= 0) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
int index = getHighlightedIndex(_highlightIndex);
|
||||
Rect glyphRect = getRect(index);
|
||||
|
||||
if (glyphRect.contains(msg->_mousePos))
|
||||
return glyph->dragGlyph(glyphRect, msg);
|
||||
else
|
||||
return glyph->MouseDragStartMsg(msg);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetGlyphs::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
|
||||
if (_dragGlyph) {
|
||||
return _dragGlyph->MouseDragMoveMsg(msg);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetGlyphs::MouseDragEndMsg(CMouseDragEndMsg *msg) {
|
||||
if (_dragGlyph) {
|
||||
return _dragGlyph->MouseDragEndMsg(msg);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetGlyphs::KeyCharMsg(int key) {
|
||||
if (_highlightIndex >= 0) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
|
||||
if (glyph && glyph->KeyCharMsg(key))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetGlyphs::ActionMsg(CActionMsg *msg) {
|
||||
if (_highlightIndex >= 0) {
|
||||
CPetGlyph *glyph = getGlyph(_highlightIndex);
|
||||
if (glyph && glyph->ActionMsg(msg))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetGlyphs::enterHighlighted() {
|
||||
if (_highlightIndex >= 0)
|
||||
return getGlyph(_highlightIndex)->enterHighlighted();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetGlyphs::leaveHighlighted() {
|
||||
if (_highlightIndex >= 0)
|
||||
getGlyph(_highlightIndex)->leaveHighlighted();
|
||||
}
|
||||
|
||||
void CPetGlyphs::startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg) {
|
||||
if (glyph) {
|
||||
_dragGlyph = glyph;
|
||||
msg->_dragItem = getPetControl();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::endDragging() {
|
||||
_dragGlyph = nullptr;
|
||||
}
|
||||
|
||||
bool CPetGlyphs::highlighted14() {
|
||||
if (_highlightIndex != -1) {
|
||||
CPetGlyph *pet = getGlyph(_highlightIndex);
|
||||
if (pet) {
|
||||
pet->updateTooltip();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int CPetGlyphs::indexOf(const CPetGlyph *glyph) const {
|
||||
int index = 0;
|
||||
for (const_iterator i = begin(); i != end(); ++i, ++index) {
|
||||
if (*i == glyph)
|
||||
return index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CPetGlyphs::incSelection() {
|
||||
if (_highlightIndex >= 0 && _highlightIndex < ((int)size() - 1)) {
|
||||
if (getHighlightedIndex(_highlightIndex) >= (_numVisibleGlyphs - 1))
|
||||
scrollRight();
|
||||
|
||||
changeHighlight(_highlightIndex + 1);
|
||||
makePetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetGlyphs::decSelection() {
|
||||
if (_highlightIndex > 0) {
|
||||
if (getHighlightedIndex(_highlightIndex) == 0)
|
||||
scrollLeft();
|
||||
|
||||
changeHighlight(_highlightIndex - 1);
|
||||
makePetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
CGameObject *CPetGlyphs::getObjectAt(const Point &pt) const {
|
||||
for (int idx = 0; idx < _numVisibleGlyphs; ++idx) {
|
||||
Rect glyphRect = getRect(idx);
|
||||
if (glyphRect.contains(pt)) {
|
||||
CPetGlyph *glyph = getGlyph(getItemIndex(idx));
|
||||
if (glyph)
|
||||
return glyph->getObjectAt();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CPetGlyphs::isGlyphHighlighted(const CPetGlyph *glyph) const {
|
||||
if (_highlightIndex == -1)
|
||||
return false;
|
||||
|
||||
return indexOf(glyph) == _highlightIndex;
|
||||
}
|
||||
|
||||
Point CPetGlyphs::getHighlightedGlyphPos() const {
|
||||
if (_highlightIndex != -1) {
|
||||
int idx = getHighlightedIndex(_highlightIndex);
|
||||
if (idx >= 0)
|
||||
return getPosition(idx);
|
||||
}
|
||||
|
||||
return Point(0, 0);
|
||||
}
|
||||
|
||||
bool CPetGlyphs::areItemsValid() const {
|
||||
for (const_iterator i = begin(); i != end(); ++i) {
|
||||
if (!(*i)->isValid())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetGlyphs::removeInvalid() {
|
||||
if (!areItemsValid()) {
|
||||
changeHighlight(-1);
|
||||
|
||||
for (iterator i = begin(); i != end(); ) {
|
||||
CPetGlyph *glyph = *i;
|
||||
|
||||
if (!glyph->isValid()) {
|
||||
i = erase(i);
|
||||
delete glyph;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
int max = MAX((int)size() - _numVisibleGlyphs, 0);
|
||||
_firstVisibleIndex = CLIP(_firstVisibleIndex, 0, max);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
496
engines/titanic/pet_control/pet_glyphs.h
Normal file
496
engines/titanic/pet_control/pet_glyphs.h
Normal file
@@ -0,0 +1,496 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_GLYPHS_H
|
||||
#define TITANIC_PET_GLYPHS_H
|
||||
|
||||
#include "common/keyboard.h"
|
||||
#include "titanic/core/list.h"
|
||||
#include "titanic/messages/mouse_messages.h"
|
||||
#include "titanic/pet_control/pet_gfx_element.h"
|
||||
#include "titanic/support/rect.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
#define TOTAL_GLYPHS 7
|
||||
|
||||
class CPetGlyphs;
|
||||
class CPetSection;
|
||||
class CTextControl;
|
||||
|
||||
enum GlyphActionMode { ACTION_REMOVE = 0, ACTION_REMOVED = 1, ACTION_CHANGE = 2 };
|
||||
|
||||
enum GlyphFlag { GFLAG_1 = 1, GFLAG_2 = 2, GFLAG_4 = 4, GFLAG_8 = 8, GFLAG_16 = 16 };
|
||||
|
||||
class CGlyphAction {
|
||||
protected:
|
||||
GlyphActionMode _mode;
|
||||
public:
|
||||
CGlyphAction() : _mode(ACTION_REMOVED) {}
|
||||
CGlyphAction(GlyphActionMode mode) : _mode(mode) {}
|
||||
|
||||
GlyphActionMode getMode() const { return _mode; }
|
||||
};
|
||||
|
||||
class CPetGlyph : public ListItem {
|
||||
protected:
|
||||
/**
|
||||
* Get the overall pet section owner
|
||||
*/
|
||||
CPetSection *getPetSection() const;
|
||||
public:
|
||||
CPetGfxElement _element;
|
||||
CPetGlyphs *_owner;
|
||||
public:
|
||||
CPetGlyph() : ListItem(), _owner(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
virtual bool setup(CPetControl *petControl, CPetGlyphs *owner);
|
||||
|
||||
/**
|
||||
* Reset the glyph
|
||||
*/
|
||||
virtual bool reset() { return false; }
|
||||
|
||||
/**
|
||||
* Called when the PET area is entered
|
||||
*/
|
||||
virtual void enter() {}
|
||||
|
||||
/**
|
||||
* Called when the PET area is left
|
||||
*/
|
||||
virtual void leave() {}
|
||||
|
||||
/**
|
||||
* Draw the glyph at a specified position
|
||||
*/
|
||||
virtual void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted);
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
virtual void draw2(CScreenManager *screenManager) {}
|
||||
|
||||
/**
|
||||
* Updates the tooltip being shown for the glyph
|
||||
*/
|
||||
virtual void updateTooltip();
|
||||
|
||||
/**
|
||||
* Get the bounds for the glyph
|
||||
*/
|
||||
virtual Rect getBounds() const { return Rect(); }
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
virtual bool MouseButtonDownMsg(const Point &pt) { return false; }
|
||||
|
||||
/**
|
||||
* Called when mouse drag starts
|
||||
*/
|
||||
virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg) { return false; }
|
||||
|
||||
/**
|
||||
* Called during mouse drags
|
||||
*/
|
||||
virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) { return false; }
|
||||
|
||||
/**
|
||||
* Called when mouse drag ends
|
||||
*/
|
||||
virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; }
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
virtual bool MouseButtonUpMsg(const Point &pt) { return false; }
|
||||
|
||||
/**
|
||||
* Handles mouse double-click messages
|
||||
*/
|
||||
virtual bool MouseDoubleClickMsg(const CMouseDoubleClickMsg *msg) { return false; }
|
||||
|
||||
/**
|
||||
* Handles keypresses
|
||||
*/
|
||||
virtual bool KeyCharMsg(int key) { return false; }
|
||||
|
||||
/**
|
||||
* Handles actions
|
||||
*/
|
||||
virtual bool ActionMsg(CActionMsg *msg) {return false; }
|
||||
|
||||
/**
|
||||
* Unhighlight any currently highlighted element
|
||||
*/
|
||||
virtual void unhighlightCurrent() {}
|
||||
|
||||
/**
|
||||
* Highlight any currently highlighted element
|
||||
*/
|
||||
virtual void highlightCurrent(const Point &pt) {}
|
||||
|
||||
/**
|
||||
* Glyph has been shifted to be first visible one
|
||||
*/
|
||||
virtual void glyphFocused(const Point &topLeft, bool flag) {}
|
||||
|
||||
/**
|
||||
* Selects a glyph
|
||||
*/
|
||||
virtual void selectGlyph(const Point &topLeft, const Point &pt) {}
|
||||
|
||||
/**
|
||||
* Called when a glyph drag starts
|
||||
*/
|
||||
virtual bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) { return false; }
|
||||
|
||||
/**
|
||||
* Returns true if the glyph's bounds, shifted to a given position,
|
||||
* will contain the specified point
|
||||
*/
|
||||
virtual bool contains(const Point &delta, const Point &pt);
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
virtual void getTooltip(CTextControl *text) {}
|
||||
|
||||
/**
|
||||
* Saves the data for the glyph
|
||||
*/
|
||||
virtual void saveGlyph(SimpleFile *file, int indent) {}
|
||||
|
||||
virtual bool proc33(CPetGlyph *glyph) { return true; }
|
||||
|
||||
/**
|
||||
* Return whether the glyph is currently valid
|
||||
*/
|
||||
virtual bool isValid() const { return true; }
|
||||
|
||||
/**
|
||||
* Called on a highlighted item when PET area is entered
|
||||
*/
|
||||
virtual bool enterHighlighted() { return false; }
|
||||
|
||||
/**
|
||||
* Called on a highlighted item when PET area is left
|
||||
*/
|
||||
virtual void leaveHighlighted() {}
|
||||
|
||||
/**
|
||||
* Returns the object associated with the glyph
|
||||
*/
|
||||
virtual CGameObject *getObjectAt() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Does a processing action on the glyph
|
||||
*/
|
||||
virtual bool doAction(CGlyphAction *action) { return true; }
|
||||
|
||||
/**
|
||||
* Translate the glyph's position
|
||||
*/
|
||||
void translate(const Point &pt) { _element.translate(pt.x, pt.y); }
|
||||
|
||||
/**
|
||||
* Translate the glyph's position back
|
||||
*/
|
||||
void translateBack(const Point &pt) { _element.translate(-pt.x, -pt.y); }
|
||||
|
||||
/**
|
||||
* Get the parent RealLife area
|
||||
*/
|
||||
CPetGlyphs *getOwner() { return _owner; }
|
||||
|
||||
/**
|
||||
* Get the PET control
|
||||
*/
|
||||
CPetControl *getPetControl() const;
|
||||
|
||||
/**
|
||||
* Sets new name and default bounds for glyph
|
||||
*/
|
||||
void setName(const CString &name, CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Returns true if the specified glyph is the currently highlighted one
|
||||
*/
|
||||
bool isHighlighted() const;
|
||||
};
|
||||
|
||||
class CPetGlyphs : public List<CPetGlyph> {
|
||||
private:
|
||||
/**
|
||||
* Get a position for the glyph
|
||||
*/
|
||||
Point getPosition(int index) const;
|
||||
|
||||
/**
|
||||
* Get a rect for the glyph
|
||||
*/
|
||||
Rect getRect(int index) const;
|
||||
|
||||
/**
|
||||
* Returns the on-screen index for the highlight to be shown at
|
||||
*/
|
||||
int getHighlightedIndex(int index) const;
|
||||
|
||||
/**
|
||||
* Returns the index of a glyph given the visible on-screen glyph number
|
||||
*/
|
||||
int getItemIndex(int index) const;
|
||||
|
||||
/**
|
||||
* Set the item index
|
||||
*/
|
||||
void setSelectedIndex(int index);
|
||||
|
||||
/**
|
||||
* Return a specified glyph
|
||||
*/
|
||||
CPetGlyph *getGlyph(int index) const;
|
||||
|
||||
/**
|
||||
* Set the first visible glyph index
|
||||
*/
|
||||
void setFirstVisible(int index);
|
||||
|
||||
/**
|
||||
* Make the PET dirty
|
||||
*/
|
||||
void makePetDirty();
|
||||
|
||||
/**
|
||||
* Returns true if all the glyphs are in a valid state
|
||||
*/
|
||||
bool areItemsValid() const;
|
||||
protected:
|
||||
int _firstVisibleIndex;
|
||||
int _totalGlyphs;
|
||||
int _numVisibleGlyphs;
|
||||
int _highlightIndex;
|
||||
int _field1C;
|
||||
int _flags;
|
||||
CPetGlyph *_dragGlyph;
|
||||
CPetSection *_owner;
|
||||
CPetGfxElement _selection;
|
||||
CPetGfxElement _scrollLeft;
|
||||
CPetGfxElement _scrollRight;
|
||||
protected:
|
||||
/**
|
||||
* Change the currently selected glyph
|
||||
*/
|
||||
void changeHighlight(int index);
|
||||
public:
|
||||
CPetGlyphs();
|
||||
|
||||
/**
|
||||
* Set the number of visible glyphs
|
||||
*/
|
||||
void setNumVisible(int total);
|
||||
|
||||
/**
|
||||
* Clears the glyph list
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
/**
|
||||
* The visual dimensions for the control and it's components
|
||||
*/
|
||||
virtual void setup(int numVisible, CPetSection *owner);
|
||||
|
||||
/**
|
||||
* Set up the control
|
||||
*/
|
||||
virtual void reset();
|
||||
|
||||
/**
|
||||
* Called when PET area is entered
|
||||
*/
|
||||
virtual void enter();
|
||||
|
||||
/**
|
||||
* Called when PET area is left
|
||||
*/
|
||||
virtual void leave();
|
||||
|
||||
void setFlags(int flags) { _flags = flags; }
|
||||
|
||||
/**
|
||||
* Draw the control
|
||||
*/
|
||||
void draw(CScreenManager *screenManager);
|
||||
|
||||
/**
|
||||
* Highlight a specific glyph by indexe
|
||||
*/
|
||||
void highlight(int index);
|
||||
|
||||
/**
|
||||
* Highlight a specific glyph
|
||||
*/
|
||||
void highlight(const CPetGlyph *glyph);
|
||||
|
||||
/**
|
||||
* Get the owning section for the glyphs
|
||||
*/
|
||||
CPetSection *getOwner() const { return _owner; }
|
||||
|
||||
/**
|
||||
* Get the PET control
|
||||
*/
|
||||
CPetControl *getPetControl() const;
|
||||
|
||||
/**
|
||||
* Mouse button down message
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt);
|
||||
|
||||
/**
|
||||
* Mouse button up message
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt);
|
||||
|
||||
/**
|
||||
* Mouse double click message
|
||||
*/
|
||||
bool MouseDoubleClickMsg(const Point &pt) { return true; }
|
||||
|
||||
/**
|
||||
* Mouse drag start messagge
|
||||
*/
|
||||
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
|
||||
|
||||
/**
|
||||
* Mouse drag move message
|
||||
*/
|
||||
bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
|
||||
|
||||
/**
|
||||
* Mouse drag end message
|
||||
*/
|
||||
bool MouseDragEndMsg(CMouseDragEndMsg *msg);
|
||||
|
||||
/**
|
||||
* Key character message
|
||||
*/
|
||||
bool KeyCharMsg(int key);
|
||||
|
||||
/**
|
||||
* Action message
|
||||
*/
|
||||
bool ActionMsg(CActionMsg *msg);
|
||||
|
||||
/**
|
||||
* When the PET section is entered, passes onto the highlighted
|
||||
* glyph, if any
|
||||
*/
|
||||
bool enterHighlighted();
|
||||
|
||||
/**
|
||||
* When the PET section is left, passes onto the highlighted
|
||||
* glyph, if any
|
||||
*/
|
||||
void leaveHighlighted();
|
||||
|
||||
/**
|
||||
* Called when a dragging operation starts
|
||||
*/
|
||||
void startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg);
|
||||
|
||||
/**
|
||||
* Called when a dragging operation ends
|
||||
*/
|
||||
void endDragging();
|
||||
|
||||
/**
|
||||
* Reset the highlight
|
||||
*/
|
||||
void resetHighlight() { changeHighlight(-1); }
|
||||
|
||||
bool highlighted14();
|
||||
|
||||
/**
|
||||
* Returns the index of the specified glyph in the lsit
|
||||
*/
|
||||
int indexOf(const CPetGlyph *glyph) const;
|
||||
|
||||
/**
|
||||
* Resets the scrolling of the glyphs list back to the start
|
||||
*/
|
||||
void scrollToStart() { _firstVisibleIndex = 0; }
|
||||
|
||||
/**
|
||||
* Scrolls the glyphs to the left
|
||||
*/
|
||||
void scrollLeft();
|
||||
|
||||
/**
|
||||
* Scrolls the glyphs to the right
|
||||
*/
|
||||
void scrollRight();
|
||||
|
||||
/**
|
||||
* Increment the currently selected index
|
||||
*/
|
||||
void incSelection();
|
||||
|
||||
/**
|
||||
* Decrement the currently selected index
|
||||
*/
|
||||
void decSelection();
|
||||
|
||||
/**
|
||||
* Returns the object associated the glyph under the specified position
|
||||
*/
|
||||
CGameObject *getObjectAt(const Point &pt) const;
|
||||
|
||||
/**
|
||||
* Returns true if the specified glyph is the currently highlighted one
|
||||
*/
|
||||
bool isGlyphHighlighted(const CPetGlyph *glyph) const;
|
||||
|
||||
/**
|
||||
* Returns the highlighted index, if any
|
||||
*/
|
||||
int getHighlightIndex() const { return _highlightIndex; }
|
||||
|
||||
/**
|
||||
* Get the top-left position of the currently highlighted glyph
|
||||
*/
|
||||
Point getHighlightedGlyphPos() const;
|
||||
|
||||
/**
|
||||
* Removes any glyphs from the list that no longer have any images
|
||||
* associated with them
|
||||
*/
|
||||
void removeInvalid();
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_GLYPHS_H */
|
||||
38
engines/titanic/pet_control/pet_graphic.cpp
Normal file
38
engines/titanic/pet_control/pet_graphic.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_graphic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetGraphic, CGameObject);
|
||||
|
||||
void CPetGraphic::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CGameObject::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetGraphic::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CGameObject::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
47
engines/titanic/pet_control/pet_graphic.h
Normal file
47
engines/titanic/pet_control/pet_graphic.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_GRAPHIC_H
|
||||
#define TITANIC_PET_GRAPHIC_H
|
||||
|
||||
#include "titanic/core/game_object.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetGraphic : public CGameObject {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_GRAPHIC_H */
|
||||
38
engines/titanic/pet_control/pet_graphic2.cpp
Normal file
38
engines/titanic/pet_control/pet_graphic2.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_graphic2.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetGraphic2, CGameObject);
|
||||
|
||||
void CPetGraphic2::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CGameObject::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetGraphic2::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CGameObject::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
47
engines/titanic/pet_control/pet_graphic2.h
Normal file
47
engines/titanic/pet_control/pet_graphic2.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_GRAPHIC2_H
|
||||
#define TITANIC_PET_GRAPHIC2_H
|
||||
|
||||
#include "titanic/core/game_object.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetGraphic2 : public CGameObject {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_GRAPHIC2_H */
|
||||
280
engines/titanic/pet_control/pet_inventory.cpp
Normal file
280
engines/titanic/pet_control/pet_inventory.cpp
Normal file
@@ -0,0 +1,280 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_inventory.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/carry/carry.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetInventory::CPetInventory() : CPetSection(),
|
||||
_movie(nullptr), _isLoading(false), _titaniaBitFlags(0) {
|
||||
for (int idx = 0; idx < TOTAL_ITEMS; ++idx) {
|
||||
_itemBackgrounds[idx] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetInventory::setup(CPetControl *petControl) {
|
||||
return setPetControl(petControl) && reset();
|
||||
}
|
||||
|
||||
bool CPetInventory::reset() {
|
||||
_items.reset();
|
||||
_text.setup();
|
||||
_text.setColor(getColor(0));
|
||||
_text.setLineColor(0, getColor(0));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetInventory::draw(CScreenManager *screenManager) {
|
||||
_petControl->drawSquares(screenManager, 7);
|
||||
_items.draw(screenManager);
|
||||
_text.draw(screenManager);
|
||||
}
|
||||
|
||||
Rect CPetInventory::getBounds() const {
|
||||
return _movie ? _movie->getBounds() : Rect();
|
||||
}
|
||||
|
||||
void CPetInventory::changed(int changeType) {
|
||||
switch (changeType) {
|
||||
case 0:
|
||||
case 2:
|
||||
itemsChanged();
|
||||
break;
|
||||
case 1:
|
||||
removeInvalid();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventory::enterRoom(CRoomItem *room) {
|
||||
int index = _items.getHighlightIndex();
|
||||
if (index != -1) {
|
||||
_items.resetHighlight();
|
||||
_items.highlight(index);
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetInventory::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
return _items.MouseButtonDownMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetInventory::MouseDragStartMsg(CMouseDragStartMsg *msg) {
|
||||
bool result = _items.MouseDragStartMsg(msg);
|
||||
if (result)
|
||||
_petControl->makeDirty();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetInventory::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
||||
return _items.MouseButtonUpMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetInventory::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
|
||||
return _items.MouseDoubleClickMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetInventory::ActionMsg(CActionMsg *msg) {
|
||||
return _items.ActionMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetInventory::MouseWheelMsg(CMouseWheelMsg *msg) {
|
||||
if (msg->_wheelUp)
|
||||
_items.scrollLeft();
|
||||
else
|
||||
_items.scrollRight();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CGameObject *CPetInventory::dragEnd(const Point &pt) const {
|
||||
return _items.getObjectAt(pt);
|
||||
}
|
||||
|
||||
bool CPetInventory::isValid(CPetControl *petControl) {
|
||||
setPetControl(petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetInventory::load(SimpleFile *file, int param) {
|
||||
_titaniaBitFlags = file->readNumber();
|
||||
}
|
||||
|
||||
void CPetInventory::postLoad() {
|
||||
reset();
|
||||
_isLoading = true;
|
||||
itemsChanged();
|
||||
_isLoading = false;
|
||||
}
|
||||
|
||||
void CPetInventory::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(_titaniaBitFlags, indent);
|
||||
}
|
||||
|
||||
void CPetInventory::enter(PetArea oldArea) {
|
||||
_items.enter();
|
||||
}
|
||||
|
||||
void CPetInventory::leave() {
|
||||
_items.leave();
|
||||
}
|
||||
|
||||
CGameObject *CPetInventory::getBackground(int index) const {
|
||||
return (index >= 0 && index < 46) ? _itemBackgrounds[index] : nullptr;
|
||||
}
|
||||
|
||||
bool CPetInventory::setPetControl(CPetControl *petControl) {
|
||||
if (!petControl)
|
||||
return false;
|
||||
|
||||
_petControl = petControl;
|
||||
_items.setup(7, this);
|
||||
_items.setFlags(28);
|
||||
|
||||
Rect tempRect(0, 0, 52, 52);
|
||||
for (uint idx = 0; idx < TOTAL_ITEMS; ++idx) {
|
||||
if (!g_vm->_itemNames[idx].empty()) {
|
||||
CString name = "3Pet" + g_vm->_itemNames[idx];
|
||||
_itemBackgrounds[idx] = petControl->getHiddenObject(name);
|
||||
}
|
||||
}
|
||||
|
||||
tempRect = Rect(0, 0, 580, 15);
|
||||
tempRect.translate(32, 445);
|
||||
_text.setBounds(tempRect);
|
||||
_text.setHasBorder(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetInventory::change(CGameObject *item) {
|
||||
if (item) {
|
||||
CInventoryGlyphAction action(item, ACTION_CHANGE);
|
||||
_items.doAction(&action);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventory::itemRemoved(CGameObject *item) {
|
||||
if (item) {
|
||||
CInventoryGlyphAction action(item, ACTION_REMOVED);
|
||||
_items.doAction(&action);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventory::itemsChanged() {
|
||||
_items.clear();
|
||||
|
||||
CGameObject *item = _petControl->getFirstObject();
|
||||
while (item) {
|
||||
CPetInventoryGlyph *glyph = new CPetInventoryGlyph();
|
||||
glyph->setup(_petControl, &_items);
|
||||
glyph->setItem(item, _isLoading);
|
||||
|
||||
_items.push_back(glyph);
|
||||
item = _petControl->getNextObject(item);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventory::highlightItem(CGameObject *item) {
|
||||
int itemIndex = getItemIndex(item);
|
||||
_items.highlight(itemIndex);
|
||||
}
|
||||
|
||||
int CPetInventory::getItemIndex(CGameObject *item) const {
|
||||
int index = 0;
|
||||
for (CGameObject *obj = _petControl->getFirstObject(); obj && obj != item;
|
||||
++index, obj = _petControl->getNextObject(obj)) {
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
CGameObject *CPetInventory::getTransformAnimation(int index) {
|
||||
if (index >= 0 && index < 46) {
|
||||
// Certain items are pieces of Titania, and they only have the
|
||||
// one-time initial transformation into Titania pieces
|
||||
CString name;
|
||||
int bits = 0;
|
||||
|
||||
switch (index) {
|
||||
case 20:
|
||||
name = "PetEarMorph";
|
||||
bits = 4;
|
||||
break;
|
||||
case 21:
|
||||
name = "PetEarMorph1";
|
||||
bits = 8;
|
||||
break;
|
||||
case 22:
|
||||
name = "PetEyeMorph";
|
||||
bits = 1;
|
||||
break;
|
||||
case 23:
|
||||
name = "PetEyeMorph";
|
||||
bits = 2;
|
||||
break;
|
||||
case 36:
|
||||
name = "PetMouthMorph";
|
||||
bits = 32;
|
||||
break;
|
||||
case 39:
|
||||
name = "PetNoseMorph";
|
||||
bits = 16;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(bits & _titaniaBitFlags) && !name.empty()) {
|
||||
CGameObject *obj = getPetControl()->getHiddenObject(name);
|
||||
assert(obj);
|
||||
|
||||
_titaniaBitFlags = bits | _titaniaBitFlags;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CPetInventory::playMovie(CGameObject *movie, bool repeat) {
|
||||
if (_movie)
|
||||
_movie->stopMovie();
|
||||
_movie = movie;
|
||||
|
||||
if (_movie) {
|
||||
if (repeat)
|
||||
_movie->playMovie(0, 14, MOVIE_REPEAT);
|
||||
else
|
||||
_movie->playMovie(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventory::removeInvalid() {
|
||||
_items.removeInvalid();
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
181
engines/titanic/pet_control/pet_inventory.h
Normal file
181
engines/titanic/pet_control/pet_inventory.h
Normal file
@@ -0,0 +1,181 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_INVENTORY_H
|
||||
#define TITANIC_PET_INVENTORY_H
|
||||
|
||||
#include "titanic/support/simple_file.h"
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/pet_control/pet_inventory_glyphs.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
/**
|
||||
* Handles displaying the player's inventory in the PET
|
||||
*/
|
||||
class CPetInventory : public CPetSection {
|
||||
private:
|
||||
CTextControl _text;
|
||||
CPetInventoryGlyphs _items;
|
||||
CGameObject *_itemBackgrounds[46];
|
||||
CGameObject *_movie;
|
||||
bool _isLoading;
|
||||
int _titaniaBitFlags;
|
||||
private:
|
||||
/**
|
||||
* Handles initial setup
|
||||
*/
|
||||
bool setPetControl(CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Get the index of an item added to the PET
|
||||
*/
|
||||
int getItemIndex(CGameObject *item) const;
|
||||
|
||||
/**
|
||||
* Remove any invalid inventory glyphs
|
||||
*/
|
||||
void removeInvalid();
|
||||
public:
|
||||
CPetInventory();
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Get the bounds for the section
|
||||
*/
|
||||
Rect getBounds() const override;
|
||||
|
||||
/**
|
||||
* Called when a general change occurs
|
||||
*/
|
||||
void changed(int changeType) override;
|
||||
|
||||
/**
|
||||
* Called when a new room is entered
|
||||
*/
|
||||
void enterRoom(CRoomItem *room) override;
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override;
|
||||
bool MouseDragStartMsg(CMouseDragStartMsg *msg) override;
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override;
|
||||
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) override;
|
||||
bool ActionMsg(CActionMsg *msg) override;
|
||||
bool MouseWheelMsg(CMouseWheelMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Returns item a drag-drop operation has dropped on, if any
|
||||
*/
|
||||
CGameObject *dragEnd(const Point &pt) const override;
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file, int param) override;
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Called when a section is switched to
|
||||
*/
|
||||
void enter(PetArea oldArea) override;
|
||||
|
||||
/**
|
||||
* Called when a section is being left, to switch to another area
|
||||
*/
|
||||
void leave() override;
|
||||
|
||||
/**
|
||||
* Get a reference to the tooltip text associated with the section
|
||||
*/
|
||||
CTextControl *getText() override { return &_text; }
|
||||
|
||||
/**
|
||||
* Special retrieval of glyph background image
|
||||
*/
|
||||
CGameObject *getBackground(int index) const override;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void change(CGameObject *item);
|
||||
|
||||
/**
|
||||
* Called when an item has been removed from the PET
|
||||
*/
|
||||
void itemRemoved(CGameObject *item);
|
||||
|
||||
/**
|
||||
* Called when the items under the PET have changed
|
||||
*/
|
||||
void itemsChanged();
|
||||
|
||||
/**
|
||||
* Called when the inventory can't be shown after adding an item
|
||||
*/
|
||||
void highlightItem(CGameObject *item);
|
||||
|
||||
/**
|
||||
* Gets the object, if any, containing the transformation animation played
|
||||
* when pieces of Titania are added to the inventory for the first time.
|
||||
*/
|
||||
CGameObject *getTransformAnimation(int index);
|
||||
|
||||
/**
|
||||
* Play the animated movie for an object
|
||||
*/
|
||||
void playMovie(CGameObject *movie, bool repeat = true);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_INVENTORY_H */
|
||||
354
engines/titanic/pet_control/pet_inventory_glyphs.cpp
Normal file
354
engines/titanic/pet_control/pet_inventory_glyphs.cpp
Normal file
@@ -0,0 +1,354 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_inventory_glyphs.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/pet_control/pet_inventory.h"
|
||||
#include "titanic/messages/pet_messages.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
const uint ITEM_MODES[40] = {
|
||||
0, 2, 11, 10, 12, 13, 9, 40, 7, 6,
|
||||
4, 5, 8, 15, 19, 24, 25, 26, 30, 20,
|
||||
21, 22, 23, 36, 39, 39, 31, 31, 32, 32,
|
||||
33, 34, 35, 38, 41, 42, 43, 44, 45, 37
|
||||
};
|
||||
|
||||
void CPetInventoryGlyph::enter() {
|
||||
startRepeatedMovie();
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::leave() {
|
||||
stopMovie();
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) {
|
||||
if (!_active)
|
||||
return;
|
||||
|
||||
if (_singular) {
|
||||
if (_singular->hasActiveMovie()) {
|
||||
if (isHighlighted_)
|
||||
_singular->draw(screenManager);
|
||||
else
|
||||
_singular->draw(screenManager, pt);
|
||||
return;
|
||||
}
|
||||
|
||||
_singular = nullptr;
|
||||
if (_repeated && isHighlighted_) {
|
||||
_repeated->setPosition(pt);
|
||||
startRepeatedMovie();
|
||||
}
|
||||
}
|
||||
|
||||
if (_repeated) {
|
||||
if (isHighlighted_)
|
||||
_repeated->draw(screenManager);
|
||||
else
|
||||
_repeated->draw(screenManager, pt);
|
||||
} else if (_singular) {
|
||||
_singular->draw(screenManager, pt, Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPetInventoryGlyph::unhighlightCurrent() {
|
||||
if (_singular) {
|
||||
_singular->setPosition(Point(0, 0));
|
||||
stopMovie();
|
||||
} else if (_repeated) {
|
||||
_repeated->setPosition(Point(0, 0));
|
||||
_repeated->loadFrame(0);
|
||||
stopMovie();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::highlightCurrent(const Point &pt) {
|
||||
reposition(pt);
|
||||
if (_item) {
|
||||
CPETObjectSelectedMsg selectedMsg;
|
||||
selectedMsg.execute(_item);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::glyphFocused(const Point &topLeft, bool flag) {
|
||||
if (_repeated && flag)
|
||||
_repeated->setPosition(topLeft);
|
||||
}
|
||||
|
||||
bool CPetInventoryGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) {
|
||||
if (!_item)
|
||||
return false;
|
||||
|
||||
if (_repeated) {
|
||||
_active = false;
|
||||
stopMovie();
|
||||
}
|
||||
|
||||
CPetControl *petControl = getPetControl();
|
||||
if (!petControl)
|
||||
return false;
|
||||
|
||||
CGameObject *carryParcel = petControl->getHiddenObject("CarryParcel");
|
||||
CGameObject *item = _item;
|
||||
|
||||
if (petControl->isSuccUBusActive() && carryParcel) {
|
||||
petControl->removeFromInventory(_item, carryParcel, false, true);
|
||||
petControl->removeFromInventory(_item, false, false);
|
||||
|
||||
carryParcel->setPosition(Point(msg->_mousePos.x - carryParcel->_bounds.width() / 2,
|
||||
msg->_mousePos.y - carryParcel->_bounds.height() / 2));
|
||||
carryParcel->setPosition(Point(SCREEN_WIDTH, SCREEN_HEIGHT));
|
||||
item = carryParcel;
|
||||
} else {
|
||||
petControl->removeFromInventory(_item, false, true);
|
||||
|
||||
_item->setPosition(Point(msg->_mousePos.x - _item->_bounds.width() / 2,
|
||||
msg->_mousePos.y - _item->_bounds.height() / 2));
|
||||
_item->setVisible(true);
|
||||
}
|
||||
|
||||
msg->_handled = true;
|
||||
if (msg->execute(item)) {
|
||||
_item = nullptr;
|
||||
_repeated = nullptr;
|
||||
_active = false;
|
||||
petControl->setAreaChangeType(1);
|
||||
return true;
|
||||
} else {
|
||||
petControl->addToInventory(item);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::getTooltip(CTextControl *text) {
|
||||
if (text) {
|
||||
text->setText("");
|
||||
|
||||
if (_active && _item) {
|
||||
int itemIndex = populateItem(_item, 0);
|
||||
if (itemIndex >= 14 && itemIndex <= 18) {
|
||||
// Variations of the chicken
|
||||
CPETObjectStateMsg stateMsg(0);
|
||||
stateMsg.execute(_item);
|
||||
|
||||
CString temperature = g_vm->_strings[stateMsg._value ? A_HOT : A_COLD];
|
||||
text->setText(CString::format("%s %s", temperature.c_str(),
|
||||
g_vm->_itemDescriptions[itemIndex].c_str()
|
||||
));
|
||||
|
||||
} else {
|
||||
text->setText(g_vm->_itemDescriptions[itemIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
|
||||
CInventoryGlyphAction *invAction = static_cast<CInventoryGlyphAction *>(action);
|
||||
CPetInventoryGlyphs *owner = dynamic_cast<CPetInventoryGlyphs *>(_owner);
|
||||
if (!invAction)
|
||||
return false;
|
||||
|
||||
switch (invAction->getMode()) {
|
||||
case ACTION_REMOVED:
|
||||
if (invAction->_item == _item) {
|
||||
_item = nullptr;
|
||||
_repeated = nullptr;
|
||||
_active = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case ACTION_CHANGE:
|
||||
if (_item == invAction->_item && _owner) {
|
||||
int v = populateItem(_item, 0);
|
||||
_repeated = owner->getBackground(v);
|
||||
|
||||
if (isHighlighted()) {
|
||||
Point glyphPos = _owner->getHighlightedGlyphPos();
|
||||
reposition(glyphPos);
|
||||
updateTooltip();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::setItem(CGameObject *item, bool isLoading) {
|
||||
_item = item;
|
||||
|
||||
if (_owner && item) {
|
||||
int idx = populateItem(item, isLoading);
|
||||
_repeated = static_cast<CPetInventoryGlyphs *>(_owner)->getBackground(idx);
|
||||
_singular = static_cast<CPetInventory *>(getPetSection())->getTransformAnimation(idx);
|
||||
}
|
||||
}
|
||||
|
||||
int CPetInventoryGlyph::populateItem(CGameObject *item, bool isLoading) {
|
||||
// Scan the master item names list
|
||||
CString itemName = item->getName();
|
||||
int itemIndex = -1;
|
||||
for (int idx = 0; idx < 40 && itemIndex == -1; ++idx) {
|
||||
if (itemName == g_vm->_itemIds[idx])
|
||||
itemIndex = idx;
|
||||
}
|
||||
if (itemIndex == -1)
|
||||
return -1;
|
||||
|
||||
// Some objects can be in multiple different states. These are handled
|
||||
// below to give each the correct inventory glyph and description
|
||||
switch (ITEM_MODES[itemIndex]) {
|
||||
case 0:
|
||||
// Maitre d'Bot's left arm
|
||||
switch (getItemIndex(item, isLoading)) {
|
||||
case 0:
|
||||
case 1:
|
||||
return 0;
|
||||
case 2:
|
||||
case 3:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
case 2:
|
||||
// Maitre d'Bot's right arm
|
||||
switch (getItemIndex(item, isLoading)) {
|
||||
case 0:
|
||||
return 2;
|
||||
default:
|
||||
return 3;
|
||||
}
|
||||
break;
|
||||
|
||||
case 15:
|
||||
// Chicken
|
||||
switch (getItemIndex(item, isLoading)) {
|
||||
case 0:
|
||||
case 1:
|
||||
return 14;
|
||||
case 2:
|
||||
return 16;
|
||||
case 3:
|
||||
return 15;
|
||||
case 4:
|
||||
return 17;
|
||||
case 5:
|
||||
return 18;
|
||||
default:
|
||||
return 15;
|
||||
}
|
||||
break;
|
||||
|
||||
case 26:
|
||||
// Beer glass
|
||||
switch (getItemIndex(item, isLoading)) {
|
||||
case 0:
|
||||
return 26;
|
||||
case 1:
|
||||
return 29;
|
||||
case 2:
|
||||
return 28;
|
||||
case 3:
|
||||
return 27;
|
||||
default:
|
||||
return 26;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ITEM_MODES[itemIndex];
|
||||
}
|
||||
|
||||
int CPetInventoryGlyph::getItemIndex(CGameObject *item, bool isLoading) {
|
||||
int frameNum = item->getFrameNumber();
|
||||
int movieFrame = item->getMovieFrame();
|
||||
|
||||
if (isLoading && frameNum != -1 && frameNum != movieFrame) {
|
||||
item->loadFrame(frameNum);
|
||||
movieFrame = frameNum;
|
||||
}
|
||||
|
||||
return movieFrame;
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::startRepeatedMovie() {
|
||||
if (_owner) {
|
||||
CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner());
|
||||
if (section)
|
||||
section->playMovie(_repeated, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::startSingularMovie() {
|
||||
if (_owner) {
|
||||
CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner());
|
||||
if (section)
|
||||
section->playMovie(_singular, false);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::stopMovie() {
|
||||
if (_owner) {
|
||||
CPetInventory *section = dynamic_cast<CPetInventory *>(_owner->getOwner());
|
||||
if (section)
|
||||
section->playMovie(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetInventoryGlyph::reposition(const Point &pt) {
|
||||
if (_singular) {
|
||||
// Special transformation of item to piece of Titania
|
||||
_singular->setPosition(pt);
|
||||
startSingularMovie();
|
||||
} else if (_repeated) {
|
||||
// Standard repeating animation
|
||||
_repeated->setPosition(pt);
|
||||
startRepeatedMovie();
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CPetInventoryGlyphs::doAction(CInventoryGlyphAction *action) {
|
||||
for (iterator i = begin(); i != end(); ++i) {
|
||||
(*i)->doAction(action);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CGameObject *CPetInventoryGlyphs::getBackground(int index) {
|
||||
return _owner ? _owner->getBackground(index) : nullptr;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
158
engines/titanic/pet_control/pet_inventory_glyphs.h
Normal file
158
engines/titanic/pet_control/pet_inventory_glyphs.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_INVENTORY_GLYPHS_H
|
||||
#define TITANIC_PET_INVENTORY_GLYPHS_H
|
||||
|
||||
#include "titanic/carry/carry.h"
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/support/screen_manager.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetInventoryGlyph : public CPetGlyph {
|
||||
private:
|
||||
/**
|
||||
* Populate the details for an item
|
||||
*/
|
||||
int populateItem(CGameObject *item, bool isLoading);
|
||||
|
||||
/**
|
||||
* For items which can have multiple different states, such as the
|
||||
* beer glass or Maitre D arms, returns the correct item index to use
|
||||
* for getting the inventory item glyph and description
|
||||
*/
|
||||
int getItemIndex(CGameObject *item, bool isLoading);
|
||||
|
||||
/**
|
||||
* Start a repeated animation for the item
|
||||
*/
|
||||
void startRepeatedMovie();
|
||||
|
||||
/**
|
||||
* Start a singular (non-repeating) animation for the item,
|
||||
* such as an item's transformation into a piece of Titania
|
||||
*/
|
||||
void startSingularMovie();
|
||||
|
||||
/**
|
||||
* Stop any previously started foreground or background movie
|
||||
*/
|
||||
void stopMovie();
|
||||
|
||||
/**
|
||||
* Reposition the inventory item
|
||||
*/
|
||||
void reposition(const Point &pt);
|
||||
public:
|
||||
CGameObject *_item;
|
||||
bool _active;
|
||||
CGameObject *_repeated;
|
||||
CGameObject *_singular;
|
||||
public:
|
||||
CPetInventoryGlyph() : _item(nullptr), _active(true),
|
||||
_repeated(nullptr), _singular(nullptr) {}
|
||||
CPetInventoryGlyph(CCarry *item, bool active) : _item(item),
|
||||
_active(active), _repeated(nullptr), _singular(nullptr) {}
|
||||
|
||||
/**
|
||||
* Called when the PET area is entered
|
||||
*/
|
||||
void enter() override;
|
||||
|
||||
/**
|
||||
* Called when the PET area is left
|
||||
*/
|
||||
void leave() override;
|
||||
|
||||
/**
|
||||
* Draw the glyph at a specified position
|
||||
*/
|
||||
void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted) override;
|
||||
|
||||
/**
|
||||
* Unhighlight any currently highlighted element
|
||||
*/
|
||||
void unhighlightCurrent() override;
|
||||
|
||||
/**
|
||||
* Highlight any currently highlighted element
|
||||
*/
|
||||
void highlightCurrent(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Glyph has been shifted to be first visible one
|
||||
*/
|
||||
void glyphFocused(const Point &topLeft, bool flag) override;
|
||||
|
||||
/**
|
||||
* Called when a glyph drag starts
|
||||
*/
|
||||
bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
|
||||
/**
|
||||
* Return whether the glyph is currently valid
|
||||
*/
|
||||
bool isValid() const override { return _item && _repeated; }
|
||||
|
||||
/**
|
||||
* Returns the object associated with the glyph
|
||||
*/
|
||||
CGameObject *getObjectAt() override { return _item; }
|
||||
|
||||
/**
|
||||
* Does a processing action on the glyph
|
||||
*/
|
||||
bool doAction(CGlyphAction *action) override;
|
||||
|
||||
/**
|
||||
* Set the inventory item
|
||||
*/
|
||||
void setItem(CGameObject *item, bool isLoading);
|
||||
};
|
||||
|
||||
class CInventoryGlyphAction : public CGlyphAction {
|
||||
public:
|
||||
CGameObject *_item;
|
||||
public:
|
||||
CInventoryGlyphAction(CGameObject *item, GlyphActionMode mode) :
|
||||
CGlyphAction(mode), _item(item) {}
|
||||
};
|
||||
|
||||
class CPetInventoryGlyphs : public CPetGlyphs {
|
||||
friend class CPetInventoryGlyph;
|
||||
private:
|
||||
CGameObject *getBackground(int index);
|
||||
public:
|
||||
/**
|
||||
* Do an action on the glyphs
|
||||
*/
|
||||
bool doAction(CInventoryGlyphAction *item);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_INVENTORY_GLYPHS_H */
|
||||
38
engines/titanic/pet_control/pet_leaf.cpp
Normal file
38
engines/titanic/pet_control/pet_leaf.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_leaf.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(PETLeaf, CGameObject);
|
||||
|
||||
void PETLeaf::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CGameObject::save(file, indent);
|
||||
}
|
||||
|
||||
void PETLeaf::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CGameObject::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
47
engines/titanic/pet_control/pet_leaf.h
Normal file
47
engines/titanic/pet_control/pet_leaf.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_LEAF_H
|
||||
#define TITANIC_PET_LEAF_H
|
||||
|
||||
#include "titanic/core/game_object.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class PETLeaf : public CGameObject {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_LEAF_H */
|
||||
70
engines/titanic/pet_control/pet_load.cpp
Normal file
70
engines/titanic/pet_control/pet_load.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_load.h"
|
||||
#include "titanic/core/project_item.h"
|
||||
#include "titanic/game_manager.h"
|
||||
#include "titanic/main_game_window.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
bool CPetLoad::reset() {
|
||||
CPetLoadSave::reset();
|
||||
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet) {
|
||||
setName("PetLoad", pet);
|
||||
_btnLoadSave.reset("PetLoadOut", pet, MODE_UNSELECTED);
|
||||
_btnLoadSave.reset("PetLoadIn", pet, MODE_SELECTED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetLoad::MouseButtonUpMsg(const Point &pt) {
|
||||
if (_btnLoadSave.MouseButtonUpMsg(pt)) {
|
||||
execute();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetLoad::getTooltip(CTextControl *text) {
|
||||
text->setText(LOAD_THE_GAME);
|
||||
}
|
||||
|
||||
void CPetLoad::execute() {
|
||||
CPetControl *pet = getPetControl();
|
||||
|
||||
if (_savegameSlotNum >= 0 && _slotInUse[_savegameSlotNum]) {
|
||||
CMainGameWindow *window = g_vm->_window;
|
||||
|
||||
// WORKAROUND: Schedule the savegame to be loaded after frame rendering ends
|
||||
window->loadGame(_savegameSlotNum);
|
||||
} else if (pet) {
|
||||
pet->displayMessage(SELECT_GAME_TO_LOAD);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
69
engines/titanic/pet_control/pet_load.h
Normal file
69
engines/titanic/pet_control/pet_load.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_LOAD_H
|
||||
#define TITANIC_PET_LOAD_H
|
||||
|
||||
#include "titanic/pet_control/pet_load_save.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetLoad : public CPetLoadSave {
|
||||
public:
|
||||
/**
|
||||
* Reset the glyph
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Highlight any currently highlighted element
|
||||
*/
|
||||
void highlightCurrent(const Point &pt) override { resetSlots(); }
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
|
||||
/**
|
||||
* Highlights a save slot
|
||||
*/
|
||||
void highlightSave(int index) override {}
|
||||
|
||||
/**
|
||||
* Unhighlight a save slot
|
||||
*/
|
||||
void unhighlightSave(int index) override {}
|
||||
|
||||
/**
|
||||
* Executes the loading or saving
|
||||
*/
|
||||
void execute() override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_LOAD_H */
|
||||
182
engines/titanic/pet_control/pet_load_save.cpp
Normal file
182
engines/titanic/pet_control/pet_load_save.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_load_save.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/core/project_item.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
int CPetLoadSave::_savegameSlotNum;
|
||||
|
||||
bool CPetLoadSave::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetGlyph::setup(petControl, owner);
|
||||
_savegameSlotNum = -1;
|
||||
|
||||
for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) {
|
||||
Rect slotRect = getSlotBounds(idx);
|
||||
_slotNames[idx].setBounds(slotRect);
|
||||
_slotNames[idx].resize(3);
|
||||
_slotNames[idx].setMaxCharsPerLine(22);
|
||||
_slotNames[idx].setHasBorder(false);
|
||||
_slotNames[idx].setup();
|
||||
}
|
||||
|
||||
Rect r1(0, 0, 68, 52);
|
||||
r1.moveTo(496, 388);
|
||||
_btnLoadSave.setBounds(r1);
|
||||
|
||||
Rect r2(0, 0, 168, 78);
|
||||
r2.moveTo(309, 377);
|
||||
_gutter.setBounds(r2);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetLoadSave::reset() {
|
||||
highlightChange();
|
||||
resetSlots();
|
||||
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet) {
|
||||
_gutter.reset("PetSaveGutter", pet, MODE_UNSELECTED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetLoadSave::draw2(CScreenManager *screenManager) {
|
||||
_gutter.draw(screenManager);
|
||||
|
||||
for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx)
|
||||
_slotNames[idx].draw(screenManager);
|
||||
|
||||
_btnLoadSave.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetLoadSave::MouseButtonDownMsg(const Point &pt) {
|
||||
if (_btnLoadSave.MouseButtonDownMsg(pt))
|
||||
return true;
|
||||
|
||||
checkSlotsHighlight(pt);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetLoadSave::ActionMsg(CActionMsg *msg) {
|
||||
Common::CustomEventType action = msg->_action;
|
||||
switch (action) {
|
||||
case kActionDown:
|
||||
if (_savegameSlotNum != -1) {
|
||||
highlightSlot((_savegameSlotNum + 1) % 5);
|
||||
getPetControl()->makeDirty();
|
||||
}
|
||||
return true;
|
||||
|
||||
case kActionUp:
|
||||
if (_savegameSlotNum != -1) {
|
||||
int slotNum = --_savegameSlotNum;
|
||||
highlightSlot((slotNum == -1) ? SAVEGAME_SLOTS_COUNT - 1 : slotNum);
|
||||
getPetControl()->makeDirty();
|
||||
}
|
||||
return true;
|
||||
|
||||
case kActionSelect:
|
||||
execute();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Rect CPetLoadSave::getSlotBounds(int index) {
|
||||
return Rect(323, 376 + index * 16, 473, 392 + index * 16);
|
||||
}
|
||||
|
||||
void CPetLoadSave::resetSlots() {
|
||||
for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) {
|
||||
_slotNames[idx].setText(EMPTY);
|
||||
_slotInUse[idx] = false;
|
||||
|
||||
// Try and open up the savegame for access
|
||||
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(
|
||||
g_vm->getSaveStateName(idx));
|
||||
|
||||
if (in) {
|
||||
// Read in the savegame header data
|
||||
CompressedFile file;
|
||||
file.open(in);
|
||||
|
||||
TitanicSavegameHeader header;
|
||||
if (CProjectItem::readSavegameHeader(&file, header)) {
|
||||
_slotInUse[idx] = true;
|
||||
_slotNames[idx].setText(header._saveName);
|
||||
}
|
||||
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
highlightSlot(_savegameSlotNum);
|
||||
}
|
||||
|
||||
void CPetLoadSave::highlightSlot(int index) {
|
||||
unhighlightSave(_savegameSlotNum);
|
||||
_savegameSlotNum = index;
|
||||
highlightChange();
|
||||
highlightSave(_savegameSlotNum);
|
||||
}
|
||||
|
||||
void CPetLoadSave::highlightChange() {
|
||||
CPetSection *section = getPetSection();
|
||||
|
||||
uint col = section ? section->getColor(3) : 0;
|
||||
for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx)
|
||||
_slotNames[idx].setLineColor(0, col);
|
||||
|
||||
if (_savegameSlotNum != -1) {
|
||||
col = section ? section->getColor(4) : 0;
|
||||
_slotNames[_savegameSlotNum].setLineColor(0, col);
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetLoadSave::checkSlotsHighlight(const Point &pt) {
|
||||
for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) {
|
||||
if (isSlotHighlighted(idx, pt)) {
|
||||
highlightSlot(idx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetLoadSave::isSlotHighlighted(int index, const Point &pt) {
|
||||
Rect r = getSlotBounds(index);
|
||||
if (r.contains(pt)) {
|
||||
highlightSlot(index);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
120
engines/titanic/pet_control/pet_load_save.h
Normal file
120
engines/titanic/pet_control/pet_load_save.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_LOAD_SAVE_H
|
||||
#define TITANIC_PET_LOAD_SAVE_H
|
||||
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
|
||||
#include "common/events.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
#define SAVEGAME_SLOTS_COUNT 5
|
||||
|
||||
class CPetLoadSave : public CPetGlyph {
|
||||
private:
|
||||
/**
|
||||
* Get the rect area for a given savegame name will be displayed in
|
||||
*/
|
||||
Rect getSlotBounds(int index);
|
||||
|
||||
/**
|
||||
* Called when savegame slot highlight changes or the view is reset
|
||||
*/
|
||||
void highlightChange();
|
||||
|
||||
/**
|
||||
* Check for whether a slot is under the passed point
|
||||
*/
|
||||
bool checkSlotsHighlight(const Point &pt);
|
||||
|
||||
/**
|
||||
* Checks if a point is within a given saveame slot
|
||||
*/
|
||||
bool isSlotHighlighted(int index, const Point &pt);
|
||||
protected:
|
||||
CTextControl _slotNames[SAVEGAME_SLOTS_COUNT];
|
||||
bool _slotInUse[SAVEGAME_SLOTS_COUNT];
|
||||
CPetGfxElement _btnLoadSave;
|
||||
CPetGfxElement _gutter;
|
||||
static int _savegameSlotNum;
|
||||
protected:
|
||||
/**
|
||||
* Reset the slot names list
|
||||
*/
|
||||
void resetSlots();
|
||||
|
||||
/**
|
||||
* Highlight one of the slots
|
||||
*/
|
||||
void highlightSlot(int index);
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Reset the glyph
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles Actions when the glyph is focused
|
||||
*/
|
||||
bool ActionMsg(CActionMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Resets highlighting on the save slots
|
||||
*/
|
||||
virtual void resetSaves() { resetSlots(); }
|
||||
|
||||
/**
|
||||
* Highlights a save slot
|
||||
*/
|
||||
virtual void highlightSave(int index) = 0;
|
||||
|
||||
/**
|
||||
* Unhighlight a save slot
|
||||
*/
|
||||
virtual void unhighlightSave(int index) = 0;
|
||||
|
||||
/**
|
||||
* Executes the loading or saving
|
||||
*/
|
||||
virtual void execute() = 0;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif
|
||||
41
engines/titanic/pet_control/pet_mode_off.cpp
Normal file
41
engines/titanic/pet_control/pet_mode_off.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_mode_off.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetModeOff, CToggleSwitch);
|
||||
|
||||
CPetModeOff::CPetModeOff() : CToggleSwitch() {
|
||||
}
|
||||
|
||||
void CPetModeOff::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CToggleSwitch::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetModeOff::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CToggleSwitch::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
48
engines/titanic/pet_control/pet_mode_off.h
Normal file
48
engines/titanic/pet_control/pet_mode_off.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_MODE_OFF_H
|
||||
#define TITANIC_PET_MODE_OFF_H
|
||||
|
||||
#include "titanic/gfx/toggle_switch.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetModeOff : public CToggleSwitch {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
CPetModeOff();
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_MODE_OFF_H */
|
||||
41
engines/titanic/pet_control/pet_mode_on.cpp
Normal file
41
engines/titanic/pet_control/pet_mode_on.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_mode_on.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetModeOn, CToggleSwitch);
|
||||
|
||||
CPetModeOn::CPetModeOn() : CToggleSwitch() {
|
||||
}
|
||||
|
||||
void CPetModeOn::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CToggleSwitch::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetModeOn::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CToggleSwitch::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
48
engines/titanic/pet_control/pet_mode_on.h
Normal file
48
engines/titanic/pet_control/pet_mode_on.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_MODE_ON_H
|
||||
#define TITANIC_PET_MODE_ON_H
|
||||
|
||||
#include "titanic/gfx/toggle_switch.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetModeOn : public CToggleSwitch {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
CPetModeOn();
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_MODE_ON_H */
|
||||
41
engines/titanic/pet_control/pet_mode_panel.cpp
Normal file
41
engines/titanic/pet_control/pet_mode_panel.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_mode_panel.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetModePanel, CToggleSwitch);
|
||||
|
||||
CPetModePanel::CPetModePanel() : CToggleSwitch() {
|
||||
}
|
||||
|
||||
void CPetModePanel::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CToggleSwitch::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetModePanel::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CToggleSwitch::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
48
engines/titanic/pet_control/pet_mode_panel.h
Normal file
48
engines/titanic/pet_control/pet_mode_panel.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_MODE_PANEL_H
|
||||
#define TITANIC_PET_MODE_PANEL_H
|
||||
|
||||
#include "titanic/gfx/toggle_switch.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetModePanel : public CToggleSwitch {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
CPetModePanel();
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_MODE_PANEL_H */
|
||||
38
engines/titanic/pet_control/pet_pannel1.cpp
Normal file
38
engines/titanic/pet_control/pet_pannel1.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_pannel1.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetPannel1, CPetGraphic);
|
||||
|
||||
void CPetPannel1::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CPetGraphic::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetPannel1::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CPetGraphic::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
47
engines/titanic/pet_control/pet_pannel1.h
Normal file
47
engines/titanic/pet_control/pet_pannel1.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_PANNEL1_H
|
||||
#define TITANIC_PET_PANNEL1_H
|
||||
|
||||
#include "titanic/pet_control/pet_graphic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetPannel1 : public CPetGraphic {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_PANNEL1_H */
|
||||
38
engines/titanic/pet_control/pet_pannel2.cpp
Normal file
38
engines/titanic/pet_control/pet_pannel2.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_pannel2.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetPannel2, CPetGraphic);
|
||||
|
||||
void CPetPannel2::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CPetGraphic::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetPannel2::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CPetGraphic::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
47
engines/titanic/pet_control/pet_pannel2.h
Normal file
47
engines/titanic/pet_control/pet_pannel2.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_PANNEL2_H
|
||||
#define TITANIC_PET_PANNEL2_H
|
||||
|
||||
#include "titanic/pet_control/pet_graphic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetPannel2 : public CPetGraphic {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_PANNEL2_H */
|
||||
38
engines/titanic/pet_control/pet_pannel3.cpp
Normal file
38
engines/titanic/pet_control/pet_pannel3.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_pannel3.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
EMPTY_MESSAGE_MAP(CPetPannel3, CPetGraphic);
|
||||
|
||||
void CPetPannel3::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CPetGraphic::save(file, indent);
|
||||
}
|
||||
|
||||
void CPetPannel3::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CPetGraphic::load(file);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
47
engines/titanic/pet_control/pet_pannel3.h
Normal file
47
engines/titanic/pet_control/pet_pannel3.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_PANNEL3_H
|
||||
#define TITANIC_PET_PANNEL3_H
|
||||
|
||||
#include "titanic/pet_control/pet_graphic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetPannel3 : public CPetGraphic {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_PANNEL3_H */
|
||||
89
engines/titanic/pet_control/pet_quit.cpp
Normal file
89
engines/titanic/pet_control/pet_quit.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_quit.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/pet_control/pet_real_life.h"
|
||||
#include "titanic/support/rect.h"
|
||||
#include "titanic/game_manager.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
bool CPetQuit::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetGlyph::setup(petControl, owner);
|
||||
|
||||
Rect tempRect(0, 0, 280, 16);
|
||||
tempRect.moveTo(322, 407);
|
||||
_text.setBounds(tempRect);
|
||||
_text.resize(3);
|
||||
_text.setHasBorder(false);
|
||||
_text.setup();
|
||||
|
||||
Rect btnRect(0, 0, 68, 52);
|
||||
btnRect.moveTo(496, 388);
|
||||
_btnYes.setBounds(btnRect);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetQuit::reset() {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (!pet)
|
||||
return false;
|
||||
|
||||
setName("PetExit", pet);
|
||||
|
||||
uint col = getPetSection()->getColor(0);
|
||||
_text.setText(SURE_YOU_WANT_TO_QUIT);
|
||||
_text.setLineColor(0, col);
|
||||
|
||||
_btnYes.reset("PetQuitOut", pet, MODE_UNSELECTED);
|
||||
_btnYes.reset("PetQuitIn", pet, MODE_SELECTED);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetQuit::draw2(CScreenManager *screenManager) {
|
||||
_text.draw(screenManager);
|
||||
_btnYes.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetQuit::MouseButtonDownMsg(const Point &pt) {
|
||||
return !_btnYes.MouseButtonDownMsg(pt);
|
||||
}
|
||||
|
||||
bool CPetQuit::MouseButtonUpMsg(const Point &pt) {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (_btnYes.MouseButtonUpMsg(pt) && pet) {
|
||||
CGameManager *gameManager = pet->getGameManager();
|
||||
if (gameManager)
|
||||
gameManager->_gameState._quitGame = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetQuit::getTooltip(CTextControl *text) {
|
||||
text->setText(QUIT_THE_GAME);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
74
engines/titanic/pet_control/pet_quit.h
Normal file
74
engines/titanic/pet_control/pet_quit.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_QUIT_H
|
||||
#define TITANIC_PET_QUIT_H
|
||||
|
||||
#include "titanic/pet_control/pet_gfx_element.h"
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetQuit : public CPetGlyph {
|
||||
private:
|
||||
CTextControl _text;
|
||||
CPetGfxElement _btnYes;
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Reset the glyph
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
|
||||
/**
|
||||
* Get a reference to the tooltip text associated with the section
|
||||
*/
|
||||
virtual CTextControl *getText() { return &_text; }
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_QUIT_H */
|
||||
133
engines/titanic/pet_control/pet_real_life.cpp
Normal file
133
engines/titanic/pet_control/pet_real_life.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_real_life.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/pet_control/pet_load.h"
|
||||
#include "titanic/pet_control/pet_save.h"
|
||||
#include "titanic/pet_control/pet_sound.h"
|
||||
#include "titanic/pet_control/pet_quit.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
bool CPetRealLife::setup(CPetControl *petControl) {
|
||||
if (petControl && setupControl(petControl))
|
||||
return reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetRealLife::reset() {
|
||||
_glyphs.reset();
|
||||
uint col = getColor(0);
|
||||
_text.setColor(col);
|
||||
_text.setLineColor(0, col);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetRealLife::draw(CScreenManager *screenManager) {
|
||||
_petControl->drawSquares(screenManager, 4);
|
||||
_glyphs.draw(screenManager);
|
||||
_text.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetRealLife::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
return _glyphs.MouseButtonDownMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetRealLife::MouseDragStartMsg(CMouseDragStartMsg *msg) {
|
||||
return _glyphs.MouseDragStartMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetRealLife::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
|
||||
return _glyphs.MouseDragMoveMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetRealLife::MouseDragEndMsg(CMouseDragEndMsg *msg) {
|
||||
return _glyphs.MouseDragEndMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetRealLife::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
||||
return _glyphs.MouseButtonUpMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetRealLife::KeyCharMsg(CKeyCharMsg *msg) {
|
||||
return _glyphs.KeyCharMsg(msg->_key);
|
||||
}
|
||||
|
||||
bool CPetRealLife::ActionMsg(CActionMsg *msg) {
|
||||
return _glyphs.ActionMsg(msg);
|
||||
}
|
||||
|
||||
void CPetRealLife::postLoad() {
|
||||
reset();
|
||||
}
|
||||
|
||||
bool CPetRealLife::isValid(CPetControl *petControl) {
|
||||
setupControl(petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetRealLife::enter(PetArea oldArea) {
|
||||
_glyphs.enterHighlighted();
|
||||
}
|
||||
|
||||
void CPetRealLife::leave() {
|
||||
_glyphs.leaveHighlighted();
|
||||
}
|
||||
|
||||
bool CPetRealLife::setupControl(CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
_petControl = petControl;
|
||||
_glyphs.setup(4, this);
|
||||
_glyphs.setFlags(6);
|
||||
|
||||
addButton(new CPetLoad());
|
||||
addButton(new CPetSave());
|
||||
addButton(new CPetSound());
|
||||
addButton(new CPetQuit());
|
||||
|
||||
Rect textRect(0, 0, 276, 30);
|
||||
textRect.moveTo(32, 436);
|
||||
_text.setBounds(textRect);
|
||||
_text.setHasBorder(false);
|
||||
_text.setup();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetRealLife::addButton(CPetGlyph *glyph) {
|
||||
if (glyph) {
|
||||
if (glyph->setup(_petControl, &_glyphs))
|
||||
_glyphs.push_back(glyph);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetRealLife::syncSoundSettings() {
|
||||
for (CPetGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) {
|
||||
CPetSound *sound = dynamic_cast<CPetSound *>(*i);
|
||||
if (sound)
|
||||
sound->setSliders();
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
136
engines/titanic/pet_control/pet_real_life.h
Normal file
136
engines/titanic/pet_control/pet_real_life.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_REAL_LIFE_H
|
||||
#define TITANIC_PET_REAL_LIFE_H
|
||||
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetSaveGlyphs : public CPetGlyphs {
|
||||
};
|
||||
|
||||
class CPetRealLife : public CPetSection {
|
||||
private:
|
||||
CPetGlyphs _glyphs;
|
||||
CTextControl _text;
|
||||
private:
|
||||
/**
|
||||
* Does setup
|
||||
*/
|
||||
bool setupControl(CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Adds one of the four button glyphs for display
|
||||
*/
|
||||
void addButton(CPetGlyph *glyph);
|
||||
public:
|
||||
~CPetRealLife() override {}
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Reset the section
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Get the bounds for the section
|
||||
*/
|
||||
Rect getBounds() const override { return Rect(); }
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override;
|
||||
bool MouseDragStartMsg(CMouseDragStartMsg *msg) override;
|
||||
bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) override;
|
||||
bool MouseDragEndMsg(CMouseDragEndMsg *msg) override;
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override;
|
||||
bool KeyCharMsg(CKeyCharMsg *msg) override;
|
||||
bool ActionMsg(CActionMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Returns item a drag-drop operation has dropped on, if any
|
||||
*/
|
||||
CGameObject *dragEnd(const Point &pt) const override { return nullptr; }
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file, int param) override {}
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override {}
|
||||
|
||||
/**
|
||||
* Called when a section is switched to
|
||||
*/
|
||||
void enter(PetArea oldArea) override;
|
||||
|
||||
/**
|
||||
* Called when a section is being left, to switch to another area
|
||||
*/
|
||||
void leave() override;
|
||||
|
||||
/**
|
||||
* Called when a new room is entered
|
||||
*/
|
||||
void enterRoom(CRoomItem *room) override {}
|
||||
|
||||
/**
|
||||
* Get a reference to the tooltip text associated with the section
|
||||
*/
|
||||
CTextControl *getText() override { return &_text; }
|
||||
|
||||
/**
|
||||
* Handles updates to the sound levels
|
||||
*/
|
||||
void syncSoundSettings();
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_REAL_LIFE_H */
|
||||
516
engines/titanic/pet_control/pet_remote.cpp
Normal file
516
engines/titanic/pet_control/pet_remote.cpp
Normal file
@@ -0,0 +1,516 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_remote.h"
|
||||
#include "titanic/pet_control/pet_remote_glyphs.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/messages/pet_messages.h"
|
||||
#include "titanic/game_manager.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
static const byte REMOTE_DATA[] = {
|
||||
0x00, 0x02,
|
||||
GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x01, 0x02,
|
||||
GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x02, 0x03,
|
||||
GLYPH_TELEVISION_CONTROL, GLYPH_OPERATE_LIGHTS, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x03, 0x02,
|
||||
GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x04, 0x02,
|
||||
GLYPH_TELEVISION_CONTROL, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x05, 0x02,
|
||||
GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x06, 0x02,
|
||||
GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x07, 0x03,
|
||||
GLYPH_TELEVISION_CONTROL, GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x08, 0x01,
|
||||
GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x09, 0x01,
|
||||
GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x0A, 0x02,
|
||||
GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
#if defined(DISABLE_SKIP)
|
||||
0x0B, 0x01,
|
||||
GLYPH_NAVIGATION_CONTROLLER,
|
||||
#else
|
||||
0x0B, 0x02,
|
||||
GLYPH_NAVIGATION_CONTROLLER, GLYPH_SKIP_NAVIGATION,
|
||||
#endif
|
||||
0x0C, 0x01,
|
||||
GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x0D, 0x01,
|
||||
GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x0E, 0x00,
|
||||
0x0F, 0x01,
|
||||
GLYPH_TELEVISION_CONTROL,
|
||||
0x10, 0x03,
|
||||
GLYPH_GOTO_BOTTOM_OF_WELL, GLYPH_GOTO_STATEROOM, GLYPH_GOTO_TOP_OF_WELL,
|
||||
0x11, 0x01,
|
||||
GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x12, 0x00,
|
||||
0x13, 0x02,
|
||||
GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x14, 0x00,
|
||||
0x15, 0x02,
|
||||
GLYPH_SUCCUBUS_DELIVERY, GLYPH_TELEVISION_CONTROL,
|
||||
0x16, 0x00,
|
||||
0x17, 0x02,
|
||||
GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x18, 0x01,
|
||||
GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x19, 0x00,
|
||||
0x1A, 0x00,
|
||||
0x1B, 0x00,
|
||||
0x1C, 0x00,
|
||||
0x1D, 0x02,
|
||||
GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x1E, 0x0C,
|
||||
GLYPH_DEPLOY_FLORAL, GLYPH_DEPLOY_FULLY_RELAXATION, GLYPH_DEPLOY_COMFORT,
|
||||
GLYPH_DEPLOY_MINOR_STORAGE, GLYPH_ENTERTAINMENT_DEVICE,
|
||||
GLYPH_DEPLOY_MAJOR_RELAXATION, GLYPH_INFLATE_RELAXATION,
|
||||
GLYPH_DEPLOY_MAINTENANCE, GLYPH_DEPLOY_WORK_SURFACE,
|
||||
GLYPH_DEPLOY_MINOR_RELAXATION, GLYPH_DEPLOY_SINK,
|
||||
GLYPH_DEPLOY_MAJOR_STORAGE,
|
||||
0x1F, 0x01,
|
||||
GLYPH_SUCCUBUS_DELIVERY,
|
||||
0x20, 0x02,
|
||||
GLYPH_SUMMON_ELEVATOR, GLYPH_SUMMON_PELLERATOR,
|
||||
0x21, 0x00
|
||||
};
|
||||
|
||||
CPetRemote::CPetRemote() : CPetSection() {
|
||||
}
|
||||
|
||||
bool CPetRemote::setup(CPetControl *petControl) {
|
||||
if (petControl && setupControl(petControl))
|
||||
return reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetRemote::reset() {
|
||||
if (_petControl) {
|
||||
_onOff.reset("PetSwitchOn", _petControl, MODE_SELECTED);
|
||||
_onOff.reset("PetSwitchOff", _petControl, MODE_UNSELECTED);
|
||||
|
||||
_up.reset("PetUp", _petControl, MODE_UNSELECTED);
|
||||
_down.reset("PetDown", _petControl, MODE_UNSELECTED);
|
||||
|
||||
_left.reset("PetLeftUp", _petControl, MODE_UNSELECTED);
|
||||
_left.reset("PetLeft", _petControl, MODE_SELECTED);
|
||||
_right.reset("PetRightUp", _petControl, MODE_UNSELECTED);
|
||||
_right.reset("PetRight", _petControl, MODE_SELECTED);
|
||||
_top.reset("PetTopUp", _petControl, MODE_UNSELECTED);
|
||||
_top.reset("PetTop", _petControl, MODE_SELECTED);
|
||||
_bottom.reset("PetBottomUp", _petControl, MODE_UNSELECTED);
|
||||
_bottom.reset("PetBottom", _petControl, MODE_SELECTED);
|
||||
_action.reset("PetActionUp", _petControl, MODE_UNSELECTED);
|
||||
_action.reset("PetAction", _petControl, MODE_SELECTED);
|
||||
|
||||
_send.reset("PetActSend0", _petControl, MODE_UNSELECTED);
|
||||
_send.reset("PetActSend1", _petControl, MODE_SELECTED);
|
||||
_receive.reset("PetActReceive0", _petControl, MODE_UNSELECTED);
|
||||
_receive.reset("PetActReceive1", _petControl, MODE_SELECTED);
|
||||
_call.reset("PetActCall0", _petControl, MODE_UNSELECTED);
|
||||
_call.reset("PetActCall1", _petControl, MODE_SELECTED);
|
||||
|
||||
_items.reset();
|
||||
uint col = getColor(0);
|
||||
_text.setColor(col);
|
||||
_text.setLineColor(0, col);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetRemote::draw(CScreenManager *screenManager) {
|
||||
_petControl->drawSquares(screenManager, 6);
|
||||
_items.draw(screenManager);
|
||||
_text.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetRemote::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
return _items.MouseButtonDownMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetRemote::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
||||
return _items.MouseButtonUpMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetRemote::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
|
||||
return _items.MouseButtonDownMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetRemote::ActionMsg(CActionMsg *msg) {
|
||||
return _items.ActionMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetRemote::MouseWheelMsg(CMouseWheelMsg *msg) {
|
||||
if (msg->_wheelUp)
|
||||
_items.scrollLeft();
|
||||
else
|
||||
_items.scrollRight();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetRemote::isValid(CPetControl *petControl) {
|
||||
return setupControl(petControl);
|
||||
}
|
||||
|
||||
void CPetRemote::postLoad() {
|
||||
reset();
|
||||
CRoomItem *room = getRoom();
|
||||
if (room)
|
||||
enterRoom(room);
|
||||
}
|
||||
|
||||
void CPetRemote::enter(PetArea oldArea) {
|
||||
if (_items.highlighted14())
|
||||
_text.setText(CString());
|
||||
}
|
||||
|
||||
void CPetRemote::enterRoom(CRoomItem *room) {
|
||||
clearGlyphs();
|
||||
|
||||
if (room) {
|
||||
CString roomName = room->getName();
|
||||
int roomIndex = roomIndexOf(roomName);
|
||||
if (roomIndex != -1) {
|
||||
Common::Array<uint> indexes;
|
||||
if (getRemoteData(roomIndex, indexes)) {
|
||||
loadGlyphs(indexes);
|
||||
_items.scrollToStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CTextControl *CPetRemote::getText() {
|
||||
return &_text;
|
||||
}
|
||||
|
||||
CPetGfxElement *CPetRemote::getElement(uint id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return &_onOff;
|
||||
case 1:
|
||||
return &_up;
|
||||
case 2:
|
||||
return &_down;
|
||||
case 3:
|
||||
return &_left;
|
||||
case 4:
|
||||
return &_right;
|
||||
case 5:
|
||||
return &_top;
|
||||
case 6:
|
||||
return &_bottom;
|
||||
case 7:
|
||||
return &_action;
|
||||
case 16:
|
||||
return &_send;
|
||||
case 17:
|
||||
return &_receive;
|
||||
case 18:
|
||||
return &_call;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetRemote::highlight(int id) {
|
||||
int highlightIndex = getHighlightIndex((RemoteGlyph)id);
|
||||
if (highlightIndex != -1)
|
||||
_items.highlight(highlightIndex);
|
||||
}
|
||||
|
||||
bool CPetRemote::setupControl(CPetControl *petControl) {
|
||||
_petControl = petControl;
|
||||
if (!petControl)
|
||||
return false;
|
||||
|
||||
_onOff.setBounds(Rect(0, 0, 15, 43));
|
||||
_onOff.translate(519, 381);
|
||||
_up.setBounds(Rect(0, 0, 21, 24));
|
||||
_up.translate(551, 381);
|
||||
_down.setBounds(Rect(0, 0, 21, 24));
|
||||
_down.translate(551, 402);
|
||||
_left.setBounds(Rect(0, 0, 22, 21));
|
||||
_left.translate(518, 393);
|
||||
_right.setBounds(Rect(0, 0, 21, 21));
|
||||
_right.translate(560, 393);
|
||||
_top.setBounds(Rect(0, 0, 21, 22));
|
||||
_top.translate(539, 371);
|
||||
_bottom.setBounds(Rect(0, 0, 21, 22));
|
||||
_bottom.translate(539, 414);
|
||||
_action.setBounds(Rect(0, 0, 21, 21));
|
||||
_action.translate(539, 393);
|
||||
_send.setBounds(Rect(0, 0, 62, 38));
|
||||
_send.translate(503, 373);
|
||||
_receive.setBounds(Rect(0, 0, 62, 38));
|
||||
_receive.translate(503, 420);
|
||||
_call.setBounds(Rect(0, 0, 62, 38));
|
||||
_call.translate(503, 383);
|
||||
|
||||
Rect rect(0, 0, 580, 15);
|
||||
rect.moveTo(32, 445);
|
||||
_text.setBounds(rect);
|
||||
_text.setHasBorder(false);
|
||||
|
||||
_items.setup(6, this);
|
||||
_items.setFlags(19);
|
||||
return true;
|
||||
}
|
||||
|
||||
CRoomItem *CPetRemote::getRoom() const {
|
||||
if (_petControl) {
|
||||
CGameManager *gameManager = _petControl->getGameManager();
|
||||
if (gameManager)
|
||||
return gameManager->getRoom();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int CPetRemote::getHighlightIndex(RemoteGlyph val) {
|
||||
CRoomItem *room = getRoom();
|
||||
if (!room)
|
||||
return -1;
|
||||
|
||||
int roomIndex = roomIndexOf(room->getName());
|
||||
if (roomIndex == -1)
|
||||
return -1;
|
||||
|
||||
Common::Array<uint> remoteData;
|
||||
getRemoteData(roomIndex, remoteData);
|
||||
|
||||
// Loop through the data for the room
|
||||
for (uint idx = 0; idx < remoteData.size(); ++idx) {
|
||||
if ((RemoteGlyph)remoteData[idx] == val)
|
||||
return idx;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CPetRemote::roomIndexOf(const CString &name) {
|
||||
for (int idx = 0; idx < TOTAL_ROOMS; ++idx) {
|
||||
if (g_vm->_roomNames[idx] == name)
|
||||
return idx;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CPetRemote::getRemoteData(int roomIndex, Common::Array<uint> &indexes) {
|
||||
const byte *p = &REMOTE_DATA[0];
|
||||
for (int idx = 0; idx < TOTAL_ROOMS; ++idx) {
|
||||
if (*p == roomIndex) {
|
||||
for (int ctr = 0; ctr < p[1]; ++ctr)
|
||||
indexes.push_back(p[ctr + 2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
p += *(p + 1) + 2;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetRemote::loadGlyphs(const Common::Array<uint> &indexes) {
|
||||
for (uint idx = 0; idx < indexes.size(); ++idx) {
|
||||
if (!loadGlyph(indexes[idx]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetRemote::loadGlyph(int glyphIndex) {
|
||||
CPetRemoteGlyph *glyph = nullptr;
|
||||
|
||||
switch (glyphIndex) {
|
||||
case GLYPH_SUMMON_ELEVATOR:
|
||||
glyph = new CSummonElevatorGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_SUMMON_PELLERATOR:
|
||||
glyph = new CSummonPelleratorGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_TELEVISION_CONTROL:
|
||||
glyph = new CTelevisionControlGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_ENTERTAINMENT_DEVICE:
|
||||
glyph = new CEntertainmentDeviceGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_OPERATE_LIGHTS:
|
||||
glyph = new COperateLightsGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_FLORAL:
|
||||
glyph = new CDeployFloralGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_FULLY_RELAXATION:
|
||||
glyph = new CDeployFullyRelaxationGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_COMFORT:
|
||||
glyph = new CDeployComfortGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_MINOR_STORAGE:
|
||||
glyph = new CDeployMinorStorageGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_MAJOR_RELAXATION:
|
||||
glyph = new CDeployMajorRelaxationGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_INFLATE_RELAXATION:
|
||||
glyph = new CInflateRelaxationGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_MAINTENANCE:
|
||||
glyph = new CDeployMaintenanceGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_WORK_SURFACE:
|
||||
glyph = new CDeployWorkSurfaceGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_MINOR_RELAXATION:
|
||||
glyph = new CDeployMinorRelaxationGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_SINK:
|
||||
glyph = new CDeploySinkGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_DEPLOY_MAJOR_STORAGE:
|
||||
glyph = new CDeployMajorStorageGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_SUCCUBUS_DELIVERY:
|
||||
glyph = new CSuccubusDeliveryGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_NAVIGATION_CONTROLLER:
|
||||
glyph = new CNavigationControllerGlyph();
|
||||
break;
|
||||
|
||||
#if !defined(DISABLE_SKIP)
|
||||
case GLYPH_SKIP_NAVIGATION:
|
||||
glyph = new CSkipNavigationGlyph();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case GLYPH_GOTO_BOTTOM_OF_WELL:
|
||||
glyph = new CGotoBottomOfWellGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_GOTO_TOP_OF_WELL:
|
||||
glyph = new CGotoTopOfWellGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_GOTO_STATEROOM:
|
||||
glyph = new CGotoStateroomGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_GOTO_BAR:
|
||||
glyph = new CGotoBarGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_GOTO_PROMENADE:
|
||||
glyph = new CGotoPromenadeDeckGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_GOTO_ARBORETUM:
|
||||
glyph = new CGotoArboretumGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_GOTO_MUSIC_ROOM:
|
||||
glyph = new CGotoMusicRoomGlyph();
|
||||
break;
|
||||
|
||||
case GLYPH_GOTO_RESTAURANT:
|
||||
glyph = new CGotoRestaurantGlyph();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (glyph) {
|
||||
if (glyph->setup(_petControl, &_items)) {
|
||||
_items.push_back(glyph);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetRemote::generateMessage(RemoteMessage msgNum, const CString &name, int num) {
|
||||
switch (msgNum) {
|
||||
case RMSG_LEFT: {
|
||||
CPETLeftMsg msg(name, num);
|
||||
msg.execute(_petControl->_remoteTarget);
|
||||
break;
|
||||
}
|
||||
|
||||
case RMSG_RIGHT: {
|
||||
CPETRightMsg msg(name, num);
|
||||
msg.execute(_petControl->_remoteTarget);
|
||||
break;
|
||||
}
|
||||
|
||||
case RMSG_UP: {
|
||||
CPETUpMsg msg(name, num);
|
||||
msg.execute(_petControl->_remoteTarget);
|
||||
break;
|
||||
}
|
||||
|
||||
case RMSG_DOWN: {
|
||||
CPETDownMsg msg(name, num);
|
||||
msg.execute(_petControl->_remoteTarget);
|
||||
break;
|
||||
}
|
||||
|
||||
case RMSG_ACTIVATE: {
|
||||
CPETActivateMsg msg(name, num);
|
||||
msg.execute(_petControl->_remoteTarget);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
159
engines/titanic/pet_control/pet_remote.h
Normal file
159
engines/titanic/pet_control/pet_remote.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_REMOTE_H
|
||||
#define TITANIC_PET_REMOTE_H
|
||||
|
||||
#include "common/array.h"
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/pet_control/pet_remote_glyphs.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetRemote : public CPetSection {
|
||||
private:
|
||||
CPetRemoteGlyphs _items;
|
||||
CPetGfxElement _onOff;
|
||||
CPetGfxElement _up;
|
||||
CPetGfxElement _down;
|
||||
CPetGfxElement _left;
|
||||
CPetGfxElement _right;
|
||||
CPetGfxElement _top;
|
||||
CPetGfxElement _bottom;
|
||||
CPetGfxElement _action;
|
||||
CPetGfxElement _send;
|
||||
CPetGfxElement _receive;
|
||||
CPetGfxElement _call;
|
||||
CTextControl _text;
|
||||
private:
|
||||
/**
|
||||
* Setup the control
|
||||
*/
|
||||
bool setupControl(CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Get the current room
|
||||
*/
|
||||
CRoomItem *getRoom() const;
|
||||
|
||||
/**
|
||||
* Return a highlight index
|
||||
*/
|
||||
int getHighlightIndex(RemoteGlyph val);
|
||||
|
||||
/**
|
||||
* Return the index of a room name in the master room names list
|
||||
*/
|
||||
int roomIndexOf(const CString &name);
|
||||
|
||||
/**
|
||||
* Return a list of remote action glyph indexes for a given room
|
||||
*/
|
||||
bool getRemoteData(int roomIndex, Common::Array<uint> &indexes);
|
||||
|
||||
/**
|
||||
* Clear the list of rooms glyphs
|
||||
*/
|
||||
void clearGlyphs() { _items.clear(); }
|
||||
|
||||
/**
|
||||
* Load the room glyphs
|
||||
*/
|
||||
bool loadGlyphs(const Common::Array<uint> &indexes);
|
||||
|
||||
/**
|
||||
* Load a single room glyph
|
||||
*/
|
||||
bool loadGlyph(int glyphIndex);
|
||||
public:
|
||||
CPetRemote();
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Reset the section
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override;
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override;
|
||||
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) override;
|
||||
bool ActionMsg(CActionMsg *msg) override;
|
||||
bool MouseWheelMsg(CMouseWheelMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override;
|
||||
|
||||
/**
|
||||
* Called when a section is switched to
|
||||
*/
|
||||
void enter(PetArea oldArea) override;
|
||||
|
||||
/**
|
||||
* Called when a new room is entered
|
||||
*/
|
||||
void enterRoom(CRoomItem *room) override;
|
||||
|
||||
/**
|
||||
* Get a reference to the tooltip text associated with the section
|
||||
*/
|
||||
CTextControl *getText() override;
|
||||
|
||||
/**
|
||||
* Get an element from the section by a designated Id
|
||||
*/
|
||||
CPetGfxElement *getElement(uint id) override;
|
||||
|
||||
/**
|
||||
* Highlights a glyph item in the section
|
||||
*/
|
||||
void highlight(int id) override;
|
||||
|
||||
/**
|
||||
* Generates a PET message
|
||||
*/
|
||||
void generateMessage(RemoteMessage msgNum, const CString &name, int num);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_REMOTE_H */
|
||||
668
engines/titanic/pet_control/pet_remote_glyphs.cpp
Normal file
668
engines/titanic/pet_control/pet_remote_glyphs.cpp
Normal file
@@ -0,0 +1,668 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_remote_glyphs.h"
|
||||
#include "titanic/game_manager.h"
|
||||
#include "titanic/messages/pet_messages.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/pet_control/pet_remote.h"
|
||||
#include "titanic/star_control/star_control.h"
|
||||
#include "titanic/support/strings.h"
|
||||
#include "titanic/titanic.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetRemote *CPetRemoteGlyphs::getOwner() const {
|
||||
return dynamic_cast<CPetRemote *>(_owner);
|
||||
}
|
||||
|
||||
void CPetRemoteGlyphs::generateMessage(RemoteMessage msgNum, const CString &name, int num) {
|
||||
getOwner()->generateMessage(msgNum, name, num);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void CPetRemoteGlyph::setDefaults(const CString &name, CPetControl *petControl) {
|
||||
_element.setBounds(Rect(0, 0, 52, 52));
|
||||
_element.setup(MODE_UNSELECTED, name, petControl);
|
||||
}
|
||||
|
||||
CPetRemoteGlyphs *CPetRemoteGlyph::getOwner() const {
|
||||
return dynamic_cast<CPetRemoteGlyphs *>(_owner);
|
||||
}
|
||||
|
||||
CPetGfxElement *CPetRemoteGlyph::getElement(uint id) const {
|
||||
CPetRemote *remote = static_cast<CPetRemote *>(_owner->getOwner());
|
||||
return remote->getElement(id);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CBasicRemoteGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults(_gfxName, petControl);
|
||||
if (owner)
|
||||
_callButton = getElement(18);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CBasicRemoteGlyph::draw2(CScreenManager *screenManager) {
|
||||
if (_callButton)
|
||||
_callButton->draw(screenManager);
|
||||
}
|
||||
|
||||
bool CBasicRemoteGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
return _callButton && _callButton->MouseButtonDownMsg(pt);
|
||||
}
|
||||
|
||||
bool CBasicRemoteGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
if (_callButton && _callButton->MouseButtonUpMsg(pt)) {
|
||||
getOwner()->generateMessage(RMSG_ACTIVATE, _msgString);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CBasicRemoteGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(_tooltip);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CToggleRemoteGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetGlyph::setup(petControl, owner);
|
||||
if (owner)
|
||||
_toggle = getElement(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CToggleRemoteGlyph::draw2(CScreenManager *screenManager) {
|
||||
_toggle->setMode(_toggleFlag ? MODE_SELECTED : MODE_UNSELECTED);
|
||||
_toggle->draw(screenManager);
|
||||
}
|
||||
|
||||
bool CToggleRemoteGlyph::elementMouseButtonDownMsg(const Point &pt, int petNum) {
|
||||
return _toggle->MouseButtonDownMsg(pt);
|
||||
}
|
||||
|
||||
bool CToggleRemoteGlyph::elementMouseButtonUpMsg(const Point &pt, int petNum) {
|
||||
if (!_toggle->MouseButtonUpMsg(pt))
|
||||
return false;
|
||||
|
||||
CTreeItem *target = getPetControl()->_remoteTarget;
|
||||
if (target) {
|
||||
CPETActivateMsg msg("SGTSelector", petNum);
|
||||
msg.execute(target);
|
||||
_toggleFlag = !_toggleFlag;
|
||||
_toggle->setMode(_toggleFlag ? MODE_SELECTED : MODE_UNSELECTED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CRemoteGotoGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults(_gfxName, petControl);
|
||||
|
||||
if (owner)
|
||||
_goButton = getElement(7);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CRemoteGotoGlyph::draw2(CScreenManager *screenManager) {
|
||||
if (_goButton)
|
||||
_goButton->draw(screenManager);
|
||||
}
|
||||
|
||||
bool CRemoteGotoGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
return _goButton && _goButton->MouseButtonDownMsg(pt);
|
||||
}
|
||||
|
||||
bool CRemoteGotoGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
if (!_goButton || !_goButton->MouseButtonUpMsg(pt))
|
||||
return false;
|
||||
|
||||
CPetControl *petControl = getPetControl();
|
||||
if (petControl) {
|
||||
CGameManager *gameManager = petControl->getGameManager();
|
||||
|
||||
if (gameManager) {
|
||||
CRoomItem *room = gameManager->getRoom();
|
||||
|
||||
if (room) {
|
||||
CTransportMsg msg(g_vm->_roomNames[_roomIndex], 1, 0);
|
||||
msg.execute(room);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CRemoteGotoGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(_tooltip);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CTelevisionControlGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetTV", petControl);
|
||||
if (owner) {
|
||||
_up = getElement(1);
|
||||
_down = getElement(2);
|
||||
_onOff = getElement(0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CTelevisionControlGlyph::draw2(CScreenManager *screenManager) {
|
||||
_onOff->setSelected(_flag);
|
||||
_onOff->draw(screenManager);
|
||||
_up->draw(screenManager);
|
||||
_down->draw(screenManager);
|
||||
}
|
||||
|
||||
bool CTelevisionControlGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
if (_onOff && _onOff->MouseButtonDownMsg(pt))
|
||||
return true;
|
||||
if (_up && _up->MouseButtonDownMsg(pt))
|
||||
return true;
|
||||
if (_down && _down->MouseButtonDownMsg(pt))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CTelevisionControlGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
if (_onOff && _onOff->MouseButtonUpMsg(pt)) {
|
||||
_flag = !_flag;
|
||||
getOwner()->generateMessage(RMSG_ACTIVATE, "Television");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_up && _up->MouseButtonUpMsg(pt)) {
|
||||
getOwner()->generateMessage(RMSG_UP, "Television");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_down && _down->MouseButtonUpMsg(pt)) {
|
||||
getOwner()->generateMessage(RMSG_DOWN, "Television");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CTelevisionControlGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(TELEVISION_CONTROL);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CEntertainmentDeviceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetSGTtv", petControl);
|
||||
if (owner) {
|
||||
_up = getElement(1);
|
||||
_down = getElement(2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEntertainmentDeviceGlyph::draw2(CScreenManager *screenManager) {
|
||||
CString viewName = getPetControl()->getFullViewName();
|
||||
if (viewName == "SGTState.Node 1.S") {
|
||||
_toggle->setSelected(_toggleFlag);
|
||||
_toggle->draw(screenManager);
|
||||
} else if (viewName == "SGTState.Node 4.E") {
|
||||
_toggle->setSelected(_flag2);
|
||||
_toggle->draw(screenManager);
|
||||
_up->draw(screenManager);
|
||||
_down->draw(screenManager);
|
||||
}
|
||||
}
|
||||
|
||||
bool CEntertainmentDeviceGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
CString viewName = getPetControl()->getFullViewName();
|
||||
if (viewName == "SGTState.Node 1.S") {
|
||||
return elementMouseButtonDownMsg(pt, 4);
|
||||
} else if (viewName == "SGTState.Node 4.E") {
|
||||
return _toggle->MouseButtonDownMsg(pt)
|
||||
|| _up->MouseButtonDownMsg(pt)
|
||||
|| _down->MouseButtonDownMsg(pt);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEntertainmentDeviceGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
CString viewName = getPetControl()->getFullViewName();
|
||||
if (viewName == "SGTState.Node 1.S") {
|
||||
return elementMouseButtonUpMsg(pt, 4);
|
||||
} else if (viewName == "SGTState.Node 4.E") {
|
||||
if (_toggle->MouseButtonUpMsg(pt)) {
|
||||
_flag2 = !_flag2;
|
||||
getOwner()->generateMessage(RMSG_ACTIVATE, "Television");
|
||||
return true;
|
||||
} else if (_up->MouseButtonUpMsg(pt)) {
|
||||
getOwner()->generateMessage(RMSG_UP, "Television");
|
||||
return true;
|
||||
} else if (_down->MouseButtonUpMsg(pt)) {
|
||||
getOwner()->generateMessage(RMSG_DOWN, "Television");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CEntertainmentDeviceGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(OPERATE_ENTERTAINMENT);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool COperateLightsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetLights", petControl);
|
||||
|
||||
if (owner) {
|
||||
_left = getElement(3);
|
||||
_right = getElement(4);
|
||||
_up = getElement(5);
|
||||
_down = getElement(6);
|
||||
_activate = getElement(7);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void COperateLightsGlyph::draw2(CScreenManager *screenManager) {
|
||||
_left->draw(screenManager);
|
||||
_right->draw(screenManager);
|
||||
_up->draw(screenManager);
|
||||
_down->draw(screenManager);
|
||||
_activate->draw(screenManager);
|
||||
}
|
||||
|
||||
bool COperateLightsGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
if (_left->MouseButtonDownMsg(pt)
|
||||
|| _right->MouseButtonDownMsg(pt)
|
||||
|| _up->MouseButtonDownMsg(pt)
|
||||
|| _down->MouseButtonDownMsg(pt)
|
||||
|| _activate->MouseButtonDownMsg(pt))
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COperateLightsGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
if (_left && _left->MouseButtonUpMsg(pt))
|
||||
getOwner()->generateMessage(RMSG_LEFT, "Light");
|
||||
else if (_right && _right->MouseButtonUpMsg(pt))
|
||||
getOwner()->generateMessage(RMSG_RIGHT, "Light");
|
||||
else if (_up && _up->MouseButtonUpMsg(pt))
|
||||
getOwner()->generateMessage(RMSG_UP, "Light");
|
||||
else if (_down && _down->MouseButtonUpMsg(pt))
|
||||
getOwner()->generateMessage(RMSG_DOWN, "Light");
|
||||
else if (_activate && _activate->MouseButtonUpMsg(pt))
|
||||
getOwner()->generateMessage(RMSG_ACTIVATE, "Light");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void COperateLightsGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(OPERATE_LIGHTS);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployFloralGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetVase", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployFloralGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_FLORAL_ENHANCEMENT);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployFullyRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetBedfoot", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployFullyRelaxationGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_FULLY_RELAXATION);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployComfortGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetToilet", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployComfortGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_COMFORT_WORKSTATION);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployMinorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetDraw", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployMinorStorageGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_MINOR_STORAGE);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployMajorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetArmChair", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployMajorRelaxationGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_MAJOR_RELAXATION);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CInflateRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetBedhead", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CInflateRelaxationGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(INFLATE_RELAXATION_DEVICE);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployMaintenanceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetWashstand", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployMaintenanceGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_MAINTENANCE_HUB);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployWorkSurfaceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetTable", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployWorkSurfaceGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_EXECUTIVE_SURFACE);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployMinorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetDeskchair", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployMinorRelaxationGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_MINOR_RELAXATION);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeploySinkGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetBasin", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeploySinkGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_SINK);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CDeployMajorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CToggleRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetChest", petControl);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDeployMajorStorageGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(DEPLOY_MAJOR_STORAGE);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CSuccubusDeliveryGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetSuccubus", petControl);
|
||||
|
||||
if (owner) {
|
||||
_send = getElement(16);
|
||||
_receive = getElement(17);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSuccubusDeliveryGlyph::draw2(CScreenManager *screenManager) {
|
||||
_send->draw(screenManager);
|
||||
_receive->draw(screenManager);
|
||||
}
|
||||
|
||||
bool CSuccubusDeliveryGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
return _send->MouseButtonDownMsg(pt)
|
||||
|| _receive->MouseButtonDownMsg(pt);
|
||||
}
|
||||
|
||||
bool CSuccubusDeliveryGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
CTreeItem *target = getPetControl()->_remoteTarget;
|
||||
|
||||
if (_send && _send->MouseButtonUpMsg(pt)) {
|
||||
if (target) {
|
||||
CPETDeliverMsg msg;
|
||||
msg.execute(target);
|
||||
}
|
||||
} else if (_receive && _receive->MouseButtonUpMsg(pt)) {
|
||||
if (target) {
|
||||
CPETReceiveMsg msg;
|
||||
msg.execute(target);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSuccubusDeliveryGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(SUCCUBUS_DELIVERY_SYSTEM);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CNavigationControllerGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetStarField", petControl);
|
||||
|
||||
if (owner)
|
||||
_gfxElement = getElement(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CNavigationControllerGlyph::draw2(CScreenManager *screenManager) {
|
||||
_gfxElement->setMode(_flag ? MODE_SELECTED : MODE_UNSELECTED);
|
||||
_gfxElement->draw(screenManager);
|
||||
}
|
||||
|
||||
bool CNavigationControllerGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
return _gfxElement->MouseButtonDownMsg(pt);
|
||||
}
|
||||
|
||||
bool CNavigationControllerGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
if (!_gfxElement->MouseButtonUpMsg(pt))
|
||||
return false;
|
||||
|
||||
CPetControl *pet = getPetControl();
|
||||
CStarControl *starControl = pet->getStarControl();
|
||||
_flag = !_flag;
|
||||
|
||||
if (!starControl->isSkipped()) {
|
||||
CTreeItem *target = pet->_remoteTarget;
|
||||
if (target) {
|
||||
CPETHelmetOnOffMsg msg;
|
||||
msg.execute(target);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CNavigationControllerGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(NAVIGATION_CONTROLLER);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CSummonElevatorGlyph::CSummonElevatorGlyph() : CBasicRemoteGlyph(
|
||||
"3PetLift", g_vm->_strings[SUMMON_ELEVATOR], "Lift") {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CSummonPelleratorGlyph::CSummonPelleratorGlyph() : CBasicRemoteGlyph(
|
||||
"3PetPellerator", g_vm->_strings[SUMMON_PELLERATOR], "Pellerator") {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoBottomOfWellGlyph::CGotoBottomOfWellGlyph() : CRemoteGotoGlyph("3PetBotOfWell",
|
||||
g_vm->_strings[GO_TO_BOTTOM_OF_WELL], 10) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoTopOfWellGlyph::CGotoTopOfWellGlyph() : CRemoteGotoGlyph("3PetTopOfWell",
|
||||
g_vm->_strings[GO_TO_TOP_OF_WELL], 32) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoStateroomGlyph::CGotoStateroomGlyph() : CRemoteGotoGlyph("3PetRoom",
|
||||
g_vm->_strings[GO_TO_STATEROOM], 33) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoBarGlyph::CGotoBarGlyph() : CRemoteGotoGlyph("3PetBar",
|
||||
g_vm->_strings[GO_TO_BAR], 7) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoPromenadeDeckGlyph::CGotoPromenadeDeckGlyph() : CRemoteGotoGlyph("3PetPromDeck",
|
||||
g_vm->_strings[GO_TO_PROMENADE_DECK], 23) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoArboretumGlyph::CGotoArboretumGlyph() : CRemoteGotoGlyph("3PetArboretum",
|
||||
g_vm->_strings[GO_TO_ARBORETUM], 5) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoMusicRoomGlyph::CGotoMusicRoomGlyph() : CRemoteGotoGlyph("3PetMusicRoom",
|
||||
g_vm->_strings[GO_TO_MUSIC_ROOM], 20) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CGotoRestaurantGlyph::CGotoRestaurantGlyph() : CRemoteGotoGlyph("3Pet1stClassRest",
|
||||
g_vm->_strings[GO_TO_1ST_CLASS_RESTAURANT], 1) {
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
bool CSkipNavigationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetRemoteGlyph::setup(petControl, owner);
|
||||
setDefaults("3PetTV", petControl);
|
||||
if (owner) {
|
||||
_button = getElement(7);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSkipNavigationGlyph::draw2(CScreenManager *screenManager) {
|
||||
_button->draw(screenManager);
|
||||
}
|
||||
|
||||
bool CSkipNavigationGlyph::MouseButtonDownMsg(const Point &pt) {
|
||||
if (_button && _button->MouseButtonDownMsg(pt))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSkipNavigationGlyph::MouseButtonUpMsg(const Point &pt) {
|
||||
if (_button && _button->MouseButtonUpMsg(pt)) {
|
||||
CPetRemote *remote = static_cast<CPetRemote *>(_owner->getOwner());
|
||||
CStarControl *starControl = remote->getPetControl()->getStarControl();
|
||||
starControl->forceSolved();
|
||||
|
||||
CActMsg actMsg("SetDestin");
|
||||
actMsg.execute("CaptainsWheel");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSkipNavigationGlyph::getTooltip(CTextControl *text) {
|
||||
text->setText(SKIP_NAVIGATION);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
736
engines/titanic/pet_control/pet_remote_glyphs.h
Normal file
736
engines/titanic/pet_control/pet_remote_glyphs.h
Normal file
@@ -0,0 +1,736 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_REMOTE_GLYPHS_H
|
||||
#define TITANIC_PET_REMOTE_GLYPHS_H
|
||||
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/pet_control/pet_gfx_element.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
enum RemoteGlyph {
|
||||
GLYPH_SUMMON_ELEVATOR = 0, GLYPH_SUMMON_PELLERATOR = 1,
|
||||
GLYPH_TELEVISION_CONTROL = 2, GLYPH_ENTERTAINMENT_DEVICE = 3,
|
||||
GLYPH_OPERATE_LIGHTS = 4, GLYPH_DEPLOY_FLORAL = 5,
|
||||
GLYPH_DEPLOY_FULLY_RELAXATION = 6, GLYPH_DEPLOY_COMFORT = 7,
|
||||
GLYPH_DEPLOY_MINOR_STORAGE = 8, GLYPH_DEPLOY_MAJOR_RELAXATION = 9,
|
||||
GLYPH_INFLATE_RELAXATION = 10, GLYPH_DEPLOY_MAINTENANCE = 11,
|
||||
GLYPH_DEPLOY_WORK_SURFACE = 12, GLYPH_DEPLOY_MINOR_RELAXATION = 13,
|
||||
GLYPH_DEPLOY_SINK = 14, GLYPH_DEPLOY_MAJOR_STORAGE = 15,
|
||||
GLYPH_SUCCUBUS_DELIVERY = 16, GLYPH_NAVIGATION_CONTROLLER = 17,
|
||||
GLYPH_SKIP_NAVIGATION = 18, GLYPH_GOTO_BOTTOM_OF_WELL = 19,
|
||||
GLYPH_GOTO_TOP_OF_WELL = 20, GLYPH_GOTO_STATEROOM = 21,
|
||||
GLYPH_GOTO_BAR = 22, GLYPH_GOTO_PROMENADE = 23, GLYPH_GOTO_ARBORETUM = 24,
|
||||
GLYPH_GOTO_MUSIC_ROOM = 25, GLYPH_GOTO_RESTAURANT = 26
|
||||
};
|
||||
|
||||
enum RemoteMessage {
|
||||
RMSG_LEFT = 0, RMSG_RIGHT = 1, RMSG_UP = 2, RMSG_DOWN = 3, RMSG_ACTIVATE = 4
|
||||
};
|
||||
|
||||
class CPetRemote;
|
||||
|
||||
class CPetRemoteGlyphs : public CPetGlyphs {
|
||||
public:
|
||||
/**
|
||||
* Returns the owning CPetRemote
|
||||
*/
|
||||
CPetRemote *getOwner() const;
|
||||
|
||||
/**
|
||||
* Generates a PET message
|
||||
*/
|
||||
void generateMessage(RemoteMessage msgNum, const CString &name, int num = -1);
|
||||
};
|
||||
|
||||
class CPetRemoteGlyph : public CPetGlyph {
|
||||
protected:
|
||||
CPetGfxElement *_callButton;
|
||||
protected:
|
||||
CPetRemoteGlyph() : CPetGlyph(), _callButton(nullptr) {}
|
||||
|
||||
/**
|
||||
* Set defaults for the glyph
|
||||
*/
|
||||
void setDefaults(const CString &name, CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Get the owner
|
||||
*/
|
||||
CPetRemoteGlyphs *getOwner() const;
|
||||
|
||||
/**
|
||||
* Get an element by id from the parent Remote section
|
||||
*/
|
||||
CPetGfxElement *getElement(uint id) const;
|
||||
};
|
||||
|
||||
class CBasicRemoteGlyph : public CPetRemoteGlyph {
|
||||
private:
|
||||
CString _gfxName, _tooltip, _msgString;
|
||||
public:
|
||||
CBasicRemoteGlyph(const CString &gfxName, const CString &tooltip,
|
||||
const CString &msgString) : CPetRemoteGlyph(),
|
||||
_gfxName(gfxName), _tooltip(tooltip), _msgString(msgString) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CToggleRemoteGlyph : public CPetRemoteGlyph {
|
||||
protected:
|
||||
CPetGfxElement *_toggle;
|
||||
bool _toggleFlag;
|
||||
public:
|
||||
CToggleRemoteGlyph() : CPetRemoteGlyph(), _toggle(nullptr), _toggleFlag(false) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages to the default element
|
||||
*/
|
||||
bool elementMouseButtonDownMsg(const Point &pt, int petNum);
|
||||
|
||||
/**
|
||||
* Called for mouse button up messages to the default element
|
||||
*/
|
||||
bool elementMouseButtonUpMsg(const Point &pt, int petNum);
|
||||
};
|
||||
|
||||
class CRemoteGotoGlyph : public CPetRemoteGlyph {
|
||||
protected:
|
||||
int _roomIndex;
|
||||
CPetGfxElement *_goButton;
|
||||
CString _gfxName, _tooltip;
|
||||
public:
|
||||
CRemoteGotoGlyph() : CPetRemoteGlyph(), _goButton(nullptr), _roomIndex(21) {}
|
||||
CRemoteGotoGlyph(const CString &gfxName, const CString &tooltip, int roomIndex) :
|
||||
CPetRemoteGlyph(), _gfxName(gfxName), _tooltip(tooltip), _roomIndex(roomIndex),
|
||||
_goButton(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CSummonElevatorGlyph : public CBasicRemoteGlyph {
|
||||
public:
|
||||
CSummonElevatorGlyph();
|
||||
};
|
||||
|
||||
class CSummonPelleratorGlyph : public CBasicRemoteGlyph {
|
||||
public:
|
||||
CSummonPelleratorGlyph();
|
||||
};
|
||||
|
||||
class CTelevisionControlGlyph : public CPetRemoteGlyph {
|
||||
private:
|
||||
bool _flag;
|
||||
CPetGfxElement *_up, *_down, *_onOff;
|
||||
public:
|
||||
CTelevisionControlGlyph() : CPetRemoteGlyph(), _flag(false),
|
||||
_up(nullptr), _down(nullptr), _onOff(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CEntertainmentDeviceGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
bool _flag2;
|
||||
CPetGfxElement *_up, *_down;
|
||||
public:
|
||||
CEntertainmentDeviceGlyph() : CToggleRemoteGlyph(),
|
||||
_flag2(false), _up(nullptr), _down(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
|
||||
class COperateLightsGlyph : public CPetRemoteGlyph {
|
||||
public:
|
||||
CPetGfxElement *_left, *_right, *_up, *_down, *_activate;
|
||||
public:
|
||||
COperateLightsGlyph() : CPetRemoteGlyph(), _left(nullptr), _right(nullptr),
|
||||
_up(nullptr), _down(nullptr), _activate(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployFloralGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployFullyRelaxationGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployComfortGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployMinorStorageGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployMajorRelaxationGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CInflateRelaxationGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployMaintenanceGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 7);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 7);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployWorkSurfaceGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployMinorRelaxationGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeploySinkGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CDeployMajorStorageGlyph : public CToggleRemoteGlyph {
|
||||
public:
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override {
|
||||
return elementMouseButtonDownMsg(pt, 11);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override {
|
||||
return elementMouseButtonUpMsg(pt, 11);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CSuccubusDeliveryGlyph : public CPetRemoteGlyph {
|
||||
private:
|
||||
CPetGfxElement *_send, *_receive;
|
||||
public:
|
||||
CSuccubusDeliveryGlyph() : CPetRemoteGlyph(),
|
||||
_send(nullptr), _receive(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CNavigationControllerGlyph : public CPetRemoteGlyph {
|
||||
private:
|
||||
bool _flag;
|
||||
CPetGfxElement *_gfxElement;
|
||||
public:
|
||||
CNavigationControllerGlyph() : CPetRemoteGlyph(),
|
||||
_flag(false), _gfxElement(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
class CGotoBottomOfWellGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoBottomOfWellGlyph();
|
||||
};
|
||||
|
||||
class CGotoTopOfWellGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoTopOfWellGlyph();
|
||||
};
|
||||
|
||||
class CGotoStateroomGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoStateroomGlyph();
|
||||
};
|
||||
|
||||
class CGotoBarGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoBarGlyph();
|
||||
};
|
||||
|
||||
class CGotoPromenadeDeckGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoPromenadeDeckGlyph();
|
||||
};
|
||||
|
||||
class CGotoArboretumGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoArboretumGlyph();
|
||||
};
|
||||
|
||||
class CGotoMusicRoomGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoMusicRoomGlyph();
|
||||
};
|
||||
|
||||
class CGotoRestaurantGlyph : public CRemoteGotoGlyph {
|
||||
public:
|
||||
CGotoRestaurantGlyph();
|
||||
};
|
||||
|
||||
class CSkipNavigationGlyph : public CPetRemoteGlyph {
|
||||
protected:
|
||||
CPetGfxElement *_button;
|
||||
public:
|
||||
CSkipNavigationGlyph() : CPetRemoteGlyph(), _button(nullptr) {}
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_REMOTE_GLYPHS_H */
|
||||
380
engines/titanic/pet_control/pet_rooms.cpp
Normal file
380
engines/titanic/pet_control/pet_rooms.cpp
Normal file
@@ -0,0 +1,380 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_rooms.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/translation.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetRooms::CPetRooms() :
|
||||
_chevLeftOnDim(nullptr), _chevLeftOffDim(nullptr),
|
||||
_chevRightOnDim(nullptr), _chevRightOffDim(nullptr),
|
||||
_chevLeftOnLit(nullptr), _chevLeftOffLit(nullptr),
|
||||
_chevRightOnLit(nullptr), _chevRightOffLit(nullptr),
|
||||
_floorNum(1), _elevatorNum(0), _roomNum(0), _sublevel(1),
|
||||
_wellEntry(0), _elevatorBroken(true) {
|
||||
}
|
||||
|
||||
bool CPetRooms::setup(CPetControl *petControl) {
|
||||
if (petControl && setupControl(petControl))
|
||||
return reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetRooms::reset() {
|
||||
if (_petControl) {
|
||||
_plinth.reset("PetChevPlinth", _petControl, MODE_UNSELECTED);
|
||||
_glyphs.reset();
|
||||
|
||||
uint col = getColor(0);
|
||||
_text.setColor(col);
|
||||
_text.setLineColor(0, col);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetRooms::draw(CScreenManager *screenManager) {
|
||||
_petControl->drawSquares(screenManager, 6);
|
||||
_plinth.draw(screenManager);
|
||||
_glyphs.draw(screenManager);
|
||||
_glyphItem.drawAt(screenManager, getGlyphPos(), false);
|
||||
_text.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetRooms::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
if (_glyphs.MouseButtonDownMsg(msg->_mousePos))
|
||||
return true;
|
||||
|
||||
if (!_glyphItem.contains(getGlyphPos(), msg->_mousePos))
|
||||
return false;
|
||||
|
||||
_glyphItem.selectGlyph(getGlyphPos(), msg->_mousePos);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetRooms::MouseDragStartMsg(CMouseDragStartMsg *msg) {
|
||||
if (_glyphs.MouseDragStartMsg(msg))
|
||||
return true;
|
||||
|
||||
Point topLeft = getGlyphPos();
|
||||
if (!_glyphItem.contains(topLeft, msg->_mousePos))
|
||||
return false;
|
||||
|
||||
_glyphItem.dragGlyph(topLeft, msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetRooms::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetRooms::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
|
||||
return !_glyphs.MouseButtonDownMsg(msg->_mousePos);
|
||||
}
|
||||
|
||||
bool CPetRooms::ActionMsg(CActionMsg *msg) {
|
||||
return _glyphs.ActionMsg(msg);
|
||||
}
|
||||
|
||||
bool CPetRooms::checkDragEnd(CGameObject *item) {
|
||||
// Ignore any item drops except onto mail items
|
||||
if (!item->_isPendingMail)
|
||||
return false;
|
||||
|
||||
uint roomFlags = item->_destRoomFlags;
|
||||
CPetRoomsGlyph *glyph = _glyphs.findGlyphByFlags(roomFlags);
|
||||
if (glyph) {
|
||||
if (_glyphs.findGlyphByFlags(0)) {
|
||||
_glyphs.highlight(glyph);
|
||||
return false;
|
||||
}
|
||||
|
||||
roomFlags = 0;
|
||||
}
|
||||
|
||||
addRoom(roomFlags, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetRooms::displayMessage(const CString &msg) {
|
||||
_glyphs.resetHighlight();
|
||||
CPetSection::displayMessage(msg);
|
||||
}
|
||||
|
||||
bool CPetRooms::isValid(CPetControl *petControl) {
|
||||
return setupControl(petControl);
|
||||
}
|
||||
|
||||
void CPetRooms::load(SimpleFile *file, int param) {
|
||||
if (!param) {
|
||||
int count = file->readNumber();
|
||||
|
||||
for (int idx = 0; idx < count; ++idx) {
|
||||
CPetRoomsGlyph *glyph = addGlyph(file->readNumber(), false);
|
||||
glyph->setMode((RoomGlyphMode)file->readNumber());
|
||||
}
|
||||
|
||||
_glyphItem.setRoomFlags(file->readNumber());
|
||||
file->readNumber();
|
||||
_floorNum = file->readNumber();
|
||||
_elevatorNum = file->readNumber();
|
||||
_roomNum = file->readNumber();
|
||||
_sublevel = file->readNumber();
|
||||
_wellEntry = file->readNumber();
|
||||
_elevatorBroken = file->readNumber();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetRooms::postLoad() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void CPetRooms::save(SimpleFile *file, int indent) {
|
||||
_glyphs.saveGlyphs(file, indent);
|
||||
_glyphItem.saveGlyph(file, indent);
|
||||
file->writeNumberLine(_floorNum, indent);
|
||||
file->writeNumberLine(_elevatorNum, indent);
|
||||
file->writeNumberLine(_roomNum, indent);
|
||||
file->writeNumberLine(_sublevel, indent);
|
||||
file->writeNumberLine(_wellEntry, indent);
|
||||
file->writeNumberLine(_elevatorBroken, indent);
|
||||
}
|
||||
|
||||
void CPetRooms::enter(PetArea oldArea) {
|
||||
if (!_glyphs.highlighted14())
|
||||
_text.setText("");
|
||||
}
|
||||
|
||||
void CPetRooms::enterRoom(CRoomItem *room) {
|
||||
if (room)
|
||||
resetHighlight();
|
||||
}
|
||||
|
||||
CTextControl *CPetRooms::getText() {
|
||||
return &_text;
|
||||
}
|
||||
|
||||
CGameObject *CPetRooms::getBackground(int index) const {
|
||||
switch (index) {
|
||||
case 8:
|
||||
return _chevLeftOnDim;
|
||||
case 9:
|
||||
return _chevLeftOffDim;
|
||||
case 10:
|
||||
return _chevLeftOnLit;
|
||||
case 11:
|
||||
return _chevLeftOffLit;
|
||||
case 12:
|
||||
return _chevRightOnDim;
|
||||
case 13:
|
||||
return _chevRightOffDim;
|
||||
case 14:
|
||||
return _chevRightOnLit;
|
||||
case 15:
|
||||
return _chevRightOffLit;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetRooms::setupControl(CPetControl *petControl) {
|
||||
_petControl = petControl;
|
||||
if (!petControl)
|
||||
return false;
|
||||
|
||||
Rect rect1(0, 0, 470, TRANSLATE(15, 32));
|
||||
rect1.moveTo(32, TRANSLATE(445, 439));
|
||||
_text.setBounds(rect1);
|
||||
_text.setHasBorder(false);
|
||||
|
||||
Rect rect2(0, 0, 81, 81);
|
||||
_plinth.setBounds(rect2);
|
||||
_plinth.translate(494, 374);
|
||||
|
||||
_chevLeftOnDim = petControl->getHiddenObject("3PetChevLeftOnDim");
|
||||
_chevLeftOffDim = petControl->getHiddenObject("3PetChevLeftOffDim");
|
||||
_chevRightOnDim = petControl->getHiddenObject("3PetChevRightOnDim");
|
||||
_chevRightOffDim = petControl->getHiddenObject("3PetChevRightOffDim");
|
||||
_chevLeftOnLit = petControl->getHiddenObject("3PetChevLeftOnLit");
|
||||
_chevLeftOffLit = petControl->getHiddenObject("3PetChevLeftOffLit");
|
||||
_chevRightOnLit = petControl->getHiddenObject("3PetChevRightOnLit");
|
||||
_chevRightOffLit = petControl->getHiddenObject("3PetChevRightOffLit");
|
||||
|
||||
_glyphs.setup(6, this);
|
||||
_glyphs.setFlags(GFLAG_16);
|
||||
_glyphItem.setup(petControl, &_glyphs);
|
||||
_glyphItem.setFlag(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetRooms::resetHighlight() {
|
||||
_glyphItem.setRoomFlags(getRoomFlags());
|
||||
_glyphs.resetHighlight();
|
||||
_glyphItem.updateTooltip();
|
||||
areaChanged(PET_ROOMS);
|
||||
}
|
||||
|
||||
uint CPetRooms::getRoomFlags() const {
|
||||
CRoomFlags roomFlags;
|
||||
CString roomName = _petControl->getRoomName();
|
||||
|
||||
uint flags = roomFlags.getSpecialRoomFlags(roomName);
|
||||
if (flags)
|
||||
return flags;
|
||||
|
||||
PassengerClass classNum = roomFlags.whatPassengerClass(_floorNum);
|
||||
roomFlags.setPassengerClassBits(classNum);
|
||||
roomFlags.setFloorNum(_floorNum);
|
||||
|
||||
switch (classNum) {
|
||||
case FIRST_CLASS:
|
||||
roomFlags.setElevatorNum(_elevatorNum);
|
||||
roomFlags.setRoomBits(_roomNum);
|
||||
break;
|
||||
|
||||
case SECOND_CLASS:
|
||||
if (_roomNum > 0) {
|
||||
if (_roomNum >= 3) {
|
||||
roomFlags.setElevatorNum(_elevatorNum == 1 || _elevatorNum == 2 ? 1 : 3);
|
||||
} else {
|
||||
roomFlags.setElevatorNum(_elevatorNum == 1 || _elevatorNum == 2 ? 2 : 4);
|
||||
}
|
||||
|
||||
roomFlags.setRoomBits(((_roomNum - 1) & 1) + (_sublevel > 1 ? 3 : 1));
|
||||
} else {
|
||||
roomFlags.setRoomBits(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case THIRD_CLASS:
|
||||
roomFlags.setElevatorNum(_elevatorNum);
|
||||
roomFlags.setRoomBits(_roomNum + _sublevel * 6 - 6);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return roomFlags.get();
|
||||
}
|
||||
|
||||
void CPetRooms::reassignRoom(PassengerClass passClassNum) {
|
||||
CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom();
|
||||
if (glyph)
|
||||
// Flag the old assigned room as no longer assigned
|
||||
glyph->setMode(RGM_PREV_ASSIGNED_ROOM);
|
||||
|
||||
CRoomFlags roomFlags;
|
||||
roomFlags.setRandomLocation(passClassNum, _elevatorBroken);
|
||||
glyph = addRoom(roomFlags, true);
|
||||
if (glyph) {
|
||||
// Flag the new room as assigned to the player, and highlight it
|
||||
glyph->setMode(RGM_ASSIGNED_ROOM);
|
||||
_glyphs.highlight(glyph);
|
||||
}
|
||||
}
|
||||
|
||||
CPetRoomsGlyph *CPetRooms::addRoom(uint roomFlags, bool highlight_) {
|
||||
// Ensure that we don't add room if the room is already present
|
||||
if (_glyphs.hasFlags(roomFlags))
|
||||
return nullptr;
|
||||
|
||||
if (_glyphs.size() >= 32) {
|
||||
// Too many room glyphs present. Scan for and remove the first
|
||||
// glyph that isn't for an assigned bedroom
|
||||
for (CPetRoomsGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) {
|
||||
CPetRoomsGlyph *glyph = dynamic_cast<CPetRoomsGlyph *>(*i);
|
||||
if (!glyph->isAssigned()) {
|
||||
_glyphs.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the glyph
|
||||
return addGlyph(roomFlags, highlight_);
|
||||
}
|
||||
|
||||
CPetRoomsGlyph *CPetRooms::addGlyph(uint roomFlags, bool highlight_) {
|
||||
CPetRoomsGlyph *glyph = new CPetRoomsGlyph(roomFlags);
|
||||
if (!glyph->setup(_petControl, &_glyphs)) {
|
||||
delete glyph;
|
||||
return nullptr;
|
||||
} else {
|
||||
_glyphs.push_back(glyph);
|
||||
if (highlight_)
|
||||
_glyphs.highlight(glyph);
|
||||
|
||||
return glyph;
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetRooms::changeLocationClass(PassengerClass newClassNum) {
|
||||
CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom();
|
||||
if (!glyph)
|
||||
return 0;
|
||||
|
||||
glyph->changeClass(newClassNum);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetRooms::isAssignedRoom(uint roomFlags) const {
|
||||
for (CPetRoomsGlyphs::const_iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) {
|
||||
const CPetRoomsGlyph *glyph = static_cast<const CPetRoomsGlyph *>(*i);
|
||||
if (glyph->isAssigned() && glyph->getRoomFlags() == roomFlags)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uint CPetRooms::getAssignedRoomFlags() const {
|
||||
CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom();
|
||||
return glyph ? glyph->getRoomFlags() : 0;
|
||||
}
|
||||
|
||||
int CPetRooms::getAssignedRoomNum() const {
|
||||
uint flags = getAssignedRoomFlags();
|
||||
if (!flags)
|
||||
return 0;
|
||||
|
||||
return CRoomFlags(flags).getRoomNum();
|
||||
}
|
||||
|
||||
int CPetRooms::getAssignedFloorNum() const {
|
||||
uint flags = getAssignedRoomFlags();
|
||||
if (!flags)
|
||||
return 0;
|
||||
|
||||
return CRoomFlags(flags).getFloorNum();
|
||||
}
|
||||
|
||||
int CPetRooms::getAssignedElevatorNum() const {
|
||||
uint flags = getAssignedRoomFlags();
|
||||
if (!flags)
|
||||
return 0;
|
||||
|
||||
return CRoomFlags(flags).getElevatorNum();
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
223
engines/titanic/pet_control/pet_rooms.h
Normal file
223
engines/titanic/pet_control/pet_rooms.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_ROOMS_H
|
||||
#define TITANIC_PET_ROOMS_H
|
||||
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
#include "titanic/pet_control/pet_rooms_glyphs.h"
|
||||
#include "titanic/game_location.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetRooms : public CPetSection {
|
||||
private:
|
||||
CPetRoomsGlyphs _glyphs;
|
||||
CPetRoomsGlyph _glyphItem;
|
||||
CGameObject *_chevLeftOnDim;
|
||||
CGameObject *_chevLeftOffDim;
|
||||
CGameObject *_chevRightOnDim;
|
||||
CGameObject *_chevRightOffDim;
|
||||
CGameObject *_chevLeftOnLit;
|
||||
CGameObject *_chevLeftOffLit;
|
||||
CGameObject *_chevRightOnLit;
|
||||
CGameObject *_chevRightOffLit;
|
||||
CPetGfxElement _plinth;
|
||||
CTextControl _text;
|
||||
int _floorNum;
|
||||
int _elevatorNum;
|
||||
int _roomNum;
|
||||
int _sublevel;
|
||||
int _wellEntry;
|
||||
bool _elevatorBroken;
|
||||
private:
|
||||
/**
|
||||
* Setup the control
|
||||
*/
|
||||
bool setupControl(CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Returns the glyth position
|
||||
*/
|
||||
Point getGlyphPos() const { return Point(509, 388); }
|
||||
|
||||
/**
|
||||
* Adds a glyph to the list
|
||||
*/
|
||||
CPetRoomsGlyph *addRoom(uint roomFlags, bool highlight);
|
||||
|
||||
/**
|
||||
* Adds a glyph to the list
|
||||
*/
|
||||
CPetRoomsGlyph *addGlyph(uint roomFlags, bool highlight);
|
||||
public:
|
||||
CPetRooms();
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Reset the section
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override;
|
||||
bool MouseDragStartMsg(CMouseDragStartMsg *msg) override;
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override;
|
||||
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) override;
|
||||
bool ActionMsg(CActionMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Check whether a drag drop can occur
|
||||
*/
|
||||
bool checkDragEnd(CGameObject *item) override;
|
||||
|
||||
/**
|
||||
* Display a message
|
||||
*/
|
||||
void displayMessage(const CString &msg) override;
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file, int param) override;
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Called when a section is switched to
|
||||
*/
|
||||
void enter(PetArea oldArea) override;
|
||||
|
||||
/**
|
||||
* Called when a new room is entered
|
||||
*/
|
||||
void enterRoom(CRoomItem *room) override;
|
||||
|
||||
/**
|
||||
* Get a reference to the tooltip text associated with the section
|
||||
*/
|
||||
CTextControl *getText() override;
|
||||
|
||||
/**
|
||||
* Special retrieval of glyph background image
|
||||
*/
|
||||
CGameObject *getBackground(int index) const override;
|
||||
|
||||
/**
|
||||
* Reset the highlight
|
||||
*/
|
||||
void resetHighlight();
|
||||
|
||||
/**
|
||||
* Gives the player a new assigned room in the specified passenger class
|
||||
*/
|
||||
void reassignRoom(PassengerClass passClassNum);
|
||||
|
||||
/**
|
||||
* Change the current location passenger class
|
||||
*/
|
||||
bool changeLocationClass(PassengerClass newClassNum);
|
||||
|
||||
/**
|
||||
* Returns true if the specified location is the current or
|
||||
* previously assigned room
|
||||
*/
|
||||
bool isAssignedRoom(uint roomFlags) const;
|
||||
|
||||
/**
|
||||
* Returns the room flags for the player's currently assigned room
|
||||
*/
|
||||
uint getAssignedRoomFlags() const;
|
||||
|
||||
/**
|
||||
* Returns the room number for the player's currently assigned room
|
||||
*/
|
||||
int getAssignedRoomNum() const;
|
||||
|
||||
/**
|
||||
* Returns the floor number for the player's currently assigned room
|
||||
*/
|
||||
int getAssignedFloorNum() const;
|
||||
|
||||
/**
|
||||
* Returns the elevator number for the player's currently assigned room
|
||||
*/
|
||||
int getAssignedElevatorNum() const;
|
||||
|
||||
/**
|
||||
* Gets room flags to use for glyphs
|
||||
*/
|
||||
uint getRoomFlags() const;
|
||||
|
||||
void setFloorNum(int floorNum) { _floorNum = floorNum; }
|
||||
int getFloorNum() const { return _floorNum; }
|
||||
void setElevatorNum(int elevNum) { _elevatorNum = elevNum; }
|
||||
int getElevatorNum() const { return _elevatorNum; }
|
||||
void setRoomNum(int roomNum) { _roomNum = roomNum; }
|
||||
int getRoomNum() const { return _roomNum; }
|
||||
void setSublevel(int level) { _sublevel = level; }
|
||||
int getSublevel() const { return _sublevel; }
|
||||
|
||||
/**
|
||||
* Sets the entry number for arriving at the well
|
||||
*/
|
||||
void setWellEntry(int val) { _wellEntry = val; }
|
||||
|
||||
/**
|
||||
* Gets the entry number used when last arriving at the well
|
||||
*/
|
||||
int getWellEntry() const { return _wellEntry; }
|
||||
|
||||
/**
|
||||
* Sets the broken elevator flag
|
||||
*/
|
||||
void setElevatorBroken(bool flag) { _elevatorBroken = flag; }
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_ROOMS_H */
|
||||
261
engines/titanic/pet_control/pet_rooms_glyphs.cpp
Normal file
261
engines/titanic/pet_control/pet_rooms_glyphs.cpp
Normal file
@@ -0,0 +1,261 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_rooms_glyphs.h"
|
||||
#include "titanic/events.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/room_flags.h"
|
||||
#include "titanic/support/screen_manager.h"
|
||||
#include "titanic/support/simple_file.h"
|
||||
#include "titanic/titanic.h"
|
||||
#include "titanic/translation.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetRoomsGlyph::CPetRoomsGlyph() : CPetGlyph(),
|
||||
_roomFlags(0), _mailFlag(0), _mode(RGM_UNASSIGNED),
|
||||
_chevLeftOnDim(nullptr), _chevLeftOffDim(nullptr), _chevLeftOnLit(nullptr), _chevLeftOffLit(nullptr),
|
||||
_chevRightOnDim(nullptr), _chevRightOffDim(nullptr), _chevRightOnLit(nullptr), _chevRightOffLit(nullptr) {
|
||||
}
|
||||
|
||||
CPetRoomsGlyph::CPetRoomsGlyph(uint flags) : CPetGlyph(),
|
||||
_roomFlags(flags), _mailFlag(0), _mode(RGM_UNASSIGNED),
|
||||
_chevLeftOnDim(nullptr), _chevLeftOffDim(nullptr), _chevLeftOnLit(nullptr), _chevLeftOffLit(nullptr),
|
||||
_chevRightOnDim(nullptr), _chevRightOffDim(nullptr), _chevRightOnLit(nullptr), _chevRightOffLit(nullptr) {
|
||||
}
|
||||
|
||||
bool CPetRoomsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
if (!CPetGlyph::setup(petControl, owner))
|
||||
return false;
|
||||
|
||||
CPetSection *section = owner->getOwner();
|
||||
_chevLeftOnDim = section->getBackground(8);
|
||||
_chevLeftOffDim = section->getBackground(9);
|
||||
_chevRightOnDim = section->getBackground(12);
|
||||
_chevRightOffDim = section->getBackground(13);
|
||||
_chevLeftOnLit = section->getBackground(10);
|
||||
_chevLeftOffLit = section->getBackground(11);
|
||||
_chevRightOnLit = section->getBackground(14);
|
||||
_chevRightOffLit = section->getBackground(15);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) {
|
||||
// Clear background
|
||||
Rect rect(pt.x, pt.y, pt.x + 52, pt.y + 52);
|
||||
screenManager->fillRect(SURFACE_BACKBUFFER, &rect, 0, 0, 0);
|
||||
|
||||
CRoomFlags roomFlags(_roomFlags);
|
||||
uint elevBits = roomFlags.getElevatorBits();
|
||||
uint classBits = roomFlags.getPassengerClassBits();
|
||||
uint floorBits = roomFlags.getFloorBits();
|
||||
uint roomBits = roomFlags.getRoomBits();
|
||||
|
||||
// Save a copy of object pointers that may be modified
|
||||
CGameObject *leftOnDim = _chevLeftOnDim;
|
||||
CGameObject *leftOffDim = _chevLeftOffDim;
|
||||
CGameObject *rightOnDim = _chevRightOnDim;
|
||||
CGameObject *rightOffDim = _chevRightOffDim;
|
||||
|
||||
if (_mailFlag || isHighlighted_) {
|
||||
_chevLeftOnDim = _chevLeftOnLit;
|
||||
_chevLeftOffDim = _chevLeftOffLit;
|
||||
_chevRightOnDim = _chevRightOnLit;
|
||||
_chevRightOffDim = _chevRightOffLit;
|
||||
}
|
||||
|
||||
// Draw the chevron fragments for each line
|
||||
Point destPt = pt;
|
||||
drawObjects(classBits + elevBits * 4, destPt, screenManager);
|
||||
destPt.y += 10;
|
||||
drawObjects((floorBits >> 4) & 15, destPt, screenManager);
|
||||
destPt.y += 10;
|
||||
drawObjects(floorBits & 15, destPt, screenManager);
|
||||
destPt.y += 10;
|
||||
drawObjects(roomBits >> 3, destPt, screenManager);
|
||||
destPt.y += 10;
|
||||
drawObjects(((roomBits & 7) << 1) + (roomFlags.getBit0() ? 1 : 0),
|
||||
destPt, screenManager);
|
||||
|
||||
// Restore original image pointers
|
||||
_chevLeftOnDim = leftOnDim;
|
||||
_chevLeftOffDim = leftOffDim;
|
||||
_chevRightOnDim = rightOnDim;
|
||||
_chevRightOffDim = rightOffDim;
|
||||
}
|
||||
|
||||
void CPetRoomsGlyph::selectGlyph(const Point &topLeft, const Point &pt) {
|
||||
if (!isAssigned()) {
|
||||
bool isShiftPressed = g_vm->_events->getSpecialButtons() & MK_SHIFT;
|
||||
|
||||
if (isShiftPressed) {
|
||||
int selection = getSelection(topLeft, pt);
|
||||
if (selection >= 0)
|
||||
_roomFlags ^= 1 << selection;
|
||||
}
|
||||
|
||||
updateTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetRoomsGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) {
|
||||
bool isShiftPressed = g_vm->_events->getSpecialButtons() & MK_SHIFT;
|
||||
CPetControl *petControl = getPetControl();
|
||||
|
||||
if (!isShiftPressed && petControl) {
|
||||
CGameObject *chevron = petControl->getHiddenObject("3PetChevron");
|
||||
|
||||
if (chevron) {
|
||||
chevron->_destRoomFlags = _roomFlags;
|
||||
chevron->_isPendingMail = _mailFlag != 0;
|
||||
petControl->removeFromInventory(chevron, false, false);
|
||||
chevron->loadSurface();
|
||||
|
||||
chevron->dragMove(msg->_mousePos);
|
||||
msg->_handled = true;
|
||||
|
||||
if (msg->execute(chevron))
|
||||
return true;
|
||||
|
||||
petControl->moveToHiddenRoom(chevron);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetRoomsGlyph::getTooltip(CTextControl *text) {
|
||||
CRoomFlags roomFlags(_roomFlags);
|
||||
CPetRooms *owner = static_cast<CPetRooms *>(getPetSection());
|
||||
|
||||
CString prefix;
|
||||
if (isCurrentlyAssigned()) {
|
||||
prefix = g_vm->_strings[YOUR_ASSIGNED_ROOM];
|
||||
} else if (isPreviouslyAssigned()) {
|
||||
prefix = g_vm->_strings[PREVIOUSLY_ASSIGNED_ROOM];
|
||||
} else if (!_mailFlag) {
|
||||
prefix = g_vm->_strings[SAVED_CHEVRON];
|
||||
} else if (_mailFlag == 1 && owner->getRoomFlags() == _roomFlags) {
|
||||
prefix = g_vm->_strings[CURRENT_LOCATION];
|
||||
}
|
||||
|
||||
// Get the room description
|
||||
CString roomStr = roomFlags.getRoomDesc();
|
||||
|
||||
if (roomStr == TRANSLATE("The Elevator", "Der Aufzug")) {
|
||||
int elevNum = owner->getElevatorNum();
|
||||
roomStr = CString::format(g_vm->_strings[ELEVATOR_NUM].c_str(), elevNum);
|
||||
}
|
||||
|
||||
roomStr += g_vm->_strings[SHIFT_CLICK_TO_EDIT];
|
||||
text->setText(prefix + roomStr);
|
||||
}
|
||||
|
||||
void CPetRoomsGlyph::saveGlyph(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(_roomFlags, indent);
|
||||
file->writeNumberLine(_mode, indent);
|
||||
}
|
||||
|
||||
bool CPetRoomsGlyph::proc33(CPetGlyph *glyph) {
|
||||
CPetRoomsGlyph *roomGlyph = static_cast<CPetRoomsGlyph *>(glyph);
|
||||
|
||||
return CPetGlyph::proc33(glyph) && _roomFlags == roomGlyph->_roomFlags;
|
||||
}
|
||||
|
||||
void CPetRoomsGlyph::loadFlags(SimpleFile *file, int val) {
|
||||
if (!val) {
|
||||
_roomFlags = file->readNumber();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetRoomsGlyph::changeClass(PassengerClass newClassNum) {
|
||||
CRoomFlags roomFlags(_roomFlags);
|
||||
roomFlags.changeClass(newClassNum);
|
||||
_roomFlags = roomFlags.get();
|
||||
}
|
||||
|
||||
int CPetRoomsGlyph::getSelection(const Point &topLeft, const Point &pt) {
|
||||
Rect rects[4] = {
|
||||
Rect(topLeft.x, topLeft.y, topLeft.x + 13, topLeft.y + 10),
|
||||
Rect(topLeft.x + 13, topLeft.y, topLeft.x + 26, topLeft.y + 10),
|
||||
Rect(topLeft.x + 26, topLeft.y, topLeft.x + 39, topLeft.y + 10),
|
||||
Rect(topLeft.x + 39, topLeft.y, topLeft.x + 52, topLeft.y + 10)
|
||||
};
|
||||
|
||||
for (int idx = 0, btnIndex = 19; idx < 5; ++idx, btnIndex -= 4) {
|
||||
// Iterate through each of the four rects, seeing if there's a match.
|
||||
// If not, move it down to the next row for the next loop iteration
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (rects[i].contains(pt))
|
||||
return btnIndex - i;
|
||||
|
||||
rects[i].translate(0, 10);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void CPetRoomsGlyph::drawObjects(uint flags, const Point &pt, CScreenManager *screenManager) {
|
||||
if (_chevLeftOnDim && _chevLeftOffDim && _chevRightOnDim && _chevRightOffDim) {
|
||||
Point destPos = pt;
|
||||
((flags & 8) ? _chevLeftOnDim : _chevLeftOffDim)->draw(screenManager, destPos);
|
||||
destPos.x += 13;
|
||||
((flags & 4) ? _chevRightOnDim : _chevRightOffDim)->draw(screenManager, destPos);
|
||||
destPos.x += 13;
|
||||
((flags & 2) ? _chevLeftOnDim : _chevLeftOffDim)->draw(screenManager, destPos);
|
||||
destPos.x += 13;
|
||||
((flags & 1) ? _chevRightOnDim : _chevRightOffDim)->draw(screenManager, destPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void CPetRoomsGlyphs::saveGlyphs(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(size(), indent);
|
||||
|
||||
for (const_iterator i = begin(); i != end(); ++i)
|
||||
(*i)->saveGlyph(file, indent);
|
||||
}
|
||||
|
||||
CPetRoomsGlyph *CPetRoomsGlyphs::findAssignedRoom() const {
|
||||
for (const_iterator i = begin(); i != end(); ++i) {
|
||||
CPetRoomsGlyph *glyph = dynamic_cast<CPetRoomsGlyph *>(*i);
|
||||
if (glyph->isCurrentlyAssigned())
|
||||
return glyph;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CPetRoomsGlyph *CPetRoomsGlyphs::findGlyphByFlags(uint flags) const {
|
||||
for (const_iterator i = begin(); i != end(); ++i) {
|
||||
CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i);
|
||||
if (glyph->getRoomFlags() == flags)
|
||||
return glyph;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
173
engines/titanic/pet_control/pet_rooms_glyphs.h
Normal file
173
engines/titanic/pet_control/pet_rooms_glyphs.h
Normal file
@@ -0,0 +1,173 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_ROOMS_GLYPHS_H
|
||||
#define TITANIC_PET_ROOMS_GLYPHS_H
|
||||
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/game_location.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class SimpleFile;
|
||||
|
||||
enum RoomGlyphMode {
|
||||
RGM_UNASSIGNED = 0, RGM_ASSIGNED_ROOM = 1, RGM_PREV_ASSIGNED_ROOM = 2
|
||||
};
|
||||
|
||||
class CPetRoomsGlyph : public CPetGlyph {
|
||||
private:
|
||||
uint _roomFlags;
|
||||
uint _mailFlag;
|
||||
RoomGlyphMode _mode;
|
||||
CGameObject *_chevLeftOnDim;
|
||||
CGameObject *_chevLeftOffDim;
|
||||
CGameObject *_chevLeftOnLit;
|
||||
CGameObject *_chevLeftOffLit;
|
||||
CGameObject *_chevRightOnDim;
|
||||
CGameObject *_chevRightOffDim;
|
||||
CGameObject *_chevRightOnLit;
|
||||
CGameObject *_chevRightOffLit;
|
||||
private:
|
||||
/**
|
||||
* Find the selected button under the given point, based on the buttons
|
||||
* starting at a designated top/left position
|
||||
*/
|
||||
int getSelection(const Point &topLeft, const Point &pt);
|
||||
|
||||
/**
|
||||
* Draws the objects
|
||||
*/
|
||||
void drawObjects(uint flags, const Point &pt, CScreenManager *screenManager);
|
||||
public:
|
||||
CPetRoomsGlyph();
|
||||
CPetRoomsGlyph(uint flags);
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Draw the glyph at a specified position
|
||||
*/
|
||||
void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted) override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override {}
|
||||
|
||||
/**
|
||||
* Selects a glyph
|
||||
*/
|
||||
void selectGlyph(const Point &topLeft, const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Called when a glyph drag starts
|
||||
*/
|
||||
bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
|
||||
/**
|
||||
* Saves the data for the glyph
|
||||
*/
|
||||
void saveGlyph(SimpleFile *file, int indent) override;
|
||||
|
||||
bool proc33(CPetGlyph *glyph) override;
|
||||
|
||||
/**
|
||||
* Loads flags for the glyph
|
||||
*/
|
||||
virtual void loadFlags(SimpleFile *file, int val);
|
||||
|
||||
/**
|
||||
* Set the room flags for the glyph
|
||||
*/
|
||||
void setRoomFlags(uint flags) { _roomFlags = flags; }
|
||||
|
||||
/**
|
||||
* Get the room flags for the glyph
|
||||
*/
|
||||
uint getRoomFlags() const { return _roomFlags; }
|
||||
|
||||
/**
|
||||
* Set mail status flag
|
||||
*/
|
||||
void setFlag(uint val) { _mailFlag = val; }
|
||||
|
||||
/**
|
||||
* Sets the mode of the glyph
|
||||
*/
|
||||
void setMode(RoomGlyphMode mode) { _mode = mode; }
|
||||
|
||||
/**
|
||||
* Change the current class
|
||||
*/
|
||||
void changeClass(PassengerClass newClassNum);
|
||||
|
||||
/**
|
||||
* Returns true if the room is either currently or previously assigned
|
||||
*/
|
||||
bool isAssigned() const { return _mode != RGM_UNASSIGNED; }
|
||||
|
||||
/**
|
||||
* Returns true if the room is the one currently assigned to the player
|
||||
*/
|
||||
bool isCurrentlyAssigned() const { return _mode == RGM_ASSIGNED_ROOM; }
|
||||
|
||||
/**
|
||||
* Returns true if the room was previously assigned to the player
|
||||
*/
|
||||
bool isPreviouslyAssigned() const { return _mode == RGM_PREV_ASSIGNED_ROOM; }
|
||||
};
|
||||
|
||||
class CPetRoomsGlyphs : public CPetGlyphs {
|
||||
private:
|
||||
public:
|
||||
/**
|
||||
* Save the list
|
||||
*/
|
||||
void saveGlyphs(SimpleFile *file, int indent);
|
||||
|
||||
/**
|
||||
* Returns the glyph for hte player's assigned room
|
||||
*/
|
||||
CPetRoomsGlyph *findAssignedRoom() const;
|
||||
|
||||
/**
|
||||
* Finds a glyph in the list by it's room flags
|
||||
*/
|
||||
CPetRoomsGlyph *findGlyphByFlags(uint flags) const;
|
||||
|
||||
/**
|
||||
* Returns true if there's a glyph in the list with a given room flags
|
||||
*/
|
||||
bool hasFlags(uint flags) const { return findGlyphByFlags(flags) != nullptr; }
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_ROOMS_GLYPHS_H */
|
||||
100
engines/titanic/pet_control/pet_save.cpp
Normal file
100
engines/titanic/pet_control/pet_save.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_save.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/core/project_item.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
bool CPetSave::reset() {
|
||||
CPetLoadSave::reset();
|
||||
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet) {
|
||||
setName("PetSave", pet);
|
||||
_btnLoadSave.reset("PetSaveOut", pet, MODE_UNSELECTED);
|
||||
_btnLoadSave.reset("PetSaveIn", pet, MODE_SELECTED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetSave::MouseButtonUpMsg(const Point &pt) {
|
||||
if (_btnLoadSave.MouseButtonUpMsg(pt)) {
|
||||
execute();
|
||||
resetSlots();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CPetSave::KeyCharMsg(int key) {
|
||||
if (_savegameSlotNum != -1)
|
||||
_slotNames[_savegameSlotNum].handleKey(key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetSave::ActionMsg(CActionMsg *msg) {
|
||||
if (CPetLoadSave::ActionMsg(msg))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetSave::highlightCurrent(const Point &pt) {
|
||||
resetSlots();
|
||||
highlightSave(_savegameSlotNum);
|
||||
}
|
||||
|
||||
void CPetSave::getTooltip(CTextControl *text) {
|
||||
text->setText(SAVE_THE_GAME);
|
||||
}
|
||||
|
||||
void CPetSave::highlightSave(int index) {
|
||||
if (index >= 0)
|
||||
_slotNames[index].showCursor(-2);
|
||||
}
|
||||
|
||||
void CPetSave::unhighlightSave(int index) {
|
||||
if (index >= 0)
|
||||
_slotNames[index].hideCursor();
|
||||
}
|
||||
|
||||
void CPetSave::execute() {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (_savegameSlotNum >= 0) {
|
||||
int slotNumber = _savegameSlotNum;
|
||||
highlightSlot(-1);
|
||||
CProjectItem *project = pet ? pet->getRoot() : nullptr;
|
||||
|
||||
if (project) {
|
||||
project->saveGame(slotNumber, _slotNames[slotNumber].getText());
|
||||
pet->displayMessage(BLANK);
|
||||
}
|
||||
} else if (pet) {
|
||||
pet->displayMessage(SELECT_GAME_TO_SAVE);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
97
engines/titanic/pet_control/pet_save.h
Normal file
97
engines/titanic/pet_control/pet_save.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_SAVE_H
|
||||
#define TITANIC_PET_SAVE_H
|
||||
|
||||
#include "titanic/pet_control/pet_load_save.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetSave : public CPetLoadSave {
|
||||
public:
|
||||
/**
|
||||
* Reset the glyph
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Handles keypresses when the glyph is focused
|
||||
*/
|
||||
bool KeyCharMsg(int key) override;
|
||||
|
||||
/**
|
||||
* Handles actions when the glyph is focused
|
||||
*/
|
||||
bool ActionMsg(CActionMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Unhighlight any currently highlighted element
|
||||
*/
|
||||
void unhighlightCurrent() override { unhighlightSave(_savegameSlotNum); }
|
||||
|
||||
/**
|
||||
* Highlight any currently highlighted element
|
||||
*/
|
||||
void highlightCurrent(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
|
||||
/**
|
||||
* Called on a highlighted item when PET area is entered
|
||||
*/
|
||||
bool enterHighlighted() override {
|
||||
highlightSave(_savegameSlotNum);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on a highlighted item when PET area is left
|
||||
*/
|
||||
void leaveHighlighted() override { unhighlightSave(_savegameSlotNum); }
|
||||
|
||||
/**
|
||||
* Highlights a save slot
|
||||
*/
|
||||
void highlightSave(int index) override;
|
||||
|
||||
/**
|
||||
* Unhighlight a save slot
|
||||
*/
|
||||
void unhighlightSave(int index) override;
|
||||
|
||||
/**
|
||||
* Executes the loading or saving
|
||||
*/
|
||||
void execute() override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_SAVE_H */
|
||||
109
engines/titanic/pet_control/pet_section.cpp
Normal file
109
engines/titanic/pet_control/pet_section.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/textconsole.h"
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
static const uint PALETTE1[6] = {
|
||||
0xA7C0DB, 0x9CFFFE, 0x73AEFF, 0xA7C0DB, 0x9CFFFE, 0
|
||||
};
|
||||
|
||||
static const uint PALETTE2[6] = {
|
||||
0x10101, 0x1013C, 0xC80101, 0x10101, 0x800101, 0
|
||||
};
|
||||
|
||||
static const uint PALETTE3[5] = {
|
||||
0x10101, 0x1013C, 0xC80101, 0x10101, 0x800101
|
||||
};
|
||||
|
||||
void CPetSection::displayMessage(const CString &msg) {
|
||||
CTextControl *text = getText();
|
||||
|
||||
if (text) {
|
||||
text->setColor(getColor(1));
|
||||
text->setText(msg);
|
||||
_petControl->makeDirty();
|
||||
removeText(5000);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetSection::timerExpired(int val) {
|
||||
if (!val) {
|
||||
removeText();
|
||||
_petControl->makeDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetSection::removeText(int duration) {
|
||||
if (duration > 0)
|
||||
_petControl->startPetTimer(0, duration, 0, this);
|
||||
else
|
||||
removeText();
|
||||
}
|
||||
|
||||
void CPetSection::removeText() {
|
||||
CTextControl *text = getText();
|
||||
if (text)
|
||||
text->setup();
|
||||
}
|
||||
|
||||
void CPetSection::stopTextTimer() {
|
||||
_petControl->stopPetTimer(0);
|
||||
}
|
||||
|
||||
uint CPetSection::getColor(uint index) {
|
||||
return getColorTable()[index];
|
||||
}
|
||||
|
||||
const uint *CPetSection::getColorTable(int tableNum) {
|
||||
if (tableNum == -1) {
|
||||
CPetControl *pet = getPetControl();
|
||||
tableNum = pet ? pet->getPassengerClass() : 3;
|
||||
}
|
||||
|
||||
switch (tableNum) {
|
||||
case 1: return PALETTE1;
|
||||
case 2: return PALETTE2;
|
||||
default: return PALETTE3;
|
||||
}
|
||||
}
|
||||
|
||||
void CPetSection::areaChanged(PetArea area) {
|
||||
if (_petControl && _petControl->_currentArea == area)
|
||||
_petControl->makeDirty();
|
||||
}
|
||||
|
||||
CString CPetSection::getActiveNPCName() const {
|
||||
if (_petControl && _petControl->_activeNPC)
|
||||
return _petControl->_activeNPC->getName();
|
||||
else
|
||||
return CString();
|
||||
}
|
||||
|
||||
void CPetSection::copyColors(uint tableNum, uint colors[5]) {
|
||||
const uint *src = getColorTable(tableNum);
|
||||
Common::copy(src, src + 5, colors);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
250
engines/titanic/pet_control/pet_section.h
Normal file
250
engines/titanic/pet_control/pet_section.h
Normal file
@@ -0,0 +1,250 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_SECTION_H
|
||||
#define TITANIC_PET_SECTION_H
|
||||
|
||||
#include "titanic/messages/mouse_messages.h"
|
||||
#include "titanic/support/simple_file.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
enum PetArea {
|
||||
PET_INVENTORY = 0, PET_CONVERSATION = 1, PET_REMOTE = 2,
|
||||
PET_ROOMS = 3, PET_REAL_LIFE = 4, PET_STARFIELD = 5, PET_TRANSLATION = 6
|
||||
};
|
||||
|
||||
class CPetControl;
|
||||
class CPetElement;
|
||||
class CTextControl;
|
||||
class CScreenManager;
|
||||
class CRoomItem;
|
||||
|
||||
struct CPetSectionSubData {
|
||||
int _field0;
|
||||
int _field4;
|
||||
int _field8;
|
||||
int _fieldC;
|
||||
|
||||
CPetSectionSubData() : _field0(0), _field4(0), _field8(0),
|
||||
_fieldC(0) {}
|
||||
};
|
||||
|
||||
class CPetSection {
|
||||
public:
|
||||
CPetControl *_petControl;
|
||||
protected:
|
||||
/**
|
||||
* Called when the current area is changed
|
||||
*/
|
||||
void areaChanged(PetArea area);
|
||||
|
||||
/**
|
||||
* Returns the name of the currently active NPC, if any
|
||||
*/
|
||||
CString getActiveNPCName() const;
|
||||
|
||||
/**
|
||||
* Create a color table
|
||||
*/
|
||||
void copyColors(uint tableNum, uint colors[5]);
|
||||
public:
|
||||
CPetSection() : _petControl(nullptr) {}
|
||||
virtual ~CPetSection() {}
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
virtual bool setup(CPetControl *petControl) { return false; }
|
||||
|
||||
/**
|
||||
* Reset the section
|
||||
*/
|
||||
virtual bool reset() { return false; }
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
virtual void draw(CScreenManager *screenManager) {}
|
||||
|
||||
/**
|
||||
* Get the bounds for the section
|
||||
*/
|
||||
virtual Rect getBounds() const { return Rect(); }
|
||||
|
||||
/**
|
||||
* Called when a general change occurs
|
||||
*/
|
||||
virtual void changed(int changeType) {}
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) { return false; }
|
||||
virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg) { return false; }
|
||||
virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) { return false; }
|
||||
virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; }
|
||||
virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) { return false; }
|
||||
virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { return false; }
|
||||
virtual bool MouseWheelMsg(CMouseWheelMsg *msg) { return false; }
|
||||
virtual bool KeyCharMsg(CKeyCharMsg *msg) { return false; }
|
||||
virtual bool ActionMsg(CActionMsg *msg) { return false; }
|
||||
|
||||
/**
|
||||
* Check whether a drag drop can occur
|
||||
*/
|
||||
virtual bool checkDragEnd(CGameObject *item) { return false; }
|
||||
|
||||
/**
|
||||
* Returns item a drag-drop operation has dropped on, if any
|
||||
*/
|
||||
virtual CGameObject *dragEnd(const Point &pt) const { return nullptr; }
|
||||
|
||||
/**
|
||||
* Display a message
|
||||
*/
|
||||
virtual void displayMessage(const CString &msg);
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
virtual bool isValid(CPetControl *petControl) { return false; }
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
virtual void load(SimpleFile *file, int param) {}
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
virtual void postLoad() {}
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
virtual void save(SimpleFile *file, int indent) {}
|
||||
|
||||
/**
|
||||
* Called when a section is switched to
|
||||
*/
|
||||
virtual void enter(PetArea oldArea) {}
|
||||
|
||||
/**
|
||||
* Called when a section is being left, to switch to another area
|
||||
*/
|
||||
virtual void leave() {}
|
||||
|
||||
virtual void proc23() {}
|
||||
|
||||
/**
|
||||
* Called when a new room is entered
|
||||
*/
|
||||
virtual void enterRoom(CRoomItem *room) {}
|
||||
|
||||
/**
|
||||
* Called when a previously set up PET timer expires
|
||||
*/
|
||||
virtual void timerExpired(int val);
|
||||
|
||||
/**
|
||||
* Get a reference to the tooltip text associated with the section
|
||||
*/
|
||||
virtual CTextControl *getText() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Removes text after a given duration
|
||||
*/
|
||||
virtual void removeText(int duration);
|
||||
|
||||
/**
|
||||
* Removes text after a given duration
|
||||
*/
|
||||
virtual void removeText();
|
||||
|
||||
/**
|
||||
* Stops the text removal timer
|
||||
*/
|
||||
virtual void stopTextTimer();
|
||||
|
||||
/**
|
||||
* Get an element from the section by a designated Id
|
||||
*/
|
||||
virtual CPetElement *getElement(uint id) { return nullptr; }
|
||||
|
||||
/**
|
||||
* Special retrieval of glyph background image
|
||||
*/
|
||||
virtual CGameObject *getBackground(int index) const { return nullptr; }
|
||||
|
||||
/**
|
||||
* Display a title for an NPC
|
||||
*/
|
||||
virtual void displayNPCName(CGameObject *npc) {}
|
||||
|
||||
virtual void proc33() {}
|
||||
|
||||
/**
|
||||
* Sets the NPC to use
|
||||
*/
|
||||
virtual void setNPC(const CString &name) {}
|
||||
|
||||
/**
|
||||
* Resets the active NPC
|
||||
*/
|
||||
virtual void resetNPC() {}
|
||||
|
||||
/**
|
||||
* Show the text cursor
|
||||
*/
|
||||
virtual void showCursor() {}
|
||||
|
||||
/**
|
||||
* Hide the text cursor
|
||||
*/
|
||||
virtual void hideCursor() {}
|
||||
|
||||
/**
|
||||
* Highlights a glyph item in the section, if applicable
|
||||
*/
|
||||
virtual void highlight(int id) {}
|
||||
|
||||
/**
|
||||
* Get the PET control
|
||||
*/
|
||||
CPetControl *getPetControl() const { return _petControl; }
|
||||
|
||||
/**
|
||||
* Get a specified color in the currently active UI color table
|
||||
*/
|
||||
uint getColor(uint index);
|
||||
|
||||
/**
|
||||
* Get one of the game's three UI color tables. If the default
|
||||
* tableNum of -1 is used, the table is taken from the game state
|
||||
*/
|
||||
const uint *getColorTable(int tableNum = -1);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_SECTION_H */
|
||||
181
engines/titanic/pet_control/pet_show_translation.cpp
Normal file
181
engines/titanic/pet_control/pet_show_translation.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_show_translation.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPETShowTranslation, CGameObject)
|
||||
ON_MESSAGE(EnterViewMsg)
|
||||
ON_MESSAGE(LeaveViewMsg)
|
||||
ON_MESSAGE(ChangeSeasonMsg)
|
||||
ON_MESSAGE(ArboretumGateMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
void CPETShowTranslation::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(1, indent);
|
||||
CGameObject::save(file, indent);
|
||||
}
|
||||
|
||||
void CPETShowTranslation::load(SimpleFile *file) {
|
||||
file->readNumber();
|
||||
CGameObject::load(file);
|
||||
}
|
||||
|
||||
bool CPETShowTranslation::EnterViewMsg(CEnterViewMsg *msg) {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (!pet)
|
||||
return true;
|
||||
|
||||
CString viewName = getFullViewName();
|
||||
CString nodeView = msg->_newView->getNodeViewName();
|
||||
|
||||
if (viewName == "Arboretum.Node 2.N" || viewName == "FrozenArboretum.Node 2.N") {
|
||||
switch (stateGetSeason()) {
|
||||
case SEASON_SUMMER:
|
||||
pet->addTranslation(DE_SUMMER_ARBORETUM, DE_SUMMER);
|
||||
break;
|
||||
|
||||
case SEASON_AUTUMN:
|
||||
pet->addTranslation(DE_AUTUMN_ARBORETUM, DE_AUTUMN);
|
||||
break;
|
||||
|
||||
case SEASON_WINTER:
|
||||
pet->addTranslation(DE_WINTER_ARBORETUM, DE_WINTER);
|
||||
break;
|
||||
|
||||
case SEASON_SPRING:
|
||||
pet->addTranslation(DE_SPRING_ARBORETUM, DE_SPRING);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pet->addTranslation(DE_ARBORETUM_MSG1, DE_ARBORETUM_MSG2);
|
||||
} else if (compareRoomNameTo("Bridge")) {
|
||||
if (nodeView == "Node 3.N") {
|
||||
pet->addTranslation(DE_BRIDGE_MSG1, DE_BRIDGE_MSG2);
|
||||
pet->addTranslation(DE_BRIDGE_MSG3, DE_BRIDGE_MSG4);
|
||||
pet->addTranslation(DE_BRIDGE_MSG5, DE_BRIDGE_MSG6);
|
||||
pet->addTranslation(DE_BRIDGE_MSG7, DE_BRIDGE_MSG8);
|
||||
} else if (nodeView == "Node 4.N") {
|
||||
pet->addTranslation(DE_BRIDGE_MSG9, DE_BRIDGE_MSG10);
|
||||
}
|
||||
} else if (compareRoomNameTo("PromenadeDeck")) {
|
||||
if (nodeView == "Node 2.S") {
|
||||
pet->addTranslation(DE_PROMENADE_DECK_MSG1, DE_PROMENADE_DECK_MSG2);
|
||||
pet->addTranslation(DE_PROMENADE_DECK_MSG3, DE_PROMENADE_DECK_MSG4);
|
||||
pet->addTranslation(DE_PROMENADE_DECK_MSG5, DE_PROMENADE_DECK_MSG6);
|
||||
pet->addTranslation(DE_PROMENADE_DECK_MSG7, DE_PROMENADE_DECK_MSG8);
|
||||
pet->addTranslation(DE_PROMENADE_DECK_MSG9, DE_PROMENADE_DECK_MSG10);
|
||||
}
|
||||
} else if (compareRoomNameTo("SgtLobby")) {
|
||||
if (nodeView == "Node 17.S") {
|
||||
pet->addTranslation(DE_SGTLOBBY_MSG1, DE_SGTLOBBY_MSG2);
|
||||
pet->addTranslation(DE_SGTLOBBY_MSG3, DE_SGTLOBBY_MSG4);
|
||||
pet->addTranslation(DE_SGTLOBBY_MSG5, DE_SGTLOBBY_MSG6);
|
||||
pet->addTranslation(DE_SGTLOBBY_MSG7, DE_SGTLOBBY_MSG8);
|
||||
}
|
||||
} else if (compareRoomNameTo("Titania")) {
|
||||
if (nodeView == "Node 9.N") {
|
||||
pet->addTranslation(DE_TITANIA_MSG1, DE_TITANIA_MSG2);
|
||||
} else if (nodeView == "Node 10.N") {
|
||||
pet->addTranslation(DE_TITANIA_MSG3, DE_TITANIA_MSG4);
|
||||
} else if (nodeView == "Node 11.N") {
|
||||
pet->addTranslation(DE_TITANIA_MSG5, DE_TITANIA_MSG6);
|
||||
} else if (nodeView == "Node 13.N") {
|
||||
pet->addTranslation(DE_TITANIA_MSG7, DE_TITANIA_MSG8);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPETShowTranslation::LeaveViewMsg(CLeaveViewMsg *msg) {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet)
|
||||
pet->clearTranslation();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPETShowTranslation::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet) {
|
||||
pet->clearTranslation();
|
||||
|
||||
CString viewName = getFullViewName();
|
||||
if (viewName == "Arboretum.Node 2.N" || viewName == "FrozenArboretum.Node 2.N") {
|
||||
if (msg->_season == "Summer")
|
||||
pet->addTranslation(DE_SUMMER_ARBORETUM, DE_SUMMER);
|
||||
else if (msg->_season == "Autumn")
|
||||
pet->addTranslation(DE_AUTUMN_ARBORETUM, DE_AUTUMN);
|
||||
else if (msg->_season == "Winter")
|
||||
pet->addTranslation(DE_WINTER_ARBORETUM, DE_WINTER);
|
||||
else if (msg->_season == "Spring")
|
||||
pet->addTranslation(DE_SPRING_ARBORETUM, DE_SPRING);
|
||||
|
||||
pet->addTranslation(DE_ARBORETUM_MSG1, DE_ARBORETUM_MSG2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPETShowTranslation::ArboretumGateMsg(CArboretumGateMsg *msg) {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet) {
|
||||
pet->clearTranslation();
|
||||
|
||||
CString viewName = getFullViewName();
|
||||
if (viewName == "Arboretum.Node 2.N" || viewName == "FrozenArboretum.Node 2.N") {
|
||||
switch (stateGetSeason()) {
|
||||
case SEASON_SUMMER:
|
||||
pet->addTranslation(DE_SUMMER_ARBORETUM, DE_SUMMER);
|
||||
break;
|
||||
|
||||
case SEASON_AUTUMN:
|
||||
pet->addTranslation(DE_AUTUMN_ARBORETUM, DE_AUTUMN);
|
||||
break;
|
||||
|
||||
case SEASON_WINTER:
|
||||
pet->addTranslation(DE_WINTER_ARBORETUM, DE_WINTER);
|
||||
break;
|
||||
|
||||
case SEASON_SPRING:
|
||||
pet->addTranslation(DE_SPRING_ARBORETUM, DE_SPRING);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
pet->addTranslation(DE_ARBORETUM_MSG1, DE_ARBORETUM_MSG2);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
56
engines/titanic/pet_control/pet_show_translation.h
Normal file
56
engines/titanic/pet_control/pet_show_translation.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_SHOW_TRANSLATION_H
|
||||
#define TITANIC_PET_SHOW_TRANSLATION_H
|
||||
|
||||
#include "titanic/core/game_object.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
/**
|
||||
* Used by the German version to show contextual translation of
|
||||
* English background text throughout the game
|
||||
*/
|
||||
class CPETShowTranslation: public CGameObject {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool EnterViewMsg(CEnterViewMsg *msg);
|
||||
bool LeaveViewMsg(CLeaveViewMsg *msg);
|
||||
bool ChangeSeasonMsg(CChangeSeasonMsg *msg);
|
||||
bool ArboretumGateMsg(CArboretumGateMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
CPETShowTranslation() : CGameObject() {}
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_SHOW_TRANSLATION_H */
|
||||
245
engines/titanic/pet_control/pet_slider.cpp
Normal file
245
engines/titanic/pet_control/pet_slider.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_slider.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetSlider::CPetSlider() {
|
||||
_orientation = 0;
|
||||
_thumbWidth = 0;
|
||||
_thumbHeight = 0;
|
||||
_sliderOffset = 0;
|
||||
_thumbFocused = false;
|
||||
}
|
||||
|
||||
Rect CPetSlider::clearDirtyArea() {
|
||||
Rect result = _dirtyArea;
|
||||
_dirtyArea.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetSlider::checkThumb(const Point &pt) {
|
||||
_thumbFocused = thumbContains(pt);
|
||||
if (_thumbFocused)
|
||||
return true;
|
||||
else
|
||||
return containsPt(pt);
|
||||
}
|
||||
|
||||
bool CPetSlider::resetThumbFocus() {
|
||||
bool result = _thumbFocused;
|
||||
_thumbFocused = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetSlider::MouseDragMoveMsg(const Point &pt) {
|
||||
int newOffset = calcSliderOffset(pt);
|
||||
setOffsetPixels(newOffset);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetSlider::MouseButtonUpMsg(const Point &pt) {
|
||||
if (thumbContains(pt))
|
||||
return true;
|
||||
if (!containsPt(pt))
|
||||
return false;
|
||||
|
||||
int newOffset = calcSliderOffset(pt);
|
||||
setOffsetPixels(newOffset);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetSlider::contains(const Point &pt) const {
|
||||
return thumbContains(pt) || containsPt(pt);
|
||||
}
|
||||
|
||||
double CPetSlider::getOffsetPixels() const {
|
||||
int maxVal = 0, minVal = 0;
|
||||
if (_orientation & ORIENTATION_HORIZONTAL) {
|
||||
maxVal = _slidingRect.right;
|
||||
minVal = _slidingRect.left;
|
||||
}
|
||||
|
||||
if (_orientation & ORIENTATION_VERTICAL) {
|
||||
maxVal = _slidingRect.bottom;
|
||||
minVal = _slidingRect.top;
|
||||
}
|
||||
|
||||
if (minVal == maxVal)
|
||||
return 0.0;
|
||||
|
||||
return (double)_sliderOffset / (maxVal - minVal);
|
||||
}
|
||||
|
||||
void CPetSlider::setSliderOffset(double offset) {
|
||||
if (_orientation & ORIENTATION_HORIZONTAL)
|
||||
_sliderOffset = (int)(offset * (_slidingRect.right - _slidingRect.left));
|
||||
|
||||
if (_orientation & ORIENTATION_VERTICAL)
|
||||
_sliderOffset = (int)(offset * (_slidingRect.bottom - _slidingRect.top));
|
||||
}
|
||||
|
||||
void CPetSlider::setOffsetPixels(int offset) {
|
||||
// Add the slider's old position to the dirty area
|
||||
Rect tempRect = getThumbRect();
|
||||
_dirtyArea.combine(tempRect);
|
||||
|
||||
// Set the new offset
|
||||
_sliderOffset = offset;
|
||||
|
||||
// Add the thumb's new location to the dirty area
|
||||
tempRect = getThumbRect();
|
||||
_dirtyArea.combine(tempRect);
|
||||
}
|
||||
|
||||
Point CPetSlider::getBackgroundDrawPos() {
|
||||
return Point(_bounds.left, _bounds.top);
|
||||
}
|
||||
|
||||
Point CPetSlider::getThumbDrawPos() {
|
||||
Point thumbPos = getThumbCentroidPos();
|
||||
thumbPos -= Point(_thumbWidth / 2, _thumbHeight / 2);
|
||||
return thumbPos;
|
||||
}
|
||||
|
||||
Point CPetSlider::getThumbCentroidPos() const {
|
||||
Point pt;
|
||||
|
||||
if (_orientation & ORIENTATION_HORIZONTAL) {
|
||||
pt = Point(_slidingRect.left + _sliderOffset,
|
||||
_slidingRect.top + _slidingRect.height() / 2);
|
||||
}
|
||||
|
||||
if (_orientation & ORIENTATION_VERTICAL) {
|
||||
pt = Point(_slidingRect.left + _slidingRect.width() / 2,
|
||||
_slidingRect.top + _sliderOffset);
|
||||
}
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
bool CPetSlider::thumbContains(const Point &pt) const {
|
||||
return getThumbRect().contains(pt);
|
||||
}
|
||||
|
||||
Rect CPetSlider::getThumbRect() const {
|
||||
Rect thumbRect(0, 0, _thumbWidth, _thumbHeight);
|
||||
Point centroid = getThumbCentroidPos();
|
||||
thumbRect.moveTo(centroid.x - _thumbWidth / 2, centroid.y - _thumbHeight / 2);
|
||||
|
||||
return thumbRect;
|
||||
}
|
||||
|
||||
int CPetSlider::calcSliderOffset(const Point &pt) const {
|
||||
int result = 0;
|
||||
|
||||
if (_orientation & ORIENTATION_HORIZONTAL) {
|
||||
result = CLIP(pt.x, _slidingRect.left, _slidingRect.right) - _slidingRect.left;
|
||||
}
|
||||
|
||||
if (_orientation & ORIENTATION_VERTICAL) {
|
||||
result = CLIP(pt.y, _slidingRect.top, _slidingRect.bottom) - _slidingRect.top;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CPetSlider::setOrientation(SliderOrientation orientation) {
|
||||
_orientation |= orientation;
|
||||
}
|
||||
|
||||
void CPetSlider::stepPosition(int direction) {
|
||||
double val = getOffsetPixels();
|
||||
|
||||
if (direction == -1) {
|
||||
val = MAX<double>(val - 0.1, 0.0);
|
||||
} else if (direction == 1) {
|
||||
val = MIN<double>(val + 0.1, 1.0);
|
||||
}
|
||||
|
||||
setSliderOffset(val);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void CPetSoundSlider::setupBackground(const CString &name, CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
_background = petControl->getHiddenObject(name);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetSoundSlider::setupThumb(const CString &name, CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
_thumb = petControl->getHiddenObject(name);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetSoundSlider::setupBackground2(const CString &name, CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
CString numStr = "3";
|
||||
int mode = petControl->getPassengerClass();
|
||||
if (mode <= 3) {
|
||||
numStr = CString(mode);
|
||||
} else if (mode == 4) {
|
||||
mode = petControl->getPriorClass();
|
||||
if (mode == 1) {
|
||||
numStr = CString(mode);
|
||||
}
|
||||
}
|
||||
|
||||
CString fullName = numStr + name;
|
||||
setupBackground(fullName, petControl);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetSoundSlider::setupThumb2(const CString &name, CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
CString numStr = "3";
|
||||
int mode = petControl->getPassengerClass();
|
||||
if (mode <= 3) {
|
||||
numStr = CString(mode);
|
||||
} else if (mode == 4) {
|
||||
mode = petControl->getPriorClass();
|
||||
if (mode == 1) {
|
||||
numStr = CString(mode);
|
||||
}
|
||||
}
|
||||
|
||||
CString fullName = numStr + name;
|
||||
setupThumb(fullName, petControl);
|
||||
}
|
||||
}
|
||||
|
||||
void CPetSoundSlider::draw(CScreenManager *screenManager) {
|
||||
if (_background) {
|
||||
Point pt = getBackgroundDrawPos();
|
||||
_background->draw(screenManager, pt);
|
||||
}
|
||||
|
||||
if (_thumb) {
|
||||
Point pt = getThumbDrawPos();
|
||||
_thumb->draw(screenManager, pt);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
238
engines/titanic/pet_control/pet_slider.h
Normal file
238
engines/titanic/pet_control/pet_slider.h
Normal file
@@ -0,0 +1,238 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_SLIDER_H
|
||||
#define TITANIC_PET_SLIDER_H
|
||||
|
||||
#include "titanic/support/rect.h"
|
||||
#include "titanic/support/string.h"
|
||||
#include "titanic/core/game_object.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
enum SliderOrientation { ORIENTATION_HORIZONTAL = 1, ORIENTATION_VERTICAL = 2 };
|
||||
|
||||
class CPetControl;
|
||||
|
||||
class CPetSlider {
|
||||
private:
|
||||
int _orientation;
|
||||
Rect _bounds;
|
||||
Rect _slidingRect;
|
||||
int _thumbWidth;
|
||||
int _thumbHeight;
|
||||
int _sliderOffset;
|
||||
bool _thumbFocused;
|
||||
Rect _dirtyArea;
|
||||
private:
|
||||
/**
|
||||
* Center the center position of the slider's thumb
|
||||
*/
|
||||
Point getThumbCentroidPos() const;
|
||||
|
||||
/**
|
||||
* Returns true if the passed point is within the thumb
|
||||
*/
|
||||
bool thumbContains(const Point &pt) const;
|
||||
|
||||
/**
|
||||
* Gets the area the slider's thumbnail covers
|
||||
*/
|
||||
Rect getThumbRect() const;
|
||||
|
||||
/**
|
||||
* Calculates the slider offset at the specificed position
|
||||
*/
|
||||
int calcSliderOffset(const Point &pt) const;
|
||||
protected:
|
||||
/**
|
||||
* Get the position to draw the background at
|
||||
*/
|
||||
Point getBackgroundDrawPos();
|
||||
|
||||
/**
|
||||
* Get the position to draw the slider thumbnail at
|
||||
*/
|
||||
Point getThumbDrawPos();
|
||||
|
||||
/**
|
||||
* Returns true if the passed point falls within the slider's bounds
|
||||
*/
|
||||
bool containsPt(const Point &pt) const { return _bounds.contains(pt); }
|
||||
public:
|
||||
CPetSlider();
|
||||
virtual ~CPetSlider() {}
|
||||
|
||||
/**
|
||||
* Setup the background
|
||||
*/
|
||||
virtual void setupBackground(const CString &name, CPetControl *petControl) {}
|
||||
|
||||
/**
|
||||
* Setup the thumb
|
||||
*/
|
||||
virtual void setupThumb(const CString &name, CPetControl *petControl) {}
|
||||
|
||||
/**
|
||||
* Setup the background
|
||||
*/
|
||||
virtual void setupBackground2(const CString &name, CPetControl *petControl) {}
|
||||
|
||||
/**
|
||||
* Setup the thumb
|
||||
*/
|
||||
virtual void setupThumb2(const CString &name, CPetControl *petControl) {}
|
||||
|
||||
/**
|
||||
* Reset the slider
|
||||
*/
|
||||
virtual void reset(const CString &name) {}
|
||||
|
||||
/**
|
||||
* Draw the slider
|
||||
*/
|
||||
virtual void draw(CScreenManager *screenManager) {}
|
||||
|
||||
/**
|
||||
* Reset the dirty area
|
||||
*/
|
||||
virtual Rect clearDirtyArea();
|
||||
|
||||
/**
|
||||
* Checks whether the slider is highlighted
|
||||
*/
|
||||
virtual bool checkThumb(const Point &pt);
|
||||
|
||||
/**
|
||||
* Resets the thumb focused flag
|
||||
*/
|
||||
virtual bool resetThumbFocus();
|
||||
|
||||
/**
|
||||
* Handles dragging the slider
|
||||
*/
|
||||
virtual bool MouseDragMoveMsg(const Point &pt);
|
||||
|
||||
/**
|
||||
* Called when a slider drag ends
|
||||
*/
|
||||
virtual bool MouseDragEndMsg(const Point &pt) { return true; }
|
||||
|
||||
/**
|
||||
* Handles mouse button up messaes
|
||||
*/
|
||||
virtual bool MouseButtonUpMsg(const Point &pt);
|
||||
|
||||
virtual bool proc13() { return false; }
|
||||
virtual bool proc14() { return false; }
|
||||
|
||||
|
||||
virtual bool contains(const Point &pt) const;
|
||||
|
||||
/**
|
||||
* Returns the slider offset in pixels
|
||||
*/
|
||||
virtual double getOffsetPixels() const;
|
||||
|
||||
/**
|
||||
* Sets the slider offset
|
||||
*/
|
||||
virtual void setSliderOffset(double offset);
|
||||
|
||||
/**
|
||||
* Set a new slider offset in pixels
|
||||
*/
|
||||
virtual void setOffsetPixels(int offset);
|
||||
|
||||
/**
|
||||
* Enables a given orientation
|
||||
*/
|
||||
void setOrientation(SliderOrientation orientation);
|
||||
|
||||
/**
|
||||
* Set the bounds for the slider
|
||||
*/
|
||||
void setBounds(const Rect &r) { _bounds = r; }
|
||||
|
||||
/**
|
||||
* Set the sliding bounds for the slider
|
||||
*/
|
||||
void setSlidingBounds(const Rect &r) { _slidingRect = r; }
|
||||
|
||||
/**
|
||||
* Set the size of the slider thumb
|
||||
*/
|
||||
void setThumbSize(const Point &pt) {
|
||||
_thumbWidth = pt.x;
|
||||
_thumbHeight = pt.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the slider
|
||||
*/
|
||||
void translate(const Point &pt) {
|
||||
_bounds.translate(pt.x, pt.y);
|
||||
_slidingRect.translate(pt.x, pt.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the current position of a slider by a step amount
|
||||
*/
|
||||
void stepPosition(int direction);
|
||||
};
|
||||
|
||||
class CPetSoundSlider : public CPetSlider {
|
||||
public:
|
||||
CGameObject *_background;
|
||||
CGameObject *_thumb;
|
||||
public:
|
||||
CPetSoundSlider() : CPetSlider(), _background(nullptr),
|
||||
_thumb(0) {}
|
||||
|
||||
/**
|
||||
* Setup the background
|
||||
*/
|
||||
void setupBackground(const CString &name, CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Setup the thumb
|
||||
*/
|
||||
void setupThumb(const CString &name, CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Setup the background
|
||||
*/
|
||||
void setupBackground2(const CString &name, CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Setup the thumb
|
||||
*/
|
||||
void setupThumb2(const CString &name, CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Draw the slider
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_SLIDER_H */
|
||||
312
engines/titanic/pet_control/pet_sound.cpp
Normal file
312
engines/titanic/pet_control/pet_sound.cpp
Normal file
@@ -0,0 +1,312 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_sound.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/pet_control/pet_real_life.h"
|
||||
#include "titanic/game_manager.h"
|
||||
#include "titanic/titanic.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetSound::CPetSound() : CPetGlyph(), _draggingSlider(nullptr), _draggingSliderNum(MASTER_SLIDER) {
|
||||
}
|
||||
|
||||
bool CPetSound::setup(CPetControl *petControl, CPetGlyphs *owner) {
|
||||
CPetGlyph::setup(petControl, owner);
|
||||
|
||||
_masterVolume.setOrientation(ORIENTATION_HORIZONTAL);
|
||||
_masterVolume.setBounds(Rect(17, 0, 147, 15));
|
||||
_masterVolume.setSlidingBounds(Rect(35, 5, 127, 11));
|
||||
_masterVolume.setThumbSize(Point(25, 15));
|
||||
_masterVolume.translate(Point(415, 376));
|
||||
|
||||
_musicVolume.setOrientation(ORIENTATION_HORIZONTAL);
|
||||
_musicVolume.setBounds(Rect(17, 20, 147, 35));
|
||||
_musicVolume.setSlidingBounds(Rect(35, 25, 127, 31));
|
||||
_musicVolume.setThumbSize(Point(25, 15));
|
||||
_musicVolume.translate(Point(415, 376));
|
||||
|
||||
_parrotVolume.setOrientation(ORIENTATION_HORIZONTAL);
|
||||
_parrotVolume.setBounds(Rect(17, 40, 147, 55));
|
||||
_parrotVolume.setSlidingBounds(Rect(35, 45, 127, 51));
|
||||
_parrotVolume.setThumbSize(Point(25, 15));
|
||||
_parrotVolume.translate(Point(415, 376));
|
||||
|
||||
_speechVolume.setOrientation(ORIENTATION_HORIZONTAL);
|
||||
_speechVolume.setBounds(Rect(17, 60, 147, 75));
|
||||
_speechVolume.setSlidingBounds(Rect(35, 65, 127, 71));
|
||||
_speechVolume.setThumbSize(Point(25, 15));
|
||||
_speechVolume.translate(Point(415, 376));
|
||||
|
||||
_element.setBounds(Rect(0, 0, 165, 77));
|
||||
_element.translate(Point(415, 376));
|
||||
|
||||
Rect rect(0, 0, 88, 16);
|
||||
rect.translate(320, 376);
|
||||
_textMasterVolume.setBounds(rect);
|
||||
_textMasterVolume.resize(3);
|
||||
_textMasterVolume.setHasBorder(false);
|
||||
_textMasterVolume.setText(MASTER_VOLUME);
|
||||
|
||||
rect.translate(0, 20);
|
||||
_textMusicVolume.setBounds(rect);
|
||||
_textMusicVolume.resize(3);
|
||||
_textMusicVolume.setHasBorder(false);
|
||||
_textMusicVolume.setText(MUSIC_VOLUME);
|
||||
|
||||
rect.translate(0, 20);
|
||||
_textParrotVolume.setBounds(rect);
|
||||
_textParrotVolume.resize(3);
|
||||
_textParrotVolume.setHasBorder(false);
|
||||
_textParrotVolume.setText(PARROT_VOLUME);
|
||||
|
||||
rect.translate(0, 20);
|
||||
_textSpeechVolume.setBounds(rect);
|
||||
_textSpeechVolume.resize(3);
|
||||
_textSpeechVolume.setHasBorder(false);
|
||||
_textSpeechVolume.setText(SPEECH_VOLUME);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetSound::reset() {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet) {
|
||||
setName("PetSound", pet);
|
||||
_element.reset("PetVolChannels", pet, MODE_UNSELECTED);
|
||||
_musicVolume.setupThumb2("PetVolSlug", pet);
|
||||
_masterVolume.setupThumb2("PetVolSlug", pet);
|
||||
_parrotVolume.setupThumb2("PetVolSlug", pet);
|
||||
_speechVolume.setupThumb2("PetVolSlug", pet);
|
||||
|
||||
CPetSection *section = getPetSection();
|
||||
uint col = section->getColor(0);
|
||||
_textMusicVolume.setLineColor(0, col);
|
||||
_textMasterVolume.setLineColor(0, col);
|
||||
_textParrotVolume.setLineColor(0, col);
|
||||
_textSpeechVolume.setLineColor(0, col);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetSound::setSliders() {
|
||||
// Get the mute settings
|
||||
bool muteAll = ConfMan.hasKey("mute") ? ConfMan.getBool("mute") : false;
|
||||
bool musicMute = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute"));
|
||||
bool sfxMute = muteAll || (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute"));
|
||||
bool speechMute = muteAll || (ConfMan.hasKey("speech_mute") && ConfMan.getBool("speech_mute"));
|
||||
|
||||
// Get the volume levels
|
||||
uint musicVol = musicMute ? 0 : MIN(255, ConfMan.getInt("music_volume"));
|
||||
uint parrotVol = sfxMute ? 0 : MIN(255, ConfMan.getInt("sfx_volume"));
|
||||
uint speechVol = speechMute ? 0 : MIN(255, ConfMan.getInt("speech_volume"));
|
||||
uint masterVol = MAX(musicVol, MAX(parrotVol, speechVol));
|
||||
|
||||
const double FACTOR = 1.0 / 255.0;
|
||||
_masterVolume.setSliderOffset(masterVol * FACTOR);
|
||||
_musicVolume.setSliderOffset(musicVol * FACTOR);
|
||||
_parrotVolume.setSliderOffset(parrotVol * FACTOR);
|
||||
_speechVolume.setSliderOffset(speechVol * FACTOR);
|
||||
}
|
||||
|
||||
void CPetSound::sliderChanged(double offset, SliderType sliderNum) {
|
||||
uint newVol = (uint)(offset * 255.0);
|
||||
|
||||
switch (sliderNum) {
|
||||
case MASTER_SLIDER:
|
||||
ConfMan.setBool("music_mute", false);
|
||||
ConfMan.setBool("sfx_mute", false);
|
||||
ConfMan.setBool("sfx_mute", false);
|
||||
ConfMan.setInt("music_volume", newVol);
|
||||
ConfMan.setInt("sfx_volume", newVol);
|
||||
ConfMan.setInt("speech_volume", newVol);
|
||||
|
||||
_musicVolume.setSliderOffset(newVol * 0.01);
|
||||
_parrotVolume.setSliderOffset(newVol * 0.01);
|
||||
_speechVolume.setSliderOffset(newVol * 0.01);
|
||||
break;
|
||||
case MUSIC_SLIDER:
|
||||
ConfMan.setBool("music_mute", false);
|
||||
ConfMan.setInt("music_volume", newVol);
|
||||
break;
|
||||
case PARROT_SLIDER:
|
||||
ConfMan.setBool("sfx_mute", false);
|
||||
ConfMan.setInt("sfx_volume", newVol);
|
||||
break;
|
||||
case SPEECH_SLIDER:
|
||||
ConfMan.setBool("speech_mute", false);
|
||||
ConfMan.setInt("speech_volume", newVol);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
ConfMan.setBool("mute", false);
|
||||
g_vm->syncSoundSettings();
|
||||
}
|
||||
|
||||
void CPetSound::draw2(CScreenManager *screenManager) {
|
||||
_element.draw(screenManager);
|
||||
|
||||
_musicVolume.draw(screenManager);
|
||||
_masterVolume.draw(screenManager);
|
||||
_parrotVolume.draw(screenManager);
|
||||
_speechVolume.draw(screenManager);
|
||||
|
||||
_textMusicVolume.draw(screenManager);
|
||||
_textMasterVolume.draw(screenManager);
|
||||
_textParrotVolume.draw(screenManager);
|
||||
_textSpeechVolume.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetSound::MouseButtonDownMsg(const Point &pt) {
|
||||
if (_musicVolume.checkThumb(pt) || _masterVolume.checkThumb(pt) ||
|
||||
_speechVolume.checkThumb(pt))
|
||||
return true;
|
||||
|
||||
if (_parrotVolume.checkThumb(pt)) {
|
||||
CPetControl *pet = getPetControl();
|
||||
if (pet)
|
||||
pet->playSound(2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Rect rectLeft(0, 0, 10, 11);
|
||||
Rect rectRight(0, 0, 10, 11);
|
||||
rectLeft.translate(415, 379);
|
||||
rectRight.translate(567, 378);
|
||||
|
||||
CPetSlider *sliders[4] = { &_masterVolume, &_musicVolume, &_parrotVolume, &_speechVolume };
|
||||
for (int idx = MASTER_SLIDER; idx <= SPEECH_SLIDER; ++idx) {
|
||||
CPetSlider *slider = sliders[idx];
|
||||
const bool isLeft = rectLeft.contains(pt);
|
||||
const bool isRight = rectRight.contains(pt);
|
||||
double offset = 0.0;
|
||||
|
||||
if (isLeft) {
|
||||
slider->stepPosition(-1);
|
||||
offset = slider->getOffsetPixels();
|
||||
} else if (isRight) {
|
||||
slider->stepPosition(1);
|
||||
offset = slider->getOffsetPixels();
|
||||
}
|
||||
|
||||
if (isLeft || isRight) {
|
||||
sliderChanged(offset, (SliderType)idx);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Move to next slider row
|
||||
rectLeft.translate(0, 20);
|
||||
rectRight.translate(0, 20);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetSound::MouseDragStartMsg(CMouseDragStartMsg *msg) {
|
||||
if (_masterVolume.resetThumbFocus()) {
|
||||
_draggingSlider = &_masterVolume;
|
||||
getOwner()->startDragging(this, msg);
|
||||
_draggingSliderNum = MASTER_SLIDER;
|
||||
return true;
|
||||
} else if (_musicVolume.resetThumbFocus()) {
|
||||
_draggingSlider = &_musicVolume;
|
||||
getOwner()->startDragging(this, msg);
|
||||
_draggingSliderNum = MUSIC_SLIDER;
|
||||
return true;
|
||||
} else if (_parrotVolume.resetThumbFocus()) {
|
||||
_draggingSlider = &_parrotVolume;
|
||||
getOwner()->startDragging(this, msg);
|
||||
_draggingSliderNum = PARROT_SLIDER;
|
||||
return true;
|
||||
} else if (_speechVolume.resetThumbFocus()) {
|
||||
_draggingSlider = &_speechVolume;
|
||||
getOwner()->startDragging(this, msg);
|
||||
_draggingSliderNum = SPEECH_SLIDER;
|
||||
return true;
|
||||
}
|
||||
|
||||
_draggingSlider = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetSound::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
|
||||
if (!_draggingSlider)
|
||||
return false;
|
||||
|
||||
if (_draggingSlider->MouseDragMoveMsg(msg->_mousePos)) {
|
||||
double offset = _draggingSlider->getOffsetPixels();
|
||||
sliderChanged(offset, _draggingSliderNum);
|
||||
getPetControl()->makeDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetSound::MouseDragEndMsg(CMouseDragEndMsg *msg) {
|
||||
if (!_draggingSlider)
|
||||
return false;
|
||||
|
||||
// Flush the changed settings
|
||||
ConfMan.flushToDisk();
|
||||
|
||||
bool result = _draggingSlider->MouseDragEndMsg(msg->_mousePos);
|
||||
getOwner()->endDragging();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CPetSound::MouseButtonUpMsg(const Point &pt) {
|
||||
SliderType sliderNum = MASTER_SLIDER;
|
||||
CPetSlider *slider = nullptr;
|
||||
|
||||
if (_masterVolume.MouseButtonUpMsg(pt)) {
|
||||
sliderNum = MASTER_SLIDER;
|
||||
slider = &_masterVolume;
|
||||
} else if (_musicVolume.MouseButtonUpMsg(pt)) {
|
||||
sliderNum = MUSIC_SLIDER;
|
||||
slider = &_musicVolume;
|
||||
} else if (_parrotVolume.MouseButtonUpMsg(pt)) {
|
||||
sliderNum = PARROT_SLIDER;
|
||||
slider = &_parrotVolume;
|
||||
} else if (_speechVolume.MouseButtonUpMsg(pt)) {
|
||||
sliderNum = SPEECH_SLIDER;
|
||||
slider = &_speechVolume;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
double offset = slider->getOffsetPixels();
|
||||
sliderChanged(offset, sliderNum);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetSound::getTooltip(CTextControl *text) {
|
||||
text->setText(CHANGE_VOLUME_SETTINGS);
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
118
engines/titanic/pet_control/pet_sound.h
Normal file
118
engines/titanic/pet_control/pet_sound.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_SOUND_H
|
||||
#define TITANIC_PET_SOUND_H
|
||||
|
||||
#include "titanic/pet_control/pet_glyphs.h"
|
||||
#include "titanic/pet_control/pet_gfx_element.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
#include "titanic/pet_control/pet_slider.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetRealLife;
|
||||
|
||||
class CPetSound : public CPetGlyph {
|
||||
enum SliderType {
|
||||
MASTER_SLIDER = 0, MUSIC_SLIDER = 1, PARROT_SLIDER = 2, SPEECH_SLIDER = 3
|
||||
};
|
||||
private:
|
||||
CPetGfxElement _element;
|
||||
CPetSoundSlider _masterVolume;
|
||||
CPetSoundSlider _musicVolume;
|
||||
CPetSoundSlider _parrotVolume;
|
||||
CPetSoundSlider _speechVolume;
|
||||
CTextControl _textMasterVolume;
|
||||
CTextControl _textMusicVolume;
|
||||
CTextControl _textParrotVolume;
|
||||
CTextControl _textSpeechVolume;
|
||||
CPetSlider *_draggingSlider;
|
||||
SliderType _draggingSliderNum;
|
||||
private:
|
||||
/**
|
||||
* Called when a slider has changed
|
||||
*/
|
||||
void sliderChanged(double offset, SliderType sliderNum);
|
||||
public:
|
||||
CPetSound();
|
||||
|
||||
/**
|
||||
* Setup the glyph
|
||||
*/
|
||||
bool setup(CPetControl *petControl, CPetGlyphs *owner) override;
|
||||
|
||||
/**
|
||||
* Reset the glyph
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Handles any secondary drawing of the glyph
|
||||
*/
|
||||
void draw2(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Called for mouse button down messages
|
||||
*/
|
||||
bool MouseButtonDownMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Called when mouse drag starts
|
||||
*/
|
||||
bool MouseDragStartMsg(CMouseDragStartMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Called during mouse drags
|
||||
*/
|
||||
bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Called when mouse drag ends
|
||||
*/
|
||||
bool MouseDragEndMsg(CMouseDragEndMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Handles mouse button up messages
|
||||
*/
|
||||
bool MouseButtonUpMsg(const Point &pt) override;
|
||||
|
||||
/**
|
||||
* Highlight any currently highlighted element
|
||||
*/
|
||||
void highlightCurrent(const Point &pt) override {
|
||||
setSliders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tooltip text for when the glyph is selected
|
||||
*/
|
||||
void getTooltip(CTextControl *text) override;
|
||||
|
||||
/**
|
||||
* Sets the positions of the volume sliders
|
||||
*/
|
||||
void setSliders();
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_SOUND_H */
|
||||
260
engines/titanic/pet_control/pet_starfield.cpp
Normal file
260
engines/titanic/pet_control/pet_starfield.cpp
Normal file
@@ -0,0 +1,260 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_starfield.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
#include "titanic/messages/pet_messages.h"
|
||||
#include "titanic/star_control/star_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetStarfield::CPetStarfield() : _flickerCtr(0), _photoOn(true),
|
||||
_hasReference(false), _rect1(22, 352, 598, 478) {
|
||||
_markerStates[0] = _markerStates[1] = _markerStates[2] = MS_BLANK;
|
||||
}
|
||||
|
||||
bool CPetStarfield::setup(CPetControl *petControl) {
|
||||
if (petControl && setupControl(petControl))
|
||||
return reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetStarfield::reset() {
|
||||
if (_petControl) {
|
||||
_imgStarfield.setup(MODE_UNSELECTED, "3PetStarField", _petControl);
|
||||
_imgPhoto.setup(MODE_UNSELECTED, "HomePhotoOnOff", _petControl);
|
||||
_btnSetDest.setup(MODE_UNSELECTED, "3PetSetDestin", _petControl);
|
||||
_btnSetDest.setup(MODE_SELECTED, "3PetSetDestin1", _petControl);
|
||||
_imgStarCtrl.setup(MODE_UNSELECTED, "3PetStarCtrl", _petControl);
|
||||
|
||||
_leds[0].setup(MODE_UNSELECTED, "LEDOff1", _petControl);
|
||||
_leds[1].setup(MODE_UNSELECTED, "LEDOn1", _petControl);
|
||||
_leds[2].setup(MODE_UNSELECTED, "LEDOff2", _petControl);
|
||||
_leds[3].setup(MODE_UNSELECTED, "LEDOn2", _petControl);
|
||||
_leds[4].setup(MODE_UNSELECTED, "LEDOff3", _petControl);
|
||||
_leds[5].setup(MODE_UNSELECTED, "LEDOn3", _petControl);
|
||||
|
||||
uint col = getColor(0);
|
||||
_text.setColor(col);
|
||||
_text.setLineColor(0, col);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetStarfield::draw(CScreenManager *screenManager) {
|
||||
_petControl->drawSquares(screenManager, 2);
|
||||
|
||||
_imgStarfield.draw(screenManager);
|
||||
if (_photoOn) {
|
||||
_imgPhoto.draw(screenManager);
|
||||
} else {
|
||||
_imgStarCtrl.draw(screenManager);
|
||||
}
|
||||
|
||||
_btnSetDest.draw(screenManager);
|
||||
drawButton(_markerStates[0], 0, screenManager);
|
||||
drawButton(_markerStates[1], 2, screenManager);
|
||||
drawButton(_markerStates[2], 4, screenManager);
|
||||
_text.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetStarfield::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
|
||||
if (!_petControl->_remoteTarget)
|
||||
return false;
|
||||
|
||||
if (_imgStarfield.MouseButtonDownMsg(msg->_mousePos)) {
|
||||
CPETHelmetOnOffMsg helmetMsg;
|
||||
helmetMsg.execute(_petControl->_remoteTarget);
|
||||
} else if (_imgPhoto.MouseButtonDownMsg(msg->_mousePos)) {
|
||||
if (_hasReference) {
|
||||
_photoOn = !_photoOn;
|
||||
CPETPhotoOnOffMsg photoMsg;
|
||||
photoMsg.execute(_petControl->_remoteTarget);
|
||||
} else {
|
||||
_petControl->displayMessage(SUPPLY_GALACTIC_REFERENCE);
|
||||
}
|
||||
} else if (!_btnSetDest.MouseButtonDownMsg(msg->_mousePos)) {
|
||||
return markersMouseDown(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetStarfield::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
|
||||
if (!_petControl->_remoteTarget || !_btnSetDest.MouseButtonUpMsg(msg->_mousePos))
|
||||
return false;
|
||||
|
||||
if (_petControl) {
|
||||
CStarControl *starControl = _petControl->getStarControl();
|
||||
|
||||
if (starControl && starControl->canSetStarDestination()) {
|
||||
CPETSetStarDestinationMsg starfieldMsg;
|
||||
starfieldMsg.execute(_petControl->_remoteTarget);
|
||||
starControl->starDestinationSet();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPetStarfield::isValid(CPetControl *petControl) {
|
||||
return setupControl(petControl);
|
||||
}
|
||||
|
||||
void CPetStarfield::load(SimpleFile *file, int param) {
|
||||
if (!param) {
|
||||
_photoOn = file->readNumber();
|
||||
_hasReference = file->readNumber();
|
||||
}
|
||||
}
|
||||
|
||||
void CPetStarfield::postLoad() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void CPetStarfield::save(SimpleFile *file, int indent) {
|
||||
file->writeNumberLine(_photoOn, indent);
|
||||
file->writeNumberLine(_hasReference, indent);
|
||||
}
|
||||
|
||||
bool CPetStarfield::setupControl(CPetControl *petControl) {
|
||||
if (petControl) {
|
||||
_petControl = petControl;
|
||||
|
||||
Rect r(0, 0, 64, 64);
|
||||
r.translate(_rect1.left, _rect1.top);
|
||||
|
||||
_imgStarfield.setBounds(r);
|
||||
_imgStarfield.translate(15, 23);
|
||||
_imgPhoto.setBounds(r);
|
||||
_imgPhoto.translate(85, 23);
|
||||
_imgStarCtrl.setBounds(r);
|
||||
_imgStarCtrl.translate(85, 23);
|
||||
|
||||
r = Rect(0, 0, 34, 34);
|
||||
r.translate(468, 396);
|
||||
_leds[0].setBounds(r);
|
||||
_leds[1].setBounds(r);
|
||||
|
||||
r.translate(36, 0);
|
||||
_leds[2].setBounds(r);
|
||||
_leds[3].setBounds(r);
|
||||
|
||||
r.translate(36, 0);
|
||||
_leds[4].setBounds(r);
|
||||
_leds[5].setBounds(r);
|
||||
|
||||
r = Rect(0, 0, 157, 51);
|
||||
r.translate(224, 33);
|
||||
r.translate(20, 350);
|
||||
_btnSetDest.setBounds(r);
|
||||
|
||||
r = Rect(0, 0, 580, 15);
|
||||
r.translate(32, 445);
|
||||
_text.setBounds(r);
|
||||
_text.setHasBorder(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetStarfield::drawButton(MarkerState state, int index, CScreenManager *screenManager) {
|
||||
int offset = (int)state;
|
||||
if (_flickerCtr < 4 && state == MS_FLICKERING)
|
||||
offset = 0;
|
||||
if (state == MS_HIGHLIGHTED)
|
||||
offset = 1;
|
||||
|
||||
_leds[index + offset].draw(screenManager);
|
||||
}
|
||||
|
||||
void CPetStarfield::setButtons(int matchIndex, bool isMarkerClose) {
|
||||
_markerStates[0] = MS_BLANK;
|
||||
_markerStates[1] = MS_BLANK;
|
||||
_markerStates[2] = MS_BLANK;
|
||||
|
||||
if (matchIndex >= 0)
|
||||
_markerStates[0] = MS_HIGHLIGHTED;
|
||||
if (matchIndex >= 1)
|
||||
_markerStates[1] = MS_HIGHLIGHTED;
|
||||
if (matchIndex >= 2)
|
||||
_markerStates[2] = MS_HIGHLIGHTED;
|
||||
|
||||
if (isMarkerClose) {
|
||||
if (matchIndex == -1)
|
||||
_markerStates[0] = MS_FLICKERING;
|
||||
if (matchIndex == 0)
|
||||
_markerStates[1] = MS_FLICKERING;
|
||||
if (matchIndex == 1)
|
||||
_markerStates[2] = MS_FLICKERING;
|
||||
}
|
||||
|
||||
_flickerCtr = (_flickerCtr + 1) % 8;
|
||||
}
|
||||
|
||||
void CPetStarfield::makePetDirty() {
|
||||
_petControl->makeDirty();
|
||||
}
|
||||
|
||||
bool CPetStarfield::markersMouseDown(CMouseButtonDownMsg *msg) {
|
||||
if (markerMouseDown(0, msg, _leds[0].getRawBounds()))
|
||||
return true;
|
||||
if (markerMouseDown(1, msg, _leds[2].getRawBounds()))
|
||||
return true;
|
||||
if (markerMouseDown(2, msg, _leds[4].getRawBounds()))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CPetStarfield::markerMouseDown(int index, CMouseButtonDownMsg *msg, const Rect &rect) {
|
||||
if (!rect.contains(msg->_mousePos))
|
||||
return false;
|
||||
|
||||
switch (_markerStates[index]) {
|
||||
case MS_FLICKERING:
|
||||
// Marker is flickering, so lock it in
|
||||
if (_petControl->_remoteTarget) {
|
||||
CPETStarFieldLockMsg lockMsg(1);
|
||||
lockMsg.execute(_petControl->_remoteTarget);
|
||||
}
|
||||
break;
|
||||
|
||||
case MS_HIGHLIGHTED:
|
||||
// Marker is locked in. If the most recently locked marker
|
||||
// is clicked on, allow it to be unlocked
|
||||
if (index == 2 || _markerStates[index + 1] != MS_HIGHLIGHTED) {
|
||||
if (_petControl->_remoteTarget) {
|
||||
CPETStarFieldLockMsg lockMsg(0);
|
||||
lockMsg.execute(_petControl->_remoteTarget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
129
engines/titanic/pet_control/pet_starfield.h
Normal file
129
engines/titanic/pet_control/pet_starfield.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_STARFIELD_H
|
||||
#define TITANIC_PET_STARFIELD_H
|
||||
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
#include "titanic/pet_control/pet_gfx_element.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
enum MarkerState { MS_BLANK = 0, MS_FLICKERING = 1, MS_HIGHLIGHTED = 2};
|
||||
|
||||
class CPetStarfield : public CPetSection {
|
||||
private:
|
||||
CPetGfxElement _imgStarfield;
|
||||
CPetGfxElement _imgPhoto;
|
||||
CPetGfxElement _imgStarCtrl;
|
||||
CPetGfxElement _btnSetDest;
|
||||
MarkerState _markerStates[3];
|
||||
CPetGfxElement _leds[6];
|
||||
Rect _rect1;
|
||||
int _flickerCtr;
|
||||
CTextControl _text;
|
||||
bool _photoOn;
|
||||
bool _hasReference;
|
||||
private:
|
||||
/**
|
||||
* Setup the control
|
||||
*/
|
||||
bool setupControl(CPetControl *petControl);
|
||||
|
||||
/**
|
||||
* Draw a button
|
||||
*/
|
||||
void drawButton(MarkerState state, int index, CScreenManager *screenManager);
|
||||
|
||||
/**
|
||||
* Handles clicking on any of the three locked star LED markers
|
||||
*/
|
||||
bool markersMouseDown(CMouseButtonDownMsg *msg);
|
||||
|
||||
/**
|
||||
* Handles clicking on a specific locked star LED marker
|
||||
*/
|
||||
bool markerMouseDown(int index, CMouseButtonDownMsg *msg, const Rect &rect);
|
||||
public:
|
||||
CPetStarfield();
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Reset the section
|
||||
*/
|
||||
bool reset() override;
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override;
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override;
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file, int param) override;
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override;
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override;
|
||||
|
||||
/**
|
||||
* Sets the display for the marker buttons
|
||||
*/
|
||||
void setButtons(int matchIndex, bool isMarkerClose);
|
||||
|
||||
/**
|
||||
* Sets whether the player has the galactic reference material
|
||||
*/
|
||||
void setHasReference(bool hasRef) { _hasReference = hasRef; }
|
||||
|
||||
/**
|
||||
* Make the PET as dirty, requiring a redraw
|
||||
*/
|
||||
void makePetDirty();
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_STARFIELD_H */
|
||||
67
engines/titanic/pet_control/pet_translation.cpp
Normal file
67
engines/titanic/pet_control/pet_translation.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "titanic/pet_control/pet_translation.h"
|
||||
#include "titanic/pet_control/pet_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CPetTranslation::CPetTranslation() {
|
||||
Rect rect1(32, 368, 586, 438);
|
||||
_message.setBounds(rect1);
|
||||
_message.resize(50);
|
||||
_message.setHasBorder(false);
|
||||
|
||||
Rect rect2(32, 445, 586, 460);
|
||||
_tooltip.setBounds(rect2);
|
||||
_tooltip.setHasBorder(false);
|
||||
}
|
||||
|
||||
bool CPetTranslation::setup(CPetControl *petControl) {
|
||||
if (petControl && setupControl(petControl))
|
||||
return reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
void CPetTranslation::draw(CScreenManager *screenManager) {
|
||||
_message.draw(screenManager);
|
||||
_tooltip.draw(screenManager);
|
||||
}
|
||||
|
||||
bool CPetTranslation::setupControl(CPetControl *petControl) {
|
||||
if (petControl)
|
||||
_petControl = petControl;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPetTranslation::clearTranslation() {
|
||||
_message.setup();
|
||||
}
|
||||
|
||||
void CPetTranslation::addTranslation(const CString &str1, const CString &str2) {
|
||||
CString msg = CString::format("%s%s - %s%s",
|
||||
CTextControl::getColorText(0, 0, 0x80).c_str(), str1.c_str(),
|
||||
CTextControl::getColorText(0, 0, 0).c_str(), str2.c_str());
|
||||
_message.addLine(msg);
|
||||
_petControl->makeDirty();
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
104
engines/titanic/pet_control/pet_translation.h
Normal file
104
engines/titanic/pet_control/pet_translation.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TITANIC_PET_TRANSLATION_H
|
||||
#define TITANIC_PET_TRANSLATION_H
|
||||
|
||||
#include "titanic/pet_control/pet_section.h"
|
||||
#include "titanic/gfx/text_control.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CPetTranslation : public CPetSection {
|
||||
private:
|
||||
CTextControl _message;
|
||||
CTextControl _tooltip;
|
||||
private:
|
||||
/**
|
||||
* Setup the control
|
||||
*/
|
||||
bool setupControl(CPetControl *petControl);
|
||||
public:
|
||||
CPetTranslation();
|
||||
|
||||
/**
|
||||
* Sets up the section
|
||||
*/
|
||||
bool setup(CPetControl *petControl) override;
|
||||
|
||||
/**
|
||||
* Reset the section
|
||||
*/
|
||||
bool reset() override { return true; }
|
||||
|
||||
/**
|
||||
* Draw the section
|
||||
*/
|
||||
void draw(CScreenManager *screenManager) override;
|
||||
|
||||
/**
|
||||
* Following are handlers for the various messages that the PET can
|
||||
* pass onto the currently active section/area
|
||||
*/
|
||||
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) override { return false; }
|
||||
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) override { return false; }
|
||||
|
||||
/**
|
||||
* Returns true if the object is in a valid state
|
||||
*/
|
||||
bool isValid(CPetControl *petControl) override {
|
||||
return setupControl(petControl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the data for the class from file
|
||||
*/
|
||||
void load(SimpleFile *file, int param) override {}
|
||||
|
||||
/**
|
||||
* Called after a game has been loaded
|
||||
*/
|
||||
void postLoad() override { reset(); }
|
||||
|
||||
/**
|
||||
* Save the data for the class to file
|
||||
*/
|
||||
void save(SimpleFile *file, int indent) override {}
|
||||
|
||||
/**
|
||||
* Get a reference to the tooltip text associated with the section
|
||||
*/
|
||||
CTextControl *getText() override { return &_tooltip; }
|
||||
|
||||
/**
|
||||
* Clear any current translation text
|
||||
*/
|
||||
void clearTranslation();
|
||||
|
||||
/**
|
||||
* Adds a line to the translation display
|
||||
*/
|
||||
void addTranslation(const CString &str1, const CString &str2);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
||||
#endif /* TITANIC_PET_TRANSLATION_H */
|
||||
Reference in New Issue
Block a user