summaryrefslogtreecommitdiff
path: root/common/library.h
diff options
context:
space:
mode:
authorleo2005-07-14 05:10:57 +0000
committerleo2005-07-14 05:10:57 +0000
commite3b7ec77734b8f415f9c756f0d7bf90ff202e71e (patch)
tree741fd8c82177a499308de47bd94453d9bdc5e229 /common/library.h
parent7c16eadee05cfe3115ac0a69a822c66f1b3e292f (diff)
Changed the pieces list to a tree sorted by categories.
git-svn-id: http://svn.leocad.org/trunk@414 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/library.h')
-rwxr-xr-xcommon/library.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/common/library.h b/common/library.h
index 54fd137..3ecdde9 100755
--- a/common/library.h
+++ b/common/library.h
@@ -3,6 +3,7 @@
#include "defines.h"
#include "str.h"
+#include "array.h"
class File;
class Texture;
@@ -10,6 +11,12 @@ class PieceInfo;
#define LC_PIECESLIB_MAXGROUPS 32
+typedef struct
+{
+ String Name;
+ String Keywords;
+} PiecesLibraryCategory;
+
class PiecesLibrary
{
public:
@@ -29,19 +36,40 @@ public:
bool NeedsReload () const
{ return m_bNeedsReload; }
+ // Categories.
+ void GetCategoryEntries(int CategoryIndex, PtrArray<PieceInfo>& SinglePieces, PtrArray<PieceInfo>& GroupedPieces);
+ void GetPatternedPieces(PieceInfo* Parent, PtrArray<PieceInfo>& Pieces);
+ void SetCategory(int Index, const String& Name, const String& Keywords);
+ void AddCategory(const String& Name, const String& Keywords);
+
+ const char* GetCategoryName(int Index) const
+ { return m_Categories[Index].Name; }
+
+ int GetNumCategories() const
+ { return m_Categories.GetSize(); }
+
+ int FindCategoryIndex(const String& CategoryName) const
+ {
+ for (int i = 0; i < m_Categories.GetSize(); i++)
+ if (m_Categories[i].Name == CategoryName)
+ return i;
+
+ return -1;
+ }
+
void CheckReload ();
bool Load (const char* libpath);
void Unload ();
bool LoadGroupConfig (const char* Filename);
- // Search for stuff
+ // Search for pieces.
PieceInfo* FindPieceInfo (const char* name) const;
PieceInfo* GetPieceInfo (int index) const;
int GetPieceIndex (PieceInfo *pInfo) const;
Texture* FindTexture (const char* name) const;
Texture* GetTexture (int index) const;
- // File operations
+ // File operations.
bool DeletePieces (char** names, int numpieces);
bool LoadUpdate (const char* update);
bool DeleteTextures (char** Names, int NumTextures);
@@ -60,6 +88,9 @@ protected:
int m_nTextureCount; // number of textures
Texture* m_pTextures; // textures array
+ // Categories.
+ ObjArray<PiecesLibraryCategory> m_Categories;
+
// Groups stuff
int m_nGroupCount;
String m_strGroups[LC_PIECESLIB_MAXGROUPS];