Commit Graph
101 Commits
Author SHA1 Message Date
Scott Percival 190406c8d1 DIRECTOR: Add debug timing for draw calls 2023-10-25 18:22:15 +02:00
Harishankar Kumar 33d4b35869 DIRECTOR: Fix visibility issue when setting window properties
This patch fixes the behaviour of windows when setting their
properties (e.g. titleVisibility, Modal, etc) from the lingo.

Initially the window was set to be visible when the property was
set, but this is not the expected behaviour. The window should
only be visible when the `open` command is called. Removed `setVisible(true)`
from various window properties assignment functions.

Fixes popupmenu overlay in `meet-mediaband` and white rectangle when
opening `mcluhan-win`.

--start-movie="main\stvimenu.dxr" mediaband-win
2023-08-09 18:49:16 +02:00
Harishankar Kumar 89cd5ff322 DIRECTOR: Improve logic for recursive enterFrame calls
In the original engine, the enterFrame handler can only be called
recursively upto second depth, and the third call will be ignored.
This was formerly implemented by counting number of frozen lingo
states, however there are cases where the lingo state is frozen,
while enterFrame handler not called, so the count is not accurate.

This patch improves the logic by counting the number of enterFrame
in frozen lingo states as well, so it can be identified that these
previous frames are indeed of `enterFrame` handler.

Fixes bug where the elevator when jumping to next floor (yellow one)
broke dimensional movement in `totaldistortion-win`.
2023-08-05 21:51:58 +02:00
Eugene Sandulenko 8bccc12786 DIRECTOR: Reduce header dependency 2023-08-02 21:05:06 +02:00
Harishankar Kumar 46ce5bd51f DIRECTOR: Fix memory leaks when changing sharedCast
When changing from shared casts in `Window::loadNewSharedCast`, and in
instance where previousCast need to be deleted, we just deleted the cast
itself but not the underlying `Archive`, this resulted in memory leaks.
`~Director()` was not deleting this archive because it was being removed
from `_allSeenResFiles` in favour of loading new archive.

Fixed by deleting `Archive *_castArchive` of previousCast after erasing
its entry from `_allSeenResFiles`.
2023-07-25 06:59:54 +02:00
Misty De Meo 26e203856f DIRECTOR: fully remove old shared cast
When reloading the shared cast, erase the references from both
_allSeenResFiles and _allOpenResFiles. In the case that the shared
cast is reloaded from a different path, this would leave a dangling
reference in _allOpenResFiles. This would then lead to a crash later
when enumerating _allOpenResFiles and trying to access the found
path in _allSeenResFiles.

Fixes a crash in the D4 version of Alice which would occur when loading
the cursor. This occurs since Alice ends up loading first Shared.dir and
then DATA:Shared.dir, leaving a dangling reference to Shared.dir in
_allSeenResFiles.

Issue was introduced in 9aa0958736.
2023-07-18 15:45:10 -07:00
Harishankar Kumar fdd8c34691 DIRECTOR: Rename _frame, getCurrentFrame(), getTotalFrames() to improve readability 2023-07-10 16:03:11 +02:00
Harishankar Kumar 0bde66b864 DIRECTOR: Implement fileName of window property
Normally Director will look for a movie of the same name as the window,
however with `the fileName` property, it can assign name of movie to be
played in the window.
2023-07-08 22:15:42 +03:00
Scott Percival 8a6d7d6c95 DIRECTOR: Move file extension checks to innermost loop
Fixes shared cast detection in Meet Mediaband.
2023-07-08 22:01:00 +03:00
Scott Percival 17e1853347 DIRECTOR: Refactor path detection
Previously, paths were verified by pathMakeRelative().
This method had several drawbacks; the code was increasingly ad-hoc
and recursive, and the function would return a Common::String that
was not guaranteed to be distinct. 90% of the time the path would need
to be converted to Common::Path so that file streams could use it.

This code has been replaced with findPath(), a function which takes a
path string as recieved from Director (e.g. a Lingo script, a filename
stored in a CastInfo record) and returns a Common::Path object for the
file on the local system. The inner workings have been split into subfunctions,
which should make it easier to add workarounds and fuzz at the correct
layer.
2023-07-08 22:01:00 +03:00
Eugene Sandulenko 1d0e7993f5 DIRECTOR: Force drawing of frame counter even when there are no other changes 2023-07-01 17:01:40 +02:00
Eugene Sandulenko 95dfac0794 DIRECTOR: Remove code duplication in debug draw 2023-07-01 17:01:40 +02:00
Eugene Sandulenko 95d8cf840c DIRECTOR: _allOpenResFiles -> _allSeenResFiles 2023-06-29 23:22:54 +02:00
Eugene Sandulenko 7baba61852 DIRECTOR: Modernized rest of the loops 2023-06-29 23:22:38 +02:00
Eugene Sandulenko a62b7985b5 DIRECTOR: Modernized some loops 2023-06-29 17:35:06 +02:00
Eugene Sandulenko 29309a4078 DIRECTOR: Draw shadow for debug sprite/frame information 2023-06-17 11:01:54 +02:00
Scott Percival 458e97933d DIRECTOR: Refactor archive loading code
Make DirectorEngine::_allOpenResFiles the de-facto owner of Archive *
objects, move all of the various loadEXE/loadMac methods off Window and
onto DirectorEngine, and replace inline Archive loading with
openArchive().
2023-06-08 09:16:30 +02:00
Harishankar KumarandPragyansh Chaturvedi 829c3e32f4 DIRECTOR: Implement modal property of window
Implements modal property using the locking widgets of macwindowmanager.

