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