2013-05-01 14:30:38 +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 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 02:34:20 +01:00
|
|
|
*
|
2013-05-01 14:30:38 +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.
|
2014-02-18 02:34:20 +01:00
|
|
|
*
|
2013-05-01 14:30:38 +03:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "base/plugins.h"
|
|
|
|
|
2013-05-01 15:15:08 +03:00
|
|
|
#include "common/archive.h"
|
2013-05-01 14:30:38 +03:00
|
|
|
#include "common/config-manager.h"
|
2016-07-27 23:58:11 +03:00
|
|
|
#include "common/debug-channels.h"
|
2016-04-14 17:43:56 +03:00
|
|
|
#include "audio/mixer.h"
|
2013-05-01 14:30:38 +03:00
|
|
|
|
|
|
|
#include "engines/util.h"
|
2016-12-26 19:13:07 +01:00
|
|
|
#include "graphics/surface.h"
|
2013-05-01 14:30:38 +03:00
|
|
|
|
|
|
|
#include "fullpipe/fullpipe.h"
|
2013-07-20 21:28:32 +03:00
|
|
|
#include "fullpipe/gameloader.h"
|
2013-07-26 15:42:11 +03:00
|
|
|
#include "fullpipe/messages.h"
|
2013-07-23 13:33:28 +03:00
|
|
|
#include "fullpipe/behavior.h"
|
2013-07-30 14:29:15 +03:00
|
|
|
#include "fullpipe/modal.h"
|
2013-07-31 20:06:13 +03:00
|
|
|
#include "fullpipe/input.h"
|
2013-12-24 00:08:18 +02:00
|
|
|
#include "fullpipe/motion.h"
|
2014-06-13 10:49:54 +03:00
|
|
|
#include "fullpipe/statics.h"
|
2013-08-07 00:43:08 +03:00
|
|
|
#include "fullpipe/scenes.h"
|
2013-11-19 19:02:00 -08:00
|
|
|
#include "fullpipe/floaters.h"
|
2013-12-07 00:16:56 +00:00
|
|
|
#include "fullpipe/console.h"
|
2014-05-03 11:37:13 +03:00
|
|
|
#include "fullpipe/constants.h"
|
2013-05-01 14:30:38 +03:00
|
|
|
|
|
|
|
namespace Fullpipe {
|
|
|
|
|
2013-12-20 16:08:02 +02:00
|
|
|
FullpipeEngine *g_fp = 0;
|
2013-08-07 00:43:08 +03:00
|
|
|
Vars *g_vars = 0;
|
2013-06-03 00:18:49 +03:00
|
|
|
|
2013-05-01 14:30:38 +03:00
|
|
|
FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
|
2016-07-28 11:25:20 +03:00
|
|
|
DebugMan.addDebugChannel(kDebugPathfinding, "path", "Pathfinding");
|
|
|
|
DebugMan.addDebugChannel(kDebugDrawing, "drawing", "Drawing");
|
|
|
|
DebugMan.addDebugChannel(kDebugLoading, "loading", "Scene loading");
|
|
|
|
DebugMan.addDebugChannel(kDebugAnimation, "animation", "Animation");
|
2016-08-13 20:51:11 +02:00
|
|
|
DebugMan.addDebugChannel(kDebugBehavior, "behavior", "Behavior");
|
2016-07-28 11:25:20 +03:00
|
|
|
DebugMan.addDebugChannel(kDebugMemory, "memory", "Memory management");
|
|
|
|
DebugMan.addDebugChannel(kDebugEvents, "events", "Event handling");
|
2016-08-28 11:11:27 +02:00
|
|
|
DebugMan.addDebugChannel(kDebugInventory, "inventory", "Inventory");
|
2016-08-28 12:44:28 +02:00
|
|
|
DebugMan.addDebugChannel(kDebugSceneLogic, "scenelogic", "Scene Logic");
|
2016-10-04 19:48:12 +02:00
|
|
|
DebugMan.addDebugChannel(kDebugInteractions, "interactions", "Interactions");
|
2016-07-28 11:25:20 +03:00
|
|
|
|
2013-05-01 14:30:38 +03:00
|
|
|
// Setup mixer
|
|
|
|
if (!_mixer->isReady()) {
|
|
|
|
warning("Sound initialization failed.");
|
|
|
|
}
|
|
|
|
|
2016-09-11 23:05:09 +02:00
|
|
|
syncSoundSettings();
|
|
|
|
_sfxVolume = ConfMan.getInt("sfx_volume") * 39 - 10000;
|
|
|
|
_musicVolume = ConfMan.getInt("music_volume");
|
2013-05-01 14:30:38 +03:00
|
|
|
|
|
|
|
_rnd = new Common::RandomSource("fullpipe");
|
2013-12-07 00:16:56 +00:00
|
|
|
_console = 0;
|
2013-05-01 14:30:38 +03:00
|
|
|
|
2013-06-24 16:22:26 -04:00
|
|
|
_gameProjectVersion = 0;
|
2013-07-12 09:03:02 +03:00
|
|
|
_pictureScale = 8;
|
2013-06-24 16:22:26 -04:00
|
|
|
_scrollSpeed = 0;
|
|
|
|
_currSoundListCount = 0;
|
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
_updateTicks = 0;
|
2013-08-09 01:19:57 +03:00
|
|
|
_lastInputTicks = 0;
|
|
|
|
_lastButtonUpTicks = 0;
|
2013-07-30 14:29:15 +03:00
|
|
|
|
2013-06-26 19:46:47 -04:00
|
|
|
_currArchive = 0;
|
|
|
|
|
2013-06-24 16:22:26 -04:00
|
|
|
_soundEnabled = true;
|
|
|
|
_flgSoundList = true;
|
|
|
|
|
2013-07-22 18:46:03 +03:00
|
|
|
_inputController = 0;
|
|
|
|
_inputDisabled = false;
|
|
|
|
|
2013-09-15 22:29:00 +03:00
|
|
|
_normalSpeed = true;
|
|
|
|
|
|
|
|
_currentCheat = -1;
|
|
|
|
_currentCheatPos = 0;
|
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
_modalObject = 0;
|
2014-06-29 22:12:52 +03:00
|
|
|
_origFormat = 0;
|
2013-07-30 14:29:15 +03:00
|
|
|
|
2014-01-26 16:52:33 +02:00
|
|
|
_liftEnterMQ = 0;
|
|
|
|
_liftExitMQ = 0;
|
|
|
|
_lift = 0;
|
2014-01-26 16:18:03 +02:00
|
|
|
_lastLiftButton = 0;
|
2014-01-26 16:52:33 +02:00
|
|
|
_liftX = 0;
|
|
|
|
_liftY = 0;
|
2014-01-26 16:18:03 +02:00
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
_gameContinue = true;
|
|
|
|
_needRestart = false;
|
2013-10-28 23:10:33 +02:00
|
|
|
_flgPlayIntro = true;
|
2013-08-09 01:19:57 +03:00
|
|
|
_gamePaused = false;
|
|
|
|
_inputArFlag = false;
|
|
|
|
_recordEvents = false;
|
2014-04-09 23:43:50 +03:00
|
|
|
_mainMenu_debugEnabled = false;
|
2013-08-09 01:19:57 +03:00
|
|
|
|
2013-08-11 23:56:14 +03:00
|
|
|
_flgGameIsRunning = true;
|
2013-07-31 20:06:13 +03:00
|
|
|
|
|
|
|
_isProcessingMessages = false;
|
2013-07-28 14:54:25 +03:00
|
|
|
|
|
|
|
_musicAllowed = -1;
|
2014-01-06 22:39:30 +02:00
|
|
|
_musicGameVar = 0;
|
2014-04-26 14:22:50 +03:00
|
|
|
_musicMinDelay = 0;
|
|
|
|
_musicMaxDelay = 0;
|
|
|
|
_musicLocal = 0;
|
|
|
|
_trackStartDelay = 0;
|
|
|
|
|
2016-11-25 18:44:14 +01:00
|
|
|
_soundStream1 = new Audio::SoundHandle();
|
|
|
|
_soundStream2 = new Audio::SoundHandle();
|
|
|
|
_soundStream3 = new Audio::SoundHandle();
|
|
|
|
_soundStream4 = new Audio::SoundHandle();
|
|
|
|
|
|
|
|
_stream2playing = false;
|
2016-04-14 17:43:56 +03:00
|
|
|
|
2014-04-26 14:22:50 +03:00
|
|
|
_numSceneTracks = 0;
|
|
|
|
_sceneTrackHasSequence = false;
|
|
|
|
_sceneTrackIsPlaying = false;
|
2013-07-17 14:44:14 +03:00
|
|
|
|
2013-07-20 16:08:05 +03:00
|
|
|
_aniMan = 0;
|
2013-07-20 23:55:04 +03:00
|
|
|
_aniMan2 = 0;
|
|
|
|
_currentScene = 0;
|
2014-01-10 21:25:56 +02:00
|
|
|
_loaderScene = 0;
|
2013-07-20 16:08:05 +03:00
|
|
|
_scene2 = 0;
|
2014-01-10 21:25:56 +02:00
|
|
|
_scene3 = 0;
|
2013-07-28 14:54:25 +03:00
|
|
|
_movTable = 0;
|
2013-11-19 19:02:00 -08:00
|
|
|
_floaters = 0;
|
2016-08-14 20:05:32 +02:00
|
|
|
_aniHandler = 0;
|
2013-07-20 16:08:05 +03:00
|
|
|
|
|
|
|
_globalMessageQueueList = 0;
|
2013-07-22 22:46:08 +03:00
|
|
|
_messageHandlers = 0;
|
|
|
|
|
|
|
|
_updateScreenCallback = 0;
|
2013-07-23 01:42:22 +03:00
|
|
|
_updateCursorCallback = 0;
|
|
|
|
|
2013-07-28 17:22:18 +03:00
|
|
|
_msgX = 0;
|
|
|
|
_msgY = 0;
|
|
|
|
_msgObjectId2 = 0;
|
|
|
|
_msgId = 0;
|
2013-07-31 20:06:13 +03:00
|
|
|
_mouseVirtX = 0;
|
|
|
|
_mouseVirtY = 0;
|
2013-07-28 17:22:18 +03:00
|
|
|
|
2013-08-11 17:18:42 +03:00
|
|
|
_currSelectedInventoryItemId = 0;
|
|
|
|
|
2013-07-23 13:33:28 +03:00
|
|
|
_behaviorManager = 0;
|
|
|
|
|
2013-07-23 01:42:22 +03:00
|
|
|
_cursorId = 0;
|
2013-07-20 16:08:05 +03:00
|
|
|
|
2013-08-20 00:34:15 +03:00
|
|
|
_keyState = Common::KEYCODE_INVALID;
|
|
|
|
_buttonState = 0;
|
|
|
|
|
|
|
|
_gameLoader = 0;
|
|
|
|
_gameProject = 0;
|
|
|
|
|
|
|
|
_updateFlag = true;
|
|
|
|
_flgCanOpenMap = true;
|
|
|
|
|
|
|
|
_sceneWidth = 1;
|
|
|
|
_sceneHeight = 1;
|
|
|
|
|
|
|
|
for (int i = 0; i < 11; i++)
|
|
|
|
_currSoundList1[i] = 0;
|
2014-10-28 16:22:48 +02:00
|
|
|
|
2013-08-20 00:34:15 +03:00
|
|
|
for (int i = 0; i < 200; i++)
|
|
|
|
_mapTable[i] = 0;
|
|
|
|
|
|
|
|
_inventoryScene = 0;
|
|
|
|
_inventory = 0;
|
|
|
|
|
2013-08-24 22:12:00 +03:00
|
|
|
_minCursorId = 0xffff;
|
|
|
|
_maxCursorId = 0;
|
|
|
|
_objectAtCursor = 0;
|
|
|
|
_objectIdAtCursor = 0;
|
2013-08-24 21:07:16 +03:00
|
|
|
|
2013-12-16 11:18:33 +02:00
|
|
|
_arcadeOverlay = 0;
|
|
|
|
_arcadeOverlayHelper = 0;
|
|
|
|
_arcadeOverlayX = 0;
|
|
|
|
_arcadeOverlayY = 0;
|
|
|
|
_arcadeOverlayMidX = 0;
|
|
|
|
_arcadeOverlayMidY = 0;
|
|
|
|
|
2013-08-20 00:34:15 +03:00
|
|
|
_isSaveAllowed = true;
|
|
|
|
|
2013-12-20 16:08:02 +02:00
|
|
|
g_fp = this;
|
2013-08-07 00:43:08 +03:00
|
|
|
g_vars = new Vars;
|
2013-05-01 14:30:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
FullpipeEngine::~FullpipeEngine() {
|
|
|
|
delete _rnd;
|
2013-12-07 00:16:56 +00:00
|
|
|
delete _console;
|
2013-07-20 16:08:05 +03:00
|
|
|
delete _globalMessageQueueList;
|
2016-11-25 18:44:14 +01:00
|
|
|
delete _soundStream1;
|
|
|
|
delete _soundStream2;
|
|
|
|
delete _soundStream3;
|
|
|
|
delete _soundStream4;
|
2013-05-01 14:30:38 +03:00
|
|
|
}
|
|
|
|
|
2013-07-20 16:08:05 +03:00
|
|
|
void FullpipeEngine::initialize() {
|
|
|
|
_globalMessageQueueList = new GlobalMessageQueueList;
|
2013-07-23 13:33:28 +03:00
|
|
|
_behaviorManager = new BehaviorManager;
|
2013-07-27 23:54:06 +03:00
|
|
|
|
|
|
|
_sceneRect.left = 0;
|
|
|
|
_sceneRect.top = 0;
|
|
|
|
_sceneRect.right = 799;
|
|
|
|
_sceneRect.bottom = 599;
|
2013-11-19 19:02:00 -08:00
|
|
|
|
|
|
|
_floaters = new Floaters;
|
2016-08-14 20:05:32 +02:00
|
|
|
_aniHandler = new AniHandler;
|
2013-07-20 16:08:05 +03:00
|
|
|
}
|
2013-07-16 23:54:18 +03:00
|
|
|
|
2014-04-15 22:17:56 +03:00
|
|
|
void FullpipeEngine::restartGame() {
|
2014-05-03 11:37:13 +03:00
|
|
|
_floaters->stopAll();
|
|
|
|
|
|
|
|
clearGlobalMessageQueueList();
|
|
|
|
clearMessages();
|
|
|
|
|
|
|
|
initObjectStates();
|
|
|
|
|
|
|
|
if (_scene2) {
|
|
|
|
_scene2->getAniMan();
|
|
|
|
_scene2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_currentScene) {
|
|
|
|
_gameLoader->unloadScene(_currentScene->_sceneId);
|
|
|
|
|
|
|
|
_currentScene = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gameLoader->restoreDefPicAniInfos();
|
|
|
|
|
|
|
|
getGameLoaderInventory()->clear();
|
|
|
|
getGameLoaderInventory()->addItem(ANI_INV_MAP, 1);
|
|
|
|
getGameLoaderInventory()->rebuildItemRects();
|
|
|
|
|
|
|
|
initMap();
|
|
|
|
|
|
|
|
if (_flgPlayIntro) {
|
|
|
|
_gameLoader->loadScene(SC_INTRO1);
|
|
|
|
_gameLoader->gotoScene(SC_INTRO1, TrubaUp);
|
|
|
|
} else {
|
|
|
|
_gameLoader->loadScene(SC_1);
|
|
|
|
_gameLoader->gotoScene(SC_1, TrubaLeft);
|
|
|
|
}
|
2014-04-15 22:17:56 +03:00
|
|
|
}
|
|
|
|
|
2016-09-27 19:10:07 +02:00
|
|
|
Common::Error FullpipeEngine::loadGameState(int slot) {
|
|
|
|
if (_gameLoader->readSavegame(getSavegameFile(slot)))
|
|
|
|
return Common::kNoError;
|
|
|
|
else
|
|
|
|
return Common::kUnknownError;
|
|
|
|
}
|
2016-12-11 16:14:58 +01:00
|
|
|
|
2016-09-27 19:10:07 +02:00
|
|
|
Common::Error FullpipeEngine::saveGameState(int slot, const Common::String &description) {
|
|
|
|
if (_gameLoader->writeSavegame(_currentScene, getSavegameFile(slot)))
|
|
|
|
return Common::kNoError;
|
|
|
|
else
|
|
|
|
return Common::kUnknownError;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-20 16:08:05 +03:00
|
|
|
Common::Error FullpipeEngine::run() {
|
2014-06-17 14:00:47 +03:00
|
|
|
const Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0);
|
2013-05-01 14:30:38 +03:00
|
|
|
// Initialize backend
|
2017-10-01 00:56:01 -05:00
|
|
|
initGraphics(800, 600, &format);
|
2013-07-16 23:54:18 +03:00
|
|
|
|
2016-12-26 19:13:07 +01:00
|
|
|
_backgroundSurface = new Graphics::Surface;
|
|
|
|
_backgroundSurface->create(800, 600, format);
|
2013-05-01 14:30:38 +03:00
|
|
|
|
2014-06-17 14:55:26 +03:00
|
|
|
_origFormat = new Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
|
|
|
|
|
2013-12-07 00:16:56 +00:00
|
|
|
_console = new Console(this);
|
|
|
|
|
2013-07-20 16:08:05 +03:00
|
|
|
initialize();
|
2017-11-12 13:47:51 -06:00
|
|
|
_globalPalette = &_defaultPalette;
|
2013-07-20 16:08:05 +03:00
|
|
|
|
2013-05-01 14:30:38 +03:00
|
|
|
_isSaveAllowed = false;
|
|
|
|
|
2013-08-08 01:14:24 +03:00
|
|
|
int scene = 0;
|
2013-07-26 00:14:47 +03:00
|
|
|
if (ConfMan.hasKey("boot_param"))
|
2013-10-10 23:58:44 +03:00
|
|
|
scene = convertScene(ConfMan.getInt("boot_param"));
|
2013-07-26 00:14:47 +03:00
|
|
|
|
2016-09-27 18:29:05 +02:00
|
|
|
if (ConfMan.hasKey("save_slot"))
|
|
|
|
scene = -1;
|
|
|
|
|
2013-08-08 01:14:24 +03:00
|
|
|
if (!loadGam("fullpipe.gam", scene))
|
|
|
|
return Common::kNoGameDataFoundError;
|
2013-07-25 00:34:15 +03:00
|
|
|
|
2016-09-27 18:29:05 +02:00
|
|
|
if (ConfMan.hasKey("save_slot")) {
|
2016-09-27 19:10:07 +02:00
|
|
|
loadGameState(ConfMan.getInt("save_slot"));
|
2016-09-27 18:29:05 +02:00
|
|
|
}
|
|
|
|
|
2013-07-29 14:28:47 +03:00
|
|
|
#if 0
|
2013-07-28 16:56:36 +03:00
|
|
|
loadAllScenes();
|
|
|
|
#endif
|
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
_gameContinue = true;
|
|
|
|
|
2016-09-21 00:14:53 +02:00
|
|
|
int time1 = g_fp->_system->getMillis();
|
|
|
|
|
2016-10-02 13:23:04 +02:00
|
|
|
// Center mouse
|
|
|
|
_system->warpMouse(400, 300);
|
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
while (_gameContinue) {
|
2013-07-25 00:34:15 +03:00
|
|
|
updateEvents();
|
2013-07-30 14:29:15 +03:00
|
|
|
|
2016-09-21 00:14:53 +02:00
|
|
|
int time2 = g_fp->_system->getMillis();
|
|
|
|
|
|
|
|
// 30fps
|
|
|
|
if (time2 - time1 >= 33 || !_normalSpeed) {
|
|
|
|
time1 = time2;
|
|
|
|
updateScreen();
|
|
|
|
}
|
2013-07-30 14:29:15 +03:00
|
|
|
|
|
|
|
if (_needRestart) {
|
|
|
|
if (_modalObject) {
|
|
|
|
delete _modalObject;
|
|
|
|
_modalObject = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
freeGameLoader();
|
|
|
|
_currentScene = 0;
|
|
|
|
_updateTicks = 0;
|
2017-11-12 13:47:51 -06:00
|
|
|
_globalPalette = &_defaultPalette;
|
2014-10-28 16:22:48 +02:00
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
loadGam("fullpipe.gam");
|
|
|
|
_needRestart = false;
|
|
|
|
}
|
|
|
|
|
2016-09-21 00:14:53 +02:00
|
|
|
_system->delayMillis(5);
|
2013-07-25 00:34:15 +03:00
|
|
|
_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
2013-07-30 14:45:39 +03:00
|
|
|
freeGameLoader();
|
|
|
|
|
|
|
|
cleanup();
|
2013-07-25 00:34:15 +03:00
|
|
|
|
2013-05-01 14:30:38 +03:00
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FullpipeEngine::updateEvents() {
|
|
|
|
Common::Event event;
|
|
|
|
Common::EventManager *eventMan = _system->getEventManager();
|
2013-08-09 01:19:57 +03:00
|
|
|
ExCommand *ex;
|
2013-05-01 14:30:38 +03:00
|
|
|
|
|
|
|
while (eventMan->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
_keyState = event.kbd.keycode;
|
2013-08-09 01:19:57 +03:00
|
|
|
|
|
|
|
switch (event.kbd.keycode) {
|
|
|
|
case Common::KEYCODE_SPACE:
|
|
|
|
if (_gamePaused) {
|
|
|
|
if (_modalObject) {
|
|
|
|
if (_modalObject->init(42)) {
|
|
|
|
_modalObject->update();
|
|
|
|
} else {
|
|
|
|
_modalObject->saveload();
|
2013-09-18 19:26:02 +04:00
|
|
|
BaseModalObject *obj = _modalObject->_parentObj;
|
2013-08-09 01:19:57 +03:00
|
|
|
if (obj)
|
|
|
|
delete _modalObject;
|
|
|
|
_modalObject = obj;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_gameLoader->updateSystems(42);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ex = new ExCommand(0, 17, 36, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 23:54:43 +02:00
|
|
|
ex->_param = 32;
|
2013-08-09 01:19:57 +03:00
|
|
|
ex->_excFlags |= 3;
|
|
|
|
ex->handle();
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_s:
|
|
|
|
if (_gamePaused) {
|
|
|
|
_gamePaused = 0;
|
2013-08-11 23:56:14 +03:00
|
|
|
_flgGameIsRunning = true;
|
2013-08-09 01:19:57 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ex = new ExCommand(0, 17, 36, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 23:54:43 +02:00
|
|
|
ex->_param = event.kbd.keycode;
|
2013-08-09 01:19:57 +03:00
|
|
|
ex->_excFlags |= 3;
|
|
|
|
ex->handle();
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_q:
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
default:
|
2013-12-07 00:16:56 +00:00
|
|
|
if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
|
|
|
|
// Start the debugger
|
|
|
|
getDebugger()->attach();
|
|
|
|
getDebugger()->onFrame();
|
|
|
|
}
|
2013-08-09 01:19:57 +03:00
|
|
|
ex = new ExCommand(0, 17, 36, 0, 0, 0, 1, 0, 0, 0);
|
2016-09-04 23:54:43 +02:00
|
|
|
ex->_param = event.kbd.keycode;
|
2013-08-09 01:19:57 +03:00
|
|
|
ex->_excFlags |= 3;
|
|
|
|
ex->handle();
|
|
|
|
break;
|
|
|
|
}
|
2013-08-20 00:34:15 +03:00
|
|
|
break;
|
2013-05-01 14:30:38 +03:00
|
|
|
case Common::EVENT_KEYUP:
|
2013-08-09 01:19:57 +03:00
|
|
|
if (!_inputArFlag) {
|
|
|
|
ex = new ExCommand(0, 17, 37, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
ex->handle();
|
|
|
|
}
|
2013-05-01 14:30:38 +03:00
|
|
|
_keyState = Common::KEYCODE_INVALID;
|
|
|
|
break;
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
2013-08-09 01:19:57 +03:00
|
|
|
if (_recordEvents) {
|
2013-09-06 21:40:02 +03:00
|
|
|
ex = new ExCommand(0, 17, 31, event.mouse.x, event.mouse.y, 0, 1, 0, 0, 0);
|
2013-08-09 01:19:57 +03:00
|
|
|
ex->_excFlags |= 3;
|
|
|
|
ex->handle();
|
|
|
|
}
|
2013-08-10 23:41:38 +03:00
|
|
|
|
2013-08-11 17:18:42 +03:00
|
|
|
_mouseScreenPos = event.mouse;
|
2013-05-01 14:30:38 +03:00
|
|
|
break;
|
2013-07-17 14:44:14 +03:00
|
|
|
case Common::EVENT_QUIT:
|
2013-07-30 14:29:15 +03:00
|
|
|
_gameContinue = false;
|
2013-07-17 14:44:14 +03:00
|
|
|
break;
|
2014-05-14 12:11:58 +02:00
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
2013-08-09 01:19:57 +03:00
|
|
|
if (!_inputArFlag && (_updateTicks - _lastInputTicks) >= 2) {
|
2013-09-06 21:40:02 +03:00
|
|
|
ex = new ExCommand(0, 17, 107, event.mouse.x, event.mouse.y, 0, 1, 0, 0, 0);
|
2013-08-09 01:19:57 +03:00
|
|
|
ex->_excFlags |= 3;
|
|
|
|
_lastInputTicks = _updateTicks;
|
|
|
|
ex->handle();
|
|
|
|
}
|
2016-08-29 23:35:20 +02:00
|
|
|
_mouseScreenPos = event.mouse;
|
2013-08-09 01:19:57 +03:00
|
|
|
break;
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
if (!_inputArFlag && (_updateTicks - _lastInputTicks) >= 2) {
|
2013-09-06 21:40:02 +03:00
|
|
|
ex = new ExCommand(0, 17, 29, event.mouse.x, event.mouse.y, 0, 1, 0, 0, 0);
|
2013-08-09 01:19:57 +03:00
|
|
|
|
|
|
|
ex->_sceneClickX = _sceneRect.left + ex->_x;
|
|
|
|
ex->_sceneClickY = _sceneRect.top + ex->_y;
|
2016-09-04 23:54:43 +02:00
|
|
|
ex->_param = getGameLoaderInventory()->getSelectedItemId();
|
2013-08-09 01:19:57 +03:00
|
|
|
ex->_excFlags |= 3;
|
|
|
|
_lastInputTicks = _updateTicks;
|
|
|
|
ex->handle();
|
|
|
|
}
|
2016-08-29 23:35:20 +02:00
|
|
|
_mouseScreenPos = event.mouse;
|
2013-08-09 01:19:57 +03:00
|
|
|
break;
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
if (!_inputArFlag && (_updateTicks - _lastButtonUpTicks) >= 2) {
|
|
|
|
ex = new ExCommand(0, 17, 30, 0, 0, 0, 1, 0, 0, 0);
|
|
|
|
ex->_excFlags |= 3;
|
|
|
|
_lastButtonUpTicks = _updateTicks;
|
|
|
|
ex->handle();
|
|
|
|
}
|
2016-08-29 23:35:20 +02:00
|
|
|
_mouseScreenPos = event.mouse;
|
2013-08-09 01:19:57 +03:00
|
|
|
break;
|
2013-05-01 14:30:38 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-08-09 01:19:57 +03:00
|
|
|
|
2014-06-13 10:08:47 +03:00
|
|
|
// pollEvent() is implemented only for video player. So skip it.
|
|
|
|
//if (event.kbd.keycode == MSG_SC11_SHOWSWING && _modalObject) {
|
|
|
|
// _modalObject->pollEvent();
|
|
|
|
//}
|
2013-05-01 14:30:38 +03:00
|
|
|
}
|
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
void FullpipeEngine::freeGameLoader() {
|
2014-06-13 10:49:54 +03:00
|
|
|
setCursor(0);
|
|
|
|
delete _movTable;
|
|
|
|
_floaters->stopAll();
|
|
|
|
delete _gameLoader;
|
|
|
|
_currentScene = 0;
|
|
|
|
_scene2 = 0;
|
|
|
|
_loaderScene = 0;
|
2013-07-30 14:29:15 +03:00
|
|
|
}
|
|
|
|
|
2013-07-30 14:45:39 +03:00
|
|
|
void FullpipeEngine::cleanup() {
|
2014-06-13 10:44:52 +03:00
|
|
|
//cleanRecorder();
|
|
|
|
clearMessageHandlers();
|
|
|
|
clearMessages();
|
|
|
|
_globalMessageQueueList->compact();
|
|
|
|
|
|
|
|
for (uint i = 0; i < _globalMessageQueueList->size(); i++)
|
|
|
|
delete (*_globalMessageQueueList)[i];
|
|
|
|
|
|
|
|
stopAllSoundStreams();
|
2014-06-17 14:55:26 +03:00
|
|
|
|
|
|
|
delete _origFormat;
|
2016-12-26 19:13:07 +01:00
|
|
|
_backgroundSurface->free();
|
|
|
|
|
|
|
|
delete _backgroundSurface;
|
2013-07-30 14:45:39 +03:00
|
|
|
}
|
|
|
|
|
2013-07-30 14:29:15 +03:00
|
|
|
void FullpipeEngine::updateScreen() {
|
2016-07-28 00:36:53 +03:00
|
|
|
debugC(4, kDebugDrawing, "FullpipeEngine::updateScreen()");
|
2013-09-01 01:41:26 +03:00
|
|
|
|
2013-08-11 17:18:42 +03:00
|
|
|
_mouseVirtX = _mouseScreenPos.x + _sceneRect.left;
|
|
|
|
_mouseVirtY = _mouseScreenPos.y + _sceneRect.top;
|
2013-07-31 20:06:13 +03:00
|
|
|
|
|
|
|
//if (inputArFlag)
|
|
|
|
// updateGame_inputArFlag();
|
|
|
|
|
2013-08-31 09:47:51 +03:00
|
|
|
if (_modalObject || (_flgGameIsRunning && (_gameLoader->updateSystems(42), _modalObject != 0))) {
|
2013-08-11 23:56:14 +03:00
|
|
|
if (_flgGameIsRunning) {
|
2013-07-31 20:06:13 +03:00
|
|
|
if (_modalObject->init(42)) {
|
|
|
|
_modalObject->update();
|
|
|
|
} else {
|
|
|
|
_modalObject->saveload();
|
2013-09-18 19:26:02 +04:00
|
|
|
BaseModalObject *tmp = _modalObject->_parentObj;
|
2013-07-31 20:06:13 +03:00
|
|
|
|
2013-08-20 00:34:15 +03:00
|
|
|
delete _modalObject;
|
2013-07-31 20:06:13 +03:00
|
|
|
|
|
|
|
_modalObject = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (_currentScene) {
|
|
|
|
_currentScene->draw();
|
|
|
|
|
|
|
|
if (_inventoryScene)
|
|
|
|
_inventory->draw();
|
|
|
|
|
|
|
|
if (_updateScreenCallback)
|
|
|
|
_updateScreenCallback();
|
|
|
|
|
|
|
|
//if (inputArFlag && _currentScene) {
|
|
|
|
// vrtTextOut(*(_DWORD *)g_vrtHandle, smallNftData, "DEMO", 4, 380, 580);
|
|
|
|
// vrtTextOut(*(_DWORD *)g_vrtHandle, smallNftData, "Alt+F4 - exit", 14, 695, 580);
|
|
|
|
//}
|
|
|
|
} else {
|
|
|
|
//vrtRectangle(*(_DWORD *)g_vrtHandle, 0, 0, 0, 800, 600);
|
|
|
|
}
|
2013-08-11 17:18:42 +03:00
|
|
|
_inputController->drawCursor(_mouseScreenPos.x, _mouseScreenPos.y);
|
2013-07-31 20:06:13 +03:00
|
|
|
|
|
|
|
++_updateTicks;
|
2013-07-30 14:29:15 +03:00
|
|
|
}
|
|
|
|
|
2017-03-24 00:35:37 +02:00
|
|
|
int FullpipeEngine::getObjectEnumState(const Common::String &name, const char *state) {
|
2013-09-18 19:37:07 +04:00
|
|
|
GameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
if (!var) {
|
|
|
|
var = _gameLoader->_gameVar->addSubVarAsInt("OBJSTATES", 0);
|
|
|
|
}
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
var = var->getSubVarByName(name);
|
|
|
|
if (var) {
|
|
|
|
var = var->getSubVarByName("ENUMSTATES");
|
|
|
|
if (var)
|
|
|
|
return var->getSubVarAsInt(state);
|
|
|
|
}
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
return 0;
|
2013-06-19 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
2017-03-24 00:35:37 +02:00
|
|
|
int FullpipeEngine::getObjectState(const Common::String &objname) {
|
2013-09-18 19:37:07 +04:00
|
|
|
GameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
|
2013-08-07 20:52:23 +03:00
|
|
|
|
|
|
|
if (var)
|
|
|
|
return var->getSubVarAsInt(objname);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-24 00:35:37 +02:00
|
|
|
void FullpipeEngine::setObjectState(const Common::String &name, int state) {
|
2013-09-18 19:37:07 +04:00
|
|
|
GameVar *var = _gameLoader->_gameVar->getSubVarByName("OBJSTATES");
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
if (!var) {
|
|
|
|
var = _gameLoader->_gameVar->addSubVarAsInt("OBJSTATES", 0);
|
|
|
|
}
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
var->setSubVarAsInt(name, state);
|
2013-06-19 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
2013-08-11 17:18:42 +03:00
|
|
|
void FullpipeEngine::disableSaves(ExCommand *ex) {
|
2014-05-29 09:18:34 +03:00
|
|
|
if (_isSaveAllowed) {
|
|
|
|
_isSaveAllowed = false;
|
|
|
|
|
|
|
|
if (_globalMessageQueueList->size() && (*_globalMessageQueueList)[0] != 0) {
|
2014-06-05 00:39:52 +03:00
|
|
|
for (uint i = 0; i < _globalMessageQueueList->size(); i++) {
|
2014-05-29 09:18:34 +03:00
|
|
|
if ((*_globalMessageQueueList)[i]->_flags & 1)
|
|
|
|
if ((*_globalMessageQueueList)[i]->_id != ex->_parId && !(*_globalMessageQueueList)[i]->_isFinished)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-28 23:12:00 +02:00
|
|
|
// Original was makeing a save on every room entering
|
2016-10-01 00:24:07 +02:00
|
|
|
if (_currentScene) {
|
|
|
|
_gameLoader->saveScenePicAniInfos(_currentScene->_sceneId);
|
|
|
|
// _gameLoader->writeSavegame(_currentScene, "savetmp.sav");
|
|
|
|
}
|
2014-05-29 09:18:34 +03:00
|
|
|
}
|
2013-08-11 17:18:42 +03:00
|
|
|
}
|
|
|
|
|
2016-12-07 19:03:08 +01:00
|
|
|
bool FullpipeEngine::isSaveAllowed() {
|
|
|
|
if (!g_fp->_isSaveAllowed)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool allowed = true;
|
|
|
|
|
|
|
|
for (Common::Array<MessageQueue *>::iterator s = g_fp->_globalMessageQueueList->begin(); s != g_fp->_globalMessageQueueList->end(); ++s) {
|
|
|
|
if (!(*s)->_isFinished && ((*s)->getFlags() & 1))
|
|
|
|
allowed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return allowed;
|
|
|
|
}
|
|
|
|
|
2013-08-11 17:18:42 +03:00
|
|
|
|
2013-05-01 14:30:38 +03:00
|
|
|
} // End of namespace Fullpipe
|