ScummVM API documentation
Notebook.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of Penumbra Overture.
26  */
27 
28 #ifndef GAME_NOTE_BOOK_H
29 #define GAME_NOTE_BOOK_H
30 
31 #include "hpl1/engine/engine.h"
32 
33 #include "hpl1/penumbra-overture/GameTypes.h"
34 
35 using namespace hpl;
36 
37 class cInit;
39 
40 //---------------------------
41 
42 #define eNotebookState_Front 0
43 #define eNotebookState_TaskList 1
44 #define eNotebookState_NoteList 2
45 #define eNotebookState_Note 3
46 
47 //---------------------------
48 
49 enum eNotebookType {
50  eNotebookType_Front,
51  eNotebookType_Open,
52 };
53 
54 //---------------------------
55 
57 public:
58  cNotebook_Note() : mbRead(false), mfAlpha(0) {}
59 
60  tWString msName;
61  tWString msText;
62  bool mbRead;
63  float mfAlpha;
64  cRect2f mRect;
65 
66  tString msTextCat;
67  tString msTextEntry;
68 };
69 
72 
74 
75 //--------------------------------------------------------
76 
77 class cNotebook;
78 
79 class iNotebookState : public iAIState {
80 public:
81  iNotebookState(cInit *apInit, cNotebook *apNotebook) : iAIState() {
82  mpInit = apInit;
83  mpNotebook = apNotebook;
84  }
85 
86  virtual void OnMouseDown(eMButton aButton) {}
87 
88  virtual void OnDraw() {}
89 
90  virtual void OnExit() {}
91 
92 protected:
93  cInit *mpInit;
94  cNotebook *mpNotebook;
95 };
96 
97 //---------------------------------------------------
98 
100 public:
101  cNoteBook_Option() : mfAlpha(0) {}
102 
103  tWString msText;
104  cVector3f mvPos;
105  cRect2f mRect;
106  float mfAlpha;
107 };
108 
110 public:
111  cNotebookState_Front(cInit *apInit, cNotebook *apNotebook);
112 
113  void OnEnterState(int alLastState);
114  void OnLeaveState(int alNextState);
115 
116  void OnUpdate(float afTime);
117 
118  void OnDraw();
119 
120  void OnMouseDown(eMButton aButton);
121 
122  void OnExit();
123 
124  cGraphicsDrawer *mpDrawer;
125  cGfxObject *mpTextBack;
126 
127  FontData *mpFrontFont;
129  int mlSelected;
130  cVector2f mvFontSize;
131 };
132 
133 //-----------------------------------------------------
134 
136 public:
137  int mlStartTask;
138  int mlEndTask;
139 };
140 
141 //-----------------------------------------------------
142 
144 public:
145  cNotebookState_TaskList(cInit *apInit, cNotebook *apNotebook);
146 
147  void OnEnterState(int alLastState);
148  void OnLeaveState(int alNextState);
149 
150  void OnUpdate(float afTime);
151 
152  void OnDraw();
153 
154  void OnMouseDown(eMButton aButton);
155 
156  void OnExit();
157 
158  FontData *mpTextFont;
159 
160  float mfFontSize;
161 
162  int mlCurrentPage;
164 
165  int mlSelected;
167  cGraphicsDrawer *mpDrawer;
168  cGfxObject *mpOptionsImage[2];
169 };
170 
171 //--------------------------------------------------------
172 
174 public:
175  cNotebookState_NoteList(cInit *apInit, cNotebook *apNotebook);
176 
177  void OnEnterState(int alLastState);
178  void OnLeaveState(int alNextState);
179 
180  void OnUpdate(float afTime);
181  void OnDraw();
182  void OnMouseDown(eMButton aButton);
183  void OnExit();
184 
185  cGraphicsDrawer *mpDrawer;
186  cGfxObject *mpTextBack;
187  cGfxObject *mpTab;
188 
189  int mlMaxNotesPerPage;
190  int mlFirstNote;
191 
192  int mlSelected;
193 
194  FontData *mpTextFont;
195  tWString msUnread;
196  cVector2f mvSize;
197  cNotebook_Note *mpSelectedNote;
198 
200  cGfxObject *mpOptionsImage[2];
201 };
202 
203 //--------------------------------------------------------
204 
205 class cNotePage {
206 public:
207  int mlStart;
208  int mlEnd;
209 };
210 
212 public:
213  cNotebookState_Note(cInit *apInit, cNotebook *apNotebook);
214 
215  void OnEnterState(int alLastState);
216  void OnLeaveState(int alNextState);
217 
218  void OnUpdate(float afTime);
219  void OnDraw();
220  void OnMouseDown(eMButton aButton);
221  void OnExit();
222 
223  FontData *mpTextFont;
224  FontData *mpNavigateFont;
225  tWStringVec mvRows;
226 
227  Common::Array<cNotePage> mvPages;
228 
229  int mlCurrentPage;
230  int mlMaxRows;
231  cVector2f mvSize;
232 
233  int mlSelected;
235  cGraphicsDrawer *mpDrawer;
236  cGfxObject *mpOptionsImage[2];
237 };
238 
239 //--------------------------------------------------------
240 
242 public:
243  cGfxObject *mpGfxImage;
244  float mfAlpha;
245  eNotebookType mType;
246 };
247 
248 //--------------------------------------------------------
249 
251 public:
252  tString msName;
253  tWString msText;
254 };
255 
258 
260 
261 //--------------------------------------------------------
262 
263 class cNotebook : public iUpdateable {
264 public:
265  cNotebook(cInit *apInit);
266  ~cNotebook();
267 
268  void OnStart();
269  void Update(float afTimeStep);
270  void OnDraw();
271  void Reset();
272 
273  void SetMousePos(const cVector2f &avPos);
274  void AddMousePos(const cVector2f &avRel);
275  cVector2f GetMousePos() { return mvMousePos; }
276 
277  void OnMouseDown(eMButton aButton);
278  void OnMouseUp(eMButton aButton);
279 
280  void OnExit();
281 
282  void SetActive(bool abX);
283  bool IsActive() { return mbActive; }
284 
285  float GetAlpha() { return mfAlpha; }
286 
287  void SetBookType(eNotebookType aType);
288  eNotebookType GetBookType() { return mBookType; }
289 
290  tNotebook_NoteList_Iterator GetNoteIterator();
291  cNotebook_Note *AddNote(const tWString &asName, const tString &asTextCat, const tString &asTextEntry);
292  void RemoveNote(const tString &asName);
293  int GetNoteNum() { return (int)mlstNotes.size(); }
294 
295  tNotebook_BookTaskList_Iterator GetTaskIterator();
296  void AddTask(const tString &asName, const tWString &asText);
297  void RemoveTask(const tString &asName);
298  int GetTaskNum() { return (int)mlstTasks.size(); }
299 
300  cNotebook_Note *GetSelectedNote() { return mpSelectedNote; }
301  void SetSelectedNote(cNotebook_Note *apNote) { mpSelectedNote = apNote; }
302 
303  cStateMachine *GetStateMachine() { return &mStateMachine; }
304 
306  // Saving
307  void SaveToGlobal(cNotebook_GlobalSave *apSave);
308  void LoadFromGlobal(cNotebook_GlobalSave *apSave);
309 
310 private:
311  cInit *mpInit;
312  cGraphicsDrawer *mpDrawer;
313 
314  cGfxObject *mpGfxBackground;
315 
316  cStateMachine mStateMachine;
317 
318  bool mbActive;
319  float mfAlpha;
320 
322 
323  eNotebookType mBookType;
324 
325  eCrossHairState mLastCrossHairState;
326 
327  bool mbInventoryWasActive;
328 
329  tNotebook_BookTaskList mlstTasks;
330  tNotebook_NoteList mlstNotes;
331 
332  cNotebook_Note *mpSelectedNote;
333 
334  cVector2f mvMousePos;
335 };
336 
337 #endif // GAME_NOTE_BOOK_H
Definition: Notebook.h:241
Definition: AI.h:36
Definition: Notebook.h:56
Definition: str.h:59
Definition: Notebook.h:135
Definition: Notebook.h:109
Definition: font_data.h:67
Definition: StateMachine.h:77
Definition: Notebook.h:79
Definition: Notebook.h:211
Definition: GraphicsDrawer.h:77
Definition: Notebook.h:205
Definition: SystemTypes.h:411
Definition: ustr.h:57
Definition: GfxObject.h:38
Definition: Updateable.h:35
Definition: SaveHandler.h:80
Definition: Notebook.h:250
Definition: list_intern.h:51
Definition: Notebook.h:99
Definition: StateMachine.h:41
Definition: Init.h:70
Definition: Notebook.h:173
Definition: Notebook.h:263
Definition: Notebook.h:143