@@ -9,13 +9,17 @@ Courseplay.baseXmlKey = "Courseplay"
99Courseplay .xmlKey = Courseplay .baseXmlKey .. " ."
1010
1111function Courseplay :init ()
12- g_gui :loadProfiles ( Utils .getFilename (" config/gui/GUIProfiles.xml" , Courseplay .BASE_DIRECTORY ) )
12+ --- TODO_25
13+ -- g_gui:loadProfiles( Utils.getFilename("config/gui/GUIProfiles.xml", Courseplay.BASE_DIRECTORY) )
1314
1415 --- Base cp folder
1516 self .baseDir = getUserProfileAppPath () .. " modSettings/" .. Courseplay .MOD_NAME .. " /"
1617 createFolder (self .baseDir )
1718 --- Base cp folder
1819 self .cpFilePath = self .baseDir .. " courseplay.xml"
20+
21+ g_overlayManager :addTextureConfigFile (Utils .getFilename (" img/iconSprite.xml" , self .BASE_DIRECTORY ), " cpIconSprite" )
22+ g_overlayManager :addTextureConfigFile (Utils .getFilename (" img/ui_courseplay.xml" , self .BASE_DIRECTORY ), " cpUi" )
1923end
2024
2125function Courseplay :registerXmlSchema ()
@@ -24,6 +28,7 @@ function Courseplay:registerXmlSchema()
2428 self .globalSettings :registerXmlSchema (self .xmlSchema , self .xmlKey )
2529 CpBaseHud .registerXmlSchema (self .xmlSchema , self .xmlKey )
2630 CpHudInfoTexts .registerXmlSchema (self .xmlSchema , self .xmlKey )
31+ CpInGameMenu .registerXmlSchema (self .xmlSchema , self .xmlKey )
2732end
2833
2934--- Loads data not tied to a savegame.
@@ -32,8 +37,9 @@ function Courseplay:loadUserSettings()
3237 if xmlFile then
3338 self :showUserInformation (xmlFile , self .baseXmlKey )
3439 self .globalSettings :loadFromXMLFile (xmlFile , self .xmlKey )
40+ g_cpInGameMenu :loadFromXMLFile (xmlFile , self .xmlKey )
3541 CpBaseHud .loadFromXmlFile (xmlFile , self .xmlKey )
36- CpHudInfoTexts . loadFromXmlFile (xmlFile , self .xmlKey )
42+ self . infoTextsHud : loadFromXmlFile (xmlFile , self .xmlKey )
3743 xmlFile :save ()
3844 xmlFile :delete ()
3945 else
@@ -47,10 +53,11 @@ function Courseplay:saveUserSettings()
4753 if xmlFile then
4854 self .globalSettings :saveUserSettingsToXmlFile (xmlFile , self .xmlKey )
4955 CpBaseHud .saveToXmlFile (xmlFile , self .xmlKey )
50- CpHudInfoTexts . saveToXmlFile (xmlFile , self .xmlKey )
56+ self . infoTextsHud : saveToXmlFile (xmlFile , self .xmlKey )
5157 if self .currentVersion then
52- xmlFile :setValue (self .baseXmlKey .. " #lastVersion" , self .currentVersion )
58+ xmlFile :setValue (self .baseXmlKey .. " #lastVersion" , self .currentVersion )
5359 end
60+ g_cpInGameMenu :saveToXMLFile (xmlFile , self .xmlKey )
5461 xmlFile :save ()
5562 xmlFile :delete ()
5663 end
@@ -74,9 +81,7 @@ function Courseplay:showUserInformation(xmlFile, key)
7481 self .MOD_NAME , self .currentVersion , lastLoadedVersion )
7582
7683 if showInfoDialog then
77- g_gui :showInfoDialog ({
78- text = string.format (g_i18n :getText (" CP_infoText" ), self .currentVersion )
79- })
84+ InfoDialog .show (string.format (g_i18n :getText (" CP_infoText" ), self .currentVersion ))
8085 if xmlFile then
8186 xmlFile :setValue (key .. " #lastVersion" , self .currentVersion )
8287 end
9297function Courseplay :loadMap (filename )
9398 self .globalSettings = CpGlobalSettings ()
9499 self :registerXmlSchema ()
95- self :loadUserSettings ()
96100 --- Savegame infos here
97101 CpUtil .info (" Map loaded: %s, Savegame name: %s(%d)" ,
98102 g_currentMission .missionInfo .mapId ,
99103 g_currentMission .missionInfo .savegameName ,
100104 g_currentMission .missionInfo .savegameIndex )
101105 self :load ()
102106 self :setupGui ()
107+ self :loadUserSettings ()
103108 if g_currentMission .missionInfo .savegameDirectory ~= nil then
104109 local saveGamePath = g_currentMission .missionInfo .savegameDirectory .. " /"
105110 local filePath = saveGamePath .. " Courseplay.xml"
106111 self .xmlFile = XMLFile .load (" cpXml" , filePath , self .xmlSchema )
107112 if self .xmlFile == nil then return end
108113 self .globalSettings :loadFromXMLFile (self .xmlFile , g_Courseplay .xmlKey )
109114 self .xmlFile :delete ()
110-
111- g_assignedCoursesManager :loadAssignedCourses (saveGamePath )
112115 end
113116
114117 --- Ugly hack to get access to the global AutoDrive table, as this global is dependent on the auto drive folder name.
115- self .autoDrive = FS22_AutoDrive and FS22_AutoDrive .AutoDrive
118+ self .autoDrive = FS25_AutoDrive and FS25_AutoDrive .AutoDrive
116119 CpUtil .info (" Auto drive found: %s" , tostring (self .autoDrive ~= nil ))
117120
118121 g_courseEditor :load ()
@@ -122,62 +125,32 @@ function Courseplay:deleteMap()
122125 g_courseEditor :delete ()
123126 BufferedCourseDisplay .deleteBuffer ()
124127 g_signPrototypes :delete ()
125- g_devHelper :delete ()
128+ g_consoleCommands :delete ()
126129end
127130
128131function Courseplay :setupGui ()
129- local vehicleSettingsFrame = CpVehicleSettingsFrame .new ()
130- local globalSettingsFrame = CpGlobalSettingsFrame .new ()
131- local courseManagerFrame = CpCourseManagerFrame .new (self .courseStorage )
132- g_gui :loadGui (Utils .getFilename (" config/gui/VehicleSettingsFrame.xml" , Courseplay .BASE_DIRECTORY ),
133- " CpVehicleSettingsFrame" , vehicleSettingsFrame , true )
134- g_gui :loadGui (Utils .getFilename (" config/gui/GlobalSettingsFrame.xml" , Courseplay .BASE_DIRECTORY ),
135- " CpGlobalSettingsFrame" , globalSettingsFrame , true )
136- g_gui :loadGui (Utils .getFilename (" config/gui/CourseManagerFrame.xml" , Courseplay .BASE_DIRECTORY ),
137- " CpCourseManagerFrame" , courseManagerFrame , true )
138- local function predicateFunc ()
139- -- Only allow the vehicle bound pages, when a vehicle with cp functionality is chosen/entered.
140- local vehicle = CpInGameMenuAIFrameExtended .getVehicle ()
141- return vehicle ~= nil and vehicle .spec_cpAIWorker ~= nil
142- end
143-
144- --- As precision farming decided to be moved in between the normal map and the ai map,
145- --- we move it down one position.
146- local pos = g_modIsLoaded [" FS22_precisionFarming" ] and 4 or 3
147-
148- CpGuiUtil .fixInGameMenuPage (vehicleSettingsFrame , " pageCpVehicleSettings" ,
149- {896 , 0 , 128 , 128 }, pos + 1 , predicateFunc )
150- CpGuiUtil .fixInGameMenuPage (globalSettingsFrame , " pageCpGlobalSettings" ,
151- {768 , 0 , 128 , 128 }, pos + 1 , function () return true end )
152- CpGuiUtil .fixInGameMenuPage (courseManagerFrame , " pageCpCourseManager" ,
153- {256 , 0 , 128 , 128 }, pos + 1 , predicateFunc )
132+ CpInGameMenu .setupGui (self .courseStorage )
154133 self .infoTextsHud = CpHudInfoTexts ()
155134
156- g_currentMission .hud .ingameMap .drawFields = Utils .appendedFunction (g_currentMission .hud .ingameMap .drawFields , Courseplay .drawHudMap )
135+ -- TODO_25
136+ -- g_currentMission.hud.ingameMap.drawFields = Utils.appendedFunction(g_currentMission.hud.ingameMap.drawFields, Courseplay.drawHudMap)
157137
138+ -- local page = g_gui.currentGui.target.pageSettings
139+
140+ -- local newPage = page.subCategoryPages[1].copy(page.subCategoryPages[1].parent)
141+ -- self:fixGui()
158142end
159143
160144--- Enables drawing onto the hud map.
161145function Courseplay .drawHudMap (map )
162146 if g_Courseplay .globalSettings .drawOntoTheHudMap :getValue () then
163- local vehicle = g_currentMission . controlledVehicle
147+ local vehicle = CpUtil . getCurrentVehicle ()
164148 if vehicle and vehicle :getIsEntered () and not g_gui :getIsGuiVisible () and vehicle .spec_cpAIWorker and not vehicle .spec_locomotive then
165149 SpecializationUtil .raiseEvent (vehicle , " onCpDrawHudMap" , map )
166150 end
167151 end
168152end
169153
170- --- Adds cp help info to the in game help menu.
171- function Courseplay :loadMapDataHelpLineManager (superFunc , ...)
172- local ret = superFunc (self , ... )
173- if ret then
174- self :loadFromXML (Utils .getFilename (" config/HelpMenu.xml" , Courseplay .BASE_DIRECTORY ))
175- return true
176- end
177- return false
178- end
179- HelpLineManager .loadMapData = Utils .overwrittenFunction ( HelpLineManager .loadMapData , Courseplay .loadMapDataHelpLineManager )
180-
181154--- Saves all global data, for example global settings.
182155function Courseplay .saveToXMLFile (missionInfo )
183156 if missionInfo .isValid then
@@ -208,8 +181,9 @@ function Courseplay:update(dt)
208181 local factor = 2 * mapElement .terrainSize / 2048
209182 mapElement .zoomMax = mapElement .zoomMax * factor
210183 end
211- setIngameMapFix (g_currentMission .inGameMenu .pageAI .ingameMap )
212- setIngameMapFix (g_currentMission .inGameMenu .pageMapOverview .ingameMap )
184+ --- TODO_25
185+ -- setIngameMapFix(g_currentMission.inGameMenu.pageAI.ingameMap)
186+ -- setIngameMapFix(g_currentMission.inGameMenu.pageMapOverview.ingameMap)
213187 end
214188end
215189
234208--- @param button number
235209function Courseplay :mouseEvent (posX , posY , isDown , isUp , button )
236210 if not g_gui :getIsGuiVisible () then
237- local vehicle = g_currentMission . controlledVehicle
211+ local vehicle = CpUtil . getCurrentVehicle ()
238212 local hud = vehicle and vehicle .getCpHud and vehicle :getCpHud ()
239213 if hud then
240214 hud :mouseEvent (posX , posY , isDown , isUp , button )
@@ -276,7 +250,6 @@ function Courseplay:load()
276250 CpAIMessages .register ()
277251 g_vineScanner :setup ()
278252end
279-
280253---- --------------------------------------------------------------------------------------------------------------------
281254-- Player action events
282255---- --------------------------------------------------------------------------------------------------------------------
@@ -352,7 +325,7 @@ function Courseplay.register(typeManager)
352325 CpAICombineUnloader .register (typeManager , typeName , typeEntry .specializations )
353326 CpAISiloLoaderWorker .register (typeManager , typeName , typeEntry .specializations )
354327 CpAIBunkerSiloWorker .register (typeManager , typeName , typeEntry .specializations )
355- CpGamePadHud .register (typeManager , typeName ,typeEntry .specializations )
328+ -- TODO 25 CpGamePadHud.register(typeManager, typeName,typeEntry.specializations)
356329 CpHud .register (typeManager , typeName , typeEntry .specializations )
357330 CpInfoTexts .register (typeManager , typeName , typeEntry .specializations )
358331 CpShovelPositions .register (typeManager , typeName , typeEntry .specializations )
0 commit comments