upgrademgr = {}
-- weaponary
--- Primary 
---- laser
---- plasma
---- minigun
---- antigravitation gun
--- Primary upgrades
---- improved cooling (higher refiring)
---- improved energy usage (less energy)
---- autoaiming
--- secondary (mass)
---- bomb
---- seeker rockets
-- defense
--- improved shields
--- repulser


researchinfo = {
	{
		name = "Primary weapons",
		description = [[Primary weapons are using energy to shoot ...]],
		researched = true,
		
		category = {
			{
				name = "Laser",
				researched = true,
				
			},
		},
	},
	secondary = {
		name = "Secundary weapons"
	}
}

function upgrademgr:think()
	if game.player.destroyed then return 1 end
	if Keyboard.isKeyDown("Q") and game.pausetimeout>20 then
		local upgrade = Container:new(0,0,400,300)
		local function addlabel(x,y,w,h,tx,to)
			local text = (to or upgrade):add(Label:new(x,y,w,h,tx))
			text.colors = {}
			setmetatable(text.colors,{__index = Label.colors})
			text.colors.text = {0,1,0,1}
			text:setAlignment(nil,Label.LABEL_ALIGNTOP)
		end
		local function addrect (x,y,w,h)
			local line = (to or upgrade):add(ImageComponent:new(x,y,w,h,matsurface.vertexcolor()))
			line.l2d.image:color(0,1,0,1)
		end
		
		local function addbutton(x,y,w,h,tx,fun)
			local btn = (to or upgrade):add(Button:new(x,y,w,h,tx))
			btn.onClicked = fun
			btn:getSkin():setSkinColor(0,1,0,.3)
			btn:getSkin():setFontColor(0,1,0,1)
		end
		local dmg = {
			"none",
			"low",
			"\v990medium\vc",
			"\v950high\vc",
			"\v900critical\vc",
		}
		
		
		
		local dlev = math.floor((100-game.player.hp)/100*#dmg)+1
		addlabel(0,0,400,20,"Upgrade, research and information menu")
		addlabel(0,19,400,40,("Scrap parts: \vx70;%d\n"..
			"Damage: \vx70;%s"):format(game.player.extracounter,dmg[dlev] or "\v900off limit\vc"))
		addrect(0,16,400,1)
		addrect(0,50,400,1)
		addrect(0,299,400,1)
		
		local infoscreen = Container:new(0,0,400,220)
		
		
		addbutton(0,55,100,20,"Information")
		addbutton(100,55,100,20,"Research")
		addbutton(200,55,100,20,"Upgrade")
		addbutton(300,55,100,20,"Mounting")
		
		
		game : showMenu (upgrade)
	end
end

game:addthink(upgrademgr)