

myTest = {};


function myPrintText(text, text2, textWidth, unit)
	print(string.format("%s =  %s %s", text..string.rep(" ",textWidth-string.len(text)),text2,"    "..unit));
end;

function myPrintBoolean(text, boolean, textWidth, unit)
	print(string.format("%s =  %s %s", text..string.rep(" ",textWidth-string.len(text)),"   "..tostring(boolean),"    "..unit));
end;

function myPrintFillTypeName(iFillType, text)
	print(string.format("		RN2.fillTypeName[%d]       = \"%s\";", iFillType, text));
end;
function myPrintPricePerLiter(iFillType, number)
	print(string.format("		RN2.pricePerLiter[%d]      = %10.4f;", iFillType, number));
end;
function myPrintMassPerLiter(iFillType, number)
	print(string.format("		RN2.massPerLiter[%d]       = %10.4f;", iFillType, number));
end;
function myPrintFruitTypeName(iFruitType, text)
	print(string.format("		RN2.fruitTypeName[%d]      = \"%s\";", iFruitType, text));
end;
function myPrintLiterPerSqm(iFruitType, number)
	print(string.format("		RN2.literPerSqm[%d]        = %10.4f;", iFruitType, number));
end;
function myPrintSeedUsagePerSqm(iFruitType, number)
	print(string.format("		RN2.seedUsagePerSqm[%d]    = %10.4f;", iFruitType, number));
end;
function myPrintWindrowLiterPerSqm(iFruitType, number)
	print(string.format("		RN2.windrowLiterPerSqm[%d] = %10.4f;", iFruitType, number));
end;

function myPrintFieldInfo5(farmlandId, landArea,  landPrice, currency, owned)
	print(string.format("Farmland %3.0f: Land area = %4.1f ha,  Price = %7.0f %s, Ownership: %s",  farmlandId*1.0, landArea, landPrice*1.0, tostring(currency), tostring(owned)));
end;

function  myPrintFieldInfo6(fieldId, fieldArea, fruitName)
print(string.format("              Field %3.0f: Field area = %4.1f ha,   Fruit: %s",  fieldId*1.0, fieldArea, tostring(fruitName)));
end;

function myTest:loadMap()
end;

function myTest:keyEvent(unicode, sym, modifier, isDown)
	local currency = " ";
	local isDebug = true;
	local isDebug2 = false;
	local myFarmland = {};
	local myFarmlandTable = {};
	local lime = {};
	local soil = {};
	local idx = 0;
	local pen = {};
	local kmFee = 0;
	local objectFee = 0;
    local textWidth = 40;
	local Fruits = {"Wheat", "Barley", "Oat", "Cotton", "Canola", "Sunflower", "Soybean", "Maize", "Potato", "Sugarbeet", "Oilseed Radish", "Poplar","Grass","Drygrass","Sugarcane","Weed"};
	local gameMoneyUnit = g_i18n.moneyUnit;
	if gameMoneyUnit == 1 then
        currency = "€";
	elseif gameMoneyUnit == 2 then
        currency = "$";
	elseif gameMoneyUnit == 3 then
        currency = "£";
	end;



	if Input.isKeyPressed(Input.KEY_lalt) and Input.isKeyPressed(Input.KEY_r) and Input.isKeyPressed(Input.KEY_i) then
		print("Left Alt-ri pressed");
--		DebugUtil.printTableRecursively(g_fieldManager.farmlandIdFieldMapping,"_",0,5);
--		print("Day number : "..g_currentMission.environment.currentDay);				--working
--		DebugUtil.printTableRecursively(g_fieldManager,"_",0,10);						--working
--		DebugUtil.printTableRecursively(g_fillTypeManager,"_",0,4);
		DebugUtil.printTableRecursively(g_fruitTypeManager,"_",0,8);					--working
