scummvm/engines/twine/debug_grid.cpp

121 lines
4.1 KiB
C++
Raw Normal View History

/* 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.
*
*/
#include "twine/debug_grid.h"
#include "common/debug.h"
#include "twine/grid.h"
2020-10-23 13:44:38 +02:00
#include "twine/input.h"
#include "twine/redraw.h"
#include "twine/scene.h"
#include "twine/twine.h"
namespace TwinE {
DebugGrid::DebugGrid(TwinEEngine *engine) : _engine(engine) {
2020-10-22 18:42:01 +02:00
canChangeScenes = _engine->cfgfile.Debug;
}
2020-10-24 13:46:18 +02:00
void DebugGrid::changeGridCamera() {
if (!useFreeCamera) {
return;
}
// Press up - more X positions
if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugGridCameraPressUp)) {
_engine->_grid->newCameraZ--;
_engine->_redraw->reqBgRedraw = true;
}
2020-10-24 13:46:18 +02:00
// Press down - less X positions
else if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugGridCameraPressDown)) {
_engine->_grid->newCameraZ++;
_engine->_redraw->reqBgRedraw = true;
}
2020-10-24 13:46:18 +02:00
// Press left - less Z positions
else if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugGridCameraPressLeft)) {
_engine->_grid->newCameraX--;
_engine->_redraw->reqBgRedraw = true;
}
2020-10-24 13:46:18 +02:00
// Press right - more Z positions
else if (_engine->_input->toggleActionIfActive(TwinEActionType::DebugGridCameraPressRight)) {
_engine->_grid->newCameraX++;
_engine->_redraw->reqBgRedraw = true;
}
}
2020-10-24 13:46:18 +02:00
void DebugGrid::changeGrid() {
if (!canChangeScenes) {
return;
}
// Press up - more X positions
2020-10-24 13:46:18 +02:00
if (_engine->_input->toggleActionIfActive(TwinEActionType::NextRoom)) {
_engine->_scene->currentSceneIdx++;
if (_engine->_scene->currentSceneIdx > NUM_SCENES)
_engine->_scene->currentSceneIdx = 0;
_engine->_scene->needChangeScene = _engine->_scene->currentSceneIdx;
2020-10-22 12:42:57 +02:00
_engine->_redraw->reqBgRedraw = true;
}
// Press down - less X positions
2020-10-24 13:46:18 +02:00
if (_engine->_input->toggleActionIfActive(TwinEActionType::PreviousRoom)) {
_engine->_scene->currentSceneIdx--;
if (_engine->_scene->currentSceneIdx < 0)
_engine->_scene->currentSceneIdx = NUM_SCENES;
_engine->_scene->needChangeScene = _engine->_scene->currentSceneIdx;
2020-10-22 12:42:57 +02:00
_engine->_redraw->reqBgRedraw = true;
}
}
2020-10-24 13:46:18 +02:00
void DebugGrid::applyCellingGrid() {
// Increase celling grid index
2020-10-24 13:46:18 +02:00
if (_engine->_input->toggleActionIfActive(TwinEActionType::IncreaseCellingGridIndex)) {
_engine->_grid->cellingGridIdx++;
if (_engine->_grid->cellingGridIdx > 133)
_engine->_grid->cellingGridIdx = 133;
}
// Decrease celling grid index
2020-10-24 13:46:18 +02:00
else if (_engine->_input->toggleActionIfActive(TwinEActionType::DecreaseCellingGridIndex)) {
_engine->_grid->cellingGridIdx--;
if (_engine->_grid->cellingGridIdx < 0)
_engine->_grid->cellingGridIdx = 0;
}
// Enable/disable celling grid
2020-10-24 13:46:18 +02:00
else if (_engine->_input->toggleActionIfActive(TwinEActionType::ApplyCellingGrid)) {
if (_engine->_grid->useCellingGrid == -1) {
_engine->_grid->useCellingGrid = 1;
//createGridMap();
_engine->_grid->initCellingGrid(_engine->_grid->cellingGridIdx);
debug("Enable Celling Grid index: %d", _engine->_grid->cellingGridIdx);
_engine->_scene->needChangeScene = -2; // tricky to make the fade
} else if (_engine->_grid->useCellingGrid == 1) {
_engine->_grid->useCellingGrid = -1;
_engine->_grid->createGridMap();
2020-10-22 12:42:57 +02:00
_engine->_redraw->reqBgRedraw = true;
debug("Disable Celling Grid index: %d", _engine->_grid->cellingGridIdx);
_engine->_scene->needChangeScene = -2; // tricky to make the fade
}
}
}
} // namespace TwinE