`modal of window` in 'workshop' uses this.

Co-authored-by: Pragyansh Chaturvedi <pragyanshchaturvedi18@gmail.com>
2023-06-01 20:17:23 +02:00
Harishankar KumarandPragyansh Chaturvedi dd72dd09ca DIRECTOR: Implement the titleVisible property of window
Modifies border of window by first changing title to "", then updating
window border to borderType 2 `ThinNoTitle`.

`titleVisible of window` to verify this behavior.

Co-authored-by: Pragyansh Chaturvedi <pragyanshchaturvedi18@gmail.com>
2023-06-01 20:17:23 +02:00
Harishankar Kumar 6700c810fa DIRECTOR: Get/Set rect property of window, allow dynamic resize/move.
Adds the support to get/set field 'rect' of window object, interally it modifies the inner dimension of window object.

'mcluhan' used this to set window dimensions of background windows (through tell), Additionally `rect of window` in `workshop` also uses this patch for setting/getting field `rect` of window.
2023-05-31 13:29:33 +02:00
Harishankar Kumar 23f1229e67 GRAPHICS: MACGUI: Refactor resize() to extract inner window resizing
resize function is extracted to new function resize and resizeInner,
also a new private function rebuildSurface is created to handle common
code of refreshing/rebuilding surface after modifying inner or outer
window dimensions.
2023-05-31 13:29:33 +02:00
Scott Percival 9ec6722b6a DIRECTOR: Remove inkBlitStretchSurface()
No longer needed, the scaling should happen when updating the widget.

Fixes adjusting sprites with Lingo, such as in DEVO Presents:
Adventures of the Smart Patrol.
2023-05-28 14:44:09 +02:00
Scott Percival 9188159114 DIRECTOR: Move draw debugger to Window::render() 2023-05-28 14:44:09 +02:00
Scott Percival f703ee6ecf DIRECTOR: Split CastMember classes into files 2023-04-29 14:20:05 +02:00
Scott Percival 82e891d1d3 DIRECTOR: Move palette/transition debugging to images flag 2023-03-06 21:26:28 +01:00
Eugene Sandulenko 31c22852fd DIRECTOR: Added more debug output 2023-02-23 13:26:49 +01:00
Eugene Sandulenko 871b39c347 DIRECTOR: Do not enforce current path when loading next movie. Bug #13204
These days we are checking path validity in Window::setNextMovie(),
thus, forcing _currentPath leaded to inability to load movies from
root when called from within a subdirectory.

Fixes alice-win
2023-02-23 01:03:56 +01:00
Eugene Sandulenko 7d6018e663 DIRECTOR: Implement and use spriteType2str() 2023-02-13 16:24:46 +01:00
Eugene Sandulenko be62305248 DIRECTOR: Implemented debugger commands for drawing bitmapcast outlines and frame number 2023-02-04 15:48:41 +01:00
Eugene Sandulenko 5ce90b0bc7 DIRECTOR: Increased number of fewframesonly to 19 2023-01-27 22:29:21 +01:00
Eugene Sandulenko 63a57c1ba3 DIRECTOR: Made fewframesonly count global frames.
If the movie is switching during the first few frames, we were
resetting the counter which led to buildbot hanging.
2023-01-27 22:25:19 +01:00
Scott Percival d76b359ac2 DIRECTOR: Refactor movie loaders to allow loading from executables 2023-01-19 12:12:21 +01:00
Scott Percival 2674b628c4 DIRECTOR: Free frozen lingo states in window destructor 2022-12-09 01:10:57 +01:00
Scott Percival 7c975eff43 DIRECTOR: LINGO: Adjust freezing/thawing behaviour 2022-12-09 01:10:57 +01:00
Scott Percival 3ea7f10467 DIRECTOR: Freeze LingoState instead of using callstack
Previously, the Lingo state would be frozen by persisting the frames on
the bottom of the callstack with a special flag. This required extra
logic to determine whether or not the callstack was intended to be empty
after execution finished, with some complex edge cases.

