mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-30 21:00:39 +00:00
GRAPHICS: Unify loading Windows cursor groups
This commit is contained in:
parent
e49282577f
commit
5cd6812b9d
@ -23,8 +23,6 @@
|
||||
#include "common/ptr.h"
|
||||
#include "common/stream.h"
|
||||
#include "common/textconsole.h"
|
||||
#include "common/winexe_ne.h"
|
||||
#include "common/winexe_pe.h"
|
||||
|
||||
#include "graphics/wincursor.h"
|
||||
|
||||
@ -242,63 +240,7 @@ WinCursorGroup::~WinCursorGroup() {
|
||||
delete cursors[i].cursor;
|
||||
}
|
||||
|
||||
WinCursorGroup *WinCursorGroup::createCursorGroup(Common::NEResources *exe, const Common::WinResourceID &id) {
|
||||
Common::ScopedPtr<Common::SeekableReadStream> stream(exe->getResource(Common::kWinGroupCursor, id));
|
||||
|
||||
if (!stream || stream->size() <= 6)
|
||||
return 0;
|
||||
|
||||
stream->skip(4);
|
||||
uint32 cursorCount = stream->readUint16LE();
|
||||
if ((uint32)stream->size() < (6 + cursorCount * 14))
|
||||
return 0;
|
||||
|
||||
WinCursorGroup *group = new WinCursorGroup();
|
||||
group->cursors.reserve(cursorCount);
|
||||
|
||||
for (uint32 i = 0; i < cursorCount; i++) {
|
||||
stream->readUint16LE(); // width
|
||||
stream->readUint16LE(); // height
|
||||
|
||||
// Plane count
|
||||
if (stream->readUint16LE() != 1) {
|
||||
delete group;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Bits per pixel
|
||||
// NE cursors can only be 1bpp
|
||||
if (stream->readUint16LE() != 1) {
|
||||
delete group;
|
||||
return 0;
|
||||
}
|
||||
|
||||
stream->readUint32LE(); // data size
|
||||
uint32 cursorId = stream->readUint16LE();
|
||||
|
||||
Common::ScopedPtr<Common::SeekableReadStream> cursorStream(exe->getResource(Common::kWinCursor, cursorId));
|
||||
if (!cursorStream) {
|
||||
delete group;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WinCursor *cursor = new WinCursor();
|
||||
if (!cursor->readFromStream(*cursorStream)) {
|
||||
delete cursor;
|
||||
delete group;
|
||||
return 0;
|
||||
}
|
||||
|
||||
CursorItem item;
|
||||
item.id = cursorId;
|
||||
item.cursor = cursor;
|
||||
group->cursors.push_back(item);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
WinCursorGroup *WinCursorGroup::createCursorGroup(Common::PEResources *exe, const Common::WinResourceID &id) {
|
||||
WinCursorGroup *WinCursorGroup::createCursorGroup(Common::WinResources *exe, const Common::WinResourceID &id) {
|
||||
Common::ScopedPtr<Common::SeekableReadStream> stream(exe->getResource(Common::kWinGroupCursor, id));
|
||||
|
||||
if (!stream || stream->size() <= 6)
|
||||
|
@ -29,8 +29,6 @@
|
||||
#include "graphics/cursor.h"
|
||||
|
||||
namespace Common {
|
||||
class NEResources;
|
||||
class PEResources;
|
||||
class SeekableReadStream;
|
||||
}
|
||||
|
||||
@ -56,10 +54,8 @@ struct WinCursorGroup {
|
||||
|
||||
Common::Array<CursorItem> cursors;
|
||||
|
||||
/** Create a cursor group from an NE EXE, returns 0 on failure */
|
||||
static WinCursorGroup *createCursorGroup(Common::NEResources *exe, const Common::WinResourceID &id);
|
||||
/** Create a cursor group from an PE EXE, returns 0 on failure */
|
||||
static WinCursorGroup *createCursorGroup(Common::PEResources *exe, const Common::WinResourceID &id);
|
||||
/** Create a cursor group from an EXE, returns 0 on failure */
|
||||
static WinCursorGroup *createCursorGroup(Common::WinResources *exe, const Common::WinResourceID &id);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user