Skip to content

Commit

Permalink
Menu methodmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
Bara committed May 11, 2018
1 parent 68250d9 commit 104d97d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 48 deletions.
28 changes: 14 additions & 14 deletions addons/sourcemod/scripting/ttt/ttt.sp
Expand Up @@ -3295,36 +3295,36 @@ stock void InspectBody(int client, int victim, int victimRole, int attacker, int
Format(team, sizeof(team), "%T", "Innocents", client);
}

Handle menu = CreateMenu(BodyMenuHandler);
Menu menu = new Menu(BodyMenuHandler);
char sBuffer[128];

SetMenuTitle(menu, "%T", "Inspected body. The extracted data are the following", client);
menu.SetTitle("%T", "Inspected body. The extracted data are the following", client);

Format(sBuffer, sizeof(sBuffer), "%T", "Victim name", client, victimName);
AddMenuItem(menu, "", sBuffer);
menu.AddItem("", sBuffer);

Format(sBuffer, sizeof(sBuffer), "%T", "Team victim", client, team);
AddMenuItem(menu, "", sBuffer);
menu.AddItem("", sBuffer);

if (g_iRole[client] == TTT_TEAM_DETECTIVE)
{
Format(sBuffer, sizeof(sBuffer), "%T", "Elapsed since his death", client, time);
AddMenuItem(menu, "", sBuffer);
menu.AddItem("", sBuffer);

if (TTT_IsClientValid(attacker) && attacker != victim)
{
Format(sBuffer, sizeof(sBuffer), "%T", "The weapon used has been", client, weapon);
AddMenuItem(menu, "", sBuffer);
menu.AddItem("", sBuffer);
}
else
{
Format(sBuffer, sizeof(sBuffer), "%T", "The weapon used has been: himself (suicide)", client);
AddMenuItem(menu, "", sBuffer);
menu.AddItem("", sBuffer);
}
}

SetMenuExitButton(menu, true);
DisplayMenu(menu, client, 15);
menu.ExitButton = true;
menu.Display(client, 15);

}

Expand Down Expand Up @@ -3490,11 +3490,11 @@ stock void manageRDM(int client)
Format(sForgive, sizeof(sForgive), "%T", "Forgive", client);
Format(sPunish, sizeof(sPunish), "%T", "Punish", client);

Handle menuHandle = CreateMenu(manageRDMHandle);
SetMenuTitle(menuHandle, display);
AddMenuItem(menuHandle, "Forgive", sForgive);
AddMenuItem(menuHandle, "Punish", sPunish);
DisplayMenu(menuHandle, client, 10);
Menu menu = new Menu(manageRDMHandle);
menu.SetTitle(display);
menu.AddItem("Forgive", sForgive);
menu.AddItem("Punish", sPunish);
menu.Display(client, 10);
}

public int manageRDMHandle(Menu menu, MenuAction action, int client, int option)
Expand Down
20 changes: 10 additions & 10 deletions addons/sourcemod/scripting/ttt/ttt_c4_jihad.sp
Expand Up @@ -584,21 +584,21 @@ stock void showPlantMenu(int client)
}


Handle menuHandle = CreateMenu(plantBombMenu);
Menu menu = new Menu(plantBombMenu);

char sTitle[128];
Format(sTitle, sizeof(sTitle), "%T", "Set C4 Timer", client);
SetMenuTitle(menuHandle, sTitle);
menu.SetTitle(sTitle);

char sSeconds[64];
for(int i = 0; i < g_iPlantSecondsCount; i++)
{
Format(sSeconds, sizeof(sSeconds), "%T", "Seconds", client, StringToInt(g_sPlantSeconds[i]));
AddMenuItem(menuHandle, g_sPlantSeconds[i], sSeconds);
menu.AddItem(g_sPlantSeconds[i], sSeconds);
}

SetMenuPagination(menuHandle, 6);
DisplayMenu(menuHandle, client, 10);
menu.Pagination = 6;
menu.Display(client, 10);
}

stock void showDefuseMenu(int client)
Expand All @@ -611,19 +611,19 @@ stock void showDefuseMenu(int client)
char sTitle[128];
char sWire[64], sWireInt[12];

Handle menuHandle = CreateMenu(defuseBombMenu);
SetMenuTitle(menuHandle, sTitle);
Menu menu = new Menu(defuseBombMenu);
menu.SetTitle(sTitle);
Format(sTitle, sizeof(sTitle), "%T", "Defuse C4", client);

