The idea here is to expose a much smaller part of the MacGui headers to
the SCUMM engine, but introducing a new class that simply relays calls
to the actual Mac GUI. I hope this will allow me to further untangle
things.
It's now the Mac dialog class that's responsible for saving/restoring
the screen shaking. (They were already responsible for pausing and
unpausing.) There are some other minor cleanups along the way, and the
drafts inventory can now be launched from the Apple menu.
In particular we set the _keyPressed object only when we find
an event.kbd for the numpad keys. Otherwise we immediately
get double events when pressing any key.
Dpad buttons are by default remapped to numpad keys. Up/Down are
KEYCODE_KP8/KEYCODE_KP2 and Left/right are KEYCODE_KP4/KEYCODE_KP6.
The numpad keys are remapped to have a corresponding ASCII value
since the state of the keys are stored in the _keyDownMap array,
indexed by the ASCII value.
It was found that the ASCII values were calculated incorrectly for
EVENT_KEYUP events but correctly for EVENT_KEY DOWN events. In the
latter cases the keyboard event was stored to the _keyPressed member
variable. The keycode was checked and if being a numpad key the
corresponding ASCII value was calculated. The key state was then
stored in the _keyDownMap array using the calculated ASCII value.
For the EVENT_KEYUP events the keyboard event was not stored to the
_keyPressed member variable. The keycode was still checked using the
_keyPressed variable. However the _keyPressed could have been reset
causing the ASCII calculation to fail for the numpad key. The raw
ASCII value of the keyboard event was instead being used to reset
the key state in the _keyDownMap array causing the numpad key to be
left in a pressed state.
This was found when plaing the Lunar Lander mini game in "The Dig"
using the virtual gamepad controller in iOS.
Fix it by writing the keyboard event to the _keyPressed variable
and use the corresponding ASCII value when reseting the key state
in the _keyDownMap array.
It's enough to do it after thigns have had a chance to change. Not every
iteration of waitForTimer(). This means we no longer have as precise
resolution for our animation timers, but I don't think that's any reason
not to cut down on the (admittedly small) amount of extra work the GUI
has to do.
This is still just a mock-up, and a bad one at that. It will all be for
nought unless I can figure out how to wire up these buttons to the SCUMM
verbs.
Albeit not 100% necessary for rewriting the HE sound engine,
I decided to make this change in order to:
- Give proper meaning to magic numbers and variables
which were given temporary names 20 years ago;
- Avoid going insane when making comparison with HE code
and ours, when rewriting the sound code.
This was caused by the fact that the pre and post save screen scripts
were not being called, and this messed up the cursor state with savegames
created as quicksaves.
Also, renamed the variables containing said scripts numbers, so that
they are a little bit more meaningful now.
The line we're amending was applied a while ago when there had
been issues with COMI losing mouse inputs during a keyboard press;
apparently this has been resolved in a different way, and keeping it
(on the contrary) loses keyboard inputs.
This has been tested by the speedrun community.
When clearBanner() is called for versions lower than 7, it can cause some pixels
from the previous dialog text to remain on screen and not be cleared when the
text speed banner is displayed and cleared out.
We allow ENTER to be used to confirm the dialog choice, swap the left and right
arrow keys, and correctly map the numpad keys (so that joypad now actually work!)
This commit implements saving and loading in the same way the original interpreters
for MANIAC v0-1-2, ZAK v1-2-3, LOOM v3 and INDY v3 do. This makes it possible to
use the original save menus without glitches or crashes.
Saves done from GMM can also be loaded from the original menu.