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-04-20 18:49:10 +01:00
|
|
|
#include <common/system.h>
|
|
|
|
|
2021-04-30 23:40:17 +01:00
|
|
|
#include "trecision/graphics.h"
|
2021-04-28 21:33:53 +01:00
|
|
|
#include "trecision/defines.h"
|
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-04-27 21:56:32 +01:00
|
|
|
#include "trecision/actor.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
|
|
|
|
2021-03-20 23:18:33 +01:00
|
|
|
char *TrecisionEngine::getNextSentence() {
|
|
|
|
while (*_textPtr) {
|
|
|
|
*_textPtr = ~(*_textPtr);
|
|
|
|
_textPtr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
_textPtr++;
|
|
|
|
return _textPtr;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::redrawString() {
|
2021-04-20 12:48:47 +02:00
|
|
|
if (!_flagDialogActive && !_flagDialogMenuActive && !_flagSomeoneSpeaks && !_flagscriptactive && isCursorVisible()) {
|
|
|
|
if (isInventoryArea(_mouseY))
|
2021-03-24 09:14:53 +01:00
|
|
|
doEvent(MC_INVENTORY, ME_SHOWICONNAME, MP_DEFAULT, 0, 0, 0, 0);
|
|
|
|
else {
|
2021-04-25 23:33:23 +01:00
|
|
|
checkMask(_mouseX, _mouseY);
|
2021-03-24 09:14:53 +01:00
|
|
|
ShowObjName(_curObj, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-24 15:17:48 +01:00
|
|
|
void StackText::doText() {
|
2021-04-27 00:15:53 +03:00
|
|
|
curString._rect.left = x;
|
|
|
|
curString._rect.top = y;
|
2021-04-29 03:00:01 +01:00
|
|
|
curString._rect.setWidth(g_vm->textLength(text, 0));
|
2021-04-27 00:15:53 +03:00
|
|
|
int16 w = curString._rect.width();
|
2021-04-27 00:36:12 +03:00
|
|
|
|
2021-04-27 00:15:53 +03:00
|
|
|
if ((y == MAXY - CARHEI) && (w > 600))
|
|
|
|
w = w * 3 / 5;
|
|
|
|
else if ((y != MAXY - CARHEI) && (w > 960))
|
|
|
|
w = w * 2 / 5;
|
|
|
|
else if ((y != MAXY - CARHEI) && (w > 320))
|
|
|
|
w = w * 3 / 5;
|
|
|
|
|
2021-04-29 03:00:01 +01:00
|
|
|
curString._rect.setWidth(w);
|
2021-04-27 00:36:12 +03:00
|
|
|
|
2021-04-14 03:04:10 +03:00
|
|
|
curString.text = text;
|
2021-03-24 09:14:53 +01:00
|
|
|
uint16 hstring = curString.checkDText();
|
2021-04-29 03:00:01 +01:00
|
|
|
curString._subtitleRect = Common::Rect(curString._rect.width(), hstring);
|
|
|
|
curString._rect.setHeight(hstring);
|
2021-03-24 09:14:53 +01:00
|
|
|
curString.tcol = tcol;
|
|
|
|
curString.scol = scol;
|
|
|
|
|
2021-04-27 00:15:53 +03:00
|
|
|
if (curString._rect.top <= hstring)
|
|
|
|
curString._rect.top += hstring;
|
2021-03-24 09:14:53 +01:00
|
|
|
else
|
2021-04-27 00:15:53 +03:00
|
|
|
curString._rect.top -= hstring;
|
2021-03-24 09:14:53 +01:00
|
|
|
|
2021-04-27 00:15:53 +03:00
|
|
|
if (curString._rect.top <= VIDEOTOP)
|
|
|
|
curString._rect.top = VIDEOTOP + 1;
|
2021-03-24 09:14:53 +01:00
|
|
|
|
|
|
|
TextStatus |= TEXT_DRAW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::doClearText() {
|
2021-04-19 18:33:46 +02:00
|
|
|
if (!oldString.text && 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
|
|
|
void TrecisionEngine::setRoom(uint16 r, bool b) {
|
2021-04-20 19:24:52 +03:00
|
|
|
_logicMgr->setupAltRoom(r, b);
|
2021-03-24 15:17:48 +01:00
|
|
|
RegenRoom();
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:05:07 +01:00
|
|
|
/*-------------------------------------------------
|
|
|
|
* Compute string length from character 0 to num
|
|
|
|
*-------------------------------------------------*/
|
2021-04-25 23:33:23 +01:00
|
|
|
uint16 TrecisionEngine::textLength(const char *text, uint16 num) {
|
2021-04-20 12:48:47 +02:00
|
|
|
if (text == nullptr)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint16 len = (num == 0) ? strlen(text) : num;
|
|
|
|
|
|
|
|
uint16 retVal = 0;
|
|
|
|
for (uint16 c = 0; c < len; c++)
|
|
|
|
retVal += _font[(uint8)text[c] * 3 + 2];
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2021-04-25 23:33:23 +01:00
|
|
|
char 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char TrecisionEngine::waitKey() {
|
|
|
|
while (_curKey == Common::KEYCODE_INVALID)
|
|
|
|
checkSystem();
|
|
|
|
|
|
|
|
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-04-25 23:33:23 +01:00
|
|
|
bool TrecisionEngine::checkMask(uint16 mx, uint16 my) {
|
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++;
|
|
|
|
|
|
|
|
if (checkedObj && (_obj[checkedObj]._mode & OBJMODE_OBJSTATUS)) {
|
|
|
|
if (lim.contains(mx, my)) {
|
|
|
|
|
|
|
|
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
|
|
|
|
if (b + TOP == my) {
|
|
|
|
if ((mx >= d + e) && (mx < d + e + *mask)) {
|
|
|
|
_curObj = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
e += *mask;
|
|
|
|
mask++;
|
|
|
|
insideObj = true;
|
|
|
|
} else { // inside an object
|
|
|
|
if (b + TOP == my) {
|
|
|
|
if ((mx >= d + e) && (mx < d + e + *mask)) {
|
|
|
|
_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
|
|
|
Graphics::Surface *TrecisionEngine::convertScummVMThumbnail(Graphics::Surface *thumbnail) {
|
|
|
|
Graphics::Surface *thumbnailConverted = thumbnail->convertTo(g_system->getScreenFormat());
|
|
|
|
Graphics::Surface *result = thumbnailConverted->scale(ICONDX, ICONDY);
|
|
|
|
|
|
|
|
thumbnailConverted->free();
|
|
|
|
delete thumbnailConverted;
|
|
|
|
thumbnail->free();
|
|
|
|
delete thumbnail;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-04-22 22:03:50 +01:00
|
|
|
void TrecisionEngine::resetZBuffer(int x1, int y1, int x2, int y2) {
|
|
|
|
if (x1 > x2 || y1 > y2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int size = (x2 - x1) * (y2 - y1);
|
|
|
|
if (size * 2 > ZBUFFERSIZE)
|
|
|
|
warning("Warning: _zBuffer size %d!\n", size * 2);
|
2021-04-20 18:20:21 +01:00
|
|
|
|
2021-04-22 22:03:50 +01:00
|
|
|
int16 *d = _zBuffer;
|
|
|
|
for (int i = 0; i < size; ++i)
|
|
|
|
*d++ = 0x7FFF;
|
|
|
|
}
|
2021-04-20 12:48:47 +02:00
|
|
|
|
2021-04-25 23:05:07 +01:00
|
|
|
void TrecisionEngine::openSys() {
|
|
|
|
// head
|
2021-04-25 23:33:23 +01:00
|
|
|
int32 idx = 0;
|
|
|
|
FTexture[idx]._dx = 300 / 2;
|
|
|
|
FTexture[idx]._dy = 208 / 2;
|
|
|
|
FTexture[idx]._angle = 0;
|
|
|
|
FTexture[idx]._texture = _textureArea;
|
|
|
|
FTexture[idx]._flag = TEXTUREACTIVE + TEXTURECYLIND;
|
2021-04-25 23:05:07 +01:00
|
|
|
|
|
|
|
// body
|
2021-04-25 23:33:23 +01:00
|
|
|
idx = 1;
|
|
|
|
FTexture[idx]._dx = 300;
|
|
|
|
FTexture[idx]._dy = 300;
|
|
|
|
FTexture[idx]._angle = 0;
|
|
|
|
FTexture[idx]._texture = FTexture[0]._texture + (300 * 208) / 4;
|
|
|
|
FTexture[idx]._flag = TEXTUREACTIVE + TEXTURECYLIND;
|
2021-04-25 23:05:07 +01:00
|
|
|
|
|
|
|
// arms
|
2021-04-25 23:33:23 +01:00
|
|
|
idx = 2;
|
|
|
|
FTexture[idx]._dx = 300;
|
|
|
|
FTexture[idx]._dy = 150;
|
|
|
|
FTexture[idx]._angle = 0;
|
|
|
|
FTexture[idx]._texture = FTexture[1]._texture + 300 * 300;
|
|
|
|
FTexture[idx]._flag = TEXTUREACTIVE + TEXTURECYLIND;
|
2021-04-25 23:05:07 +01:00
|
|
|
|
|
|
|
delete _actor;
|
2021-04-25 23:42:35 +01:00
|
|
|
_actor = new Actor(this);
|
2021-05-01 12:05:17 +01:00
|
|
|
_actor->readModel("jm.om");
|
2021-04-25 23:05:07 +01:00
|
|
|
|
|
|
|
_actor->_light = (SLight *)&VLight;
|
|
|
|
_actor->_camera = (SCamera *)&FCamera;
|
|
|
|
_actor->_texture = (STexture *)&FTexture[0];
|
|
|
|
|
|
|
|
TextArea = new char[MAXTEXTAREA];
|
|
|
|
|
|
|
|
// zbuffer
|
|
|
|
_zBuffer = new int16[ZBUFFERSIZE / 2];
|
|
|
|
for (int c = 0; c < ZBUFFERSIZE / 2; ++c)
|
|
|
|
_zBuffer[c] = 0x7FFF;
|
|
|
|
|
|
|
|
_screenBuffer = new uint16[MAXX * MAXY];
|
|
|
|
memset(_screenBuffer, 0, MAXX * MAXY * 2);
|
|
|
|
|
|
|
|
_graphicsMgr->clearScreen();
|
|
|
|
|
|
|
|
hideCursor();
|
|
|
|
|
|
|
|
for (int i = 0; i < MAXOBJINROOM; ++i) {
|
|
|
|
OldObjStatus[i] = false;
|
|
|
|
VideoObjStatus[i] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-04-28 08:12:44 +01:00
|
|
|
void TrecisionEngine::ProcessTime() {
|
|
|
|
static uint8 OldRegInvSI = 0xFF;
|
|
|
|
static uint8 OldRegInvSL = 0xFF;
|
|
|
|
static uint8 OldLightIcon = 0xFF;
|
|
|
|
|
|
|
|
TheTime = readTime();
|
|
|
|
_animMgr->refreshAllAnimations();
|
|
|
|
|
|
|
|
if (TheTime >= _nextRefresh) {
|
|
|
|
drawString();
|
|
|
|
|
|
|
|
if (_inventoryStatus == INV_PAINT || _inventoryStatus == INV_DEPAINT)
|
|
|
|
rollInventory(_inventoryStatus);
|
|
|
|
|
|
|
|
if (_inventoryStatus != INV_OFF && (OldRegInvSI != _inventoryRefreshStartIcon || OldRegInvSL != _inventoryRefreshStartLine || OldLightIcon != _lightIcon)) {
|
|
|
|
refreshInventory(_inventoryRefreshStartIcon, _inventoryRefreshStartLine);
|
|
|
|
OldRegInvSI = _inventoryRefreshStartIcon;
|
|
|
|
OldRegInvSL = _inventoryRefreshStartLine;
|
|
|
|
OldLightIcon = _lightIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
PaintScreen(false);
|
|
|
|
_textStackTop = -1;
|
|
|
|
|
|
|
|
uint32 paintTime = readTime();
|
|
|
|
if (paintTime - TheTime >= 5)
|
|
|
|
_nextRefresh = paintTime + 1;
|
|
|
|
else
|
|
|
|
_nextRefresh = TheTime + 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TrecisionEngine::ProcessMouse() {
|
|
|
|
static bool MaskMouse;
|
|
|
|
static uint16 oldMouseX;
|
|
|
|
static uint16 oldMouseY;
|
|
|
|
static bool lastMouseOn = true;
|
|
|
|
int16 mx = _mouseX;
|
|
|
|
int16 my = _mouseY;
|
|
|
|
|
|
|
|
if (lastMouseOn && !isCursorVisible()) {
|
|
|
|
oldMouseX = 0; // Switch off
|
|
|
|
oldMouseY = 0;
|
|
|
|
} else if (!lastMouseOn && isCursorVisible()) {
|
|
|
|
oldMouseX = 0; // Switch on
|
|
|
|
oldMouseY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
lastMouseOn = isCursorVisible();
|
|
|
|
checkSystem();
|
|
|
|
|
|
|
|
if (!isCursorVisible())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (_mouseLeftBtn || _mouseRightBtn) {
|
|
|
|
if (!MaskMouse) {
|
|
|
|
doEvent(MC_MOUSE, _mouseRightBtn ? ME_MRIGHT : ME_MLEFT, MP_DEFAULT, mx, my, 0, 0);
|
|
|
|
MaskMouse = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MaskMouse = false;
|
|
|
|
|
|
|
|
if (!_flagscriptactive) {
|
|
|
|
if (mx != oldMouseX || my != oldMouseY) {
|
|
|
|
doEvent(MC_MOUSE, ME_MMOVE, MP_DEFAULT, mx, my, 0, 0);
|
|
|
|
oldMouseX = mx;
|
|
|
|
oldMouseY = my;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-03-20 23:18:33 +01:00
|
|
|
} // End of namespace Trecision
|