TITANIC: Added CGameObject saving, and movie range info methods

This commit is contained in:
Paul Gilbert 2016-06-29 22:05:06 -04:00
parent 5ccc0a66da
commit 8ea5d53329
10 changed files with 107 additions and 27 deletions

View File

@ -82,7 +82,49 @@ CGameObject::~CGameObject() {
void CGameObject::save(SimpleFile *file, int indent) {
file->writeNumberLine(7, indent);
error("TODO: CGameObject::save");
_movieRangeInfoList.destroyContents();
if (_surface) {
Common::List<CMovieRangeInfo *> rangeList = _surface->getMovieRangeInfo();
for (Common::List<CMovieRangeInfo *>::const_iterator i = rangeList.begin();
i != rangeList.end(); ++i) {
CMovieRangeInfo *rangeInfo = new CMovieRangeInfo(*i);
rangeInfo->_frameNumber = (i == rangeList.begin()) ? getMovieFrame() : -1;
}
}
_movieRangeInfoList.save(file, indent);
_movieRangeInfoList.destroyContents();
file->writeNumberLine(getMovieFrame(), indent + 1);
file->writeNumberLine(_cursorId, indent + 1);
_movieClips.save(file, indent + 1);
file->writeNumberLine(_field60, indent + 1);
file->writeNumberLine(_field40, indent + 1);
file->writeQuotedLine(_resource, indent + 1);
file->writeBounds(_bounds, indent + 1);
file->writeFloatLine(_field34, indent + 1);
file->writeFloatLine(_field38, indent + 1);
file->writeFloatLine(_field3C, indent + 1);
file->writeNumberLine(_field44, indent + 1);
file->writeNumberLine(_field48, indent + 1);
file->writeNumberLine(_field4C, indent + 1);
file->writeNumberLine(_fieldB8, indent + 1);
file->writeNumberLine(_visible, indent + 1);
file->writeNumberLine(_isMail, indent + 1);
file->writeNumberLine(_id, indent + 1);
file->writeNumberLine(_roomFlags, indent + 1);
if (_surface) {
_surface->_resourceKey.save(file, indent);
} else {
CResourceKey resourceKey;
resourceKey.save(file, indent);
}
file->writeNumberLine(_surface != nullptr, indent);
CNamedItem::save(file, indent);
}
@ -93,7 +135,7 @@ void CGameObject::load(SimpleFile *file) {
switch (val) {
case 7:
_movieRangeInfo.load(file);
_movieRangeInfoList.load(file);
_frameNumber = file->readNumber();
// Deliberate fall-through
@ -179,7 +221,7 @@ void CGameObject::draw(CScreenManager *screenManager) {
_frameNumber = -1;
}
if (!_movieRangeInfo.empty())
if (!_movieRangeInfoList.empty())
processMoveRangeInfo();
if (_bounds.intersects(getGameManager()->_bounds)) {
@ -377,10 +419,10 @@ void CGameObject::playMovie(int v1, int v2) {
}
void CGameObject::processMoveRangeInfo() {
for (CMovieRangeInfoList::iterator i = _movieRangeInfo.begin(); i != _movieRangeInfo.end(); ++i)
for (CMovieRangeInfoList::iterator i = _movieRangeInfoList.begin(); i != _movieRangeInfoList.end(); ++i)
(*i)->process(this);
_movieRangeInfo.destroyContents();
_movieRangeInfoList.destroyContents();
}
void CGameObject::makeDirty(const Rect &r) {
@ -1071,12 +1113,12 @@ bool CGameObject::clipExistsByEnd(const CString &name, int endFrame) const {
return _movieClips.existsByEnd(name, endFrame);
}
void CGameObject::checkPlayMovie(const CString &name, int flags) {
void CGameObject::checkPlayMovie(int fieldC, int field10, int frameNumber, int flags) {
if (!_surface && !_resource.empty())
loadResource(_resource);
if (_surface ) {
_surface->proc35(name, flags, (flags & CLIPFLAG_4) ? this : nullptr);
_surface->proc35(fieldC, field10, frameNumber, flags, (flags & CLIPFLAG_4) ? this : nullptr);
if (flags & CLIPFLAG_PLAY)
getGameManager()->_gameState.addMovie(_surface->_movie);
}

View File

@ -90,7 +90,7 @@ protected:
int _field4C;
CMovieClipList _movieClips;
int _initialFrame;
CMovieRangeInfoList _movieRangeInfo;
CMovieRangeInfoList _movieRangeInfoList;
int _frameNumber;
CPetText *_text;
uint _textBorder;
@ -533,7 +533,7 @@ public:
/**
* Returns the clip list, if any, associated with the item
*/
virtual const CMovieClipList *getClipList() const { return &_movieClips; }
virtual const CMovieClipList *getMovieClips() const { return &_movieClips; }
/**
* Allows the item to draw itself
@ -594,7 +594,7 @@ public:
/**
* Checks and plays a pending clip
*/
void checkPlayMovie(const CString &name, int flags);
void checkPlayMovie(int fieldC, int field10, int frameNumber, int flags);
/**
* Returns true if the object has a currently active movie

View File

@ -134,7 +134,7 @@ public:
/**
* Returns the clip list, if any, associated with the item
*/
virtual const CMovieClipList *getClipList() const { return nullptr; }
virtual const CMovieClipList *getMovieClips() const { return nullptr; }
/**
* Returns true if the given item connects to another specified view

View File

@ -99,7 +99,7 @@ void OSMovie::proc11() {
warning("TODO: OSMovie::proc11");
}
void OSMovie::proc12(const CString &name, int flags, CGameObject *obj) {
void OSMovie::proc12(int v1, int v2, int frameNumber, int flags, CGameObject *obj) {
warning("TODO: OSMovie::proc12");
}
@ -121,8 +121,9 @@ void OSMovie::proc16() {
warning("TODO: OSMovie::proc16");
}
void OSMovie::proc17() {
warning("TODO: OSMovie::proc17");
const Common::List<CMovieRangeInfo *> OSMovie::getMovieRangeInfo() const {
warning("TODO: OSMovie::getMovieRangeInfo");
return Common::List<CMovieRangeInfo *>();
}
void OSMovie::proc18() {

View File

@ -23,9 +23,11 @@
#ifndef TITANIC_MOVIE_H
#define TITANIC_MOVIE_H
#include "common/list.h"
#include "video/video_decoder.h"
#include "titanic/core/list.h"
#include "titanic/core/resource_key.h"
#include "titanic/support/movie_range_info.h"
namespace Titanic {
@ -72,7 +74,7 @@ public:
virtual void playClip(const Rect &rect, uint startFrame, uint endFrame) = 0;
virtual void proc11() = 0;
virtual void proc12(const CString &name, int flags, CGameObject *obj) = 0;
virtual void proc12(int v1, int v2, int frameNumber, int flags, CGameObject *obj) = 0;
/**
* Stops the movie
@ -82,7 +84,12 @@ public:
virtual void proc14() = 0;
virtual void setFrame(uint frameNumber) = 0;
virtual void proc16() = 0;
virtual void proc17() = 0;
/**
* Return any movie range info associated with the movie
*/
virtual const Common::List<CMovieRangeInfo *> getMovieRangeInfo() const = 0;
virtual void proc18() = 0;
/**
@ -139,7 +146,7 @@ public:
virtual void playClip(const Rect &rect, uint startFrame, uint endFrame);
virtual void proc11();
virtual void proc12(const CString &name, int flags, CGameObject *obj);
virtual void proc12(int v1, int v2, int frameNumber, int flags, CGameObject *obj);
/**
* Stops the movie
@ -154,7 +161,12 @@ public:
virtual void setFrame(uint frameNumber);
virtual void proc16();
virtual void proc17();
/**
* Return any movie range info associated with the movie
*/
virtual const Common::List<CMovieRangeInfo *> getMovieRangeInfo() const;
virtual void proc18();
/**

View File

@ -65,6 +65,8 @@ void CMovieClip::load(SimpleFile *file) {
ListItem::load(file);
}
/*------------------------------------------------------------------------*/
CMovieClip *CMovieClipList::findByName(const Common::String &name) const {
for (const_iterator i = begin(); i != end(); ++i) {
CMovieClip *clip = *i;

View File

@ -34,7 +34,9 @@ CMovieRangeInfo::~CMovieRangeInfo() {
}
CMovieRangeInfo::CMovieRangeInfo(const CMovieRangeInfo *src) : ListItem() {
_movieName = src->_movieName;
_fieldC = src->_fieldC;
_field10 = src->_field10;
_frameNumber = src->_frameNumber;
_startFrame = src->_startFrame;
_endFrame = src->_endFrame;
@ -47,7 +49,9 @@ CMovieRangeInfo::CMovieRangeInfo(const CMovieRangeInfo *src) : ListItem() {
void CMovieRangeInfo::save(SimpleFile *file, int indent) {
file->writeNumberLine(0, indent);
file->writeQuotedLine(_movieName, indent + 1);
file->writeNumberLine(_fieldC, indent + 1);
file->writeNumberLine(_field10, indent + 1);
file->writeNumberLine(_frameNumber, indent + 1);
file->writeNumberLine(_endFrame, indent + 1);
file->writeNumberLine(_startFrame, indent + 1);
_events.save(file, indent + 1);
@ -56,7 +60,9 @@ void CMovieRangeInfo::save(SimpleFile *file, int indent) {
void CMovieRangeInfo::load(SimpleFile *file) {
int val = file->readNumber();
if (!val) {
_movieName = file->readString();
_fieldC = file->readNumber();
_field10 = file->readNumber();
_frameNumber = file->readNumber();
_endFrame = file->readNumber();
_startFrame = file->readNumber();
_events.load(file);
@ -94,7 +100,7 @@ void CMovieRangeInfo::process(CGameObject *owner) {
}
}
owner->checkPlayMovie(_movieName, flags);
owner->checkPlayMovie(_fieldC, _field10, _frameNumber, flags);
for (CMovieEventList::iterator i = _events.begin(); i != _events.end(); ++i) {
CMovieEvent *movieEvent = *i;

View File

@ -34,7 +34,9 @@ class CGameObject;
class CMovieRangeInfo : public ListItem {
public:
CString _movieName;
int _fieldC;
int _field10;
int _frameNumber;
uint _startFrame;
uint _endFrame;
CMovieEventList _events;

View File

@ -402,9 +402,9 @@ void OSVideoSurface::playMovie(uint startFrame, uint endFrame, int v3, bool v4)
}
}
void OSVideoSurface::proc35(const CString &name, int flags, CGameObject *owner) {
void OSVideoSurface::proc35(int v1, int v2, int frameNumber, int flags, CGameObject *owner) {
if (loadIfReady() && _movie) {
_movie->proc12(name, flags, owner);
_movie->proc12(v1, v2, frameNumber, flags, owner);
}
}
@ -426,6 +426,10 @@ void OSVideoSurface::proc39(int v1, int v2) {
warning("OSVideoSurface::proc39");
}
const Common::List<CMovieRangeInfo *> OSVideoSurface::getMovieRangeInfo() const {
return _movie ? _movie->getMovieRangeInfo() : Common::List<CMovieRangeInfo *>();
}
bool OSVideoSurface::loadIfReady() {
_videoSurfaceNum = _videoSurfaceCounter;

View File

@ -28,6 +28,7 @@
#include "titanic/support/font.h"
#include "titanic/support/direct_draw.h"
#include "titanic/support/movie.h"
#include "titanic/support/movie_range_info.h"
#include "titanic/support/rect.h"
#include "titanic/core/list.h"
#include "titanic/core/resource_key.h"
@ -166,7 +167,7 @@ public:
*/
virtual void playMovie(uint startFrame, uint endFrame, int v3, bool v4) = 0;
virtual void proc35(const CString &name, int flags, CGameObject *owner) = 0;
virtual void proc35(int v1, int v2, int frameNumber, int flags, CGameObject *owner) = 0;
/**
* Stops any movie currently attached to the surface
@ -182,6 +183,11 @@ public:
virtual void proc39(int v1, int v2) = 0;
/**
* Return any movie range info associated with the surface's movie
*/
virtual const Common::List<CMovieRangeInfo *> getMovieRangeInfo() const = 0;
/**
* Loads the surface's resource if there's one pending
*/
@ -335,7 +341,7 @@ public:
*/
virtual void playMovie(uint startFrame, uint endFrame, int v3, bool v4);
virtual void proc35(const CString &name, int flags, CGameObject *owner);
virtual void proc35(int v1, int v2, int frameNumber, int flags, CGameObject *owner);
/**
* Stops any movie currently attached to the surface
@ -351,6 +357,11 @@ public:
virtual void proc39(int v1, int v2);
/**
* Return any movie range info associated with the surface's movie
*/
virtual const Common::List<CMovieRangeInfo *> getMovieRangeInfo() const;
/**
* Loads the surface's resource if there's one pending
*/