mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-19 18:51:09 +00:00
PRIVATE: initial implementation of the SafeDigit function
This commit is contained in:
parent
b7ea13750a
commit
10310cccdd
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user