-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblocklist.cpp
More file actions
48 lines (45 loc) · 1.11 KB
/
Copy pathblocklist.cpp
File metadata and controls
48 lines (45 loc) · 1.11 KB
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
#include "blocklist.h"
#include <QDir>
#include "settings.h"
#include "items/luablock.h"
QList<Block*> BlockList::blocks;
BlockList::BlockList(QObject *parent) : QObject(parent)
{
if(blocks.isEmpty())
{
QDir dir=QDir::current();
dir.cd("modules");
QStringList files=dir.entryList();
for(int i=0;i<files.length();i++)
if(files[i].endsWith(".lua"))
{
QString fn=dir.absoluteFilePath(files[i]);
LuaBlock* b=new LuaBlock(fn);
b->load(fn);
if(b->valid)
blocks.append(b);
}
}
bool done=false;
do
{
done=false;
for(int i=1;i<blocks.length();i++)
{
if(blocks[i-1]->name>blocks[i]->name)
{
blocks.swap(i-1,i);
done=true;
}
}
}
while(done);
}
Block *BlockList::newBlock(QString name)
{
for(int i=0;i<blocks.length();i++)
if(blocks[i]->name==name)
return blocks[i]->clone();
qDebug()<<"BLOCK"<<name<<"Not Found";
return NULL;
}