--
-- by Zippo
--

menu = {};

function menu.prerequisitesPresent(specializations)
    return true;
end;

function menu:load(xmlFile)
		print("Zippo Menu");
		local i = 0;
		self.menu = {};
    self.menuAn = false;
		while true do
			local menu = {};
			local objname = string.format("vehicle.menu.extramenu(%d)",i);
      local rotnode = getXMLString(xmlFile, objname .. "#rotNode");
      if rotnode == nil then 
      	break;
      end;
      menu = {};
      menu.rotNode = Utils.indexToObject(self.components, rotnode);
      
      if(menu.rotNode == nil or menu.light == nil) then
      	print("Error: Index ("..rotnode..") Error");
            	table.insert(self.menu, menu);
      end;
      i=i+1;
    end;
    self.menuAnz = table.getn(self.menu);
      
end;

function menu:delete()
end;

function menu:mouseEvent(posX, posY, isDown, isUp, button)
end;

function menu:keyEvent(unicode, sym, modifier, isDown)
end;

function menu:update(dt)
	
    if InputBinding.hasEvent(InputBinding.MENU) then
    	self.menuAn = not self.menuAn;
      for i=1, self.menuAnz do
        setVisibility(self.menu[i].light, self.menuAn);
      end;
    end;
    if self.menuAn then
      for i=1, self.menuAnz do
        setVisibility(self.menu[i].light, self.menuAn);
      end;
    end;
  end;


function menu:draw()
    if self.menuAnz > 0 and self:getIsActive() then
    		g_currentMission:addHelpButtonText(g_i18n:getText("menu"), InputBinding.MENU);
		if self.menuAn then
		renderText(0.8, 0.280, 0.02, "Forklift Menu");
		renderText(0.8, 0.255, 0.02, "Num Enter -> Motor An/Aus");
		renderText(0.8, 0.240, 0.02, "Num 7/4 -> Hubarm Hoch/Runter");
		renderText(0.8, 0.225, 0.02, "Num 9/6 -> Hubarm Kippen");
        renderText(0.8, 0.210, 0.02, "L -> Arbeitslicht");
        renderText(0.8, 0.195, 0.02, "R -> Rundumleuchte");
		renderText(0.8, 0.180, 0.02, "+ / - Drehzahlbegrenzer");
	end;
    end;
end;

