10017
|
1 |
/*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
18 |
*/
|
|
19 |
|
|
20 |
/**
|
|
21 |
* Functions for managing a list of schemes.
|
|
22 |
* This is in here because the scheme config file of the QtFrontend (which we are staying compatible with) contains
|
|
23 |
* all the schemes at once, so we need functions to work with a list like that.
|
|
24 |
*/
|
|
25 |
|
|
26 |
#ifndef SCHEMELIST_H_
|
|
27 |
#define SCHEMELIST_H_
|
|
28 |
|
|
29 |
#include "scheme.h"
|
|
30 |
|
|
31 |
typedef struct {
|
|
32 |
int schemeCount;
|
|
33 |
flib_scheme **schemes;
|
|
34 |
} flib_schemelist;
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Load a list of configurations from the ini file.
|
|
38 |
* Returns NULL on error.
|
|
39 |
*/
|
|
40 |
flib_schemelist *flib_schemelist_from_ini(const char *filename);
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Store the list of configurations to an ini file.
|
|
44 |
* Returns NULL on error.
|
|
45 |
*/
|
|
46 |
int flib_schemelist_to_ini(const char *filename, const flib_schemelist *config);
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Create an empty scheme list. Returns NULL on error.
|
|
50 |
*/
|
|
51 |
flib_schemelist *flib_schemelist_create();
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Insert a new scheme into the list at position pos, moving all higher schemes to make place.
|
|
55 |
* pos must be at least 0 (insert at the start) and at most list->schemeCount (insert at the end).
|
|
56 |
* Ownership of the scheme is transferred to the list.
|
|
57 |
* Returns 0 on success.
|
|
58 |
*/
|
|
59 |
int flib_schemelist_insert(flib_schemelist *list, flib_scheme *cfg, int pos);
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Delete a scheme from the list at position pos, moving down all higher schemes.
|
|
63 |
* The scheme is destroyed.
|
|
64 |
* Returns 0 on success.
|
|
65 |
*/
|
|
66 |
int flib_schemelist_delete(flib_schemelist *list, int pos);
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Find the scheme with a specific name
|
|
70 |
*/
|
|
71 |
flib_scheme *flib_schemelist_find(flib_schemelist *list, const char *name);
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Free this schemelist and all contained schemes
|
|
75 |
*/
|
|
76 |
void flib_schemelist_destroy(flib_schemelist *list);
|
|
77 |
|
|
78 |
|
|
79 |
#endif /* SCHEMELIST_H_ */
|