1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef SHERLOCK_JOURNAL_H
24 #define SHERLOCK_JOURNAL_H
25 
26 #include "common/scummsys.h"
27 #include "common/array.h"
28 #include "common/rect.h"
29 #include "common/str-array.h"
30 #include "common/stream.h"
31 #include "sherlock/saveload.h"
32 
33 namespace Sherlock {
34 
35 #define LINES_PER_PAGE (IS_SERRATED_SCALPEL ? 11 : 17)
36 #define JOURNAL_MAX_WIDTH (IS_SERRATED_SCALPEL ? 230 : 422)
37 #define JOURNAL_MAX_CHARS 80
38 #define JOURNAL_LEFT_X (IS_SERRATED_SCALPEL ? 53 : 156)
39 
40 class SherlockEngine;
41 
42 struct JournalEntry {
43 	int _converseNum;
44 	bool _replyOnly;
45 	int _statementNum;
46 
JournalEntryJournalEntry47 	JournalEntry() : _converseNum(0), _replyOnly(false), _statementNum(0) {}
48 	JournalEntry(int converseNum, int statementNum, bool replyOnly = false) :
_converseNumJournalEntry49 		_converseNum(converseNum), _statementNum(statementNum), _replyOnly(replyOnly) {}
50 };
51 
52 class Journal {
53 protected:
54 	SherlockEngine *_vm;
55 	Common::StringArray _directory;
56 	Common::StringArray _locations;
57 	Common::Array<JournalEntry> _journal;
58 	Common::StringArray _lines;
59 	bool _up, _down;
60 	int _index;
61 	int _page;
62 	int _maxPage;
63 	int _sub;
64 	Common::String _find;
65 
66 	Journal(SherlockEngine *vm);
67 
68 	/**
69 	 * Loads the description for the current display index in the journal, and then
70 	 * word wraps the result to prepare it for being displayed
71 	 * @param alreadyLoaded		Indicates whether the journal file is being loaded for the
72 	 *		first time, or being reloaded
73 	 */
74 	void loadJournalFile(bool alreadyLoaded);
75 
76 	/**
77 	 * Returns true if a given character is printable
78 	 */
79 	bool isPrintable(byte ch) const;
80 public:
81 	static Journal *init(SherlockEngine *vm);
~Journal()82 	virtual ~Journal() {}
83 
84 	/**
85 	* Displays a page of the journal at the current index
86 	*/
87 	bool drawJournal(int direction, int howFar);
88 
89 	/**
90 	 * Synchronize the data for a savegame
91 	 */
92 	void synchronize(Serializer &s);
93 public:
94 	/**
95 	 * Draw the journal background, frame, and interface buttons
96 	 */
97 	virtual void drawFrame() = 0;
98 
99 	/**
100 	 * Reset viewing position to the start of the journal
101 	 */
resetPosition()102 	virtual void resetPosition() {}
103 
104 	/**
105 	 * Records statements that are said, in the order which they are said. The player
106 	 * can then read the journal to review them
107 	 */
108 	virtual void record(int converseNum, int statementNum, bool replyOnly = false);
109 };
110 
111 } // End of namespace Sherlock
112 
113 #endif
114