Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework parking UI #1986

Open
wants to merge 3 commits into
base: beta-testing
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
first version final
  • Loading branch information
Dueesberch committed Jun 15, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7f6f05aabdc268bf6e4760d7c7a37ead1adbc8c2
8 changes: 4 additions & 4 deletions FS19_AutoDrive/gui/setRmParkDestinationGUI.xml
Original file line number Diff line number Diff line change
@@ -8,12 +8,12 @@
<GuiElement type="text" profile="dialogHeaderText" text="$l10n_gui_ad_setRmParkDestinationTitle" />
</GuiElement>

<GuiElement type="text" profile="sleepDialogText" text="$l10n_gui_ad_setRmParkDestinationText" />
<GuiElement type="text" profile="sleepDialogText" id="setRmParkDestinationText" text="" position="5px 4px"/>
<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" />
<GuiElement type="button" profile="buttonCancel" text="$l10n_button_rm" onClick="onClickCancel" />
<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>
90 changes: 58 additions & 32 deletions FS19_AutoDrive/scripts/Gui/SetRmParkDestinationGUI.lua
Original file line number Diff line number Diff line change
@@ -6,81 +6,107 @@
-- @date 09/06/2019

ADSetRmParkDestinationGui = {}
ADSetRmParkDestinationGui.CONTROLS = {"setRmParkDestinationText"}
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
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.setRmParkDestinationText.blockTime = 0
self.setRmParkDestinationText:onFocusActivate()
local actualParkDestination = -1
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
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.setRmParkDestinationText:setText(selectedWorkTool:getFullName())
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()
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()
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)
ADSetRmParkDestinationGui:superClass().onClickBack(self)
end

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

function ADSetRmParkDestinationGui:onEscPressed()
self:onClickBack()
self:onClickBack()
end
7 changes: 5 additions & 2 deletions FS19_AutoDrive/translations/translation_de.xml
Original file line number Diff line number Diff line change
@@ -327,9 +327,12 @@
<text name="AD_task_drive_to_park" text="Fahre zum Parkplatz" />

<text name="gui_ad_setRmParkDestinationTitle" text="Setze / Lösche Parkplatz" />
<text name="gui_ad_setRmParkDestinationText" text="Benutze Parkplatz von:" />
<text name="gui_ad_currentParkDestinationText" text="Aktueller Parkplatz " />
<text name="gui_ad_noCurrentParkDestinationText" text="Kein Parkplatz zugewiesen " />
<text name="gui_ad_selectedMarkerText" text="Ausgewähltes Ziel: " />
<text name="button_set" text="Setze" />
<text name="button_rm" text="Lösche" />
<text name="button_rm" text="Löschen" />
<text name="gui_ad_targetEmpty" text="Kein Ziel ausgewählt" />

<text name = "gui_CPAD_off" text = "aus"/>
<text name = "gui_CPAD_simple" text = "einfach"/>
4 changes: 3 additions & 1 deletion FS19_AutoDrive/translations/translation_en.xml
Original file line number Diff line number Diff line change
@@ -327,7 +327,9 @@
<text name="AD_task_drive_to_park" text="Drive to parking place" />

<text name="gui_ad_setRmParkDestinationTitle" text="Set / Remove Park Destination" />
<text name="gui_ad_setRmParkDestinationText" text="Use park destination from:" />
<text name="gui_ad_currentParkDestinationText" text="Current park destination: " />
<text name="gui_ad_noCurrentParkDestinationText" text="No park destination set" />
<text name="gui_ad_selectedMarkerText" text="Selected destination: " />
<text name="button_set" text="Set" />
<text name="button_rm" text="Remove" />