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

Commit

Permalink
Small fixes/changes
Browse files Browse the repository at this point in the history
- fixes #7312 partly
- created CourseDrawModeSetting
  • Loading branch information
schwiti6190 committed Jul 2, 2021
1 parent 63dfdf6 commit 5ccbae3
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 32 deletions.
2 changes: 1 addition & 1 deletion AIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1726,7 +1726,7 @@ end
--- without restarting the game.
function AIDriver:onDraw()
if CpManager.isDeveloper and self.course and
(self.vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_DBGONLY or self.vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_BOTH) then
self.settings.courseDrawMode:isCourseVisible() then
self.course:draw()
end
if CpManager.isDeveloper and self.pathfinder then
Expand Down
6 changes: 6 additions & 0 deletions FieldworkAIDriver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ function FieldworkAIDriver:stop(msgReference)
AIDriver.stop(self, msgReference)
end


function FieldworkAIDriver:setWorkFinished(msgReference)
self:stopWork()
AIDriver.setWorkFinished(self, msgReference)
end

function FieldworkAIDriver:writeUpdateStream(streamId, connection, dirtyMask)
if self.vehicle.cp.settings.convoyActive:is(true) then
streamWriteInt32(streamId,self.convoyCurrentDistance)
Expand Down
16 changes: 8 additions & 8 deletions base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -265,25 +265,25 @@ function courseplay:onLoad(savegame)

self.cp.mouseCursorActive = false;

-- 2D course
self.cp.drawCourseMode = courseplay.COURSE_2D_DISPLAY_OFF;
-- 2D pda map background -- TODO: MP?
if g_currentMission.hud.ingameMap and g_currentMission.hud.ingameMap.mapOverlay and g_currentMission.hud.ingameMap.mapOverlay.filename then
self.cp.course2dPdaMapOverlay = Overlay:new(g_currentMission.hud.ingameMap.mapOverlay.filename, 0, 0, 1, 1);
self.cp.course2dPdaMapOverlay:setColor(1, 1, 1, CpManager.course2dPdaMapOpacity);
end;

-- HUD
courseplay.hud:setupVehicleHud(self);

courseplay:validateCanSwitchMode(self);

---@type SettingsContainer
self.cp.settings = SettingsContainer.createVehicleSpecificSettings(self)

---@type SettingsContainer
self.cp.courseGeneratorSettings = SettingsContainer.createCourseGeneratorSettings(self)

-- HUD
courseplay.hud:setupVehicleHud(self);

courseplay:validateCanSwitchMode(self);


courseplay.signs:updateWaypointSigns(self);

courseplay:setAIDriver(self, self.cp.mode)
Expand Down Expand Up @@ -365,7 +365,7 @@ function courseplay:onDraw()
self.cp.hudBroken = true
end

if self.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_2DONLY or self.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_BOTH then
if self.cp.settings.courseDrawMode:isCourseMapVisible() then
courseplay:drawCourse2D(self, false);
end;
end; --END draw()
Expand Down Expand Up @@ -500,7 +500,7 @@ function courseplay:onUpdate(dt)
end


if self.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_DBGONLY or self.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_BOTH then
if self.cp.settings.courseDrawMode:isCourseVisible() then
courseplay:drawWaypointsLines(self);
end;

Expand Down
6 changes: 0 additions & 6 deletions courseplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,6 @@ local function setGlobalData()
courseplay.lights.HEADLIGHT_STREET = 1;
courseplay.lights.HEADLIGHT_FULL = 7;

-- 2D/debug lines display options
courseplay.COURSE_2D_DISPLAY_OFF = 0;
courseplay.COURSE_2D_DISPLAY_2DONLY = 1;
courseplay.COURSE_2D_DISPLAY_DBGONLY = 2;
courseplay.COURSE_2D_DISPLAY_BOTH = 3;

