[Scummvm-git-logs] scummvm master -> 10310cccdd7f8052515d3d3f181a94a21992497d
neuromancer
neuromancer at users.noreply.github.com
Sun Jul 4 11:13:32 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
10310cccdd PRIVATE: initial implementation of the SafeDigit function
Commit: 10310cccdd7f8052515d3d3f181a94a21992497d
https://github.com/scummvm/scummvm/commit/10310cccdd7f8052515d3d3f181a94a21992497d
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2021-07-04T13:13:21+02:00
Commit Message:
PRIVATE: initial implementation of the SafeDigit function
Changed paths:
engines/private/funcs.cpp
engines/private/private.cpp
engines/private/private.h
diff --git a/engines/private/funcs.cpp b/engines/private/funcs.cpp
index f11dc945b4..28b8d66995 100644
--- a/engines/private/funcs.cpp
+++ b/engines/private/funcs.cpp
@@ -716,7 +716,10 @@ static void fSoundArea(ArgArray args) {
}
static void fSafeDigit(ArgArray args) {
- debugC(1, kPrivateDebugScript, "WARNING: SafeDigit is not implemented");
+ assert(args[0].type == NUM);
+ assert(args[1].type == RECT);
+ debugC(1, kPrivateDebugScript, "SafeDigit(%d, ..)", args[0].u.val);
+ g_private->addSafeDigit(args[0].u.val, args[1].u.rect);
}
static void fAskSave(ArgArray args) {
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 001a8cc9dd..c0fc205e65 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -106,6 +106,14 @@ PrivateEngine::PrivateEngine(OSystem *syst, const ADGameDescription *gd)
// Diary
_diaryLocPrefix = "inface/diary/loclist/";
+
+ // Safe
+ _safeNumberPath = "sg/search_s/sgsaf%d.bmp";
+ for (uint d = 0 ; d < 3; d++) {
+ _safeDigitArea[d].clear();
+ _safeDigit[d] = 0;
+ _safeDigitRect[d] = Common::Rect(0, 0);
+ }
}
PrivateEngine::~PrivateEngine() {
@@ -198,6 +206,7 @@ Common::Error PrivateEngine::run() {
return Common::kUnsupportedColorMode;
_transparentColor = _pixelFormat.RGBToColor(0, 255, 0);
+ _safeColor = _pixelFormat.RGBToColor(65, 65, 65);
screenRect = Common::Rect(0, 0, _screenW, _screenH);
changeCursor("default");
_origin = Common::Point(0, 0);
@@ -247,6 +256,8 @@ Common::Error PrivateEngine::run() {
break;
else if (selectDossierPrevSheet(mousePos))
break;
+ else if (selectSafeDigit(mousePos))
+ break;
selectPauseMovie(mousePos);
selectPhoneArea(mousePos);
@@ -387,6 +398,15 @@ void PrivateEngine::clearAreas() {
_dossierPrevSheetMask.surf->free();
delete _dossierPrevSheetMask.surf;
_dossierPrevSheetMask.clear();
+
+ for (uint d = 0 ; d < 3; d++) {
+ if (_safeDigitArea[d].surf)
+ _safeDigitArea[d].surf->free();
+ delete _safeDigitArea[d].surf;
+ _safeDigitArea[d].clear();
+ _safeDigit[d] = 0;
+ _safeDigitRect[d] = Common::Rect(0, 0);
+ }
}
void PrivateEngine::startPoliceBust() {
@@ -552,6 +572,13 @@ Common::String PrivateEngine::getPoliceBustFromMOSetting() {
return "k6";
}
+Common::String PrivateEngine::getWallSafeValueVariable() {
+ if ((_language == Common::EN_USA || _language == Common::RU_RUS) && _platform != Common::kPlatformMacintosh)
+ return "kWallSafeValue";
+
+ return "k3";
+}
+
Common::String PrivateEngine::getExitCursor() {
if ((_language == Common::EN_USA || _language == Common::RU_RUS) && _platform != Common::kPlatformMacintosh)
return "kExit";
@@ -792,6 +819,59 @@ bool PrivateEngine::selectDossierPrevSuspect(Common::Point mousePos) {
return false;
}
+bool PrivateEngine::selectSafeDigit(Common::Point mousePos) {
+ if (_safeDigitArea[0].surf == NULL)
+ return false;
+
+ mousePos = mousePos - _origin;
+ if (mousePos.x < 0 || mousePos.y < 0)
+ return false;
+
+ for (uint d = 0 ; d < 3; d ++)
+ if (_safeDigitRect[d].contains(mousePos)) {
+ _safeDigit[d] = (_safeDigit[d] + 1) % 10;
+ renderSafeDigit(d);
+ Private::Symbol *sym = maps.variables.getVal(getWallSafeValueVariable());
+ sym->u.val = 100*_safeDigit[0] + 10*_safeDigit[1] + _safeDigit[2];
+ return true;
+ }
+
+ return false;
+}
+
+void PrivateEngine::addSafeDigit(uint32 d, Common::Rect *rect) {
+
+ MaskInfo m;
+ _safeDigitRect[d] = *rect;
+ fillRect(_safeColor, _safeDigitRect[d]);
+ m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), _safeDigit[d]), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
+ m.cursor = g_private->getExitCursor();
+ m.nextSetting = "";
+ m.flag1 = NULL;
+ m.flag2 = NULL;
+ _safeDigitArea[d] = m;
+ drawScreen();
+}
+
+
+void PrivateEngine::renderSafeDigit(uint32 d) {
+
+ if (_safeDigitArea[d].surf != NULL) {
+ _safeDigitArea[d].surf->free();
+ delete _safeDigitArea[d].surf;
+ _safeDigitArea[d].clear();
+ }
+ fillRect(_safeColor, _safeDigitRect[d]);
+ MaskInfo m;
+ m.surf = loadMask(Common::String::format(_safeNumberPath.c_str(), _safeDigit[d]), _safeDigitRect[d].left, _safeDigitRect[d].top, true);
+ m.cursor = g_private->getExitCursor();
+ m.nextSetting = "";
+ m.flag1 = NULL;
+ m.flag2 = NULL;
+ _safeDigitArea[d] = m;
+ drawScreen();
+}
+
void PrivateEngine::selectLoadGame(Common::Point mousePos) {
if (_loadGameMask.surf == NULL)
return;
@@ -1143,6 +1223,12 @@ void PrivateEngine::loadImage(const Common::String &name, int x, int y) {
_image->destroy();
}
+void PrivateEngine::fillRect(uint32 color, Common::Rect rect) {
+ debugC(1, kPrivateDebugFunction, "%s(%d,..)", __FUNCTION__, color);
+ rect.translate(_origin.x, _origin.y);
+ _compositeSurface->fillRect(rect, color);
+}
+
void PrivateEngine::drawScreenFrame() {
g_system->copyRectToScreen(_frame->getPixels(), _frame->pitch, 0, 0, _screenW, _screenH);
}
diff --git a/engines/private/private.h b/engines/private/private.h
index f4610fd03b..4770ac03e4 100644
--- a/engines/private/private.h
+++ b/engines/private/private.h
@@ -211,6 +211,7 @@ public:
Graphics::ManagedSurface *_compositeSurface;
Graphics::Surface *loadMask(const Common::String &, int, int, bool);
void drawMask(Graphics::Surface *);
+ void fillRect(uint32, Common::Rect);
bool inMask(Graphics::Surface *, Common::Point);
uint32 _transparentColor;
Common::Rect screenRect;
@@ -231,6 +232,7 @@ public:
Common::String getPoliceBustFromMOSetting();
Common::String getAlternateGameVariable();
Common::String getPoliceIndexVariable();
+ Common::String getWallSafeValueVariable();
// movies
Common::String _nextMovie;
@@ -313,6 +315,17 @@ public:
void selectPhoneArea(Common::Point);
void checkPhoneCall();
+ // Safe
+ uint32 _safeColor;
+ Common::String _safeNumberPath;
+ MaskInfo _safeDigitArea[3];
+ Common::Rect _safeDigitRect[3];
+ uint32 _safeDigit[3];
+
+ bool selectSafeDigit(Common::Point);
+ void addSafeDigit(uint32, Common::Rect*);
+ void renderSafeDigit(uint32);
+
// Random values
bool getRandomBool(uint);
More information about the Scummvm-git-logs
mailing list