for (int i = 1; i <= g_cWireCount.IntValue; i++)
{
Format(sWire, sizeof(sWire), "%T", "C4 Wire", client, i);
IntToString(i, sWireInt, sizeof(sWireInt));
AddMenuItem(menuHandle, sWireInt, sWire);
menu.AddItem(sWireInt, sWire);
}

SetMenuPagination(menuHandle, 4);
DisplayMenu(menuHandle, client, 10);
menu.Pagination = 4;
menu.Display(client, 10);
}

public int plantBombMenu(Menu menu, MenuAction action, int client, int option)
Expand Down
40 changes: 21 additions & 19 deletions addons/sourcemod/scripting/ttt/ttt_res.sp
Expand Up @@ -184,26 +184,26 @@ public Action Commamnd_RES(int client, int args)
}

int cookievalue = GetIntCookie(client, g_hCookie);
Handle hMenu = CreateMenu(MenuHandle);
SetMenuTitle(hMenu, "Round End Sounds...");
Menu menu = new Menu(MenuHandle);
menu.SetTitle("Round End Sounds...");
char Item[128];
if(cookievalue == 0)
{
Format(Item, sizeof(Item), "Sounds on [X]");
AddMenuItem(hMenu, "ON", Item);
menu.AddItem("ON", Item);
Format(Item, sizeof(Item), "Sounds off");
AddMenuItem(hMenu, "OFF", Item);
menu.AddItem("OFF", Item);
}
else
{
Format(Item, sizeof(Item), "Sounds on");
AddMenuItem(hMenu, "ON", Item);
menu.AddItem("ON", Item);
Format(Item, sizeof(Item), "Sounds off [X]");
AddMenuItem(hMenu, "OFF", Item);
menu.AddItem("OFF", Item);
}
SetMenuExitBackButton(hMenu, true);
SetMenuExitButton(hMenu, true);
DisplayMenu(hMenu, client, 30);
menu.ExitBackButton = true;
menu.ExitButton = true;
menu.Display(client, 30);
return Plugin_Continue;
}

Expand All @@ -213,33 +213,35 @@ public Action Command_ResRefresh(int client, int args)
return Plugin_Handled;
}

public int MenuHandle(Handle menu, MenuAction action, int param1, int param2)
public int MenuHandle(Menu menu, MenuAction action, int client, int param)
{
Handle hMenu = CreateMenu(MenuHandle);
if (action == MenuAction_DrawItem)
{
return ITEMDRAW_DEFAULT;
}
else if(param2 == MenuCancel_ExitBack)
else if(param == MenuCancel_ExitBack)
{
ShowCookieMenu(param1);
ShowCookieMenu(client);
}
else if (action == MenuAction_Select)
{
switch (param2)
switch (param)
{
case 0:
{
SetClientCookie(param1, g_hCookie, "0");
Commamnd_RES(param1, 0);
SetClientCookie(client, g_hCookie, "0");
Commamnd_RES(client, 0);
}
case 1:
{
SetClientCookie(param1, g_hCookie, "1");
Commamnd_RES(param1, 0);
SetClientCookie(client, g_hCookie, "1");
Commamnd_RES(client, 0);
}
}
delete hMenu;
}
else if (action == MenuAction_End)
{
delete menu;
}
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions addons/sourcemod/scripting/ttt/ttt_shop.sp
Expand Up @@ -519,8 +519,8 @@ public Action Command_Shop(int client, int args)
int team = TTT_GetClientRole(client);
if (team != TTT_TEAM_UNASSIGNED)
{
Handle menu = CreateMenu(Menu_ShopHandler);
SetMenuTitle(menu, "%T", "TTT Shop", client, g_iCredits[client]);
Menu menu = new Menu(Menu_ShopHandler);
menu.SetTitle("%T", "TTT Shop", client, g_iCredits[client]);

char display[128];
int temp_item[Item];
Expand Down Expand Up @@ -563,13 +563,13 @@ public Action Command_Shop(int client, int args)
{
Format(display, sizeof(display), "%s - %d", temp_item[Long], price);
}
AddMenuItem(menu, temp_item[Short], display);
menu.AddItem(temp_item[Short], display);
}
}
}

SetMenuExitButton(menu, true);
DisplayMenu(menu, client, 15);
menu.ExitButton = true;
menu.Display(client, 15);
}
else
{
Expand Down

0 comments on commit 104d97d

Please sign in to comment.