From 70705aabd36805fd2920c96b6b2c826fb8f54966 Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Tue, 3 Dec 2024 16:19:06 +0100 Subject: [PATCH 01/14] WIP --- config/gui/pages/CourseGeneratorFrame.xml | 540 ++++++++++++ scripts/ai/jobs/CpAIJob.lua | 4 +- scripts/ai/jobs/CpAIJobBaleFinder.lua | 4 +- scripts/ai/jobs/CpAIJobBunkerSilo.lua | 4 +- scripts/ai/jobs/CpAIJobCombineUnloader.lua | 2 +- scripts/ai/jobs/CpAIJobFieldWork.lua | 2 +- scripts/ai/jobs/CpAIJobSiloLoader.lua | 2 +- scripts/gui/CpInGameMenu.lua | 14 +- scripts/gui/pages/CpCourseGeneratorFrame.lua | 864 ++++++++++++++++++- scripts/gui/pages/CpGlobalSettingsFrame.lua | 2 +- scripts/gui/pages/CpVehicleSettingsFrame.lua | 2 +- 11 files changed, 1415 insertions(+), 25 deletions(-) diff --git a/config/gui/pages/CourseGeneratorFrame.xml b/config/gui/pages/CourseGeneratorFrame.xml index 29cd19636..a2a59ad50 100644 --- a/config/gui/pages/CourseGeneratorFrame.xml +++ b/config/gui/pages/CourseGeneratorFrame.xml @@ -1,5 +1,13 @@ + + + + + + @@ -14,6 +22,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/gui/CpInGameMenu.lua b/scripts/gui/CpInGameMenu.lua index b6bd14ef3..d2f74a58e 100644 --- a/scripts/gui/CpInGameMenu.lua +++ b/scripts/gui/CpInGameMenu.lua @@ -89,7 +89,6 @@ function CpInGameMenu:initializePages() self.pageCourseGenerator:setInGameMap( g_inGameMenu.baseIngameMap, - g_currentMission.terrainSize, g_currentMission.hud) self.pageGlobalSettings:initialize(self) diff --git a/scripts/gui/elements/CpOptionToggleElement.lua b/scripts/gui/elements/CpOptionToggleElement.lua index 32b2bad71..ea34dc548 100644 --- a/scripts/gui/elements/CpOptionToggleElement.lua +++ b/scripts/gui/elements/CpOptionToggleElement.lua @@ -19,7 +19,6 @@ function CpOptionToggleElement:copyAttributes(src) self.onClickCenterCallback = src.onClickCenterCallback end - function CpOptionToggleElement:onCenterButtonClicked() self:raiseCallback("onClickCenterCallback", self) if self.dataSource ~= nil then @@ -61,17 +60,17 @@ function CpOptionToggleElement:setLabelElement(element) self:updateTitle() end -function CpOptionToggleElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) - if self.parent then - -- Fixes giants bug, where the scrolling layout is not disabling the mouse event for invisible child elements. - local _, clipY1 , _, clipY2 = self.parent:getClipArea(0,0,1,1) - if (clipY1 - self.absPosition[2] * 0.02) > (self.absPosition[2]) or - (clipY2 + self.absPosition[2] * 0.02) < ( self.absPosition[2] + self.absSize[2]) then - return eventUsed - end - end - return CpOptionToggleElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) -end +-- function CpOptionToggleElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) +-- if self.parent then +-- -- Fixes giants bug, where the scrolling layout is not disabling the mouse event for invisible child elements. +-- local _, clipY1 , _, clipY2 = self.parent:getClipArea(0,0,1,1) +-- if (clipY1 - self.absPosition[2] * 0.02) > (self.absPosition[2]) or +-- (clipY2 + self.absPosition[2] * 0.02) < ( self.absPosition[2] + self.absSize[2]) then +-- return eventUsed +-- end +-- end +-- return CpOptionToggleElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) +-- end function CpOptionToggleElement:inputEvent(action, value, eventUsed) if self:getIsActive() then diff --git a/scripts/gui/pages/CpCourseGeneratorFrame.lua b/scripts/gui/pages/CpCourseGeneratorFrame.lua index 9c655daaf..823482e7b 100644 --- a/scripts/gui/pages/CpCourseGeneratorFrame.lua +++ b/scripts/gui/pages/CpCourseGeneratorFrame.lua @@ -80,7 +80,7 @@ function CpCourseGeneratorFrame.new(target, custom_mt) self.isInputContextActive = false self.driveToAiTargetMapHotspot = AITargetHotspot.new() self.fieldSiloAiTargetMapHotspot = AITargetHotspot.new() - -- self.fieldSiloAiTargetMapHotspot.icon:setUVs(POSITION_UVS) --- TODO_25 + self.fieldSiloAiTargetMapHotspot.icon:setUVs(GuiUtils.getUVs({760, 111, 100, 100}, AIPlaceableMarkerHotspot.FILE_RESOLUTION)) --- TODO_25 self.unloadAiTargetMapHotspot = AITargetHotspot.new() self.loadAiTargetMapHotspot = AITargetHotspot.new() @@ -110,10 +110,9 @@ function CpCourseGeneratorFrame.createFromExistingGui(gui, guiName) return newGui end -function CpCourseGeneratorFrame:setInGameMap(ingameMap, terrainSize, hud) +function CpCourseGeneratorFrame:setInGameMap(ingameMap, hud) self.ingameMapBase = ingameMap self.ingameMap:setIngameMap(ingameMap) - self.ingameMap:setTerrainSize(terrainSize) self.hud = hud end @@ -180,6 +179,7 @@ function CpCourseGeneratorFrame:initialize(menu) self.currentContextBox = self.contextBox self.currentHotspot = nil + self.ingameMap:setTerrainSize(g_currentMission.terrainSize) end function CpCourseGeneratorFrame:update(dt) @@ -403,6 +403,13 @@ function CpCourseGeneratorFrame:onDrawPostIngameMapHotspots() if self.currentContextBox ~= nil then InGameMenuMapUtil.updateContextBoxPosition(self.currentContextBox, self.currentHotspot) end + if self.aiTargetMapHotspot ~= nil then + + local icon = self.aiTargetMapHotspot.icon + + --Lx: [952, 952], [19, 35], 1 + self.actionMessage:setAbsolutePosition(icon.x + icon.width * 0.5, icon.y + icon.height * 0.5) + end end function CpCourseGeneratorFrame:onDrawPostIngameMap() @@ -490,6 +497,10 @@ function CpCourseGeneratorFrame:onClickMultiTextOptionParameter(index, element) self:validateParameters() end +function CpCourseGeneratorFrame:onClickMultiTextOptionCenterParameter() + +end + function CpCourseGeneratorFrame:onClickPositionParameter(element) local parameter = element.aiParameter g_currentMission:removeMapHotspot(self.loadAiTargetMapHotspot) @@ -507,6 +518,7 @@ function CpCourseGeneratorFrame:onClickPositionParameter(element) end self.contextBox:setVisible(false) g_inGameMenu.pageMapOverview.startPickPosition(self, parameter, function (success, x, z) + print(success, x, z) if success then element:setText(parameter:getString()) end @@ -517,7 +529,10 @@ end function CpCourseGeneratorFrame:onClickPositionRotationParameter(element) self.contextBox:setVisible(false) local parameter = element.aiParameter - + g_currentMission:removeMapHotspot(self.loadAiTargetMapHotspot) + g_currentMission:removeMapHotspot(self.fieldSiloAiTargetMapHotspot) + g_currentMission:removeMapHotspot(self.unloadAiTargetMapHotspot) + g_currentMission:removeMapHotspot(self.driveToAiTargetMapHotspot) g_inGameMenu.pageMapOverview.startPickPositionAndRotation(self, parameter, function (success, x, z, angle) if success then element:setText(parameter:getString()) @@ -756,6 +771,7 @@ function CpCourseGeneratorFrame:mouseEvent(posX, posY, isDown, isUp, button, eve local localX, localY = self.ingameMap:getLocalPosition(self.lastMousePosX, self.lastMousePoxY) local worldX, worldZ = self.ingameMap:localToWorldPos(localX, localY) self.aiTargetMapHotspot:setWorldPosition(worldX, worldZ) + CpUtil.info("%s, %s, %s, %s, %s, %s", self.lastMousePosX, self.lastMousePoxY, localX, localY, worldX, worldZ) end return CpCourseGeneratorFrame:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) end @@ -982,6 +998,7 @@ function CpCourseGeneratorFrame:onCreateJob() if self.currentHotspot then local vehicle = self.currentHotspot:getVehicle() if vehicle then + self.currentJobTypes = {} local currentJobTypesTexts = {} for index, job in pairs(self.jobTypeInstances) do if job:getIsAvailableForVehicle(vehicle, true) then From 07881feaab88b67db82a9cdf60a47b6104ab9d19 Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Wed, 4 Dec 2024 22:12:44 +0100 Subject: [PATCH 05/14] Some more fixes .. --- config/gui/pages/CourseGeneratorFrame.xml | 16 ++- scripts/gui/pages/CpCourseGeneratorFrame.lua | 117 ++++++++++++++++--- 2 files changed, 116 insertions(+), 17 deletions(-) diff --git a/config/gui/pages/CourseGeneratorFrame.xml b/config/gui/pages/CourseGeneratorFrame.xml index 5dc227b63..51b6284b3 100644 --- a/config/gui/pages/CourseGeneratorFrame.xml +++ b/config/gui/pages/CourseGeneratorFrame.xml @@ -97,15 +97,22 @@ - - + + + + - @@ -202,7 +202,6 @@ - @@ -219,28 +218,17 @@ - + - + - - - @@ -604,19 +592,6 @@ - - - - - - - @@ -633,12 +608,5 @@ - - - - - - - diff --git a/config/gui/pages/CourseManagerFrame.xml b/config/gui/pages/CourseManagerFrame.xml index 9c4615aaf..fe21fe33c 100644 --- a/config/gui/pages/CourseManagerFrame.xml +++ b/config/gui/pages/CourseManagerFrame.xml @@ -42,14 +42,14 @@ --> - + - + @@ -59,14 +59,14 @@ --> - + - + @@ -93,9 +93,9 @@ - - + @@ -122,13 +122,13 @@ - - + - - + + @@ -172,8 +172,8 @@ - - + + diff --git a/scripts/gui/elements/CpBinaryOptionElement.lua b/scripts/gui/elements/CpBinaryOptionElement.lua index 9275d9e43..d68f84cc6 100644 --- a/scripts/gui/elements/CpBinaryOptionElement.lua +++ b/scripts/gui/elements/CpBinaryOptionElement.lua @@ -8,21 +8,23 @@ function CpBinaryOptionElement.new(target, custom_mt) return self end --- Lines 19-23 function CpBinaryOptionElement:delete() self.dataSource = nil CpBinaryOptionElement:superClass().delete(self) end --- Lines 25-28 function CpBinaryOptionElement:setDataSource(dataSource) self.dataSource = dataSource - - self:updateTitle() + self.useYesNoTexts = false + self:setTexts({self.dataSource.texts[1], self.dataSource.texts[2]}) + if self.dataSource:getValue() then + self:setState(BinaryOptionElement.STATE_RIGHT, true) + else + self:setState(BinaryOptionElement.STATE_LEFT, true) + end end - function CpBinaryOptionElement:addElement(element, ...) CpBinaryOptionElement:superClass().addElement(self, element, ...) -- if self.textElement then @@ -36,41 +38,27 @@ function CpBinaryOptionElement:addElement(element, ...) end end --- Lines 30-33 function CpBinaryOptionElement:updateTitle() - if self.dataSource:getValue() then - self:setState(2) - else - self:setState(1) - end if self.labelElement then self.labelElement:setText(self.dataSource:getTitle()) end if self.toolTipElement then self.toolTipElement:setText(self.dataSource:getTooltip()) end - -- self:setState(1) end --- Lines 35-42 -function CpBinaryOptionElement:onRightButtonClicked(steps, noFocus) - if self.dataSource ~= nil then - self.dataSource:setNextItem() - - -- self.texts[1] = self.dataSource:getString() +function CpBinaryOptionElement:setState(state, ...) + if state == BinaryOptionElement.STATE_RIGHT then + self.dataSource:setValue(true) + else + self.dataSource:setValue(false) end - - CpBinaryOptionElement:superClass().onRightButtonClicked(self, steps, noFocus) -end - --- Lines 44-51 -function CpBinaryOptionElement:onLeftButtonClicked(steps, noFocus) - if self.dataSource ~= nil then - self.dataSource:setPreviousItem() - - -- self.texts[1] = self.dataSource:getString() + self:updateTitle() + if self.dataSource:getValue() then + CpBinaryOptionElement:superClass().setState(self, BinaryOptionElement.STATE_RIGHT, true) + else + CpBinaryOptionElement:superClass().setState(self, BinaryOptionElement.STATE_LEFT, true) end - - CpBinaryOptionElement:superClass().onLeftButtonClicked(self, steps, noFocus) end + Gui.registerGuiElement("CpBinaryyOption", CpBinaryOptionElement) diff --git a/scripts/gui/elements/CpOptionToggleElement.lua b/scripts/gui/elements/CpOptionToggleElement.lua index ea34dc548..4b0dc6b4f 100644 --- a/scripts/gui/elements/CpOptionToggleElement.lua +++ b/scripts/gui/elements/CpOptionToggleElement.lua @@ -60,17 +60,17 @@ function CpOptionToggleElement:setLabelElement(element) self:updateTitle() end --- function CpOptionToggleElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) --- if self.parent then --- -- Fixes giants bug, where the scrolling layout is not disabling the mouse event for invisible child elements. --- local _, clipY1 , _, clipY2 = self.parent:getClipArea(0,0,1,1) --- if (clipY1 - self.absPosition[2] * 0.02) > (self.absPosition[2]) or --- (clipY2 + self.absPosition[2] * 0.02) < ( self.absPosition[2] + self.absSize[2]) then --- return eventUsed --- end --- end --- return CpOptionToggleElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) --- end +function CpOptionToggleElement:mouseEvent(posX, posY, isDown, isUp, button, eventUsed) + if self.parent then + -- Fixes giants bug, where the scrolling layout is not disabling the mouse event for invisible child elements. + local _, clipY1 , _, clipY2 = self.parent:getClipArea(0,0,1,1) + if (clipY1 - self.absPosition[2] * 0.02) > (self.absPosition[2]) or + (clipY2 + self.absPosition[2] * 0.02) < ( self.absPosition[2] + self.absSize[2]) then + return eventUsed + end + end + return CpOptionToggleElement:superClass().mouseEvent(self, posX, posY, isDown, isUp, button, eventUsed) +end function CpOptionToggleElement:inputEvent(action, value, eventUsed) if self:getIsActive() then diff --git a/scripts/gui/pages/CpCourseGeneratorFrame.lua b/scripts/gui/pages/CpCourseGeneratorFrame.lua index 8afec82fb..c2f3f3141 100644 --- a/scripts/gui/pages/CpCourseGeneratorFrame.lua +++ b/scripts/gui/pages/CpCourseGeneratorFrame.lua @@ -163,7 +163,6 @@ function CpCourseGeneratorFrame:initialize(menu) FocusManager:loadElementFromCustomValues(self.subCategoryPages[key]) end end - self:resetUIDeadzones() self.mapOverviewSelector:setTexts(self.mapSelectorTexts) self.mapOverviewSelector:setState(1, true) @@ -206,6 +205,7 @@ function CpCourseGeneratorFrame:update(dt) if hasChanged then self:updateStatusMessages() end + CpCourseGeneratorFrame:superClass().update(self, dt) end function CpCourseGeneratorFrame:onFrameOpen() @@ -227,10 +227,6 @@ function CpCourseGeneratorFrame:onFrameOpen() layout, self.multiTextPrefab, self.booleanPrefab, self.sectionHeaderPrefab, settings) CpSettingsUtil.updateGuiElementsBoundToSettings(layout, vehicle) - - self:updateSubCategoryPages(self.CATEGRORIES.BASIC_SETTINGS) - FocusManager:setFocus(self.subCategoryPages[self.CATEGRORIES.BASIC_SETTINGS]:getDescendantByName("layout")) - -- g_messageCenter:subscribe(MessageType.AI_VEHICLE_STATE_CHANGE, self.onAIVehicleStateChanged, self) self.activeWorkerList:reloadData() @@ -285,6 +281,12 @@ function CpCourseGeneratorFrame:onFrameOpen() self:setMapSelectionItem(nil) self:setJobMenuVisible(false) self.startJobPending = false + self.ingameMap:onOpen() + + self:updateSubCategoryPages(self.CATEGRORIES.BASIC_SETTINGS) + FocusManager:setFocus(self.subCategoryPages[self.CATEGRORIES.BASIC_SETTINGS]:getDescendantByName("layout")) + + CpCourseGeneratorFrame:superClass().onFrameOpen(self) end function CpCourseGeneratorFrame:saveHotspotFilter() @@ -321,10 +323,10 @@ function CpCourseGeneratorFrame:onFrameClose() g_currentMission:removeMapHotspot(self.fieldSiloAiTargetMapHotspot) g_currentMission:removeMapHotspot(self.unloadAiTargetMapHotspot) g_currentMission:removeMapHotspot(self.loadAiTargetMapHotspot) - + self.ingameMap:onClose() self.ingameMapBase:restoreDefaultFilter() if not self:getIsPicking() then - g_inGameMenu.pageMapOverview.executePickingCallback(self, false) + self:executePickingCallback(false) end self.mode = self.AI_MODE_OVERVIEW self:setJobMenuVisible(false) @@ -332,12 +334,14 @@ function CpCourseGeneratorFrame:onFrameClose() self.statusMessages = {} self:updateStatusMessages() self.startJobPending = false + + CpCourseGeneratorFrame:superClass().onFrameClose(self) end function CpCourseGeneratorFrame:requestClose() if self.mode == self.AI_MODE_CREATE then if self:getIsPicking() then - g_inGameMenu.pageMapOverview.executePickingCallback(self, false) + self:executePickingCallback(false) self:updateContextActions() return false end @@ -359,10 +363,6 @@ function CpCourseGeneratorFrame:onClickCpMultiTextOption(_, guiElement) end end -function CpCourseGeneratorFrame:isMapVisible() - return self.ingameMap:getIsVisible() -end - function CpCourseGeneratorFrame:updateSubCategoryPages(state) for i, _ in ipairs(self.subCategoryPages) do self.subCategoryPages[i]:setVisible(false) @@ -372,11 +372,12 @@ function CpCourseGeneratorFrame:updateSubCategoryPages(state) self.subCategoryTabs[state]:setSelected(true) local layout = self.subCategoryPages[state]:getDescendantByName("layout") if layout then + self:closeMap() self.settingsSliderBox:setVisible(true) self.ingameMap:setVisible(false) layout:invalidateLayout() self.settingsSlider:setDataElement(layout) - self:closeMap() + FocusManager:setFocus(layout) else self.settingsSliderBox:setVisible(false) self.ingameMap:setVisible(true) @@ -414,18 +415,66 @@ function CpCourseGeneratorFrame:onDrawPostIngameMapHotspots() end end -function CpCourseGeneratorFrame:onDrawPostIngameMap() - +function CpCourseGeneratorFrame:onDrawPostIngameMap(element, ingameMap) + local areCursePlotsAlwaysVisible = g_Courseplay.globalSettings:getSettings().showsAllActiveCourses:getValue() + local vehicle = self.currentHotspot and self.currentHotspot:getVehicle() + if areCursePlotsAlwaysVisible then + local vehicles = g_assignedCoursesManager:getRegisteredVehicles() + for _, v in pairs(vehicles) do + if g_currentMission.accessHandler:canPlayerAccess(v) then + v:drawCpCoursePlot(ingameMap) + end + end + elseif vehicle and vehicle.drawCpCoursePlot then + vehicle:drawCpCoursePlot(ingameMap) + end + -- show the custom fields on the AI map + g_customFieldManager:draw(ingameMap) + -- show the selected field on the AI screen map when creating a job + if self.currentJob and self.currentJob.draw then + self.currentJob:draw(ingameMap, self.mode == self.MODE_OVERVIEW) + end + + --- Draws the current progress, while creating a custom field. + -- if pageAI.mode == CpInGameMenuAIFrameExtended.MODE_DRAW_FIELD_BORDER and next(CpInGameMenuAIFrameExtended.curDrawPositions) then + -- local localX, localY = pageAI.ingameMap:getLocalPosition(g_inputBinding.mousePosXLast, g_inputBinding.mousePosYLast) + -- local worldX, worldZ = pageAI.ingameMap:localToWorldPos(localX, localY) + + -- if #CpInGameMenuAIFrameExtended.curDrawPositions > 0 then + -- local pos = CpInGameMenuAIFrameExtended.curDrawPositions[#CpInGameMenuAIFrameExtended.curDrawPositions] + -- local dx, dz, length = CpMathUtil.getPointDirection( pos, {x = worldX, z = worldZ}) + -- if Input.isKeyPressed(Input.KEY_lshift) then + -- if math.abs(dx) > math.abs(dz) then + -- dz = 0 + -- dx = math.sign(dx) + -- else + -- dx = 0 + -- dz = math.sign(dz) + -- end + -- worldX = pos.x + dx * length + -- worldZ = pos.z + dz * length + -- end + -- pageAI.customFieldPlot:setNextTargetPoint(worldX, worldZ) + -- else + -- pageAI.customFieldPlot:setNextTargetPoint() + -- end + + + -- pageAI.customFieldPlot:setWaypoints(CpInGameMenuAIFrameExtended.curDrawPositions) + -- pageAI.customFieldPlot:draw(self,true) + -- pageAI.customFieldPlot:setVisible(true) + -- end + end function CpCourseGeneratorFrame:onClickMap(element ,worldX, worldZ) if self.isPickingLocation then - g_inGameMenu.pageMapOverview.executePickingCallback(self, true, worldX, worldZ) + self:executePickingCallback(true, worldX, worldZ) return end if self.isPickingRotation then local angle = math.atan2(worldX - self.pickingRotationOrigin[1], worldZ - self.pickingRotationOrigin[2]) - g_inGameMenu.pageMapOverview.executePickingCallback(self, true, angle) + self:executePickingCallback(true, angle) return end self:setMapSelectionItem(nil) @@ -433,12 +482,12 @@ end function CpCourseGeneratorFrame:onClickHotspot(element, hotspot) if self.isPickingLocation then - g_inGameMenu.pageMapOverview.executePickingCallback(self, true, hotspot.worldX, hotspot.worldZ) + self:executePickingCallback(true, hotspot.worldX, hotspot.worldZ) return end if self.isPickingRotation then - g_inGameMenu.pageMapOverview.executePickingCallback(self, true, worldX, worldZ) - g_inGameMenu.pageMapOverview.executePickingCallback(self, true, math.atan2(hotspot.worldX - self.pickingRotationOrigin[0], hotspot.worldZ - self.pickingRotationOrigin[1])) + self:executePickingCallback(true, worldX, worldZ) + self:executePickingCallback(true, math.atan2(hotspot.worldX - self.pickingRotationOrigin[0], hotspot.worldZ - self.pickingRotationOrigin[1])) return end self:setMapSelectionItem(hotspot) @@ -500,7 +549,19 @@ function CpCourseGeneratorFrame:onClickMultiTextOptionParameter(index, element) end function CpCourseGeneratorFrame:onClickMultiTextOptionCenterParameter() - + +end + +function CpCourseGeneratorFrame:executePickingCallback(...) + self.ingameMap:setHotspotSelectionActive(true) + self.isPickingLocation = false + self.isPickingRotation = false + self.ingameMap:unlockMapMovement() + local cb = self.pickingCallback + self.pickingCallback = nil + if cb ~= nil then + cb(...) + end end function CpCourseGeneratorFrame:onClickPositionParameter(element) @@ -519,12 +580,21 @@ function CpCourseGeneratorFrame:onClickPositionParameter(element) else self.aiTargetMapHotspot = self.driveToAiTargetMapHotspot end - g_inGameMenu.pageMapOverview.startPickPosition(self, parameter, function (success, x, z) + g_currentMission:addMapHotspot(self.aiTargetMapHotspot) + self.ingameMap:setHotspotSelectionActive(false) + self.ingameMap:setIsCursorAvailable(false) + self.isPickingLocation = true + self:showActionMessage("ui_ai_pickTargetLocation") + function self.pickingCallback(success, x, z) + self:showActionMessage() + self.ingameMap:setIsCursorAvailable(true) if success then - element:setText(parameter:getString()) + parameter:setValue(x, z) + self.aiTargetMapHotspot:setWorldPosition(x, z) end + self:validateParameters() self:updateParameterValueTexts() - end) + end end function CpCourseGeneratorFrame:onClickPositionRotationParameter(element) @@ -543,12 +613,45 @@ function CpCourseGeneratorFrame:onClickPositionRotationParameter(element) else self.aiTargetMapHotspot = self.driveToAiTargetMapHotspot end - g_inGameMenu.pageMapOverview.startPickPositionAndRotation(self, parameter, function (success, x, z, angle) + g_currentMission:addMapHotspot(self.aiTargetMapHotspot) + self.isPickingLocation = true + self.ingameMap:setHotspotSelectionActive(false) + self.ingameMap:setIsCursorAvailable(false) + self:showActionMessage("ui_ai_pickTargetLocation") + function self.pickingCallback(success, x, z) + self:showActionMessage() + self.ingameMap:setIsCursorAvailable(true) + self.contextBox:setVisible(true) + if success then - element:setText(parameter:getString()) + self.contextBox:setVisible(false) + self.ingameMap:setHotspotSelectionActive(false) + self.ingameMap:setIsCursorAvailable(false) + self.ingameMap:lockMapMovement() + self.aiTargetMapHotspot:setWorldPosition(x, z) + self.isPickingRotation = true + self.pickingRotationOrigin = {x, z} + self.pickingRotationSnapAngle = parameter:getSnappingAngle() + self:showActionMessage("ui_ai_pickTargetRotation") + + function self.pickingCallback(successRotation, angle) + self:showActionMessage() + self.ingameMap:setIsCursorAvailable(true) + self.contextBox:setVisible(true) + if successRotation then + parameter:setPosition(x, z) + parameter:setAngle(angle) + local convertedAngle = parameter:getAngle() + self.aiTargetMapHotspot:setWorldRotation(convertedAngle + math.pi) + end + self:validateParameters() + self:updateParameterValueTexts() + end + else + self:validateParameters() + self:updateParameterValueTexts() end - self:updateParameterValueTexts() - end) + end end function CpCourseGeneratorFrame:getIsPicking() @@ -563,7 +666,6 @@ function CpCourseGeneratorFrame:validateParameters() errorText = self.currentJob:validate() self:updateWarnings() self:updateContextActions() - self:updateParameterValueTexts() end self.errorMessage:setText(errorText) self.errorMessage:setVisible(not isValid) @@ -679,16 +781,13 @@ function CpCourseGeneratorFrame:onStartedJob(args, state, jobTypeIndex) self.startJobPending = false g_messageCenter:unsubscribe(AIJobStartRequestEvent, self) if state == AIJob.START_SUCCESS then - self.mapOverviewSelector:setState(InGameMenuMapFrame.AI_WORKER_LIST, true) + self.mapOverviewSelector:setState(self.MAP_SELECTOR_ACTIVE_JOBS, true) else local jobType = g_currentMission.aiJobTypeManager:getJobTypeByIndex(jobTypeIndex) local text = jobType.classObject.getIsStartErrorText(state) - InfoDialog.show(text, nil, nil, DialogElement.TYPE_INFO) end - callback(state) - end function CpCourseGeneratorFrame:tryStartJob(job, farmId, callback) @@ -778,7 +877,9 @@ function CpCourseGeneratorFrame:populateCellForItemInSection(list, section, inde cell:getAttribute("iconBg").getIsSelected = function () return self.hotspotStateFilter[section][index] end - g_inGameMenu.pageMapOverview.assignItemColors(self, cell:getAttribute("iconBg"), status.color, cell:getAttribute("colorTemplate")) + g_inGameMenu.pageMapOverview.assignItemColors(self, + cell:getAttribute("iconBg"), status.color, + cell:getAttribute("colorTemplate")) elseif list == self.contextButtonList then local buttonInfo = self.contextActions[self.contextActionMapping[index]] cell:getAttribute("text"):setText(buttonInfo.text) @@ -890,7 +991,7 @@ end -- Lines 992-1005 function CpCourseGeneratorFrame:registerInput() - self:unregisterInput() + -- self:unregisterInput() -- g_inputBinding:registerActionEvent(InputAction.MENU_ACTIVATE, self, self.onStartCancelJob, false, true, false, true) -- g_inputBinding:registerActionEvent(InputAction.MENU_CANCEL, self, self.onStartGoToJob, false, true, false, true) -- g_inputBinding:registerActionEvent(InputAction.MENU_ACCEPT, self, self.onCreateJob, false, true, false, true) @@ -983,7 +1084,7 @@ function CpCourseGeneratorFrame:updateContextActions() local vehicle = self.currentHotspot and self.currentHotspot:getVehicle() self.contextActions[self.CONTEXT_ACTIONS.ENTER_VEHICLE].isActive = vehicle and vehicle:getIsEnterableFromMenu() and self.mode ~= self.AI_MODE_CREATE self.canCreateJob = false - if not self.canCreateJob and not self.currentJobVehicle then + if vehicle and not self.currentJobVehicle then for _, job in pairs(self.jobTypeInstances) do if job:getIsAvailableForVehicle(vehicle, true) then self.canCreateJob = true @@ -1000,17 +1101,17 @@ function CpCourseGeneratorFrame:updateContextActions() end function CpCourseGeneratorFrame:toggleMapInput(isActive) - if self.isInputContextActive ~= isActive then - self.isInputContextActive = isActive + -- if self.isInputContextActive ~= isActive then + -- self.isInputContextActive = isActive - self:toggleCustomInputContext(isActive, self.INPUT_CONTEXT_NAME) + -- -- self:toggleCustomInputContext(isActive, self.INPUT_CONTEXT_NAME) - if not isActive then - self:registerInput() - else - self:unregisterInput(true) - end - end + -- if isActive then + -- self:registerInput() + -- else + -- self:unregisterInput(true) + -- end + -- end end function CpCourseGeneratorFrame:setMapSelectionItem(hotspot) @@ -1107,12 +1208,15 @@ function CpCourseGeneratorFrame:onCreateJob() self:updateContextActions() end -function CpCourseGeneratorFrame:resetUIDeadzones() +function CpCourseGeneratorFrame:resetUIDeadzones(enable) self.ingameMap:clearCursorDeadzones() - self.ingameMap:addCursorDeadzone(self.rightBackground.absPosition[1], self.rightBackground.absPosition[2], self.rightBackground.size[1], self.rightBackground.size[2]) - self.ingameMap:addCursorDeadzone(self.topBackground.absPosition[1], self.topBackground.absPosition[2], self.topBackground.size[1], self.topBackground.size[2]) - self.ingameMap:addCursorDeadzone(self.bottomBackground.absPosition[1], self.bottomBackground.absPosition[2], self.bottomBackground.size[1], self.bottomBackground.size[2]) - self.ingameMap:addCursorDeadzone(0, 0, self.leftBox.absPosition[1] + self.leftBox.absSize[1], 1) + if enable then + self.ingameMap:addCursorDeadzone(self.rightBackground.absPosition[1], self.rightBackground.absPosition[2], self.rightBackground.size[1], self.rightBackground.size[2]) + self.ingameMap:addCursorDeadzone(self.topBackground.absPosition[1], self.topBackground.absPosition[2], self.topBackground.size[1], self.topBackground.size[2]) + self.ingameMap:addCursorDeadzone(self.bottomBackground.absPosition[1], self.bottomBackground.absPosition[2], self.bottomBackground.size[1], self.bottomBackground.size[2]) + self.ingameMap:addCursorDeadzone(0, 0, self.leftBox.absPosition[1] + self.leftBox.absSize[1], 1) + else + end end function CpCourseGeneratorFrame:setJobMenuVisible(isVisible) @@ -1189,17 +1293,17 @@ function CpCourseGeneratorFrame:setActiveJobTypeSelection(jobTypeIndex) end function CpCourseGeneratorFrame:openMap() - ---------------------- - --- Ingame map - ---------------------- - --- - -- self:setJobMenuVisible(false) - - -- self.activeWorkerList:reloadData() self:toggleMapInput(true) - self.ingameMap:onOpen() + self.ingameMap:setDisabled(false) self.ingameMap:registerActionEvents() self.ingameMapBase:restoreDefaultFilter() + self:updateContextActions() + self:resetUIDeadzones(true) + if self.mode == self.AI_MODE_OVERVIEW and self.currentHotspot then + FocusManager:setFocus(self.currentContextBox) + else + FocusManager:setFocus(self.mapOverviewSelector) + end -- if g_localPlayer ~= nil then -- local x, _, z = g_localPlayer:getPosition() -- self.ingameMap:setCenterToWorldPosition(x, z) @@ -1207,18 +1311,12 @@ function CpCourseGeneratorFrame:openMap() end function CpCourseGeneratorFrame:closeMap() - self.ingameMap:onClose() + self.ingameMap:removeActionEvents() + self.ingameMap:setDisabled(true) self:toggleMapInput(false) - - -- self.startJobPending = false - - -- if self:getIsPicking() then - -- self:executePickingCallback(false) - -- self:refreshContextInput() - -- end - + if self:getIsPicking() then + self:executePickingCallback(false) + end + self:resetUIDeadzones(false) -- g_inputBinding:setContextEventsActive(self.INPUT_CONTEXT_NAME, InputAction.MENU_AXIS_LEFT_RIGHT, true) - - -- self.statusMessages = {} - -- self:updateStatusMessages() end \ No newline at end of file From 53811077b55b3a815783d26c0c5d90a78face278 Mon Sep 17 00:00:00 2001 From: schwiti6190 Date: Fri, 6 Dec 2024 11:30:31 +0000 Subject: [PATCH 07/14] Updated translations --- translations/translation_br.xml | 7 ++++++- translations/translation_cs.xml | 7 ++++++- translations/translation_ct.xml | 7 ++++++- translations/translation_cz.xml | 7 ++++++- translations/translation_da.xml | 7 ++++++- translations/translation_de.xml | 7 ++++++- translations/translation_ea.xml | 7 ++++++- translations/translation_en.xml | 7 ++++++- translations/translation_es.xml | 7 ++++++- translations/translation_fc.xml | 7 ++++++- translations/translation_fi.xml | 7 ++++++- translations/translation_fr.xml | 7 ++++++- translations/translation_hu.xml | 7 ++++++- translations/translation_it.xml | 7 ++++++- translations/translation_jp.xml | 7 ++++++- translations/translation_kr.xml | 7 ++++++- translations/translation_nl.xml | 7 ++++++- translations/translation_no.xml | 7 ++++++- translations/translation_pl.xml | 7 ++++++- translations/translation_pt.xml | 7 ++++++- translations/translation_ro.xml | 7 ++++++- translations/translation_ru.xml | 7 ++++++- translations/translation_sv.xml | 7 ++++++- translations/translation_tr.xml | 7 ++++++- 24 files changed, 144 insertions(+), 24 deletions(-) diff --git a/translations/translation_br.xml b/translations/translation_br.xml index 5a9fcfd2f..7ec959036 100644 --- a/translations/translation_br.xml +++ b/translations/translation_br.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ A rota é salva automaticamente ao fechar o editor e substituir a rota seleciona + + + + @@ -1037,7 +1042,7 @@ Agora sua seleção deve ser semelhante à imagem. - + diff --git a/translations/translation_cs.xml b/translations/translation_cs.xml index c4ff42489..b933d5f1a 100644 --- a/translations/translation_cs.xml +++ b/translations/translation_cs.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ + + + + @@ -1006,7 +1011,7 @@ hud还显示助手工作时堆或思洛存储器的剩余填充水平。 - + diff --git a/translations/translation_ct.xml b/translations/translation_ct.xml index b158f6dde..427174bc6 100644 --- a/translations/translation_ct.xml +++ b/translations/translation_ct.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ + + + + @@ -1006,7 +1011,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_cz.xml b/translations/translation_cz.xml index e32cb9529..fe9c3b671 100644 --- a/translations/translation_cz.xml +++ b/translations/translation_cz.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Trasa se automaticky uloží při zavření editoru a přepíše vybranou trasu. + + + + @@ -1004,7 +1009,7 @@ Nyní by váš výběr měl vypadat podobně jako na obrázku. - + diff --git a/translations/translation_da.xml b/translations/translation_da.xml index 1ff794fb8..5d9b4a0b5 100644 --- a/translations/translation_da.xml +++ b/translations/translation_da.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Ruten gemmes automatisk ved lukning af editoren og tilsidesætter den valgte rut + + + + @@ -1017,7 +1022,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_de.xml b/translations/translation_de.xml index e7ea5cf2f..f00662c9c 100644 --- a/translations/translation_de.xml +++ b/translations/translation_de.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Der Kurs wird beim Schließen automatisch gespeichert und überschrieben. + + + + @@ -1037,7 +1042,7 @@ Das Kreuz sollte jetzt, wie im Bild dargestellt, gelb sein. - + diff --git a/translations/translation_ea.xml b/translations/translation_ea.xml index 863dfda43..e154678db 100644 --- a/translations/translation_ea.xml +++ b/translations/translation_ea.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1014,7 +1019,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_en.xml b/translations/translation_en.xml index 1bc6e3f45..24971fa29 100644 --- a/translations/translation_en.xml +++ b/translations/translation_en.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1052,7 +1057,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_es.xml b/translations/translation_es.xml index 861893038..459a91efb 100644 --- a/translations/translation_es.xml +++ b/translations/translation_es.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ El curso se guarda automáticamente al cerrar el editor y anula el curso selecci + + + + @@ -1015,7 +1020,7 @@ Ahora su selección debería verse similar a la imagen. - + diff --git a/translations/translation_fc.xml b/translations/translation_fc.xml index dbf158946..0622fc9b0 100644 --- a/translations/translation_fc.xml +++ b/translations/translation_fc.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1014,7 +1019,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_fi.xml b/translations/translation_fi.xml index c3092f90a..50d397d02 100644 --- a/translations/translation_fi.xml +++ b/translations/translation_fi.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1014,7 +1019,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_fr.xml b/translations/translation_fr.xml index 1056efbc6..1c4e01fa7 100644 --- a/translations/translation_fr.xml +++ b/translations/translation_fr.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ La course est automatiquement sauvegardée à la fermeture de l'éditeur et remp + + + + @@ -999,7 +1004,7 @@ Votre sélection devrait ressembler à l'illustration ci-contre. - + diff --git a/translations/translation_hu.xml b/translations/translation_hu.xml index d18c2d9f1..181723932 100644 --- a/translations/translation_hu.xml +++ b/translations/translation_hu.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Az útvonal automatikusan mentésre kerül a szerkesztő bezárásakor és felü + + + + @@ -1023,7 +1028,7 @@ A kijelölésnek hasonlónak kell lennie, mint a képen. - + diff --git a/translations/translation_it.xml b/translations/translation_it.xml index bb919755a..b02212c9f 100644 --- a/translations/translation_it.xml +++ b/translations/translation_it.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Il percorso viene salvato automaticamente alla chiusura dell'editor e sovrascriv + + + + @@ -1019,7 +1024,7 @@ Ora la tua selezione dovrebbe essere simile all'immagine. - + diff --git a/translations/translation_jp.xml b/translations/translation_jp.xml index 6379f1ed5..71ce2e52c 100644 --- a/translations/translation_jp.xml +++ b/translations/translation_jp.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1013,7 +1018,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_kr.xml b/translations/translation_kr.xml index c69a4f73f..a4c4aaa20 100644 --- a/translations/translation_kr.xml +++ b/translations/translation_kr.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1014,7 +1019,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_nl.xml b/translations/translation_nl.xml index 551ad119c..94049ca87 100644 --- a/translations/translation_nl.xml +++ b/translations/translation_nl.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1013,7 +1018,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_no.xml b/translations/translation_no.xml index f1bb544b5..1bee07ec0 100644 --- a/translations/translation_no.xml +++ b/translations/translation_no.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1014,7 +1019,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_pl.xml b/translations/translation_pl.xml index 954b1838d..1e5dcae9f 100644 --- a/translations/translation_pl.xml +++ b/translations/translation_pl.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Kurs jest automatycznie zapisywany po zamknięciu edytora i nadpisuje wybrany ku + + + + @@ -983,7 +988,7 @@ Twój wybór powinien wyglądać podobnie do tego zdjęcia. - + diff --git a/translations/translation_pt.xml b/translations/translation_pt.xml index f62d6417f..634f30740 100644 --- a/translations/translation_pt.xml +++ b/translations/translation_pt.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ A rota é guardada automaticamente ao fechar o editor e sobrepõe-se a qualquer + + + + @@ -1008,7 +1013,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_ro.xml b/translations/translation_ro.xml index 2669f47a5..cdbf7c45b 100644 --- a/translations/translation_ro.xml +++ b/translations/translation_ro.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ The course is saved automatically on closing of the editor and overrides the sel + + + + @@ -1014,7 +1019,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_ru.xml b/translations/translation_ru.xml index 4ea80862c..bcc676a1b 100644 --- a/translations/translation_ru.xml +++ b/translations/translation_ru.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ + + + + @@ -1023,7 +1028,7 @@ HUD также показывает оставшийся уровень запо - + diff --git a/translations/translation_sv.xml b/translations/translation_sv.xml index b6881d40d..37136dc99 100644 --- a/translations/translation_sv.xml +++ b/translations/translation_sv.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Banan sparas automatiskt vid stängning av editorn och åsidosätter den valda b + + + + @@ -1011,7 +1016,7 @@ Now your selection should look similar to the image. - + diff --git a/translations/translation_tr.xml b/translations/translation_tr.xml index 4619b668f..75c929cbe 100644 --- a/translations/translation_tr.xml +++ b/translations/translation_tr.xml @@ -156,6 +156,7 @@ + @@ -516,6 +517,10 @@ Editör kapatıldığında kurs otomatik olarak kaydedilir ve seçilen kursu ge + + + + @@ -1011,7 +1016,7 @@ Now your selection should look similar to the image. - + From 68164ea499e4a386be00ccf0b1f44390985533f2 Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 6 Dec 2024 13:50:25 +0100 Subject: [PATCH 08/14] Divide by zero fix and vine generator settings added --- config/MasterTranslations.xml | 4 +++ config/VehicleSettingsSetup.xml | 4 +-- scripts/gui/CoursePlot.lua | 2 +- scripts/gui/pages/CpCourseGeneratorFrame.lua | 26 ++++++++++++++----- .../CpCourseGeneratorSettings.lua | 6 ++--- 5 files changed, 28 insertions(+), 14 deletions(-) diff --git a/config/MasterTranslations.xml b/config/MasterTranslations.xml index da3b6ab31..a6d2c666d 100644 --- a/config/MasterTranslations.xml +++ b/config/MasterTranslations.xml @@ -877,6 +877,10 @@ + + + + diff --git a/config/VehicleSettingsSetup.xml b/config/VehicleSettingsSetup.xml index 386445ff1..4608d3264 100644 --- a/config/VehicleSettingsSetup.xml +++ b/config/VehicleSettingsSetup.xml @@ -123,9 +123,9 @@ + isVisible="isPipeOffsetSettingsVisible" title="CP_deactivated"/> + isVisible="isPipeOffsetSettingsVisible" title="CP_deactivated"/> diff --git a/scripts/gui/CoursePlot.lua b/scripts/gui/CoursePlot.lua index d28c770c8..84cbb94ed 100644 --- a/scripts/gui/CoursePlot.lua +++ b/scripts/gui/CoursePlot.lua @@ -113,8 +113,8 @@ 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 = length > 0 and MathUtil.vector2Normalize(dx, dz) or 0, 1 if startX and startY and endX and endY then local dx2D = endX - startX local dy2D = ( endY - startY ) / g_screenAspectRatio diff --git a/scripts/gui/pages/CpCourseGeneratorFrame.lua b/scripts/gui/pages/CpCourseGeneratorFrame.lua index c2f3f3141..d0e32a6ea 100644 --- a/scripts/gui/pages/CpCourseGeneratorFrame.lua +++ b/scripts/gui/pages/CpCourseGeneratorFrame.lua @@ -5,13 +5,15 @@ CpCourseGeneratorFrame = { CATEGRORIES = { - BASIC_SETTINGS = 1, - IN_GAME_MAP = 2, + IN_GAME_MAP = 1, + BASIC_SETTINGS = 2, + Vine_SETTINGS = 3 }, INPUT_CONTEXT_NAME = "CP_COURSE_GENERATOR_MENU", CATEGRORY_TEXTS = { - "CP_vehicle_courseGeneratorSetting_subTitle_basic", "CP_ingameMenu_map_title", + "CP_vehicle_courseGeneratorSetting_subTitle_basic", + "CP_vehicle_courseGeneratorSetting_subTitle_vineField", }, CLEAR_INPUT_ACTIONS = { InputAction.MENU_ACTIVATE, @@ -155,7 +157,7 @@ function CpCourseGeneratorFrame:initialize(menu) self.subCategoryTabs[key].onClickCallback = function () self:updateSubCategoryPages(key) end - if key == 2 then + if key == self.CATEGRORIES.IN_GAME_MAP then self.subCategoryPages[key] = self.containerMap else self.subCategoryPages[key] = self.containerPrefab:clone(self) @@ -219,7 +221,7 @@ function CpCourseGeneratorFrame:onFrameOpen() local title = string.format(g_i18n:getText(pageTitle), vehicle:getName()) self.categoryHeaderText:setText(title) - local layout = self.subCategoryPages[1]:getDescendantByName("layout") + local layout = self.subCategoryPages[self.CATEGRORIES.BASIC_SETTINGS]:getDescendantByName("layout") for i = #layout.elements, 1, -1 do layout.elements[i]:delete() end @@ -228,6 +230,17 @@ function CpCourseGeneratorFrame:onFrameOpen() self.sectionHeaderPrefab, settings) CpSettingsUtil.updateGuiElementsBoundToSettings(layout, vehicle) + settings = vehicle:getCpVineSettings() + settingsBySubTitle = CpCourseGeneratorSettings.getVineSettingSetup() + layout = self.subCategoryPages[self.CATEGRORIES.Vine_SETTINGS]:getDescendantByName("layout") + for i = #layout.elements, 1, -1 do + layout.elements[i]:delete() + end + CpSettingsUtil.generateAndBindGuiElementsToSettings(settingsBySubTitle, + layout, self.multiTextPrefab, self.booleanPrefab, + self.sectionHeaderPrefab, settings) + CpSettingsUtil.updateGuiElementsBoundToSettings(layout, vehicle) + -- g_messageCenter:subscribe(MessageType.AI_VEHICLE_STATE_CHANGE, self.onAIVehicleStateChanged, self) self.activeWorkerList:reloadData() g_messageCenter:subscribe(MessageType.AI_JOB_STARTED, function(self) @@ -283,8 +296,7 @@ function CpCourseGeneratorFrame:onFrameOpen() self.startJobPending = false self.ingameMap:onOpen() - self:updateSubCategoryPages(self.CATEGRORIES.BASIC_SETTINGS) - FocusManager:setFocus(self.subCategoryPages[self.CATEGRORIES.BASIC_SETTINGS]:getDescendantByName("layout")) + self:updateSubCategoryPages(self.CATEGRORIES.IN_GAME_MAP) CpCourseGeneratorFrame:superClass().onFrameOpen(self) end diff --git a/scripts/specializations/CpCourseGeneratorSettings.lua b/scripts/specializations/CpCourseGeneratorSettings.lua index 3dbeab48f..0e1f2d97d 100644 --- a/scripts/specializations/CpCourseGeneratorSettings.lua +++ b/scripts/specializations/CpCourseGeneratorSettings.lua @@ -199,10 +199,8 @@ function CpCourseGeneratorSettings.getSettingSetup() end function CpCourseGeneratorSettings.getVineSettingSetup(vehicle) - local title = g_i18n:getText(CpCourseGeneratorSettings.vineSettings.pageTitle) - return CpCourseGeneratorSettings.vineSettings.settingsBySubTitle, - vehicle and string.format(title, vehicle:getName()) - or title + return CpCourseGeneratorSettings.vineSettings.settingsBySubTitle, + CpCourseGeneratorSettings.vineSettings.pageTitle end function CpCourseGeneratorSettings:loadSettings(savegame) From a23021f41d7f97fe4609efb7ac53dba1f341705d Mon Sep 17 00:00:00 2001 From: schwiti6190 Date: Fri, 6 Dec 2024 12:50:48 +0000 Subject: [PATCH 09/14] Updated translations --- translations/translation_br.xml | 1 + translations/translation_cs.xml | 1 + translations/translation_ct.xml | 1 + translations/translation_cz.xml | 1 + translations/translation_da.xml | 1 + translations/translation_de.xml | 1 + translations/translation_ea.xml | 1 + translations/translation_en.xml | 1 + translations/translation_es.xml | 1 + translations/translation_fc.xml | 1 + translations/translation_fi.xml | 1 + translations/translation_fr.xml | 1 + translations/translation_hu.xml | 1 + translations/translation_it.xml | 1 + translations/translation_jp.xml | 1 + translations/translation_kr.xml | 1 + translations/translation_nl.xml | 1 + translations/translation_no.xml | 1 + translations/translation_pl.xml | 1 + translations/translation_pt.xml | 1 + translations/translation_ro.xml | 1 + translations/translation_ru.xml | 1 + translations/translation_sv.xml | 1 + translations/translation_tr.xml | 1 + 24 files changed, 24 insertions(+) diff --git a/translations/translation_br.xml b/translations/translation_br.xml index 7ec959036..801f96eb8 100644 --- a/translations/translation_br.xml +++ b/translations/translation_br.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_cs.xml b/translations/translation_cs.xml index b933d5f1a..ddb5cb96c 100644 --- a/translations/translation_cs.xml +++ b/translations/translation_cs.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_ct.xml b/translations/translation_ct.xml index 427174bc6..c52881c74 100644 --- a/translations/translation_ct.xml +++ b/translations/translation_ct.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_cz.xml b/translations/translation_cz.xml index fe9c3b671..bcd516a80 100644 --- a/translations/translation_cz.xml +++ b/translations/translation_cz.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_da.xml b/translations/translation_da.xml index 5d9b4a0b5..d686bf494 100644 --- a/translations/translation_da.xml +++ b/translations/translation_da.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_de.xml b/translations/translation_de.xml index f00662c9c..5c4aebd8f 100644 --- a/translations/translation_de.xml +++ b/translations/translation_de.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_ea.xml b/translations/translation_ea.xml index e154678db..59ebaa33a 100644 --- a/translations/translation_ea.xml +++ b/translations/translation_ea.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_en.xml b/translations/translation_en.xml index 24971fa29..26a786407 100644 --- a/translations/translation_en.xml +++ b/translations/translation_en.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_es.xml b/translations/translation_es.xml index 459a91efb..17c04c9b0 100644 --- a/translations/translation_es.xml +++ b/translations/translation_es.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_fc.xml b/translations/translation_fc.xml index 0622fc9b0..ed65c28d2 100644 --- a/translations/translation_fc.xml +++ b/translations/translation_fc.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_fi.xml b/translations/translation_fi.xml index 50d397d02..a459aad6c 100644 --- a/translations/translation_fi.xml +++ b/translations/translation_fi.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_fr.xml b/translations/translation_fr.xml index 1c4e01fa7..ce644b726 100644 --- a/translations/translation_fr.xml +++ b/translations/translation_fr.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_hu.xml b/translations/translation_hu.xml index 181723932..c6b5b3ebc 100644 --- a/translations/translation_hu.xml +++ b/translations/translation_hu.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_it.xml b/translations/translation_it.xml index b02212c9f..35370492b 100644 --- a/translations/translation_it.xml +++ b/translations/translation_it.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_jp.xml b/translations/translation_jp.xml index 71ce2e52c..5c01b9673 100644 --- a/translations/translation_jp.xml +++ b/translations/translation_jp.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_kr.xml b/translations/translation_kr.xml index a4c4aaa20..1a00b2e15 100644 --- a/translations/translation_kr.xml +++ b/translations/translation_kr.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_nl.xml b/translations/translation_nl.xml index 94049ca87..f6c1bbf06 100644 --- a/translations/translation_nl.xml +++ b/translations/translation_nl.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_no.xml b/translations/translation_no.xml index 1bee07ec0..728234d63 100644 --- a/translations/translation_no.xml +++ b/translations/translation_no.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_pl.xml b/translations/translation_pl.xml index 1e5dcae9f..69f51f670 100644 --- a/translations/translation_pl.xml +++ b/translations/translation_pl.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_pt.xml b/translations/translation_pt.xml index 634f30740..4acfc78a9 100644 --- a/translations/translation_pt.xml +++ b/translations/translation_pt.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_ro.xml b/translations/translation_ro.xml index cdbf7c45b..29693329e 100644 --- a/translations/translation_ro.xml +++ b/translations/translation_ro.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_ru.xml b/translations/translation_ru.xml index bcc676a1b..beb1c0b11 100644 --- a/translations/translation_ru.xml +++ b/translations/translation_ru.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_sv.xml b/translations/translation_sv.xml index 37136dc99..5f9baa879 100644 --- a/translations/translation_sv.xml +++ b/translations/translation_sv.xml @@ -272,6 +272,7 @@ + diff --git a/translations/translation_tr.xml b/translations/translation_tr.xml index 75c929cbe..53dd790ed 100644 --- a/translations/translation_tr.xml +++ b/translations/translation_tr.xml @@ -272,6 +272,7 @@ + From 0464112c68bc6f701a293d5fa0201184eabcc62e Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 6 Dec 2024 14:08:02 +0100 Subject: [PATCH 10/14] Fixes getIsMotorStarted() --- scripts/ai/controllers/MotorController.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/ai/controllers/MotorController.lua b/scripts/ai/controllers/MotorController.lua index d74ccda95..f29909af5 100644 --- a/scripts/ai/controllers/MotorController.lua +++ b/scripts/ai/controllers/MotorController.lua @@ -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 @@ -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 @@ -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 @@ -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() @@ -133,3 +129,7 @@ function MotorController:onFinished() self.implement:setFillUnitIsFilling(false) end end + +function MotorController:getIsStarted() + return self.vehicle:getMotorState() ~= MotorState.OFF +end \ No newline at end of file From 13852fa2ede944ce30ab156c882082060b425fd1 Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 6 Dec 2024 15:49:23 +0100 Subject: [PATCH 11/14] Stupid map fix .. --- scripts/gui/CoursePlot.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/gui/CoursePlot.lua b/scripts/gui/CoursePlot.lua index 84cbb94ed..5c2a1953e 100644 --- a/scripts/gui/CoursePlot.lua +++ b/scripts/gui/CoursePlot.lua @@ -114,7 +114,11 @@ function CoursePlot:drawLineBetween(map, x, z, nx, nz, isHudMap, lineThickness, local endX, endY, _, ev = CpGuiUtil.worldToScreen(map, nx, nz, isHudMap) local dx, dz = nx - x, nz - z local length = MathUtil.vector2Length(dx, dz) - local dirX, dirZ = length > 0 and MathUtil.vector2Normalize(dx, dz) or 0, 1 + 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 From 922e4edaabe0f5beee7378e58fae6f101a8f613b Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 6 Dec 2024 16:02:40 +0100 Subject: [PATCH 12/14] Added Building Collision Flag to the proximity sensor --- scripts/ai/ProximitySensor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ai/ProximitySensor.lua b/scripts/ai/ProximitySensor.lua index da17ae61c..91ab425eb 100644 --- a/scripts/ai/ProximitySensor.lua +++ b/scripts/ai/ProximitySensor.lua @@ -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) From d75af2dfa062efb9c169d59ae502d84ba880697c Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 6 Dec 2024 16:06:49 +0100 Subject: [PATCH 13/14] Added Collision flag building to pathfinder and veritcal proximity sensor --- scripts/ai/ProximitySensor.lua | 2 +- scripts/dev/DevHelper.lua | 2 +- scripts/pathfinder/PathfinderUtil.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ai/ProximitySensor.lua b/scripts/ai/ProximitySensor.lua index 91ab425eb..ef9e00625 100644 --- a/scripts/ai/ProximitySensor.lua +++ b/scripts/ai/ProximitySensor.lua @@ -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, diff --git a/scripts/dev/DevHelper.lua b/scripts/dev/DevHelper.lua index 9255f50fe..06e011cca 100644 --- a/scripts/dev/DevHelper.lua +++ b/scripts/dev/DevHelper.lua @@ -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) diff --git a/scripts/pathfinder/PathfinderUtil.lua b/scripts/pathfinder/PathfinderUtil.lua index 9f189a248..164552fb2 100644 --- a/scripts/pathfinder/PathfinderUtil.lua +++ b/scripts/pathfinder/PathfinderUtil.lua @@ -343,7 +343,7 @@ function PathfinderUtil.CollisionDetector:findCollidingShapes(node, vehicleData, self.collidingShapes = 0 self.collidingShapesText = 'unknown' - 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 overlapBox(x, y + 0.2, z, xRot, yRot, zRot, width, 1, length, 'overlapBoxCallback', self, collisionMask, true, true, true) From 388d1f7b892e236d69a17666b139b08a6dcd6d53 Mon Sep 17 00:00:00 2001 From: David Schwietering Date: Fri, 6 Dec 2024 16:17:38 +0100 Subject: [PATCH 14/14] Added nil check for shovel mode --- scripts/specializations/CpShovelPositions.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/specializations/CpShovelPositions.lua b/scripts/specializations/CpShovelPositions.lua index aa3bc0979..401fd0b04 100644 --- a/scripts/specializations/CpShovelPositions.lua +++ b/scripts/specializations/CpShovelPositions.lua @@ -358,7 +358,6 @@ function CpShovelPositions:setShovelPosition(dt, shovelLimits, armLimits, height local ax, ay, az = localToLocal(armTool.node, armVehicle.rootNode, 0, 0, 0) local wx, _, wz = getWorldTranslation(armVehicle.rootNode) - local function draw(x1, y1, z1, x2, y2, z2, r, g, b) if CpUtil.getCurrentVehicle() == shovelVehicle.rootVehicle and CpDebug:isChannelActive(CpDebug.DBG_SILO, shovelVehicle.rootVehicle) then @@ -445,7 +444,7 @@ function CpShovelPositions:setShovelPosition(dt, shovelLimits, armLimits, height end local alpha, oldRotRelativeArmRot = 0, 0 - if hasIntersection then + if hasIntersection and i1y ~= nil then --- Controls the arm height setTranslation(armProjectionNode, 0, i1y, i1z) setTranslation(armToolRefNode, ax, ay, az)