project_files/frontlib/model/cfg.h
changeset 7175 038e3415100a
child 7224 5143861c83bd
equal deleted inserted replaced
7173:7c2eb284f9f1 7175:038e3415100a
       
     1 /**
       
     2  * Data structures for game scheme information.
       
     3  *
       
     4  * Important conventions:
       
     5  * - All data structures own what they point to.
       
     6  * - Strings are never null pointers.
       
     7  */
       
     8 
       
     9 #ifndef CFG_H_
       
    10 #define CFG_H_
       
    11 
       
    12 #include <stdbool.h>
       
    13 
       
    14 typedef struct {
       
    15     char *iniName;
       
    16     char *title;
       
    17     char *engineCommand;
       
    18     char *image;
       
    19     int netplayIndex;
       
    20     bool checkOverMax;
       
    21     bool times1000;
       
    22     int def;
       
    23     int min;
       
    24     int max;
       
    25 } flib_cfg_setting_meta;
       
    26 
       
    27 typedef struct {
       
    28     char *iniName;
       
    29     int bitmaskIndex;
       
    30 } flib_cfg_mod_meta;
       
    31 
       
    32 typedef struct {
       
    33     int settingCount;
       
    34     int modCount;
       
    35     flib_cfg_setting_meta *settings;
       
    36     flib_cfg_mod_meta *mods;
       
    37 } flib_cfg_meta;
       
    38 
       
    39 typedef struct {
       
    40     int settingCount;
       
    41     int modCount;
       
    42     char *schemeName;
       
    43     int *settings;
       
    44     bool *mods;
       
    45 } flib_cfg;
       
    46 
       
    47 flib_cfg_meta *flib_cfg_meta_from_ini(const char *settingpath, const char *modpath);
       
    48 void flib_cfg_meta_destroy(flib_cfg_meta *metainfo);
       
    49 
       
    50 flib_cfg *flib_cfg_create(const flib_cfg_meta *meta, const char *schemeName);
       
    51 flib_cfg *flib_cfg_from_ini(const flib_cfg_meta *meta, const char *filename);
       
    52 int flib_cfg_to_ini(const flib_cfg_meta *meta, const char *filename, const flib_cfg *config);
       
    53 void flib_cfg_destroy(flib_cfg* cfg);
       
    54 
       
    55 #endif /* CFG_H_ */