Skip to content

Commit

Permalink
Merge pull request #2 from Courseplay/Gui-Additions
Browse files Browse the repository at this point in the history
WIP GUI
  • Loading branch information
Tensuko authored Dec 6, 2024
2 parents 2d9ec4b + 388d1f7 commit ae93b9b
Show file tree
Hide file tree
Showing 47 changed files with 2,075 additions and 171 deletions.
14 changes: 14 additions & 0 deletions config/MasterTranslations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@
<Text language="de"><![CDATA[Fahrzeugeinstellungen für (%s)]]></Text>
<Text language="en"><![CDATA[Vehicle settings for (%s)]]></Text>
</Translation>
<Translation name="CP_vehicle_setting_subTitle_vehicle">
<Text language="de"><![CDATA[Fahrzeugeinstellungen]]></Text>
<Text language="en"><![CDATA[Vehicle settings]]></Text>
</Translation>
<Translation name="CP_vehicle_setting_subTitle_basic">
<Text language="de"><![CDATA[Grundeinstellungen]]></Text>
<Text language="en"><![CDATA[Basic settings]]></Text>
Expand Down Expand Up @@ -873,6 +877,10 @@
<Text language="de"><![CDATA[Grundeinstellungen]]></Text>
<Text language="en"><![CDATA[Basic settings]]></Text>
</Translation>
<Translation name="CP_vehicle_courseGeneratorSetting_subTitle_vineField">
<Text language="de"><![CDATA[Weinfeld Einstellungen]]></Text>
<Text language="en"><![CDATA[Vine field settings]]></Text>
</Translation>
<Translation name="CP_vehicle_courseGeneratorSetting_subTitle_headland">
<Text language="de"><![CDATA[Einstellungen Vorgewende]]></Text>
<Text language="en"><![CDATA[Settings headland]]></Text>
Expand Down Expand Up @@ -1823,6 +1831,12 @@ The course is saved automatically on closing of the editor and overrides the sel
<Text language="en"><![CDATA[Unpause custom field recording]]></Text>
</Translation>
</Category>
<Category name="CP ingame menu">
<Translation name="CP_ingameMenu_map_title">
<Text language="de"><![CDATA[Karte]]></Text>
<Text language="en"><![CDATA[Map]]></Text>
</Translation>
</Category>
<Category name="Help menu">
<Translation name="CP_help_title">
<Text language="de"><![CDATA[Courseplay]]></Text>
Expand Down
4 changes: 2 additions & 2 deletions config/VehicleSettingsSetup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
</Texts>
</Setting>
<Setting classType="AIParameterSettingList" name="pipeOffsetX" min="-100" max="100" incremental="0.1" default="0" unit="2" precision="3"
isVisible="isPipeOffsetSettingsVisible"/>
isVisible="isPipeOffsetSettingsVisible" title="CP_deactivated"/>
<Setting classType="AIParameterSettingList" name="pipeOffsetZ" min="-100" max="100" incremental="0.1" default="0" unit="2" precision="3"
isVisible="isPipeOffsetSettingsVisible"/>
isVisible="isPipeOffsetSettingsVisible" title="CP_deactivated"/>
</SettingSubTitle>

<SettingSubTitle title="seeder" isVisible="areSowingMachineSettingsVisible">
Expand Down
562 changes: 548 additions & 14 deletions config/gui/pages/CourseGeneratorFrame.xml

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions config/gui/pages/CourseManagerFrame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
<Text profile="fs25_statisticsHeaderText" size="340px 104px" id="leftColumnHeader" />
</BoxLayout> -->

<SmoothList profile="fs25_pricesProductList" id="leftList" focusChangeTop="nil" focusChangeBottom="nil" selectedWithoutFocus="true">
<SmoothList profile="cpLeftList" id="leftList" focusChangeTop="nil" focusChangeBottom="nil" selectedWithoutFocus="true">
<ListItem profile="fs25_pricesProductListItem">
<Bitmap name="icon" profile="fs25_pricesProductListItemIcon" />
<Text name="title" profile="fs25_pricesProductListItemName" />
</ListItem>
</SmoothList>

<ThreePartBitmap profile="fs25_pricesProductListSliderBox">
<ThreePartBitmap profile="cpLeftListSliderBox">
<Slider profile="fs25_listSlider" dataElementId="leftList" id="leftListSlider" />
</ThreePartBitmap>
</GuiElement>
Expand All @@ -59,14 +59,14 @@
<Text profile="fs25_statisticsHeaderText" size="330px 104px" id="rightColumnHeader" />
</BoxLayout> -->

