diff options
-rw-r--r-- | engines/titanic/files.cpp | 27 | ||||
-rw-r--r-- | engines/titanic/files.h | 11 | ||||
-rw-r--r-- | engines/titanic/list.h | 2 | ||||
-rw-r--r-- | engines/titanic/module.mk | 8 | ||||
-rw-r--r-- | engines/titanic/objects/file_item.cpp | 28 | ||||
-rw-r--r-- | engines/titanic/objects/file_item.h | 36 | ||||
-rw-r--r-- | engines/titanic/objects/message_target.cpp | 27 | ||||
-rw-r--r-- | engines/titanic/objects/message_target.h | 35 | ||||
-rw-r--r-- | engines/titanic/objects/project_item.cpp | 60 | ||||
-rw-r--r-- | engines/titanic/objects/project_item.h | 52 | ||||
-rw-r--r-- | engines/titanic/objects/saveable_object.cpp (renamed from engines/titanic/saveable_object.cpp) | 14 | ||||
-rw-r--r-- | engines/titanic/objects/saveable_object.h (renamed from engines/titanic/saveable_object.h) | 0 | ||||
-rw-r--r-- | engines/titanic/objects/tree_item.cpp | 27 | ||||
-rw-r--r-- | engines/titanic/objects/tree_item.h | 35 | ||||
-rw-r--r-- | engines/titanic/titanic.cpp | 2 |
15 files changed, 355 insertions, 9 deletions
diff --git a/engines/titanic/files.cpp b/engines/titanic/files.cpp index 6432595748..2f5b1b511e 100644 --- a/engines/titanic/files.cpp +++ b/engines/titanic/files.cpp @@ -25,7 +25,7 @@ namespace Titanic { -SimpleFile::SimpleFile() { +SimpleFile::SimpleFile(): _stream(nullptr) { } SimpleFile::~SimpleFile() { @@ -38,18 +38,24 @@ void SimpleFile::open(const Common::String &name, FileMode mode) { error("Could not find file - %s", name.c_str()); } +void SimpleFile::open(Common::SeekableReadStream *stream, FileMode mode) { + close(); + _stream = stream; +} + void SimpleFile::close() { _file.close(); + _stream = nullptr; } void SimpleFile::safeRead(void *dst, size_t count) { - assert(_file.isOpen()); + assert(_stream); if (unsafeRead(dst, count) != count) error("Could not read %d bytes", count); } size_t SimpleFile::unsafeRead(void *dst, size_t count) { - return _file.read(dst, count); + return _stream->read(dst, count); } CString SimpleFile::readString() { @@ -225,7 +231,7 @@ void Decompressor::load(const char *version, int v) { } int Decompressor::sub1(Method3Fn fn, int v) { - + return 0; } void Decompressor::close() { @@ -263,6 +269,19 @@ void CompressedFile::open(const Common::String &name, FileMode mode) { _fileMode = 1; } } + +void CompressedFile::open(Common::SeekableReadStream *stream, FileMode mode) { + SimpleFile::open(stream, mode); + + if (mode == FILE_READ) { + _decompressor.load(); + _fileMode = 2; + } else if (mode == FILE_WRITE) { + _decompressor.load(); + _fileMode = 1; + } +} + void CompressedFile::close() { _queue.clear(); SimpleFile::close(); diff --git a/engines/titanic/files.h b/engines/titanic/files.h index 1689f392d2..0f72f60270 100644 --- a/engines/titanic/files.h +++ b/engines/titanic/files.h @@ -38,6 +38,7 @@ class DecompressorData; class SimpleFile { protected: Common::File _file; + Common::SeekableReadStream *_stream; public: SimpleFile(); virtual ~SimpleFile(); @@ -48,6 +49,11 @@ public: virtual void open(const Common::String &name, FileMode mode = FILE_READ); /** + * Set up a stream for access + */ + virtual void open(Common::SeekableReadStream *stream, FileMode mode = FILE_READ); + + /** * Close the file */ virtual void close(); @@ -144,6 +150,11 @@ public: virtual void open(const Common::String &name, FileMode mode = FILE_READ); /** + * Set up a stream for access + */ + virtual void open(Common::SeekableReadStream *stream, FileMode mode = FILE_READ); + + /** * Close the file */ virtual void close(); diff --git a/engines/titanic/list.h b/engines/titanic/list.h index 0d3c62e3d2..bea3776f0f 100644 --- a/engines/titanic/list.h +++ b/engines/titanic/list.h @@ -25,7 +25,7 @@ #include "common/scummsys.h" #include "common/list.h" -#include "titanic/saveable_object.h" +#include "titanic/objects/saveable_object.h" namespace Titanic { diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index d65459d2d1..6cb4fc14ec 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -7,11 +7,15 @@ MODULE_OBJS := \ font.o \ image.o \ main_game_window.o \ - saveable_object.o \ screen_manager.o \ string.o \ titanic.o \ - video_surface.o + video_surface.o \ + objects/file_item.o \ + objects/message_target.o \ + objects/project_item.o \ + objects/saveable_object.o \ + objects/tree_item.o # This module can be built as a plugin ifeq ($(ENABLE_TITANIC), DYNAMIC_PLUGIN) diff --git a/engines/titanic/objects/file_item.cpp b/engines/titanic/objects/file_item.cpp new file mode 100644 index 0000000000..d49df71fcc --- /dev/null +++ b/engines/titanic/objects/file_item.cpp @@ -0,0 +1,28 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/objects/file_item.h" + +namespace Titanic { + + +} // End of namespace Titanic diff --git a/engines/titanic/objects/file_item.h b/engines/titanic/objects/file_item.h new file mode 100644 index 0000000000..133421ae1c --- /dev/null +++ b/engines/titanic/objects/file_item.h @@ -0,0 +1,36 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FILE_ITEM_H +#define TITANIC_FILE_ITEM_H + +#include "titanic/objects/tree_item.h" + +namespace Titanic { + +class CFileItem: public CTreeItem { +public: +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FILE_ITEM_H */ diff --git a/engines/titanic/objects/message_target.cpp b/engines/titanic/objects/message_target.cpp new file mode 100644 index 0000000000..1e727a3686 --- /dev/null +++ b/engines/titanic/objects/message_target.cpp @@ -0,0 +1,27 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/objects/message_target.h" + +namespace Titanic { + +} // End of namespace Titanic diff --git a/engines/titanic/objects/message_target.h b/engines/titanic/objects/message_target.h new file mode 100644 index 0000000000..6afd709211 --- /dev/null +++ b/engines/titanic/objects/message_target.h @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MESSAGE_TARGET_H +#define TITANIC_MESSAGE_TARGET_H + +#include "titanic/objects/saveable_object.h" + +namespace Titanic { + +class CMessageTarget: public CSaveableObject { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MESSAGE_TARGET_H */ diff --git a/engines/titanic/objects/project_item.cpp b/engines/titanic/objects/project_item.cpp new file mode 100644 index 0000000000..80596ec15c --- /dev/null +++ b/engines/titanic/objects/project_item.cpp @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/savefile.h" +#include "titanic/titanic.h" +#include "titanic/files.h" +#include "titanic/objects/project_item.h" + +namespace Titanic { + +void CProjectItem::load(int id) { + CompressedFile file; + Common::InSaveFile *saveFile = nullptr; + + // Clear any existing project contents + clear(); + + // Open either an existing savegame slot or the new game template + if (id > 0) { + saveFile = g_system->getSavefileManager()->openForLoading( + Common::String::format("slot%d.gam", id)); + file.open(saveFile); + } else { + file.open("newgame.st"); + } + + // Load the contents in + loadData(file); + + file.close(); +} + +void CProjectItem::clear() { + +} + +void CProjectItem::loadData(SimpleFile &file) { + +} + +} // End of namespace Titanic diff --git a/engines/titanic/objects/project_item.h b/engines/titanic/objects/project_item.h new file mode 100644 index 0000000000..2856f42110 --- /dev/null +++ b/engines/titanic/objects/project_item.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PROJECT_ITEM_H +#define TITANIC_PROJECT_ITEM_H + +#include "common/scummsys.h" +#include "titanic/files.h" +#include "titanic/objects/file_item.h" + +namespace Titanic { + +class CProjectItem : public CFileItem { +private: + /** + * Load project data from the passed file + */ + void loadData(SimpleFile &file); +public: + /** + * Load the entire project data for a given Id + */ + void load(int id); + + /** + * Clear any currently loaded project + */ + void clear(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PROJECT_ITEM_H */ diff --git a/engines/titanic/saveable_object.cpp b/engines/titanic/objects/saveable_object.cpp index 8d0e75bef8..b2384a56f2 100644 --- a/engines/titanic/saveable_object.cpp +++ b/engines/titanic/objects/saveable_object.cpp @@ -20,7 +20,11 @@ * */ -#include "titanic/saveable_object.h" +#include "titanic/objects/saveable_object.h" +#include "titanic/objects/file_item.h" +#include "titanic/objects/message_target.h" +#include "titanic/objects/project_item.h" +#include "titanic/objects/tree_item.h" #include "titanic/list.h" namespace Titanic { @@ -33,11 +37,19 @@ Common::HashMap<Common::String, CSaveableObject::CreateFunction> * DEFFN(List); DEFFN(ListItem); +DEFFN(CMessageTarget); +DEFFN(CTreeItem); +DEFFN(CFileItem); +DEFFN(CProjectItem); void CSaveableObject::initClassList() { _classList = new Common::HashMap<Common::String, CreateFunction>(); ADDFN(List); ADDFN(ListItem); + ADDFN(CMessageTarget); + ADDFN(CTreeItem); + ADDFN(CFileItem); + ADDFN(CProjectItem); } void CSaveableObject::freeClassList() { diff --git a/engines/titanic/saveable_object.h b/engines/titanic/objects/saveable_object.h index 5253892f51..5253892f51 100644 --- a/engines/titanic/saveable_object.h +++ b/engines/titanic/objects/saveable_object.h diff --git a/engines/titanic/objects/tree_item.cpp b/engines/titanic/objects/tree_item.cpp new file mode 100644 index 0000000000..06128ce354 --- /dev/null +++ b/engines/titanic/objects/tree_item.cpp @@ -0,0 +1,27 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/objects/tree_item.h" + +namespace Titanic { + +} // End of namespace Titanic diff --git a/engines/titanic/objects/tree_item.h b/engines/titanic/objects/tree_item.h new file mode 100644 index 0000000000..170a0e905d --- /dev/null +++ b/engines/titanic/objects/tree_item.h @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TREE_ITEM_H +#define TITANIC_TREE_ITEM_H + +#include "titanic/objects/message_target.h" + +namespace Titanic { + +class CTreeItem: public CMessageTarget { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TREE_ITEM_H */ diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp index d64577c814..57f3c7df0c 100644 --- a/engines/titanic/titanic.cpp +++ b/engines/titanic/titanic.cpp @@ -28,7 +28,7 @@ #include "graphics/scaler.h" #include "graphics/thumbnail.h" #include "titanic/titanic.h" -#include "titanic/saveable_object.h" +#include "titanic/objects/saveable_object.h" namespace Titanic { |