include("class.lua")
include("hud.lua")

BankInfoGauge = class(HudGauge)

function BankInfoGauge:init()
	self:move(0.05, 0.75)

    self:setClipping(false)
end

function BankInfoGauge:render()
	self:setupRendering()

	local primBank = self.script:getSubsystem():get().PrimaryBanks
	local secBank = self.script:getSubsystem():get().SecondaryBanks

	local currentBank = 0

	local x = 0
	local y = 0

	if (primBank:isValid()) then
		gr.setColor(0, 255, 0, 128)
		self:drawString("Primary weapons:", x, y)
		y = y + gr.CurrentFont.Height

		x = x + 15
		if (#primBank > 0) then
			for i=1, #primBank do
				local bank = primBank[i]
				currentBank = currentBank + 1

				self:drawString(bank.WeaponClass.Name, x, y)

				if (currentBank == self.scriptConfig:getCurrentWeaponBank()) then
                    self:drawRectangle(x - 15, y + gr.CurrentFont.Height * 0.1, x - 5, y + gr.CurrentFont.Height * 0.9)
                end
				y = y + gr.CurrentFont.Height
			end
		else
			self:drawString("<none>", x, y)
		end
		x = x - 15
	end

	if (secBank:isValid()) then
		gr.setColor(0, 128, 128, 128)
		y = y + 3
		self:drawString("Secondary Weapons:", x, y)
		y = y + gr.CurrentFont.Height

		x = x + 15
		if (#secBank > 0) then
			for i=1, #secBank do
				local bank = secBank[i]
				currentBank = currentBank + 1

				self:drawString(bank.WeaponClass.Name, x, y)

				if (currentBank == self.scriptConfig:getCurrentWeaponBank()) then
                    self:drawRectangle(x - 15, y + gr.CurrentFont.Height * 0.1, x - 5, y + gr.CurrentFont.Height * 0.9)
                end
				y = y + gr.CurrentFont.Height
			end
		else
			self:drawString("<none>", x, y)
		end
		x = x - 15
	end

	self:doneRendering()
end

function BankInfoGauge:shouldDraw()
	return not self.hudConfig:isShowingHelp()
end

function BankInfoGauge:getName()
	return "Weapon gauge"
end

function BankInfoGauge:getDescription()
	return "Shows the available weapons"
end

return BankInfoGauge
