Skip to content

Commit 76413c2

Browse files
authored
Merge pull request #87 from Courseplay/Gui-Additions
Fixed some leftover hud zoom code
2 parents f6417fe + 94ce381 commit 76413c2

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

scripts/gui/hud/CpBaseHud.lua

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,18 +296,6 @@ function CpBaseHud:init(vehicle)
296296
self:openCourseGeneratorGui(vehicle)
297297
end)
298298

299-
300-
---- Disables zoom, while mouse is over the cp hud.
301-
local function disableCameraZoomOverHud(vehicle, superFunc, ...)
302-
if vehicle.getIsMouseOverCpHud and vehicle:getIsMouseOverCpHud() then
303-
return
304-
end
305-
return superFunc(vehicle, ...)
306-
end
307-
308-
Enterable.actionEventCameraZoomIn = Utils.overwrittenFunction(Enterable.actionEventCameraZoomIn, disableCameraZoomOverHud)
309-
Enterable.actionEventCameraZoomOut = Utils.overwrittenFunction(Enterable.actionEventCameraZoomOut, disableCameraZoomOverHud)
310-
311299
self.baseHud:setVisible(false)
312300

313301
self.baseHud:setScale(self.uiScale, self.uiScale)

scripts/specializations/CpCourseManager.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,13 @@ function CpCourseManager:onWriteStream(streamId,connection)
354354
end
355355

356356
function CpCourseManager:onPreDelete()
357-
g_assignedCoursesManager:unregisterVehicle(self, self.id)
358-
CpCourseManager.resetCourses(self)
359357
local spec = self.spec_cpCourseManager
360-
spec.courseDisplay:delete()
358+
if spec then
359+
g_assignedCoursesManager:unregisterVehicle(self, self.id)
360+
CpCourseManager.resetCourses(self)
361+
local spec = self.spec_cpCourseManager
362+
spec.courseDisplay:delete()
363+
end
361364
end
362365

363366
------------------------------------------------------------------------

scripts/specializations/CpHud.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ function CpHud.registerFunctions(vehicleType)
7878
end
7979

8080
function CpHud.registerOverwrittenFunctions(vehicleType)
81-
if vehicleType.functions["enterVehicleRaycastClickToSwitch"] ~= nil then
81+
if vehicleType.functions["enterVehicleRaycastClickToSwitch"] ~= nil then
8282
SpecializationUtil.registerOverwrittenFunction(vehicleType, "enterVehicleRaycastClickToSwitch", CpHud.enterVehicleRaycastClickToSwitch)
83-
end
84-
SpecializationUtil.registerOverwrittenFunction(vehicleType, 'getCpStartText', CpHud.getCpStartText)
83+
end
84+
SpecializationUtil.registerOverwrittenFunction(vehicleType, 'getCpStartText', CpHud.getCpStartText)
8585
end
8686

8787
--- Disables the click to switch action, while the mouse is over the cp hud.
@@ -104,7 +104,7 @@ function CpHud:onRegisterActionEvents(isActiveForInput, isActiveForInputIgnoreSe
104104
if self.isClient then
105105
local spec = self.spec_cpHud
106106
self:clearActionEventsTable(spec.actionEvents)
107-
if self.isActiveForInputIgnoreSelectionIgnoreAI then
107+
if self.isActiveForInputIgnoreSelectionIgnoreAI and self.propertyState ~= VehiclePropertyState.SHOP_CONFIG then
108108
--- Toggle mouse cursor action event
109109
--- Parameters:
110110
--- (actionEventsTable, inputAction, target,
@@ -312,6 +312,15 @@ function CpHud:onLeaveVehicle(wasEntered)
312312
end
313313
end
314314

315+
---- Disables zoom, while mouse is over the cp hud.
316+
local function actionEventCameraZoomInOut(self, superFunc, ...)
317+
if self.getIsMouseOverCpHud and self:getIsMouseOverCpHud() then
318+
return
319+
end
320+
return superFunc(self, ...)
321+
end
322+
Enterable.actionEventCameraZoomInOut = Utils.overwrittenFunction(Enterable.actionEventCameraZoomInOut, actionEventCameraZoomInOut)
323+
315324
function CpHud:onStateChange(state, data)
316325
local spec = self.spec_cpHud
317326
if state == VehicleStateChange.ATTACH or state == VehicleStateChange.DETACH then

0 commit comments

Comments
 (0)