<SmoothList profile="fs25_pricesPriceList" id="rightList" focusChangeTop="nil" focusChangeBottom="nil">
<SmoothList profile="cpRightList" id="rightList" focusChangeTop="nil" focusChangeBottom="nil">
<ListItem profile="fs25_pricesPriceListItem">
<Bitmap name="icon" profile="fs25_pricesPriceListItemHotspot" />
<Text name="title" profile="fs25_pricesPriceListItemName" />
</ListItem>
</SmoothList>

<ThreePartBitmap profile="fs25_pricesPriceSliderBox">
<ThreePartBitmap profile="cpRightListSliderBox">
<Slider profile="fs25_listSlider" dataElementId="rightList" id="rightListSlider" />
</ThreePartBitmap>
</GuiElement>
Expand All @@ -93,9 +93,9 @@
<imageColor value="$preset_colorWhite_50" />
<imageSliceId value="gui.prices_buying" />
</Profile>
<Profile name="fs25_pricesProductList" extends="emptyPanel"
<Profile name="cpLeftList" extends="emptyPanel"
with="anchorStretchingYLeft pivotTopLeft">
<width value="396px" />
<width value="695px" />
<absoluteSizeOffset value="0px 56px" />
<position value="25px -56px" />
</Profile>
Expand All @@ -122,13 +122,13 @@
<textOffset value="-10px 0px" />
<textAlignment value="right" />
</Profile>
<Profile name="fs25_pricesProductListSliderBox" extends="fs25_listSliderBox"
<Profile name="cpLeftListSliderBox" extends="fs25_listSliderBox"
with="anchorTopLeft">
<absoluteSizeOffset value="0px 56px" />
<position value="434px -56px" />
<position value="733px -56px" />
</Profile>
<Profile name="fs25_pricesPriceList" extends="emptyPanel" with="anchorTopRight">
<size value="1025px 240px" />
<Profile name="cpRightList" extends="emptyPanel" with="anchorStretchingYLeft pivotTopRight">
<width value="695px" />
<absoluteSizeOffset value="0px 56px" />
<position value="-63px -56px" />
<selectedWithoutFocus value="false" />
Expand Down Expand Up @@ -172,8 +172,8 @@
<format value="currency" />
<formatDecimalPlaces value="0" />
</Profile>
<Profile name="fs25_pricesPriceSliderBox" extends="fs25_listSliderBox" with="anchorTopRight">
<height value="240px" />
<Profile name="cpRightListSliderBox" extends="fs25_listSliderBox" with="anchorTopRight">
<absoluteSizeOffset value="0px 56px" />
<position value="-41px -56px" />
</Profile>
<Profile name="fs25_pricesNoSellpointsText" extends="textDefault" with="anchorTopCenter">
Expand Down
4 changes: 2 additions & 2 deletions scripts/ai/ProximitySensor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function ProximitySensor:update()
self.objectId = nil
self.hitTerrain = false
if self.enabled then
local raycastMask = CollisionFlag.DEFAULT + CollisionFlag.TREE + CollisionFlag.DYNAMIC_OBJECT + CollisionFlag.VEHICLE
local raycastMask = CollisionFlag.DEFAULT + CollisionFlag.TREE + CollisionFlag.DYNAMIC_OBJECT + CollisionFlag.VEHICLE + CollisionFlag.BUILDING
raycastClosest(x, y1 + self.height, z, nx, ny, nz, self.range, 'raycastCallback', self, raycastMask)
if CpDebug:isChannelActive(CpDebug.DBG_TRAFFIC, self.vehicle) then
DebugUtil.drawDebugLine(x, y1 + self.height, z, x + 5 * nx, y1 + self.height + 5 * ny, z + 5 * nz, 0, 1, 0)
Expand Down Expand Up @@ -460,7 +460,7 @@ function VerticalProximitySensor:update()
self.objectId = nil
self.hitTerrain = false
if self.enabled then
local raycastMask = CollisionFlag.DEFAULT + CollisionFlag.TREE + CollisionFlag.DYNAMIC_OBJECT + CollisionFlag.VEHICLE
local raycastMask = CollisionFlag.DEFAULT + CollisionFlag.TREE + CollisionFlag.DYNAMIC_OBJECT + CollisionFlag.VEHICLE + CollisionFlag.BUILDING
-- straight up from 10 cm above the ground to height
raycastClosest(x, y + self.minHeightAboveGround, z, 0, 1, 0,
self.height - self.minHeightAboveGround,
Expand Down
18 changes: 9 additions & 9 deletions scripts/ai/controllers/MotorController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function MotorController:update()
return
end
if not self.settings.fuelSave:getValue() then
if not self.vehicle:getIsMotorStarted() then
if not self:getIsStarted() then
self:startMotor()
self.vehicle:raiseAIEvent('onAIFieldWorkerContinue', 'onAIImplementContinue')
end
Expand All @@ -35,7 +35,7 @@ function MotorController:update()
end
if self:isFuelSaveDisabled() or self.driveStrategy:getMaxSpeed() >
self.speedThreshold then
if not self.vehicle:getIsMotorStarted() then
if not self:getIsStarted() then
self:startMotor()
self.vehicle:raiseAIEvent("onAIFieldWorkerContinue", "onAIImplementContinue")
end
Expand All @@ -47,7 +47,7 @@ function MotorController:update()
self.timerSet = true
end
if self.timer:get() then
if self.vehicle:getIsMotorStarted() then
if self:getIsStarted() then
self.vehicle:raiseAIEvent('onAIFieldWorkerBlock', 'onAIImplementBlock')
self:stopMotor()
end
Expand Down Expand Up @@ -113,12 +113,8 @@ end

function MotorController:startMotor()
self.vehicle.spec_cpAIWorker.motorDisabled = false
-- TODO 25 for whatever reason, vehicle:getIsMotorStarted() returns true only much later after the motor was started
-- so we call this and log for quite a few seconds when the motor was not running when the helper was started
if self.vehicle:getCanBeTurnedOn() then
self.implement:startMotor()
self:debug('Started motor after fuel save.')
end
self.implement:startMotor()
self:debug('Started motor after fuel save.')
end

function MotorController:stopMotor()
Expand All @@ -133,3 +129,7 @@ function MotorController:onFinished()
self.implement:setFillUnitIsFilling(false)
end
end

function MotorController:getIsStarted()
return self.vehicle:getMotorState() ~= MotorState.OFF
end
4 changes: 2 additions & 2 deletions scripts/ai/jobs/CpAIJob.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ function CpAIJob:applyCurrentState(vehicle, mission, farmId, isDirectStart)
end

--- Can the vehicle be used for this job?
function CpAIJob:getIsAvailableForVehicle(vehicle)
return true
function CpAIJob:getIsAvailableForVehicle(vehicle, cpJobsAllowed)
return cpJobsAllowed
end

function CpAIJob:getTitle()
Expand Down
4 changes: 2 additions & 2 deletions scripts/ai/jobs/CpAIJobBaleFinder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function CpAIJobBaleFinder:setupJobParameters()
self:setupCpJobParameters(CpBaleFinderJobParameters(self))
end

function CpAIJobBaleFinder:getIsAvailableForVehicle(vehicle)
return false--vehicle.getCanStartCpBaleFinder and vehicle:getCanStartCpBaleFinder() -- TODO_25
function CpAIJobBaleFinder:getIsAvailableForVehicle(vehicle, cpJobsAllowed)
return CpAIJob.getIsAvailableForVehicle(self, vehicle, cpJobsAllowed) and vehicle.getCanStartCpBaleFinder and vehicle:getCanStartCpBaleFinder() -- TODO_25
end

function CpAIJobBaleFinder:getCanStartJob()
Expand Down
4 changes: 2 additions & 2 deletions scripts/ai/jobs/CpAIJobBunkerSilo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function CpAIJobBunkerSilo:setupJobParameters()
self:setupCpJobParameters(CpBunkerSiloJobParameters(self))
end

function CpAIJobBunkerSilo:getIsAvailableForVehicle(vehicle)
return false--vehicle.getCanStartCpBunkerSiloWorker and vehicle:getCanStartCpBunkerSiloWorker() -- TODO_25
function CpAIJobBunkerSilo:getIsAvailableForVehicle(vehicle, cpJobsAllowed)
return CpAIJob.getIsAvailableForVehicle(self, vehicle, cpJobsAllowed) and vehicle.getCanStartCpBunkerSiloWorker and vehicle:getCanStartCpBunkerSiloWorker() -- TODO_25
end

function CpAIJobBunkerSilo:getCanStartJob()
Expand Down
4 changes: 2 additions & 2 deletions scripts/ai/jobs/CpAIJobCombineUnloader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function CpAIJobCombineUnloader:setupJobParameters()
self.waitForFillingTask = self.combineUnloaderTask
end

function CpAIJobCombineUnloader:getIsAvailableForVehicle(vehicle)
return false--vehicle.getCanStartCpCombineUnloader and vehicle:getCanStartCpCombineUnloader() -- TODO_25
function CpAIJobCombineUnloader:getIsAvailableForVehicle(vehicle, cpJobsAllowed)
return CpAIJob.getIsAvailableForVehicle(self, vehicle, cpJobsAllowed) and vehicle.getCanStartCpCombineUnloader and vehicle:getCanStartCpCombineUnloader() -- TODO_25
end

function CpAIJobCombineUnloader:getCanStartJob()
Expand Down
4 changes: 2 additions & 2 deletions scripts/ai/jobs/CpAIJobFieldWork.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ function CpAIJobFieldWork:isPipeOnLeftSide(vehicle)
end
end

function CpAIJobFieldWork:getIsAvailableForVehicle(vehicle)
return false --vehicle.getCanStartCpFieldWork and vehicle:getCanStartCpFieldWork() -- TODO_25
function CpAIJobFieldWork:getIsAvailableForVehicle(vehicle, cpJobsAllowed)
return CpAIJob.getIsAvailableForVehicle(self, vehicle, cpJobsAllowed) and vehicle.getCanStartCpFieldWork and vehicle:getCanStartCpFieldWork() -- TODO_25
end

function CpAIJobFieldWork:resetStartPositionAngle(vehicle)
Expand Down
4 changes: 2 additions & 2 deletions scripts/ai/jobs/CpAIJobSiloLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function CpAIJobSiloLoader:setupJobParameters()
self.cpJobParameters.unloadPosition:setSnappingAngle(math.pi/8) -- AI menu snapping angle of 22.5 degree.
end

function CpAIJobSiloLoader:getIsAvailableForVehicle(vehicle)
return false --vehicle.getCanStartCpSiloLoaderWorker and vehicle:getCanStartCpSiloLoaderWorker() -- TODO_25
function CpAIJobSiloLoader:getIsAvailableForVehicle(vehicle, cpJobsAllowed)
return CpAIJob.getIsAvailableForVehicle(self, vehicle, cpJobsAllowed) and vehicle.getCanStartCpSiloLoaderWorker and vehicle:getCanStartCpSiloLoaderWorker() -- TODO_25
end

function CpAIJobSiloLoader:getCanStartJob()
Expand Down
2 changes: 1 addition & 1 deletion scripts/dev/DevHelper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function DevHelper:update()
self.data.isOnFieldArea, self.data.onFieldArea, self.data.totalOnFieldArea = CpFieldUtil.isOnFieldArea(self.data.x, self.data.z)
self.data.nx, self.data.ny, self.data.nz = getTerrainNormalAtWorldPos(g_currentMission.terrainRootNode, self.data.x, y, self.data.z)

local collisionMask = CollisionFlag.DEFAULT + CollisionFlag.TREE + CollisionFlag.DYNAMIC_OBJECT + CollisionFlag.VEHICLE + CollisionFlag.TERRAIN_DELTA
local collisionMask = CollisionFlag.DEFAULT + CollisionFlag.TREE + CollisionFlag.DYNAMIC_OBJECT + CollisionFlag.VEHICLE + CollisionFlag.TERRAIN_DELTA + CollisionFlag.BUILDING
self.data.collidingShapes = ''
overlapBox(self.data.x, self.data.y + 0.2, self.data.z, 0, self.yRot, 0, 1.6, 1, 8, "overlapBoxCallback", self, collisionMask, true, true, true)

Expand Down
6 changes: 5 additions & 1 deletion scripts/gui/CoursePlot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ function CoursePlot:drawLineBetween(map, x, z, nx, nz, isHudMap, lineThickness,
local startX, startY, _, sv = CpGuiUtil.worldToScreen(map, x, z, isHudMap)
local endX, endY, _, ev = CpGuiUtil.worldToScreen(map, nx, nz, isHudMap)
local dx, dz = nx - x, nz - z
local dirX, dirZ = MathUtil.vector2Normalize(dx, dz)
local length = MathUtil.vector2Length(dx, dz)
local dirX, dirZ = 0, 1
if length <= 0 then
return
end
dirX, dirZ = MathUtil.vector2Normalize(dx, dz)
if startX and startY and endX and endY then
local dx2D = endX - startX
local dy2D = ( endY - startY ) / g_screenAspectRatio
Expand Down
68 changes: 38 additions & 30 deletions scripts/gui/CpInGameMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ end
-- Lines 279-324
function CpInGameMenu:initializePages()
self.clickBackCallback = self:makeSelfCallback(self.onButtonBack)
self.pageGlobalSettings:initialize()
self.pageVehicleSettings:initialize()
self.pageCourseGenerator:initialize()
self.pageCourseManager:initialize()

self.pageCourseGenerator:setInGameMap(
g_inGameMenu.baseIngameMap,
g_currentMission.hud)

self.pageGlobalSettings:initialize(self)
self.pageVehicleSettings:initialize(self)
self.pageCourseGenerator:initialize(self)
self.pageCourseManager:initialize(self)
self.pageCourseManager:setCourseStorage(self.courseStorage)
end

Expand Down Expand Up @@ -143,41 +148,38 @@ end
-- Lines 365-397
function CpInGameMenu:setupMenuButtonInfo()
CpInGameMenu:superClass().setupMenuButtonInfo(self)

local onButtonBackFunction = self.clickBackCallback
local onButtonQuitFunction = self:makeSelfCallback(self.onButtonQuit)
local onButtonSaveGameFunction = self:makeSelfCallback(self.onButtonSaveGame)
self.backButtonInfo = {
inputAction = InputAction.MENU_BACK,
text = self.l10n:getText(CpInGameMenu.L10N_SYMBOL.BUTTON_BACK),
callback = onButtonBackFunction
}
self.saveButtonInfo = {
showWhenPaused = true,
inputAction = InputAction.MENU_ACTIVATE,
text = self.l10n:getText(CpInGameMenu.L10N_SYMBOL.BUTTON_SAVE_GAME),
callback = onButtonSaveGameFunction
}
self.quitButtonInfo = {
showWhenPaused = true,
inputAction = InputAction.MENU_CANCEL,
text = self.l10n:getText(CpInGameMenu.L10N_SYMBOL.BUTTON_CANCEL_GAME),
callback = onButtonQuitFunction
}
local onButtonPagePreviousFunction = self:makeSelfCallback(self.onPagePrevious)
local onButtonPageNextFunction = self:makeSelfCallback(self.onPageNext)


self.backButtonInfo = {
inputAction = InputAction.MENU_BACK,
text = g_i18n:getText(InGameMenu.L10N_SYMBOL.BUTTON_BACK),
callback = onButtonBackFunction }
self.nextPageButtonInfo = {
inputAction = InputAction.MENU_PAGE_NEXT,
text = g_i18n:getText("ui_ingameMenuNext"),
callback = self.onPageNext }
self.prevPageButtonInfo = {
inputAction = InputAction.MENU_PAGE_PREV,
text = g_i18n:getText("ui_ingameMenuPrev"),
callback = self.onPagePrevious }


self.defaultMenuButtonInfo = {
self.backButtonInfo,
self.saveButtonInfo,
self.quitButtonInfo
self.nextPageButtonInfo,
self.prevPageButtonInfo
}

self.defaultMenuButtonInfoByActions[InputAction.MENU_BACK] = self.defaultMenuButtonInfo[1]
self.defaultMenuButtonInfoByActions[InputAction.MENU_ACTIVATE] = self.defaultMenuButtonInfo[2]
self.defaultMenuButtonInfoByActions[InputAction.MENU_CANCEL] = self.defaultMenuButtonInfo[3]
self.defaultMenuButtonInfoByActions[InputAction.MENU_PAGE_NEXT] = self.defaultMenuButtonInfo[2]
self.defaultMenuButtonInfoByActions[InputAction.MENU_PAGE_PREV] = self.defaultMenuButtonInfo[3]
self.defaultButtonActionCallbacks = {
[InputAction.MENU_BACK] = onButtonBackFunction,
[InputAction.MENU_CANCEL] = onButtonQuitFunction,
[InputAction.MENU_ACTIVATE] = onButtonSaveGameFunction
[InputAction.MENU_PAGE_NEXT] = onButtonPageNextFunction,
[InputAction.MENU_PAGE_PREV] = onButtonPagePreviousFunction
}
end

Expand Down Expand Up @@ -227,6 +229,12 @@ function CpInGameMenu:onMenuOpened()
-- end
end

function CpInGameMenu:onButtonBack(_, _, force)
if force or self.currentPage:requestClose(self.clickBackCallback) then
CpInGameMenu:superClass().onButtonBack(self)
end
end

-- Lines 559-578
function CpInGameMenu:onClose(element)
CpInGameMenu:superClass().onClose(self)
Expand Down
Loading

0 comments on commit ae93b9b

Please sign in to comment.