scummvm/engines/pink/audio_info_mgr.cpp

89 lines
2.3 KiB
C++
Raw Normal View History

2018-06-13 08:45:30 +03:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2018-06-13 08:45:30 +03:00
*
* 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/>.
2018-06-13 08:45:30 +03:00
*
*/
#include "pink/audio_info_mgr.h"
#include "pink/archive.h"
2018-06-29 14:26:22 +03:00
#include "pink/constants.h"
2018-06-13 08:45:30 +03:00
#include "pink/objects/actors/lead_actor.h"
namespace Pink {
AudioInfoMgr::AudioInfoMgr(LeadActor *lead)
: _lead(lead) {}
void AudioInfoMgr::loadState(Archive &archive) {
_aboutWhom = archive.readString();
}
void AudioInfoMgr::saveState(Archive &archive) {
archive.writeString(_aboutWhom);
}
void AudioInfoMgr::start(Actor *actor) {
if (!actor->getPDALink().empty()) {
_aboutWhom = actor->getName();
playAudio();
showPDAButton();
} else
stop();
}
void AudioInfoMgr::stop() {
if (!_aboutWhom.empty()) {
stopAudio();
hidePDAButton();
_aboutWhom.clear();
}
}
void AudioInfoMgr::onLeftClick() {
Actor *actor = _lead->findActor(_aboutWhom);
assert(actor);
_lead->loadPDA(actor->getPDALink());
stopAudio();
}
void AudioInfoMgr::playAudio() {
2018-06-29 14:26:22 +03:00
Actor *audioInfo = _lead->findActor(kAudioInfoActor);
2018-06-13 08:45:30 +03:00
assert(audioInfo);
audioInfo->setAction(_aboutWhom);
}
void AudioInfoMgr::stopAudio() {
2018-06-29 14:26:22 +03:00
Actor *audioInfo = _lead->findActor(kAudioInfoActor);
2018-06-13 08:45:30 +03:00
assert(audioInfo);
2018-06-29 14:26:22 +03:00
audioInfo->setAction(kIdleAction);
2018-06-13 08:45:30 +03:00
}
void AudioInfoMgr::showPDAButton() {
2018-06-29 14:26:22 +03:00
Actor *pdaButton = _lead->findActor(kPdaButtonActor);
2018-06-13 08:45:30 +03:00
assert(pdaButton);
2018-06-29 14:26:22 +03:00
pdaButton->setAction(kShowAction);
2018-06-13 08:45:30 +03:00
}
void AudioInfoMgr::hidePDAButton() {
2018-06-29 14:26:22 +03:00
Actor *pdaButton = _lead->findActor(kPdaButtonActor);
2018-06-13 08:45:30 +03:00
assert(pdaButton);
2018-06-29 14:26:22 +03:00
pdaButton->setAction(kHideAction);
2018-06-13 08:45:30 +03:00
}
} // End of namespace Pink