extensions/clientprefs/menus.cpp
changeset 3804 90159516acd3
parent 3573 440c51204096
     1.1 --- a/extensions/clientprefs/menus.cpp	Mon Feb 25 20:44:16 2013 -0600
     1.2 +++ b/extensions/clientprefs/menus.cpp	Thu Feb 28 21:51:49 2013 +0000
     1.3 @@ -99,7 +99,7 @@
     1.4  	if (data->handler->forward != NULL)
     1.5  	{
     1.6  		char buffer[100];
     1.7 -		UTIL_Format(buffer, sizeof(buffer), "%s", dr.display);
     1.8 +		g_pSM->Format(buffer, sizeof(buffer), "%s", dr.display);
     1.9  
    1.10  		data->handler->forward->PushCell(client);
    1.11  		data->handler->forward->PushCell(CookieMenuAction_DisplayOption);
    1.12 @@ -118,53 +118,15 @@
    1.13  
    1.14  void AutoMenuHandler::OnMenuSelect(SourceMod::IBaseMenu *menu, int client, unsigned int item)
    1.15  {
    1.16 +	static const char settings[CookieMenu_Elements][2][4] = { {"yes", "no"}, {"1", "0"}, {"on", "off"}, {"1", "0"} };
    1.17  	ItemDrawInfo draw;
    1.18  
    1.19  	const char *info = menu->GetItemInfo(item, &draw);
    1.20  
    1.21  	AutoMenuData *data = (AutoMenuData *)strtoul(info, NULL, 16);
    1.22  
    1.23 -	switch (data->type)
    1.24 -	{
    1.25 -	case CookieMenu_YesNo:
    1.26 -		{
    1.27 -			if (item == 0)
    1.28 -			{
    1.29 -				g_CookieManager.SetCookieValue(data->pCookie, client, "yes");
    1.30 -			}
    1.31 -			else
    1.32 -			{
    1.33 -				g_CookieManager.SetCookieValue(data->pCookie, client, "no");
    1.34 -			}
    1.35 -			break;
    1.36 -		}
    1.37 -	case CookieMenu_YesNo_Int:
    1.38 -	case CookieMenu_OnOff_Int:
    1.39 -		{
    1.40 -			if (item == 0)
    1.41 -			{
    1.42 -				g_CookieManager.SetCookieValue(data->pCookie, client, "1");
    1.43 -			}
    1.44 -			else
    1.45 -			{
    1.46 -				g_CookieManager.SetCookieValue(data->pCookie, client, "0");
    1.47 -			}
    1.48 -			break;
    1.49 -		}
    1.50 -	case CookieMenu_OnOff:
    1.51 -		{
    1.52 -			if (item == 0)
    1.53 -			{
    1.54 -				g_CookieManager.SetCookieValue(data->pCookie, client, "on");
    1.55 -			}
    1.56 -			else
    1.57 -			{
    1.58 -				g_CookieManager.SetCookieValue(data->pCookie, client, "off");
    1.59 -			}
    1.60 -			break;
    1.61 -		}
    1.62 -	}
    1.63 -
    1.64 +	g_CookieManager.SetCookieValue(data->pCookie, client, settings[data->type][item]);
    1.65 +	
    1.66  	char message[255];
    1.67  	char *value;
    1.68  	g_CookieManager.GetCookieValue(data->pCookie, client, &value);