kgoldrunner
kgrgameio.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _KGRGAMEIO_H_
00022 #define _KGRGAMEIO_H_
00023
00024 #include <QByteArray>
00025 #include <QFile>
00026
00027 #include "kgrconsts.h"
00028
00030 enum IOStatus {OK, NotFound, NoRead, NoWrite, UnexpectedEOF};
00031
00033 typedef struct {
00034 QString filePath;
00035 Owner owner;
00036 int nLevels;
00037 char rules;
00038 QString prefix;
00039 char skill;
00040 QByteArray name;
00041 QByteArray about;
00042 } GameData;
00043
00045 typedef struct {
00046 QString filePath;
00047 int level;
00048 QByteArray layout;
00049 QByteArray name;
00050 QByteArray hint;
00051 } LevelData;
00052
00080 class KGrGameIO : public QObject
00081 {
00082 Q_OBJECT
00083 public:
00087 KGrGameIO();
00088
00092 IOStatus fetchGameListData (const QString & dir,
00093 QList<GameData *> & gameList);
00097 IOStatus fetchLevelData (const QString & dir, const QString & prefix,
00098 const int level, LevelData & d);
00099
00100 private:
00101 QFile openFile;
00102
00103 QString getFilePath (const QString & dir,
00104 const QString & prefix, const int level);
00105 char getALine (const bool kgr3, QByteArray & line);
00106 QByteArray removeNewline (const QByteArray & line);
00107 GameData * initGameData (const QString & filePath);
00108 };
00109
00110 #endif // _KGRGAMEIO_H_