Skip to content

Commit

Permalink
Disabled course generator with no field work job creation and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
schwiti6190 committed Dec 15, 2024
1 parent abb9134 commit d323f0e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 deletions.
5 changes: 3 additions & 2 deletions config/gui/pages/CourseGeneratorFrame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<ListItem profile="cpInfoTextListElement">
<Bitmap profile="cpInfoTextListElementBg" />
<Text profile="cpInfoTextListElementText" name="text" />
<Button profile="cpInfoTextListElementIcon"/>
<Button profile="cpInfoTextListElementIcon" name="icon"/>
</ListItem>
</SmoothList>
</GuiElement>
Expand Down Expand Up @@ -304,7 +304,8 @@
<absoluteSizeOffset value="3px 3px"/>
<iconSliceId value="cpIconSprite.white_vehicle" />
<iconSize value="20px 20px" />
<iconColor value="$preset_fs25_colorMainHighlight" />
<iconColor value="$preset_fs25_colorGrey" />
<iconSelectedColor value="$preset_fs25_colorMainHighlight" />
</Profile>
<Profile name="cpInfoTextListElementBg" extends="baseReference" with="anchorTopStretchingX">
<imageSliceId value="gui.animalScreen_left" />
Expand Down
3 changes: 3 additions & 0 deletions scripts/gui/CpInGameMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ end

function CpInGameMenu:onCurrentVehicleChanged()
if self:getIsOpen() then
local prevPage = self.pagingElement:getPageElementByIndex(self.currentPageId)
self:updatePages()
local index = self.pagingElement:getPageMappingIndexByElement(prevPage)
self.pagingTabList:setSelectedIndex(index, true, 0)
end
end

Expand Down
55 changes: 31 additions & 24 deletions scripts/gui/pages/CpCourseGeneratorFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,23 +187,9 @@ function CpCourseGeneratorFrame:initialize(menu)
self.currentHotspot = nil
g_messageCenter:subscribe(MessageType.GUI_CP_INGAME_CURRENT_VEHICLE_CHANGED,
function(self, vehicle)
if vehicle then
self.subCategoryPaging:setDisabled(false)
for ix=1, self.NUM_CATEGORIES do
if ix ~= self.CATEGRORIES.IN_GAME_MAP then
self.subCategoryTabs[ix]:setDisabled(false)
end
end
self:updateSettings(vehicle)
else
self:updateSubCategoryPages(self.CATEGRORIES.IN_GAME_MAP)
self.subCategoryPaging:setDisabled(true)
for ix=1, self.NUM_CATEGORIES do
if ix ~= self.CATEGRORIES.IN_GAME_MAP then
self.subCategoryTabs[ix]:setDisabled(true)
end
end
end
local _, pageTitle = CpCourseGeneratorSettings.getSettingSetup()
local title = string.format(g_i18n:getText(pageTitle), vehicle and vehicle:getName() or "--")
self.categoryHeaderText:setText(title)
end, self)
end

Expand Down Expand Up @@ -246,9 +232,7 @@ end

function CpCourseGeneratorFrame:updateSettings(vehicle)
local settings = vehicle:getCourseGeneratorSettings()
local settingsBySubTitle, pageTitle = CpCourseGeneratorSettings.getSettingSetup()
local title = string.format(g_i18n:getText(pageTitle), vehicle:getName())
self.categoryHeaderText:setText(title)
local settingsBySubTitle = CpCourseGeneratorSettings.getSettingSetup()

local layout = self.subCategoryPages[self.CATEGRORIES.BASIC_SETTINGS]:getDescendantByName("layout")
for i = #layout.elements, 1, -1 do
Expand Down Expand Up @@ -343,14 +327,12 @@ function CpCourseGeneratorFrame:onFrameOpen()
self:updateSubCategoryPages(self.CATEGRORIES.IN_GAME_MAP)

CpCourseGeneratorFrame:superClass().onFrameOpen(self)

self:updateCourseGenerator(false)
local vehicle = self.cpMenu:getCurrentVehicle()
if vehicle and self.currentHotspot == nil then
self.subCategoryPaging:setDisabled(false)
self:setAIVehicle(vehicle)
elseif vehicle == nil then
self:updateSubCategoryPages(self.CATEGRORIES.IN_GAME_MAP)
self.subCategoryPaging:setDisabled(true)
self:setMapSelectionItem(nil)
end

Expand Down Expand Up @@ -430,7 +412,7 @@ function CpCourseGeneratorFrame:onClickBack(force)
self:setMapSelectionItem(nil)
elseif self.currentHotspot then
self:setMapSelectionItem(nil)
return not force
return force
end
return true
end
Expand All @@ -439,6 +421,26 @@ function CpCourseGeneratorFrame:onClickCpMultiTextOption(_, guiElement)
CpSettingsUtil.updateGuiElementsBoundToSettings(guiElement.parent.parent, self.cpMenu:getCurrentVehicle())
end

function CpCourseGeneratorFrame:updateCourseGenerator(visible, vehicle)
if visible then
self.subCategoryPaging:setDisabled(false)
for ix=1, self.NUM_CATEGORIES do
if ix ~= self.CATEGRORIES.IN_GAME_MAP then
self.subCategoryTabs[ix]:setDisabled(false)
end
end
self:updateSettings(vehicle)
else
self:updateSubCategoryPages(self.CATEGRORIES.IN_GAME_MAP)
self.subCategoryPaging:setDisabled(true)
for ix=1, self.NUM_CATEGORIES do
if ix ~= self.CATEGRORIES.IN_GAME_MAP then
self.subCategoryTabs[ix]:setDisabled(true)
end
end
end
end

function CpCourseGeneratorFrame:updateSubCategoryPages(state)
for i, _ in ipairs(self.subCategoryPages) do
self.subCategoryPages[i]:setVisible(false)
Expand Down Expand Up @@ -1023,6 +1025,9 @@ function CpCourseGeneratorFrame:populateCellForItemInSection(list, section, inde
cell.onClickCallback = buttonInfo.callback
elseif list == self.infoTextList then
cell:getAttribute("text"):setText(self.activeInfoTexts[index].text)
cell:getAttribute("icon").getIsSelected = function ()
return self.currentHotspot and self.currentHotspot:getVehicle() == self.activeInfoTexts[index].vehicle
end
cell.onClickCallback = function ()
if self:getIsPicking() then
return
Expand Down Expand Up @@ -1365,6 +1370,7 @@ function CpCourseGeneratorFrame:setJobMenuVisible(isVisible)
if not isVisible then
self.currentJob = nil
self.currentJobVehicle = nil
self:updateCourseGenerator(false)
FocusManager:setFocus(self.mapOverviewSelector)
self.mapOverviewSelector:setState(self.MAP_SELECTOR_ACTIVE_JOBS, true)
else
Expand Down Expand Up @@ -1421,6 +1427,7 @@ function CpCourseGeneratorFrame:setActiveJobTypeSelection(jobTypeIndex)
self:validateParameters()
self.jobMenuLayout:invalidateLayout()
FocusManager:setFocus(self.jobTypeElement)
self:updateCourseGenerator(self.currentJob:isa(CpAIJobFieldWork), self.currentJobVehicle)
end
self:updateContextActions()
end
Expand Down

0 comments on commit d323f0e

Please sign in to comment.