Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions FS19_AutoDrive/gui/setRmParkDestinationGUI.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<GUI onOpen="onOpen" onClose="onClose" onCreate="onCreate">
<GuiElement type="empty" profile="newLayer" />
<GuiElement type="bitmap" profile="dialogFullscreenBg" />

<GuiElement type="bitmap" profile="yesNoDialogBg">
<GuiElement type="bitmap" profile="dialogHeaderDocked">
<GuiElement type="text" profile="dialogHeaderText" text="$l10n_gui_ad_setRmParkDestinationTitle" />
</GuiElement>

<GuiElement type="text" profile="sleepDialogText" id="SelectedWorktoolText" text="" />
<GuiElement type="text" profile="sleepDialogText" id="CurrentParkDestinationText" text="" position="0px 0px"/>

<GuiElement type="flowLayout" profile="buttonBoxDocked">
<GuiElement type="button" profile="buttonOK" text="$l10n_button_set" onClick="onClickOk" id="Button_ok" />
<GuiElement type="button" profile="buttonCancel" text="$l10n_button_rm" onClick="onClickCancel" id="Button_cancel" />
<GuiElement type="button" profile="buttonBack" text="$l10n_button_back" onClick="onClickBack" />
</GuiElement>
</GuiElement>
</GUI>
1 change: 1 addition & 0 deletions FS19_AutoDrive/register.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ source(Utils.getFilename("scripts/Gui/ExperimentalFeaturesSettingsPage.lua", g_c
source(Utils.getFilename("scripts/Gui/Settings.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Gui/TipOfTheDayGUI.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/TipOfTheDayHandler.lua", g_currentModDirectory))
source(Utils.getFilename("scripts/Gui/SetRmParkDestinationGUI.lua", g_currentModDirectory))

AutoDriveRegister = {}
AutoDriveRegister.version = g_modManager:getModByName(g_currentModName).version
Expand Down
8 changes: 8 additions & 0 deletions FS19_AutoDrive/scripts/Gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function AutoDrive:loadGUI()
AutoDrive.gui.ADRoutesManagerGui = ADRoutesManagerGui:new()
AutoDrive.gui.ADNotificationsHistoryGui = ADNotificationsHistoryGui:new()
AutoDrive.gui.ADTipOfTheDayGUI = ADTipOfTheDayGUI:new()
AutoDrive.gui.ADSetRmParkDestinationGui = ADSetRmParkDestinationGui:new()

g_gui:loadGui(AutoDrive.directory .. "gui/enterDriverNameGUI.xml", "ADEnterDriverNameGui", AutoDrive.gui.ADEnterDriverNameGui)
g_gui:loadGui(AutoDrive.directory .. "gui/enterTargetNameGUI.xml", "ADEnterTargetNameGui", AutoDrive.gui.ADEnterTargetNameGui)
Expand All @@ -18,6 +19,7 @@ function AutoDrive:loadGUI()
g_gui:loadGui(AutoDrive.directory .. "gui/routesManagerGUI.xml", "ADRoutesManagerGui", AutoDrive.gui.ADRoutesManagerGui)
g_gui:loadGui(AutoDrive.directory .. "gui/notificationsHistoryGUI.xml", "ADNotificationsHistoryGui", AutoDrive.gui.ADNotificationsHistoryGui)
g_gui:loadGui(AutoDrive.directory .. "gui/tipOfTheDayGUI.xml", "ADTipOfTheDayGui", AutoDrive.gui.ADTipOfTheDayGUI)
g_gui:loadGui(AutoDrive.directory .. "gui/setRmParkDestinationGUI.xml", "ADSetRmParkDestinationGui", AutoDrive.gui.ADSetRmParkDestinationGui)

AutoDrive.gui.ADSettingsPage = ADSettingsPage:new()
AutoDrive.gui.ADUserSettingsPage = ADSettingsPage:new()
Expand Down Expand Up @@ -102,3 +104,9 @@ function AutoDrive.onOpenTipOfTheDay()
g_gui:showGui("ADTipOfTheDayGui")
end
end

function AutoDrive.onOpenSetRmParkDestination()
if not AutoDrive.gui.ADSetRmParkDestinationGui.isOpen then
g_gui:showGui("ADSetRmParkDestinationGui")
end
end
112 changes: 112 additions & 0 deletions FS19_AutoDrive/scripts/Gui/SetRmParkDestinationGUI.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
--
-- AutoDrive Enter Driver Name GUI
-- V1.1.0.0
--
-- @author Stephan Schlosser
-- @date 09/06/2019

ADSetRmParkDestinationGui = {}
ADSetRmParkDestinationGui.CONTROLS = {"SelectedWorktoolText", "CurrentParkDestinationText", "Button_ok", "Button_cancel"}
selectedWorkTool = nil
vehicle = nil
firstMarkerID = nil

local ADSetRmParkDestinationGui_mt = Class(ADSetRmParkDestinationGui, ScreenElement)

function ADSetRmParkDestinationGui:new(target)
local o = ScreenElement:new(target, ADSetRmParkDestinationGui_mt)
o.returnScreenName = ""
o.textInputElement = nil
o:registerControls(ADSetRmParkDestinationGui.CONTROLS)
return o
end

function ADSetRmParkDestinationGui:onOpen()
ADSetRmParkDestinationGui:superClass().onOpen(self)
self.CurrentParkDestinationText.blockTime = 0
self.CurrentParkDestinationText:onFocusActivate()
self.SelectedWorktoolText.blockTime = 0
self.SelectedWorktoolText:onFocusActivate()
local actualParkDestination = -1

vehicle = g_currentMission.controlledVehicle

if vehicle ~= nil and vehicle.ad ~= nil and vehicle.ad.stateModule ~= nil and vehicle.ad.stateModule:getFirstMarker() ~= nil then
firstMarkerID = vehicle.ad.stateModule:getFirstMarkerId()
if firstMarkerID > 0 then
local mapMarker = ADGraphManager:getMapMarkerById(firstMarkerID)
-- do not allow to set debug marker as park destination
if mapMarker ~= nil and mapMarker.isADDebug ~= true then
self.Button_ok:setText(g_i18n:getText("button_set") .. " " .. mapMarker.name)
selectedWorkTool = AutoDrive.getSelectedWorkTool(vehicle)

if selectedWorkTool == nil then
-- no attachment selected, so use the vehicle itself
selectedWorkTool = vehicle
end

if selectedWorkTool ~= nil then
self.Button_ok:setDisabled(false)
self.SelectedWorktoolText:setText(selectedWorkTool:getFullName())
if selectedWorkTool.advd.parkDestination ~= -1 then
self.CurrentParkDestinationText:setText(g_i18n:getText("gui_ad_currentParkDestinationText") .. ADGraphManager:getMapMarkerById(selectedWorkTool.advd.parkDestination).name)
self.Button_cancel:setDisabled(false)
else
self.CurrentParkDestinationText:setText(g_i18n:getText("gui_ad_noCurrentParkDestinationText"))
self.Button_cancel:setDisabled(true)
end
end
else
self.SelectedWorktoolText:setText(g_i18n:getText("gui_ad_targetEmpty"))
self.CurrentParkDestinationText:setText("")
self.Button_ok:setDisabled(true)
self.Button_cancel:setDisabled(true)
end
else
self.SelectedWorktoolText:setText(g_i18n:getText("gui_ad_targetEmpty"))
self.CurrentParkDestinationText:setText("")
self.Button_ok:setDisabled(true)
self.Button_cancel:setDisabled(true)
end
else
self.SelectedWorktoolText:setText(g_i18n:getText("gui_ad_targetEmpty"))
self.CurrentParkDestinationText:setText("")
self.Button_ok:setDisabled(true)
self.Button_cancel:setDisabled(true)
end
end

-- set destination
function ADSetRmParkDestinationGui:onClickOk()
ADSetRmParkDestinationGui:superClass().onClickOk(self)
if g_currentMission.controlledVehicle ~= nil then
if vehicle.advd ~= nil then
vehicle.advd:setParkDestination(selectedWorkTool, firstMarkerID)
end
end
self:onClickBack()
end

-- rm destination
function ADSetRmParkDestinationGui:onClickCancel()
if g_currentMission.controlledVehicle ~= nil and g_currentMission.controlledVehicle.ad ~= nil then
if vehicle.advd ~= nil then
vehicle.advd:setParkDestination(selectedWorkTool, -1)
end
end
self:onClickBack()
end

function ADSetRmParkDestinationGui:onClickBack()
ADSetRmParkDestinationGui:superClass().onClickBack(self)
end

function ADSetRmParkDestinationGui:onEnterPressed(_, isClick)
if not isClick then
self:onClickOk()
end
end

function ADSetRmParkDestinationGui:onEscPressed()
self:onClickBack()
end
2 changes: 1 addition & 1 deletion FS19_AutoDrive/scripts/Manager/InputManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function ADInputManager:input_decLoopCounter(vehicle)
end

function ADInputManager:input_setParkDestination(vehicle)
AutoDrive.setActualParkDestination(vehicle)
AutoDrive.onOpenSetRmParkDestination(vehicle)
end

function ADInputManager:input_silomode(vehicle)
Expand Down
Loading