Files
scummvm-cursorfix/engines/titanic/game/ship_setting_button.cpp
2026-02-02 04:50:13 +01:00

92 lines
2.3 KiB
C++

/* 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/game/ship_setting_button.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CShipSettingButton, CGameObject)
ON_MESSAGE(TurnOn)
ON_MESSAGE(TurnOff)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(EnterViewMsg)
END_MESSAGE_MAP()
CShipSettingButton::CShipSettingButton() : CGameObject(), _pressed(false), _enabled(false) {
}
void CShipSettingButton::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeQuotedLine(_target, indent);
file->writeNumberLine(_pressed, indent);
file->writeNumberLine(_enabled, indent);
CGameObject::save(file, indent);
}
void CShipSettingButton::load(SimpleFile *file) {
file->readNumber();
_target = file->readString();
_pressed = file->readNumber();
_enabled = file->readNumber();
CGameObject::load(file);
}
bool CShipSettingButton::TurnOn(CTurnOn *msg) {
_pressed = true;
return true;
}
bool CShipSettingButton::TurnOff(CTurnOff *msg) {
_pressed = false;
return true;
}
bool CShipSettingButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (_pressed) {
if (_enabled)
playMovie(8, 16, 0);
else
playMovie(0, 8, 0);
_enabled = !_enabled;
CActMsg actMsg(_enabled ? "EnableObject" : "DisableObject");
actMsg.execute(_target);
} else {
if (_enabled) {
playMovie(8, 16, 0);
playMovie(0, 8, 0);
} else {
playMovie(0, 16, 0);
}
}
return true;
}
bool CShipSettingButton::EnterViewMsg(CEnterViewMsg *msg) {
loadFrame(_enabled ? 8 : 16);
return true;
}
} // End of namespace Titanic