X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=25df21ca234f94b882d895c1b59c2ffd32efff84;hb=9233f6cfc90e72b7cc168c570fdd2e545f698674;hp=d0c62ab591b14d707931c43395f9c3dfca7dbb56;hpb=0868de4751d9e3d4b2f3185c52edb5569217d39a;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index d0c62ab5..25df21ca 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -584,6 +584,14 @@ boolean strEqual(char *s1, char *s2) strcmp(s1, s2) == 0); } +boolean strEqualN(char *s1, char *s2, int n) +{ + return (s1 == NULL && s2 == NULL ? TRUE : + s1 == NULL && s2 != NULL ? FALSE : + s1 != NULL && s2 == NULL ? FALSE : + strncmp(s1, s2, n) == 0); +} + /* ------------------------------------------------------------------------- */ /* command line option handling functions */ @@ -1811,8 +1819,6 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : string_has_parameter(value, "vertical") ? ANIM_VERTICAL : string_has_parameter(value, "centered") ? ANIM_CENTERED : - string_has_parameter(value, "fade") ? ANIM_FADE : - string_has_parameter(value, "crossfade") ? ANIM_CROSSFADE : ANIM_DEFAULT); if (string_has_parameter(value, "reverse")) @@ -1824,6 +1830,17 @@ int get_parameter_value(char *value_raw, char *suffix, int type) if (string_has_parameter(value, "static_panel")) result |= ANIM_STATIC_PANEL; } + else if (strEqual(suffix, ".fade_mode")) + { + result = (string_has_parameter(value, "none") ? FADE_MODE_NONE : + string_has_parameter(value, "fade") ? FADE_MODE_FADE : + string_has_parameter(value, "crossfade") ? FADE_MODE_CROSSFADE : + FADE_MODE_DEFAULT); + } + else if (strEqualN(suffix, ".font", 5)) /* (may also be ".font_xyz") */ + { + result = gfx.get_font_from_token_function(value); + } else /* generic parameter of type integer or boolean */ { result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE : @@ -1837,6 +1854,35 @@ int get_parameter_value(char *value_raw, char *suffix, int type) return result; } +int get_token_parameter_value(char *token, char *value_raw) +{ + char *suffix; + + if (token == NULL || value_raw == NULL) + return ARG_UNDEFINED_VALUE; + + suffix = strrchr(token, '.'); + if (suffix == NULL) + suffix = token; + +#if 0 + if (strncmp(suffix, ".font", 5) == 0) + { + int i; + + /* !!! OPTIMIZE THIS BY USING HASH !!! */ + for (i = 0; i < NUM_FONTS; i++) + if (strEqual(value_raw, font_info[i].token_name)) + return i; + + /* if font not found, use reliable default value */ + return FONT_INITIAL_1; + } +#endif + + return get_parameter_value(value_raw, suffix, TYPE_INTEGER); +} + struct ScreenModeInfo *get_screen_mode_from_string(char *screen_mode_string) { static struct ScreenModeInfo screen_mode;