Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7603 from Courseplay/issue-7578
Browse files Browse the repository at this point in the history
Issue 7578
  • Loading branch information
Tensuko authored Nov 6, 2021
2 parents be50fd2 + 9cfa318 commit d092d76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ function courseplay:onUpdate(dt)
self.cp.driver:postInit()
end
self.cp.settings.driverMode:postInit()
--- Refreshes all field number settings on start,
--- as clients might have a corrupted version.
FieldNumberSetting.refreshOnStart()
self.cp.postInitDone = true
end

Expand Down
12 changes: 12 additions & 0 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2021,9 +2021,13 @@ end
--- Setting to select a field
---@class FieldNumberSetting : SettingList
FieldNumberSetting = CpObject(SettingList)
FieldNumberSetting.Settings = {}
function FieldNumberSetting:init(name, label, toolTip, vehicle)
local values, texts = self:loadFields()
SettingList.init(self, name, label, toolTip, vehicle, values, texts)
--- Store all instances of this setting in a global table,
--- for direct access to update their manual tool positions.
table.insert(FieldNumberSetting.Settings,self)
end

function FieldNumberSetting:loadFields()
Expand Down Expand Up @@ -2053,6 +2057,14 @@ function FieldNumberSetting:refresh()
self.current = math.min(self.current, #self.values)
end

--- Refreshes all field number settings on start,
--- as clients might have a corrupted version.
function FieldNumberSetting.refreshOnStart()
for _,setting in pairs(FieldNumberSetting.Settings) do
setting:refresh()
end
end

-- see above, refresh in case it was not initialized
function FieldNumberSetting:get()
if #self.values == 0 or self.current > #self.values then
Expand Down
2 changes: 1 addition & 1 deletion toolManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ end
---@param object table
---@param logPrefix string
function WorkWidthUtil.getShovelWorkWidth(object,logPrefix)
if object.spec_shovel then
if object.spec_shovel and object.spec_shovel.shovelNodes and object.spec_shovel.shovelNodes[1] then
local width = object.spec_shovel.shovelNodes[1].width
WorkWidthUtil.debug(object,logPrefix,'is a shovel with work width: %.1f',width)
return width
Expand Down

0 comments on commit d092d76

Please sign in to comment.