--		DebugUtil.printTableRecursively(g_helperManager,"_",0,3);						--working
--		DebugUtil.printTableRecursively(g_sprayTypeManager,"_",0,5);					--working
--		DebugUtil.printTableRecursively(g_farmManager,"_",0,5);
--		DebugUtil.printTableRecursively(g_farmlandManager,"_",0,8);
--		DebugUtil.printTableRecursively(g_currentMission,"_",0,8);
--		DebugUtil.printTableRecursively(g_currentMission.fruitsList,"_",0,8);
--		DebugUtil.printTableRecursively(g_currentMission.fruits,"_",0,4);
--		DebugUtil.printTableRecursively(g_currentMission.missionFruitTypes,"_",0,3);
--		DebugUtil.printTableRecursively(g_currentMission.displayCropTypes,"_",0,3);
--		DebugUtil.printTableRecursively(g_currentMission.missionInfo,"_",0,8);
--		DebugUtil.printTableRecursively(g_currentMission.masterUsers,"_",0,8);				-- nil
--		DebugUtil.printTableRecursively(g_currentMission.economyManager,"_",0,8);
--		DebugUtil.printTableRecursively(g_currentMission.shopController.storeManager,"_",0,4); -- nil
--		DebugUtil.printTableRecursively(g_currentMission.inGameMenu.pageShopVehicles ,"_",0,4);  -- nil
--		DebugUtil.printTableRecursively(g_currentMission.shopController.leasedFarmItems ,"_",0,3);
--		DebugUtil.printTableRecursively(g_currentMission.vehicles,"_",0,2);
--		DebugUtil.printTableRecursively(g_economyManager,"_",0,4);
--		DebugUtil.printTableRecursively(g_i18n,"_",0,4);								-- working but not much information
--		DebugUtil.printTableRecursively(g_missionManager.fieldToMission,"_",0,3);
--		DebugUtil.printTableRecursively(g_storeManager,"_",0,10);
--		DebugUtil.printTableRecursively(g_storeManager.items,"_",0,5);
--		DebugUtil.printTableRecursively(g_storeManager.shopController,"_",0,4); -- nil

	end;
--[[

	local farmland = {};
	local farmlandId = 0;
	local farmlandArea = 0;
	local farmlandPrice = 0;
	local farmlandIsOwned = false;

	local fieldId = 0;
	local fieldArea = 0;
	local fruitName = "Undefined";
	local fruitTypeIndex = 0;
	if Input.isKeyPressed(Input.KEY_lalt) and Input.isKeyPressed(Input.KEY_r) and Input.isKeyPressed(Input.KEY_t) then
		print("Left Alt-rt pressed");
		for k,v in pairs (g_fieldManager.farmlandIdFieldMapping) do
			for j,field in pairs (v) do
					farmland = field.farmland;
					farmlandId = farmland.id;
					farmlandArea = farmland.areaInHa;
					farmlandPrice = farmland.price;
					farmlandIsOwned = farmland.isOwned;
					if farmlandIsOwned then
						if RN.fieldStatus[farmlandId] == " For sale" then RN.fieldStatus[farmlandId] = " Owned   "; end;
						if RN.fieldStatus[farmlandId] == " For rent" then RN.fieldStatus[farmlandId] = " Rented  "; end;
					end;
			end;
			myPrintFieldInfo5(farmlandId, farmlandArea,  farmlandPrice, currency, RN.fieldStatus[farmlandId]);
			for j,field in pairs (v) do
				fieldId = field.fieldId;
				fieldArea = field.fieldArea;
				fruitTypeIndex = field.fruitType;
				if fruitTypeIndex == nil then
					fruitName = "Undefined";
				else
					fruitType = g_fruitTypeManager:getFruitTypeByIndex(fruitTypeIndex);
					fruitName = fruitType.name;

				end;
				myPrintFieldInfo6(fieldId, fieldArea, fruitName);
			end;
		end;
	end;
--]]
end;

function myTest:update(dt)
end;
function myTest:draw()
end;
function myTest:deleteMap()
end;
function myTest:mouseEvent(posX, posY, isDown, isUp, button)
end;

addModEventListener(myTest);
