Skip to content

Commit

Permalink
Some more adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Apr 6, 2024
1 parent 4d302d4 commit 44e6802
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 229 deletions.
37 changes: 13 additions & 24 deletions config/HudSettingsSetup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,28 @@

<Settings prefixText="CP_hud_settings_">
<SettingSubTitle title="basic">
<Setting classType="AIParameterSettingList" name="hudStartAt">
<Setting classType="AIParameterSettingList" name="selectedJob">
<Values>
<!-- Fieldwork -->
<Value name="START_AT_FIELDWORK_NEAREST_POINT" isDisabled="isFieldWorkModeDisabled">1</Value>
<Value name="START_AT_FIELDWORK_FIRST_POINT" isDisabled="isFieldWorkModeDisabled">2</Value>
<Value name="START_AT_FIELDWORK_LAST_POINT" isDisabled="isFieldWorkModeDisabled">3</Value>
<Value name="FIELDWORK_SELECTED" isDisabled="isFieldWorkModeDisabled">1</Value>
<!-- Bale Finder -->
<Value name="START_AT_BALE_FINDER" isDisabled="isBaleFinderModeDisabled">4</Value>
<Value name="BALE_FINDER_SELECTED" isDisabled="isBaleFinderModeDisabled">2</Value>
<!-- Bunker Silo -->
<Value name="START_AT_BUNKER_SILO" isDisabled="isBunkerSiloModeDisabled">5</Value>
<Value name="BUNKER_SILO_SELECTED" isDisabled="isBunkerSiloModeDisabled">3</Value>
<!-- Silo Loader -->
<Value name="START_AT_SILO_LOADING" isDisabled="isSiloLoadingModeDisabled">6</Value>
<Value name="SILO_LOADER_SELECTED" isDisabled="isSiloLoadingModeDisabled">4</Value>
<!-- Combine Unloader -->
<Value name="START_AT_UNLOADER_HARVESTER" isDisabled="isUnloaderModeDisabled">7</Value>
<Value name="START_AT_UNLOADER_LOADER" isDisabled="isUnloaderModeDisabled">8</Value>
<Value name="COMBINE_UNLOADER_SELECTED" isDisabled="isUnloaderModeDisabled">5</Value>
<!-- Street Driver -->
<Value name="START_AT_STREET_DRIVE_TO" isDisabled="isStreetModeDisabled">9</Value>
<Value name="START_AT_STREET_UNLOAD_OR_REFILL" isDisabled="isStreetModeDisabled">10</Value>
<Value name="START_AT_STREET_LOAD_AND_UNLOAD" isDisabled="isStreetModeDisabled">11</Value>

