2021-03-20 23:18:33 +01: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-03-24 15:17:48 +01:00
|
|
|
#include "trecision/nl/extern.h"
|
|
|
|
#include "trecision/nl/message.h"
|
2021-04-13 21:48:04 +03:00
|
|
|
#include "trecision/nl/proto.h"
|
|
|
|
#include "trecision/nl/struct.h"
|
|
|
|
#include "trecision/logic.h"
|
|
|
|
#include "trecision/trecision.h"
|
2021-03-24 09:14:53 +01:00
|
|
|
|
2021-03-20 23:18:33 +01:00
|
|
|
namespace Trecision {
|
2021-03-24 15:17:48 +01:00
|
|
|
|
|
|
|
void TrecisionEngine::initNames() {
|
2021-04-01 10:27:14 +03:00
|
|
|
_sysText[kMessageSavePosition] = "SAVE POSITION";
|
|
|
|
_sysText[kMessageEmptySpot] = "EMPTY SLOT";
|
|
|
|
_sysText[kMessageLoadPosition] = "LOAD POSITION";
|
|
|
|
_sysText[kMessageConfirmExit] = "Are you sure that you want to quit (y/n)?";
|
|
|
|
_sysText[kMessageDemoOver] = "This demo is over.";
|
|
|
|
_sysText[kMessageError] = "ERROR!";
|
|
|
|
_sysText[kMessageUse] = "Use ";
|
|
|
|
_sysText[kMessageWith] = " with ";
|
|
|
|
_sysText[kMessageGoto] = "Go to ";
|
|
|
|
_sysText[kMessageGoto2] = "Go to ... ";
|
2021-03-24 15:17:48 +01:00
|
|
|
|
|
|
|
_sentence[0] = " "; // Use it like a buffer !!!!
|
|
|
|
_objName[0] = " ";
|
|
|
|
}
|
|
|
|
|
2021-03-20 23:18:33 +01:00
|
|
|
/* --------------------------------------------------
|
|
|
|
* getNextSentence
|
|
|
|
* --------------------------------------------------*/
|
|
|
|
char *TrecisionEngine::getNextSentence() {
|
|
|
|
while (*_textPtr) {
|
|
|
|
*_textPtr = ~(*_textPtr);
|
|
|
|
_textPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
_textPtr++;
|
|
|
|
return _textPtr;
|
|
|
|
}
|
|
|
|
|
2021-03-24 09:14:53 +01:00
|
|
|
/*-------------------------------------------------------------------------*/
|
2021-03-24 15:17:48 +01:00
|
|
|
/* addText */
|
2021-03-24 09:14:53 +01:00
|
|
|
/*-------------------------------------------------------------------------*/
|
2021-04-14 03:04:10 +03:00
|
|
|
void TrecisionEngine::addText(uint16 x, uint16 y, const char *text, uint16 tcol, uint16 scol) {
|
2021-03-24 09:14:53 +01:00
|
|
|
_textStackTop++;
|
|
|
|
if (_textStackTop >= MAXTEXTSTACK) {
|
|
|
|
warning("MAXTEXTSTACK Reached!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_textStack[_textStackTop].x = x;
|
|
|
|
_textStack[_textStackTop].y = y;
|
|
|
|
_textStack[_textStackTop].tcol = tcol;
|
|
|
|
_textStack[_textStackTop].scol = scol;
|
2021-04-14 03:04:10 +03:00
|
|
|
_textStack[_textStackTop].clear = false;
|
|
|
|
strcpy(_textStack[_textStackTop].text, text);
|
2021-03-24 09:14:53 +01:00
|
|
|
}
|
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
/* ------------------------------------------------
|
2021-03-24 09:14:53 +01:00
|
|
|
clearText
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void TrecisionEngine::clearText() {
|
|
|
|
if (_textStackTop >= 0) {
|
|
|
|
// The stack isn't empty
|
2021-04-14 03:04:10 +03:00
|
|
|
if (!_textStack[_textStackTop].clear)
|
2021-03-24 09:14:53 +01:00
|
|
|
// The previous is a string to write, return
|
|
|
|
_textStackTop--;
|
|
|
|
} else {
|
|
|
|
// the stack is empty
|
|
|
|
_textStackTop = 0;
|
2021-04-14 03:04:10 +03:00
|
|
|
_textStack[_textStackTop].clear = true;
|
2021-03-24 09:14:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
/* ------------------------------------------------
|
2021-03-24 09:14:53 +01:00
|
|
|
drawString
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void TrecisionEngine::drawString() {
|
|
|
|
for (int16 i = 0; i <= _textStackTop; i++) {
|
2021-04-14 03:04:10 +03:00
|
|
|
if (_textStack[i].clear)
|
2021-03-24 09:14:53 +01:00
|
|
|
doClearText();
|
|
|
|
else
|
2021-03-24 15:17:48 +01:00
|
|
|
_textStack[i].doText();
|
2021-03-24 09:14:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* redrawString */
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
void TrecisionEngine::redrawString() {
|
2021-04-13 20:03:56 +03:00
|
|
|
if (!_flagDialogActive && !_flagDialogMenuActive && !_flagSomeoneSpeaks && !_flagscriptactive && g_vm->isCursorVisible()) {
|
|
|
|
if (isInventoryArea(g_vm->_mouseY))
|
2021-03-24 09:14:53 +01:00
|
|
|
doEvent(MC_INVENTORY, ME_SHOWICONNAME, MP_DEFAULT, 0, 0, 0, 0);
|
|
|
|
else {
|
2021-04-13 20:03:56 +03:00
|
|
|
CheckMask(g_vm->_mouseX, g_vm->_mouseY);
|
2021-03-24 09:14:53 +01:00
|
|
|
ShowObjName(_curObj, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
/* ------------------------------------------------
|
|
|
|
doText
|
2021-03-24 09:14:53 +01:00
|
|
|
--------------------------------------------------*/
|
2021-03-24 15:17:48 +01:00
|
|
|
void StackText::doText() {
|
2021-03-24 09:14:53 +01:00
|
|
|
curString.x = x;
|
|
|
|
curString.y = y;
|
2021-04-14 03:04:10 +03:00
|
|
|
curString.dx = TextLength(text, 0);
|
2021-03-24 09:14:53 +01:00
|
|
|
if ((y == MAXY - CARHEI) && (curString.dx > 600))
|
|
|
|
curString.dx = curString.dx * 3 / 5;
|
|
|
|
else if ((y != MAXY - CARHEI) && (curString.dx > 960))
|
|
|
|
curString.dx = curString.dx * 2 / 5;
|
|
|
|
else if ((y != MAXY - CARHEI) && (curString.dx > 320))
|
|
|
|
curString.dx = curString.dx * 3 / 5;
|
|
|
|
|
2021-04-14 03:04:10 +03:00
|
|
|
curString.text = text;
|
2021-04-07 16:47:25 +03:00
|
|
|
curString._subtitleRect.left = 0;
|
|
|
|
curString._subtitleRect.top = 0;
|
|
|
|
curString._subtitleRect.right = curString.dx;
|
2021-03-24 09:14:53 +01:00
|
|
|
uint16 hstring = curString.checkDText();
|
2021-04-07 16:47:25 +03:00
|
|
|
curString._subtitleRect.bottom = hstring;
|
2021-03-24 09:14:53 +01:00
|
|
|
curString.dy = hstring;
|
|
|
|
curString.tcol = tcol;
|
|
|
|
curString.scol = scol;
|
|
|
|
|
|
|
|
if (curString.y <= hstring)
|
|
|
|
curString.y += hstring;
|
|
|
|
else
|
|
|
|
curString.y -= hstring;
|
|
|
|
|
|
|
|
if (curString.y <= VIDEOTOP)
|
|
|
|
curString.y = VIDEOTOP + 1;
|
|
|
|
|
|
|
|
TextStatus |= TEXT_DRAW;
|
|
|
|
}
|
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
/* ------------------------------------------------
|
|
|
|
doClearText
|
2021-03-24 09:14:53 +01:00
|
|
|
--------------------------------------------------*/
|
|
|
|
void TrecisionEngine::doClearText() {
|
2021-04-07 16:47:25 +03:00
|
|
|
if ((oldString.text == nullptr) && (curString.text)) {
|
2021-03-24 09:14:53 +01:00
|
|
|
oldString.set(curString);
|
2021-04-07 16:47:25 +03:00
|
|
|
curString.text = nullptr;
|
2021-03-24 09:14:53 +01:00
|
|
|
|
|
|
|
TextStatus |= TEXT_DEL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
/* --------------------------------------------------
|
|
|
|
* setRoom
|
|
|
|
* --------------------------------------------------*/
|
|
|
|
void TrecisionEngine::setRoom(uint16 r, bool b) {
|
|
|
|
_logicMgr->setRoom(r, b);
|
|
|
|
RegenRoom();
|
|
|
|
}
|
|
|
|
|
2021-03-20 23:18:33 +01:00
|
|
|
} // End of namespace Trecision
|