add loader
add schema new loader model using xml separated work and load data validation using schema map data in xml new core model... proecting
This commit is contained in:
28
map.cpp
28
map.cpp
@@ -4,7 +4,12 @@ Map::Map(int Id, QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
mapId=Id;
|
||||
ReadSettings();
|
||||
}
|
||||
|
||||
|
||||
void Map::load()
|
||||
{
|
||||
//ReadSettings();
|
||||
//CreateMapExample();
|
||||
for (int i=0; i<Cells.size(); i++)
|
||||
{
|
||||
@@ -14,7 +19,7 @@ Map::Map(int Id, QObject *parent) :
|
||||
if (Cells[i][j]==Finish) finishs.push_back(QPoint(i,j));
|
||||
}
|
||||
}
|
||||
if (starts.isEmpty() || finishs.isEmpty()) qDebug("invalid map, not found start/finish"),exit(-1);
|
||||
if (starts.isEmpty() || finishs.isEmpty()) qFatal("invalid map, not found start/finish");
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +37,8 @@ void Map::ReadSettings()
|
||||
{
|
||||
mapsize.setWidth(Cells.size());
|
||||
mapsize.setHeight(Cells[0].size());
|
||||
qDebug() << "Map size" << mapsize;
|
||||
printMap();
|
||||
//qDebug() << "Map size" << mapsize;
|
||||
//printMap();
|
||||
} else qDebug("invalid size");
|
||||
delete f;
|
||||
delete sreader;
|
||||
@@ -128,10 +133,19 @@ void Map::CreateMapExample()
|
||||
Cells[Cells.size()/2-1][0]=Start;
|
||||
Cells[Cells.size()/2][Cells[Cells.size()/2].size()-1]=Finish;
|
||||
Cells[Cells.size()/2-1][Cells[Cells.size()/2].size()-1]=Finish;
|
||||
QFile * f = new QFile("example16x16.map");
|
||||
QFile * f = new QFile("example16x16_64.map");
|
||||
f->open(QIODevice::ReadWrite);
|
||||
QDataStream s(f);
|
||||
s << Cells;
|
||||
f->resize(0);
|
||||
QByteArray ba;
|
||||
QDataStream tmps(&ba,QIODevice::ReadWrite);
|
||||
tmps << Cells;
|
||||
ba = qCompress(ba);
|
||||
ba = ba.toBase64();
|
||||
QString str(ba);
|
||||
// QDataStream s(f);
|
||||
// s << ba;
|
||||
f->write(str.toUtf8());
|
||||
f->close();
|
||||
delete f;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user