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-05-08 14:21:09 +03:00
|
|
|
#include "common/system.h"
|
2021-05-07 18:39:58 +01:00
|
|
|
|
2021-05-16 18:32:21 +01:00
|
|
|
#include "trecision/3d.h"
|
2021-05-09 13:55:50 +01:00
|
|
|
#include "trecision/scheduler.h"
|
2021-05-07 18:39:58 +01:00
|
|
|
#include "trecision/text.h"
|
2021-05-08 14:21:09 +03:00
|
|
|
#include "trecision/actor.h"
|
2021-04-28 21:33:53 +01:00
|
|
|
#include "trecision/defines.h"
|
2021-05-08 14:21:09 +03:00
|
|
|
#include "trecision/graphics.h"
|
2021-04-13 21:48:04 +03:00
|
|
|
#include "trecision/logic.h"
|
|
|
|
#include "trecision/trecision.h"
|
2021-05-13 23:53:34 +01:00
|
|
|
#include "trecision/struct.h"
|
2021-05-17 07:23:00 +01:00
|
|
|
#include "trecision/video.h"
|
2021-05-05 22:17:30 +01:00
|
|
|
|
2021-03-20 23:18:33 +01:00
|
|
|
namespace Trecision {
|
2021-03-24 15:17:48 +01:00
|
|
|
|
2021-03-20 23:18:33 +01:00
|
|
|
char *TrecisionEngine::getNextSentence() {
|
|
|
|
while (*_textPtr) {
|
|
|
|
*_textPtr = ~(*_textPtr);
|
|
|
|
_textPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
_textPtr++;
|
|
|
|
return _textPtr;
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:05:07 +01:00
|
|
|
/*-------------------------------------------------
|
2021-05-14 17:23:17 +01:00
|
|
|
* Compute string length from character begin to end
|
2021-04-25 23:05:07 +01:00
|
|
|
*-------------------------------------------------*/
|
2021-05-14 17:23:17 +01:00
|
|
|
uint16 TrecisionEngine::textLength(const Common::String &text, uint16 begin, uint16 end) {
|
2021-05-09 01:04:27 +03:00
|
|
|
if (text.empty())
|
2021-04-20 12:48:47 +02:00
|
|
|
return 0;
|
|
|
|
|
2021-05-14 17:23:17 +01:00
|
|
|
if (end == 0)
|
|
|
|
end = text.size();
|
2021-04-20 12:48:47 +02:00
|
|
|
|
|
|
|
uint16 retVal = 0;
|
2021-05-14 17:23:17 +01:00
|
|
|
for (uint16 c = begin; c < end; c++)
|
2021-05-18 12:22:20 +03:00
|
|
|
retVal += _graphicsMgr->getCharWidth(text[c]);
|
2021-04-20 12:48:47 +02:00
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2021-05-16 08:13:42 +01:00
|
|
|
uint16 TrecisionEngine::getKey() {
|
2021-04-20 12:48:47 +02:00
|
|
|
Common::KeyCode key = _curKey;
|
|
|
|
uint16 ascii = _curAscii;
|
|
|
|
_curKey = Common::KEYCODE_INVALID;
|
|
|
|
_curAscii = 0;
|
|
|
|
|
|
|
|
switch (key) {
|
|
|
|
case Common::KEYCODE_SPACE:
|
|
|
|
case Common::KEYCODE_ESCAPE:
|
|
|
|
case Common::KEYCODE_RETURN:
|
|
|
|
case Common::KEYCODE_CLEAR:
|
|
|
|
case Common::KEYCODE_BACKSPACE:
|
|
|
|
return key;
|
|
|
|
case Common::KEYCODE_F1:
|
|
|
|
case Common::KEYCODE_F2:
|
|
|
|
case Common::KEYCODE_F3:
|
|
|
|
case Common::KEYCODE_F4:
|
|
|
|
case Common::KEYCODE_F5:
|
|
|
|
case Common::KEYCODE_F6:
|
|
|
|
return 0x3B + key - Common::KEYCODE_F1;
|
|
|
|
default:
|
|
|
|
if (ascii) {
|
|
|
|
return ascii;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-16 08:13:42 +01:00
|
|
|
Common::KeyCode TrecisionEngine::waitKey() {
|
2021-05-09 06:42:19 +01:00
|
|
|
_graphicsMgr->hideCursor();
|
2021-04-20 12:48:47 +02:00
|
|
|
while (_curKey == Common::KEYCODE_INVALID)
|
|
|
|
checkSystem();
|
2021-05-09 06:42:19 +01:00
|
|
|
_graphicsMgr->showCursor();
|
2021-04-20 12:48:47 +02:00
|
|
|
|
|
|
|
Common::KeyCode t = _curKey;
|
|
|
|
_curKey = Common::KEYCODE_INVALID;
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
void TrecisionEngine::waitDelay(uint32 val) {
|
|
|
|
uint32 sv = readTime();
|
2021-04-20 18:20:21 +01:00
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
while (sv + val > readTime())
|
2021-04-21 08:00:59 +01:00
|
|
|
checkSystem();
|
2021-04-20 18:20:21 +01:00
|
|
|
}
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
void TrecisionEngine::freeKey() {
|
2021-04-20 18:49:10 +01:00
|
|
|
_curKey = Common::KEYCODE_INVALID;
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
uint32 TrecisionEngine::readTime() {
|
2021-04-21 08:00:59 +01:00
|
|
|
return (g_system->getMillis() * 3) / 50;
|
|
|
|
}
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
bool TrecisionEngine::checkMask(Common::Point pos) {
|
2021-04-21 08:00:59 +01:00
|
|
|
for (int8 a = MAXOBJINROOM - 1; a >= 0; a--) {
|
|
|
|
uint16 checkedObj = _room[_curRoom]._object[a];
|
|
|
|
Common::Rect lim = _obj[checkedObj]._lim;
|
|
|
|
lim.translate(0, TOP);
|
2021-04-25 23:05:07 +01:00
|
|
|
// Trecision includes the bottom and right coordinates
|
2021-04-21 08:00:59 +01:00
|
|
|
lim.right++;
|
|
|
|
lim.bottom++;
|
|
|
|
|
2021-05-04 15:41:20 +03:00
|
|
|
if (checkedObj && isObjectVisible(checkedObj)) {
|
2021-05-06 22:03:56 +01:00
|
|
|
if (lim.contains(pos)) {
|
2021-04-21 08:00:59 +01:00
|
|
|
|
|
|
|
if ((_obj[checkedObj]._mode & OBJMODE_FULL) || (_obj[checkedObj]._mode & OBJMODE_LIM)) {
|
|
|
|
_curObj = checkedObj;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_obj[checkedObj]._mode & OBJMODE_MASK) {
|
2021-04-25 23:33:23 +01:00
|
|
|
uint8 *mask = _maskPointers[a];
|
2021-04-27 00:15:53 +03:00
|
|
|
int16 d = _obj[checkedObj]._rect.left;
|
|
|
|
uint16 max = _obj[checkedObj]._rect.bottom;
|
2021-04-21 08:00:59 +01:00
|
|
|
|
2021-04-27 00:15:53 +03:00
|
|
|
for (uint16 b = _obj[checkedObj]._rect.top; b < max; b++) {
|
2021-04-21 08:00:59 +01:00
|
|
|
bool insideObj = false;
|
|
|
|
int16 e = 0;
|
2021-04-29 02:28:29 +01:00
|
|
|
while (e < _obj[checkedObj]._rect.width()) {
|
2021-04-21 08:00:59 +01:00
|
|
|
if (!insideObj) { // not inside an object
|
2021-05-06 22:03:56 +01:00
|
|
|
if (b + TOP == pos.y) {
|
|
|
|
if ((pos.x >= d + e) && (pos.x < d + e + *mask)) {
|
2021-04-21 08:00:59 +01:00
|
|
|
_curObj = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
e += *mask;
|
|
|
|
mask++;
|
|
|
|
insideObj = true;
|
|
|
|
} else { // inside an object
|
2021-05-06 22:03:56 +01:00
|
|
|
if (b + TOP == pos.y) {
|
|
|
|
if ((pos.x >= d + e) && (pos.x < d + e + *mask)) {
|
2021-04-21 08:00:59 +01:00
|
|
|
_curObj = checkedObj;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
e += *mask;
|
|
|
|
mask++;
|
|
|
|
insideObj = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_curObj = 0;
|
|
|
|
return false;
|
2021-04-20 18:49:10 +01:00
|
|
|
}
|
2021-04-21 19:55:59 +02:00
|
|
|
|
2021-04-26 21:10:51 +01:00
|
|
|
float TrecisionEngine::sinCosAngle(float sinus, float cosinus) {
|
|
|
|
if (sinus == 0 && cosinus == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
float t = (float)sqrt((double)(sinus * sinus) + (double)(cosinus * cosinus));
|
|
|
|
cosinus /= t;
|
|
|
|
sinus /= t;
|
|
|
|
|
|
|
|
// 1e3 & 2e4 quad
|
|
|
|
if (sinus >= 0)
|
|
|
|
// 1 & 2 quad
|
|
|
|
return (float)acos(cosinus);
|
|
|
|
|
|
|
|
// 3 quad
|
2021-04-27 21:56:32 +01:00
|
|
|
return PI2 - (float)acos(cosinus);
|
2021-04-26 21:10:51 +01:00
|
|
|
}
|
|
|
|
|
2021-05-14 19:45:42 +01:00
|
|
|
void TrecisionEngine::processTime() {
|
2021-05-16 08:13:42 +01:00
|
|
|
static uint8 oldRegInvSI = 0xFF;
|
|
|
|
static uint8 oldRegInvSL = 0xFF;
|
|
|
|
static uint8 oldLightIcon = 0xFF;
|
2021-04-28 08:12:44 +01:00
|
|
|
|
2021-05-04 22:19:15 +01:00
|
|
|
_curTime = readTime();
|
2021-04-28 08:12:44 +01:00
|
|
|
|
2021-05-04 22:19:15 +01:00
|
|
|
if (_curTime >= _nextRefresh) {
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->drawTexts();
|
2021-04-28 08:12:44 +01:00
|
|
|
|
|
|
|
if (_inventoryStatus == INV_PAINT || _inventoryStatus == INV_DEPAINT)
|
|
|
|
rollInventory(_inventoryStatus);
|
|
|
|
|
2021-05-16 08:13:42 +01:00
|
|
|
if (_inventoryStatus != INV_OFF && (oldRegInvSI != _inventoryRefreshStartIcon || oldRegInvSL != _inventoryRefreshStartLine || oldLightIcon != _lightIcon)) {
|
2021-04-28 08:12:44 +01:00
|
|
|
refreshInventory(_inventoryRefreshStartIcon, _inventoryRefreshStartLine);
|
2021-05-16 08:13:42 +01:00
|
|
|
oldRegInvSI = _inventoryRefreshStartIcon;
|
|
|
|
oldRegInvSL = _inventoryRefreshStartLine;
|
|
|
|
oldLightIcon = _lightIcon;
|
2021-04-28 08:12:44 +01:00
|
|
|
}
|
|
|
|
|
2021-05-12 00:58:07 +01:00
|
|
|
_renderer->paintScreen(false);
|
2021-05-09 01:04:27 +03:00
|
|
|
_textMgr->clearTextStack();
|
2021-04-28 08:12:44 +01:00
|
|
|
|
|
|
|
uint32 paintTime = readTime();
|
2021-05-04 22:19:15 +01:00
|
|
|
if (paintTime - _curTime >= 5)
|
2021-04-28 08:12:44 +01:00
|
|
|
_nextRefresh = paintTime + 1;
|
|
|
|
else
|
2021-05-04 22:19:15 +01:00
|
|
|
_nextRefresh = _curTime + 5;
|
2021-04-28 08:12:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-14 19:45:42 +01:00
|
|
|
void TrecisionEngine::processMouse() {
|
2021-05-06 22:03:56 +01:00
|
|
|
int16 mx = _mousePos.x;
|
|
|
|
int16 my = _mousePos.y;
|
2021-04-28 08:12:44 +01:00
|
|
|
|
2021-05-07 15:30:08 +03:00
|
|
|
if (lastMouseOn && !_graphicsMgr->isCursorVisible()) {
|
2021-05-06 22:03:56 +01:00
|
|
|
oldMousePos = Common::Point(0, 0); // Switch off
|
2021-05-07 15:30:08 +03:00
|
|
|
} else if (!lastMouseOn && _graphicsMgr->isCursorVisible()) {
|
2021-05-06 22:03:56 +01:00
|
|
|
oldMousePos = Common::Point(0, 0); // Switch on
|
2021-04-28 08:12:44 +01:00
|
|
|
}
|
|
|
|
|
2021-05-07 15:30:08 +03:00
|
|
|
lastMouseOn = _graphicsMgr->isCursorVisible();
|
2021-04-28 08:12:44 +01:00
|
|
|
checkSystem();
|
|
|
|
|
2021-05-07 15:30:08 +03:00
|
|
|
if (!_graphicsMgr->isCursorVisible())
|
2021-04-28 08:12:44 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (_mouseLeftBtn || _mouseRightBtn) {
|
2021-05-14 21:51:14 +01:00
|
|
|
if (!maskMouse) {
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_MOUSE, _mouseRightBtn ? ME_MRIGHT : ME_MLEFT, MP_DEFAULT, mx, my, 0, 0);
|
2021-05-14 21:51:14 +01:00
|
|
|
maskMouse = true;
|
2021-04-28 08:12:44 +01:00
|
|
|
}
|
|
|
|
} else {
|
2021-05-14 21:51:14 +01:00
|
|
|
maskMouse = false;
|
2021-04-28 08:12:44 +01:00
|
|
|
|
2021-05-14 23:37:26 +01:00
|
|
|
if (!_flagScriptActive && (mx != oldMousePos.x || my != oldMousePos.y)) {
|
2021-05-09 13:55:50 +01:00
|
|
|
_scheduler->doEvent(MC_MOUSE, ME_MMOVE, MP_DEFAULT, mx, my, 0, 0);
|
2021-05-06 22:03:56 +01:00
|
|
|
oldMousePos = Common::Point(mx, my);
|
2021-04-28 08:12:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-03 21:48:06 +01:00
|
|
|
/*------------------------------------------------
|
|
|
|
Fake distance between two 2D points
|
|
|
|
--------------------------------------------------*/
|
|
|
|
float TrecisionEngine::dist2D(float x1, float y1, float x2, float y2) {
|
|
|
|
double d1 = fabs((double)(x1 - x2));
|
|
|
|
double d2 = fabs((double)(y1 - y2));
|
|
|
|
|
|
|
|
return (float)sqrt(d1 * d1 + d2 * d2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------
|
|
|
|
Distance between two 3D points
|
|
|
|
--------------------------------------------------*/
|
|
|
|
float TrecisionEngine::dist3D(float x1, float y1, float z1, float x2, float y2, float z2) {
|
|
|
|
double d1 = fabs((double)(x1 - x2));
|
|
|
|
double d2 = fabs((double)(y1 - y2));
|
|
|
|
double d3 = fabs((double)(z1 - z2));
|
|
|
|
return (float)sqrt(d1 * d1 + d2 * d2 + d3 * d3);
|
|
|
|
}
|
|
|
|
|
2021-05-05 22:17:30 +01:00
|
|
|
bool TrecisionEngine::isBetween(int a, int x, int b) {
|
|
|
|
return x >= a && x <= b;
|
|
|
|
}
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
bool TrecisionEngine::isGameArea(Common::Point pos) {
|
|
|
|
return isBetween(TOP, pos.y, TOP + AREA - 1);
|
2021-05-05 22:17:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
bool TrecisionEngine::isInventoryArea(Common::Point pos) {
|
|
|
|
return pos.y >= TOP + AREA;
|
2021-05-05 22:17:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-06 22:03:56 +01:00
|
|
|
bool TrecisionEngine::isIconArea(Common::Point pos) {
|
|
|
|
return pos.y >= TOP + AREA && pos.y < MAXY && pos.x >= ICONMARGSX && pos.x <= MAXX - ICONMARGDX;
|
2021-05-05 22:17:30 +01:00
|
|
|
}
|
|
|
|
|
2021-05-12 00:58:07 +01:00
|
|
|
int TrecisionEngine::getRoomObjectIndex(uint16 objectId) {
|
|
|
|
for (uint16 index = 0; index < MAXOBJINROOM; index++) {
|
2021-05-14 19:56:16 +01:00
|
|
|
const uint16 curObjId = _room[_curRoom]._object[index];
|
2021-05-12 00:58:07 +01:00
|
|
|
if (curObjId == 0)
|
|
|
|
return -1;
|
|
|
|
if (curObjId == objectId)
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-05-13 23:53:34 +01:00
|
|
|
/************************************************
|
|
|
|
* SDText
|
|
|
|
************************************************/
|
|
|
|
void SDText::set(SDText org) {
|
|
|
|
set(org._rect, org._subtitleRect, org.tcol, org.scol, org.text);
|
|
|
|
}
|
|
|
|
|
2021-05-14 17:23:17 +01:00
|
|
|
void SDText::set(Common::Rect rect, Common::Rect subtitleRect, uint16 ptcol, uint16 pscol, const Common::String &pText) {
|
2021-05-13 23:53:34 +01:00
|
|
|
_rect = rect;
|
|
|
|
_subtitleRect = subtitleRect;
|
|
|
|
tcol = ptcol;
|
|
|
|
scol = pscol;
|
|
|
|
text = pText;
|
2021-05-16 08:34:52 +01:00
|
|
|
|
|
|
|
// Clean output buffer
|
|
|
|
for (int i = 0; i < MAXDTEXTLINES; ++i) {
|
|
|
|
for (int j = 0; j < MAXDTEXTCHARS; ++j)
|
|
|
|
_drawTextLines[i][j] = '\0';
|
|
|
|
}
|
2021-05-13 23:53:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------
|
2021-05-16 18:05:22 +01:00
|
|
|
calcHeight - Computes and returns the dy of the current text
|
2021-05-13 23:53:34 +01:00
|
|
|
--------------------------------------------------------------*/
|
2021-05-18 04:32:45 +01:00
|
|
|
uint16 SDText::calcHeight(TrecisionEngine *vm) {
|
2021-05-13 23:53:34 +01:00
|
|
|
if (text.empty())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint8 curLine = 0;
|
2021-05-18 04:32:45 +01:00
|
|
|
if (vm->textLength(text) <= _rect.width()) {
|
2021-05-16 08:34:52 +01:00
|
|
|
strcpy((char *)_drawTextLines[curLine], text.c_str());
|
2021-05-13 23:53:34 +01:00
|
|
|
return CARHEI;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 a = 0;
|
|
|
|
uint16 tmpDy = 0;
|
|
|
|
uint16 lastSpace = 0;
|
|
|
|
uint16 curInit = 0;
|
|
|
|
|
|
|
|
while (a < text.size()) {
|
|
|
|
a++;
|
|
|
|
if (a < text.size() && text[a] == ' ') {
|
2021-05-18 04:32:45 +01:00
|
|
|
if (vm->textLength(text, curInit, a) <= _rect.width())
|
2021-05-13 23:53:34 +01:00
|
|
|
lastSpace = a;
|
2021-05-18 04:32:45 +01:00
|
|
|
else if (vm->textLength(text, curInit, lastSpace) <= _rect.width()) {
|
2021-05-13 23:53:34 +01:00
|
|
|
uint16 b;
|
|
|
|
for (b = curInit; b < lastSpace; b++)
|
2021-05-16 08:34:52 +01:00
|
|
|
_drawTextLines[curLine][b - curInit] = text[b];
|
2021-05-13 23:53:34 +01:00
|
|
|
|
2021-05-16 08:34:52 +01:00
|
|
|
_drawTextLines[curLine][b - curInit] = '\0';
|
2021-05-13 23:53:34 +01:00
|
|
|
curLine++;
|
|
|
|
|
|
|
|
curInit = lastSpace + 1;
|
|
|
|
|
|
|
|
tmpDy += CARHEI;
|
|
|
|
a = curInit;
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
} else if (a == text.size()) {
|
2021-05-18 04:32:45 +01:00
|
|
|
if (vm->textLength(text, curInit, a) <= _rect.width()) {
|
2021-05-13 23:53:34 +01:00
|
|
|
uint16 b;
|
|
|
|
for (b = curInit; b < a; b++)
|
2021-05-16 08:34:52 +01:00
|
|
|
_drawTextLines[curLine][b - curInit] = text[b];
|
|
|
|
_drawTextLines[curLine][b - curInit] = '\0';
|
2021-05-13 23:53:34 +01:00
|
|
|
|
|
|
|
tmpDy += CARHEI;
|
|
|
|
|
|
|
|
return tmpDy;
|
|
|
|
}
|
|
|
|
|
2021-05-18 04:32:45 +01:00
|
|
|
if (vm->textLength(text, curInit, lastSpace) <= _rect.width()) {
|
2021-05-13 23:53:34 +01:00
|
|
|
uint16 b;
|
|
|
|
for (b = curInit; b < lastSpace; b++)
|
2021-05-16 08:34:52 +01:00
|
|
|
_drawTextLines[curLine][b - curInit] = text[b];
|
2021-05-13 23:53:34 +01:00
|
|
|
|
2021-05-16 08:34:52 +01:00
|
|
|
_drawTextLines[curLine][b - curInit] = '\0';
|
2021-05-13 23:53:34 +01:00
|
|
|
curLine++;
|
|
|
|
|
|
|
|
curInit = lastSpace + 1;
|
|
|
|
tmpDy += CARHEI;
|
|
|
|
|
|
|
|
if (curInit < text.size()) {
|
|
|
|
for (b = curInit; b < text.size(); b++)
|
2021-05-16 08:34:52 +01:00
|
|
|
_drawTextLines[curLine][b - curInit] = text[b];
|
2021-05-13 23:53:34 +01:00
|
|
|
|
2021-05-16 08:34:52 +01:00
|
|
|
_drawTextLines[curLine][b - curInit] = '\0';
|
2021-05-13 23:53:34 +01:00
|
|
|
|
|
|
|
tmpDy += CARHEI;
|
|
|
|
}
|
|
|
|
return tmpDy;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:22:20 +03:00
|
|
|
void SDText::draw(TrecisionEngine *vm, Graphics::Surface *externalSurface) {
|
2021-05-13 23:53:34 +01:00
|
|
|
uint16 tmpTCol = tcol;
|
|
|
|
uint16 tmpSCol = scol;
|
2021-05-18 04:32:45 +01:00
|
|
|
vm->_graphicsMgr->updatePixelFormat(&tmpTCol, 1);
|
2021-05-13 23:53:34 +01:00
|
|
|
if (scol != MASKCOL)
|
2021-05-18 04:32:45 +01:00
|
|
|
vm->_graphicsMgr->updatePixelFormat(&tmpSCol, 1);
|
2021-05-13 23:53:34 +01:00
|
|
|
|
|
|
|
if (text.empty())
|
|
|
|
return;
|
|
|
|
|
2021-05-18 12:22:20 +03:00
|
|
|
const uint16 curDy = calcHeight(vm);
|
2021-05-13 23:53:34 +01:00
|
|
|
|
2021-05-18 12:22:20 +03:00
|
|
|
for (uint16 line = 0; line < curDy / CARHEI; line++) {
|
2021-05-18 19:50:35 +03:00
|
|
|
Common::String curText = _drawTextLines[line];
|
2021-05-18 04:32:45 +01:00
|
|
|
uint16 inc = (_rect.width() - vm->textLength(curText)) / 2;
|
2021-05-13 23:53:34 +01:00
|
|
|
|
2021-05-18 19:50:35 +03:00
|
|
|
if (curText.size() >= MAXCHARS) {
|
|
|
|
curText = vm->_sysText[kMessageError];
|
2021-05-13 23:53:34 +01:00
|
|
|
}
|
|
|
|
|
2021-05-18 19:50:35 +03:00
|
|
|
for (uint16 index = 0; index < curText.size(); index++) {
|
2021-05-18 12:22:20 +03:00
|
|
|
const byte curChar = curText[index];
|
2021-05-13 23:53:34 +01:00
|
|
|
|
2021-05-18 19:50:35 +03:00
|
|
|
if (index == curText.size() - 1 && vm->_blinkLastDTextChar != MASKCOL)
|
2021-05-18 04:32:45 +01:00
|
|
|
tmpTCol = vm->_blinkLastDTextChar;
|
2021-05-13 23:53:34 +01:00
|
|
|
|
2021-05-18 12:22:20 +03:00
|
|
|
vm->_graphicsMgr->drawChar(
|
|
|
|
curChar,
|
|
|
|
tmpSCol,
|
|
|
|
tmpTCol,
|
|
|
|
line,
|
|
|
|
_rect,
|
|
|
|
_subtitleRect,
|
|
|
|
inc,
|
|
|
|
externalSurface
|
|
|
|
);
|
|
|
|
|
|
|
|
inc += vm->_graphicsMgr->getCharWidth(curChar);
|
2021-05-13 23:53:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-20 23:18:33 +01:00
|
|
|
} // End of namespace Trecision
|