Replaced all menu line lengths with defines in menu.inc

*Moved the including of menu.inc up to allow all modules to use its defines.
This commit is contained in:
Greyscale 2009-07-27 13:25:23 -07:00
parent 75d72fb3f2
commit b7018e9fe8
8 changed files with 62 additions and 54 deletions

View File

@ -46,6 +46,7 @@
#include "zr/steamidcache"
#include "zr/sayhooks"
#include "zr/tools"
#include "zr/menu"
#include "zr/cookies"
#include "zr/paramtools"
#include "zr/models"
@ -58,7 +59,6 @@
#include "zr/roundend"
#include "zr/infect"
#include "zr/damage"
#include "zr/menu"
#include "zr/event"
#include "zr/zadmin"
#include "zr/commands"

View File

@ -372,8 +372,8 @@ bool:HitgroupsMenuHitgroups(client)
SetMenuTitle(menu_hitgroups, "%t\n ", "Hitgroups menu hitgroups title");
decl String:enableall[32];
decl String:headshotsonly[32];
decl String:enableall[MENU_LINE_REG_LENGTH];
decl String:headshotsonly[MENU_LINE_REG_LENGTH];
// Format menu options.
Format(enableall, sizeof(enableall), "%t", "Hitgroups menu hitgroups enable all");
@ -383,8 +383,8 @@ bool:HitgroupsMenuHitgroups(client)
AddMenuItem(menu_hitgroups, "Enable All", enableall);
AddMenuItem(menu_hitgroups, "Headshots Only", headshotsonly);
decl String:hitgroupoption[MAX_NAME_LENGTH];
decl String:hitgroupcandamage[MAX_NAME_LENGTH];
decl String:hitgroupoption[MENU_LINE_REG_LENGTH];
decl String:hitgroupcandamage[8];
decl String:hitgroupid[4];
// x = Hitgroup index.
@ -416,7 +416,7 @@ bool:HitgroupsMenuHitgroups(client)
/**
* Called when client selects option in the infect clients menu, and handles it.
* @param menu_weapons_main Handle of the menu being used.
* @param menu_hitgroups Handle of the menu being used.
* @param action The action done on the menu (see menus.inc, enum MenuAction).
* @param client The client index.
* @param slot The slot index selected (starting from 0).

View File

@ -817,7 +817,7 @@ InfectMenuClients(client)
SetMenuTitle(menu_infect_clients, "%t\n ", "Infect menu clients title");
decl String:clientoption[64];
decl String:clientoption[MENU_LINE_REG_LENGTH];
decl String:clientuserid[8];
// x = Client index.
@ -862,7 +862,7 @@ InfectMenuClients(client)
/**
* Called when client selects option in the infect clients menu, and handles it.
* @param menu_weapons_main Handle of the menu being used.
* @param menu_infect_clients Handle of the menu being used.
* @param action The action done on the menu (see menus.inc, enum MenuAction).
* @param client The client index.
* @param slot The slot index selected (starting from 0).

View File

@ -25,6 +25,17 @@
* ============================================================================
*/
/**
* @section Some defined lengths of menu lines throughout the plugin.
*/
#define MENU_LINE_SMALL_LENGTH 32
#define MENU_LINE_REG_LENGTH 64
#define MENU_LINE_BIG_LENGTH 128
#define MENU_LINE_HUGE_LENGTH 256
/**
* @endsection
*/
/**
* Create commands specific to ZMenu.
*/
@ -81,13 +92,13 @@ ZMenuMain(client)
SetMenuTitle(menu_main, "%t\n ", "Menu main title", publictrigger, silenttrigger);
// Initialize menu lines.
decl String:zadmin[256];
decl String:zclass[256];
decl String:zcookies[256];
decl String:zspawn[256];
decl String:ztele[256];
decl String:zhp[256];
decl String:zmarket[256];
decl String:zadmin[MENU_LINE_HUGE_LENGTH];
decl String:zclass[MENU_LINE_HUGE_LENGTH];
decl String:zcookies[MENU_LINE_HUGE_LENGTH];
decl String:zspawn[MENU_LINE_HUGE_LENGTH];
decl String:ztele[MENU_LINE_HUGE_LENGTH];
decl String:zhp[MENU_LINE_HUGE_LENGTH];
decl String:zmarket[MENU_LINE_HUGE_LENGTH];
// Translate each line into client's language.
Format(zadmin, sizeof(zadmin), "%t", "Menu main zadmin", SAYHOOKS_KEYWORD_ZADMIN);
@ -216,13 +227,13 @@ stock MenuClientList(client, MenuHandler:handler, bool:team = false, bool:alive
SetGlobalTransTarget(client);
// Translate phrase.
decl String:translation[TRANSLATION_MAX_LENGTH_CHAT];
decl String:translation[MENU_LINE_REG_LENGTH];
VFormat(translation, sizeof(translation), "%t", 6);
// Set menu title to the translated phrase.
SetMenuTitle(menu_clients, translation);
decl String:clientoption[MAX_NAME_LENGTH];
decl String:clientoption[MENU_LINE_REG_LENGTH];
decl String:clientuserid[8];
new count = 0;

View File

@ -51,8 +51,8 @@ bool:WeaponsMenuMain(client)
SetMenuTitle(menu_weapons_main, "%t\n ", "Weapons menu restrict main title");
decl String:restrict[64];
decl String:zmarket[64];
decl String:restrict[MENU_LINE_SMALL_LENGTH];
decl String:zmarket[MENU_LINE_SMALL_LENGTH];
Format(restrict, sizeof(restrict), "%t", "Weapons menu restrict main restrict");
Format(zmarket, sizeof(zmarket), "%t", "Weapons menu restrict main market");
@ -144,7 +144,7 @@ WeaponsMenuTypes(client)
// If there are no weapons, add an "(Empty)" line.
if (size == 0)
{
decl String:empty[64];
decl String:empty[MENU_LINE_SMALL_LENGTH];
Format(empty, sizeof(empty), "%t", "Menu empty");
AddMenuItem(menu_weapons_types, "empty", empty, ITEMDRAW_DISABLED);
@ -206,8 +206,8 @@ WeaponsMenuTypeWeapons(client)
SetMenuTitle(menu_weapons_typeweapons, "%t\n ", "Weapons menu restrict types weapon type title", typename);
decl String:restrictall[64];
decl String:unrestrictall[64];
decl String:restrictall[MENU_LINE_REG_LENGTH];
decl String:unrestrictall[MENU_LINE_REG_LENGTH];
Format(restrictall, sizeof(restrictall), "%t", "Weapons menu restrict types restrict all", typename);
Format(unrestrictall, sizeof(unrestrictall), "%t\n ", "Weapons menu restrict types unrestrict all", typename);
@ -216,8 +216,8 @@ WeaponsMenuTypeWeapons(client)
AddMenuItem(menu_weapons_typeweapons, "restrictall", restrictall, MenuGetItemDraw(!RestrictIsTypeUniform(true, g_iWeaponsCurType[client])));
AddMenuItem(menu_weapons_typeweapons, "unrestrictall", unrestrictall, MenuGetItemDraw(!RestrictIsTypeUniform(false, g_iWeaponsCurType[client])));
decl String:typeweapon[WEAPONS_MAX_LENGTH];
decl String:display[WEAPONS_MAX_LENGTH];
decl String:typeweapon[MENU_LINE_SMALL_LENGTH];
decl String:display[MENU_LINE_SMALL_LENGTH + 2]; // +2 to allow room for the [ ] if its restricted.
// Get an array populated with all weapons of the given type.
new Handle:arrayTypeWeapons;
@ -291,7 +291,7 @@ public WeaponsMenuTypeWeaponsHandle(Handle:menu_weapons_typeweapons, MenuAction:
default:
{
// Get weappon name.
decl String:typeweapon[WEAPONS_MAX_LENGTH];
decl String:typeweapon[MENU_LINE_REG_LENGTH];
GetMenuItem(menu_weapons_typeweapons, slot, typeweapon, sizeof(typeweapon));
// Get weapon index.
@ -356,7 +356,7 @@ WeaponsMenuZMarket(client)
SetMenuTitle(menu_weapons_market, "%t\n ", "Weapons menu restrict zmarket title");
decl String:buyzone[64];
decl String:buyzone[MENU_LINE_REG_LENGTH];
decl String:buyzonesetting[8];
// Get "yes" or "no" settings from respective cvar.

View File

@ -258,11 +258,11 @@ bool:ZMarketMenuMain(client)
new bool:zmarketrebuyauto = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_REBUY_AUTO]);
// Add "Get Current Loadout" option.
decl String:getloadout[WEAPONS_MAX_LENGTH];
decl String:viewloadout[WEAPONS_MAX_LENGTH];
decl String:rebuy[WEAPONS_MAX_LENGTH];
decl String:rebuyauto[WEAPONS_MAX_LENGTH];
decl String:weaponslist[WEAPONS_MAX_LENGTH];
decl String:getloadout[MENU_LINE_REG_LENGTH];
decl String:viewloadout[MENU_LINE_REG_LENGTH];
decl String:rebuy[MENU_LINE_REG_LENGTH];
decl String:rebuyauto[MENU_LINE_REG_LENGTH];
decl String:weaponslist[MENU_LINE_REG_LENGTH];
// Get auto-rebuy setting.
decl String:rebuyautosetting[8];
@ -399,7 +399,7 @@ bool:ZMarketMenuLoadout(client)
WeaponsClassnameToDisplay(rebuyweapons[Slot_NVGs], sizeof(rebuyweapons[]), nvgsweapon, sizeof(nvgsweapon));
// Get the empty translation.
decl String:empty[64];
decl String:empty[MENU_LINE_SMALL_LENGTH];
Format(empty, sizeof(empty), "%t", "Weapons menu zmarket loadout empty");
// If the client doesn't have a weapon in this slot, then set the weapon to the empty translation.
@ -428,12 +428,12 @@ bool:ZMarketMenuLoadout(client)
decl String:nvgsbool[8];
ConfigBoolToSetting(bool:nvgsweapon[0], nvgsbool, sizeof(nvgsbool));
decl String:primary[64];
decl String:secondary[64];
decl String:melee[64];
decl String:projectile[64];
decl String:explosive[64];
decl String:nvgs[64];
decl String:primary[MENU_LINE_REG_LENGTH];
decl String:secondary[MENU_LINE_REG_LENGTH];
decl String:melee[MENU_LINE_REG_LENGTH];
decl String:projectile[MENU_LINE_REG_LENGTH];
decl String:explosive[MENU_LINE_REG_LENGTH];
decl String:nvgs[MENU_LINE_REG_LENGTH];
// Format all the lines of the menu.
Format(primary, sizeof(primary), "%t", "Weapons menu zmarket loadout primary", primaryweapon);
@ -525,7 +525,7 @@ ZMarketMenuTypes(client)
// If there are no weapons, add an "(Empty)" line.
if (size == 0)
{
decl String:empty[64];
decl String:empty[MENU_LINE_SMALL_LENGTH];
Format(empty, sizeof(empty), "%t", "Menu empty");
AddMenuItem(menu_zmarket_types, "empty", empty, ITEMDRAW_DISABLED);
@ -605,8 +605,8 @@ ZMarketMenuTypeWeapons(client)
SetMenuTitle(menu_zmarket_typeweapons, "%t\n ", "Weapons menu zmarket types weapon type title", typename);
decl String:typeweapon[WEAPONS_MAX_LENGTH];
decl String:typeweapondisplay[WEAPONS_MAX_LENGTH];
decl String:display[128];
decl String:typeweapondisplay[MENU_LINE_REG_LENGTH];
decl String:display[MENU_LINE_BIG_LENGTH];
// Get an array populated with all weapons of the given type.
new Handle:arrayTypeWeapons;

View File

@ -79,13 +79,12 @@ bool:ZAdminMenu(client)
SetMenuTitle(menu_zadmin, "%t\n ", "ZAdmin main title");
decl String:classmultipliers[64];
decl String:weapons[64];
decl String:hitgroups[64];
decl String:infect[64];
decl String:zspawn[64];
decl String:ztele[64];
//decl String:logflags[64];
decl String:classmultipliers[MENU_LINE_REG_LENGTH];
decl String:weapons[MENU_LINE_REG_LENGTH];
decl String:hitgroups[MENU_LINE_REG_LENGTH];
decl String:infect[MENU_LINE_REG_LENGTH];
decl String:zspawn[MENU_LINE_REG_LENGTH];
decl String:ztele[MENU_LINE_REG_LENGTH];
Format(classmultipliers, sizeof(classmultipliers), "%t", "ZAdmin main class multipliers");
Format(weapons, sizeof(weapons), "%t", "ZAdmin main weapons");
@ -93,7 +92,6 @@ bool:ZAdminMenu(client)
Format(infect, sizeof(infect), "%t", "ZAdmin main zombie");
Format(zspawn, sizeof(zspawn), "%t", "ZAdmin main force zspawn");
Format(ztele, sizeof(ztele), "%t", "ZAdmin main force ztele");
//Format(logflags, sizeof(logflags), "%t", "!zadmin main logflags");
// Get conditions for options.
new bool:hitgroupsenabled = GetConVarBool(g_hCvarsList[CVAR_HITGROUPS]);
@ -105,7 +103,6 @@ bool:ZAdminMenu(client)
AddMenuItem(menu_zadmin, "infect", infect);
AddMenuItem(menu_zadmin, "zspawn", zspawn);
AddMenuItem(menu_zadmin, "ztele", ztele);
//AddMenuItem(menu_zadmin, "logflags", logflags);
// Set "Back" button.
SetMenuExitBackButton(menu_zadmin, true);

View File

@ -59,10 +59,10 @@ ZCookiesMenuMain(client)
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false);
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false);
decl String:autorebuy[64];
decl String:zhp[64];
decl String:overlay[64];
decl String:zmarket[64];
decl String:autorebuy[MENU_LINE_REG_LENGTH];
decl String:zhp[MENU_LINE_REG_LENGTH];
decl String:overlay[MENU_LINE_REG_LENGTH];
decl String:zmarket[MENU_LINE_REG_LENGTH];
// Translate each line into client's language.
Format(autorebuy, sizeof(autorebuy), "%t", "ZCookies menu main auto-rebuy", autorebuyenabled);