113 lines
2.6 KiB
C
113 lines
2.6 KiB
C
////////////////////////////////////////////////////////////
|
|
//~ Tweak var types
|
|
|
|
Enum(TweakKind)
|
|
{
|
|
TweakKind_Bool,
|
|
TweakKind_Float,
|
|
};
|
|
|
|
Enum(TweakFlag)
|
|
{
|
|
TweakFlag_None = 0,
|
|
TweakFlag_Hidden = (1 << 0),
|
|
};
|
|
|
|
Struct(TweakVar)
|
|
{
|
|
TweakKind kind;
|
|
TweakFlag flags;
|
|
String name;
|
|
String category;
|
|
|
|
String value;
|
|
String initial;
|
|
|
|
RngF64 range;
|
|
i32 precision;
|
|
};
|
|
|
|
Struct(TweakVarArray)
|
|
{
|
|
i64 count;
|
|
TweakVar *v;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Utility types
|
|
|
|
Struct(TweakBoolDesc)
|
|
{
|
|
TweakFlag flags;
|
|
String category;
|
|
};
|
|
|
|
Struct(TweakFloatDesc)
|
|
{
|
|
TweakFlag flags;
|
|
String category;
|
|
f64 min;
|
|
f64 max;
|
|
i32 precision;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Cache types
|
|
|
|
Struct(TweakVarEntry)
|
|
{
|
|
TweakVarEntry *next_in_bin;
|
|
TweakVarEntry *next_in_list;
|
|
u64 hash;
|
|
TweakVar v;
|
|
};
|
|
|
|
Struct(TweakVarEntryBin)
|
|
{
|
|
TweakVarEntry *first;
|
|
TweakVarEntry *last;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ State types
|
|
|
|
Struct(TweakCtx)
|
|
{
|
|
TicketMutex tm;
|
|
|
|
TweakVarEntryBin entry_bins[8192];
|
|
|
|
i64 entries_count;
|
|
TweakVarEntry *first_entry;
|
|
TweakVarEntry *last_entry;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Bootstrap
|
|
|
|
void BootstrapTweakVars(void);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Tweak var operations
|
|
|
|
String TweakEx(Arena *arena, TweakVar desc, b32 update_existing);
|
|
TweakVarArray GetAllTweakVars(Arena *arena);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Tweak utils
|
|
|
|
b32 TweakBool_(String name, b32 initial, TweakBoolDesc desc);
|
|
#define TweakBool(_name, _initial, ...) TweakBool_(Lit(_name), (_initial), (TweakBoolDesc) { \
|
|
.category = Lit("Debug"), \
|
|
__VA_ARGS__ \
|
|
})
|
|
|
|
f64 TweakFloat_(String name, f64 initial, TweakFloatDesc desc);
|
|
#define TweakFloat(_name, _initial, _min, _max, ...) TweakFloat_(Lit(_name), (_initial), (TweakFloatDesc) { \
|
|
.category = Lit("Debug"), \
|
|
.min = (_min), \
|
|
.max = (_max), \
|
|
.precision = 3, \
|
|
__VA_ARGS__ \
|
|
})
|