-
Notifications
You must be signed in to change notification settings - Fork 0
/
Levels.h
70 lines (60 loc) · 1.89 KB
/
Levels.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
/*
* This file is part of NumptyPhysics
* Copyright (C) 2008 Tim Edmonds
*
* This program 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.
*
* This program 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.
*
*/
#ifndef LEVELS_H
#define LEVELS_H
#include <cstdio>
#include <sstream>
#include "Array.h"
class Levels
{
public:
Levels( int numDirs=0, const char** dirs=NULL );
bool addPath( const char* path );
bool addLevel( const std::string& file, int rank=-1, int index=-1 );
int numLevels();
int load( int i, unsigned char* buf, int bufLen );
std::string levelName( int i, bool pretty=true );
int findLevel( const char *file );
int numCollections();
int collectionFromLevel( int l, int *indexInCol=NULL );
std::string collectionName( int i, bool pretty=true );
int collectionSize(int c);
int collectionLevel(int c, int i);
private:
struct LevelDesc
{
LevelDesc( const std::string& f,int r=0, int i=-1)
: file(f), index(i), rank(r) {}
std::string file;
int index;
int rank;
};
struct Collection
{
std::string file;
std::string name;
int rank;
Array<LevelDesc*> levels;
};
bool addLevel( Collection* collection,
const std::string& file, int rank, int index );
LevelDesc* findLevel( int i );
Collection* getCollection( const std::string& file );
bool scanCollection( const std::string& file, int rank );
int m_numLevels;
Array<Collection*> m_collections;
};
#endif //LEVELS_H