Skip to content

Commit

Permalink
Added DeleteAll
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexer10 committed Feb 10, 2018
1 parent c6e1a30 commit 7836305
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions addons/sourcemod/scripting/hexprops.sp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ Menu CreateMainMenu(int client)
MainMenu.AddItem("Edit", "Edit Props");
MainMenu.AddItem("Safe", "Save Props");
MainMenu.AddItem("Move", sEditDisplay);
MainMenu.AddItem("Reset", "Reset Props");
MainMenu.AddItem("Reset", "Reset Props");
MainMenu.AddItem("DeleteAll", "Delete All Props");

return MainMenu;
}
Expand Down Expand Up @@ -185,6 +186,22 @@ Menu CreateEditMenu()
EditMenu.ExitBackButton = true;

return EditMenu;
}

Menu CreateDeleteAllMenu()
{
Menu DeleteAllMenu = new Menu(Handler_DeleteAll);

DeleteAllMenu.SetTitle("Are you sure?");

DeleteAllMenu.AddItem("", "If you want to go back", ITEMDRAW_DISABLED);
DeleteAllMenu.AddItem("", "after you deleted the props", ITEMDRAW_DISABLED);
DeleteAllMenu.AddItem("", "press Reset Props and do NOT save the props!", ITEMDRAW_DISABLED);
DeleteAllMenu.AddItem("0", "NO");
DeleteAllMenu.AddItem("1", "YES");

DeleteAllMenu.ExitBackButton = true;
return DeleteAllMenu;
}

Menu CreateColorMenu()
Expand Down Expand Up @@ -321,11 +338,15 @@ public int Handler_Main(Menu menu, MenuAction action, int param1, int param2)
}
CreateMainMenu(param1).Display(param1, MENU_TIME_FOREVER);
}
else
else if (StrEqual(info, "Reset"))
{
ResetProps();
PrintToChat(param1, "[HexProps] Props successfully resetted!");
CreateMainMenu(param1).Display(param1, MENU_TIME_FOREVER);
}
else
{
CreateDeleteAllMenu().Display(param1, 20);
}
}
else if (action == MenuAction_End)
Expand Down Expand Up @@ -395,6 +416,39 @@ public int Handler_Edit(Menu menu, MenuAction action, int param1, int param2)
{
delete menu;
}
}

public int Handler_DeleteAll(Menu menu, MenuAction action, int param1, int param2)
{
if (action == MenuAction_Select)
{
char info[64];
menu.GetItem(param2, info, sizeof(info));
bool bDelete = view_as<bool>(StringToInt(info));

if (bDelete)
{
if (!PropKv.GotoFirstSubKey())
SetFailState("- HexProps - Failed to read: %s", sPropPath);
do
{
PropKv.DeleteThis();
}
while (PropKv.GotoNextKey());
PropKv.Rewind();

ReplyToCommand(param1, "[SM] Props deleted!");
}
CreateMainMenu(param1).Display(param1, MENU_TIME_FOREVER);
}
else if (action == MenuAction_Cancel)
{
CreateEditMenu().Display(param1, MENU_TIME_FOREVER);
}
else if (action == MenuAction_End)
{
delete menu;
}
}

public int Handler_Color(Menu menu, MenuAction action, int param1, int param2)
Expand Down

0 comments on commit 7836305

Please sign in to comment.