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

Commit

Permalink
6.01.00173 Calculate work width added to course gen screen
Browse files Browse the repository at this point in the history
  • Loading branch information
pvaiko committed Apr 10, 2019
1 parent 3cd6309 commit 17fc309
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 124 deletions.
27 changes: 23 additions & 4 deletions course-generator/CourseGeneratorScreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local CourseGeneratorScreen_mt = Class(CourseGeneratorScreen, ScreenElement)
CourseGeneratorScreen.SHOW_NOTHING = 0
CourseGeneratorScreen.SHOW_FULL_MAP = 1
CourseGeneratorScreen.SHOW_SELECTED_FIELD = 2
CourseGeneratorScreen.WidthFormatString = '%.1f m'

-- these are needed to be able to access those screen elements with self.<id>
CourseGeneratorScreen.CONTROLS = {
Expand All @@ -15,6 +16,7 @@ CourseGeneratorScreen.CONTROLS = {
rowDirectionMode = 'rowDirectionMode',
manualDirectionAngle = 'manualDirectionAngle',
width = 'width',
autoWidth = 'autoWidth',
islandBypassMode = 'islandBypassMode',
headlandDirection = 'headlandDirection',
headlandCorners = 'headlandCorners',
Expand Down Expand Up @@ -189,12 +191,11 @@ end
function CourseGeneratorScreen:onOpenWidth( element )
local texts = {}
self.minWidth, self.maxWidth = 1, 50
local formatString = '%.1f m'
local w = self.vehicle.cp.workWidth
-- have at most 3 values in the text box around the selected
if w > self.minWidth then table.insert( texts, string.format(formatString, w - 0.1)) end
table.insert(texts, string.format(formatString, w))
if w < self.maxWidth then table.insert( texts, string.format(formatString, w + 0.1)) end
if w > self.minWidth then table.insert( texts, string.format(CourseGeneratorScreen.WidthFormatString, w - 0.1)) end
table.insert(texts, string.format(CourseGeneratorScreen.WidthFormatString, w))
if w < self.maxWidth then table.insert( texts, string.format(CourseGeneratorScreen.WidthFormatString, w + 0.1)) end
element:setTexts(texts)
if w == self.minWidth then
element:setState(1)
Expand All @@ -212,6 +213,24 @@ function CourseGeneratorScreen:onClickWidth( state )
self:onOpenWidth(self.width)
end

function CourseGeneratorScreen:onOpenAutoWidth(element)
local autoWidth = courseplay:getWorkWidth(self.vehicle)
if autoWidth > 0 then
element:setVisible(true)
element:setText(string.format(CourseGeneratorScreen.WidthFormatString, courseplay:getWorkWidth(self.vehicle)))
else
element:setVisible(false)
end
end

function CourseGeneratorScreen:onClickAutoWidth(state)
local autoWidth = courseplay:getWorkWidth(self.vehicle)
if autoWidth > 0 then
self.vehicle.cp.workWidth = autoWidth
self:onOpenWidth(self.width)
end
end

function CourseGeneratorScreen:onScrollWidth(element, isDown, isUp, button)
local eventUsed = false
if isDown and button == Input.MOUSE_BUTTON_WHEEL_UP then
Expand Down
Loading

1 comment on commit 17fc309

@frka85
Copy link

@frka85 frka85 commented on 17fc309 Apr 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where i can find calculator of fields (how big field is and how many each seed i need)?

Please sign in to comment.