The new approach is to swap out the LingoState object on the window,
meaning that an empty callstack always signifies execution has completed.
It remains to be seen if we'll need to track more than one frozen
context; for now it seems to be okay.

Fixes driving to locations in DEVO Presents: Adventures of the Smart Patrol.
2022-12-09 01:10:57 +01:00
Scott Percival 873095c87e DIRECTOR: Move current Lingo state into Window-owned struct
The previous arrangement was to copy the bits of Lingo state back and forth from
the Window object to the Lingo instance, and query the window for the
callstack. This refactor consolidates the current Lingo state into a single
struct, owned by the Window object and accessible via a pointer on the
Lingo object.
2022-12-09 01:10:57 +01:00
Vladimir Serbinenko 0670d1a16a DIRECTOR: Switch to openFileOrDataFork 2022-12-04 20:16:21 +01:00
Roland van Laar 891fa08f15 DIRECTOR: Refactor loading next Movie
The loading of the next movie and corresponding shared cast
is now handled in seperate functions.
There checks when to load a new shared cast and when to delete
the previous one could be simplified by returning early when the
previous and new shared casts are the same.

At the same time it fixes a Dereference after null check from Coverity.
sharedCast->getArchive() could return a null pointer and wasn't checked
in all places.

Fixes COVERITY: 1498090
2022-10-07 17:00:31 +02:00
Scott Percival 2874f05eb3 DIRECTOR: Implement movie and nextmovie debugger commands 2022-09-28 17:07:07 +02:00
Roland van Laar 6c4e6321f3 DIRECTOR: LINGO: Improve frozen context handling
When an error happens during go, for example with a nonexisting movie
the lingo callstack isn't cleaned up properly.

Now the callstack is cleaned up via `popContext(aborting=true)`.

This improves on commit:
DIRECTOR: fix memleak when lingo context is frozen
27b314cb25
2022-09-24 23:49:10 +02:00
Roland van Laar 15ee7ba98a DIRECTOR: LINGO: fix memory leaks for lingo tests
The Lingo tests were failing because of memory leaks.
- `move` overwrote an existing cast without deleting it
- `puppetTransition` was set but not removed on class destruction
- the *.lingo test files were opened but never removed
2022-09-24 23:21:38 +02:00
Roland van Laar 27b314cb25 DIRECTOR: fix memleak when lingo context is frozen
Cleanup the lingo callstack when closing.

When a movie calls `go frameId` a big pause button is hit
and everything is put into order to not go to the frame +1
but to the requested frameId. That big pause button is called
`_freezeContext`.

However when quitting in the middle of a frozen context
there are lingo frames left on the callstack.

This can be reliably reproduced with a plethora of D2 and D3 movies
with the debugflags fewframesonly,fast.
2022-09-24 21:28:22 +02:00
Roland van Laar 0091a20fe9 DIRECTOR: limit files closed by closeResFile
Lingo function `closeResFile` is only responsible for closing resource
file opened by `openResFile`. Register in `openResFile` which files
where opened and close only those files in `closeResFile`.

- Rename `_openResFiles` to `_allOpenResFiles` and
- Add new `_openResFiles` hashmap to track which files were opened in
  `openResFile`.
2022-09-23 22:55:50 +02:00
Roland van Laar f440529512 DIRECTOR: only cleanup sharedcast when it exists
Fixes segfault when the sharedcast was a nullptr.
2022-09-17 23:51:57 +02:00
Roland van Laar a105a0c121 DIRECTOR: unregister shared cast before deleting
A pointer to sharedCast was stored in the HashMap_openResFiles.
sharedCasts were deleted when a switch to a new movie was made
while _openResFiles is cleared when quitting Director.

This fix removes the reference to the shared cast when the shared cast
is deleted.
2022-09-17 23:15:50 +02:00
Scott Percival e750f05fe4 DIRECTOR: Don't erase _composeSurface after movie change
Fixes the scene transitions in the Spaceship Warlock trailer.
2022-09-12 15:52:18 +02:00
Roland van Laar c342819a60 DIRECTOR: LINGO: Implement the rect of the stage
The rect of stage returns the values of the stage rect.
2022-04-03 12:05:30 +02:00
Eugene Sandulenko abea37c9bb ALL: Update ScummVM project license to GPLv3+ 2021-12-26 18:48:43 +01:00
Scott Percival 6d32f570f5 DIRECTOR: Rework film loops to render as channels
The engine treats film loops as N full channels getting rendered to the
screen in the space of one. As such, it's impossible to pre-blit together
the content, as any blitter mode can be used for each of the items.
2021-11-07 12:05:29 +08:00
Scott Percival 29973e8627 DIRECTOR: Revert change to inkBlitShape
Using the dest. rect for everything leaves snail trails
in most of Spaceship Warlock.
2021-10-12 08:19:29 +08:00