summaryrefslogtreecommitdiff
path: root/common/libman.h
blob: ac48c1b1971a4a995592492695bf80beff964410 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
#ifndef _LIBMAN_H_
#define _LIBMAN_H_

#include "defines.h"
#include "config.h"
#include "str.h"
#include "library.h"

class PieceInfo;

typedef enum
{
	LC_LIBDLG_FILE_RESET,
	LC_LIBDLG_FILE_OPEN,
	LC_LIBDLG_FILE_SAVE,
	LC_LIBDLG_FILE_SAVEAS,
	LC_LIBDLG_FILE_MERGEUPDATE,
	LC_LIBDLG_FILE_IMPORTPIECE,
	LC_LIBDLG_FILE_RETURN,
	LC_LIBDLG_FILE_CANCEL,
	LC_LIBDLG_GROUP_INSERT,
	LC_LIBDLG_GROUP_DELETE,
	LC_LIBDLG_GROUP_EDIT,
	LC_LIBDLG_GROUP_MOVEUP,
	LC_LIBDLG_GROUP_MOVEDOWN
} LC_LIBDLG_COMMANDS;

class LibraryManager
{
public:
	LibraryManager ();
	virtual ~LibraryManager ();

	void HandleCommand (int id, int param);
	bool Initialize ();
	bool DoSave (bool bAskName);
	bool SaveModified ();

	// Commands
	bool DeletePieces (char** Names, int Count);

	// Access
	int GetGroupCount () const
		{ return m_nGroups; }
	String& GetGroupName (int index)
		{ return m_strGroups[index]; }

	int GetPieceCount () const
		{ return m_nPieces; }
	void GetPieceInfo (int index, PieceInfo** Info, lcuint32* Group)
		{ *Info = m_pPieces[index].Info; *Group = m_pPieces[index].CurrentGroups; }
	void SetPieceGroup (int Index, int Group, bool Add)
		{
			if (Add)
				m_pPieces[Index].CurrentGroups = Group;
			else
				m_pPieces[Index].CurrentGroups |= Group;

			m_bModified = true;
		}

protected:
	void LoadDefaults ();

	typedef struct
	{
		PieceInfo* Info;
		lcuint32 CurrentGroups;
	} LC_LIBDLG_PIECEINFO;

	int m_nPieces;
	LC_LIBDLG_PIECEINFO* m_pPieces;

	int m_nGroups;
	String m_strGroups[LC_PIECESLIB_MAXGROUPS];

	bool m_bModified;
	char m_strFile[LC_MAXPATH];
};

#endif // _LIBMAN_H_