Ticket #6186: loom-doubleclick2.diff

File loom-doubleclick2.diff, 3.0 KB (added by eriktorbjorn, 12 years ago)

Slightly more elaborate (perhaps unnecessarily so?) patch

  • engines/scumm/script.cpp

    diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp
    index d8c4948..605d831 100644
    a b void ScummEngine::runInputScript(int clickArea, int val, int mode) {  
    13631363                                args[1] = VAR(82 + (val - 100));
    13641364                        }
    13651365                }
     1366        }
    13661367
    1367                 // Clicks are handled differently in Indy3 mac: param 2 of the
    1368                 // input script is set to 0 for normal clicks, and to 1 for double clicks.
     1368        // Double clicks are handled differently in Mac Indy3 and Loom
     1369        if (_game.platform == Common::kPlatformMacintosh && (_game.id == GID_INDY3 || _game.id == GID_LOOM)) {
    13691370                uint32 time = _system->getMillis();
    1370                 args[2] = (time < _lastInputScriptTime + 500);  // 500 ms double click delay
     1371                bool doubleClick = false;
     1372
     1373                // The DOS EGA version of Loom checks not only the time between
     1374                // the clicks, but also that the mouse position hasn't changed
     1375                // to much. That seems like a good idea to use here as well.
     1376                //
     1377                // We use a 500 ms as the double click delay, though at least
     1378                // DOS EGA Loom uses timer variables instead.
     1379                doubleClick = (time < _lastInputScriptTime + 500) &&
     1380                        (ABS(_lastInputScriptClickX - VAR(VAR_VIRT_MOUSE_X)) < 6) &&
     1381                        (ABS(_lastInputScriptClickY - VAR(VAR_VIRT_MOUSE_Y)) < 3);
     1382               
     1383                if (_game.id == GID_INDY3) {
     1384                        // param 2 of the input script is set to 0 for normal
     1385                        // clicks, and to 1 for double clicks.
     1386                        args[2] = doubleClick;
     1387                } else if (_game.id == GID_LOOM) {
     1388                        // DOS EGA Loom uses variables 50 and upwards to store
     1389                        // information about drafts. The Mac version uses
     1390                        // variables 55 and upwards. Variable 52 appears to be
     1391                        // the flag indicating double click. It's currently
     1392                        // unknown what the other extra variables are, or if
     1393                        // they are even used.
     1394                        VAR(52) = doubleClick;
     1395                }
     1396
    13711397                _lastInputScriptTime = time;
     1398                _lastInputScriptClickX = VAR(VAR_VIRT_MOUSE_X);
     1399                _lastInputScriptClickY = VAR(VAR_VIRT_MOUSE_Y);
    13721400        }
    13731401
    13741402        if (verbScript)
  • engines/scumm/scumm.cpp

    diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
    index 6a4fe23..2bbf743 100644
    a b ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)  
    200200        _leftBtnPressed = 0;
    201201        _rightBtnPressed = 0;
    202202        _lastInputScriptTime = 0;
     203        _lastInputScriptClickX = 0;
     204        _lastInputScriptClickY = 0;
    203205        _bootParam = 0;
    204206        _dumpScripts = false;
    205207        _debugMode = 0;
  • engines/scumm/scumm.h

    diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h
    index a77c1c0..6403c56 100644
    a b protected:  
    574574
    575575        /**
    576576         * Last time runInputScript was run (measured in terms of OSystem::getMillis()).
    577          * This is currently only used for Indy3 mac to detect "double clicks".
     577         * This is currently only used for Mac Indy3 and Loom to detect "double clicks".
    578578         */
    579579        uint32 _lastInputScriptTime;
     580        int _lastInputScriptClickX;
     581        int _lastInputScriptClickY;
    580582
    581583        /** The bootparam, to be passed to the script 1, the bootscript. */
    582584        int _bootParam;