Skip to content

Commit

Permalink
6.01.00172:Bugfix HUD
Browse files Browse the repository at this point in the history
Courseplay#3559
known issues: potato harvester is valid for mode 1 and 2 as well
  • Loading branch information
ThomasGaertner committed Apr 9, 2019
1 parent c6ab1ed commit 3cd6309
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 36 deletions.
2 changes: 1 addition & 1 deletion hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,7 @@ function courseplay.hud:showCpModeButtons(vehicle, show)
local fn, cpModeToCheck = button.functionToCall, button.parameter;
if fn == 'setCpMode'then
button:setShow(show);
button:setDisabled(not courseplay:getIsToolValidForCpMode(vehicle,cpModeToCheck))
button:setDisabled(not courseplay:getIsToolCombiValidForCpMode(vehicle,cpModeToCheck))
button:setActive(cpModeToCheck == vehicle.cp.mode)
end
end
Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="40">
<version>6.01.00171</version>
<version>6.01.00172</version>
<author><![CDATA[Courseplay.devTeam]]></author>
<title>
<br>CoursePlay SIX</br>
Expand Down
4 changes: 2 additions & 2 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function courseplay:changeWorkWidth(vehicle, changeBy, force, noDraw)
end;


function courseplay:changeSiloFillType(vehicle, modifyer, currentSelectedFilltype)
function courseplay:changeSiloFillType(vehicle, modifier, currentSelectedFilltype)
local eftl = vehicle.cp.easyFillTypeList;
local newVal = 1;
if currentSelectedFilltype and currentSelectedFilltype ~= FillType.UNKNOWN then
Expand All @@ -444,7 +444,7 @@ function courseplay:changeSiloFillType(vehicle, modifyer, currentSelectedFilltyp
end;
end;
else
newVal = vehicle.cp.siloSelectedEasyFillType + modifyer
newVal = vehicle.cp.siloSelectedEasyFillType + modifier
if newVal < 1 then
newVal = #eftl;
elseif newVal > #eftl then
Expand Down
77 changes: 45 additions & 32 deletions toolManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1865,42 +1865,55 @@ function courseplay:getAIMarkerWidth(object, logPrefix)
end
end

function courseplay:getIsToolValidForCpMode(vehicle,cpModeToCheck)
--3,8,9,10 are still disabled
function courseplay:getIsToolCombiValidForCpMode(vehicle,cpModeToCheck)
--5 is always valid
if cpModeToCheck == 5 then
return true;
elseif vehicle.cp.workToolAttached then
local modeValid = false
end
local modeValid = false
if vehicle.cp.workToolAttached then
for _, workTool in pairs(vehicle.cp.workTools) do
if ((cpModeToCheck == 1 or cpModeToCheck == 2) and workTool.spec_dischargeable and workTool.cp.capacity and workTool.cp.capacity > 0.1) then
modeValid = true;
elseif cpModeToCheck == 4 then
local isSprayer, isSowingMachine = courseplay:isSprayer(workTool), courseplay:isSowingMachine(workTool);
if isSprayer or isSowingMachine or workTool.cp.isTreePlanter or workTool.cp.isKuhnDC401 or workTool.cp.isKuhnHR4004 then
modeValid = true;
end
elseif cpModeToCheck == 6 then
if (courseplay:isBaler(workTool)
or courseplay:isBaleLoader(workTool)
or courseplay:isSpecialBaleLoader(workTool)
or workTool.cp.hasSpecializationCultivator
or courseplay:isCombine(workTool)
or workTool.cp.hasSpecializationFruitPreparer
or workTool.cp.hasSpecializationPlow
or workTool.cp.hasSpecializationTedder
or workTool.cp.hasSpecializationWindrower
or workTool.cp.hasSpecializationCutter
or workTool.spec_dischargeable
or courseplay:isMower(workTool)
or courseplay:isAttachedCombine(workTool)
or courseplay:isFoldable(workTool))
and not courseplay:isSprayer(workTool)
and not courseplay:isSowingMachine(workTool)
then
modeValid = true;
end
if courseplay:getIsToolValidForCpMode(workTool,cpModeToCheck) then
modeValid = true
end
end
return modeValid
end
if not modeValid then
modeValid = courseplay:getIsToolValidForCpMode(vehicle,cpModeToCheck)
end
return modeValid
end

function courseplay:getIsToolValidForCpMode(workTool,cpModeToCheck)
local modeValid = false
--3,8,9,10 are still disabled
if ((cpModeToCheck == 1 or cpModeToCheck == 2) and workTool.spec_dischargeable and workTool.cp.capacity and workTool.cp.capacity > 0.1) then
modeValid = true;
elseif cpModeToCheck == 4 then
local isSprayer, isSowingMachine = courseplay:isSprayer(workTool), courseplay:isSowingMachine(workTool);
if isSprayer or isSowingMachine or workTool.cp.isTreePlanter or workTool.cp.isKuhnDC401 or workTool.cp.isKuhnHR4004 then
modeValid = true;
end
elseif cpModeToCheck == 6 then
if (courseplay:isBaler(workTool)
or courseplay:isBaleLoader(workTool)
or courseplay:isSpecialBaleLoader(workTool)
or workTool.cp.hasSpecializationCultivator
or courseplay:isCombine(workTool)
or workTool.cp.hasSpecializationFruitPreparer
or workTool.cp.hasSpecializationPlow
or workTool.cp.hasSpecializationTedder
or workTool.cp.hasSpecializationWindrower
or workTool.cp.hasSpecializationCutter
--or workTool.spec_dischargeable
or courseplay:isMower(workTool)
or courseplay:isAttachedCombine(workTool)
or courseplay:isFoldable(workTool))
and not courseplay:isSprayer(workTool)
and not courseplay:isSowingMachine(workTool)
then
modeValid = true;
end
end
return modeValid ;
end

0 comments on commit 3cd6309

Please sign in to comment.