| 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 |
#pragma once |
| 30 |
|
| 31 |
#include <stdbool.h> |
| 32 |
#include <stdio.h> |
| 33 |
|
| 34 |
#include "c_array.h" |
| 35 |
|
| 36 |
#define CONFIG_FILE "options.cnf" |
| 37 |
|
| 38 |
typedef enum |
| 39 |
{ |
| 40 |
DIFFICULTY_VERYEASY = 1, |
| 41 |
DIFFICULTY_EASY, |
| 42 |
DIFFICULTY_NORMAL, |
| 43 |
DIFFICULTY_HARD, |
| 44 |
DIFFICULTY_VERYHARD |
| 45 |
} difficulty_e; |
| 46 |
|
| 47 |
const char *DifficultyStr(int d); |
| 48 |
int StrDifficulty(const char *str); |
| 49 |
|
| 50 |
typedef enum |
| 51 |
{ |
| 52 |
FIREMOVE_STOP = 0, |
| 53 |
FIREMOVE_NORMAL, |
| 54 |
FIREMOVE_STRAFE |
| 55 |
} FireMoveStyle; |
| 56 |
const char *FireMoveStyleStr(int s); |
| 57 |
int StrFireMoveStyle(const char *s); |
| 58 |
|
| 59 |
typedef enum |
| 60 |
{ |
| 61 |
SWITCHMOVE_SLIDE = 0, |
| 62 |
SWITCHMOVE_STRAFE, |
| 63 |
SWITCHMOVE_NONE |
| 64 |
} SwitchMoveStyle; |
| 65 |
const char *SwitchMoveStyleStr(int s); |
| 66 |
int StrSwitchMoveStyle(const char *s); |
| 67 |
|
| 68 |
typedef enum |
| 69 |
{ |
| 70 |
SCALE_MODE_NN, |
| 71 |
SCALE_MODE_BILINEAR |
| 72 |
} ScaleMode; |
| 73 |
const char *ScaleModeStr(int q); |
| 74 |
int StrScaleMode(const char *str); |
| 75 |
|
| 76 |
typedef enum |
| 77 |
{ |
| 78 |
GORE_NONE, |
| 79 |
GORE_LOW, |
| 80 |
GORE_MEDIUM, |
| 81 |
GORE_HIGH |
| 82 |
} GoreAmount; |
| 83 |
const char *GoreAmountStr(int g); |
| 84 |
int StrGoreAmount(const char *s); |
| 85 |
|
| 86 |
typedef enum |
| 87 |
{ |
| 88 |
LASER_SIGHT_NONE, |
| 89 |
LASER_SIGHT_PLAYERS, |
| 90 |
LASER_SIGHT_ALL |
| 91 |
} LaserSight; |
| 92 |
const char *LaserSightStr(int l); |
| 93 |
int StrLaserSight(const char *s); |
| 94 |
|
| 95 |
typedef enum |
| 96 |
{ |
| 97 |
SPLITSCREEN_NORMAL, |
| 98 |
SPLITSCREEN_ALWAYS, |
| 99 |
SPLITSCREEN_NEVER |
| 100 |
} SplitscreenStyle; |
| 101 |
|
| 102 |
const char *SplitscreenStyleStr(int s); |
| 103 |
int StrSplitscreenStyle(const char *str); |
| 104 |
|
| 105 |
typedef enum |
| 106 |
{ |
| 107 |
AICHATTER_NONE, |
| 108 |
AICHATTER_SELDOM, |
| 109 |
AICHATTER_OFTEN, |
| 110 |
AICHATTER_ALWAYS |
| 111 |
} AIChatterFrequency; |
| 112 |
const char *AIChatterStr(int c); |
| 113 |
int StrAIChatter(const char *str); |
| 114 |
|
| 115 |
typedef enum |
| 116 |
{ |
| 117 |
QUICKPLAY_QUANTITY_ANY, |
| 118 |
QUICKPLAY_QUANTITY_SMALL, |
| 119 |
QUICKPLAY_QUANTITY_MEDIUM, |
| 120 |
QUICKPLAY_QUANTITY_LARGE |
| 121 |
} QuickPlayQuantity; |
| 122 |
const char *QuickPlayQuantityStr(int s); |
| 123 |
int StrQuickPlayQuantity(const char *str); |
| 124 |
|
| 125 |
typedef enum |
| 126 |
{ |
| 127 |
CONFIG_TYPE_STRING, |
| 128 |
CONFIG_TYPE_INT, |
| 129 |
CONFIG_TYPE_FLOAT, |
| 130 |
CONFIG_TYPE_BOOL, |
| 131 |
CONFIG_TYPE_ENUM, |
| 132 |
CONFIG_TYPE_GROUP |
| 133 |
} ConfigType; |
| 134 |
|
| 135 |
|
| 136 |
typedef struct |
| 137 |
{ |
| 138 |
char *Name; |
| 139 |
ConfigType Type; |
| 140 |
union { |
| 141 |
#define VALUES(_name, _type) \ |
| 142 |
struct \ |
| 143 |
{ \ |
| 144 |
_type Value; \ |
| 145 |
_type Last; \ |
| 146 |
_type Default; \ |
| 147 |
_type Min; \ |
| 148 |
_type Max; \ |
| 149 |
_type Increment; \ |
| 150 |
} _name |
| 151 |
VALUES(String, char *); |
| 152 |
VALUES(Float, double); |
| 153 |
VALUES(Bool, bool); |
| 154 |
#undef VALUES |
| 155 |
#define FORMATTED_VALUES(_name, _type, _toStrType) \ |
| 156 |
struct \ |
| 157 |
{ \ |
| 158 |
_type Value; \ |
| 159 |
_type Last; \ |
| 160 |
_type Default; \ |
| 161 |
_type Min; \ |
| 162 |
_type Max; \ |
| 163 |
_type Increment; \ |
| 164 |
_type (*StrTo##_name)(const char *); \ |
| 165 |
_toStrType *(*_name##ToStr)(_type); \ |
| 166 |
} _name |
| 167 |
FORMATTED_VALUES(Int, int, char); |
| 168 |
FORMATTED_VALUES(Enum, int, const char); |
| 169 |
#undef FORMATTED_VALUES |
| 170 |
CArray Group; |
| 171 |
} u; |
| 172 |
} Config; |
| 173 |
|
| 174 |
Config ConfigNewString(const char *name, const char *defaultValue); |
| 175 |
Config ConfigNewInt( |
| 176 |
const char *name, const int defaultValue, const int minValue, |
| 177 |
const int maxValue, const int increment, int (*strToInt)(const char *), |
| 178 |
char *(*intToStr)(int)); |
| 179 |
Config ConfigNewFloat( |
| 180 |
const char *name, const double defaultValue, const double minValue, |
| 181 |
const double maxValue, const double increment); |
| 182 |
Config ConfigNewBool(const char *name, const bool defaultValue); |
| 183 |
Config ConfigNewEnum( |
| 184 |
const char *name, const int defaultValue, const int minValue, |
| 185 |
const int maxValue, int (*strToEnum)(const char *), |
| 186 |
const char *(*enumToStr)(int)); |
| 187 |
Config ConfigNewGroup(const char *name); |
| 188 |
void ConfigDestroy(Config *c); |
| 189 |
bool ConfigChangedAndApply(Config *c); |
| 190 |
|
| 191 |
void ConfigGroupAdd(Config *group, Config child); |
| 192 |
|
| 193 |
extern Config gConfig; |
| 194 |
|
| 195 |
Config ConfigDefault(void); |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
CArray ConfigFind(const Config *c, const char *prefix); |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
Config *ConfigGet(Config *c, const char *name); |
| 205 |
|
| 206 |
|
| 207 |
bool ConfigChanged(const Config *c); |
| 208 |
|
| 209 |
void ConfigResetChanged(Config *c); |
| 210 |
|
| 211 |
void ConfigSetChanged(Config *c); |
| 212 |
|
| 213 |
void ConfigResetDefault(Config *c); |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
const char *ConfigGetString(Config *c, const char *name); |
| 220 |
int ConfigGetInt(Config *c, const char *name); |
| 221 |
double ConfigGetFloat(Config *c, const char *name); |
| 222 |
bool ConfigGetBool(Config *c, const char *name); |
| 223 |
int ConfigGetEnum(Config *c, const char *name); |
| 224 |
CArray *ConfigGetGroup(Config *c, const char *name); |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
void ConfigSetInt(Config *c, const char *name, const int value); |
| 229 |
void ConfigSetFloat(Config *c, const char *name, const double value); |
| 230 |
|
| 231 |
bool ConfigTrySetFromString(Config *c, const char *name, const char *value); |
| 232 |
|
| 233 |
bool ConfigApply(Config *config, bool *resetBg); |
| 234 |
int ConfigGetVersion(FILE *f); |