From 1757ec97fa345daeba43e7e9091d65132b94ac8a Mon Sep 17 00:00:00 2001 From: Greyscale Date: Mon, 3 Aug 2009 14:55:50 -0700 Subject: [PATCH] ConfigBoolToSetting now translates a bool into the client's/server's native language. --- src/zr/config.inc | 22 ++++++++++++++++------ src/zr/hitgroups.inc | 2 +- src/zr/weapons/menu_weapons.inc | 2 +- src/zr/weapons/zmarket.inc | 4 ++-- src/zr/zcookies.inc | 6 +++--- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/zr/config.inc b/src/zr/config.inc index 560ad82..402106e 100644 --- a/src/zr/config.inc +++ b/src/zr/config.inc @@ -878,7 +878,7 @@ public Action:ConfigReloadAllCommand(client, argc) } /** - * Converts string of "yes/on" or "no/off" to a boolean value. + * Converts string of "yes/on" or "no/off" to a boolean value. Always uses english as yes/no/on/off language. * * @param option "yes/on" or "no/off" string to be converted. * @return True if string is "yes", false otherwise. @@ -891,7 +891,7 @@ stock bool:ConfigSettingToBool(const String:option[]) return true; } - // Option isn't "yes." + // Option isn't yes. return false; } @@ -901,19 +901,29 @@ stock bool:ConfigSettingToBool(const String:option[]) * @param bOption True/false value to be converted to "yes/on"/"no/off", respectively. * @param option Destination string buffer to store "yes/on" or "no/off" in. * @param maxlen Length of destination string buffer (wont't be more than 4). - * @param yesno When true, returns "yes/no", false returns "on/off." + * @param yesno When true, returns "yes/no", false returns "on/off." + * @param target The target to use as translation language. */ -stock ConfigBoolToSetting(bool:bOption, String:option[], maxlen, bool:yesno = true) +stock ConfigBoolToSetting(bool:bOption, String:option[], maxlen, bool:yesno = true, target = LANG_SERVER) { + decl String:t_yes[16], String:t_on[16]; + decl String:t_no[16], String:t_off[16]; + + SetGlobalTransTarget(target); + + // Get the yes/no translations for the target. + Format(t_yes, sizeof(t_yes), "%t", "Yes"); Format(t_on, sizeof(t_on), "%t", "On"); + Format(t_no, sizeof(t_no), "%t", "No"); Format(t_off, sizeof(t_off), "%t", "Off"); + // If option is true, then copy "yes" to return string. if (bOption) { - yesno ? strcopy(option, maxlen, "Yes") : strcopy(option, maxlen, "On"); + yesno ? strcopy(option, maxlen, t_yes) : strcopy(option, maxlen, t_on); } // If option is false, then copy "no" to return string. else { - yesno ? strcopy(option, maxlen, "No") : strcopy(option, maxlen, "Off"); + yesno ? strcopy(option, maxlen, t_no) : strcopy(option, maxlen, t_off); } } diff --git a/src/zr/hitgroups.inc b/src/zr/hitgroups.inc index 0cd330e..5dc71c1 100644 --- a/src/zr/hitgroups.inc +++ b/src/zr/hitgroups.inc @@ -397,7 +397,7 @@ bool:HitgroupsMenuHitgroups(client) IntToString(x, hitgroupid, sizeof(hitgroupid)); // Convert bool to "On/Off" - ConfigBoolToSetting(HitgroupsCanDamage(x), hitgroupcandamage, sizeof(hitgroupcandamage), false); + ConfigBoolToSetting(HitgroupsCanDamage(x), hitgroupcandamage, sizeof(hitgroupcandamage), false, client); // Format "on/off" to the option. Format(hitgroupoption, sizeof(hitgroupoption), "%s: %s", hitgroupoption, hitgroupcandamage); diff --git a/src/zr/weapons/menu_weapons.inc b/src/zr/weapons/menu_weapons.inc index 711cfa4..c28ada7 100644 --- a/src/zr/weapons/menu_weapons.inc +++ b/src/zr/weapons/menu_weapons.inc @@ -360,7 +360,7 @@ WeaponsMenuZMarket(client) // Get "yes" or "no" settings from respective cvar. decl String:buyzonesetting[8]; - ConfigBoolToSetting(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]), buyzonesetting, sizeof(buyzonesetting)); + ConfigBoolToSetting(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]), buyzonesetting, sizeof(buyzonesetting), true, client); SetGlobalTransTarget(client); diff --git a/src/zr/weapons/zmarket.inc b/src/zr/weapons/zmarket.inc index 02082b9..fc2f0c9 100644 --- a/src/zr/weapons/zmarket.inc +++ b/src/zr/weapons/zmarket.inc @@ -264,7 +264,7 @@ bool:ZMarketMenuMain(client) // Get auto-rebuy setting. decl String:rebuyautosetting[8]; - ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie), rebuyautosetting, sizeof(rebuyautosetting)); + ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie), rebuyautosetting, sizeof(rebuyautosetting), true, client); // Format menu options. Format(title, sizeof(title), "%t\n ", "Weapons menu zmarket main title"); @@ -422,7 +422,7 @@ bool:ZMarketMenuLoadout(client) // Copy "Yes/No" to NVGs string. decl String:nvgsbool[8]; - ConfigBoolToSetting(bool:nvgsweapon[0], nvgsbool, sizeof(nvgsbool)); + ConfigBoolToSetting(bool:nvgsweapon[0], nvgsbool, sizeof(nvgsbool), true, client); decl String:title[MENU_LINE_TITLE_LENGTH]; decl String:primary[MENU_LINE_REG_LENGTH]; diff --git a/src/zr/zcookies.inc b/src/zr/zcookies.inc index e09bd7a..be200e9 100644 --- a/src/zr/zcookies.inc +++ b/src/zr/zcookies.inc @@ -52,9 +52,9 @@ ZCookiesMenuMain(client) decl String:overlayenabled[4]; // Get the current toggle state of the cookies. - ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie), autorebuyenabled, sizeof(autorebuyenabled), false); - ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false); - ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false); + ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZMarketAutoRebuyCookie), autorebuyenabled, sizeof(autorebuyenabled), false, client); + ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false, client); + ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false, client); decl String:title[MENU_LINE_TITLE_LENGTH]; decl String:autorebuy[MENU_LINE_REG_LENGTH];