1 | /*************************************************************************** |
2 | * KBlocks, a falling blocks game for KDE * |
3 | * Copyright (C) 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) any later version. * |
9 | ***************************************************************************/ |
10 | #ifndef KBLOCKSGAMERECORDER_H |
11 | #define KBLOCKSGAMERECORDER_H |
12 | |
13 | #include "KBlocksDefine.h" |
14 | |
15 | #include <stdio.h> |
16 | #include <string> |
17 | #include <list> |
18 | |
19 | using std::string; |
20 | using std::list; |
21 | |
22 | struct _game_record_data |
23 | { |
24 | int index; |
25 | int type; |
26 | int value; |
27 | timeLong time; |
28 | }; |
29 | |
30 | class KBlocksGameRecorder |
31 | { |
32 | public: |
33 | KBlocksGameRecorder(); |
34 | ~KBlocksGameRecorder(); |
35 | |
36 | public: |
37 | void append(int index, int type, int value); |
38 | void save(const char * fileName, bool isBinaryMode = true); |
39 | |
40 | private: |
41 | void saveText(FILE * pFile); |
42 | void saveBinary(FILE * pFile); |
43 | void writeByte(FILE * pFile, int value); |
44 | |
45 | timeLong getMillisecOfNow(); |
46 | |
47 | private: |
48 | list<_game_record_data> mGameRecord; |
49 | }; |
50 | |
51 | #endif |
52 | |