Add karma changes display

See #38
This commit is contained in:
Alexander Batalov 2022-06-08 23:33:54 +03:00
parent 5731cd6058
commit ba1715d9b0
3 changed files with 20 additions and 0 deletions

View File

@ -891,6 +891,24 @@ int gameSetGlobalVar(int var, int value)
return -1;
}
// SFALL: Display karma changes.
if (var == GVAR_PLAYER_REPUTATION) {
bool shouldDisplayKarmaChanges = false;
configGetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DISPLAY_KARMA_CHANGES_KEY, &shouldDisplayKarmaChanges);
if (shouldDisplayKarmaChanges) {
int diff = value - gGameGlobalVars[var];
if (diff != 0) {
char formattedMessage[80];
if (diff > 0) {
sprintf(formattedMessage, "You gained %d karma.", diff);
} else {
sprintf(formattedMessage, "You lost %d karma.", -diff);
}
displayMonitorAddMessage(formattedMessage);
}
}
}
gGameGlobalVars[var] = value;
return 0;

View File

@ -29,6 +29,7 @@ bool sfallConfigInit(int argc, char** argv)
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_MAIN_MENU_FONT_COLOR, 0);
configSetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_SKIP_OPENING_MOVIES_KEY, 0);
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_STARTING_MAP_KEY, "");
configSetBool(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DISPLAY_KARMA_CHANGES_KEY, false);
char path[COMPAT_MAX_PATH];
char* executable = argv[0];

View File

@ -15,6 +15,7 @@
#define SFALL_CONFIG_MAIN_MENU_FONT_COLOR "MainMenuFontColour"
#define SFALL_CONFIG_SKIP_OPENING_MOVIES_KEY "SkipOpeningMovies"
#define SFALL_CONFIG_STARTING_MAP_KEY "StartingMap"
#define SFALL_CONFIG_DISPLAY_KARMA_CHANGES_KEY "DisplayKarmaChanges"
extern bool gSfallConfigInitialized;
extern Config gSfallConfig;