-- number separators
local langNumData = {
br = { '.', ',' },
Expand Down
16 changes: 5 additions & 11 deletions hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -563,15 +563,9 @@ function courseplay.hud:renderHud(vehicle)


-- 2D/DEBUG LINE BUTTON MODE
if vehicle.cp.drawCourseMode ~= courseplay.COURSE_2D_DISPLAY_OFF then
local txt;
if vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_2DONLY then
txt = '2D';
elseif vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_DBGONLY then
txt = '\nDBG';
else
txt = '2D\nDBG';
end;
local courseDrawModeSetting = vehicle.cp.settings.courseDrawMode
if not courseDrawModeSetting:isDeactivated() then
local txt = courseDrawModeSetting:getText()
courseplay:setFontSettings('white', true);
renderText(vehicle.cp.hud.changeDrawCourseModeButton.x + vehicle.cp.hud.changeDrawCourseModeButton.width * 0.5, self.topIconsY + self.fontSizes.version * 1.25, self.fontSizes.version, txt);
courseplay:setFontSettings('white', false);
Expand Down Expand Up @@ -1215,7 +1209,7 @@ function courseplay.hud:updatePageContent(vehicle, page)
else
self:showShowWaypointsButtons(vehicle, false)
end

vehicle.cp.hud.changeDrawCourseModeButton:setActive(not vehicle.cp.settings.courseDrawMode:isDeactivated())
-- make sure AutoDrive mode has all options currently available for the vehicle
vehicle.cp.settings.autoDriveMode:update()
self:setReloadPageOrder(vehicle, page, forceUpdate);
Expand Down Expand Up @@ -1376,7 +1370,7 @@ function courseplay.hud:setupVehicleHud(vehicle)

vehicle.cp.hud.saveCourseButton = courseplay.button:new(vehicle, 'global', { 'iconSprite.png', 'save' }, 'showSaveCourseForm', 'course', topIconsX[3], self.topIconsY, wMiddle, hMiddle, nil, nil, false, false, false, courseplay:loc('COURSEPLAY_SAVE_CURRENT_COURSE'));
vehicle.cp.hud.clearCurrentCourseButton = courseplay.button:new(vehicle, 'global', { 'iconSprite.png', 'courseClear' }, 'clearCurrentLoadedCourse', nil, topIconsX[0], self.topIconsY, wMiddle, hMiddle, nil, nil, false, false, false, courseplay:loc('COURSEPLAY_CLEAR_COURSE'));
vehicle.cp.hud.changeDrawCourseModeButton = courseplay.button:new(vehicle, 'global', { 'iconSprite.png', 'eye' }, 'changeDrawCourseMode', 1, self.col1posX, self.topIconsY, wMiddle, hMiddle, nil, -1, false, false, true);
vehicle.cp.hud.changeDrawCourseModeButton = courseplay.button:new(vehicle, 'global', { 'iconSprite.png', 'eye' }, 'changeByX', 1, self.col1posX, self.topIconsY, wMiddle, hMiddle, nil, -1, false, false, true):setSetting(vehicle.cp.settings.courseDrawMode)
self:setupCpModeButtons(vehicle)
self:setupRecordingButtons(vehicle)
self:setupCoursePageButtons(vehicle,2)
Expand Down
2 changes: 1 addition & 1 deletion input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function courseplay:onMouseEvent(posX, posY, isDown, isUp, mouseButton)

-- ##################################################
-- 2D COURSE WINDOW: DRAG + DROP MOVE
if vehicle.cp.course2dDrawData and (vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_2DONLY or vehicle.cp.drawCourseMode == courseplay.COURSE_2D_DISPLAY_BOTH) then
if vehicle.cp.course2dDrawData and vehicle.cp.settings.courseDrawMode:isCourseVisible() then
local plot = CpManager.course2dPlotField;
if isDown and mouseButton == courseplay.inputBindings.mouse.primaryButtonId and vehicle.cp.mouseCursorActive and vehicle:getIsEntered() and courseplay:mouseIsInArea(posX, posY, plot.x, plot.x + plot.width, plot.y, plot.y + plot.height) then
CpManager.course2dDragDropMouseDown = { posX, posY };
Expand Down
40 changes: 39 additions & 1 deletion settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,7 @@ end

--- The wait time setting can be incremented by 15 seconds up to max: 60min.
---
---@class WaitTimeSetting
---@class WaitTimeSetting : IntSetting
WaitTimeSetting = CpObject(IntSetting)
function WaitTimeSetting:init(vehicle)
local max = 3600 --- 60 min
Expand Down Expand Up @@ -3834,6 +3834,43 @@ function WaitTimeSetting:changeByX(x)
IntSetting.changeByX(self,x)
end

--- @class CourseDrawModeSetting : SettingList
CourseDrawModeSetting = CpObject(SettingList)
-- 2D/debug lines display options
CourseDrawModeSetting.COURSE_2D_DISPLAY_OFF = 0;
CourseDrawModeSetting.COURSE_2D_DISPLAY_2DONLY = 1;
CourseDrawModeSetting.COURSE_2D_DISPLAY_DBGONLY = 2;
CourseDrawModeSetting.COURSE_2D_DISPLAY_BOTH = 3;
function CourseDrawModeSetting:init(vehicle)
local values = {
self.COURSE_2D_DISPLAY_OFF,
self.COURSE_2D_DISPLAY_2DONLY,
self.COURSE_2D_DISPLAY_DBGONLY,
self.COURSE_2D_DISPLAY_BOTH
}
local texts = {
"",
"2D",
"\nDBG",
"2D\nDBG"
}
SettingList.init(self,"courseDrawMode","","",vehicle,values,texts)
self:set(self.COURSE_2D_DISPLAY_OFF)
self.syncValue = false
end

function CourseDrawModeSetting:isDeactivated()
return self:get() == self.COURSE_2D_DISPLAY_OFF
end

function CourseDrawModeSetting:isCourseMapVisible()
return self:get() == self.COURSE_2D_DISPLAY_2DONLY or self:get() == self.COURSE_2D_DISPLAY_BOTH
end

function CourseDrawModeSetting:isCourseVisible()
return self:get() == self.COURSE_2D_DISPLAY_DBGONLY or self:get() == self.COURSE_2D_DISPLAY_BOTH
end

--[[
---@class SearchCombineAutomaticallySetting : BooleanSetting
SearchCombineAutomaticallySetting = CpObject(BooleanSetting)
Expand Down Expand Up @@ -4029,6 +4066,7 @@ function SettingsContainer.createVehicleSpecificSettings(vehicle)
container:addSetting(WaitTimeSetting, vehicle)
container:addSetting(MixerWagonAIDriver_SiloSelectedFillTypeSetting, vehicle)
container:addSetting(MixerWagonToolPositionsSetting, vehicle)
container:addSetting(CourseDrawModeSetting,vehicle)
return container
end

Expand Down
5 changes: 1 addition & 4 deletions start_stop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,7 @@ function courseplay:stop(self)
courseplay:setEngineState(self, true);
self.cp.saveFuel = false;
end
if courseplay:getCustomTimerExists(self,'fuelSaveTimer') then
--print("reset existing timer")
courseplay:resetCustomTimer(self,'fuelSaveTimer',true)
end


if self.cp.directionNodeToTurnNodeLength ~= nil then
self.cp.directionNodeToTurnNodeLength = nil
Expand Down

0 comments on commit 5ccbae3

Please sign in to comment.