Skip to content

Commit

Permalink
ZVISION: New search manager for handle right handle for ZIX-files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa-Chan committed Feb 4, 2014
1 parent 9c9f59d commit 4a454ed
Show file tree
Hide file tree
Showing 20 changed files with 518 additions and 98 deletions.
45 changes: 17 additions & 28 deletions engines/zvision/actions.cpp
Expand Up @@ -312,27 +312,11 @@ ActionMusic::~ActionMusic() {
bool ActionMusic::execute() {
if (_engine->getScriptManager()->getSideFX(_slotkey))
return true;
Common::File *file = new Common::File();
if (!file->exists(_fileName) && _fileName.size() >= 12) {
_fileName.setChar('r', 9);
_fileName.setChar('a', 10);
_fileName.setChar('w', 11);
if (!file->exists(_fileName)) {
_fileName.setChar('i', 9);
_fileName.setChar('f', 10);
_fileName.setChar('p', 11);
if (!file->exists(_fileName)) {
_fileName.setChar('s', 9);
_fileName.setChar('r', 10);
_fileName.setChar('c', 11);
if (!file->exists(_fileName))
return true;
}
}
}
if (file->exists(_fileName))
_engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));
delete file;

if (!_engine->getSearchManager()->hasFile(_fileName))
return true;

_engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume));

return true;
}
Expand Down Expand Up @@ -585,16 +569,21 @@ ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Commo

bool ActionStreamVideo::execute() {
ZorkAVIDecoder decoder;
if (!decoder.loadFile(_fileName)) {
return true;
}
Common::File *_file = _engine->getSearchManager()->openFile(_fileName);

if (_file) {
if (!decoder.loadStream(_file)) {
return true;
}

Common::Rect destRect;
if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
destRect = Common::Rect(_x1, _y1, _x2, _y2);
}

Common::Rect destRect;
if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) {
destRect = Common::Rect(_x1, _y1, _x2, _y2);
_engine->playVideo(decoder, destRect, _skippable);
}

_engine->playVideo(decoder, destRect, _skippable);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion engines/zvision/animation_node.cpp
Expand Up @@ -41,7 +41,7 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S
_animation(NULL) {

if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) {
_animation = new MetaAnimation(fileName);
_animation = new MetaAnimation(fileName, engine);
_frmDelay = _animation->frameTime();
} else {
warning("Unrecognized animation file type: %s", fileName.c_str());
Expand Down
29 changes: 29 additions & 0 deletions engines/zvision/cursor.cpp
Expand Up @@ -66,6 +66,35 @@ ZorkCursor::ZorkCursor(const Common::String &fileName)
_surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
}

ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName)
: _width(0),
_height(0),
_hotspotX(0),
_hotspotY(0) {
Common::File file;
if (!engine->getSearchManager()->openFile(file, fileName))
return;

uint32 magic = file.readUint32BE();
if (magic != MKTAG('Z', 'C', 'R', '1')) {
warning("%s is not a Zork Cursor file", fileName.c_str());
return;
}

_hotspotX = file.readUint16LE();
_hotspotY = file.readUint16LE();
_width = file.readUint16LE();
_height = file.readUint16LE();

uint dataSize = _width * _height * sizeof(uint16);
_surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0));
uint32 bytesRead = file.read(_surface.getPixels(), dataSize);
assert(bytesRead == dataSize);

// Convert to RGB 565
_surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
}

