------------------------------------------------------------------
--								--
--			KoRi's BotMenu				--
--								--
------------------------------------------------------------------


UI.PageBotMenu=
{	
	keyBinds={},
	GUI=
	{	
		lap="0",
		darkerpane=
		{
			classname = "static",
			left = 15, top = 240, width = 90, height = 120,
			color = "0 0 0 128", zorder = 50,						
			halign=UIALIGN_CENTER, 
			fontsize = 10,
		},
		
		RC1text=
		{
			classname = "static",
			left = 20, top = 240, width = 80, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,				
			fontsize =10,
		},
		
		RC2text=
		{
			classname = "static",
			left = 20, top = 252, width = 80, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,				
			fontsize =10,
		},
		
		RC3text=
		{
			classname = "static",
			left = 20, top = 264, width = 80, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,				
			fontsize =10,
		},
		
		RC4text=
		{
			classname = "static",
			left = 20, top = 276, width = 80, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,					
			fontsize =10,
		},
		
		RC5text=
		{
			classname = "static",
			left = 20, top = 288, width = 80, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,					
			fontsize =10,
		},
		
		RC6text=
		{
			classname = "static",
			left = 20, top = 300, width = 80, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,					
			fontsize =10,
		},
		
		RC7text=
		{
			classname = "static",
			left = 20, top = 312, width = 80, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,					
			fontsize =10,
		},
		
		RC8text=
		{
			classname = "static",
			left = 20, top = 324, width = 75, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,					
			fontsize =10,
		},
		
		RC9text=
		{
			classname = "static",
			left = 20, top = 336, width = 75, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,					
			fontsize =10,
		},
		
		RC10text=
		{
			classname = "static",
			left = 20, top = 348, width = 75, height = 12,
			color = "0 0 0 0", zorder = 55,
			halign = UIALIGN_LEFT,					
			fontsize =10,
		},
		
		OnActivate = function(Sender)
			local ActionList = Game:GetActions();
			local LocalkeyBinds=UI.PageBotMenu.keyBinds;
			for i=0, 9 do
				LocalkeyBinds[i]={};
				for j, Action in ActionList do
					if (Action and Action.actionmaps[1]) then
						local bindings = Input:GetBinding(Action.actionmaps[1], Action.id);
						if(bindings[1] and (bindings[1].key == tostring(i)))then
							LocalkeyBinds[i].first = Action;
							Input:BindActionMultipleMaps(Action.name, "" , 0);
						end
						if(bindings[2] and bindings[2].key == tostring(i))then
							LocalkeyBinds[i].second = Action;     
							Input:BindActionMultipleMaps(Action.name, "" , 1);
						end
					end
				end
			end
			UI.PageBotMenu.keyBinds=LocalkeyBinds;
			UI:DeactivateScreen("BackScreen");
			UI.PageBotMenu.GUI.lap="0";
			Game:EnableUIOverlay(1, 0);
			UI.PageBotMenu.GUI.RC1text:SetText("1. Add Bot to Team...");
			UI.PageBotMenu.GUI.RC2text:SetText("2. $9Remove Bot from Team...");
			UI.PageBotMenu.GUI.RC3text:SetText("3. $9Fill Up Bots");
			UI.PageBotMenu.GUI.RC4text:SetText("4. $9Remove All Bots");
			UI.PageBotMenu.GUI.RC5text:SetText("");
			UI.PageBotMenu.GUI.RC6text:SetText("o. Exit");
			UI.PageBotMenu.GUI.RC7text:SetText("");
			UI.PageBotMenu.GUI.RC8text:SetText("");
			UI.PageBotMenu.GUI.RC9text:SetText("");
			UI.PageBotMenu.GUI.RC10text:SetText("");
			UI:HideMouseCursor();
		end,
		
		OnDeactivate = function(Sender)
			local LocalkeyBinds=UI.PageBotMenu.keyBinds;
			for i=0, 9 do
				if(LocalkeyBinds[i].first)then
					Input:BindActionMultipleMaps(LocalkeyBinds[i].first.name, tostring(i), 0);
				end 
				if(LocalkeyBinds[i].second)then
					Input:BindActionMultipleMaps(LocalkeyBinds[i].second.name, tostring(i), 1);
				end
			end
			Game:EnableUIOverlay(0, 0);
		end,
		
		OnUpdate = function(Sender)
			local szKeyName = Input:GetXKeyPressedName();
			if (szKeyName and ((tostring(szKeyName)=="esc") or (tostring(szKeyName)=="o") or ((tostring(szKeyName)>="1") and (tostring(szKeyName)<="9")))) then
				if UI.PageBotMenu.GUI.lap=="0" then
					if tostring(szKeyName)== "1" then
						UI.PageBotMenu.GUI.lap="1";
						UI.PageBotMenu.GUI.RC1text:SetText("1. $5Blue");
						UI.PageBotMenu.GUI.RC2text:SetText("2. $4Red");
						UI.PageBotMenu.GUI.RC3text:SetText("");
						UI.PageBotMenu.GUI.RC4text:SetText("o. Exit");
						UI.PageBotMenu.GUI.RC6text:SetText("");
					--elseif tostring(szKeyName)== "2" then
						--UI.PageBotMenu.GUI.lap="2";
						--UI.PageBotMenu.GUI.RC1text:SetText("1. $5Blue");
						--UI.PageBotMenu.GUI.RC2text:SetText("2. $4Red!");
						--UI.PageBotMenu.GUI.RC4text:SetText("o. Exit");												
					elseif tostring(szKeyName)== "3" then						
						--Client:SendCommand("BOT fill");
						--UI.PageBotMenu.GUI.OnDeactivate();						
					elseif tostring(szKeyName)== "4" then						
						--Client:SendCommand("BOT remove");
						--UI.PageBotMenu.GUI.OnDeactivate();
					elseif szKeyName=="o" then 
						UI.PageBotMenu.GUI.OnDeactivate();
					end
				elseif UI.PageBotMenu.GUI.lap=="1" then
					if tostring(szKeyName)== "1" then	
						Client:SendCommand("BOT addb");												
						UI.PageBotMenu.GUI.OnDeactivate();
					elseif tostring(szKeyName)== "2" then 
						Client:SendCommand("BOT addr");						
						UI.PageBotMenu.GUI.OnDeactivate();					
					elseif szKeyName=="o" then 
						UI.PageBotMenu.GUI.OnDeactivate();
					end
				elseif UI.PageBotMenu.GUI.lap=="2" then
					if tostring(szKeyName)== "1" then	
						Client:SendCommand("BOT remb");												
						UI.PageBotMenu.GUI.OnDeactivate();
					elseif tostring(szKeyName)== "2" then 
						Client:SendCommand("BOT remr");						
						UI.PageBotMenu.GUI.OnDeactivate();					
					elseif szKeyName=="o" then 
						UI.PageBotMenu.GUI.OnDeactivate();
					end
				end
			end
		end,
	},
};

UI:CreateScreenFromTable("BotMenu",UI.PageBotMenu.GUI);