<Value name="STREET_DRIVER_SELECTED" isDisabled="isStreetModeDisabled">6</Value>
</Values>
<Texts>
<Text>fieldWork_nearest</Text>
<Text>fieldWork_first</Text>
<Text>fieldWork_last</Text>
<Text>baleFinder</Text>
<Text>bunkerSilo</Text>
<Text>siloLoader</Text>
<Text>unloader_harvester</Text>
<Text>unloader_loader</Text>
<Text>street_driveTo</Text>
<Text>street_unloadOrRefill</Text>
<Text>street_loadAndUnload</Text>
<Text prefix="false">CP_job_fieldWork</Text>
<Text prefix="false">CP_job_baleCollect</Text>
<Text prefix="false">CP_job_bunkerSilo</Text>
<Text prefix="false">CP_job_siloLoader</Text>
<Text prefix="false">CP_job_combineUnload</Text>
<Text prefix="false">CP_job_street</Text>
</Texts>
</Setting>
</SettingSubTitle>
Expand Down
50 changes: 3 additions & 47 deletions config/MasterTranslations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,53 +453,9 @@
</Translation>
</Category>
<Category name="Hud settings">
<Translation name="CP_hud_settings_hudStartAt_title">
<Text language="de"><![CDATA[TODO: CP AI Job:]]></Text>
<Text language="en"><![CDATA[TODO: CP AI Job:]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_fieldWork_first">
<Text language="de"><![CDATA[TODO: Feldarbeit: erster Wegpunkt]]></Text>
<Text language="en"><![CDATA[TODO: Feldarbeit: erster Wegpunkt]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_fieldWork_nearest">
<Text language="de"><![CDATA[TODO: Feldarbeit: nächster Wegpunkt]]></Text>
<Text language="en"><![CDATA[TODO: Feldarbeit: nächster Wegpunkt]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_fieldWork_last">
<Text language="de"><![CDATA[TODO: Feldarbeit: letzter Wegpunkt]]></Text>
<Text language="en"><![CDATA[TODO: Feldarbeit: letzter Wegpunkt]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_baleFinder">
<Text language="de"><![CDATA[TODO: Ballen sammeln]]></Text>
<Text language="en"><![CDATA[TODO: Ballen sammeln]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_bunkerSilo">
<Text language="de"><![CDATA[TODO: Bunkersilo]]></Text>
<Text language="en"><![CDATA[TODO: Bunkersilo]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_siloLoader">
<Text language="de"><![CDATA[TODO: Silo Lader]]></Text>
<Text language="en"><![CDATA[TODO: Silo Lader]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_unloader_harvester">
<Text language="de"><![CDATA[TODO: Drescher abladen]]></Text>
<Text language="en"><![CDATA[TODO: Drescher abladen]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_unloader_loader">
<Text language="de"><![CDATA[TODO: Lader abladen]]></Text>
<Text language="en"><![CDATA[TODO: Lader abladen]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_street_driveTo">
<Text language="de"><![CDATA[TODO: Drive to]]></Text>
<Text language="en"><![CDATA[TODO: Drive to]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_street_unloadOrRefill">
<Text language="de"><![CDATA[TODO: Unload or refill]]></Text>
<Text language="en"><![CDATA[TODO: Unload or refill]]></Text>
</Translation>
<Translation name="CP_hud_settings_hudStartAt_street_loadAndUnload">
<Text language="de"><![CDATA[TODO: Load and unload]]></Text>
<Text language="en"><![CDATA[TODO: Load and unload]]></Text>
<Translation name="CP_hud_settings_selectedJob_title">
<Text language="de"><![CDATA[TODO: Ausgewählter Job:]]></Text>
<Text language="en"><![CDATA[TODO: Selected Job:]]></Text>
</Translation>
</Category>
<Category name="Vehicle settings">
Expand Down
120 changes: 61 additions & 59 deletions scripts/gui/hud/CpBaseHud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CpBaseHud.headerFontSize = 14
CpBaseHud.titleFontSize = 20
CpBaseHud.defaultFontSize = 16

CpBaseHud.numLines = 7
CpBaseHud.numLines = 8

CpBaseHud.uvs = {
plusSymbol = {
Expand Down Expand Up @@ -168,7 +168,9 @@ function CpBaseHud:init(vehicle)
}
self.lines[i] = line
end

self.lines[self.numLines-1].left[2] = self.lines[self.numLines-1].left[2] - self.hMargin/2
self.lines[self.numLines-1].right[2] = self.lines[self.numLines-1].right[2] - self.hMargin/2
self.lines[self.numLines].right[2] = self.lines[self.numLines].right[2] - self.hMargin/4

local background = CpGuiUtil.createOverlay({self.width, self.height},
{g_baseUIFilename, g_colorBgUVs},
Expand Down Expand Up @@ -222,28 +224,34 @@ function CpBaseHud:init(vehicle)
self.BASE_COLOR,
self.alignments.bottomLeft)
self.cpIcon = CpHudButtonElement.new(cpIconOverlay, self.baseHud)
local x, y = unpack(self.lines[7].left)
local x, y = unpack(self.lines[8].left)
y = y - self.hMargin/4
self.cpIcon:setPosition(x, y)
self.cpIcon:setCallback("onClickPrimary", self.vehicle, function (vehicle)
self:openGlobalSettingsGui(vehicle)
end)

--- Title
local x, y = unpack(self.lines[7].left)
local x, y = unpack(self.lines[8].left)
x = x + cpIconWidth + self.wMargin/2
self.vehicleNameBtn = CpTextHudElement.new(self.baseHud , x , y, self.defaultFontSize)
self.vehicleNameBtn:setCallback("onClickPrimary", self.vehicle,
function()
self:openVehicleSettingsGui(self.vehicle)
end)

--- Starting point
self.startingPointBtn = self:addLeftLineTextButtonWithIcon(self.baseHud, 5, self.defaultFontSize,

self.selectedJobBtn = self:addLeftLineTextButton(self.baseHud, 7, self.defaultFontSize,
function (vehicle)
self:executeStartingPointBtnCallback(vehicle)
end, self.vehicle, 24, 24, "img/ui_courseplay.dds")

vehicle:cpGetHudSelectedJobSetting():setNextItem()
end, self.vehicle)

local x, y = unpack(self.lines[6].left)
local spacerLineOverlay = Overlay.new("dataS/scripts/shared/graph_pixel.png",
x, y, self.width - 2 * self.wMargin, self.hMargin/8)
spacerLineOverlay:setColor(unpack(self.OFF_COLOR))
spacerLineOverlay:setAlignment(Overlay.ALIGN_VERTICAL_MIDDLE)
local spacerLine = CpHudElement.new(spacerLineOverlay, self.baseHud)

--------------------------------------
--- Right side
--------------------------------------
Expand All @@ -257,7 +265,7 @@ function CpBaseHud:init(vehicle)
self.alignments.bottomRight)

self.exitBtn = CpHudButtonElement.new(exitBtnOverlay, self.baseHud)
local x, y = CpBaseHud.x + self.width -width/3 , CpBaseHud.y + self.height - headerHeight + self.hMargin/8
local x, y = CpBaseHud.x + self.width -width/3 , CpBaseHud.y + self.height - headerHeight + self.hMargin/12
self.exitBtn:setPosition(x, y)
self.exitBtn:setCallback("onClickPrimary", self.vehicle, function (vehicle)
vehicle:closeCpHud()
Expand All @@ -271,7 +279,7 @@ function CpBaseHud:init(vehicle)
self.OFF_COLOR,
self.alignments.bottomRight)
self.onOffButton = CpHudButtonElement.new(onOffIndicatorOverlay, self.baseHud)
local x, y = unpack(self.lines[6].right)
local x, y = unpack(self.lines[8].right)
self.onOffButton:setPosition(x, y)
self.onOffButton:setCallback("onClickPrimary", self.vehicle, function(vehicle)
vehicle:cpStartStopDriver(true)
Expand All @@ -285,7 +293,7 @@ function CpBaseHud:init(vehicle)
self.OFF_COLOR,
self.alignments.bottomRight)
self.startStopRecordingBtn = CpHudButtonElement.new(circleOverlay, self.baseHud)
local x, y = unpack(self.lines[6].right)
local x, y = unpack(self.lines[8].right)
x = x - onOffBtnWidth - self.wMargin/2
self.startStopRecordingBtn:setPosition(x, y)
self.startStopRecordingBtn:setCallback("onClickPrimary", self.vehicle, function (vehicle)
Expand All @@ -302,14 +310,28 @@ function CpBaseHud:init(vehicle)
self.OFF_COLOR,
self.alignments.bottomRight)
self.pauseRecordingBtn = CpHudButtonElement.new(circleOverlay, self.baseHud)
local x, y = unpack(self.lines[6].right)
local x, y = unpack(self.lines[8].right)
self.pauseRecordingBtn:setPosition(x, y)
self.pauseRecordingBtn:setCallback("onClickPrimary", self.vehicle, function (vehicle)
if vehicle:getIsCpCourseRecorderActive() then
vehicle:toggleCpCourseRecorderPause()
end
end)

--- Goal button.
local width, height = getNormalizedScreenValues(34, 34)
local goalOverlay = CpGuiUtil.createOverlay({width, height},
{AITargetHotspot.FILENAME, self.uvs.goalSymbol},
self.OFF_COLOR,
self.alignments.bottomRight)

self.goalBtn = CpHudButtonElement.new(goalOverlay, self.baseHud)
local x, y = unpack(self.lines[7].right)
self.goalBtn:setPosition(x, y - self.hMargin/4)
self.goalBtn:setCallback("onClickPrimary", vehicle, function (vehicle)
self:openCourseGeneratorGui(vehicle)
end)


---- Disables zoom, while mouse is over the cp hud.
local function disableCameraZoomOverHud(vehicle, superFunc, ...)
Expand Down Expand Up @@ -469,7 +491,6 @@ function CpBaseHud:isMouseOverArea(posX, posY)
end

function CpBaseHud:getActiveHudPage(vehicle)

if vehicle:cpIsHudFieldWorkJobSelected() then
return self.fieldworkLayout
elseif vehicle:cpIsHudBaleFinderJobSelected() then
Expand All @@ -480,10 +501,8 @@ function CpBaseHud:getActiveHudPage(vehicle)
return self.siloLoaderWorkerLayout
elseif vehicle:cpIsHudUnloaderJobSelected() then
return self.combineUnloaderLayout
elseif vehicle:cpIsHudDriveToJobSelected() then
return self.fieldworkLayout
else
return self.fieldworkLayout
elseif vehicle:cpIsHudStreetJobSelected() then
-- return self.fieldworkLayout
end
end

Expand Down Expand Up @@ -543,38 +562,33 @@ function CpBaseHud:updateContent(vehicle, status)
self.siloLoaderWorkerLayout:setDisabled(true)

local activeLayout = self:getActiveHudPage(vehicle)
activeLayout:setVisible(true)
activeLayout:setDisabled(false)
activeLayout:updateContent(vehicle, status)

local text, uvs = self:getStartingPointBtnTextAndIconUvs(vehicle)
if text ~= self.startingPointBtn:getText() then
self.startingPointBtn:setTextDetails(text)
self.startingPointBtn.icon:setUVs(uvs)
if activeLayout then
activeLayout:setVisible(true)
activeLayout:setDisabled(false)
activeLayout:updateContent(vehicle, status)
end
self.selectedJobBtn:setTextDetails(vehicle:cpGetHudSelectedJobSetting():getString())
end


function CpBaseHud:getStartingPointBtnTextAndIconUvs(vehicle)
local setting = vehicle:cpGetHudStartingPointSetting()
local uvs = self.uvs.fieldWorkSymbol
if vehicle:cpIsHudFieldWorkJobSelected() then
uvs = self.uvs.fieldWorkSymbol
elseif vehicle:cpIsHudBaleFinderJobSelected() then
uvs = self.uvs.baleFinderSymbol
elseif vehicle:cpIsHudBunkerSiloJobSelected() then
uvs = self.uvs.bunkerSymbol
elseif vehicle:cpIsHudSiloLoaderJobSelected() then
uvs = self.uvs.shovelSymbol
elseif vehicle:cpIsHudUnloaderJobSelected() then
uvs = self.uvs.unloaderSymbol
elseif vehicle:cpIsHudDriveToJobSelected() then
uvs = self.uvs.streetDriveToSymbol
else
uvs = self.uvs.streetLoadAndUnloadSymbol
end
return setting:getString(), GuiUtils.getUVs(unpack(uvs))
end
-- function CpBaseHud:getStartingPointBtnTextAndIconUvs(vehicle)
-- local setting = vehicle:cpGetHudSelectedJobSetting()
-- local uvs = self.uvs.fieldWorkSymbol
-- if vehicle:cpIsHudFieldWorkJobSelected() then
-- uvs = self.uvs.fieldWorkSymbol
-- elseif vehicle:cpIsHudBaleFinderJobSelected() then
-- uvs = self.uvs.baleFinderSymbol
-- elseif vehicle:cpIsHudBunkerSiloJobSelected() then
-- uvs = self.uvs.bunkerSymbol
-- elseif vehicle:cpIsHudSiloLoaderJobSelected() then
-- uvs = self.uvs.shovelSymbol
-- elseif vehicle:cpIsHudUnloaderJobSelected() then
-- uvs = self.uvs.unloaderSymbol
-- elseif vehicle:cpIsHudStreetJobSelected() then
-- uvs = self.uvs.streetDriveToSymbol
-- end
-- return setting:getString(), GuiUtils.getUVs(unpack(uvs))
-- end

function CpBaseHud:delete()
self.baseHud:delete()
Expand Down Expand Up @@ -604,18 +618,6 @@ function CpBaseHud:openGlobalSettingsGui(vehicle)
CpGuiUtil.openGlobalSettingsGui(vehicle)
end

function CpBaseHud:executeStartingPointBtnCallback(vehicle)
local setting = vehicle:cpGetHudStartingPointSetting()
setting:setNextItem()

-- local activeLayout = self:getActiveHudPage(vehicle)
-- if activeLayout and activeLayout.executeStartingPointBtnCallback then
-- activeLayout:executeStartingPointBtnCallback(vehicle)
-- else
-- vehicle:getCpStartingPointSetting():setNextItem()
-- end
end

--- Saves hud position.
function CpBaseHud.saveToXmlFile(xmlFile, baseKey)
if CpBaseHud.x ~= nil and CpBaseHud.y ~= nil then
Expand Down
Loading

0 comments on commit 44e6802

Please sign in to comment.