mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +00:00
DIRECTOR: Check current cast archive for CURS resources
This commit is contained in:
parent
d2e56053f0
commit
ce78554746
@ -23,6 +23,7 @@
|
||||
#include "graphics/wincursor.h"
|
||||
|
||||
#include "director/director.h"
|
||||
#include "director/cast.h"
|
||||
#include "director/cursor.h"
|
||||
#include "director/movie.h"
|
||||
#include "director/castmember.h"
|
||||
@ -175,25 +176,17 @@ void Cursor::readFromResource(Datum resourceId) {
|
||||
default:
|
||||
bool readSuccessful = false;
|
||||
|
||||
for (Common::HashMap<Common::String, Archive *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo>::iterator it = g_director->_allOpenResFiles.begin(); it != g_director->_allOpenResFiles.end(); ++it) {
|
||||
MacArchive *arch = (MacArchive *)it->_value;
|
||||
Common::SeekableReadStreamEndian *cursorStream = nullptr;
|
||||
if (arch->hasResource(MKTAG('C', 'U', 'R', 'S'), resourceId.asInt()))
|
||||
cursorStream = arch->getResource(MKTAG('C', 'U', 'R', 'S'), resourceId.asInt());
|
||||
|
||||
if (!cursorStream && arch->hasResource(MKTAG('C', 'R', 'S', 'R'), resourceId.asInt()))
|
||||
cursorStream = arch->getResource(MKTAG('C', 'R', 'S', 'R'), resourceId.asInt());
|
||||
|
||||
if (cursorStream && readFromStream(*((Common::SeekableReadStream *)cursorStream), false, 0)) {
|
||||
_usePalette = true;
|
||||
_keyColor = 0xff;
|
||||
readSuccessful = true;
|
||||
|
||||
resetCursor(Graphics::kMacCursorCustom, false, resourceId);
|
||||
delete cursorStream;
|
||||
Cast *cast = g_director->getCurrentMovie()->getCast();
|
||||
if (cast && cast->getArchive()) {
|
||||
readSuccessful = readFromArchive(cast->getArchive(), resourceId.asInt());
|
||||
if (readSuccessful)
|
||||
break;
|
||||
}
|
||||
|
||||
for (Common::HashMap<Common::String, Archive *, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo>::iterator it = g_director->_allOpenResFiles.begin(); it != g_director->_allOpenResFiles.end(); ++it) {
|
||||
readSuccessful = readFromArchive(it->_value, resourceId.asInt());
|
||||
if (readSuccessful)
|
||||
break;
|
||||
}
|
||||
delete cursorStream;
|
||||
}
|
||||
|
||||
// TODO: figure out where to read custom cursor in windows platform
|
||||
@ -223,6 +216,26 @@ void Cursor::readFromResource(Datum resourceId) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Cursor::readFromArchive(Archive *archive, uint16 resourceId) {
|
||||
bool readSuccessful = false;
|
||||
Common::SeekableReadStreamEndian *cursorStream = nullptr;
|
||||
if (archive->hasResource(MKTAG('C', 'U', 'R', 'S'), resourceId))
|
||||
cursorStream = archive->getResource(MKTAG('C', 'U', 'R', 'S'), resourceId);
|
||||
|
||||
if (!cursorStream && archive->hasResource(MKTAG('C', 'R', 'S', 'R'), resourceId))
|
||||
cursorStream = archive->getResource(MKTAG('C', 'R', 'S', 'R'), resourceId);
|
||||
|
||||
if (cursorStream && readFromStream(*((Common::SeekableReadStream *)cursorStream), false, 0)) {
|
||||
_usePalette = true;
|
||||
_keyColor = 0xff;
|
||||
readSuccessful = true;
|
||||
|
||||
resetCursor(Graphics::kMacCursorCustom, false, resourceId);
|
||||
}
|
||||
delete cursorStream;
|
||||
return readSuccessful;
|
||||
}
|
||||
|
||||
void Cursor::resetCursor(Graphics::MacCursorType type, bool shouldClear, Datum resId) {
|
||||
if (shouldClear)
|
||||
clear();
|
||||
|
@ -34,6 +34,7 @@ class MacCursor;
|
||||
|
||||
namespace Director {
|
||||
|
||||
class Archive;
|
||||
struct CursorRef;
|
||||
|
||||
class Cursor : public Graphics::MacCursor {
|
||||
@ -45,6 +46,7 @@ class Cursor : public Graphics::MacCursor {
|
||||
void readFromCast(Datum casts);
|
||||
void readFromResource(Datum resourceId);
|
||||
void readBuiltinType(Datum resourceId);
|
||||
bool readFromArchive(Archive *archive, uint16 resourceId);
|
||||
|
||||
bool isEmpty() {return Datum(0).equalTo(_cursorResId);}
|
||||
bool operator==(const Cursor &c);
|
||||
|
Loading…
x
Reference in New Issue
Block a user