ZorkCursor::ZorkCursor(const ZorkCursor &other) {
_width = other._width;
_height = other._height;
Expand Down
2 changes: 2 additions & 0 deletions engines/zvision/cursor.h
Expand Up @@ -24,6 +24,7 @@
#define ZVISION_CURSOR_H

#include "graphics/surface.h"
#include "zvision/zvision.h"


namespace Common {
Expand All @@ -40,6 +41,7 @@ class ZorkCursor {
public:
ZorkCursor();
ZorkCursor(const Common::String &fileName);
ZorkCursor(ZVision *engine, const Common::String &fileName);
ZorkCursor(const ZorkCursor &other);
~ZorkCursor();

Expand Down
24 changes: 12 additions & 12 deletions engines/zvision/cursor_manager.cpp
Expand Up @@ -57,15 +57,15 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel
if (_engine->getGameId() == GID_NEMESIS) {
Common::String name;
name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]);
_cursors[i][0] = ZorkCursor(name); // Up cursor
_cursors[i][0] = ZorkCursor(_engine, name); // Up cursor
name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]);
_cursors[i][1] = ZorkCursor(name); // Down cursor
_cursors[i][1] = ZorkCursor(_engine, name); // Down cursor
} else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
_cursors[i][0] = ZorkCursor(_zgiCursorFileNames[i]); // Up cursor
_cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor
char buffer[25];
strcpy(buffer, _zgiCursorFileNames[i]);
buffer[3] += 2;
_cursors[i][1] = ZorkCursor(buffer); // Down cursor
_cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor
}
}
}
Expand All @@ -76,22 +76,22 @@ void CursorManager::setItemID(int id) {
Common::String file;
if (_engine->getGameId() == GID_NEMESIS) {
file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a');
_cursors[NUM_CURSORS][0] = ZorkCursor(file);
_cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b');
_cursors[NUM_CURSORS][1] = ZorkCursor(file);
_cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a');
_cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
_cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b');
_cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
_cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
} else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id);
_cursors[NUM_CURSORS][0] = ZorkCursor(file);
_cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file);
file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id);
_cursors[NUM_CURSORS][1] = ZorkCursor(file);
_cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file);
file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id);
_cursors[NUM_CURSORS + 1][0] = ZorkCursor(file);
_cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file);
file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id);
_cursors[NUM_CURSORS + 1][1] = ZorkCursor(file);
_cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file);
} else
return;
}
Expand Down
4 changes: 2 additions & 2 deletions engines/zvision/lever_control.cpp
Expand Up @@ -86,7 +86,7 @@ LeverControl::~LeverControl() {

void LeverControl::parseLevFile(const Common::String &fileName) {
Common::File file;
if (!file.open(fileName)) {
if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("LEV file %s could could be opened", fileName.c_str());
return;
}
Expand All @@ -103,7 +103,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) {
Common::String animationFileName(fileNameBuffer);

if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf"))
_animation = new MetaAnimation(animationFileName);
_animation = new MetaAnimation(animationFileName, _engine);

} else if (line.matchString("*skipcolor*", true)) {
// Not used
Expand Down
8 changes: 5 additions & 3 deletions engines/zvision/meta_animation.cpp
Expand Up @@ -37,17 +37,19 @@

namespace ZVision {

MetaAnimation::MetaAnimation(const Common::String &fileName)
MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine)
: _fileType(RLF),
_cur_frame(NULL) {
if (fileName.hasSuffix(".rlf")) {
_fileType = RLF;
_animation.rlf = new RlfAnimation(fileName, false);
Common::File *_file = engine->getSearchManager()->openFile(fileName);
_animation.rlf = new RlfAnimation(_file, false);
_frmDelay = _animation.rlf->frameTime();
} else if (fileName.hasSuffix(".avi")) {
_fileType = AVI;
Common::File *_file = engine->getSearchManager()->openFile(fileName);
_animation.avi = new ZorkAVIDecoder();
_animation.avi->loadFile(fileName);
_animation.avi->loadStream(_file);
_frmDelay = 1000.0 / _animation.avi->getDuration().framerate();
} else {
warning("Unrecognized animation file type: %s", fileName.c_str());
Expand Down
3 changes: 2 additions & 1 deletion engines/zvision/meta_animation.h
Expand Up @@ -24,6 +24,7 @@
#define ZVISION_METAANIM_NODE_H

#include "zvision/sidefx.h"
#include "zvision/zvision.h"
#include "common/rect.h"
#include "common/list.h"

Expand All @@ -47,7 +48,7 @@ class RlfAnimation;

class MetaAnimation {
public:
MetaAnimation(const Common::String &fileName);
MetaAnimation(const Common::String &fileName, ZVision *engine);
~MetaAnimation();

struct playnode {
Expand Down
3 changes: 2 additions & 1 deletion engines/zvision/module.mk
Expand Up @@ -35,7 +35,8 @@ MODULE_OBJS := \
inventory_manager.o \
slot_control.o \
menu.o \
meta_animation.o
meta_animation.o \
search_manager.o

MODULE_DIRS += \
engines/zvision
Expand Down
2 changes: 1 addition & 1 deletion engines/zvision/music_node.cpp
Expand Up @@ -51,7 +51,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool

if (filename.contains(".wav")) {
Common::File *file = new Common::File();
if (file->open(filename)) {
if (_engine->getSearchManager()->openFile(*file, filename)) {
audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES);
}
} else {
Expand Down
10 changes: 6 additions & 4 deletions engines/zvision/render_manager.cpp
Expand Up @@ -22,6 +22,7 @@

#include "common/scummsys.h"

#include "zvision/zvision.h"
#include "zvision/render_manager.h"

#include "zvision/lzss_read_stream.h"
Expand All @@ -37,8 +38,9 @@

namespace ZVision {

RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
: _system(system),
RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat)
: _engine(engine),
_system(engine->_system),
_wrkWidth(workingWindow.width()),
_wrkHeight(workingWindow.height()),
_screenCenterX(_wrkWidth / 2),
Expand Down Expand Up @@ -113,7 +115,7 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1
void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) {
Common::File file;

if (!file.open(fileName)) {
if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Could not open file %s", fileName.c_str());
return;
}
Expand Down Expand Up @@ -207,7 +209,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics:
void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) {
Common::File file;

if (!file.open(fileName)) {
if (!_engine->getSearchManager()->openFile(file, fileName)) {
warning("Could not open file %s", fileName.c_str());
return;
}
Expand Down
3 changes: 2 additions & 1 deletion engines/zvision/render_manager.h
Expand Up @@ -47,7 +47,7 @@ namespace ZVision {

class RenderManager {
public:
RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat);
~RenderManager();

private:
Expand All @@ -70,6 +70,7 @@ class RenderManager {
typedef Common::HashMap<uint16, oneSub> subMap;

private:
ZVision *_engine;
OSystem *_system;
const Graphics::PixelFormat _pixelFormat;

Expand Down

0 comments on commit 4a454ed

Please sign in to comment.