From 1e4de9a3232127f72c7d832548343699aa1088cc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 18 Feb 2016 19:29:13 -0500 Subject: TITANIC: Starting to create classes for project item hierarchy --- engines/titanic/objects/file_item.cpp | 28 +++++++++++ engines/titanic/objects/file_item.h | 36 ++++++++++++++ engines/titanic/objects/message_target.cpp | 27 +++++++++++ engines/titanic/objects/message_target.h | 35 ++++++++++++++ engines/titanic/objects/project_item.cpp | 60 +++++++++++++++++++++++ engines/titanic/objects/project_item.h | 52 ++++++++++++++++++++ engines/titanic/objects/saveable_object.cpp | 75 +++++++++++++++++++++++++++++ engines/titanic/objects/saveable_object.h | 59 +++++++++++++++++++++++ engines/titanic/objects/tree_item.cpp | 27 +++++++++++ engines/titanic/objects/tree_item.h | 35 ++++++++++++++ 10 files changed, 434 insertions(+) create mode 100644 engines/titanic/objects/file_item.cpp create mode 100644 engines/titanic/objects/file_item.h create mode 100644 engines/titanic/objects/message_target.cpp create mode 100644 engines/titanic/objects/message_target.h create mode 100644 engines/titanic/objects/project_item.cpp create mode 100644 engines/titanic/objects/project_item.h create mode 100644 engines/titanic/objects/saveable_object.cpp create mode 100644 engines/titanic/objects/saveable_object.h create mode 100644 engines/titanic/objects/tree_item.cpp create mode 100644 engines/titanic/objects/tree_item.h (limited to 'engines/titanic/objects') 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/objects/saveable_object.cpp b/engines/titanic/objects/saveable_object.cpp new file mode 100644 index 0000000000..b2384a56f2 --- /dev/null +++ b/engines/titanic/objects/saveable_object.cpp @@ -0,0 +1,75 @@ +/* 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/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 { + +Common::HashMap * + CSaveableObject::_classList = nullptr; + +#define DEFFN(T) CSaveableObject *Function##T() { return new T(); } +#define ADDFN(T) (*_classList)["TEST"] = Function##T + +DEFFN(List); +DEFFN(ListItem); +DEFFN(CMessageTarget); +DEFFN(CTreeItem); +DEFFN(CFileItem); +DEFFN(CProjectItem); + +void CSaveableObject::initClassList() { + _classList = new Common::HashMap(); + ADDFN(List); + ADDFN(ListItem); + ADDFN(CMessageTarget); + ADDFN(CTreeItem); + ADDFN(CFileItem); + ADDFN(CProjectItem); +} + +void CSaveableObject::freeClassList() { + delete _classList; +} + +CSaveableObject *CSaveableObject::createInstance(const Common::String &name) { + return (*_classList)[name](); +} + +void CSaveableObject::proc4() { + +} + +void CSaveableObject::proc5() { + +} + +void CSaveableObject::proc6() { + +} + +} // End of namespace Titanic diff --git a/engines/titanic/objects/saveable_object.h b/engines/titanic/objects/saveable_object.h new file mode 100644 index 0000000000..5253892f51 --- /dev/null +++ b/engines/titanic/objects/saveable_object.h @@ -0,0 +1,59 @@ +/* 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_SAVEABLE_OBJECT_H +#define TITANIC_SAVEABLE_OBJECT_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/hash-str.h" + +namespace Titanic { + +class CSaveableObject { + typedef CSaveableObject *(*CreateFunction)(); +private: + static Common::HashMap *_classList; +public: + /** + * Sets up the list of saveable object classes + */ + static void initClassList(); + + /** + * Free the list of saveable object classes + */ + static void freeClassList(); + + /** + * Creates a new instance of a saveable object class + */ + static CSaveableObject *createInstance(const Common::String &name); +public: + virtual void proc4(); + virtual void proc5(); + virtual void proc6(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_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 */ -- cgit v1.2.3