2021-09-05 17:14:13 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-08-30 19:08:22 +00:00
|
|
|
#include "common/events.h"
|
|
|
|
|
|
|
|
#include "hypno/grammar.h"
|
|
|
|
#include "hypno/hypno.h"
|
|
|
|
|
|
|
|
namespace Hypno {
|
|
|
|
|
|
|
|
//Actions
|
|
|
|
|
|
|
|
void HypnoEngine::runMenu(Hotspots hs) {
|
|
|
|
const Hotspot h = *hs.begin();
|
|
|
|
assert(h.type == MakeMenu);
|
2021-09-05 16:26:53 +00:00
|
|
|
debugC(1, kHypnoDebugScene, "hotspot actions size: %d", h.actions.size());
|
2021-08-30 19:08:22 +00:00
|
|
|
for (Actions::const_iterator itt = h.actions.begin(); itt != h.actions.end(); ++itt) {
|
|
|
|
Action *action = *itt;
|
2021-10-24 19:11:32 +00:00
|
|
|
switch (action->type) {
|
|
|
|
case QuitAction:
|
|
|
|
runQuit((Quit *)action);
|
|
|
|
break;
|
|
|
|
case BackgroundAction:
|
|
|
|
runBackground((Background *)action);
|
|
|
|
break;
|
|
|
|
case OverlayAction:
|
|
|
|
runOverlay((Overlay *)action);
|
|
|
|
break;
|
|
|
|
case AmbientAction:
|
|
|
|
runAmbient((Ambient *)action);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-08-30 19:08:22 +00:00
|
|
|
|
|
|
|
//else if (typeid(*action) == typeid(Mice))
|
|
|
|
// runMice(h, (Mice*) action);
|
|
|
|
}
|
|
|
|
|
|
|
|
//if (h.stype == "SINGLE_RUN")
|
|
|
|
// loadImage("int_main/mainbutt.smk", 0, 0);
|
|
|
|
if (h.stype == "AUTO_BUTTONS" && _conversation.empty())
|
|
|
|
loadImage("int_main/resume.smk", 0, 0, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runBackground(Background *a) {
|
|
|
|
if (a->condition.size() > 0 && !_sceneState[a->condition])
|
|
|
|
return;
|
2021-09-17 07:05:04 +00:00
|
|
|
loadImage(a->path, a->origin.x, a->origin.y, false);
|
2021-08-30 19:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runOverlay(Overlay *a) {
|
2021-09-17 07:05:04 +00:00
|
|
|
loadImage(a->path, a->origin.x, a->origin.y, false);
|
2021-08-30 19:08:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runMice(Mice *a) {
|
|
|
|
changeCursor(a->path, a->index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runEscape(Escape *a) {
|
|
|
|
_nextHotsToRemove = stack.back();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runCutscene(Cutscene *a) {
|
|
|
|
stopSound();
|
|
|
|
disableCursor();
|
2021-09-17 07:05:04 +00:00
|
|
|
_music.clear();
|
2021-08-30 19:08:22 +00:00
|
|
|
_nextSequentialVideoToPlay.push_back(MVideo(a->path, Common::Point(0, 0), false, true, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runGlobal(Global *a) {
|
|
|
|
if (a->command == "TURNON")
|
|
|
|
_sceneState[a->variable] = 1;
|
|
|
|
else if (a->command == "TURNOFF")
|
|
|
|
_sceneState[a->variable] = 0;
|
2021-10-06 15:45:40 +00:00
|
|
|
else if (a->command == "TOGGLE")
|
|
|
|
_sceneState[a->variable] = !_sceneState[a->variable];
|
2021-08-30 19:08:22 +00:00
|
|
|
else
|
|
|
|
error("Invalid command %s", a->command.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runPlay(Play *a) {
|
|
|
|
if (a->condition.size() > 0 && !_sceneState[a->condition])
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (a->flag == "/BITMAP")
|
2021-09-17 07:05:04 +00:00
|
|
|
loadImage(a->path, a->origin.x, a->origin.y, false);
|
2021-08-30 19:08:22 +00:00
|
|
|
else {
|
|
|
|
_nextSequentialVideoToPlay.push_back(MVideo(a->path, a->origin, false, false, false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runAmbient(Ambient *a) {
|
2021-10-31 10:47:48 +00:00
|
|
|
if (a->flag == "/BITMAP") {
|
|
|
|
Graphics::Surface *frame = decodeFrame(a->path, a->frameNumber, true);
|
|
|
|
Graphics::Surface *sframe;
|
|
|
|
if (a->fullscreen)
|
|
|
|
sframe = frame->scale(_screenW, _screenH);
|
|
|
|
else
|
|
|
|
sframe = frame;
|
|
|
|
drawImage(*sframe, a->origin.x, a->origin.y, true);
|
|
|
|
//loadImage(a->path, a->origin.x, a->origin.y, false, a->frameNumber);
|
|
|
|
} else {
|
2021-08-30 19:08:22 +00:00
|
|
|
_nextSequentialVideoToPlay.push_back(MVideo(a->path, a->origin, false, a->fullscreen, a->flag == "/LOOP"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runWalN(WalN *a) {
|
|
|
|
if (a->condition.size() > 0 && !_sceneState[a->condition])
|
|
|
|
return;
|
|
|
|
if (a->flag == "/BITMAP")
|
2021-09-17 07:05:04 +00:00
|
|
|
loadImage(a->path, a->origin.x, a->origin.y, false);
|
2021-08-30 19:08:22 +00:00
|
|
|
else {
|
|
|
|
_nextSequentialVideoToPlay.push_back(MVideo(a->path, a->origin, false, false, false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runQuit(Quit *a) {
|
|
|
|
quitGame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runChangeLevel(ChangeLevel *a) {
|
|
|
|
_nextLevel = a->level;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HypnoEngine::runTalk(Talk *a) {
|
|
|
|
_conversation.push_back(a);
|
|
|
|
_refreshConversation = true;
|
|
|
|
}
|
|
|
|
|
2021-09-08 20:49:56 +00:00
|
|
|
} // End of namespace Hypno
|
|
|
|
|