diff options
Diffstat (limited to 'src/gamemodifiers.h')
-rw-r--r-- | src/gamemodifiers.h | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h index 63114cc22..c8579afe0 100644 --- a/src/gamemodifiers.h +++ b/src/gamemodifiers.h @@ -1,9 +1,9 @@ /* - * The ManaPlus Client + * The ManaVerse Client * Copyright (C) 2011-2020 The ManaPlus Developers - * Copyright (C) 2020-2023 The ManaVerse Developers + * Copyright (C) 2020-2025 The ManaVerse Developers * - * This file is part of The ManaPlus Client. + * This file is part of The ManaVerse Client. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,24 +26,41 @@ #include "localconsts.h" -#define declModifier(name1) \ - static void change##name1(const bool forward); \ - static std::string get##name1##String(); \ - static const unsigned m##name1##Size; \ - static const char *const m##name1##Strings[]; +#define declModifier(typeName) \ + static void change##typeName(const bool forward); \ + static std::string get##typeName##String(); \ + static const unsigned m##typeName##Size; \ + static const char *const m##typeName##Strings[]; class GameModifiers final { public: A_DELETE_COPY(GameModifiers) + /* + * Load most modifiers from config. + */ static void init(); + /* + * Cycle through available modifier settings + * + * Assumes that settings start at 0 and end at limit-1 without holes. + * + * @param var the variable that stores the current settings + * @param first first valid setting (used when limit is reached) + * @param limit how many settings there are (for looping around) + * @param configKey name of this setting in config + * @param func obtain human readable representation of the next setting + * used to print new setting state into debug log. + * @param save toggles whether to save changed setting + * @param forward direction of cycling + */ static void changeMode(unsigned *restrict const var, + const unsigned first, const unsigned limit, - const char *restrict const conf, + const char *restrict const configKey, std::string (*const func)(), - const unsigned def, const bool save, const bool forward); @@ -66,13 +83,24 @@ class GameModifiers final static void setQuickDropCounter(const int n); + /* + * Reset modifiers to their default values + */ static void resetModifiers(); protected: - static const char *getVarItem(const char *const *const arr, - const unsigned index, - const unsigned sz) - A_WARN_UNUSED A_NONNULL(1); + /* + * Return untranslated human representation of a setting's state + * + * @param lut look up table with strings before translation + * @param index setting's value + * @param size upper limit on setting's value (index of top + * element reserved for unknown/error string) + */ + static const char *getHumanString(const char *const *const lut, + const unsigned index, + const unsigned size) + A_WARN_UNUSED A_NONNULL(1); }; #undef declModifier |